Your agent writes it. Kane checks it. โ a closed verify-and-repair loop for AI-written code
๐ Live App | ๐ป GitHub | ๐๏ธ Architecture | ๐ฆ Twitter | ๐ค LinkedIn
--- ## Project Overview **Problem Statement:** AI coding agents write code faster than anyone can check it. The unclosed part of the loop is trust โ when the agent ships, a human still has to open a browser and click through the flow. An agent that cannot observe its own output runs open-loop, and every regression it introduces survives until a person notices. **Solution:** kane-loop is a local dev-loop daemon. A watcher fires Kane CLI against your running app on every save; Kane drives a real Chrome window through a plain-English flow and returns a verdict. On PASS the console shows a green iteration. On FAIL the failing step, its assertion, a console excerpt and the trace path are written to `.kane-loop/failure.md`, and a coding agent (Claude Code or Codex) is spawned with that brief as context. The agent edits the source, the save refires the watcher, Kane runs again. Four attempts without green and it bails loudly rather than looping forever. The console it streams to is itself the app Kane verifies โ the loop verifies the thing that renders the loop. **Relevance:** real browser verification (not mocked), machine-readable verdicts an agent can act on with no human relay, a Claude Code `PostToolUse` hook that fires one verification per agent edit, and committed NDJSON evidence from real runs. --- ## Technical Architecture ``` โโ terminal 1 โโโโโโโโโโโโโโ โโ terminal 2 โโโโโโโโโโโโโโโโโโโโโโโโโ โ bun app/server.ts โ โ bun loop.ts --agent claude โ โ :3000 console + SSE โโโโโโโค watcher โ kane โ parse โ agent โ โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ โโโโโโโโฌโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโ โ โ spawn โ spawn โ โโโโโโโโผโโโโโโโ โโโโโโโโผโโโโโโโโโโโ โ โ kane-cli โ โ claude -p โ โ โ real Chrome โ โ or codex exec โ โ โโโโโโโโฌโโโโโโโ โโโโโโโโฌโโโโโโโโโโโ โ โ drives โ edits โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โผ localhost:3000 src/ ``` **The loop, in four beats:** - **Save** โ watcher on `app/` and `src/`, 800ms debounce - **Verify** โ `kane-cli testmd run` against the flow, NDJSON parsed line by line into a `KaneResult` - **Repair** โ failure brief written, agent CLI spawned with it as context - **Repeat** โ the agent's edit refires the watcher; cap 4, then bail loudly **Core tech stack:** - **Runtime:** Bun + TypeScript, no framework, no LLM SDK, no database - **Verification:** Kane CLI (`@testmuai/kane-cli`) driving real Chromium - **Agents:** `claude -p` / `codex exec` as spawned subprocesses โ no API key anywhere - **Console:** `Bun.serve` with SSE at `/events`; marketing site + dashboard in Next.js 16 on Vercel - **Container:** Dockerfile ships its own Chromium for headless deploys --- ## Core Components **Source directories:** `loop.ts`, `src/`, `app/`, `flows/` | Module | Description | |---|---| | `loop.ts` | Watcher + state machine: `IDLE โ VERIFYING โ REPAIRING`, iteration cap 4, `--once` mode for the hook | | `src/kane.ts` | Spawns `kane-cli`, parses NDJSON into `KaneResult` (verdict, per-step ok, trace path), always retains raw output | | `src/agents.ts` | `AgentAdapter` โ `claude` and `codex` adapters, plus a paste-ready manual degradation path | | `src/bus.ts` | In-memory pub/sub feeding the SSE stream | | `app/server.ts` | `Bun.serve` โ `/`, `POST /api/run`, `GET /events`, `/evidence/*` | | `flows/smoke_test.md` | The Kane flow that verifies the console itself | | `evidence/` | Committed NDJSON + stderr from real runs, so a demo survives a network outage | **Wire it into Claude Code** โ one verification per agent edit: ```json { "hooks": { "PostToolUse": [ { "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "bun loop.ts --once" } ] } ] } } ``` Kane also ships its own agent skill: `kane-cli install claude-code`. --- ## Installation & Setup **Requirements:** - Bun 1.x - Node.js 18+ (for the global install) - A TestMu AI account โ free credits at [testmuai.com/register](https://testmuai.com/register) **Steps:** 1. Install and authenticate Kane CLI ```bash npm install -g @testmuai/kane-cli kane-cli login --oauth ``` 2. Clone and install ```bash git clone https://github.com/Venkat5599/kane cd kane bun install ``` 3. Run the console and the loop ```bash bun run app # terminal 1 โ console on :3000 bun run loop # terminal 2 โ watcher + Kane + agent ``` 4. Open `http://localhost:3000`, enter a target URL and a check in plain English, click **Run Verification**. Then edit anything under `app/` or `src/` and watch the loop fire. > With `--agent claude`, run `bun run loop` from a **plain terminal**. Claude Code blocks nested sessions, so the spawn fails from inside one. `--agent codex` works from either. **Commands:** | Command | Does | |---|---| | `bun run app` | Console + SSE on :3000 | | `bun run loop` | Watch, verify, repair | | `bun run once` | One verification, write the brief, no agent | | `bun loop.ts --agent codex --max 6` | Pick agent / iteration cap | **Config:** every Kane invocation flag lives in one block, `src/kane.ts` โ `KANE`, overridable by env: `KANE_BIN`, `KANE_RUN_ARGS`, `KANE_JSON_FLAG`, `KANE_TARGET_FLAG`, `KANE_EXTRA_ARGS`, `KANE_TIMEOUT_MS`. --- ## Demo **Live demo:** https://kane-loop.vercel.app ### Screenshots **Landing page**