Skip to content

refactor(cli): resolve plugin catalogs through one path - #547

Merged
blafourcade merged 1 commit into
nextfrom
refactor/e7-04-shared-catalog-resolution
Jul 29, 2026
Merged

blafourcade merged 1 commit into
nextfrom
refactor/e7-04-shared-catalog-resolution

Conversation

@blafourcade

Copy link
Copy Markdown
Contributor

🎯 What & why

The story (item B8) asked to unify "find a plugin by name in a catalog" across plugin search, plugin pick and plugin install. Checked against the code, that premise is false. The three do different things, deliberately:

Use-case Matching
plugin-search entry.name.toLowerCase().includes(q) || description.includes(q) — substring, case-insensitive, name or description
plugin-install-from-marketplace entry.name === options.pluginName — exact, case-sensitive, name only
plugin-pick no matching at all — the whole catalog goes to an interactive prompt

Unifying them would be a behaviour change, not a refactor, and a harmful one: a fuzzy install lets aidd plugin install foo silently install foo-bar. That part of the story is not implemented, and the plan doc records why.

🛠️ How it works

What is genuinely duplicated is catalog resolution. PluginSearchUseCase and PluginPickUseCase each hand-rolled marketplaceCacheDir → fetchMarketplaceSource.execute → catalogRepo.load — precisely the triplet ResolveMarketplaceUseCase encapsulates and that PluginInstallFromMarketplaceUseCase already used. Both now route through it.

Error behaviour is preserved, not harmonized. ResolveMarketplaceUseCase returns catalog: null rather than throwing, so search still returns [] (skip) and pick still throws InvalidPluginManifestError with the same message. Its localPath now comes off the resolver result instead of being recomputed locally — identical by construction, and a test pins the full message since that is where the change could have leaked.

catalogRepo and fetchMarketplaceSource were dropped from both use-cases once grep confirmed zero remaining uses; four construction sites updated including deps.ts.

Left alone: MarketplaceCheckUseCase hand-rolls the same triplet, but it belongs to the marketplace-commands story (B9), not this one.

🧪 How to verify

Characterization tests came first: plugin-pick's missing-catalog path was untested, and it is exactly the path the routing changes. Lines 91.8% → 100%.

2113/2113 pass (2109 baseline plus 4 characterization tests), tsc --noEmit clean, no existing assertion changed.

Mutation-tested by forcing the resolver to return catalog: null: 26 tests failed across plugin-search, plugin-pick, plugin-install-from-marketplace, the resolver's own test, and 4 e2e files — confirming all three callers now share one resolution path.

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

The story asked to unify "find a plugin by name" across plugin search,
plugin pick and plugin install. Checked against the code, that premise is
false. The three do different things deliberately:

  search:  entry.name.toLowerCase().includes(q) || description includes q
  install: entry.name === options.pluginName
  pick:    no matching at all, the whole catalog goes to a prompt

Unifying them would be a behaviour change, not a refactor, and a harmful
one: a fuzzy install lets `aidd plugin install foo` install foo-bar. That
part of the story is not implemented.

What was genuinely duplicated is catalog resolution. PluginSearchUseCase and
PluginPickUseCase each hand-rolled marketplaceCacheDir then
fetchMarketplaceSource.execute then catalogRepo.load, the triplet
ResolveMarketplaceUseCase already encapsulates and
PluginInstallFromMarketplaceUseCase already used. Both now route through it.

Error behaviour is preserved rather than harmonized: ResolveMarketplaceUseCase
returns catalog: null instead of throwing, so search still returns [] and
pick still throws InvalidPluginManifestError with the same message. Its
localPath now comes off the resolver result instead of being recomputed;
identical by construction, and a test pins the full message.

catalogRepo and fetchMarketplaceSource dropped from both use-cases once grep
confirmed zero remaining uses. Four construction sites updated.

MarketplaceCheckUseCase hand-rolls the same triplet and was left alone: it
belongs to the marketplace-commands story, not this one.

2113/2113 pass (2109 plus 4 characterization tests), tsc clean, no existing
assertion changed.

Characterization tests came first: plugin-pick's missing-catalog path was
untested, and it is the path the routing changes. Lines 91.8% to 100%.

