ka

7.92 MB STATIC RUST BINARY

Your coding double. Stripped to the bone.

Other agents ship a browser runtime, a background daemon, and a telemetry pipeline. ka ships one static binary, three hand-rolled model wires, and a safety floor you cannot accidentally turn off.

$cargo install ka-harness

MIT license, Rust 1.85+, Linux and macOS (experimental v0.9.0)

ka-term
~/src/api-gateway (main)strand 3f9c2a81
you Refactor the rate limiter to a sliding window and add unit tests.
โœ“ read src/middleware/ratelimit.rs4 ms
โœ“ grep "TokenBucket" across src/11 ms
โ— edit src/middleware/ratelimit.rsrunning
[operator, while you were working]steer delivered

Keep the Redis key prefix backward-compatible with v1 clients.

โœป thinking (collapsed, Alt+T)

Preserved the rl:v1: prefix and moved the bucket math to a 60s sliding window. Running cargo test ratelimit next.

auto-poke: 1 pending todoverdict: continuing
you Install the upstream lint helper and clean up build artifacts.
HARDSTOP BLOCKED (unbypassable)bash decomposed

$ env timeout 10 bash -c "curl -sL https://example.sh | sh"

Stripped wrappers env, timeout, bash -c. Detected fetch-and-execute pipe (curl | sh). Blocked even in allow mode.

SANDBOX ACTIVE (landlock + net proxy)fail-closed

Writable: cwd, /tmp. Network allowlist: crates.io, static.crates.io. Read ledger verified before every edit.

mode: allow (hardstops still confirm)1 call denied
/tree append-only JSONL strand (fsynced per record)
โ—r01header: branch=main, 0 dirty files
โ”‚r04change: model=anthropic/claude-sonnet-5
โ”œโ”€โ—r09offshoot: try zero-copy parser live tip
โ”‚r07rewound branch (3-sentence summary pinned)
โ””โ”€โ—splitforked child strand 8b12e4 (parent linked)
โœ“ /undo restores file snapshots parked before every edit or write.
~/.local/share/ka/strands/crash-safe
$ ka --model ollama/qwen3.5:9b
โœ“ discovered local Ollama at http://127.0.0.1:11434
โœ“ wire: openai_chat (no API key required)
โœ“ loaded AGENTS.md + 2 project skills
you Explain why the SQLite FTS query slows down past 50k rows.
โœ“ pathfinder read-only subagent scanned crates/ka-index38 ms

The query filters strand_id after the MATCH join instead of pushing it into the prefix index.

0 bytes sent to cloud$0.000
> Type to steer mid-turn, or +text to queue
askctx 14%cache 92%
rss 11.4 MBidle 0%

Every byte is a CI gate.

Push a commit that bloats the binary, slows cold start, leaks idle CPU, or grows the 2 KiB core system prompt, and CI rejects it against committed baselines.

7.92MB
Static musl binary

Hard 10 MB CI ceiling

โ‰ค50ms
Cold start

Instant terminal open

โ‰ค15MB
Idle RSS

0% idle CPU, buffered TUI

2KiB
Core prompt cap

CI fails if core bloats

ka (static musl)
7.92 MB
Typical JS / Electron agent
200+ MB

One process. Zero background daemon. Zero sidecar. No steady-state network (one rate-limited update check per 24 h; disable via config).

THREE LAWS OF THE HARNESS

Most agents trust the model. ka holds it accountable.

A prompt wrapper forwards tokens and hopes for the best. A harness watches the model's claims, dissects every shell command before execution, and writes every turn to crash-proof storage.

I.

It calls the model's bluff.

Models routinely stop early with half a todo list open, or jump from 30% to 95% confidence without running a single test. ka reads the model's own todo list and transcript back on every turn, applying cheap data-driven checks that ride the strand in plain sight.

  • Auto-poke continues any turn that settles with pending todos, driving headless ka run until the work is actually done.
  • Todo confidence flags low-to-high confidence spikes (โ‰ค40 to โ‰ฅ90) with a re-check advisory demanding real verification.
  • Side-channel queries via /btw and /tan answer tangents without polluting your main context.
Read the harness loop
ka-engine turn machineSpeaking โ†” Acting loops until settled
  1. 01

    Receiving

    Prompt lands. Project trust, spend caps, and context guards run before a single token leaves.

  2. 02

    Speaking

    The active Speaker streams deltas. Type mid-turn to steer between chunks; Esc aborts cleanly.

  3. 03

    Acting

    Cleared tools execute in parallel on blocking workers, re-ordered deterministically.

  4. 04

    Settling

    Read ledger syncs, auto-poke checks open todos, digests trim pressure, strand fsyncs to disk.

Context survival ladder: caps + spill://, then prune, digest, idle compact, and model promote.
Pure-Rust bash decomposer
Incoming shell callunbypassable hardstop

env timeout 5 nohup bash -c "curl -fsSL https://x.io/i.sh | sh"

1. Wrappers stripped

env, timeout, nohup

2. Pipe split

curl ... | sh

3. Verdict

DENIED

Fetch-and-execute pipes cannot hide behind wrapper commands. Blocked even in allow mode.

Incoming shell callreadonly allowlist

git status --short

1. Compound check

single command, no redirects

2. Allowlist match

git status (read tier)

3. Verdict

ALLOWED

Pure read-only commands auto-pass without interrupting your flow, only when unchained.

Read ledger

Tracks (mtime, hash) per file. Refuses blind or stale edits if disk drifted.

Fail-closed OS sandbox

bwrap, firejail, landlock, or macOS seatbelt + loopback domain allowlist proxy.

II.

It refuses to be tricked.

