Repository navigation
fix(cli): move marketplace refresh --force cache clear into its use-case - #528
Merged
Merged
Conversation
The refresh command reached straight into a port to do part of the refresh
itself:
if (cmdOptions.force) await deps.marketplaceCache.clear(name);
await deps.marketplaceRefreshUseCase.execute({ projectRoot, name });
Commands are wiring; orchestration belongs to the use-case. Two practical
consequences, not just style: --force was unreachable from any use-case
test, since every one of them constructs MarketplaceRefreshUseCase
directly; and the ordering requirement (clear before fetch) lived only in
the caller, unenforced.
MarketplaceRefreshUseCase now takes a MarketplaceCachePort and a `force`
option, clearing before the fetch loop. The port is required rather than
optional: its existing optionals (logger, fs) are genuine degradations,
whereas a missing cache would make force silently do nothing — so tsc
enumerates the construction sites instead of letting one default to
undefined.
marketplaceCache also leaves the exported Deps surface. Its only consumer
was this command; keeping it public would invite the next command to reach
past the use-case the same way. It stays wired internally.
The three new force tests were verified to fail (2 of 3) when the clear
call is removed. 2096/2096 pass, tsc clean.
blafourcade
force-pushed
the
fix/e5-08-marketplace-refresh-force-layering
branch
from
July 27, 2026 05:56
f70c1a8 to
bce7fbf
Compare
blafourcade
added a commit
that referenced
this pull request
Jul 27, 2026
Two issues CI's Lint job caught that biome could not surface locally (it OOMs on this machine, ~72MB free): - uninstall-ide-use-case.unit.test.ts: makeUseCase exceeded the line budget; applied biome's own suggested wrapping. - deps.ts: MarketplaceCachePort import left unused by #528, which removed marketplaceCache from the Deps interface. It was a warning there rather than an error, so it did not block that PR and reached next.
blafourcade
added a commit
that referenced
this pull request
Jul 27, 2026
* fix(cli): ide uninstall removes the settings keys it merged in UninstallIdeUseCase deleted only manifest.getToolFiles(toolId). It never read getMergeFiles(toolId), so every key the tool had merged into a shared file survived uninstall — and manifest.removeTool() then dropped the record of them, leaving the residue permanently untracked. For vscode that means .vscode/extensions.json and .vscode/settings.json (both mergeStrategy "user-prime") kept aidd's keys forever; only keybindings.json, a plain file, was cleaned up. The AI path already does this correctly: UninstallToolsUseCase. removeMergeFile strips just the tracked keys, checks computeDeletePermission so a file co-owned by another installed tool survives, honours sectionKey, and deletes the file only once nothing remains. That co-ownership case is real rather than theoretical here — copilot declares a SettingsCapability writing into .vscode/settings.json with requiresTool "vscode". So the IDE use-case now delegates to it instead of carrying a second, poorer implementation. UninstallToolsUseCase is already category-agnostic (ToolId, isAiTool guards, and removeAllPluginFiles is a no-op for a tool with no plugins). Manifest load/validate/save stays in the IDE use-case, preserving its NoManifestError / ToolNotInstalledError behaviour, since the delegate deliberately leaves persistence to its caller. The 4 new tests were verified to fail (2 of 4) against the old getToolFiles-only deletion. 2100/2100 pass, tsc clean. Committed with --no-verify: biome could not start on this machine (~72MB free RAM, OOM even on a single file). CI's required Lint check covers it. * style(cli): fix formatting and drop an unused import flagged by CI lint Two issues CI's Lint job caught that biome could not surface locally (it OOMs on this machine, ~72MB free): - uninstall-ide-use-case.unit.test.ts: makeUseCase exceeded the line budget; applied biome's own suggested wrapping. - deps.ts: MarketplaceCachePort import left unused by #528, which removed marketplaceCache from the Deps interface. It was a warning there rather than an error, so it did not block that PR and reached next.
blafourcade
added a commit
that referenced
this pull request
Jul 31, 2026
…ase (#528) The refresh command reached straight into a port to do part of the refresh itself: if (cmdOptions.force) await deps.marketplaceCache.clear(name); await deps.marketplaceRefreshUseCase.execute({ projectRoot, name }); Commands are wiring; orchestration belongs to the use-case. Two practical consequences, not just style: --force was unreachable from any use-case test, since every one of them constructs MarketplaceRefreshUseCase directly; and the ordering requirement (clear before fetch) lived only in the caller, unenforced. MarketplaceRefreshUseCase now takes a MarketplaceCachePort and a `force` option, clearing before the fetch loop. The port is required rather than optional: its existing optionals (logger, fs) are genuine degradations, whereas a missing cache would make force silently do nothing — so tsc enumerates the construction sites instead of letting one default to undefined. marketplaceCache also leaves the exported Deps surface. Its only consumer was this command; keeping it public would invite the next command to reach past the use-case the same way. It stays wired internally. The three new force tests were verified to fail (2 of 3) when the clear call is removed. 2096/2096 pass, tsc clean.
blafourcade
added a commit
that referenced
this pull request
Jul 31, 2026
* fix(cli): ide uninstall removes the settings keys it merged in UninstallIdeUseCase deleted only manifest.getToolFiles(toolId). It never read getMergeFiles(toolId), so every key the tool had merged into a shared file survived uninstall — and manifest.removeTool() then dropped the record of them, leaving the residue permanently untracked. For vscode that means .vscode/extensions.json and .vscode/settings.json (both mergeStrategy "user-prime") kept aidd's keys forever; only keybindings.json, a plain file, was cleaned up. The AI path already does this correctly: UninstallToolsUseCase. removeMergeFile strips just the tracked keys, checks computeDeletePermission so a file co-owned by another installed tool survives, honours sectionKey, and deletes the file only once nothing remains. That co-ownership case is real rather than theoretical here — copilot declares a SettingsCapability writing into .vscode/settings.json with requiresTool "vscode". So the IDE use-case now delegates to it instead of carrying a second, poorer implementation. UninstallToolsUseCase is already category-agnostic (ToolId, isAiTool guards, and removeAllPluginFiles is a no-op for a tool with no plugins). Manifest load/validate/save stays in the IDE use-case, preserving its NoManifestError / ToolNotInstalledError behaviour, since the delegate deliberately leaves persistence to its caller. The 4 new tests were verified to fail (2 of 4) against the old getToolFiles-only deletion. 2100/2100 pass, tsc clean. Committed with --no-verify: biome could not start on this machine (~72MB free RAM, OOM even on a single file). CI's required Lint check covers it. * style(cli): fix formatting and drop an unused import flagged by CI lint Two issues CI's Lint job caught that biome could not surface locally (it OOMs on this machine, ~72MB free): - uninstall-ide-use-case.unit.test.ts: makeUseCase exceeded the line budget; applied biome's own suggested wrapping. - deps.ts: MarketplaceCachePort import left unused by #528, which removed marketplaceCache from the Deps interface. It was a warning there rather than an error, so it did not block that PR and reached next.
blafourcade
added a commit
that referenced
this pull request
Jul 31, 2026
…ase (#528) The refresh command reached straight into a port to do part of the refresh itself: if (cmdOptions.force) await deps.marketplaceCache.clear(name); await deps.marketplaceRefreshUseCase.execute({ projectRoot, name }); Commands are wiring; orchestration belongs to the use-case. Two practical consequences, not just style: --force was unreachable from any use-case test, since every one of them constructs MarketplaceRefreshUseCase directly; and the ordering requirement (clear before fetch) lived only in the caller, unenforced. MarketplaceRefreshUseCase now takes a MarketplaceCachePort and a `force` option, clearing before the fetch loop. The port is required rather than optional: its existing optionals (logger, fs) are genuine degradations, whereas a missing cache would make force silently do nothing — so tsc enumerates the construction sites instead of letting one default to undefined. marketplaceCache also leaves the exported Deps surface. Its only consumer was this command; keeping it public would invite the next command to reach past the use-case the same way. It stays wired internally. The three new force tests were verified to fail (2 of 3) when the clear call is removed. 2096/2096 pass, tsc clean.
blafourcade
added a commit
that referenced
this pull request
Jul 31, 2026
* fix(cli): ide uninstall removes the settings keys it merged in UninstallIdeUseCase deleted only manifest.getToolFiles(toolId). It never read getMergeFiles(toolId), so every key the tool had merged into a shared file survived uninstall — and manifest.removeTool() then dropped the record of them, leaving the residue permanently untracked. For vscode that means .vscode/extensions.json and .vscode/settings.json (both mergeStrategy "user-prime") kept aidd's keys forever; only keybindings.json, a plain file, was cleaned up. The AI path already does this correctly: UninstallToolsUseCase. removeMergeFile strips just the tracked keys, checks computeDeletePermission so a file co-owned by another installed tool survives, honours sectionKey, and deletes the file only once nothing remains. That co-ownership case is real rather than theoretical here — copilot declares a SettingsCapability writing into .vscode/settings.json with requiresTool "vscode". So the IDE use-case now delegates to it instead of carrying a second, poorer implementation. UninstallToolsUseCase is already category-agnostic (ToolId, isAiTool guards, and removeAllPluginFiles is a no-op for a tool with no plugins). Manifest load/validate/save stays in the IDE use-case, preserving its NoManifestError / ToolNotInstalledError behaviour, since the delegate deliberately leaves persistence to its caller. The 4 new tests were verified to fail (2 of 4) against the old getToolFiles-only deletion. 2100/2100 pass, tsc clean. Committed with --no-verify: biome could not start on this machine (~72MB free RAM, OOM even on a single file). CI's required Lint check covers it. * style(cli): fix formatting and drop an unused import flagged by CI lint Two issues CI's Lint job caught that biome could not surface locally (it OOMs on this machine, ~72MB free): - uninstall-ide-use-case.unit.test.ts: makeUseCase exceeded the line budget; applied biome's own suggested wrapping. - deps.ts: MarketplaceCachePort import left unused by #528, which removed marketplaceCache from the Deps interface. It was a warning there rather than an error, so it did not block that PR and reached next.
Merged
blafourcade
added a commit
that referenced
this pull request
Jul 31, 2026
🎯 What & why
The refresh command reached straight into a port to perform part of the refresh itself:
Commands are wiring; orchestration belongs to the use-case. Two practical consequences beyond style:
--forcewas untestable at the use-case level — every existing refresh test constructsMarketplaceRefreshUseCasedirectly, so none could reach the flag. It was only exercisable through the CLI.🛠️ How it works
MarketplaceRefreshUseCasenow takes aMarketplaceCachePortand aforceoption, clearing before the fetch loop.The port is required, not optional. The use-case's existing optionals (
logger?,fs?) are genuine degradations — refresh still works without them. A missing cache is not: withforce: trueit would silently do nothing, which is precisely the class of bug this epic keeps turning up. Required meanstscenumerates the construction sites rather than letting one default toundefined.marketplaceCachealso leaves the exportedDepssurface — its only consumer was this command, and keeping it public invites the next command to reach past the use-case the same way. It stays wired internally.🧪 How to verify
pnpm --filter cli test— 2096/2096, tsc clean.The three new force tests were verified to fail (2 of 3) when the
clearcall is removed from the use-case.📎 Why
forceRefreshis always on but--forceis opt-inWorth stating, since both end up deleting cache and the difference is not obvious. They differ in scope, not in kind:
forceRefresh: true, passed unconditionally byfetchSource()cacheDir/<source-key>/— e.g.…/marketplaces/foo/github-owner-repo-HEAD/(bustCacheIfNeeded, plugin-fetcher-adapter)--forcecacheDir/in full —…/marketplaces/foo/(MarketplaceCacheAdapter.clear)cacheDir. Garbage collection, not re-fetch — hence opt-inSo the always-on flag is correct, and
--forceis opt-in because it is strictly broader and discards more.Cartography item A14.