0
Kai Detmers
← Project index
Developer tooling · context engineering · 2026npm + desktop workbench

CAI— keep the agent's mental model honest.

CAI detects drift between agent instructions and the repository they describe, then pushes the same context engine into CI, MCP and a desktop workbench. The deterministic core stays independent from the optional AI layer so verification remains reproducible.

CAI health terminal showing drift score and findings
Actual cai health output. The terminal is the primary product surface, not a marketing mockup.

Stack

CoreTypeScript strict · ESM · Commander
Code modelweb-tree-sitter · Git history · Markdown parsing
Agent deliveryMCP over stdio · focused context modes
VerificationVitest · language adapters · CI gates
DesktopTauri · Rust shell · system webview
Releasenpm · GitHub Actions

How it evolved

Process reconstruction — based on the repository timeline and current architecture. Exact motivations are condensed where the commits show the change but not a written design rationale.

01
Begin as a deterministic drift linter.

The first useful question was simple: do CLAUDE.md, AGENTS.md, Cursor and Copilot instructions still match the files, scripts and dependencies that actually exist?

02
Move from detection to evidence-backed repair.

Fix impact preview, drift-fix hit rate and configurable scoring turned warnings into an engineering loop: what will change, what improved, and which drift matters on hot paths?

03
Make context distribution part of the product.

MCP context delivery and push-based injection let agents request headings, summaries or full context rather than loading one giant instruction document on every turn.

04
Promote verification into a blocking gate.

CI annotations, type/build adapters and baseline comparisons made “task complete” contingent on repository evidence rather than an agent saying it looks done.

05
Add a GUI — then remove GUI.

The workbench initially expanded into more tabs, then Health was folded into Overview and six tabs became five. The design improved by deleting navigation and making the core questions visible sooner.

06
Make live updates calmer and more meaningful.

Re-rendering on every filesystem timestamp caused flicker, focus loss and repeated animations. Updates were changed to react to an actual drift signature, while telemetry surfaced “what your AI reads” and hot files.

Interface rationale

CLI is the source of truthThe desktop app consumes the same engine and contracts. It never reimplements drift logic, so terminal, CI, MCP and GUI cannot disagree about system state.
Overview answers three questionsWhat is stale? What context is the agent actually reading? What is the next useful action? Anything else belongs behind progressive disclosure.
Errors stay visible; noise collapsesMCP and GUI output distill warning/info detail while preserving blocking errors. Context tooling becomes unusable if every run produces a wall of diagnostics.
Calm live stateA developer tool must preserve selection, focus and spatial memory. Rerendering only on semantic drift makes live monitoring feel stable rather than “realtime” for its own sake.
CAI command overview
The CLI surface grew beyond checking into verification, context distribution and repair — but remains the canonical backend for every UI.

Core engineering decisions

No LLM in the gateDrift checks use filesystem/Git/AST evidence so CI is fast and reproducible. AI can help rewrite documentation, but not decide whether a deterministic gate passes.
Hot-path weightingA stale file that an agent reads every third turn matters more than an unused appendix. Local access telemetry changes prioritization from raw issue count to operational impact.
Focused MCP contextAgents choose headings, summary or full context. The interface optimizes information delivery instead of assuming more tokens equals more context quality.
Parity contractsThe Tauri workbench adapts versioned CLI output rather than importing business logic. That keeps the npm tool lightweight and the GUI replaceable.

Where it is going

The project started as “lint the instructions.” It is moving toward a broader context-control plane: plan what context should exist, measure what agents consume, evaluate whether it improves work, and learn candidate rules without silently mutating the repository.