Mutation-tested by forcing the resolver to return catalog: null. 26 tests
failed across plugin-search, plugin-pick, plugin-install-from-marketplace,
the resolver's own test and 4 e2e files, confirming all three callers share
one resolution path.

--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 c6dd536 into next Jul 29, 2026
14 checks passed
@blafourcade
blafourcade deleted the refactor/e7-04-shared-catalog-resolution branch July 29, 2026 02:40
blafourcade added a commit that referenced this pull request Jul 31, 2026
The story asked to unify "find a plugin by name" across plugin search,
plugin pick and plugin install. Checked against the code, that premise is
false. The three do different things deliberately:

  search:  entry.name.toLowerCase().includes(q) || description includes q
  install: entry.name === options.pluginName
  pick:    no matching at all, the whole catalog goes to a prompt

Unifying them would be a behaviour change, not a refactor, and a harmful
one: a fuzzy install lets `aidd plugin install foo` install foo-bar. That
part of the story is not implemented.

What was genuinely duplicated is catalog resolution. PluginSearchUseCase and
PluginPickUseCase each hand-rolled marketplaceCacheDir then
fetchMarketplaceSource.execute then catalogRepo.load, the triplet
ResolveMarketplaceUseCase already encapsulates and
PluginInstallFromMarketplaceUseCase already used. Both now route through it.

Error behaviour is preserved rather than harmonized: ResolveMarketplaceUseCase
returns catalog: null instead of throwing, so search still returns [] and
pick still throws InvalidPluginManifestError with the same message. Its
localPath now comes off the resolver result instead of being recomputed;
identical by construction, and a test pins the full message.

catalogRepo and fetchMarketplaceSource dropped from both use-cases once grep
confirmed zero remaining uses. Four construction sites updated.

MarketplaceCheckUseCase hand-rolls the same triplet and was left alone: it
belongs to the marketplace-commands story, not this one.

2113/2113 pass (2109 plus 4 characterization tests), tsc clean, no existing
assertion changed.

Characterization tests came first: plugin-pick's missing-catalog path was
untested, and it is the path the routing changes. Lines 91.8% to 100%.

Mutation-tested by forcing the resolver to return catalog: null. 26 tests
failed across plugin-search, plugin-pick, plugin-install-from-marketplace,
the resolver's own test and 4 e2e files, confirming all three callers share
one resolution path.

--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
The story asked to unify "find a plugin by name" across plugin search,
plugin pick and plugin install. Checked against the code, that premise is
false. The three do different things deliberately:

  search:  entry.name.toLowerCase().includes(q) || description includes q
  install: entry.name === options.pluginName
  pick:    no matching at all, the whole catalog goes to a prompt

Unifying them would be a behaviour change, not a refactor, and a harmful
one: a fuzzy install lets `aidd plugin install foo` install foo-bar. That
part of the story is not implemented.

What was genuinely duplicated is catalog resolution. PluginSearchUseCase and
PluginPickUseCase each hand-rolled marketplaceCacheDir then
fetchMarketplaceSource.execute then catalogRepo.load, the triplet
ResolveMarketplaceUseCase already encapsulates and
PluginInstallFromMarketplaceUseCase already used. Both now route through it.

Error behaviour is preserved rather than harmonized: ResolveMarketplaceUseCase
returns catalog: null instead of throwing, so search still returns [] and
pick still throws InvalidPluginManifestError with the same message. Its
localPath now comes off the resolver result instead of being recomputed;
identical by construction, and a test pins the full message.

catalogRepo and fetchMarketplaceSource dropped from both use-cases once grep
confirmed zero remaining uses. Four construction sites updated.

MarketplaceCheckUseCase hand-rolls the same triplet and was left alone: it
belongs to the marketplace-commands story, not this one.

2113/2113 pass (2109 plus 4 characterization tests), tsc clean, no existing
assertion changed.

Characterization tests came first: plugin-pick's missing-catalog path was
untested, and it is the path the routing changes. Lines 91.8% to 100%.

Mutation-tested by forcing the resolver to return catalog: null. 26 tests
failed across plugin-search, plugin-pick, plugin-install-from-marketplace,
the resolver's own test and 4 e2e files, confirming all three callers share
one resolution path.

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