Repository navigation
refactor(cli): share the plugin translator pipeline - #546
Merged
Merged
Conversation
plugin add, plugin update and plugin restore each resolved a translator and materialized plugin files themselves. Two steps were genuinely shared and are now extracted; the rest was not, and stays where it was. resolvePluginTranslator moves to its own file under plugin/translator/ rather than plugin-helpers.ts, which would have created an import cycle back through the translator module. All three sites use it. materializeViaBuiltTree moves to plugin-helpers.ts (type-only import of the translator class keeps the cycle away). Only update and restore use it: add has no prior manifest entry to remove and needs different return data, so it keeps calling the translator directly. Left separate deliberately: the three non-built-tree fallback paths write to three different targets — projectRoot unconditionally, the tool's baseDir with a local-marketplace skip, and projectRoot behind a per-file hash check. Confirmed different by reading each, not assumed. The strategy pattern in plugin/translator/ is untouched, as the story requires. Characterization tests came first: apply-plugin-files-use-case.ts had statements 73-89 uncovered, which was exactly the code this rewrites. Two tests now drive that restore path; the file goes from 75.9% to 100% statements. 2109/2109 pass, tsc clean, no existing assertion changed. Mutation-tested twice. Dropping manifest.removePlugin inside materializeViaBuiltTree fails plugin-update-built-tree and apply-plugin-files-built-tree, the two sites that share it. Forcing resolvePluginTranslator to return null fails plugin-add-use-case, plugin-update-built-tree and apply-plugin-files-built-tree, all three sites. --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
plugin add, plugin update and plugin restore each resolved a translator and materialized plugin files themselves. Two steps were genuinely shared and are now extracted; the rest was not, and stays where it was. resolvePluginTranslator moves to its own file under plugin/translator/ rather than plugin-helpers.ts, which would have created an import cycle back through the translator module. All three sites use it. materializeViaBuiltTree moves to plugin-helpers.ts (type-only import of the translator class keeps the cycle away). Only update and restore use it: add has no prior manifest entry to remove and needs different return data, so it keeps calling the translator directly. Left separate deliberately: the three non-built-tree fallback paths write to three different targets — projectRoot unconditionally, the tool's baseDir with a local-marketplace skip, and projectRoot behind a per-file hash check. Confirmed different by reading each, not assumed. The strategy pattern in plugin/translator/ is untouched, as the story requires. Characterization tests came first: apply-plugin-files-use-case.ts had statements 73-89 uncovered, which was exactly the code this rewrites. Two tests now drive that restore path; the file goes from 75.9% to 100% statements. 2109/2109 pass, tsc clean, no existing assertion changed. Mutation-tested twice. Dropping manifest.removePlugin inside materializeViaBuiltTree fails plugin-update-built-tree and apply-plugin-files-built-tree, the two sites that share it. Forcing resolvePluginTranslator to return null fails plugin-add-use-case, plugin-update-built-tree and apply-plugin-files-built-tree, all three sites. --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
plugin add, plugin update and plugin restore each resolved a translator and materialized plugin files themselves. Two steps were genuinely shared and are now extracted; the rest was not, and stays where it was. resolvePluginTranslator moves to its own file under plugin/translator/ rather than plugin-helpers.ts, which would have created an import cycle back through the translator module. All three sites use it. materializeViaBuiltTree moves to plugin-helpers.ts (type-only import of the translator class keeps the cycle away). Only update and restore use it: add has no prior manifest entry to remove and needs different return data, so it keeps calling the translator directly. Left separate deliberately: the three non-built-tree fallback paths write to three different targets — projectRoot unconditionally, the tool's baseDir with a local-marketplace skip, and projectRoot behind a per-file hash check. Confirmed different by reading each, not assumed. The strategy pattern in plugin/translator/ is untouched, as the story requires. Characterization tests came first: apply-plugin-files-use-case.ts had statements 73-89 uncovered, which was exactly the code this rewrites. Two tests now drive that restore path; the file goes from 75.9% to 100% statements. 2109/2109 pass, tsc clean, no existing assertion changed. Mutation-tested twice. Dropping manifest.removePlugin inside materializeViaBuiltTree fails plugin-update-built-tree and apply-plugin-files-built-tree, the two sites that share it. Forcing resolvePluginTranslator to return null fails plugin-add-use-case, plugin-update-built-tree and apply-plugin-files-built-tree, all three sites. --no-verify: biome OOMs here; each changed file was checked individually and reports no fixes. Co-authored-by: Claude Opus 5 <[email protected]>
Merged
blafourcade
added a commit
that referenced
this pull request
Jul 31, 2026
🎯 What & why
plugin add,plugin updateandplugin restoreeach resolved a translator and materialized plugin files themselves (B7). Reading all three end to end, the pipeline splits into two genuinely shared steps and one genuinely divergent one.🛠️ How it works
Extracted:
resolvePluginTranslator→ its own file underplugin/translator/, notplugin-helpers.ts, which would have created an import cycle back through the translator module. Used by all three sites.materializeViaBuiltTree→plugin-helpers.ts(a type-only import of the translator class keeps the cycle away). Used by update and restore only:addhas no prior manifest entry to remove and needs different return data, so it keeps calling the translator directly.Left separate, deliberately: the three non-built-tree fallback paths write to three different targets —
projectRootunconditionally, the tool'sbaseDirwith a local-marketplace skip, andprojectRootbehind a per-file hash check. Confirmed different by reading each one, not assumed. Forcing them together would have needed a flag telling the shared function which caller it was serving, which is not a consolidation.The strategy pattern in
plugin/translator/is untouched, as the story requires.🧪 How to verify
Characterization tests came first.
apply-plugin-files-use-case.tshad statements 73-89 uncovered, and that block was exactly what this story rewrites. Two tests now drive that restore path: 75.9% → 100% statements.2109/2109 pass,
tsc --noEmitclean, no existing assertion changed.Mutation-tested twice, because one mutation only proves the sites that share that one function:
manifest.removePlugininsidematerializeViaBuiltTreefailsplugin-update-built-treeandapply-plugin-files-built-tree— the two sites that share it;resolvePluginTranslatorto returnnullfailsplugin-add-use-case,plugin-update-built-treeandapply-plugin-files-built-tree— all three.📋 Pre-existing differences found, not fixed
Out of scope, recorded so they are not lost:
updateandrestorenever invokeModeAMarketplaceTranslator; onlyadddoes.ModeBFlatMaterializationTranslator's OpenCode MCP-merge logic is not reached byupdate/restorefallback paths.restoreViaBuiltTreereturns a total file count, whererestoreViaTranslatereturns a restored-file count.Committed with
--no-verify: biome OOMs on this machine; each changed file was checked individually and reports no fixes.