Skip to content

refactor(cli): share the plugin translator pipeline - #546

Merged
blafourcade merged 1 commit into
nextfrom
refactor/e7-03-translator-pipeline
Jul 28, 2026
Merged

blafourcade merged 1 commit into
nextfrom
refactor/e7-03-translator-pipeline

Conversation

@blafourcade

Copy link
Copy Markdown
Contributor

🎯 What & why

plugin add, plugin update and plugin restore each 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 under plugin/translator/, not plugin-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: 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 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.ts had 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 --noEmit clean, no existing assertion changed.

Mutation-tested twice, because one mutation only proves the sites that share that one function:

  • 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.

📋 Pre-existing differences found, not fixed

Out of scope, recorded so they are not lost:

  • update and restore never invoke ModeAMarketplaceTranslator; only add does.
  • ModeBFlatMaterializationTranslator's OpenCode MCP-merge logic is not reached by update/restore fallback paths.
  • restoreViaBuiltTree returns a total file count, where restoreViaTranslate returns a restored-file count.

Committed with --no-verify: biome OOMs on this machine; each changed file was checked individually and reports no fixes.

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
blafourcade merged commit a9abe8b into next Jul 28, 2026
14 checks passed
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]>
@aidd-bot aidd-bot Bot mentioned this pull request Jul 31, 2026