/** * Dependency-cruiser configuration for AirCoding monorepo * * Enforces DD §2 import-boundary rules: * contracts -> (nothing) — leaf package, no deps * llm -> contracts * toolchain-cpp -> contracts * tui -> contracts * runtime -> contracts, llm — llm facade only * cli -> contracts, runtime, tui, llm, toolchain-cpp * workers -> contracts — WorkerRuntime IPC surface only */ module.exports = { forbidden: [ /* ── Rule 0: contracts must import NOTHING from sibling packages ── */ { name: "contracts-no-internal-deps", comment: "contracts is the leaf package — it must not depend on any other AirCoding package", severity: "error", from: { path: "^packages/contracts/src/" }, to: { path: "^packages/(llm|runtime|tui|cli|workers|toolchain-cpp)/" }, }, /* ── Rule 1: llm may only import from contracts ── */ { name: "llm-boundary", comment: "llm may only depend on contracts", severity: "error", from: { path: "^packages/llm/src/" }, to: { path: "^packages/(runtime|tui|cli|workers|toolchain-cpp)/", pathNot: "^packages/contracts/", }, }, /* ── Rule 2: toolchain-cpp may only import from contracts ── */ { name: "toolchain-cpp-boundary", comment: "toolchain-cpp may only depend on contracts", severity: "error", from: { path: "^packages/toolchain-cpp/src/" }, to: { path: "^packages/(llm|runtime|tui|cli|workers)/", pathNot: "^packages/contracts/", }, }, /* ── Rule 3: tui may only import from contracts ── */ { name: "tui-boundary", comment: "tui may only depend on contracts", severity: "error", from: { path: "^packages/tui/src/" }, to: { path: "^packages/(llm|runtime|cli|workers|toolchain-cpp)/", pathNot: "^packages/contracts/", }, }, /* ── Rule 4: runtime may only import from contracts, llm & toolchain-cpp ── */ { name: "runtime-boundary", comment: "runtime may only depend on contracts, llm (facade), and toolchain-cpp (capability registration)", severity: "error", from: { path: "^packages/runtime/src/" }, to: { path: "^packages/(tui|cli|workers)/", pathNot: "^packages/(contracts|llm|toolchain-cpp)/", }, }, /* ── Rule 5: workers may only import from contracts ── */ { name: "workers-boundary", comment: "workers may only depend on contracts (WorkerRuntime IPC surface)", severity: "error", from: { path: "^packages/workers/src/" }, to: { path: "^packages/(llm|runtime|tui|cli|toolchain-cpp)/", pathNot: "^packages/contracts/", }, }, /* ── Rule 6: cli may import from contracts, runtime, tui, llm, toolchain-cpp ── */ { name: "cli-boundary", comment: "cli may only depend on contracts, runtime, tui, llm, toolchain-cpp", severity: "error", from: { path: "^packages/cli/src/" }, to: { path: "^packages/workers/", pathNot: "^packages/(contracts|runtime|tui|llm|toolchain-cpp)/", }, }, /* ── Rules 7-11: no deep cross-package imports (bypass barrel) ── */ { name: "no-deep-cross-contracts-import", comment: "Don't deep-import from contracts — use its barrel (index.ts)", severity: "warn", from: { path: "^packages/(?!contracts)[^/]+/src/" }, to: { path: "^packages/contracts/src/(?!index\\.ts)" }, }, { name: "no-deep-cross-llm-import", comment: "Don't deep-import from llm — use its barrel (index.ts)", severity: "warn", from: { path: "^packages/(?!llm)[^/]+/src/" }, to: { path: "^packages/llm/src/(?!index\\.ts)" }, }, { name: "no-deep-cross-runtime-import", comment: "Don't deep-import from runtime — use its barrel (index.ts)", severity: "warn", from: { path: "^packages/(?!runtime)[^/]+/src/" }, to: { path: "^packages/runtime/src/(?!index\\.ts)" }, }, { name: "no-deep-cross-tui-import", comment: "Don't deep-import from tui — use its barrel (index.ts)", severity: "warn", from: { path: "^packages/(?!tui)[^/]+/src/" }, to: { path: "^packages/tui/src/(?!index\\.ts)" }, }, { name: "no-deep-cross-toolchain-cpp-import", comment: "Don't deep-import from toolchain-cpp — use its barrel (index.ts)", severity: "warn", from: { path: "^packages/(?!toolchain-cpp)[^/]+/src/" }, to: { path: "^packages/toolchain-cpp/src/(?!index\\.ts)" }, }, ], options: { doNotFollow: { path: "node_modules", }, moduleSystems: ["es6"], tsPreCompilationDeps: true, includeOnly: "^packages/", exclude: [ "node_modules", "dist", "\\.d\\.ts$", ], /* Use TypeScript path mappings to resolve workspace packages */ tsConfig: { fileName: "./tsconfig.json" }, /* Combined deps helps with bun workspaces */ combinedDependencies: true, }, };