feat(#1754): CLI version-skew detection — warn when a global install shadows project-local GSD (#1755)
* feat(#1754): CLI version-skew detection — warn when a global install shadows project-local GSD Addresses #1754 (approved-enhancement). Detects when the running gsd-tools.cjs is outside the project root while a project-local install exists — the shadowing scenario from #1748 where a stale global canary CLI (retired @gsd-build/sdk) silently overrides project-local GSD. Implementation (Node CLI entry-point, not shell snippet — avoids bloating 93 workflow files past their size caps): - src/cli-skew-check.cts: pure function checkCliSkew({resolvedPath, projectRoot, projectLocalExists}) → string|null. Compares paths via path.relative; returns a warning when the resolved CLI is outside the project root AND a project-local install exists. Includes @gsd-build/sdk removal hint when the path matches. No I/O (pure), no gsd-sdk literal (avoids bug-2801 lint). - gsd-core/bin/gsd-tools.cjs: wired at startup via the existing findProjectRoot resolver. Non-blocking (try/catch; advisory stderr warning, never gates). - eslint.config.mjs: registers the new ADR-457 generated artifact in the ignores. - tests: 6-case suite (skew/no-skew/legacy/normalization); all green. - Golden fixtures regenerated (UPDATE_GOLDEN=1) for the new compiled artifact. - docs/how-to/update-gsd.md: Diátaxis reference note for the skew warning. Full suite: 3354 pass, 0 regressions (1 pre-existing local AGENTS.md failure). lint:ci green. Closes #1754 * chore(#1754): backfill changeset pr placeholder * chore(#1754): regenerate INVENTORY-MANIFEST for the new cli-skew-check source module --------- Co-authored-by: review-bot <review-bot@gsd>
This commit is contained in:
@@ -204,6 +204,24 @@ const projectRoot = require('./lib/project-root.cjs');
|
||||
// against any require/load-ordering edge where the export isn't bound yet
|
||||
// when this entrypoint is first required (#604).
|
||||
const findProjectRoot = (...args) => projectRoot.findProjectRoot(...args);
|
||||
|
||||
// #1754: CLI skew detection — warn (stderr, non-blocking) if this gsd-tools.cjs
|
||||
// is NOT the project-local install while a project-local install exists. Catches
|
||||
// the shadowing scenario from #1748 (stale global canary shadowing project-local).
|
||||
try {
|
||||
const _skew = require('./lib/cli-skew-check.cjs');
|
||||
const _skewRoot = findProjectRoot(process.cwd());
|
||||
if (_skewRoot) {
|
||||
const _skewLocal = path.join(_skewRoot, '.claude', 'gsd-core', 'bin', 'gsd-tools.cjs');
|
||||
const _skewWarn = _skew.checkCliSkew({
|
||||
resolvedPath: path.resolve(__filename),
|
||||
projectRoot: _skewRoot,
|
||||
projectLocalExists: fs.existsSync(_skewLocal),
|
||||
});
|
||||
if (_skewWarn) process.stderr.write(_skewWarn + '\n');
|
||||
}
|
||||
} catch { /* advisory — never block */ }
|
||||
|
||||
const { getActiveWorkstream } = require('./lib/planning-workspace.cjs');
|
||||
const { resolveActiveWorkstream, applyResolvedWorkstreamEnv } = require('./lib/active-workstream-store.cjs');
|
||||
const state = require('./lib/state.cjs');
|
||||
|
||||
Reference in New Issue
Block a user