Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

docs(readme): lead with what it does, not how it's built

Rach Pradhan20e217449e6a
diff --git a/README.md b/README.md
index 2c922d21..b59823ea 100644
--- a/README.md
+++ b/README.md
@@ -1,19 +1,54 @@
+<p align="center">
+ <img src="codegraff.png" alt="codegraff" width="360">
+</p>
+
<h1 align="center">graff</h1>
<p align="center">
- <strong>the super simple harness</strong> — a minimal agentic coding harness in Zig 0.16.<br/>
- One <strong>1.7&nbsp;MB</strong> binary, zero dependencies. Talks to <strong>Anthropic</strong>, any <strong>OpenAI-compatible</strong> endpoint (DeepSeek, OpenAI, …), or your <strong>ChatGPT subscription</strong>.
+ <strong>An AI that actually does the work. Not just talks about it.</strong>
</p>
-<p align="center"><code>./install.sh</code></p>
+<p align="center">
+ Install it on your Mac or Linux machine, sign in with the AI subscription you
+ <em>already have</em>, and hand it real tasks. graff writes and runs code,
+ automates the boring stuff, digs through your files, researches the web, and
+ runs its own experiments, on its own, until the job is done.<br/>
+ <strong>You don't chat with it. You give it work.</strong>
+</p>
<p align="center">
- <img alt="Zig 0.16" src="https://img.shields.io/badge/Zig-0.16-f7a41d?logo=zig&logoColor=white">
- <img alt="Platforms" src="https://img.shields.io/badge/platforms-macOS%20·%20Linux-555">
- <img alt="Binary" src="https://img.shields.io/badge/binary-1.7%20MB-44cc11">
- <img alt="Dependencies" src="https://img.shields.io/badge/dependencies-0-44cc11">
+ <img alt="macOS · Linux" src="https://img.shields.io/badge/macOS%20·%20Linux-555">
+ <img alt="One binary, 1.7 MB" src="https://img.shields.io/badge/one%20binary-1.7%20MB-44cc11">
+ <img alt="Zero dependencies" src="https://img.shields.io/badge/dependencies-0-44cc11">
+ <img alt="Built in Zig 0.16" src="https://img.shields.io/badge/built%20in-Zig%200.16-f7a41d?logo=zig&logoColor=white">
</p>
+```sh
+curl -fsSL https://github.com/justrach/codegraff/releases/latest/download/install.sh | sh
+```
+
+<p align="center"><sub>Prefer a window? Grab the <a href="#install">desktop app</a>. Then just run <code>graff</code> and tell it what you need.</sub></p>
+
+## What can I ask it?
+
+If you could do it at a computer, you can ask graff to do it for you:
+
+- *"Build me a little app to track my workouts."* It writes it, runs it, and shows you.
+- *"Turn this folder of messy CSVs into one clean spreadsheet."*
+- *"Figure out why my site is slow, then fix it."*
+- *"Scrape these five pages and summarize them."*
+- *"Run an experiment: try three versions of this and tell me which scores best."*
+
+It works in your real terminal, on your real files, with the real internet, and it can spin up a whole team of sub-agents to work in parallel. It even keeps score of which approaches work and gets better over time.
+
+> **Don't write code?** You don't have to. Say what you want in plain English; graff figures out the steps and does them.
+
+---
+
+## Under the hood
+
+<strong>the super simple harness.</strong> A minimal agentic coding harness in Zig 0.16. One <strong>1.7&nbsp;MB</strong> binary, zero dependencies. Talks to <strong>Anthropic</strong>, any <strong>OpenAI-compatible</strong> endpoint (DeepSeek, OpenAI, …), or your <strong>ChatGPT subscription</strong>.
+
```
user text ─→ POST ─→ model asks for tools?
↑ │
@@ -23,21 +58,21 @@ user text ─→ POST ─→ model asks for tools?
```
A REPL that talks to the model directly over HTTPS (`std.http.Client`),
-hand-rolls every JSON wire format (`std.json`), and runs tool calls — including
-subagents — in parallel on the std.Io thread pool. It also compacts its own
+hand-rolls every JSON wire format (`std.json`), and runs tool calls (subagents
+included) in parallel on the std.Io thread pool. It also compacts its own
context when the conversation gets long.
**Contents**
- [Install](#install) · [give it a key](#give-it-a-key) · [run it](#run-it)
- [Why](#why)
-- [Code intelligence](#code-intelligence--token-efficient-by-default)
+- [Code intelligence](#code-intelligence-token-efficient-by-default)
- [An evolutionary harness](#an-evolutionary-harness)
- [Providers & models](#providers--models)
- [CLI reference](#cli-reference)
- [REPL commands](#repl-commands)
- [Permission modes](#permission-modes)
-- [SDKs — TypeScript & Python](#sdks--typescript--python)
+- [SDKs: TypeScript & Python](#sdks-typescript--python)
- [Reference](#reference)
- [Coming soon](#coming-soon)
@@ -45,9 +80,9 @@ context when the conversation gets long.
## Install
-### Desktop app — macOS (Apple Silicon)
+### Desktop app: macOS (Apple Silicon)
-Prefer a window over a terminal? Download the latest signed, notarized build, drag it to Applications, and open it. The desktop app is **fully self-contained** — it bundles the `graff` agent, so there's nothing else to install to start coding, and it keeps itself up to date automatically. On first launch it drops two commands on your PATH: `codegraff <path>` (opens that folder in the app, `code`-style) and `graff` itself (the agent CLI, in your terminal) — so the one install covers both the window and the command line. The terminal `graff` is symlinked into the app, so it auto-updates along with it. Not on Apple Silicon, or want a standalone CLI? Use the command-line install below.
+Prefer a window over a terminal? Download the latest signed, notarized build, drag it to Applications, and open it. The desktop app is **fully self-contained**: it bundles the `graff` agent, so there's nothing else to install to start coding, and it keeps itself up to date automatically. On first launch it drops two commands on your PATH: `codegraff <path>` (opens that folder in the app, `code`-style) and `graff` itself (the agent CLI, in your terminal), so the one install covers both the window and the command line. The terminal `graff` is symlinked into the app, so it auto-updates along with it. Not on Apple Silicon, or want a standalone CLI? Use the command-line install below.
<p align="center">
<a href="https://github.com/justrach/codegraff/releases/latest/download/Codegraff.dmg"><img alt="Download Codegraff for macOS" src="https://img.shields.io/badge/Download%20for%20macOS-Apple%20Silicon-000000?style=for-the-badge&logo=apple&logoColor=white"></a>
@@ -55,9 +90,9 @@ Prefer a window over a terminal? Download the latest signed, notarized build, dr
<sub><a href="https://github.com/justrach/codegraff/releases/latest">or browse all releases</a></sub>
</p>
-### Command line — macOS · Linux
+### Command line: macOS · Linux
-Grab the latest prebuilt release binary — macOS builds are Developer ID signed
+Grab the latest prebuilt release binary: macOS builds are Developer ID signed
and Apple notarized; on any other platform the installer builds from source with
Zig 0.16:
@@ -70,12 +105,12 @@ From a checkout, just run `./install.sh`. The binary lands in `~/bin` by default
| tool | purpose |
| --------- | ------- |
-| `graff` | the agent CLI + REPL — the one binary this script installs |
+| `graff` | the agent CLI + REPL: the one binary this script installs |
| `codedb` | optional code-intelligence companion (structural search/outline/callers). graff auto-detects it and points at the [one-line install](https://github.com/justrach/codedb) if it's missing; everything else works without it |
### Give it a key
-Three ways — pick whichever is easiest:
+Three ways, pick whichever is easiest:
```sh
graff login # free codegraff key (device-code OAuth, no signup forms)
@@ -83,13 +118,13 @@ graff key set deepseek sk-... # store ANY provider's key (macOS Keychain, else
export DEEPSEEK_API_KEY=sk-... # or just an env var (env always wins)
```
-Already logged into the Codex CLI? Skip this step — your ChatGPT subscription is
+Already logged into the Codex CLI? Skip this step. Your ChatGPT subscription is
picked up automatically from `~/.codex/auth.json`. Or run `graff login codex`.
> **Note on `login`:** there is no per-provider `login` command. `graff login`
> is *specifically* the free codegraff key, and `graff login codex` is the
> ChatGPT-subscription OAuth. **Every other provider** (deepseek, openai,
-> anthropic, kimi, xai, zai, minimax, xiaomi) is a key — set it with
+> anthropic, kimi, xai, zai, minimax, xiaomi) is a key: set it with
> `graff key set <provider> <key>` or its `<PROVIDER>_API_KEY` env var, then
> select a model with `--model` / `/model`. See [Providers & models](#providers--models).
@@ -105,7 +140,7 @@ First things to try once you're at the `›` prompt:
```
› what's in this directory? summarize the build setup.
› /model sonnet # fuzzy-switches to claude-sonnet-4-6
-› spawn three subagents to summarize src/, count TODOs, and check git status — in parallel
+› spawn three subagents to summarize src/, count TODOs, and check git status, in parallel
› ultracode audit this repo for error-handling gaps # codeword → multi-agent workflow mode
› /help # everything else
```
@@ -114,7 +149,7 @@ First things to try once you're at the `›` prompt:
## Why
-Measured, not vibes — arm64 macOS, ReleaseFast; methodology and the budgets each
+Measured, not vibes: arm64 macOS, ReleaseFast; methodology and the budgets each
change is held to live in [architecture.md](architecture.md):
| metric | measured |
@@ -123,47 +158,47 @@ change is held to live in [architecture.md](architecture.md):
| cold start | **~1.4 ms** |
| full agentic turn | **12 MB** peak RSS, ~4% CPU (network-bound) |
| 8 parallel subagents | **+0.4 MB each** (15 MB total) |
-| tool output into history | hard 128 KB cap — a 500 MB python child process never touches the harness's footprint |
+| tool output into history | hard 128 KB cap: a 500 MB python child process never touches the harness's footprint |
Benchmarked against the Rust codegraff ([justrach/codegraff](https://github.com/justrach/codegraff),
39 MB binary, 934 crates) on the *same model through the same endpoint*,
-interleaved 3×: turn speed was a dead tie (2.94 s vs 2.93 s — the network and
+interleaved 3×: turn speed was a dead tie (2.94 s vs 2.93 s; the network and
the model dominate the turn), but the Zig harness ran in **4.3× less memory**
(11.3 MB vs 48.5 MB), starts 3.5× faster, and is 23× smaller on disk. An agent
CLI rarely wins on turn speed; it can win on the cost of being there.
---
-## Code intelligence — token-efficient by default
+## Code intelligence: token-efficient by default
The fastest way to blow a context window is to read whole files into it. graff
-ships with a built-in **`codedb`** tool — read-only, structural code
+ships with a built-in **`codedb`** tool: read-only, structural code
intelligence over a local index of the repo
-([github.com/justrach/codedb](https://github.com/justrach/codedb)) — and the
+([github.com/justrach/codedb](https://github.com/justrach/codedb)), and the
system prompt steers the model to reach for it *before* `grep` or
whole-file reads. Instead of paying for a 2,000-line file to find one function,
the model asks for exactly the shape it needs:
```
-codedb outline src/main.zig # just the symbol map — functions/types, no bodies
+codedb outline src/main.zig # just the symbol map, functions/types, no bodies
codedb symbol switchProvider --body # one function, by name
codedb callers recordUsage # who calls it (call sites, not files)
-codedb search "parse SSE" # indexed search — ranked hits, not a grep dump
+codedb search "parse SSE" # indexed search, ranked hits, not a grep dump
codedb context "add a new provider" # task-shaped orientation across the codebase
```
Why this keeps token cost low:
- **Structural slices, not files.** `outline`/`symbol`/`callers`/`deps` return a
- function map or a single definition — tens of lines where a `read_file` would
+ function map or a single definition, tens of lines where a `read_file` would
spend thousands. The index is queried, not the raw bytes streamed into history.
- **It's free and indexed; the metered tools come second.** The system prompt
- encodes an explicit search order — try the free, indexed `codedb` first;
+ encodes an explicit search order: try the free, indexed `codedb` first;
fall to (metered) `muonry`/raw search only for literal/regex or non-indexed
files. The cheap path is the default path.
- **Hard output cap.** A query is truncated at **64 KB** with a marker that nudges
the model back toward targeted queries (`outline`, `symbol --body`) rather than
- whole-file reads — so even a broad search can't balloon the context.
+ whole-file reads, so even a broad search can't balloon the context.
- **Same index powers the `@` file picker** (`codedb glob`), so attaching a file
by name never shells out to a directory walk.
@@ -176,7 +211,7 @@ and points at the one-line install; everything else keeps working without it.
## An evolutionary harness
-graff doesn't just run an agent — it records every run as a node in a
+graff doesn't just run an agent; it records every run as a node in a
**Darwin Gödel Machine-style archive tree** ([arXiv:2505.22954](https://arxiv.org/abs/2505.22954)),
so the harness itself is the substrate for agent self-improvement. Each session
appends to `harness.trajectory.jsonl` (truncated per session, like the trace):
@@ -184,9 +219,9 @@ appends to `harness.trajectory.jsonl` (truncated per session, like the trace):
- **A lineage tree, not a flat log.** Root turns form a spine (each turn's
parent is the previous one); every subagent and workflow task hangs off the
turn that spawned it. Each node carries a **fingerprint of the system prompt
- it ran with** (`prompt_sha` = first 8 bytes of SHA-256), so prompt mutations —
+ it ran with** (`prompt_sha` = first 8 bytes of SHA-256), so prompt mutations (
`set_system_prompt` on the spine, per-child `system_prompt` overrides on the
- fan-out — show up as hash changes along edges. A lineage can be replayed or
+ fan-out) show up as hash changes along edges. A lineage can be replayed or
scored offline.
- **Personas are variants.** Subagents pick a persona with `agent` (built-ins:
`reviewer · researcher · implementer · skeptic`, plus anything in
@@ -194,15 +229,15 @@ appends to `harness.trajectory.jsonl` (truncated per session, like the trace):
trajectory records the lineage, so you can mine *which agent variant actually
worked*.
- **A fitness ledger with integrity.** The `score` channel appends evaluation
- records (`prompt_sha`, `score`, `parent_sha` — the lineage edge DGM parent
+ records (`prompt_sha`, `score`, `parent_sha`; the lineage edge DGM parent
selection counts children with). Because the archive lives in the working
- directory, a forged `score` row could manufacture fitness — so every score the
+ directory, a forged `score` row could manufacture fitness, so every score the
harness writes is **HMAC-signed** (keyed by `GRAFF_SCORE_KEY_FILE`, a secret
outside the cwd that the evolving agent's confined tools can't reach). Readers
recompute the HMAC and reject unsigned or forged rows. Signing is opt-in and
backward-compatible (no key → unsigned, accepted as before).
- **Tool-use is mined too.** Each agent logs its tool calls (name + error flag,
- in order) — the process signal behind "which tool combinations work",
+ in order): the process signal behind "which tool combinations work",
joinable to scores via `prompt_sha`.
- **Closed loop in releases.** Release binaries ship anonymous evolution
telemetry (opt-out) so agent-variant fitness is learned across the fleet, not
@@ -229,7 +264,7 @@ from [models.dev](https://models.dev)'s `api.json` (snapshot 2026-06-10).
| `kimi` / `xai` (grok) / `zai` (GLM) | OpenAI chat, bearer | `KIMI_API_KEY` / `XAI_API_KEY` / `ZAI_API_KEY` (via `graff key set`) |
| `codex` | Responses API, ChatGPT login | `~/.codex/auth.json` (no env var) |
-**Using a specific provider directly** is always the same two steps — give it
+**Using a specific provider directly** is always the same two steps: give it
the key, then name a model. For example, DeepSeek straight to `api.deepseek.com`:
```sh
@@ -237,17 +272,17 @@ graff key set deepseek sk-... # or: export DEEPSEEK_API_KEY=sk-...
graff --model deepseek-reasoner # models: deepseek-v4-pro · deepseek-v4-flash · deepseek-chat · deepseek-reasoner
```
-The same pattern works for every API-key row above — swap in the provider id
+The same pattern works for every API-key row above: swap in the provider id
and one of its models (`graff key set openai sk-...` → `--model gpt-...`,
`graff key set anthropic sk-ant-...` → `--model sonnet`, and so on).
A model is routed to the first provider (in the table order above) that both has
a key set **and** lists the model in `model_table`. Unknown `claude*` models
fall back to Anthropic; any other unknown model falls back to the codegraff
-gateway — and `/model` prints a warning when that fallback fires, since a typo'd
+gateway, and `/model` prints a warning when that fallback fires, since a typo'd
name will be rejected by the API on the first request. The startup default is
the first provider with a key, on its default model. `/models` prints the full
-table — context window, compaction point, provider, and which providers you have
+table: context window, compaction point, provider, and which providers you have
keys for; `/model <name>` switches (a bare `/model` opens an interactive fuzzy
picker).
@@ -259,20 +294,20 @@ picker).
If you're logged into the Codex CLI, the harness reads the ChatGPT OAuth token
from `~/.codex/auth.json` at startup (the same on-disk-credential trick used for
the codegraff key) and prints `logged into Codex (ChatGPT account …)`. Switch to
-it with `/model gpt-5.5` (or `gpt-5-codex`). This is a third wire format — the
+it with `/model gpt-5.5` (or `gpt-5-codex`). This is a third wire format: the
**Responses API** against the ChatGPT backend
-(`chatgpt.com/backend-api/codex/responses`), not `api.openai.com` — so it uses
+(`chatgpt.com/backend-api/codex/responses`), not `api.openai.com`, so it uses
your ChatGPT Pro/Plus subscription rather than a paid API key. Text, tool
calling, compaction, and `/save`/`/resume` all work on it. Not logged in?
`graff login codex` runs the PKCE browser flow itself.
Claude models route through a real `ANTHROPIC_API_KEY` or the codegraff gateway
-only — there is deliberately no Claude-subscription login: reusing a Claude Code
+only. There is deliberately no Claude-subscription login: reusing a Claude Code
OAuth token outside the official client violates Anthropic's terms of service.
Tool definitions are written once as comptime specs and rendered into both
formats (Anthropic `input_schema` vs OpenAI `function.parameters`) at compile
-time — see `anthropicToolsJson` / `openaiToolsJson` in `src/main.zig`.
+time. See `anthropicToolsJson` / `openaiToolsJson` in `src/main.zig`.
</details>
@@ -298,14 +333,14 @@ flags:
-p, --print one-shot print mode (answer on stdout, tool progress on stderr)
--timing show per-tool wall-clock on result lines (✓ (312ms) …)
--cost show running session spend in the prompt ([model · 12k tok · $0.0042])
- --json structured stdio protocol (JSON in, JSONL events out — SDK transport)
+ --json structured stdio protocol (JSON in, JSONL events out, SDK transport)
-h, --help usage
-V, --version version
```
Unknown flags are an error (with a pointer to `--help`), a missing `--model`
value is an error, and `--help`/`--version` are handled before subcommand
-dispatch — so `graff login --help` prints usage instead of starting an OAuth
+dispatch, so `graff login --help` prints usage instead of starting an OAuth
flow. With no key configured at all, startup fails with the three quickest fixes
spelled out rather than a bare env-var list.
@@ -313,7 +348,7 @@ spelled out rather than a bare env-var list.
many TODOs in src/?"` runs a full agentic turn (tools included), prints only the
final answer on stdout (progress lines go to stderr), and exits non-zero on
failure. There's no human to ask, so the permission gate denies anything not
-already allowed — pre-approve commands in `.harness/settings.json` or pass
+already allowed. Pre-approve commands in `.harness/settings.json` or pass
`--yolo`.
---
@@ -321,7 +356,7 @@ already allowed — pre-approve commands in `.harness/settings.json` or pass
## REPL commands
A bare `/` opens the whole list as a filterable full-screen menu (type to
-narrow, Enter runs it); **Esc during a response interrupts the turn** —
+narrow, Enter runs it); **Esc during a response interrupts the turn**:
generation stops (it works from the moment the request is sent, including a slow
provider connect), what already streamed stays in history with an
`[interrupted]` marker, and you're back at the prompt. A bare Esc at the prompt
@@ -329,9 +364,9 @@ clears the input line.
While a response streams you stay in control: besides Esc to interrupt,
**Ctrl-T (`^T`) folds/unfolds the live "Thinking" block** in place, and the mouse
-wheel scrolls your terminal's own scrollback — the REPL doesn't grab the mouse, so
+wheel scrolls your terminal's own scrollback: the REPL doesn't grab the mouse, so
scrolling up to re-read earlier output works like any normal terminal (parity with
-Claude Code). Folding the Thinking block is keyboard-only (`^T`) — there is no
+Claude Code). Folding the Thinking block is keyboard-only (`^T`). There is no
click-to-fold.
```
@@ -357,7 +392,7 @@ exit | /exit | ctrl-d | ctrl-c(empty) quit
```
`/plan`, `/yolo`, and `/strict` change how the permission gate behaves for the
-session — see [Permission modes](#permission-modes).
+session. See [Permission modes](#permission-modes).
The line editor supports ↑/↓ history (persisted to `~/.simple-harness-history`),
Tab completion (commands, and model names after `/model `), and emacs-style
@@ -365,7 +400,7 @@ editing (Ctrl-A/E/W/U/K, Option+Delete, word moves). The selected model is
remembered in `~/.simple-harness-model` and resumed next launch
(`--model <name>` overrides; a remembered model that's no longer in the table is
ignored with a note). The prompt is a small statusline:
-`[model · 12345/800k tok (1%) · ⚡cached · $0.0042]` — context used vs the
+`[model · 12345/800k tok (1%) · ⚡cached · $0.0042]`: context used vs the
compaction budget, last cache hit, and session spend. Errors aim to be
actionable: `/resume nope` says the session file wasn't found and points at
`/sessions`; an unknown `/foo` points at `/help`.
@@ -386,36 +421,36 @@ that isn't read-only stop at a permission gate:
- **y** runs it once · **a** runs it *and* remembers the rule · **n** denies it
(the model is told and picks another path).
- **Always** appends a prefix rule to `.harness/settings.json` under `"allow"`,
- so that command never prompts again — this session or a future one. Pre-seed
+ so that command never prompts again, this session or a future one. Pre-seed
that file by hand to allow commands up front (it lives next to your hooks; the
harness preserves the rest of the file).
- Read-only commands are auto-allowed and never prompt: `ls cat head tail wc
- grep rg pwd which file`, `git status|diff|log|show`, `zig build|fmt` — but
+ grep rg pwd which file`, `git status|diff|log|show`, `zig build|fmt`, but
only while every path stays inside the working directory (`cat /etc/passwd`
still asks), and only as a plain command. A pipe, redirect, `&&`, or `$(…)`
always prompts, so a second command can't be smuggled past a prefix match.
-Three session-wide modes change the gate — set on the CLI, or flip them live in
+Three session-wide modes change the gate. Set on the CLI, or flip them live in
the REPL:
| mode | turn on | what it does |
| ---------- | -------------------- | ------------ |
-| **yolo** | `--yolo` · `/yolo` | Skip **every** prompt — bash, edits, and MCP all run without asking. For sandboxes, CI, and `-p`/`--json` runs where there's no human to answer. `--yolo` starts the session in it; `/yolo` toggles mid-session. |
+| **yolo** | `--yolo` · `/yolo` | Skip **every** prompt: bash, edits, and MCP all run without asking. For sandboxes, CI, and `-p`/`--json` runs where there's no human to answer. `--yolo` starts the session in it; `/yolo` toggles mid-session. |
| **plan** | `/plan` | Read-only: the model explores and *proposes* a plan; the gate hard-denies writes, edits, MCP, and any bash beyond the read-only seed (even your saved allow-list) until you `/plan` again to execute. The prompt shows a ` plan` badge. |
-| **strict** | `/strict` | "Every message is a tool" — the model must call exactly one tool per message and finish with `attempt_completion`. Useful for deterministic, scriptable agent loops. |
+| **strict** | `/strict` | "Every message is a tool": the model must call exactly one tool per message and finish with `attempt_completion`. Useful for deterministic, scriptable agent loops. |
**One-shot mode** (`graff -p "…"` or `--json`) has no human to answer the
-prompt, so the gate denies anything not already allowed — pre-approve commands
+prompt, so the gate denies anything not already allowed. Pre-approve commands
in `.harness/settings.json` or pass `--yolo`.
---
-## SDKs — TypeScript & Python
+## SDKs: TypeScript & Python
graff is scriptable from your own code. `graff --json` is a structured stdio
protocol (JSON requests in, JSONL events out; `ask_user` is answered with a
structured `{"type":"answer","text":"...","cancelled":false}` line) and `graff --schema` prints the
-machine-readable interface — and the **TypeScript and Python SDKs in
+machine-readable interface, and the **TypeScript and Python SDKs in
[`sdk/`](sdk/) are auto-generated from that schema**, so they never drift from
the binary. On every release tag a GitHub Action rebuilds, regenerates, fails if
the committed SDKs are stale, and publishes to npm (`@graff-new/sdk`) and PyPI
@@ -449,7 +484,7 @@ session.close();
Can't spawn a local process (edge runtimes, browsers, other machines)? Run
`graff serve` and both SDKs ship matching **remote clients** that drive it over
-HTTP — `@graff-new/sdk/remote` (fetch-only: Workers/Deno/Bun/browsers) and
+HTTP: `@graff-new/sdk/remote` (fetch-only: Workers/Deno/Bun/browsers) and
Python's `RemoteHarness` (stdlib only). Same method surface, same event stream.
See [`sdk/README.md`](sdk/README.md).
@@ -468,7 +503,7 @@ See [`sdk/README.md`](sdk/README.md).
| `read_file` | built-in | `Io.Dir.cwd().readFileAlloc` (256 KB cap) |
| `edit_file` | built-in | exact string replace; unique match required unless `replace_all` |
| `write_file` | built-in | `Io.Dir.cwd().writeFile` |
-| `codedb` | built-in | shells out to [codedb](https://github.com/justrach/codedb) — read-only code-intel (search/symbol/callers/outline/…) |
+| `codedb` | built-in | shells out to [codedb](https://github.com/justrach/codedb): read-only code-intel (search/symbol/callers/outline/…) |
| `subagent` | built-in | this same agent loop, recursively (root agent only) |
| `workflow` | built-in | phases of parallel subagents; `{{prev}}` carries results forward (root only) |
| `todo_write`/`_read` | meta | mutate/read the agent's own task list |
@@ -484,22 +519,22 @@ the agent finishes via another tool. In `/strict` mode the model is forced to
call a tool every turn, so *every* message is a tool call or tool result.
**Permission gate.** The gate (`gateTool`) covers `bash`, `write_file`,
-`edit_file`, and MCP tool calls — a call that isn't pre-approved prompts at the
+`edit_file`, and MCP tool calls. A call that isn't pre-approved prompts at the
REPL: `[y]es once · [a]lways allow "<key>" (saved) · [n]o`. The approval key is
the command's first word for bash, the tool name for writes/MCP. "Always"
**persists**: it's written to `.harness/settings.json` in the cwd
(`{"allow": ["touch", "write_file", …]}`) and loaded back on every launch in
-that project — edit the file by hand to revoke or pre-approve. A small seed
+that project. Edit the file by hand to revoke or pre-approve. A small seed
allowlist (read-only basics like `ls`/`cat`/`rg`, plus `zig build`/`zig fmt` and
`git status`/`diff`/`log`/`show`) never prompts; `find` is deliberately excluded
(its `-exec`/`-delete` make it an exec tool). Commands containing chaining,
-pipes, redirection, substitution, or newlines never match a prefix — they always
+pipes, redirection, substitution, or newlines never match a prefix: they always
prompt. Approving an interpreter as a bash word (`python3`, `node`, …) prints a
heads-up that it grants arbitrary code execution.
**Path confinement.** `read_file`/`write_file`/`edit_file` are confined to the
working-directory subtree: no absolute paths, no `..`. This is structural (not
-bypassed by `/yolo`) — `read_file /etc/shadow` and `write_file ../../x` are
+bypassed by `/yolo`): `read_file /etc/shadow` and `write_file ../../x` are
refused with an error.
**bash is cwd-locked by default too.** A seed/approved command auto-runs only
@@ -535,7 +570,7 @@ discovers their tools, and offers them to the model namespaced
```
Pointing it at `codedb mcp .` gives the agent 22 structural code-intelligence
-tools — pure-Zig client to pure-Zig server, zero dependencies on either side.
+tools: pure-Zig client to pure-Zig server, zero dependencies on either side.
`/mcp` lists what connected; `/mcp add <name> <cmd> [args…]` connects a server
live and saves it to `.mcp.json`. From a shell, use the Codex-style form
`graff mcp add <name> [--env KEY=VALUE ...] -- <cmd> [args…]`; for example,
@@ -545,7 +580,7 @@ servers already saved in `.mcp.json`. Workspace servers auto-connect only with
One known companion is exempt from the workspace gate: if the `muonry` binary is
on PATH (the fast code-intelligence suite), the harness auto-connects it in
-every workspace — it's a user-installed tool, not arbitrary repo config — and
+every workspace (it's a user-installed tool, not arbitrary repo config) and
injects its usage note so the model prefers `mcp__muonry__read`/`search` over
native navigation, falling back to the native tools whenever a call fails. Opt
out with `{"skills": {"muonry": false}}` in `.harness/settings.json`.
@@ -553,20 +588,20 @@ out with `{"skills": {"muonry": false}}` in `.harness/settings.json`.
</details>
<details>
-<summary><strong>ultracode & workflows — multi-agent fan-out</strong></summary>
+<summary><strong>ultracode & workflows: multi-agent fan-out</strong></summary>
<br/>
-**ultracode — the multi-agent codeword.** Put the word **ultracode** anywhere in
+**ultracode: the multi-agent codeword.** Put the word **ultracode** anywhere in
a message and the harness augments that turn with a note steering the model into
-multi-agent workflow mode: it prints `⚡ ultracode — multi-agent workflow mode
+multi-agent workflow mode: it prints `⚡ ultracode: multi-agent workflow mode
engaged`, records an `ultracode` trace event, and asks the model to fan the work
out across phases of parallel subagents (then synthesize) via the `workflow`
-tool rather than doing it solo. It's a per-turn toggle — no flag, no mode to
+tool rather than doing it solo. It's a per-turn toggle: no flag, no mode to
remember, just the keyword.
**Workflows.** Dynamic workflows as data (inspired by pi-dynamic-workflows,
-minus the JS sandbox): the model calls the `workflow` tool with a JSON plan — up
+minus the JS sandbox): the model calls the `workflow` tool with a JSON plan of up
to 5 sequential phases, each holding up to 8 tasks that run in parallel as
isolated subagents. From phase 2 on, `{{prev}}` in a task prompt is replaced
with the labeled results of the previous phase (auto-appended if omitted), and
@@ -589,7 +624,7 @@ Subagents inherit the parent's provider, so deepseek subagents work the same as
claude ones.
- Depth capped at one level: subagents don't get the `subagent` tool.
-- Subagents don't share the root agent's context — the orchestrator must put
+- Subagents don't share the root agent's context, so the orchestrator must put
everything needed into the prompt (the tool description tells it so).
- Progress lines (`[label] ⚙ bash …`) go to stderr via `std.debug.print`, which
locks stderr and is safe from pool threads.
@@ -603,18 +638,18 @@ claude ones.
**Session persistence.** `/save [name]` writes the conversation (messages +
provider + strict flag) to `<name>.session.json` in the cwd (default name
-`last`); `/resume [name]` restores it — provider, model, and full history — in
+`last`); `/resume [name]` restores it (provider, model, and full history) in
any later run, and `/sessions` lists the saved ones. The stored message array is
already the provider-native wire shape, so resume is a verbatim restore and
works across providers (including codex's Responses-format items).
-**Compaction** — client-side, provider-agnostic:
+**Compaction**, client-side, provider-agnostic:
1. Every response's `usage` is recorded (`input+output+cache` tokens for
Anthropic, `total_tokens` for OpenAI) and shown in the prompt.
-2. Past the model's compaction threshold — 80% of its context window, from a
+2. Past the model's compaction threshold, 80% of its context window, from a
comptime model table (`/models` prints it: 800k for the 1M-context models,
- 160k for `claude-haiku-4-5`, 160k fallback for unknown models) — or on
+ 160k for `claude-haiku-4-5`, 160k fallback for unknown models), or on
`/compact`, the harness sends the history plus a handoff instruction *with no
tools offered*, so the model must reply with a text summary covering goals,
decisions, file paths, code state, and pending work.
@@ -642,7 +677,7 @@ so you can see the hit rate in `harness.trace.jsonl`.
The one deliberate exception is `set_system_prompt` (--json protocol / SDK
`setSystemPrompt`): the system prompt is the *first* token of the cached prefix,
-so mutating it — even appending — invalidates the KV-cache for the entire
+so mutating it, even appending, invalidates the KV-cache for the entire
conversation and the next request re-reads everything at full input price. Treat
it as a task-boundary operation: prefer the spawn-time
`--system-prompt`/`--append-system-prompt` flags, and never flip the prompt back
@@ -655,16 +690,16 @@ and forth inside an agent loop.
<br/>
-**Tracing — the harness can debug itself.** Every API round trip (latency,
+**Tracing: the harness can debug itself.** Every API round trip (latency,
request/response bytes, context tokens) and every tool execution (duration,
result size, errors, root-vs-subagent) is appended as one JSON line to
`harness.trace.jsonl` in the cwd, truncated at startup so it always covers the
-current session. The system prompt tells the agent the file exists — so "profile
+current session. The system prompt tells the agent the file exists, so "profile
yourself" or "why was that slow?" makes the agent read its own trace and answer
from data. `/trace` toggles it.
-**Telemetry — pseudonymous, opt-out, on by default.** *Every* build — release,
-source, and dev — bakes in a default OTLP endpoint (pass `-Dtelemetry-endpoint=""`
+**Telemetry, pseudonymous, opt-out, on by default.** *Every* build (release,
+source, and dev) bakes in a default OTLP endpoint (pass `-Dtelemetry-endpoint=""`
to disable it at build time), so by default a session ships best-effort OTLP/HTTP
JSON POSTs to `<endpoint>/v1/logs` (at exit, plus mid-session batches). **Opt out
any time** with `--no-telemetry` or `GRAFF_NO_TELEMETRY=1`; setting
@@ -672,19 +707,19 @@ any time** with `--no-telemetry` or `GRAFF_NO_TELEMETRY=1`; setting
collector instead.
It's *pseudonymous, not anonymous*: records carry a **random** per-install id
-(`~/.simple-harness-install-id`, generated with `io.random` — not derived from your
+(`~/.simple-harness-install-id`, generated with `io.random`, not derived from your
name, host, or user) plus your request IP, version, OS, and arch. The payload is
**counts, hashes, and tool names**: a `session` summary (duration, turns, API/tool
call+error counts, models used, workflow/ultracode counts), per-`workflow` and
per-error records, and per-turn/score records keyed by a one-way **system-prompt
fingerprint** + `prompt_sha` hashes with a tool-**name** sequence (e.g.
`read_file, bash, edit_file`). It does **not** send your prompts, your code, file
-contents, file paths, or tool arguments — your input is never an argument to any
+contents, file paths, or tool arguments. Your input is never an argument to any
telemetry call.
-**Fleet / evolution signals** (`fleet:propose|submit|elite_pull` — the
+**Fleet / evolution signals** (`fleet:propose|submit|elite_pull`, the
agent-evolution fitness loop) ride the same channel and have a *separate* opt-out:
-`GRAFF_FLEET=off` or `/fleet off`. They're hashes and labels, with one exception —
+`GRAFF_FLEET=off` or `/fleet off`. They're hashes and labels, with one exception.
`fleet:propose` sends an agent's **system-prompt / persona text** (≤8192 chars: the
evolved "genome"; graff's own text for built-in agents, *your* text for a custom
agent or inline override). Error details are capped at 200 chars. The SDKs tag their
@@ -719,7 +754,7 @@ and ends with a PATH check. Alternatively, run in place:
```sh
zig build run # or: ./zig-out/bin/graff
-zig build test # the test suite (also run by CI — .github/workflows/ci.yml)
+zig build test # the test suite (also run by CI, .github/workflows/ci.yml)
```
**Releases & verification.** Tagged releases ship a prebuilt **darwin-arm64**
@@ -733,7 +768,7 @@ codesign -dv --verbose=4 graff 2>&1 | grep Authority
```
Keys can come from env vars, or be stored safely with `graff key set <provider>
-<key>` — on macOS in the login **Keychain** (service `simple-harness`),
+<key>`. On macOS that's the login **Keychain** (service `simple-harness`),
elsewhere a `0600` `~/.simple-harness-keys.json`; the harness auto-loads them at
startup for any provider whose env var isn't set (env always wins). `graff key
list` shows which providers have a stored key. Providers
@@ -750,9 +785,9 @@ token) and `graff login codex --refresh` refreshes it, both writing
`~/.codex/auth.json`.
**SDKs.** `graff --json` exposes a structured stdio protocol (JSON requests in,
-JSONL events out) and `graff --schema` prints the machine-readable interface —
-together the foundation for the auto-generated TypeScript + Python SDKs in
-[`sdk/`](sdk/) (regenerated on release by `sdk/generate.py` /
+JSONL events out) and `graff --schema` prints the machine-readable interface.
+Together they are the foundation for the auto-generated TypeScript + Python SDKs
+in [`sdk/`](sdk/) (regenerated on release by `sdk/generate.py` /
`.github/workflows/sdk.yml`).
`graff serve` puts that same protocol on HTTP for clients that can't spawn a
@@ -761,12 +796,11 @@ local process (edge runtimes, browsers, other machines): each session is a real
response streams NDJSON events until that request's terminal event. `answer`
POSTs can be sent while the original stream is waiting on `ask_user`; they ack
immediately and the original stream continues to the `tool_result`/`turn`.
-Bearer auth via
-`--token`/`HARNESS_SERVE_TOKEN` (required to bind beyond loopback); CORS opens
-only when a token gates access. The SDKs ship matching remote clients —
-`@graff-new/sdk/remote` (fetch-only: Workers/Deno/Bun/browsers) and Python's
-`RemoteHarness` (stdlib urllib). Endpoints are documented under the `serve` key
-of `graff --schema`.
+Bearer auth via `--token`/`HARNESS_SERVE_TOKEN` (required to bind beyond
+loopback); CORS opens only when a token gates access. The SDKs ship matching
+remote clients: `@graff-new/sdk/remote` (fetch-only: Workers/Deno/Bun/browsers)
+and Python's `RemoteHarness` (stdlib urllib). Endpoints are documented under the
+`serve` key of `graff --schema`.
</details>
@@ -775,22 +809,22 @@ of `graff --schema`.
<br/>
-- An agent harness is I/O-bound, so you don't need an async runtime — but Zig
- 0.16's new `std.Io` interface gives you one anyway: `io.async(fn, args)`
- returns a typed `Future`, executed on a thread pool you configure
- (`std.Io.Threaded`). Parallel tools and parallel subagents are the same ~6
- lines (see `runToolsParallel`).
+- An agent harness is I/O-bound, so you don't need an async runtime. Zig 0.16's
+ new `std.Io` interface gives you one anyway: `io.async(fn, args)` returns a
+ typed `Future`, executed on a thread pool you configure (`std.Io.Threaded`).
+ Parallel tools and parallel subagents are the same ~6 lines (see
+ `runToolsParallel`).
- The new `pub fn main(init: std.process.Init)` entry point hands you `io`, a
thread-safe gpa, a process-lifetime arena, and the environment map.
- Compiles in well under a second; the binary is self-contained (TLS included,
no libcurl/openssl).
-- The payoff is measurable: same model, same endpoint, the Rust codegraff burns 4.3×
- the memory and 23× the disk for an identical-speed turn — see [Why](#why) and
- `architecture.md` for the methodology.
+- The payoff is measurable. Same model, same endpoint, the Rust codegraff burns
+ 4.3× the memory and 23× the disk for an identical-speed turn. See [Why](#why)
+ and `architecture.md` for the methodology.
Notes:
-- UI/UX changes are tracked in [uxlog.md](uxlog.md) — what changed, what it
+- UI/UX changes are tracked in [uxlog.md](uxlog.md): what changed, what it
replaced, and the design reasoning (newest first).
- Anthropic requests use adaptive thinking; the assistant's full `content` array
(including thinking blocks and signatures) is echoed back verbatim, as the API
@@ -813,13 +847,12 @@ Notes:
Honest list of what the harness still lacks, roughly in the order it hurts.
**Foundational:**
-1. ~~**A public repo + signed release.**~~ **Done — v0.0.1.** The repo is public at
+1. ~~**A public repo + signed release.**~~ **Done, v0.0.1.** The repo is public at
[`justrach/codegraff`](https://github.com/justrach/codegraff), and releases ship
a prebuilt **darwin-arm64 binary that is codesigned (Developer ID) and notarized
by Apple**. The release workflow (`.github/workflows/release.yml`) cross-compiles
the rest on every `v*` tag; `install.sh` prefers the prebuilt download over a
source build, so `curl … | bash` now installs in one command with no toolchain.
- command with no toolchain.
**Later:**
@@ -831,18 +864,18 @@ Honest list of what the harness still lacks, roughly in the order it hurts.
stream; a long-running bash call still runs to completion).
6. Honor `Retry-After` on 429s (the backoff is plain exponential today).
-Recently shipped: **v0.1.0** — tagged GitHub release with prebuilt darwin/linux
+Recently shipped: **v0.1.0** · tagged GitHub release with prebuilt darwin/linux
binaries · bash output truncates at its 128 KB cap instead of failing the tool
call (`runCapped`: real exit code, `[truncated]` marker, memory stays flat while
the child streams gigabytes) · measured performance budgets + the Rust-graff
bake-off in [architecture.md](architecture.md) · 429/5xx retry with exponential
backoff (1s·2ⁿ capped at 8s, Esc cancels the wait, `retry` notes in the trace) ·
`--version` stamped from `git describe` at build time (`-Dversion=X.Y.Z`
-overrides) · Esc coverage from the moment the request is sent — no more `^[` echo
-while a slow provider connects, and the interrupt lands before the first token ·
-bare Esc at the prompt clears the line · one-shot `-p` print mode · persistent
-approvals (`.harness/settings.json`) · plan mode (`/plan`) · `/clear` · bare-`/`
-command menu · interactive `/resume` picker · context-% statusline.
+overrides) · Esc coverage from the moment the request is sent, so no more `^[`
+echo while a slow provider connects, and the interrupt lands before the first
+token · bare Esc at the prompt clears the line · one-shot `-p` print mode ·
+persistent approvals (`.harness/settings.json`) · plan mode (`/plan`) · `/clear`
+· bare-`/` command menu · interactive `/resume` picker · context-% statusline.
</details>
@@ -850,14 +883,14 @@ command menu · interactive `/resume` picker · context-% statusline.
## Coming soon
-Active directions — see the **Status & roadmap** details above for the full
-list, and the GitHub issues for what's in flight:
+Active directions. See the **Status & roadmap** details above for the full list,
+and the GitHub issues for what's in flight:
- **Sandboxes.** Run the agent's `bash`/file tools inside an isolated sandbox
(ephemeral container / microVM) so untrusted or destructive steps can't touch
- the host — the natural next layer above today's cwd-confinement and permission
- gate, and the safe substrate for hands-off evolutionary runs.
-- **Closing the evolution loop end-to-end** — a grounded judge, sync-back of
+ the host. It's the natural next layer above today's cwd-confinement and
+ permission gate, and the safe substrate for hands-off evolutionary runs.
+- **Closing the evolution loop end-to-end:** a grounded judge, sync-back of
fleet trajectories, and automatic promotion of winning agent variants.
- **Windows support, shell completions + man page, and a config file** for
default flags/model.
@@ -866,12 +899,21 @@ list, and the GitHub issues for what's in flight:
## License
-codegraff is licensed under a **modified GNU AGPL-3.0** (see [`LICENSE`](LICENSE)):
-the public receives it under the AGPL-3.0 — so network use triggers the Section 13
-obligation to make Corresponding Source available to remote users — while the
-authors **Rach Pradhan (justrach)** and **Yu Xi Lim (yxlyx)** reserve full rights
-to use, distribute, and offer it (and modified versions) as a private, proprietary,
-or hosted/cloud product, free of those obligations. For commercial or proprietary
+codegraff is licensed under a **modified GNU AGPL-3.0** (see [`LICENSE`](LICENSE)).
+The public receives it under the AGPL-3.0, so network use triggers the Section 13
+obligation to make Corresponding Source available to remote users. The authors
+**Rach Pradhan (justrach)** and **Yu Xi Lim (yxlyx)** reserve full rights to use,
+distribute, and offer it (and modified versions) as a private, proprietary, or
+hosted/cloud product, free of those obligations.
+
+A recipient's AGPL-3.0 licence is **perpetual and irrevocable unless they breach
+it**: it can't be withdrawn at will, which is what makes open use safe to rely on.
+Any **proprietary or commercial permission** to use codegraff *without* the AGPL's
+copyleft is a separate thing, and exists only if **both authors grant it jointly in
+writing**. Such a permission is **revocable at the authors' discretion at any
+time**, and neither the provision of consultancy or other services nor any side
+agreement grants it or makes it irrevocable. If it is revoked, the user falls back
+to full AGPL compliance or must stop using codegraff. For commercial or proprietary
licensing, contact the authors.
---