{"version":3,"sources":["../../../src/registration/__tests__/transform.test.ts","../../../src/registration/assets.ts"],"sourcesContent":["import { describe, it } from 'node:test'\nimport assert from 'node:assert/strict'\nimport { transformContent } from '../assets.js'\n\nconst TEST_HOME = '/Users/test/.claude/gsd-munch'\n\ndescribe('transformContent', () => {\n  describe('Pattern 1: bash-invoked gsd-tools path', () => {\n    it('replaces \"$HOME/.claude/get-shit-done/bin/gsd-tools.cjs\" with absolute gsd-munch path', () => {\n      const input = 'node \"$HOME/.claude/get-shit-done/bin/gsd-tools.cjs\" init'\n      const output = transformContent(input, TEST_HOME)\n      assert.equal(output, `node \"${TEST_HOME}/bin/gsd-tools.cjs\" init`)\n    })\n\n    it('replaces all occurrences of the bash-invoked path', () => {\n      const input = [\n        'node \"$HOME/.claude/get-shit-done/bin/gsd-tools.cjs\" init',\n        'node \"$HOME/.claude/get-shit-done/bin/gsd-tools.cjs\" state load',\n      ].join('\\n')\n      const output = transformContent(input, TEST_HOME)\n      assert.ok(!output.includes('get-shit-done'), 'Output must not contain get-shit-done')\n      assert.equal(output.split(`${TEST_HOME}/bin/gsd-tools.cjs`).length - 1, 2)\n    })\n  })\n\n  describe('Pattern 2: .claude/get-shit-done/ path fragments', () => {\n    it('replaces @-reference absolute paths with gsd-munch home path', () => {\n      const input = '@/Users/danieltopham/.claude/get-shit-done/workflows/plan-phase.md'\n      const output = transformContent(input, TEST_HOME)\n      assert.equal(output, `@${TEST_HOME}/workflows/plan-phase.md`)\n    })\n\n    it('replaces get-shit-done path fragments in general absolute paths', () => {\n      const input = '/Users/danieltopham/.claude/get-shit-done/references/checkpoints.md'\n      const output = transformContent(input, TEST_HOME)\n      assert.equal(output, `${TEST_HOME}/references/checkpoints.md`)\n    })\n\n    it('replaces multiple @-references in the same content', () => {\n      const input = [\n        '@/Users/danieltopham/.claude/get-shit-done/workflows/plan-phase.md',\n        '@/Users/danieltopham/.claude/get-shit-done/references/ui-brand.md',\n      ].join('\\n')\n      const output = transformContent(input, TEST_HOME)\n      assert.ok(!output.includes('get-shit-done'), 'Output must not contain get-shit-done')\n    })\n  })\n\n  describe('Pattern 3: /gsd: command namespace', () => {\n    it('replaces /gsd: command references with /gm:', () => {\n      const input = 'run /gsd:research-phase before /gsd:plan-phase'\n      const output = transformContent(input, TEST_HOME)\n      assert.equal(output, 'run /gm:research-phase before /gm:plan-phase')\n    })\n\n    it('replaces all /gsd: occurrences', () => {\n      const input = 'Use /gsd:new-project, /gsd:plan-phase, /gsd:execute-phase'\n      const output = transformContent(input, TEST_HOME)\n      assert.equal(output, 'Use /gm:new-project, /gm:plan-phase, /gm:execute-phase')\n      assert.ok(!output.includes('/gsd:'), 'Output must not contain /gsd:')\n    })\n  })\n\n  describe('Pattern 4: name: gsd: frontmatter field', () => {\n    it('replaces \"name: gsd:\" frontmatter with \"name: gm:\"', () => {\n      const input = 'name: gsd:plan-phase'\n      const output = transformContent(input, TEST_HOME)\n      assert.equal(output, 'name: gm:plan-phase')\n    })\n\n    it('replaces name: gsd: in multiline frontmatter', () => {\n      const input = '---\\nname: gsd:plan-phase\\ndescription: Create phase plans\\n---'\n      const output = transformContent(input, TEST_HOME)\n      assert.ok(output.includes('name: gm:plan-phase'), 'name field should use gm: prefix')\n      assert.ok(!output.includes('name: gsd:'), 'Output must not contain name: gsd:')\n    })\n  })\n\n  describe('no-op cases', () => {\n    it('returns content unchanged when no patterns match', () => {\n      const input = 'Hello, world! This content has no matching patterns.'\n      const output = transformContent(input, TEST_HOME)\n      assert.equal(output, input)\n    })\n\n    it('handles empty string', () => {\n      const output = transformContent('', TEST_HOME)\n      assert.equal(output, '')\n    })\n  })\n\n  describe('combined patterns', () => {\n    it('applies all replacements when all patterns are present', () => {\n      const input = [\n        'node \"$HOME/.claude/get-shit-done/bin/gsd-tools.cjs\" init',\n        '@/Users/danieltopham/.claude/get-shit-done/workflows/plan-phase.md',\n        'run /gsd:research-phase',\n        'name: gsd:plan-phase',\n      ].join('\\n')\n      const output = transformContent(input, TEST_HOME)\n      assert.ok(!output.includes('get-shit-done'), 'Output must not contain get-shit-done after transformation')\n      assert.ok(!output.includes('/gsd:'), 'Output must not contain /gsd:')\n      assert.ok(output.includes(`\"${TEST_HOME}/bin/gsd-tools.cjs\"`), 'Should have absolute gsd-tools path')\n      assert.ok(output.includes(`@${TEST_HOME}/workflows/plan-phase.md`), 'Should have transformed @-ref')\n      assert.ok(output.includes('/gm:research-phase'), 'Should have /gm: namespace')\n      assert.ok(output.includes('name: gm:plan-phase'), 'Should have gm: name field')\n    })\n\n    it('critical: no deployed output contains the string get-shit-done', () => {\n      const sampleWorkflowContent = `---\nname: gsd:execute-phase\ndescription: Execute a phase plan\n---\n<objective>\nExecute the plan.\n</objective>\n\n<execution_context>\n@/Users/danieltopham/.claude/get-shit-done/workflows/execute-plan.md\n</execution_context>\n\n\\`\\`\\`bash\nINIT=$(node \"$HOME/.claude/get-shit-done/bin/gsd-tools.cjs\" init execute-phase)\n\\`\\`\\`\n\nAfter done, run /gsd:verify-work.\n`\n      const output = transformContent(sampleWorkflowContent, TEST_HOME)\n      assert.ok(\n        !output.includes('get-shit-done'),\n        `Output must not contain \"get-shit-done\". Found in: ${output}`\n      )\n    })\n  })\n})\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport os from 'node:os'\n\n/**\n * Returns the stable gsd-munch home directory path.\n * Mirrors upstream GSD's ~/.claude/get-shit-done/ pattern.\n */\nexport function getGsdMunchHome(): string {\n  return path.join(os.homedir(), '.claude', 'gsd-munch')\n}\n\n/**\n * Returns the package root directory (one level above dist/).\n */\nexport function getPkgRoot(): string {\n  return path.resolve(__dirname, '..')\n}\n\n/**\n * Transforms file content by replacing all upstream GSD path references\n * with the gsd-munch equivalents. Three passes in order:\n *\n * 1. Replace bash-invoked gsd-tools path (shell expansion not available in @-refs)\n * 2. Replace any remaining get-shit-done path fragments (catches @-refs and absolute paths)\n * 3. Replace /gsd: command namespace with /gm:\n * 4. Replace name: gsd: frontmatter field with name: gm:\n *\n * CRITICAL: After transformation, output must not contain 'get-shit-done'.\n */\nexport function transformContent(content: string, gsdMunchHome: string): string {\n  return content\n    // Pass 1: Replace bash-invoked gsd-tools path (quoted shell invocation)\n    .replaceAll(\n      '\"$HOME/.claude/get-shit-done/bin/gsd-tools.cjs\"',\n      `\"${gsdMunchHome}/bin/gsd-tools.cjs\"`\n    )\n    // Pass 2: Replace any remaining get-shit-done path fragments\n    // Matches paths like @/Users/foo/.claude/get-shit-done/ or /Users/foo/.claude/get-shit-done/\n    // Uses a capture group to preserve any leading @ character from @-references\n    .replaceAll(\n      /(@?)\\/[^\\s\"']*\\.claude\\/get-shit-done\\//g,\n      `$1${gsdMunchHome}/`\n    )\n    // Pass 3: Replace name: gsd: frontmatter field\n    .replaceAll('name: gsd:', 'name: gm:')\n    // Pass 4: Replace /gsd: command namespace references\n    .replaceAll('/gsd:', '/gm:')\n}\n\n/**\n * Recursively copies files from srcDir to destDir, applying transformer to each file's content.\n * Creates destDir if it doesn't exist.\n */\nexport async function deployDirectory(\n  srcDir: string,\n  destDir: string,\n  transformer: (content: string) => string\n): Promise<void> {\n  fs.mkdirSync(destDir, { recursive: true })\n  const entries = fs.readdirSync(srcDir, { withFileTypes: true })\n  for (const entry of entries) {\n    const srcPath = path.join(srcDir, entry.name)\n    const destPath = path.join(destDir, entry.name)\n    if (entry.isDirectory()) {\n      await deployDirectory(srcPath, destPath, transformer)\n    } else {\n      const content = fs.readFileSync(srcPath, 'utf-8')\n      fs.writeFileSync(destPath, transformer(content), 'utf-8')\n    }\n  }\n}\n\n/**\n * Deploys all GSD workflow assets to the gsd-munch home directory.\n * Deploys: workflows/, templates/, references/, bin/ directories + VERSION file.\n * All file content is transformed with path substitution before writing.\n *\n * @param gsdMunchHome Deployment target directory (defaults to ~/.claude/gsd-munch)\n */\nexport async function deployAssets(gsdMunchHome = getGsdMunchHome()): Promise<void> {\n  const pkgRoot = getPkgRoot()\n  const transformer = (content: string) => transformContent(content, gsdMunchHome)\n\n  const dirs = ['workflows', 'templates', 'references', 'bin', 'hooks', 'contexts']\n  for (const dir of dirs) {\n    const srcDir = path.join(pkgRoot, dir)\n    if (fs.existsSync(srcDir)) {\n      await deployDirectory(srcDir, path.join(gsdMunchHome, dir), transformer)\n    }\n  }\n\n  // Copy VERSION verbatim (no transformation needed)\n  const versionSrc = path.join(pkgRoot, 'VERSION')\n  if (fs.existsSync(versionSrc)) {\n    fs.mkdirSync(gsdMunchHome, { recursive: true })\n    fs.copyFileSync(versionSrc, path.join(gsdMunchHome, 'VERSION'))\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAA6B;AAC7B,oBAAmB;;;AC6BZ,SAAS,iBAAiB,SAAiB,cAA8B;AAC9E,SAAO,QAEJ;AAAA,IACC;AAAA,IACA,IAAI,YAAY;AAAA,EAClB,EAIC;AAAA,IACC;AAAA,IACA,KAAK,YAAY;AAAA,EACnB,EAEC,WAAW,cAAc,WAAW,EAEpC,WAAW,SAAS,MAAM;AAC/B;;;AD5CA,IAAM,YAAY;AAAA,IAElB,2BAAS,oBAAoB,MAAM;AACjC,iCAAS,0CAA0C,MAAM;AACvD,6BAAG,yFAAyF,MAAM;AAChG,YAAM,QAAQ;AACd,YAAM,SAAS,iBAAiB,OAAO,SAAS;AAChD,oBAAAA,QAAO,MAAM,QAAQ,SAAS,SAAS,0BAA0B;AAAA,IACnE,CAAC;AAED,6BAAG,qDAAqD,MAAM;AAC5D,YAAM,QAAQ;AAAA,QACZ;AAAA,QACA;AAAA,MACF,EAAE,KAAK,IAAI;AACX,YAAM,SAAS,iBAAiB,OAAO,SAAS;AAChD,oBAAAA,QAAO,GAAG,CAAC,OAAO,SAAS,eAAe,GAAG,uCAAuC;AACpF,oBAAAA,QAAO,MAAM,OAAO,MAAM,GAAG,SAAS,oBAAoB,EAAE,SAAS,GAAG,CAAC;AAAA,IAC3E,CAAC;AAAA,EACH,CAAC;AAED,iCAAS,oDAAoD,MAAM;AACjE,6BAAG,gEAAgE,MAAM;AACvE,YAAM,QA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