Skip to content

refactor: Add dependency injection for gitCommand, tmux, and Bun.spawn #45

@nigel-dev

Description

@nigel-dev

Source

Audit report — Section 7: Technical Debt > Architecture

Description

orchestrator.ts, worktree.ts, integration.ts, and other core modules directly import and call gitCommand(), tmux functions, and Bun.spawn(). This makes unit testing difficult — tests must mock module-level imports via spyOn rather than injecting test doubles through constructors.

Current State

  • orchestrator.ts directly imports from tmux.ts, git.ts, integration.ts, worktree.ts
  • Tests use spyOn(module, 'function') pattern extensively (fragile, order-dependent)
  • No interface abstractions for git operations, tmux, or process spawning

Proposed Solution

  1. Define interfaces: GitClient, Multiplexer, ProcessRunner
  2. Accept these via constructor injection in Orchestrator, MergeTrain, WorktreeProvider
  3. Provide default implementations wrapping current functions
  4. Tests inject mocks directly — no more module-level spying

Relationship to Other Issues

Priority

P3 — architectural improvement, not blocking any functionality. Best done alongside #17 decomposition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3: lowNice to have — polish, cleanup, or long-termenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions