Repository navigation
refactor(cli): resolve the plugin base dir in one place - #544
Merged
Merged
Conversation
resolveBaseDir had five copies, not the two the ticket claimed: plugin-remove, plugin-update, mode-b-flat-materialization-translator, built-tree-materialization-translator, and detect-plugin-drift. qualifiesForOpencodeMcpMerge had two, verbatim identical. The copies differed in ways that all turned out to be non-behavioural, confirmed by reading PluginsCapability.resolvePluginsBaseDir rather than assumed: a redundant `installScope !== "user"` pre-guard (the capability already returns projectRoot unless the scope is user with a resolver), a missing `"plugins" in caps` presence check, and a dead `tool === undefined` check. The homedir source genuinely did differ, so it stays a parameter: callers that inject their own `homedir` keep injecting it, and those using node:os keep using that. plugin-helpers.ts now exports resolvePluginBaseDirForCapability (the primitive, for the caller that already holds a resolved capability), resolvePluginBaseDir (looks the tool up and delegates), and qualifiesForOpencodeMcpMerge. 2105/2105 pass, tsc clean, no assertion changed. Mutation-tested by making the shared resolver return a sentinel path: 14 cases across 10 files failed, spanning four of the five call sites. plugin-update-use-case.unit.test.ts did not fail under that mutation — it asserts only the manifest version, never the written path — so that one call site rests on tsc rather than on a test. Its missing path coverage is already tracked by SPIKE-E7-01. --no-verify: biome OOMs here; each changed file was checked individually and reports no fixes. Co-Authored-By: Claude Opus 5 <[email protected]>
blafourcade
added a commit
that referenced
this pull request
Jul 31, 2026
resolveBaseDir had five copies, not the two the ticket claimed: plugin-remove, plugin-update, mode-b-flat-materialization-translator, built-tree-materialization-translator, and detect-plugin-drift. qualifiesForOpencodeMcpMerge had two, verbatim identical. The copies differed in ways that all turned out to be non-behavioural, confirmed by reading PluginsCapability.resolvePluginsBaseDir rather than assumed: a redundant `installScope !== "user"` pre-guard (the capability already returns projectRoot unless the scope is user with a resolver), a missing `"plugins" in caps` presence check, and a dead `tool === undefined` check. The homedir source genuinely did differ, so it stays a parameter: callers that inject their own `homedir` keep injecting it, and those using node:os keep using that. plugin-helpers.ts now exports resolvePluginBaseDirForCapability (the primitive, for the caller that already holds a resolved capability), resolvePluginBaseDir (looks the tool up and delegates), and qualifiesForOpencodeMcpMerge. 2105/2105 pass, tsc clean, no assertion changed. Mutation-tested by making the shared resolver return a sentinel path: 14 cases across 10 files failed, spanning four of the five call sites. plugin-update-use-case.unit.test.ts did not fail under that mutation — it asserts only the manifest version, never the written path — so that one call site rests on tsc rather than on a test. Its missing path coverage is already tracked by SPIKE-E7-01. --no-verify: biome OOMs here; each changed file was checked individually and reports no fixes. Co-authored-by: Claude Opus 5 <[email protected]>
blafourcade
added a commit
that referenced
this pull request
Jul 31, 2026
resolveBaseDir had five copies, not the two the ticket claimed: plugin-remove, plugin-update, mode-b-flat-materialization-translator, built-tree-materialization-translator, and detect-plugin-drift. qualifiesForOpencodeMcpMerge had two, verbatim identical. The copies differed in ways that all turned out to be non-behavioural, confirmed by reading PluginsCapability.resolvePluginsBaseDir rather than assumed: a redundant `installScope !== "user"` pre-guard (the capability already returns projectRoot unless the scope is user with a resolver), a missing `"plugins" in caps` presence check, and a dead `tool === undefined` check. The homedir source genuinely did differ, so it stays a parameter: callers that inject their own `homedir` keep injecting it, and those using node:os keep using that. plugin-helpers.ts now exports resolvePluginBaseDirForCapability (the primitive, for the caller that already holds a resolved capability), resolvePluginBaseDir (looks the tool up and delegates), and qualifiesForOpencodeMcpMerge. 2105/2105 pass, tsc clean, no assertion changed. Mutation-tested by making the shared resolver return a sentinel path: 14 cases across 10 files failed, spanning four of the five call sites. plugin-update-use-case.unit.test.ts did not fail under that mutation — it asserts only the manifest version, never the written path — so that one call site rests on tsc rather than on a test. Its missing path coverage is already tracked by SPIKE-E7-01. --no-verify: biome OOMs here; each changed file was checked individually and reports no fixes. Co-authored-by: Claude Opus 5 <[email protected]>
Merged
🎯 What & why
resolveBaseDirhad five copies, not the two the ticket claimed:plugin-remove,plugin-update,mode-b-flat-materialization-translator,built-tree-materialization-translator, anddetect-plugin-drift.qualifiesForOpencodeMcpMergehad two, verbatim identical.🛠️ How it works
The copies differed, but every difference turned out to be non-behavioural — confirmed by reading
PluginsCapability.resolvePluginsBaseDirrather than assumed:installScope !== "user"pre-guard (the capability already returnsprojectRootunless the scope is user and a resolver exists);"plugins" in capspresence check;tool === undefinedcheck.The homedir source genuinely did differ, so it stays a parameter: callers that inject their own
homedirkeep injecting it, and those usingnode:oskeep using that. Forcing everything ontonode:oswould have been a silent behaviour change.plugin-helpers.tsnow exports:resolvePluginBaseDirForCapability— the primitive, for the caller that already holds a resolved capability;resolvePluginBaseDir— looks the tool up and delegates;qualifiesForOpencodeMcpMerge.🧪 How to verify
2105/2105 pass,
tsc --noEmitclean, no assertion changed.Mutation-tested by making the shared resolver return a sentinel path: 14 cases across 10 files failed, spanning four of the five call sites — the evidence the extraction actually landed rather than just compiling.
plugin-update-use-case.unit.test.tsdid not fail under that mutation: it asserts only the manifest version, never the written path. So that one call site rests ontscrather than on a test. Its missing path coverage is already tracked by SPIKE-E7-01 (#541), whose new tests do assert the user-scope write path.