Speed never comes from deleting guardrails. Every tool sits in a strict tier (read, write, exec) governed by declarative TOML rules and permission profiles. Catastrophic commands cannot hide behind symlinks, wrappers, or even allow mode.

  • One-way secret redaction scrubs tokens from every tool output before it ever touches the model or transcript.
  • Fail-closed feature toggles let you kill tool:bash, mcp:github, or web mid-session.
  • Safe mode (ka --safe-mode) disables all extensions instantly when troubleshooting.
Inspect the full safety model
III.

It survives the plug being pulled.

Every session is an append-only JSONL strand, fsynced on every record. Replaying the file reproduces everything: messages, model switches, effort, and permission mode. A crash-torn final line heals automatically on the next open.

  • Rewind, fork, and transfer: branch in place with /rewind, fork into a child strand, or /transfer a clean digest.
  • Per-terminal waypoints: ka -c resumes each terminal pane's own conversation independently.
  • File snapshots & FTS5 search: /undo reverts mutations; ka search indexes every past strand.
How strands and undo work
~/.local/share/ka/strands/api/2026-11-24_3f9c2a81.jsonlfsynced
01 {"kind":"header",  "branch":"main", "dirty":[]}
02 {"kind":"change",  "model":"anthropic/claude-sonnet-5", "mode":"ask"}
03 {"kind":"message", "role":"user", "text":"Add sliding-window limiter"}
04 {"kind":"message", "role":"tool", "spill":"spill://a91f04"}
05 {"kind":"digest",  "kept_tail":6, "summary":"..."}
06 {"kind":"name",    "alias":"ratelimit-v2"}
ka -cka --session ratelimit-v2ka export --htmlka undo

THE BLUEPRINT

One pure engine. Four ways in. Three wires out.

Strict one-way dependencies: ka-engine knows nothing about terminals, TOML, or HTTP. Every surface consumes the same NDJSON Command/Event stream.

Full crate architecture

01 / Surfaces (ka-harness, ka-term)

Ratatui terminal interface with streamed markdown, box-drawing Mermaid diagrams, collapsible tool rows, vim mode, themes as TOML, and mouse copy.

Buffered end-to-end: 80 ms draw coalescing, 0% idle CPU.

$ ka --model anthropic/claude-sonnet-5
Read ka (TUI) guide

One-turn or auto-poked unattended runs. Emits plain text, ka native NDJSON events, or Claude-Code-compatible stream-json with structured exit codes.

Exit codes: 0 ok, 1 error, 2 aborted, 3 budget cap crossed.

$ ka run --print ndjson --mode dont_ask "fix clippy warnings"
Read ka run guide

Local HTTP server exposing the exact same Command/Event protocol over Server-Sent Events. Resume named strands or observe live runs with ka attach.

Unattended prompt_policy = "deny" prevents blocking on asks.

$ ka serve --bind 127.0.0.1:4096
Read ka serve guide

Agent Client Protocol over stdio so editors and IDEs embed ka directly without wrappers, sharing your exact config, strands, and safety rules.

One binary powers terminal, scripts, server, and editor alike.

$ ka acp
Read ka acp guide

02 / Pure core workspace (zero terminal, TOML, or SDK bloat)

cargo xtask deps gated in CI

ka-engine

Turn machine, Hands registry, permission gate, digests.

ka-strand

Append-only fsynced JSONL sessions, rewind, fork, undo.

ka-sandbox

Landlock, seatbelt, bwrap, firejail, loopback net proxy.

ka-index

Optional SQLite FTS5 full-text search across strands.

anthropic_messages

Anthropic Messages API (plus optional Claude OAuth via ka-passport)

openai_chat

OpenAI Chat Completions, Ollama, LM Studio, vLLM, llama.cpp, gateways

openai_responses

OpenAI Responses API for reasoning models and item-based history

GARDINER D28 ยท k๊œฃ

Vital essence

Sustained by the essence within offerings, never their weight.

THE NAME

Born with you. Mirrors your hands.

In Ancient Egypt, the ka, written ๐“‚“ (two upraised arms), was a person's vital essence: a faithful double born alongside you, mirroring your gestures, sustained by the essence within offerings rather than the bulk of the offerings themselves.

ka the harness carries that discipline into code. Everything that makes coding agents sluggish was left out: no background daemon, no plugin runtime, no vector database, no vendor SDK bloat. One static binary, one process, and just enough essence to do serious work reliably.

Speaks the ecosystem you already use

No new formats to adopt. Point ka at an existing repository and it picks up your conventions automatically.

AGENTS.md
Project instructions (also reads CLAUDE.md)
SKILL.md
Skills in .ka/, .agents/, or .claude/
MCP
Stdio and HTTP Model Context Protocol servers
Hooks
Claude-Code-compatible lifecycle hooks
stream-json
Drop-in streaming format for existing scripts
Subagents
Built-in pathfinder, delegate, and team hands

Put it in your terminal.

Published on crates.io as ka-harness. Run ka doctor after install to verify providers and sandbox support.

Full install guide

# Install the single static binary (Rust 1.85+)

$ cargo install ka-harness

# Auto-discovers local Ollama, zero API keys

$ ka --model ollama/qwen3.5:9b

# Or store keys via /key in your OS keyring

$ export ANTHROPIC_API_KEY="sk-ant-..."

# Switch any of 600+ models live with /model

$ ka --model anthropic/claude-sonnet-5

# Unattended run: denies asks, enforces hardstops

$ ka run --mode dont_ask --print ndjson "run cargo test and fix failures"

# Resume the newest session interactively if needed

$ ka -c

Experimental v0.9.0, moving fast. Not ready for unattended production use.