From 9ac7bcd4627a125694d1831482c4db9c9296118a Mon Sep 17 00:00:00 2001 From: Lex Christopherson Date: Mon, 15 Dec 2025 17:35:22 -0600 Subject: [PATCH] Add path replacement for local installs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace ~/.claude/ with ./.claude/ in all .md files when installing locally, so file references work correctly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- bin/install.js | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/bin/install.js b/bin/install.js index 5a8a84d4b..407fab8c0 100755 --- a/bin/install.js +++ b/bin/install.js @@ -35,6 +35,31 @@ const hasLocal = args.includes('--local') || args.includes('-l'); console.log(banner); +/** + * Recursively copy directory, replacing paths in .md files + */ +function copyWithPathReplacement(srcDir, destDir, pathPrefix) { + fs.mkdirSync(destDir, { recursive: true }); + + const entries = fs.readdirSync(srcDir, { withFileTypes: true }); + + for (const entry of entries) { + const srcPath = path.join(srcDir, entry.name); + const destPath = path.join(destDir, entry.name); + + if (entry.isDirectory()) { + copyWithPathReplacement(srcPath, destPath, pathPrefix); + } else if (entry.name.endsWith('.md')) { + // Replace ~/.claude/ with the appropriate prefix in markdown files + let content = fs.readFileSync(srcPath, 'utf8'); + content = content.replace(/~\/\.claude\//g, pathPrefix); + fs.writeFileSync(destPath, content); + } else { + fs.copyFileSync(srcPath, destPath); + } + } +} + /** * Install to the specified directory */ @@ -48,22 +73,25 @@ function install(isGlobal) { ? claudeDir.replace(os.homedir(), '~') : claudeDir.replace(process.cwd(), '.'); + // Path prefix for file references + const pathPrefix = isGlobal ? '~/.claude/' : './.claude/'; + console.log(` Installing to ${cyan}${locationLabel}${reset}\n`); // Create commands directory const commandsDir = path.join(claudeDir, 'commands'); fs.mkdirSync(commandsDir, { recursive: true }); - // Copy commands/gsd + // Copy commands/gsd with path replacement const gsdSrc = path.join(src, 'commands', 'gsd'); const gsdDest = path.join(commandsDir, 'gsd'); - fs.cpSync(gsdSrc, gsdDest, { recursive: true }); + copyWithPathReplacement(gsdSrc, gsdDest, pathPrefix); console.log(` ${green}✓${reset} Installed commands/gsd`); - // Copy get-shit-done skill + // Copy get-shit-done skill with path replacement const skillSrc = path.join(src, 'get-shit-done'); const skillDest = path.join(claudeDir, 'get-shit-done'); - fs.cpSync(skillSrc, skillDest, { recursive: true }); + copyWithPathReplacement(skillSrc, skillDest, pathPrefix); console.log(` ${green}✓${reset} Installed get-shit-done`); console.log(`