Phase 2 of #3660 / ADR-3660. Routes both lifecycle verbs through the Runtime Artifact Layout Module landed in Phase 1 (#3663): - Add installRuntimeArtifacts(runtime, configDir, scope, resolvedProfile) and uninstallRuntimeArtifacts(runtime, configDir, scope) as the public orchestrators. Both pre-prune stale gsd-* entries before staged copy; installRuntimeArtifacts brackets the prune+copy with preserveUserArtifacts / restoreUserArtifacts so user-owned content (e.g. gsd-dev-preferences) survives wipe-and-replace for claude/qwen/hermes runtimes. - Add applyRuntimeContentRewritesInPlace as the per-runtime path/branding post-stage step (preserves byte-output equivalence with the legacy copyCommandsAs* pipeline, including Qwen/Hermes branding rewrites). - Add _copyStaged, _removeGsdEntries kind-aware filesystem helpers. - Add _runLegacyInstallMigrations, _runLegacyUninstallCleanup as thin dispatchers over existing ADR-0008 legacy migrations (Hermes flat->nested per #2841, dev-preferences-as-skill per #2973). For Hermes, also clean up the intermediate skills/gsd/gsd-*/ layout that pre-Phase-2 installs left on disk. - Delete the 9 copyCommandsAs*Skills functions (Codex / Cursor / Windsurf / Trae / CodeBuddy / Copilot / Claude / Antigravity / Augment) and the _copyCommandsAsSkillsViaConverter helper. All test entry points migrated to call installRuntimeArtifacts directly through the unified seam. - Collapse the 9-branch uninstall ladder to one uninstallRuntimeArtifacts call plus preserved non-layout side-effects (Codex TOML, Copilot instructions, hooks). - Unify install dispatcher: a single _isSkillsRuntime gate routes all 11 skills runtimes through installRuntimeArtifacts for both full and core/ minimal profiles. Removes 11 per-runtime if-else branches (3 minimal-mode shim branches + 8 dead after-the-gate branches). Net delta on bin/install.js: 11,495 -> 11,174 (-321 LOC). New tests: - tests/install-uninstall-layout-loop.test.cjs (34 tests) - per-runtime fixture assertions on install/uninstall/legacy-migration ordering. - tests/install-hermes-regressions.test.cjs (6 tests) - covers the six defects surfaced by iterative review: Hermes upgrade leaves stale dirs, --hermes --profile=core fall-through, --qwen --profile=core fall-through, minimal-mode dev-preferences migration skipped (Hermes/Qwen/Claude-global), and ordering bug in _runLegacyInstallMigrations. Existing tests (10,038 prior + 40 new) all green: 10,078/10,078 pass. Refs #3664 Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
100 lines
3.5 KiB
JavaScript
100 lines
3.5 KiB
JavaScript
/**
|
||
* Regression test for #1736: local Claude install missing commands/gsd/
|
||
*
|
||
* After a fresh local install (`--claude --local`), all /gsd-* commands
|
||
* except /gsd-help return "Unknown skill: gsd-quick" because
|
||
* .claude/commands/gsd/ is not populated. Claude Code reads local project
|
||
* commands from .claude/commands/gsd/ (the commands/ format), not from
|
||
* .claude/skills/ — only the global ~/.claude/skills/ is used for skills.
|
||
*/
|
||
|
||
'use strict';
|
||
|
||
process.env.GSD_TEST_MODE = '1';
|
||
|
||
const { describe, test, before, beforeEach, afterEach } = require('node:test');
|
||
const assert = require('node:assert/strict');
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
const os = require('os');
|
||
const { execFileSync } = require('child_process');
|
||
|
||
const INSTALL_SRC = path.join(__dirname, '..', 'bin', 'install.js');
|
||
const BUILD_SCRIPT = path.join(__dirname, '..', 'scripts', 'build-hooks.js');
|
||
const { install } = require(INSTALL_SRC);
|
||
const { cleanup } = require('./helpers.cjs');
|
||
|
||
// ─── Ensure hooks/dist/ is populated before install tests ────────────────────
|
||
// With --test-concurrency=4, other install tests (bug-1834, bug-1924) run
|
||
// build-hooks.js concurrently. That script creates hooks/dist/ empty first,
|
||
// then copies files — creating a window where this test sees an empty dir and
|
||
// install() fails with "directory is empty" → process.exit(1).
|
||
|
||
before(() => {
|
||
execFileSync(process.execPath, [BUILD_SCRIPT], {
|
||
encoding: 'utf-8',
|
||
stdio: 'pipe',
|
||
});
|
||
});
|
||
|
||
// ─── #1736: local install deploys commands/gsd/ ─────────────────────────────
|
||
|
||
describe('#1736: local Claude install populates .claude/commands/gsd/', () => {
|
||
let tmpDir;
|
||
|
||
beforeEach(() => {
|
||
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-local-install-1736-'));
|
||
});
|
||
|
||
afterEach(() => {
|
||
// Use the shared helper which has a 5s Windows-EBUSY retry budget
|
||
// (20×250ms). The inline 1s budget here was insufficient on cold runners.
|
||
cleanup(tmpDir);
|
||
});
|
||
|
||
test('local install creates .claude/commands/gsd/ directory', (t) => {
|
||
const origCwd = process.cwd();
|
||
t.after(() => { process.chdir(origCwd); });
|
||
process.chdir(tmpDir);
|
||
install(false, 'claude');
|
||
|
||
const commandsDir = path.join(tmpDir, '.claude', 'commands', 'gsd');
|
||
assert.ok(
|
||
fs.existsSync(commandsDir),
|
||
'.claude/commands/gsd/ directory must exist after local install'
|
||
);
|
||
});
|
||
|
||
test('local install deploys at least one .md command file to .claude/commands/gsd/', (t) => {
|
||
const origCwd = process.cwd();
|
||
t.after(() => { process.chdir(origCwd); });
|
||
process.chdir(tmpDir);
|
||
install(false, 'claude');
|
||
|
||
const commandsDir = path.join(tmpDir, '.claude', 'commands', 'gsd');
|
||
assert.ok(
|
||
fs.existsSync(commandsDir),
|
||
'.claude/commands/gsd/ must exist'
|
||
);
|
||
|
||
const files = fs.readdirSync(commandsDir).filter(f => f.endsWith('.md'));
|
||
assert.ok(
|
||
files.length > 0,
|
||
`.claude/commands/gsd/ must contain at least one .md file, found: ${JSON.stringify(files)}`
|
||
);
|
||
});
|
||
|
||
test('local install deploys quick.md to .claude/commands/gsd/', (t) => {
|
||
const origCwd = process.cwd();
|
||
t.after(() => { process.chdir(origCwd); });
|
||
process.chdir(tmpDir);
|
||
install(false, 'claude');
|
||
|
||
const quickCmd = path.join(tmpDir, '.claude', 'commands', 'gsd', 'quick.md');
|
||
assert.ok(
|
||
fs.existsSync(quickCmd),
|
||
'.claude/commands/gsd/quick.md must exist after local install'
|
||
);
|
||
});
|
||
});
|