refactor: remove dead descriptor-driven mechanisms (no remaining consumer)
Drop code whose only consumer was a retired runtime: hostBehaviors readers for agentFileExtension, localTargetIsProjectRoot, sharedHooksDirName, skillsManifestPrefix and skipCodexSkillsManifest; the empty NON_REGISTRY_CONFIG_HOME_DESCRIPTORS array and live-config-guard plumbing; the empty RUNTIME_NOTE_AUDIENCE_BY_HEADING filter; the unused resolveVersionFrom export; and the WINDSURF_SESSION_ID workstream session key. Delete tests that only exercised those mechanisms.
This commit is contained in:
@@ -353,14 +353,8 @@ const MSD_CURSOR_HOOK_MARKER = hooksSurface.MSD_CURSOR_HOOK_MARKER;
|
||||
// two guards require so their copies cannot drift.
|
||||
const MSD_HOOK_LIB_FILES = ['git-cmd.js', 'msd-graphify-rebuild.sh', 'cursor-workspace.js', 'injection-patterns.js'];
|
||||
|
||||
/**
|
||||
* Directory name MSD stages its shared hook bundle under, inside a runtime's
|
||||
* install root. Defaults to 'hooks' — the name every runtime used before #3023.
|
||||
* A runtime may override it via hostBehaviors.sharedHooksDirName (single path
|
||||
* segment, same depth, so every `__dirname/..`-relative resolution inside the
|
||||
* bundle keeps working).
|
||||
*/
|
||||
const SHARED_HOOKS_DIR_DEFAULT = 'hooks';
|
||||
/** Directory name MSD stages its shared hook bundle under, inside a runtime's install root. */
|
||||
const SHARED_HOOKS_DIR = 'hooks';
|
||||
|
||||
// #3184 — MSD-managed file enumerations for scripts/changeset/ and scripts/lib/
|
||||
// uninstall. The install-side copy of both directories is wholesale ("copy every
|
||||
@@ -388,53 +382,6 @@ const CODEX_HOOKS_TO_COPY = [
|
||||
'managed-hooks-registry.cjs',
|
||||
];
|
||||
|
||||
/**
|
||||
* Resolve a runtime's shared-hooks directory name from its descriptor.
|
||||
*
|
||||
* The value is a single path SEGMENT. This string is joined onto a user's config
|
||||
* root and then written to and recursively read, so anything that is not a plain,
|
||||
* non-empty, separator-free, non-dot segment is rejected back to the default —
|
||||
* a descriptor typo must never let the installer write outside the install root.
|
||||
*
|
||||
* The "non-dot" part of that contract is enforced beyond the literal '.' / '..'
|
||||
* segments: an all-dot (or dot-and-whitespace-only) segment is rejected as a
|
||||
* meaningless name, a segment with a trailing dot or space is rejected because
|
||||
* Windows silently strips it at directory-creation time (which would split the
|
||||
* name the installer creates from the name callers probe for), and a Windows
|
||||
* reserved device name (CON, PRN, AUX, NUL, COM1-9, LPT1-9, with or without an
|
||||
* extension) is rejected because it cannot exist as a directory on Windows at
|
||||
* all. These checks are unconditional on every platform: the descriptor is
|
||||
* authored once and shipped everywhere, so a value invalid on Windows must be
|
||||
* rejected identically on Linux/macOS, or the install and its fixtures disagree
|
||||
* cross-platform.
|
||||
*
|
||||
* @param {string} runtime
|
||||
* @returns {string}
|
||||
*/
|
||||
function resolveSharedHooksDirName(runtime) {
|
||||
const raw = _hostBehaviors(runtime).sharedHooksDirName;
|
||||
if (typeof raw !== 'string') return SHARED_HOOKS_DIR_DEFAULT;
|
||||
const name = raw.trim();
|
||||
if (name === '') return SHARED_HOOKS_DIR_DEFAULT;
|
||||
if (name === '.' || name === '..') return SHARED_HOOKS_DIR_DEFAULT;
|
||||
// All-dot or dot+whitespace segments ('...', '. .') are not meaningful
|
||||
// directory names and are almost certainly a descriptor typo.
|
||||
if (name.replace(/[.\s]/g, '') === '') return SHARED_HOOKS_DIR_DEFAULT;
|
||||
// Windows silently strips a trailing dot or space at creation time, so the
|
||||
// directory the installer creates would not match the name the adapter
|
||||
// probes for — a split-brain that only reproduces off-Linux.
|
||||
if (/[. ]$/.test(name)) return SHARED_HOOKS_DIR_DEFAULT;
|
||||
// Windows reserved device names cannot exist as directories.
|
||||
if (/^(?:CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\..*)?$/i.test(name)) return SHARED_HOOKS_DIR_DEFAULT;
|
||||
if (name.includes('/') || name.includes('\\')) return SHARED_HOOKS_DIR_DEFAULT;
|
||||
// Belt-and-braces: reject anything path.basename() would reduce, and any
|
||||
// Windows drive/UNC-flavoured value.
|
||||
if (path.basename(name) !== name) return SHARED_HOOKS_DIR_DEFAULT;
|
||||
if (path.isAbsolute(name)) return SHARED_HOOKS_DIR_DEFAULT;
|
||||
if (name.includes('\0')) return SHARED_HOOKS_DIR_DEFAULT;
|
||||
return name;
|
||||
}
|
||||
|
||||
// #3897 rung 3 — sandbox_mode derivation, the hold list, and the hold-roster
|
||||
// validator now live in `src/codex-agent-toml.cts` (compiled to
|
||||
// `msd-core/bin/lib/codex-agent-toml.cjs`), NOT here. This module used to be
|
||||
@@ -5953,7 +5900,7 @@ function uninstall(isGlobal, runtime = DEFAULT_RUNTIME) {
|
||||
|
||||
// 4. Remove MSD hooks
|
||||
// #3023: mirror the install site's descriptor-driven bundle dir name.
|
||||
const hooksDir = path.join(targetDir, resolveSharedHooksDirName(runtime));
|
||||
const hooksDir = path.join(targetDir, SHARED_HOOKS_DIR);
|
||||
if (fs.existsSync(hooksDir)) {
|
||||
let hookCount = 0;
|
||||
for (const hook of MSD_UNINSTALL_HOOKS) {
|
||||
@@ -6789,7 +6736,6 @@ function writeManifest(configDir, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// `options.scope` could drift; one cannot.
|
||||
const resolvedScope = options.scope === 'local' ? 'local' : 'global';
|
||||
const codexSkillsDir = _resolveSkillsRootDir(runtime, configDir, resolvedScope);
|
||||
const codexSkillsManifestPrefix = _hostBehaviors(runtime).skillsManifestPrefix || 'skills/';
|
||||
// #3738: resolve the ACTUAL agents-install dir honoring an agents-kind `home`
|
||||
// override (antigravity global → $HOME/.gemini/config/agents), mirroring
|
||||
// _resolveSkillsRootDir for skills. Hardcoding configDir/agents left the
|
||||
@@ -6859,14 +6805,14 @@ function writeManifest(configDir, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!_hostBehaviors(runtime).skipCodexSkillsManifest && fs.existsSync(codexSkillsDir)) {
|
||||
if (fs.existsSync(codexSkillsDir)) {
|
||||
// All runtimes use the canonical 'msd-' prefix.
|
||||
const skillListPrefix = 'msd-';
|
||||
for (const skillName of listCodexSkillNames(codexSkillsDir, skillListPrefix)) {
|
||||
const skillRoot = path.join(codexSkillsDir, skillName);
|
||||
const skillHashes = generateManifest(skillRoot);
|
||||
for (const [rel, hash] of Object.entries(skillHashes)) {
|
||||
manifest.files[`${codexSkillsManifestPrefix}${skillName}/${rel}`] = hash;
|
||||
manifest.files[`skills/${skillName}/${rel}`] = hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6884,8 +6830,7 @@ function writeManifest(configDir, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
if (!isCodex && _hostBehaviors(runtime).skipSharedHooksInstall !== true) {
|
||||
// #3023: manifest keys must track the bundle wherever the descriptor put it,
|
||||
// or uninstall/saveLocalPatches silently orphan the tree.
|
||||
const sharedHooksDirName = resolveSharedHooksDirName(runtime);
|
||||
const hooksDir = path.join(configDir, sharedHooksDirName);
|
||||
const hooksDir = path.join(configDir, SHARED_HOOKS_DIR);
|
||||
if (fs.existsSync(hooksDir)) {
|
||||
// Drive from INSTALLED_HOOK_FILES (the canonical HOOKS_TO_COPY set from
|
||||
// scripts/build-hooks.js) rather than a prefix/extension regex, so the
|
||||
@@ -6897,7 +6842,7 @@ function writeManifest(configDir, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
for (const hook of INSTALLED_HOOK_FILES) {
|
||||
const hookPath = path.join(hooksDir, hook);
|
||||
if (fs.existsSync(hookPath)) {
|
||||
manifest.files[sharedHooksDirName + '/' + hook] = fileHash(hookPath);
|
||||
manifest.files[SHARED_HOOKS_DIR + '/' + hook] = fileHash(hookPath);
|
||||
}
|
||||
}
|
||||
// Track hooks/lib/ helpers so saveLocalPatches() can back up user edits
|
||||
@@ -6906,7 +6851,7 @@ function writeManifest(configDir, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
if (fs.existsSync(hooksLibDir)) {
|
||||
for (const file of fs.readdirSync(hooksLibDir)) {
|
||||
if (MSD_HOOK_LIB_FILES.includes(file)) {
|
||||
manifest.files[sharedHooksDirName + '/lib/' + file] = fileHash(path.join(hooksLibDir, file));
|
||||
manifest.files[SHARED_HOOKS_DIR + '/lib/' + file] = fileHash(path.join(hooksLibDir, file));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7179,8 +7124,7 @@ function saveLocalPatches(configDir, pristineCtx) {
|
||||
skillsRoot !== resolvedConfig &&
|
||||
!skillsRoot.startsWith(resolvedConfig + path.sep)
|
||||
) {
|
||||
const prefix = _hostBehaviors(patchRuntime).skillsManifestPrefix || 'skills/';
|
||||
skillsRedirect = { root: skillsRoot, prefix };
|
||||
skillsRedirect = { root: skillsRoot, prefix: 'skills/' };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8555,7 +8499,6 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// #3023: the bundle's directory NAME is descriptor-driven — a host that
|
||||
// reserves `hooks/` must be able to opt out. Resolved once here so the
|
||||
// stage / lib / marker sites can never disagree about where the bundle is.
|
||||
const sharedHooksDirName = resolveSharedHooksDirName(runtime);
|
||||
|
||||
// #2544: the CommonJS marker is NOT written here (destRootDir is the
|
||||
// runtime's shared config root — user-writable territory on OpenCode,
|
||||
@@ -8572,7 +8515,7 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// Template paths for the target runtime (replaces '.claude' with correct config dir)
|
||||
const hooksSrc = path.join(src, 'hooks', 'dist');
|
||||
if (fs.existsSync(hooksSrc)) {
|
||||
const hooksDest = path.join(destRootDir, sharedHooksDirName);
|
||||
const hooksDest = path.join(destRootDir, SHARED_HOOKS_DIR);
|
||||
fs.mkdirSync(hooksDest, { recursive: true });
|
||||
const hookEntries = fs.readdirSync(hooksSrc);
|
||||
if (hookEntries.some((e) => fs.statSync(path.join(hooksSrc, e)).isFile())) stagedHooks = true;
|
||||
@@ -8628,7 +8571,7 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
}
|
||||
}
|
||||
if (verifyInstalled(hooksDest, 'hooks')) {
|
||||
console.log(` ${green}✓${reset} Installed ${sharedHooksDirName} (bundled)`);
|
||||
console.log(` ${green}✓${reset} Installed ${SHARED_HOOKS_DIR} (bundled)`);
|
||||
// Warn if expected community .sh hooks are missing (non-fatal)
|
||||
const expectedShHooks = ['msd-session-state.sh', 'msd-validate-commit.sh', 'msd-phase-boundary.sh', 'msd-graphify-update.sh'];
|
||||
for (const sh of expectedShHooks) {
|
||||
@@ -8653,11 +8596,11 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// below; this helper itself only checks source presence.)
|
||||
const hooksLibSrc = path.join(src, 'hooks', 'lib');
|
||||
if (fs.existsSync(hooksLibSrc)) {
|
||||
const hooksLibDest = path.join(destRootDir, sharedHooksDirName, 'lib');
|
||||
const hooksLibDest = path.join(destRootDir, SHARED_HOOKS_DIR, 'lib');
|
||||
fs.mkdirSync(hooksLibDest, { recursive: true });
|
||||
copyLibDir(hooksLibSrc, hooksLibDest, MSD_HOOK_LIB_FILES);
|
||||
if (MSD_HOOK_LIB_FILES.some((f) => fs.existsSync(path.join(hooksLibDest, f)))) stagedHooks = true;
|
||||
console.log(` ${green}✓${reset} Installed ${sharedHooksDirName}/lib/ helpers (git-cmd, graphify-rebuild, ...)`);
|
||||
console.log(` ${green}✓${reset} Installed ${SHARED_HOOKS_DIR}/lib/ helpers (git-cmd, graphify-rebuild, ...)`);
|
||||
}
|
||||
|
||||
// #2544: pin the staged hook scripts to CommonJS from inside hooks/ — the
|
||||
@@ -8678,11 +8621,11 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// populate as CommonJS claims an ownership the install did not earn — the
|
||||
// two flags answer different questions ("did we intend to fill it" vs "is
|
||||
// it actually filled"), and the marker needs both.
|
||||
const hooksMarkerDir = path.join(destRootDir, sharedHooksDirName);
|
||||
const hooksMarkerDir = path.join(destRootDir, SHARED_HOOKS_DIR);
|
||||
if (stagedHooks && hooksOk) {
|
||||
switch (ensureCommonJsMarker(hooksMarkerDir)) {
|
||||
case 'written':
|
||||
console.log(` ${green}✓${reset} Wrote ${sharedHooksDirName}/package.json (CommonJS mode)`);
|
||||
console.log(` ${green}✓${reset} Wrote ${SHARED_HOOKS_DIR}/package.json (CommonJS mode)`);
|
||||
break;
|
||||
case 'preserved-foreign':
|
||||
// #4759: the foreign file usually DOES declare "type": "commonjs" —
|
||||
@@ -8692,12 +8635,12 @@ function install(isGlobal, runtime = DEFAULT_RUNTIME, options = {}) {
|
||||
// sibling plugin path (src/install-engine.cts) words this same
|
||||
// outcome conditionally; match it and keep will-not-load conditional
|
||||
// on "type": "module", the only case where it is true.
|
||||
console.warn(` ${yellow}⚠${reset} Left existing ${sharedHooksDirName}/package.json untouched (not MSD's marker). If it declares "type": "module", the staged hooks will not load.`);
|
||||
console.warn(` ${yellow}⚠${reset} Left existing ${SHARED_HOOKS_DIR}/package.json untouched (not MSD's marker). If it declares "type": "module", the staged hooks will not load.`);
|
||||
break;
|
||||
case 'failed':
|
||||
// Best-effort: a read-only or full config dir must not abort the
|
||||
// install with a raw stack trace. The hooks themselves are staged.
|
||||
console.warn(` ${yellow}⚠${reset} Could not write ${sharedHooksDirName}/package.json (CommonJS mode) — install continued; MSD hooks may not resolve as CommonJS`);
|
||||
console.warn(` ${yellow}⚠${reset} Could not write ${SHARED_HOOKS_DIR}/package.json (CommonJS mode) — install continued; MSD hooks may not resolve as CommonJS`);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -10998,8 +10941,7 @@ module.exports = {
|
||||
_resolveHostBehaviors,
|
||||
FALLBACK_HOST_BEHAVIORS,
|
||||
// #3023 — shared hook bundle directory name, descriptor-driven
|
||||
SHARED_HOOKS_DIR_DEFAULT,
|
||||
resolveSharedHooksDirName,
|
||||
SHARED_HOOKS_DIR,
|
||||
// #3184 — uninstall-side MSD-managed file enumerations, exported for
|
||||
// parity assertions against the wholesale-copy source directories
|
||||
MSD_CHANGESET_FILES,
|
||||
|
||||
Reference in New Issue
Block a user