refactor(#1679): ADR-1239 Phase B — collapse getConfigDirFromHome chain into getGlobalConfigHomeFragment [AC2 slice 2/6] (#1801)
* refactor(#1679): ADR-1239 Phase B — collapse getConfigDirFromHome chain into getGlobalConfigHomeFragment AC2 slice 2. Collapses the 14-branch runtime->global-config-home source-fragment chain in bin/install.js getConfigDirFromHome (the hook path.join() codegen mapping) into a single getGlobalConfigHomeFragment(runtime) lookup in runtime-name-policy.cts, sibling to getDirName / getRuntimeLabel. The antigravity branch stays dynamic in the caller (resolveAntigravityGlobalDir + path.relative — env-overridable, multi-segment); the prior inner unreachable `if (!isGlobal) return "'agents'"` (dead: !isGlobal returns at the fn top) is dropped. Behavior: byte-identical. Fragments preserved verbatim in the table. - claude/unknown/empty -> default '.claude' fragment - 14 runtimes (copilot..kimi) -> table lookup - antigravity -> dynamic (unchanged) Verification: - TDD: tests/global-config-home-fragment.test.cjs (golden map + 2 drift guards + fallbacks). Red->green. - 16-runtime golden install parity: byte-identical (hook codegen output unchanged) - eslint + test-file-count + regression-names clean - runtime === count in install.js: 115 -> 101 (-14) * chore(changeset): add Changed fragment for getConfigDirFromHome collapse (#1679)
This commit is contained in:
@@ -37,7 +37,7 @@ const {
|
||||
// installer to the runtime-name-policy leaf (ADR-1508 / #1510 Phase 1) so the
|
||||
// conversion module's rewrite engine can consume it without importing
|
||||
// bin/install.js. Re-exported below for back-compat consumers/tests.
|
||||
const { getDirName, getRuntimeLabel } = require('../gsd-core/bin/lib/runtime-name-policy.cjs');
|
||||
const { getDirName, getRuntimeLabel, getGlobalConfigHomeFragment } = require('../gsd-core/bin/lib/runtime-name-policy.cjs');
|
||||
const {
|
||||
applyWorktreeBaseRef,
|
||||
readBaseRefFromSettings,
|
||||
@@ -510,18 +510,11 @@ function getConfigDirFromHome(runtime, isGlobal) {
|
||||
// Local installs use the same dir name pattern
|
||||
return `'${getDirName(runtime)}'`;
|
||||
}
|
||||
// Global installs - OpenCode uses XDG path structure
|
||||
if (runtime === 'copilot') return "'.copilot'";
|
||||
if (runtime === 'opencode') {
|
||||
// OpenCode: ~/.config/opencode -> '.config', 'opencode'
|
||||
// Return as comma-separated for path.join() replacement
|
||||
return "'.config', 'opencode'";
|
||||
}
|
||||
if (runtime === 'gemini') return "'.gemini'";
|
||||
if (runtime === 'kilo') return "'.config', 'kilo'";
|
||||
if (runtime === 'codex') return "'.codex'";
|
||||
// Global installs. antigravity's home is resolved dynamically (env-overridable,
|
||||
// multi-segment via resolveAntigravityGlobalDir + path.relative) — not a table
|
||||
// entry. (The prior inner `if (!isGlobal) return "'.agents'"` was unreachable:
|
||||
// !isGlobal returns at the top of this function.)
|
||||
if (runtime === 'antigravity') {
|
||||
if (!isGlobal) return "'.agents'";
|
||||
const antigravityDir = resolveAntigravityGlobalDir();
|
||||
const rel = path.relative(os.homedir(), antigravityDir);
|
||||
const segments = rel.split(path.sep).filter(Boolean);
|
||||
@@ -532,16 +525,9 @@ function getConfigDirFromHome(runtime, isGlobal) {
|
||||
// stable legacy template so generated path.join() calls remain valid.
|
||||
return "'.gemini', 'antigravity'";
|
||||
}
|
||||
if (runtime === 'cursor') return "'.cursor'";
|
||||
if (runtime === 'windsurf') return "'.windsurf'";
|
||||
if (runtime === 'augment') return "'.augment'";
|
||||
if (runtime === 'trae') return "'.trae'";
|
||||
if (runtime === 'qwen') return "'.qwen'";
|
||||
if (runtime === 'hermes') return "'.hermes'";
|
||||
if (runtime === 'codebuddy') return "'.codebuddy'";
|
||||
if (runtime === 'cline') return "'.cline'";
|
||||
if (runtime === 'kimi') return "'.config', 'agents'";
|
||||
return "'.claude'";
|
||||
// All other runtimes: single source-of-truth fragment table (ADR-1239 Phase B,
|
||||
// #1679). claude/unknown fall through to the table's default '.claude'.
|
||||
return getGlobalConfigHomeFragment(runtime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user