[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71K6Y9KQ48TTBTPK4QB7KNN":3,"skill-same:01M71K6Y9KQ48TTBTPK4QB7KNN":69},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":40,"linkOnly":41,"markdownContent":42,"markdownBody":43,"frontMatter":44,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":48,"repositoryHtmlUrl":49,"repositoryHomepageUrl":50,"ownerHtmlUrl":51,"ownerBlogUrl":52,"ownerDescription":53,"updatedAt":54,"install":55,"resources":68},"01M71K6Y9KQ48TTBTPK4QB7KNN","gsd-reapply-patches",null,"Use after a GSD update, when local modifications were backed up to gsd-local-patches\u002F and must be merged back. Three-way compares the pristine baseline, the backup, and the new install, flagging conflicts instead of skipping files.","coco-research\u002Fcoco","coco-research","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F68911604?v=4","01M71JRE9C4NM4NSZM4JD0BJTB","Coco Research","01M71JREA0ZMR0PMH3CKA99SN1",631,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fcoco-research\u002Fcoco\u002Fblob\u002Fmain\u002Fsystems\u002Fgsd\u002Fskills\u002Fgsd-reapply-patches\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39],"gsd reapply patches","gsd","update","baseline","backup","install","use","gsd update","up","files","conflicts","back","three","local","when","new","2026-11-10 10:12:30",false,"---\nname: gsd-reapply-patches\ndescription: \"Use after a GSD update, when local modifications were backed up to gsd-local-patches\u002F and must be merged back. Three-way compares the pristine baseline, the backup, and the new install, flagging conflicts instead of skipping files.\"\n---\n\n\n\u003Cpurpose>\nAfter a GSD update wipes and reinstalls files, this command merges user's previously saved local modifications back into the new version. Uses three-way comparison (pristine baseline, user-modified backup, newly installed version) to reliably distinguish user customizations from version drift.\n\n**Critical invariant:** Every file in `gsd-local-patches\u002F` was backed up because the installer's hash comparison detected it was modified. The workflow must NEVER conclude \"no custom content\" for any backed-up file — that is a logical contradiction. When in doubt, classify as CONFLICT requiring user review, not SKIP.\n\u003C\u002Fpurpose>\n\n\u003Cprocess>\n\n## Step 1: Detect backed-up patches\n\nCheck for local patches directory:\n\n```bash\nexpand_home() {\n  case \"$1\" in\n    \"~\u002F\"*) printf '%s\u002F%s\\n' \"$HOME\" \"${1#~\u002F}\" ;;\n    *) printf '%s\\n' \"$1\" ;;\n  esac\n}\n\nPATCHES_DIR=\"\"\n\n# Env overrides first — covers custom config directories used with --config-dir\nif [ -n \"$KILO_CONFIG_DIR\" ]; then\n  candidate=\"$(expand_home \"$KILO_CONFIG_DIR\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nelif [ -n \"$KILO_CONFIG\" ]; then\n  candidate=\"$(dirname \"$(expand_home \"$KILO_CONFIG\")\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nelif [ -n \"$XDG_CONFIG_HOME\" ]; then\n  candidate=\"$(expand_home \"$XDG_CONFIG_HOME\")\u002Fkilo\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nfi\n\nif [ -z \"$PATCHES_DIR\" ] && [ -n \"$OPENCODE_CONFIG_DIR\" ]; then\n  candidate=\"$(expand_home \"$OPENCODE_CONFIG_DIR\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nelif [ -z \"$PATCHES_DIR\" ] && [ -n \"$OPENCODE_CONFIG\" ]; then\n  candidate=\"$(dirname \"$(expand_home \"$OPENCODE_CONFIG\")\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nelif [ -z \"$PATCHES_DIR\" ] && [ -n \"$XDG_CONFIG_HOME\" ]; then\n  candidate=\"$(expand_home \"$XDG_CONFIG_HOME\")\u002Fopencode\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nfi\n\nif [ -z \"$PATCHES_DIR\" ] && [ -n \"$GEMINI_CONFIG_DIR\" ]; then\n  candidate=\"$(expand_home \"$GEMINI_CONFIG_DIR\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nfi\n\nif [ -z \"$PATCHES_DIR\" ] && [ -n \"$CODEX_HOME\" ]; then\n  candidate=\"$(expand_home \"$CODEX_HOME\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nfi\n\nif [ -z \"$PATCHES_DIR\" ] && [ -n \"$CLAUDE_CONFIG_DIR\" ]; then\n  candidate=\"$(expand_home \"$CLAUDE_CONFIG_DIR\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nfi\n\n# Global install — detect runtime config directory defaults\nif [ -z \"$PATCHES_DIR\" ]; then\n  if [ -d \"$HOME\u002F.config\u002Fkilo\u002Fgsd-local-patches\" ]; then\n    PATCHES_DIR=\"$HOME\u002F.config\u002Fkilo\u002Fgsd-local-patches\"\n  elif [ -d \"$HOME\u002F.config\u002Fopencode\u002Fgsd-local-patches\" ]; then\n    PATCHES_DIR=\"$HOME\u002F.config\u002Fopencode\u002Fgsd-local-patches\"\n  elif [ -d \"$HOME\u002F.opencode\u002Fgsd-local-patches\" ]; then\n    PATCHES_DIR=\"$HOME\u002F.opencode\u002Fgsd-local-patches\"\n  elif [ -d \"$HOME\u002F.gemini\u002Fgsd-local-patches\" ]; then\n    PATCHES_DIR=\"$HOME\u002F.gemini\u002Fgsd-local-patches\"\n  elif [ -d \"$HOME\u002F.codex\u002Fgsd-local-patches\" ]; then\n    PATCHES_DIR=\"$HOME\u002F.codex\u002Fgsd-local-patches\"\n  else\n    PATCHES_DIR=\"$HOME\u002F.claude\u002Fgsd-local-patches\"\n  fi\nfi\n# Local install fallback — check all runtime directories\nif [ ! -d \"$PATCHES_DIR\" ]; then\n  for dir in .config\u002Fkilo .kilo .config\u002Fopencode .opencode .gemini .codex .claude; do\n    if [ -d \".\u002F$dir\u002Fgsd-local-patches\" ]; then\n      PATCHES_DIR=\".\u002F$dir\u002Fgsd-local-patches\"\n      break\n    fi\n  done\nfi\n```\n\nRead `backup-meta.json` from the patches directory.\n\n**If no patches found:**\n```\nNo local patches found. Nothing to reapply.\n\nLocal patches are automatically saved when you run \u002Fgsd-update\nafter modifying any GSD workflow, command, or agent files.\n```\nExit.\n\n## Step 2: Determine baseline for three-way comparison\n\nThe quality of the merge depends on having a **pristine baseline** — the original unmodified version of each file from the pre-update GSD release. This enables three-way comparison:\n- **Pristine baseline** (original GSD file before any user edits)\n- **User's version** (backed up in `gsd-local-patches\u002F`)\n- **New version** (freshly installed after update)\n\nCheck for baseline sources in priority order:\n\n### Option A: Git history (most reliable)\nIf the config directory is a git repository:\n```bash\nCONFIG_DIR=$(dirname \"$PATCHES_DIR\")\nif git -C \"$CONFIG_DIR\" rev-parse --git-dir >\u002Fdev\u002Fnull 2>&1; then\n  HAS_GIT=true\nfi\n```\nWhen `HAS_GIT=true`, use `git log` to find the commit where GSD was originally installed (before user edits). For each file, the pristine baseline can be extracted with:\n```bash\ngit -C \"$CONFIG_DIR\" log --diff-filter=A --format=\"%H\" -- \"{file_path}\"\n```\nThis gives the commit that first added the file (the install commit). Extract the pristine version:\n```bash\ngit -C \"$CONFIG_DIR\" show {install_commit}:{file_path}\n```\n\n### Option B: Pristine snapshot directory\nCheck if a `gsd-pristine\u002F` directory exists alongside `gsd-local-patches\u002F`:\n```bash\nPRISTINE_DIR=\"$CONFIG_DIR\u002Fgsd-pristine\"\n```\nIf it exists, the installer saved pristine copies at install time. Use these as the baseline.\n\n### Option C: No baseline available (two-way fallback)\nIf neither git history nor pristine snapshots are available, fall back to two-way comparison — but with **strengthened heuristics** (see Step 3).\n\n## Step 3: Show patch summary\n\n```\n## Local Patches to Reapply\n\n**Backed up from:** v{from_version}\n**Current version:** {read VERSION file}\n**Files modified:** {count}\n**Merge strategy:** {three-way (git) | three-way (pristine) | two-way (enhanced)}\n\n| # | File | Status |\n|---|------|--------|\n| 1 | {file_path} | Pending |\n| 2 | {file_path} | Pending |\n```\n\n## Step 4: Merge each file\n\nFor each file in `backup-meta.json`:\n\n1. **Read the backed-up version** (user's modified copy from `gsd-local-patches\u002F`)\n2. **Read the newly installed version** (current file after update)\n3. **If available, read the pristine baseline** (from git history or `gsd-pristine\u002F`)\n\n### Three-way merge (when baseline is available)\n\nCompare the three versions to isolate changes:\n- **User changes** = diff(pristine → user's version) — these are the customizations to preserve\n- **Upstream changes** = diff(pristine → new version) — these are version updates to accept\n\n**Merge rules:**\n- Sections changed only by user → apply user's version\n- Sections changed only by upstream → accept upstream version\n- Sections changed by both → flag as CONFLICT, show both, ask user\n- Sections unchanged by either → use new version (identical to all three)\n\n### Two-way merge (fallback when no baseline)\n\nWhen no pristine baseline is available, use these **strengthened heuristics**:\n\n**CRITICAL RULE: Every file in this backup directory was explicitly detected as modified by the installer's SHA-256 hash comparison. \"No custom content\" is never a valid conclusion.**\n\nFor each file:\na. Read both versions completely\nb. Identify ALL differences, then classify each as:\n   - **Mechanical drift** — path substitutions (e.g. `\u002FUsers\u002Fxxx\u002F.claude\u002F` → `$HOME\u002F.claude\u002F`), variable additions (`${GSD_WS}`, `${AGENT_SKILLS_*}`), error handling additions (`|| true`)\n   - **User customization** — added steps\u002Fsections, removed sections, reordered content, changed behavior, added frontmatter fields, modified instructions\n\nc. **If ANY differences remain after filtering out mechanical drift → those are user customizations. Merge them.**\nd. **If ALL differences appear to be mechanical drift → still flag as CONFLICT.** The installer's hash check already proved this file was modified. Ask the user: \"This file appears to only have path\u002Fvariable differences. Were there intentional customizations?\" Do NOT silently skip.\n\n### Git-enhanced two-way merge\n\nWhen the config directory is a git repo but the pristine install commit can't be found, use commit history to identify user changes:\n```bash\n# Find non-update commits that touched this file\ngit -C \"$CONFIG_DIR\" log --oneline --no-merges -- \"{file_path}\" | grep -v \"gsd:update\\|GSD update\\|gsd-install\"\n```\nEach matching commit represents an intentional user modification. Use the commit messages and diffs to understand what was changed and why.\n\n4. **Write merged result** to the installed location\n\n### Post-merge verification\n\nAfter writing each merged file, verify that user modifications survived the merge:\n\n1. **Line-count check:** Count lines in the backup and the merged result. If the merged result has fewer lines than the backup minus the expected upstream removals, flag for review.\n2. **Hunk presence check:** For each user-added section identified during diff analysis, search the merged output for at least the first significant line (non-blank, non-comment) of each addition. Missing signature lines indicate a dropped hunk.\n3. **Report warnings inline** (do not block):\n   ```\n   ⚠ Potential dropped content in {file_path}:\n     - Missing hunk near line {N}: \"{first_line_preview}...\" ({line_count} lines)\n     - Backup available: {patches_dir}\u002F{file_path}\n   ```\n4. **Track verification status** — add to per-file report: `Merged (verified)` vs `Merged (⚠ {N} hunks may be missing)`\n\n5. **Report status per file:**\n   - `Merged` — user modifications applied cleanly (show summary of what was preserved)\n   - `Conflict` — user reviewed and chose resolution\n   - `Incorporated` — user's modification was already adopted upstream (only valid when pristine baseline confirms this)\n\n**Never report `Skipped — no custom content`.** If a file is in the backup, it has custom content.\n\n## Step 5: Cleanup option\n\nAsk user:\n- \"Keep patch backups for reference?\" → preserve `gsd-local-patches\u002F`\n- \"Clean up patch backups?\" → remove `gsd-local-patches\u002F` directory\n\n## Step 6: Report\n\n```\n## Patches Reapplied\n\n| # | File | Result | User Changes Preserved |\n|---|------|--------|----------------------|\n| 1 | {file_path} | Merged | Added step X, modified section Y |\n| 2 | {file_path} | Incorporated | Already in upstream v{version} |\n| 3 | {file_path} | Conflict resolved | User chose: keep custom section |\n\n{count} file(s) updated. Your local modifications are active again.\n```\n\n\u003C\u002Fprocess>\n\n\u003Csuccess_criteria>\n- [ ] All backed-up patches processed — zero files left unhandled\n- [ ] No file classified as \"no custom content\" or \"SKIP\" — every backed-up file is definitionally modified\n- [ ] Three-way merge used when pristine baseline available (git history or gsd-pristine\u002F)\n- [ ] User modifications identified and merged into new version\n- [ ] Conflicts surfaced to user with both versions shown\n- [ ] Status reported for each file with summary of what was preserved\n- [ ] Post-merge verification checks each file for dropped hunks and warns if content appears missing\n\u003C\u002Fsuccess_criteria>\n","\u003Cpurpose>\nAfter a GSD update wipes and reinstalls files, this command merges user's previously saved local modifications back into the new version. Uses three-way comparison (pristine baseline, user-modified backup, newly installed version) to reliably distinguish user customizations from version drift.\n\n**Critical invariant:** Every file in `gsd-local-patches\u002F` was backed up because the installer's hash comparison detected it was modified. The workflow must NEVER conclude \"no custom content\" for any backed-up file — that is a logical contradiction. When in doubt, classify as CONFLICT requiring user review, not SKIP.\n\u003C\u002Fpurpose>\n\n\u003Cprocess>\n\n## Step 1: Detect backed-up patches\n\nCheck for local patches directory:\n\n```bash\nexpand_home() {\n  case \"$1\" in\n    \"~\u002F\"*) printf '%s\u002F%s\\n' \"$HOME\" \"${1#~\u002F}\" ;;\n    *) printf '%s\\n' \"$1\" ;;\n  esac\n}\n\nPATCHES_DIR=\"\"\n\n# Env overrides first — covers custom config directories used with --config-dir\nif [ -n \"$KILO_CONFIG_DIR\" ]; then\n  candidate=\"$(expand_home \"$KILO_CONFIG_DIR\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nelif [ -n \"$KILO_CONFIG\" ]; then\n  candidate=\"$(dirname \"$(expand_home \"$KILO_CONFIG\")\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nelif [ -n \"$XDG_CONFIG_HOME\" ]; then\n  candidate=\"$(expand_home \"$XDG_CONFIG_HOME\")\u002Fkilo\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nfi\n\nif [ -z \"$PATCHES_DIR\" ] && [ -n \"$OPENCODE_CONFIG_DIR\" ]; then\n  candidate=\"$(expand_home \"$OPENCODE_CONFIG_DIR\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nelif [ -z \"$PATCHES_DIR\" ] && [ -n \"$OPENCODE_CONFIG\" ]; then\n  candidate=\"$(dirname \"$(expand_home \"$OPENCODE_CONFIG\")\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nelif [ -z \"$PATCHES_DIR\" ] && [ -n \"$XDG_CONFIG_HOME\" ]; then\n  candidate=\"$(expand_home \"$XDG_CONFIG_HOME\")\u002Fopencode\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nfi\n\nif [ -z \"$PATCHES_DIR\" ] && [ -n \"$GEMINI_CONFIG_DIR\" ]; then\n  candidate=\"$(expand_home \"$GEMINI_CONFIG_DIR\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nfi\n\nif [ -z \"$PATCHES_DIR\" ] && [ -n \"$CODEX_HOME\" ]; then\n  candidate=\"$(expand_home \"$CODEX_HOME\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nfi\n\nif [ -z \"$PATCHES_DIR\" ] && [ -n \"$CLAUDE_CONFIG_DIR\" ]; then\n  candidate=\"$(expand_home \"$CLAUDE_CONFIG_DIR\")\u002Fgsd-local-patches\"\n  if [ -d \"$candidate\" ]; then\n    PATCHES_DIR=\"$candidate\"\n  fi\nfi\n\n# Global install — detect runtime config directory defaults\nif [ -z \"$PATCHES_DIR\" ]; then\n  if [ -d \"$HOME\u002F.config\u002Fkilo\u002Fgsd-local-patches\" ]; then\n    PATCHES_DIR=\"$HOME\u002F.config\u002Fkilo\u002Fgsd-local-patches\"\n  elif [ -d \"$HOME\u002F.config\u002Fopencode\u002Fgsd-local-patches\" ]; then\n    PATCHES_DIR=\"$HOME\u002F.config\u002Fopencode\u002Fgsd-local-patches\"\n  elif [ -d \"$HOME\u002F.opencode\u002Fgsd-local-patches\" ]; then\n    PATCHES_DIR=\"$HOME\u002F.opencode\u002Fgsd-local-patches\"\n  elif [ -d \"$HOME\u002F.gemini\u002Fgsd-local-patches\" ]; then\n    PATCHES_DIR=\"$HOME\u002F.gemini\u002Fgsd-local-patches\"\n  elif [ -d \"$HOME\u002F.codex\u002Fgsd-local-patches\" ]; then\n    PATCHES_DIR=\"$HOME\u002F.codex\u002Fgsd-local-patches\"\n  else\n    PATCHES_DIR=\"$HOME\u002F.claude\u002Fgsd-local-patches\"\n  fi\nfi\n# Local install fallback — check all runtime directories\nif [ ! -d \"$PATCHES_DIR\" ]; then\n  for dir in .config\u002Fkilo .kilo .config\u002Fopencode .opencode .gemini .codex .claude; do\n    if [ -d \".\u002F$dir\u002Fgsd-local-patches\" ]; then\n      PATCHES_DIR=\".\u002F$dir\u002Fgsd-local-patches\"\n      break\n    fi\n  done\nfi\n```\n\nRead `backup-meta.json` from the patches directory.\n\n**If no patches found:**\n```\nNo local patches found. Nothing to reapply.\n\nLocal patches are automatically saved when you run \u002Fgsd-update\nafter modifying any GSD workflow, command, or agent files.\n```\nExit.\n\n## Step 2: Determine baseline for three-way comparison\n\nThe quality of the merge depends on having a **pristine baseline** — the original unmodified version of each file from the pre-update GSD release. This enables three-way comparison:\n- **Pristine baseline** (original GSD file before any user edits)\n- **User's version** (backed up in `gsd-local-patches\u002F`)\n- **New version** (freshly installed after update)\n\nCheck for baseline sources in priority order:\n\n### Option A: Git history (most reliable)\nIf the config directory is a git repository:\n```bash\nCONFIG_DIR=$(dirname \"$PATCHES_DIR\")\nif git -C \"$CONFIG_DIR\" rev-parse --git-dir >\u002Fdev\u002Fnull 2>&1; then\n  HAS_GIT=true\nfi\n```\nWhen `HAS_GIT=true`, use `git log` to find the commit where GSD was originally installed (before user edits). For each file, the pristine baseline can be extracted with:\n```bash\ngit -C \"$CONFIG_DIR\" log --diff-filter=A --format=\"%H\" -- \"{file_path}\"\n```\nThis gives the commit that first added the file (the install commit). Extract the pristine version:\n```bash\ngit -C \"$CONFIG_DIR\" show {install_commit}:{file_path}\n```\n\n### Option B: Pristine snapshot directory\nCheck if a `gsd-pristine\u002F` directory exists alongside `gsd-local-patches\u002F`:\n```bash\nPRISTINE_DIR=\"$CONFIG_DIR\u002Fgsd-pristine\"\n```\nIf it exists, the installer saved pristine copies at install time. Use these as the baseline.\n\n### Option C: No baseline available (two-way fallback)\nIf neither git history nor pristine snapshots are available, fall back to two-way comparison — but with **strengthened heuristics** (see Step 3).\n\n## Step 3: Show patch summary\n\n```\n## Local Patches to Reapply\n\n**Backed up from:** v{from_version}\n**Current version:** {read VERSION file}\n**Files modified:** {count}\n**Merge strategy:** {three-way (git) | three-way (pristine) | two-way (enhanced)}\n\n| # | File | Status |\n|---|------|--------|\n| 1 | {file_path} | Pending |\n| 2 | {file_path} | Pending |\n```\n\n## Step 4: Merge each file\n\nFor each file in `backup-meta.json`:\n\n1. **Read the backed-up version** (user's modified copy from `gsd-local-patches\u002F`)\n2. **Read the newly installed version** (current file after update)\n3. **If available, read the pristine baseline** (from git history or `gsd-pristine\u002F`)\n\n### Three-way merge (when baseline is available)\n\nCompare the three versions to isolate changes:\n- **User changes** = diff(pristine → user's version) — these are the customizations to preserve\n- **Upstream changes** = diff(pristine → new version) — these are version updates to accept\n\n**Merge rules:**\n- Sections changed only by user → apply user's version\n- Sections changed only by upstream → accept upstream version\n- Sections changed by both → flag as CONFLICT, show both, ask user\n- Sections unchanged by either → use new version (identical to all three)\n\n### Two-way merge (fallback when no baseline)\n\nWhen no pristine baseline is available, use these **strengthened heuristics**:\n\n**CRITICAL RULE: Every file in this backup directory was explicitly detected as modified by the installer's SHA-256 hash comparison. \"No custom content\" is never a valid conclusion.**\n\nFor each file:\na. Read both versions completely\nb. Identify ALL differences, then classify each as:\n   - **Mechanical drift** — path substitutions (e.g. `\u002FUsers\u002Fxxx\u002F.claude\u002F` → `$HOME\u002F.claude\u002F`), variable additions (`${GSD_WS}`, `${AGENT_SKILLS_*}`), error handling additions (`|| true`)\n   - **User customization** — added steps\u002Fsections, removed sections, reordered content, changed behavior, added frontmatter fields, modified instructions\n\nc. **If ANY differences remain after filtering out mechanical drift → those are user customizations. Merge them.**\nd. **If ALL differences appear to be mechanical drift → still flag as CONFLICT.** The installer's hash check already proved this file was modified. Ask the user: \"This file appears to only have path\u002Fvariable differences. Were there intentional customizations?\" Do NOT silently skip.\n\n### Git-enhanced two-way merge\n\nWhen the config directory is a git repo but the pristine install commit can't be found, use commit history to identify user changes:\n```bash\n# Find non-update commits that touched this file\ngit -C \"$CONFIG_DIR\" log --oneline --no-merges -- \"{file_path}\" | grep -v \"gsd:update\\|GSD update\\|gsd-install\"\n```\nEach matching commit represents an intentional user modification. Use the commit messages and diffs to understand what was changed and why.\n\n4. **Write merged result** to the installed location\n\n### Post-merge verification\n\nAfter writing each merged file, verify that user modifications survived the merge:\n\n1. **Line-count check:** Count lines in the backup and the merged result. If the merged result has fewer lines than the backup minus the expected upstream removals, flag for review.\n2. **Hunk presence check:** For each user-added section identified during diff analysis, search the merged output for at least the first significant line (non-blank, non-comment) of each addition. Missing signature lines indicate a dropped hunk.\n3. **Report warnings inline** (do not block):\n   ```\n   ⚠ Potential dropped content in {file_path}:\n     - Missing hunk near line {N}: \"{first_line_preview}...\" ({line_count} lines)\n     - Backup available: {patches_dir}\u002F{file_path}\n   ```\n4. **Track verification status** — add to per-file report: `Merged (verified)` vs `Merged (⚠ {N} hunks may be missing)`\n\n5. **Report status per file:**\n   - `Merged` — user modifications applied cleanly (show summary of what was preserved)\n   - `Conflict` — user reviewed and chose resolution\n   - `Incorporated` — user's modification was already adopted upstream (only valid when pristine baseline confirms this)\n\n**Never report `Skipped — no custom content`.** If a file is in the backup, it has custom content.\n\n## Step 5: Cleanup option\n\nAsk user:\n- \"Keep patch backups for reference?\" → preserve `gsd-local-patches\u002F`\n- \"Clean up patch backups?\" → remove `gsd-local-patches\u002F` directory\n\n## Step 6: Report\n\n```\n## Patches Reapplied\n\n| # | File | Result | User Changes Preserved |\n|---|------|--------|----------------------|\n| 1 | {file_path} | Merged | Added step X, modified section Y |\n| 2 | {file_path} | Incorporated | Already in upstream v{version} |\n| 3 | {file_path} | Conflict resolved | User chose: keep custom section |\n\n{count} file(s) updated. Your local modifications are active again.\n```\n\n\u003C\u002Fprocess>\n\n\u003Csuccess_criteria>\n- [ ] All backed-up patches processed — zero files left unhandled\n- [ ] No file classified as \"no custom content\" or \"SKIP\" — every backed-up file is definitionally modified\n- [ ] Three-way merge used when pristine baseline available (git history or gsd-pristine\u002F)\n- [ ] User modifications identified and merged into new version\n- [ ] Conflicts surfaced to user with both versions shown\n- [ ] Status reported for each file with summary of what was preserved\n- [ ] Post-merge verification checks each file for dropped hunks and warns if content appears missing\n\u003C\u002Fsuccess_criteria>\n",{"name":5,"description":7},"main","cd89f013b617f7eea982a9bbc60e992974fda2aa","systems\u002Fgsd\u002Fskills\u002Fgsd-reapply-patches",15,"https:\u002F\u002Fgithub.com\u002Fcoco-research\u002Fcoco","https:\u002F\u002Fcocoresearch.org\u002Fcoco\u002F","https:\u002F\u002Fgithub.com\u002Fcoco-research","https:\u002F\u002Fcocoresearch.org","Local-first, open-source tools for people who work with AI agents: governed memory, agents that check their own work, and data that stays on your machine.","2026-11-11 12:18:13",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add coco-research\u002Fcoco --skill gsd-reapply-patches",{"tool":61,"command":62},"bunx","bunx skills add coco-research\u002Fcoco --skill gsd-reapply-patches",{"tool":64,"command":65},"pnpm","pnpm dlx skills add coco-research\u002Fcoco --skill gsd-reapply-patches","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fcoco-research\u002Fcoco\u002Fblob\u002Fmain\u002Fsystems\u002Fgsd\u002Fskills\u002Fgsd-reapply-patches\u002FSKILL.md",true,[],[70,94,104,122,157,176],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":77,"publishedAt":40},"01M71KEJXF9KMT0BWCMRSRFA4M","trading-super-intelligence","Trading Super Intelligence Team. Named real-world personas across 8 cells. Built local-first (LM Studio) and validator-gated. Illustrative composites; see DISCLAIMER.md.","https:\u002F\u002Fgithub.com\u002Fcoco-research\u002Fcoco\u002Fblob\u002Fmain\u002Fsystems\u002Fsuperintelligence\u002Ftrading\u002FSKILL.md",[76],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[78,79,80,81,82,83,37,84,85,86,87,88,89,90,91,92,93],"super","trading super intelligence","intelligence","trading","validator","personas","composites","studio","team","across","world","first","gated","2026","lm studio","local-first",{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":101,"publishedAt":40},"01M71KEFWS3CMAP7DF1P0FWTDE","strategy-super-intelligence","Strategy Super Intelligence Team. Named real-world personas across 7 cells. Built local-first (LM Studio) and validator-gated. Illustrative composites; see DISCLAIMER.md.","https:\u002F\u002Fgithub.com\u002Fcoco-research\u002Fcoco\u002Fblob\u002Fmain\u002Fsystems\u002Fsuperintelligence\u002Fstrategy\u002FSKILL.md",[100],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[102,78,103,80,82,83,37,84,85,86,87,88,89,90,91,92,93],"strategy","strategy super intelligence",{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":116,"publishedAt":40},"01M71KED56ZEPK2QE84QSQPMT0","risk-compliance-super-intelligence","Risk & Compliance (GRC) Super Intelligence Team. Named real-world personas across 7 cells. Built local-first (LM Studio) and validator-gated. Illustrative composites; see DISCLAIMER.md.","https:\u002F\u002Fgithub.com\u002Fcoco-research\u002Fcoco\u002Fblob\u002Fmain\u002Fsystems\u002Fsuperintelligence\u002Frisk-compliance\u002FSKILL.md",[110,111],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":112,"categoryName":113,"taxonomyType":114,"taxonomyTypeDesc":115},"01JBSEEDCAT000000000000037","律师与法务","PROFESSION","适用职业",[117,78,118,119,120,80,82,83,37,84,121,85,86,87,88,89,90,91,92,93],"risk","risk compliance super intelligence","compliance","risk compliance","grc",{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":126,"categories":127,"keywords":141,"publishedAt":40},"01M71KE9A2FWSC74VA96W1EZSN","product-design-super-intelligence","Your product + design brain trust and decision partner. Named personas across 8 cells spanning product strategy, discovery\u002Fresearch, growth\u002Fmetrics, design foundations\u002Fusability, design leadership\u002Fcraft, UX\u002Fcontent, design systems, and a…","https:\u002F\u002Fgithub.com\u002Fcoco-research\u002Fcoco\u002Fblob\u002Fmain\u002Fsystems\u002Fsuperintelligence\u002Fproduct-design\u002FSKILL.md",[128,131,134,135,138],{"categoryNo":129,"categoryName":130,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":132,"categoryName":133,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000021","资料检索与研究",{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":136,"categoryName":137,"taxonomyType":114,"taxonomyTypeDesc":115},"01JBSEEDCAT000000000000031","产品经理",{"categoryNo":139,"categoryName":140,"taxonomyType":114,"taxonomyTypeDesc":115},"01JBSEEDCAT000000000000032","设计师",[142,143,80,144,78,145,146,147,148,149,150,86,87,151,152,91,153,154,155,156],"design","product","product design","product design super intelligence","foundations","product-design","decision","design systems","usability","leadership","ux","brain","craft","metrics","trust",{"skillNo":158,"name":159,"nameZh":6,"description":160,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":161,"categories":162,"keywords":165,"publishedAt":40},"01M71KE6H9FPSD9TECYFBPXZ8Y","legal-ip-super-intelligence","Your legal, IP, and regulatory brain trust. 31 named personas across 7 cells covering patent strategy, tech licensing, regulatory litigation, AI governance, open-source compliance, privacy law, and antitrust.","https:\u002F\u002Fgithub.com\u002Fcoco-research\u002Fcoco\u002Fblob\u002Fmain\u002Fsystems\u002Fsuperintelligence\u002Flegal-ip\u002FSKILL.md",[163,164],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":112,"categoryName":113,"taxonomyType":114,"taxonomyTypeDesc":115},[166,78,167,80,168,169,156,170,83,171,172,173,102,86,87,174,119,175,91,153],"ip","legal ip super intelligence","legal","sep","tech","litigation","ai governance","open","open-source","governance",{"skillNo":177,"name":178,"nameZh":6,"description":179,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":180,"categories":181,"keywords":183,"publishedAt":40},"01M71KE36QRY610V6YVB9JWRND","healthcare-life-sciences-super-intelligence","Your healthcare and life sciences brain trust. 25 named personas across 7 cells covering drug discovery, medtech, biotech strategy, health policy, genomics, clinical trials, and healthcare economics.","https:\u002F\u002Fgithub.com\u002Fcoco-research\u002Fcoco\u002Fblob\u002Fmain\u002Fsystems\u002Fsuperintelligence\u002Fhealthcare-life-sciences\u002FSKILL.md",[182],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[184,78,185,186,80,169,156,187,188,83,189,190,102,86,87,191,192,193,194,91],"healthcare","healthcare life sciences super intelligence","life","economics","discovery","policy","clinical","clinical trials","health","trials","genomics"]