Skip to content

chore(cli): commands import infrastructure directly, contradicting the documented architecture #470

Description

@blafourcade

Problem

aidd_docs/memory/architecture.md documents a strict 3-layer flow: Infrastructure → Application → Domain, dependencies flow inward only. But 14 of 15 files in src/application/commands/ (e.g. doctor.ts:2, status.ts:2, restore.ts:2, marketplace.ts:7, plugin.ts:6, setup.ts:11, ai.ts:6, framework.ts:7) call createDeps()/createMenuDeps() imported directly from infrastructure/deps.js inside the action handler.

Why this needs a decision, not just a fix

It's systemic (100% of applicable command files) and consistent, and the leak stops at the wiring boundary — use-cases and domain never import infrastructure. That reads as a deliberate composition-root-in-commands pattern, not erosion. But it contradicts the architecture doc's own diagram with no documented exception, and it blocks unit-testing a command's action handler without constructing real/mocked infra.

Options

  1. Build the deps object once in src/cli.ts and pass it into each registerXCommand(program, deps), so commands stop importing infrastructure directly.
  2. Amend architecture.md to explicitly document commands as an allowed composition-root exception to the inward-only rule.

Acceptance criteria

  • A decision is made and recorded (either the code changes, or the doc changes — not left disagreeing)
  • If option 1: no file under src/application/commands/ imports from infrastructure/ directly
  • If option 2: architecture.md states the exception explicitly, with the reasoning above

Found by an architecture audit of cli/ — full report: cli/aidd_docs/tasks/2026_07/2026_07_22_audit/architecture.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    None yet

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions