Repository navigation
refactor(cli): inject PostInstallPipelineUseCase and GitignoreUseCase - #523
Merged
Merged
Conversation
Both were instantiated ad hoc at 6 sites, escaping the dependency graph entirely — no test could substitute either at the command level, unlike every other shared use-case. deps.ts now builds each once and injects them: GitignoreUseCase -> PostInstallPipelineUseCase -> the 3 install use-cases, and GitignoreUseCase -> CleanUseCase. Both verified stateless (only readonly constructor deps) before being shared as singletons, same check applied in #508. Dead constructor params removed as a consequence, each checked per file rather than assumed: PostInstallPipelineUseCase drops `fs` (its only use was the removed `new GitignoreUseCase`), and InstallIdeConfigUseCase / InstallRuntimeConfigUseCase drop `manifestRepo` (their only use was the removed `new PostInstallPipelineUseCase`). InstallIdeToolUseCase still uses manifestRepo once, so it keeps it; clean-use-case uses `fs` 13 times, so it keeps that. Scope: 5 of the 6 sites. init-use-case.ts is deliberately left alone — InitUseCase is not in the dependency graph at all (no deps.ts entry; it is itself ad-hoc constructed by setup-use-case.ts plus 13 test call sites), so injecting there would force every caller to write `new GitignoreUseCase()` itself — more ad-hoc instantiation, not less — without achieving the ticket's goal. Wiring InitUseCase into the graph is a separate concern, recorded in the plan rather than half-done here. 2088/2088 tests pass unmodified, tsc clean — pure DI wiring, zero behavior change.
blafourcade
added a commit
that referenced
this pull request
Jul 31, 2026
…#523) Both were instantiated ad hoc at 6 sites, escaping the dependency graph entirely — no test could substitute either at the command level, unlike every other shared use-case. deps.ts now builds each once and injects them: GitignoreUseCase -> PostInstallPipelineUseCase -> the 3 install use-cases, and GitignoreUseCase -> CleanUseCase. Both verified stateless (only readonly constructor deps) before being shared as singletons, same check applied in #508. Dead constructor params removed as a consequence, each checked per file rather than assumed: PostInstallPipelineUseCase drops `fs` (its only use was the removed `new GitignoreUseCase`), and InstallIdeConfigUseCase / InstallRuntimeConfigUseCase drop `manifestRepo` (their only use was the removed `new PostInstallPipelineUseCase`). InstallIdeToolUseCase still uses manifestRepo once, so it keeps it; clean-use-case uses `fs` 13 times, so it keeps that. Scope: 5 of the 6 sites. init-use-case.ts is deliberately left alone — InitUseCase is not in the dependency graph at all (no deps.ts entry; it is itself ad-hoc constructed by setup-use-case.ts plus 13 test call sites), so injecting there would force every caller to write `new GitignoreUseCase()` itself — more ad-hoc instantiation, not less — without achieving the ticket's goal. Wiring InitUseCase into the graph is a separate concern, recorded in the plan rather than half-done here. 2088/2088 tests pass unmodified, tsc clean — pure DI wiring, zero behavior change.
🎯 What & why
PostInstallPipelineUseCaseandGitignoreUseCasewere instantiated ad hoc at 6 sites, escaping the dependency graph entirely — no test could substitute either at the command level, unlike every other shared use-case.🛠️ How it works
deps.tsnow builds each once and injects them:GitignoreUseCase→PostInstallPipelineUseCase→ the 3 install use-cases, andGitignoreUseCase→CleanUseCase. Both verified stateless (onlyreadonlyconstructor deps) before being shared as singletons — same check applied in #508.Dead constructor params removed as a consequence, each checked per file rather than assumed:
PostInstallPipelineUseCasedropsfs— its only use was the removednew GitignoreUseCase(this.fs)InstallIdeConfigUseCase/InstallRuntimeConfigUseCasedropmanifestRepo— their only use was the removednew PostInstallPipelineUseCase(...)InstallIdeToolUseCasekeepsmanifestRepo(still used once);CleanUseCasekeepsfs(used 13×)I initially got the
manifestRepopart wrong — the plan asserted it stayed in use across all three install use-cases because I'd countedthis.fsbut notthis.manifestRepo. Biome'snoUnusedPrivateClassMemberscaught it at commit time;tscthen enumerated all 8 affected call sites. Recorded in the plan's Decisions rather than quietly fixed.🧪 How to verify
pnpm --filter cli test— 2088/2088 unmodified, tsc clean. Pure DI wiring, zero behavior change:.gitignorestill gains.aidd/cache/on install,aidd cleanstill removes it.5 of the 6 sites converted, not 6.
init-use-case.tsis deliberately left alone:InitUseCaseis not in the dependency graph at all — nodeps.tsentry, and it is itself ad-hoc constructed bysetup-use-case.tsplus 13 test call sites. InjectingGitignoreUseCasethere would force every one of those callers to writenew GitignoreUseCase(deps.fs)itself — more ad-hoc instantiation, not less — while still not achieving the ticket's goal, sinceInitUseCasekeeps escaping the graph one level up. WiringInitUseCaseintodeps.tsis a distinct concern; recorded in the plan rather than half-done here.Planned in the (now-archived) standalone
aidd-clirepo before the framework migration (#462), cartography item B11.