fix: resolve gsd-tools.cjs from repo-local installation before global fallback (#1425)

Probe <projectDir>/.claude/get-shit-done/bin/gsd-tools.cjs before falling back
to ~/.claude/get-shit-done/bin/gsd-tools.cjs, fixing MODULE_NOT_FOUND for
repo-local GSD installations. Also adds repo-local agent definition path.

Closes #1424

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
TÂCHES
2026-03-27 09:57:54 -06:00
committed by GitHub
parent 38c18ac68a
commit 1421dc07bc
5 changed files with 62 additions and 9 deletions

View File

@@ -7,6 +7,7 @@
import { execFile } from 'node:child_process';
import { readFile } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import { join } from 'node:path';
import { homedir } from 'node:os';
import type { InitNewProjectInfo, PhaseOpInfo, PhasePlanIndex, RoadmapAnalysis } from './types.js';
@@ -42,8 +43,7 @@ export class GSDTools {
}) {
this.projectDir = opts.projectDir;
this.gsdToolsPath =
opts.gsdToolsPath ??
join(homedir(), '.claude', 'get-shit-done', 'bin', 'gsd-tools.cjs');
opts.gsdToolsPath ?? resolveGsdToolsPath(opts.projectDir);
this.timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
}
@@ -281,3 +281,15 @@ export class GSDTools {
return this.execRaw('config-set', [key, value]);
}
}
// ─── Path resolution ────────────────────────────────────────────────────────
/**
* Resolve gsd-tools.cjs path with repo-local fallback.
* Probe order: repo-local → global home directory.
*/
export function resolveGsdToolsPath(projectDir: string): string {
const localPath = join(projectDir, '.claude', 'get-shit-done', 'bin', 'gsd-tools.cjs');
if (existsSync(localPath)) return localPath;
return join(homedir(), '.claude', 'get-shit-done', 'bin', 'gsd-tools.cjs');
}