codetwin

Crates

CodeTwin is organised as a Cargo workspace. Each crate has one job and a narrow public surface. New crates are added when a real seam appears (two adapters, not one).

Index

Crate Role Depends on
codetwin Published binary. main.rs only — parse argv, init tracing, dispatch. codetwin-cli (eventually); codetwin-legacy (today)
codetwin-cli clap-derived CLI surface and subcommand dispatch. codetwin-config, codetwin-pipeline
codetwin-pipeline Orchestration: discover → parse → merge → render → write. Owns snapshot, diff, watch. codetwin-ir, codetwin-config, codetwin-drivers, codetwin-render
codetwin-render Markdown / Mermaid builders and the Layout trait + built-in layouts. codetwin-ir
codetwin-drivers Driver trait, auto-detection registry, and per-language tree-sitter drivers. codetwin-ir
codetwin-config codetwin.toml schema + loader + override merging. (leaf)
codetwin-ir Intermediate representation: CodeModel, Module, Symbol, Edge. (leaf)
codetwin-legacy Transitional. Holds the pre-workspace monolith while modules migrate out. (everything the monolith did)

Dependency DAG

codetwin (bin)
  └── codetwin-legacy           ← today
       └── (will become)
            codetwin-cli
              └── codetwin-pipeline
                   ├── codetwin-render ──┐
                   ├── codetwin-drivers ─┼── codetwin-ir
                   └── codetwin-config   ┘

Edges only point downward. A leaf crate must never depend on a higher-level one. Adding an upward edge needs an explicit ADR.

Conventions

Adding a new crate

  1. Confirm the seam is real (two adapters, not one — see AGENTS.md).
  2. Add the crate’s directory under crates/<name>/ with Cargo.toml + src/lib.rs.
  3. Register it in [workspace.dependencies] at the root.
  4. Add a row to the table above.
  5. Update the dependency DAG diagram if a new edge appears.

Phase 0 migration status

codetwin-legacy is being decomposed. As modules move out:

When codetwin-legacy is empty, delete it and switch the bin to depend on codetwin-cli. Track in ROADMAP.md Phase 0.