{"version":3,"sources":["../../src/registration/agents.ts","../../src/registration/assets.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport os from 'node:os'\nimport { transformContent, getGsdMunchHome, getPkgRoot } from './assets.js'\n\n/**\n * Target directory for Claude Code agent files.\n * Agent filenames preserve gsd-* naming (gsd-executor.md, gsd-planner.md, etc.)\n * as these are internal implementation names referenced by workflows.\n */\nexport const AGENTS_DIR = path.join(os.homedir(), '.claude', 'agents')\n\n/**\n * Reads all .md agent files from the package agents/ directory,\n * applies transformContent to each (updating paths and /gsd: -> /gm: namespace),\n * and writes them to ~/.claude/agents/.\n *\n * IMPORTANT: Agent filenames are preserved as gsd-*.md — the /gm: namespace\n * change applies only to user-facing command stubs. Agent names are internal\n * identifiers referenced by workflows when spawning subagents.\n *\n * Creates the target directory if it doesn't exist.\n * Safe to re-run — overwrites existing agent files (idempotent by design).\n *\n * @param gsdMunchHome Deployed assets home directory (defaults to ~/.claude/gsd-munch)\n */\nexport async function registerAgents(gsdMunchHome = getGsdMunchHome()): Promise<void> {\n  const agentSrcDir = path.join(getPkgRoot(), 'agents')\n\n  if (!fs.existsSync(agentSrcDir)) {\n    return\n  }\n\n  fs.mkdirSync(AGENTS_DIR, { recursive: true })\n\n  for (const file of fs.readdirSync(agentSrcDir)) {\n    if (!file.endsWith('.md')) continue\n    const content = fs.readFileSync(path.join(agentSrcDir, file), 'utf-8')\n    const adapted = transformContent(content, gsdMunchHome)\n    // Agent filenames stay as gsd-*.md — no name transformation\n    fs.writeFileSync(path.join(AGENTS_DIR, file), adapted, 'utf-8')\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAe;AACf,IAAAA,oBAAiB;AACjB,IAAAC,kBAAe;;;ACDf,uBAAiB;AACjB,qBAAe;AAMR,SAAS,kBAA0B;AACxC,SAAO,iBAAAC,QAAK,KAAK,eAAAC,QAAG,QAAQ,GAAG,WAAW,WAAW;AACvD;AAKO,SAAS,aAAqB;AACnC,SAAO,iBAAAD,QAAK,QAAQ,WAAW,IAAI;AACrC;AAaO,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;;;ADtCO,IAAM,aAAa,kBAAAE,QAAK,KAAK,gBAAAC,QAAG,QAAQ,GAAG,WAAW,QAAQ;AAgBrE,eAAsB,eAAe,eAAe,gBA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