kane-loop Banner

kane-loop

kane-loop

Your agent writes it. Kane checks it. โ€” a closed verify-and-repair loop for AI-written code

Live Hackathon Bun Next.js TypeScript MIT

๐ŸŒ 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**

kane-loop landing page

**Dashboard overview โ€” every number came out of a real Kane run**

kane-loop dashboard overview

**Loop โ€” run a check, watch the loop close**

kane-loop loop page

**Evidence โ€” committed NDJSON and traces**

kane-loop evidence page

**Local console โ€” the app Kane verifies**

kane-loop local console

--- ## A Note on Exposure `POST /api/run` takes a user-supplied URL and drives a real browser at it, so the server binds to `127.0.0.1` only. Do not expose it publicly as-is โ€” an open instance is a browser-driving primitive for anyone who can reach it. If you tunnel it for a demo, close the tunnel afterwards. Kane credentials live in Kane's own config; `.kane-loop/` stays gitignored. --- ## Roadmap **Completed features:** - Kane run console โ€” target URL + plain-English check โ†’ real browser verdict, SSE-streamed - Closed loop: Kane verdict โ†’ failure brief โ†’ agent patch โ†’ Kane rerun, unattended - `claude` and `codex` agent adapters, plus a manual degradation path - Claude Code `PostToolUse` hook โ€” one verification per agent edit - Iteration cap with a loud bail, so it never loops forever - Tolerant NDJSON parser โ€” unknown events ignored, raw output always retained - `evidence/` โ€” committed NDJSON + stderr from real runs - Next.js site and dashboard (Overview / Loop / Runs / Evidence), dark and light - Dockerfile shipping its own Chromium for headless deploys **Next phase plans:** - Persist iterations beyond JSONL โ€” a real run history with diffs - Multi-flow projects, not just one smoke flow - Failure-brief templates tuned per agent - Hosted mode with auth so `/api/run` can be exposed safely - GitHub Action that runs the loop on pull requests --- ## Team **Team name:** kane-loop **Members & roles:** - Venkata Ramana Komari โ€” solo builder (loop engine, console, site, deployment) **Contact:** komarivenkataramana4@gmail.com --- ## Docs [PRD](./PRD.md) ยท [Architecture](./ARCHITECTURE.md) ยท [Runbook](./RUNBOOK.md) ยท [Checklist](./TODO.md) --- ## License MIT