Files
AirCoding/.dependency-cruiser.js
AirCoding ae44be31d5 chore: push all design docs, V2 plan specs, and current working state
Includes AirPlan design documents, AircOding-alpha1-plan, AirPlanV2,
AirPlan-ParaV2, AirPlan-Para V1 reference docs, and all working code
changes across packages.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-12 17:12:29 +08:00

153 lines
5.2 KiB
JavaScript
Executable File

/**
* 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, runtime — WorkerRuntime IPC + shared utilities
*/
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 import from contracts and runtime ── */
{
name: "workers-boundary",
comment: "workers may depend on contracts (IPC surface) and runtime (shared utilities like CompressionValidator)",
severity: "error",
from: { path: "^packages/workers/src/" },
to: {
path: "^packages/(llm|tui|cli|toolchain-cpp)/",
pathNot: "^packages/(contracts|runtime)/",
},
},
/* ── 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,
},
};