[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74CTVYZEMTPYNZ61RXZ9B85":3,"skill-same:01M74CTVYZEMTPYNZ61RXZ9B85":46},{"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":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":31,"install":32,"resources":45},"01M74CTVYZEMTPYNZ61RXZ9B85","gsd-reapply-patches",null,"Reapply local modifications after a GSD update","tamarillo-ai\u002Ftheta","tamarillo-ai","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F264659913?v=4","01M732W8TW61PS979NJ2W4Z6XZ","tamarillo.ai","01M732W8VRBBGT4F0Q3B2HNGTQ",15,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Ftamarillo-ai\u002Ftheta\u002Fblob\u002Fmain\u002Ftest\u002Fcast-fixtures\u002Fcodex-cli\u002Fregression\u002FMarkdownPreview\u002F.codex\u002Fskills\u002Fgsd-reapply-patches\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: \"gsd-reapply-patches\"\ndescription: \"Reapply local modifications after a GSD update\"\nmetadata:\n  short-description: \"Reapply local modifications after a GSD update\"\n---\n\n\u003Ccodex_skill_adapter>\n## A. Skill Invocation\n- This skill is invoked by mentioning `$gsd-reapply-patches`.\n- Treat all user text after `$gsd-reapply-patches` as `{{GSD_ARGS}}`.\n- If no arguments are present, treat `{{GSD_ARGS}}` as empty.\n\n## B. AskUserQuestion → request_user_input Mapping\nGSD workflows use `AskUserQuestion` (Claude Code syntax). Translate to Codex `request_user_input`:\n\nParameter mapping:\n- `header` → `header`\n- `question` → `question`\n- Options formatted as `\"Label\" — description` → `{label: \"Label\", description: \"description\"}`\n- Generate `id` from header: lowercase, replace spaces with underscores\n\nBatched calls:\n- `AskUserQuestion([q1, q2])` → single `request_user_input` with multiple entries in `questions[]`\n\nMulti-select workaround:\n- Codex has no `multiSelect`. Use sequential single-selects, or present a numbered freeform list asking the user to enter comma-separated numbers.\n\nExecute mode fallback:\n- When `request_user_input` is rejected (Execute mode), present a plain-text numbered list and pick a reasonable default.\n\n## C. Task() → spawn_agent Mapping\nGSD workflows use `Task(...)` (Claude Code syntax). Translate to Codex collaboration tools:\n\nDirect mapping:\n- `Task(subagent_type=\"X\", prompt=\"Y\")` → `spawn_agent(agent_type=\"X\", message=\"Y\")`\n- `Task(model=\"...\")` → omit (Codex uses per-role config, not inline model selection)\n- `fork_context: false` by default — GSD agents load their own context via `\u003Cfiles_to_read>` blocks\n\nParallel fan-out:\n- Spawn multiple agents → collect agent IDs → `wait(ids)` for all to complete\n\nResult parsing:\n- Look for structured markers in agent output: `CHECKPOINT`, `PLAN COMPLETE`, `SUMMARY`, etc.\n- `close_agent(id)` after collecting results from each agent\n\u003C\u002Fcodex_skill_adapter>\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=\"C:\u002FUsers\u002Fbarnardh\u002Fsource\u002Frepos\u002FMarkdownPreview\u002F.codex\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` → `C:\u002FUsers\u002Fbarnardh\u002Fsource\u002Frepos\u002FMarkdownPreview\u002F.codex\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","\u003Ccodex_skill_adapter>\n## A. Skill Invocation\n- This skill is invoked by mentioning `$gsd-reapply-patches`.\n- Treat all user text after `$gsd-reapply-patches` as `{{GSD_ARGS}}`.\n- If no arguments are present, treat `{{GSD_ARGS}}` as empty.\n\n## B. AskUserQuestion → request_user_input Mapping\nGSD workflows use `AskUserQuestion` (Claude Code syntax). Translate to Codex `request_user_input`:\n\nParameter mapping:\n- `header` → `header`\n- `question` → `question`\n- Options formatted as `\"Label\" — description` → `{label: \"Label\", description: \"description\"}`\n- Generate `id` from header: lowercase, replace spaces with underscores\n\nBatched calls:\n- `AskUserQuestion([q1, q2])` → single `request_user_input` with multiple entries in `questions[]`\n\nMulti-select workaround:\n- Codex has no `multiSelect`. Use sequential single-selects, or present a numbered freeform list asking the user to enter comma-separated numbers.\n\nExecute mode fallback:\n- When `request_user_input` is rejected (Execute mode), present a plain-text numbered list and pick a reasonable default.\n\n## C. Task() → spawn_agent Mapping\nGSD workflows use `Task(...)` (Claude Code syntax). Translate to Codex collaboration tools:\n\nDirect mapping:\n- `Task(subagent_type=\"X\", prompt=\"Y\")` → `spawn_agent(agent_type=\"X\", message=\"Y\")`\n- `Task(model=\"...\")` → omit (Codex uses per-role config, not inline model selection)\n- `fork_context: false` by default — GSD agents load their own context via `\u003Cfiles_to_read>` blocks\n\nParallel fan-out:\n- Spawn multiple agents → collect agent IDs → `wait(ids)` for all to complete\n\nResult parsing:\n- Look for structured markers in agent output: `CHECKPOINT`, `PLAN COMPLETE`, `SUMMARY`, etc.\n- `close_agent(id)` after collecting results from each agent\n\u003C\u002Fcodex_skill_adapter>\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=\"C:\u002FUsers\u002Fbarnardh\u002Fsource\u002Frepos\u002FMarkdownPreview\u002F.codex\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` → `C:\u002FUsers\u002Fbarnardh\u002Fsource\u002Frepos\u002FMarkdownPreview\u002F.codex\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,"metadata":24,"description":7},{"short-description":7},"main","08c084f718b2b842cd53622ce0b1a1fb2888ccef","test\u002Fcast-fixtures\u002Fcodex-cli\u002Fregression\u002FMarkdownPreview\u002F.codex\u002Fskills\u002Fgsd-reapply-patches",1,"https:\u002F\u002Fgithub.com\u002Ftamarillo-ai\u002Ftheta","https:\u002F\u002Fgithub.com\u002Ftamarillo-ai","2026-07-15 23:48:12",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add tamarillo-ai\u002Ftheta --skill gsd-reapply-patches",{"tool":38,"command":39},"bunx","bunx skills add tamarillo-ai\u002Ftheta --skill gsd-reapply-patches",{"tool":41,"command":42},"pnpm","pnpm dlx skills add tamarillo-ai\u002Ftheta --skill gsd-reapply-patches","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Ftamarillo-ai\u002Ftheta\u002Fblob\u002Fmain\u002Ftest\u002Fcast-fixtures\u002Fcodex-cli\u002Fregression\u002FMarkdownPreview\u002F.codex\u002Fskills\u002Fgsd-reapply-patches\u002FSKILL.md",true,[],[47,54,61,69,76,83],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":19},"01M74FCAJ0RRFRJRQES26329E7","deploy-app","Deploy the application to staging or production environments.","https:\u002F\u002Fgithub.com\u002Ftamarillo-ai\u002Ftheta\u002Fblob\u002Fmain\u002Ftest\u002Fcast-fixtures\u002Fcursor\u002Fskills\u002Fbasic\u002F.cursor\u002Fskills\u002Fdeploy-app\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M74FC8GPJGCS0KTGKS1CJZZS","deploy","Deploy the application to environments.","https:\u002F\u002Fgithub.com\u002Ftamarillo-ai\u002Ftheta\u002Fblob\u002Fmain\u002Ftest\u002Fcast-fixtures\u002Fcursor\u002Fcombined\u002Ffull-config\u002F.cursor\u002Fskills\u002Fdeploy\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":65,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M74FC5RT3VTNZEK1F7NX5380","building-native-ui","Complete guide for building beautiful apps with Expo Router. Covers fundamentals, styling, components, navigation, animations, patterns, and native tabs.","MIT","https:\u002F\u002Fgithub.com\u002Ftamarillo-ai\u002Ftheta\u002Fblob\u002Fmain\u002Ftest\u002Fcast-fixtures\u002Fcopilot\u002Fskills\u002Fwith-references\u002F.github\u002Fskills\u002Fbuilding-native-ui\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M74FC1ZGP5R44HPGWWSW6P3B","create-section","Use when creating a new section for the AI Workshop presentation. Guides through title slide setup, layout choices, and content gathering. Activates when user wants to add a new topic section to the slideshow.","https:\u002F\u002Fgithub.com\u002Ftamarillo-ai\u002Ftheta\u002Fblob\u002Fmain\u002Ftest\u002Fcast-fixtures\u002Fcopilot\u002Fskills\u002Fbasic\u002F.github\u002Fskills\u002Fcreate-section\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M74FBZXSZ7GVP0HCGNR1BVNH","ship-checker","Run a full pre-ship review for this repo. Use when asked if a change is ready to deploy, publish, or ship.","https:\u002F\u002Fgithub.com\u002Ftamarillo-ai\u002Ftheta\u002Fblob\u002Fmain\u002Ftest\u002Fcast-fixtures\u002Fcopilot\u002Fcombined\u002Feverything\u002F.github\u002Fskills\u002Fship-checker\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M74FBY4N2E3ZERWBRM4S3DE6","lint-check","Run repository linters and report failures.","https:\u002F\u002Fgithub.com\u002Ftamarillo-ai\u002Ftheta\u002Fblob\u002Fmain\u002Ftest\u002Fcast-fixtures\u002Fcodex-cli\u002Fskills\u002Fagents-path\u002F.agents\u002Fskills\u002Flint-check\u002FSKILL.md",[],[]]