Skip to content

Commit a1de077

Browse files
authored
Merge pull request #1 from codebase/codex/usage-dogfood-20260705
Launch-harden CLI and prepare pre.74
2 parents cd50539 + d9bd884 commit a1de077

174 files changed

Lines changed: 17423 additions & 557 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Formula/codebase.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# that opens a PR against the tap (see Phase 12.5).
1616
class Codebase < Formula
1717
desc "AI coding agent in your terminal — TypeScript, multi-provider, OAuth-aware"
18-
homepage "https://codebase.foundation"
18+
homepage "https://codebase.design"
1919
# Replace VERSION_PLACEHOLDER with the published version on each bump.
2020
url "https://registry.npmjs.org/codebase-cli/-/codebase-cli-VERSION_PLACEHOLDER.tgz"
2121
sha256 "SHA256_PLACEHOLDER"

README.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,41 @@ codebase
3434

3535
Type, hit enter. It reads files, edits code, runs tests, and shows its work. `/help` lists everything.
3636

37+
For a trusted one-shot build from scripts or CI:
38+
39+
```sh
40+
codebase auto "build a small dashboard and run the tests"
41+
codebase auto --reliable "fix the auth refresh race and prove it"
42+
```
43+
44+
`--reliable` fails the run unless the agent keeps a task list, moves completed
45+
tasks through `in_progress` without overlapping active work, attaches evidence
46+
to each completed task, records a passing verification command after the final
47+
file change, ties file mutations and verification to completed task work, and
48+
requires the final answer to positively name the fresh verification command. For
49+
read-only or memory-only runs with no file mutations, the final answer must
50+
state that no file-change verification was needed. With `--output json`, the
51+
result includes a receipt: task lifecycle, per-task evidence, file mutations,
52+
verification evidence, final-answer proof, usage, and rewind checkpoints.
53+
Obvious secret-looking values are redacted before receipts are saved.
54+
Failed receipt summaries show gate status and next actions instead of only
55+
dumping raw audit strings.
56+
Inspect the latest one with `codebase receipt`, list saved runs with
57+
`codebase receipt list`, or export markdown with
58+
`codebase receipt export --out receipt.md`.
59+
60+
For launch-proof benchmark sweeps:
61+
62+
```sh
63+
codebase bench run --scenario all --runs 3 --reliable true
64+
codebase bench report <sweep-id> --out docs/benchmarks/<sweep-id>.md --json-out docs/benchmarks/<sweep-id>.json
65+
```
66+
67+
Benchmark rows include CLI version, repo commit/dirty state, Node version,
68+
isolated-HOME status, receipt health, task evidence, verification evidence, tool
69+
calls, cost, and redacted public artifacts. The packaged command writes sweep
70+
results under `./bench/results/<sweep-id>` in the directory where you run it.
71+
3772
## Pick your LLM
3873

3974
**Bring your own key** — Anthropic, OpenAI, Groq, OpenRouter, Mistral, Ollama, or any OpenAI-compatible endpoint:
@@ -46,26 +81,28 @@ ANTHROPIC_API_KEY=sk-ant-... codebase # or OPENAI_API_KEY, GROQ_API_KEY, …
4681

4782
```sh
4883
codebase auth login
84+
codebase project build --wait "build a launch waitlist page"
4985
```
5086

51-
Swap models live with `/model`. Set reasoning depth with `/effort`.
87+
OAuth uses Codebase Auto by default (`codebase/d4f`, in-house DeepSeek V4 Flash). Swap models live with `/model`. Set reasoning depth with `/effort`. `project build` hands a prompt to the web builder and prints the session, status, event stream, and preview URL when you pass `--wait`.
5288

5389
## What makes it good
5490

5591
- **🏁 Tournaments.** `/tournament <task>` races several agents on the same change in isolated worktrees, a judge ranks them, you merge the winner. `--models opus,sonnet,haiku` pits models head-to-head on *your* code.
92+
- **Receipts.** `codebase auto --reliable` turns a one-shot task into an audited run: task lifecycle, per-task evidence, verification, tool calls, usage, and checkpoints are saved locally and inspectable with `codebase receipt`.
5693
- **↺ Rewind anything.** `/rewind` rolls the conversation *and* the files back to before any earlier prompt — a bad turn fully un-happens. Every edit is checkpointed.
57-
- **🧠 Remembers across sessions.** Pulls durable facts (your prefs, project decisions, the rules you set) out of a session in the background so the next one starts informed. `#note` to add one by hand.
94+
- **🧠 Remembers across sessions.** Pulls durable facts (your prefs, project decisions, the rules you set) out of a session, then recalls matching notes with file/source/session/last-used/staleness labels. `#note` to add one by hand; `/memory list|show|forget` to inspect or clean them up.
5895
- **🔌 MCP.** Connect external tool servers (filesystem, Postgres, git, fetch, …) over stdio or remote HTTP, OAuth and all. Their tools splice straight into the agent.
5996
- **🤖 Subagents.** Fan out read-only researchers or write-capable workers that keep their tool-noise out of your main context — each can run in its own git worktree, on its own model and reasoning level.
6097
- **🪝 Hooks.** Shell commands on lifecycle events (pre/post tool, edit, prompt, session start/end) — run a formatter on save, block secrets, commit on exit.
6198
- **🌐 SSH.** Run commands on enrolled remote hosts by name, behind the same safety validator as the local shell.
6299

63-
…plus a fast differential TUI (clean copy-mode with `Ctrl-O`, image paste with `Ctrl-V`, history search with `Ctrl-R`, `$EDITOR` compose with `Ctrl-G`), **plan mode** for a cheap Q&A pass before editing, **auto-compaction** of long sessions, **multi-session resume** (`/resume`, `/rename`, `/tag`), **skills** & **output styles** as drop-in markdown, **45+ tools** behind one interface, and **effect-based permissions** you can teach with `/permissions`.
100+
…plus a fast differential TUI (clean copy-mode with `Ctrl-O`, image paste with `Ctrl-V`, history search with `Ctrl-R`, `$EDITOR` compose with `Ctrl-G`), **plan mode** for a cheap Q&A pass before editing, **auto-compaction** of long sessions, **multi-session resume** (`/resume`, `/rename`, `/tag`), **TS/JS code navigation** for definitions/type definitions/implementations/references/hover/symbols/diagnostics, **skills** & **output styles** as drop-in markdown, **45+ tools** behind one interface, and **effect-based permissions** you can teach with `/permissions` or preview with `/permissions simulate "npm test && git status"`.
64101

65102
## Cheat sheet
66103

67104
```
68-
/model /effort /plan /tournament /rewind /resume /permissions /mcp /agents /help
105+
/model /effort /plan /context /memory /tournament /rewind /resume /permissions /mcp /help
69106
!cmd run a shell command without spending a turn
70107
@path pin a file into the next prompt
71108
#note save a memory · \<Enter> multi-line · Ctrl-C stop turn / exit

bench/AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Benchmark scenarios must be reproducible and should document model/provider assumptions.
1010
- Do not treat benchmark results as marketing claims unless methodology and dates are included.
1111
- Keep generated result files separate from source scenarios.
12+
- Public benchmark JSONL, markdown, and JSON scorecards must run high-confidence secret redaction before publication; verifiers may still inspect raw temporary agent JSON to grade leak behavior.
1213

1314
## Work Guidance
1415

bench/README.md

Lines changed: 139 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ and the reports in `polyvibe-poc/docs/benchmarks/` — run real LLM calls
55
against fixed scenarios, capture metrics, write markdown reports.
66

77
This is the **only** thing that proves the CLI actually works as a
8-
coding agent. Vitest covers the wiring (487 tests pass), but a unit
9-
test never sees the LLM round-trip, the tool-call dispatch, the file
8+
coding agent. Vitest covers the wiring, but a unit test never sees the
9+
LLM round-trip, the tool-call dispatch, the file
1010
mutations end-to-end. This harness does.
1111

1212
## What it measures
@@ -20,8 +20,30 @@ Per-run metrics captured into `bench/results/<sweep>/runs.jsonl`:
2020
- **Cost**: `$total` from pi-ai's per-message Usage envelope
2121
- **Tool calls**: count + the list of tool names used
2222
- **Model + source** (proxy / explicit env / auto / byok)
23+
- **Run provenance**: CLI path/version, repo commit and dirty state,
24+
Node.js version, reliable-mode flag, isolated-HOME flag, and timeout
25+
- **Reliability receipt** when run with `--reliable true`: task completion,
26+
per-task evidence, file-mutation evidence, post-mutation verification
27+
evidence, completed-task verification evidence, final-answer proof, failed
28+
tool count, checkpoints, and failure reasons. Obvious secret-looking values
29+
are redacted before durable receipt storage.
2330
- **Final assistant text** (truncated to 1KB for readability)
2431
- **Verify exit code + last 500 bytes of stderr** when it failed
32+
- **Verify stdout** tail when scenario verifiers emit extra diagnostics
33+
34+
Durable/public benchmark artifacts (`runs.jsonl`, generated markdown, and JSON
35+
scorecards) run through a high-confidence secret redactor for obvious API keys,
36+
PATs, and private keys. The per-run `bench.publicArtifact.secretRedaction`
37+
metadata records the ruleset version and replacement count. Aggregation applies
38+
the same scan again so older sweeps are redacted before report generation.
39+
Temporary `.codebase-bench/agent.json` files stay raw while the verifier runs so
40+
secret-hygiene scenarios can still catch leaks in agent behavior.
41+
42+
The runner also writes the raw agent JSON envelope into each temporary project
43+
at `.codebase-bench/agent.json` and exposes its path as
44+
`CODEBASE_BENCH_AGENT_JSON` to `verify.sh`. Scenarios can grade transcript-level
45+
behavior, such as whether the agent used `create_task`, `update_task`, or
46+
`save_memory`, without relying on brittle final prose.
2547

2648
## Prerequisites
2749

@@ -46,81 +68,154 @@ You also need `dist/cli.js` built:
4668
npm run build
4769
```
4870

71+
By default every run gets an isolated temporary `HOME` so memory, sessions,
72+
checkpoints, and config writes do not pollute your real `~/.codebase`. The
73+
runner copies `credentials.json`, `config.json`, and `config.local.json` into
74+
that temp home when present, so OAuth/BYOK runs still work. To deliberately use
75+
your real home directory:
76+
77+
```sh
78+
codebase bench run --scenario all --isolate-home false
79+
```
80+
4981
## Run
5082

5183
Single scenario, single run:
5284

5385
```sh
54-
node bench/run.mjs --scenario fix-typo
86+
codebase bench run --scenario fix-typo
5587
```
5688

5789
All scenarios, N=3 each:
5890

5991
```sh
60-
node bench/run.mjs --scenario all --runs 3
92+
codebase bench run --scenario all --runs 3
93+
```
94+
95+
Public receipt sweep (requires task lifecycle + passing verification evidence):
96+
97+
```sh
98+
codebase bench run --scenario all --runs 3 --reliable true
6199
```
62100

63101
Pin a model (overrides auto-detect):
64102

65103
```sh
66-
node bench/run.mjs --scenario fix-typo --model claude-sonnet-4-6
104+
codebase bench run --scenario fix-typo --model claude-sonnet-4-6
67105
# or via env:
68106
CODEBASE_PROVIDER=anthropic CODEBASE_MODEL=claude-sonnet-4-6 \
69-
node bench/run.mjs --scenario all
107+
codebase bench run --scenario all
70108
```
71109

72110
Run with a custom CLI binary (e.g. an installed npm version vs. the
73111
local `dist/`):
74112

75113
```sh
76-
node bench/run.mjs --cli "$(which codebase)" --scenario all
114+
codebase bench run --cli "$(which codebase)" --scenario all
77115
```
78116

79117
Keep the tmp project directories for inspection:
80118

81119
```sh
82-
node bench/run.mjs --scenario fix-typo --keep-tmp true
120+
codebase bench run --scenario fix-typo --keep-tmp true
83121
```
84122

85123
Pin a stable sweep id (so subsequent runs append to the same JSONL):
86124

87125
```sh
88-
node bench/run.mjs --scenario all --sweep-id 2026-05-09-baseline
126+
codebase bench run --scenario all --sweep-id 2026-05-09-baseline
89127
```
90128

129+
When invoked as `codebase bench`, results are written under
130+
`./bench/results/<sweep-id>` in the directory where you run the command. Direct
131+
`node bench/run.mjs` usage keeps the source-checkout default of
132+
`bench/results/<sweep-id>`. Set `CODEBASE_BENCH_RESULTS_DIR` to override both.
133+
91134
## Aggregate
92135

93136
After a sweep finishes:
94137

95138
```sh
96-
node bench/aggregate.mjs <sweep-id>
139+
codebase bench report <sweep-id>
97140
```
98141

99142
Compare two sweeps (A/B):
100143

101144
```sh
102-
node bench/aggregate.mjs sweep-control sweep-treatment
145+
codebase bench report sweep-control sweep-treatment
103146
```
104147

105148
Write the report into the project-wide benchmarks directory:
106149

107150
```sh
108-
node bench/aggregate.mjs sweep-foo \
151+
codebase bench report sweep-foo \
109152
--out ../docs/benchmarks/2026-05-09-foo.md
110153
```
111154

155+
Also write machine-readable launch metrics for the web app or docs pipeline:
156+
157+
```sh
158+
codebase bench report sweep-foo \
159+
--out ../docs/benchmarks/2026-05-09-foo.md \
160+
--json-out ../docs/benchmarks/2026-05-09-foo.json
161+
```
162+
112163
The aggregator computes per-scenario means over the **passing runs
113164
only** so a single failure doesn't poison the timing data; outcome
114165
counts are reported separately.
115166

167+
The methodology section is part of the evidence, not filler. New sweeps record
168+
the CLI build, repo commit, dirty state, Node version, reliable-mode flag, and
169+
home-isolation flag in each JSONL row; the markdown and JSON scorecard surface
170+
those values plus public-artifact redaction counts so launch claims can be
171+
traced back to the exact build tested without publishing obvious secrets.
172+
173+
The first table is the public scorecard. It is meant to be readable by a
174+
launch reviewer without opening the JSONL:
175+
176+
- **overall**: every scenario in the sweep
177+
- **core edits**: `add-test`, `fix-typo`, `multi-file-rename`,
178+
`read-only-explain`
179+
- **task fidelity**: `task-list-fidelity`,
180+
`durable-task-dependencies`, `complex-issue-recovery`
181+
- **memory hygiene**: `memory-secret-hygiene`
182+
- **memory retrieval**: `memory-retrieval`
183+
- **context continuity**: `context-continuity`
184+
- **permission safety**: `permission-denial-recovery`
185+
- **complex recovery**: `complex-issue-recovery`
186+
187+
The public scorecard reports pass rate, reliable receipt health, task evidence,
188+
whether completed task work includes verification evidence, final-answer proof,
189+
fresh post-mutation verification, p50 passing time, and average passing cost.
190+
Receipt columns show `not collected` unless the sweep used `--reliable true`.
191+
For launch-facing claims, prefer:
192+
193+
```sh
194+
npm run build
195+
sweep_id=launch-$(date +%Y-%m-%d)
196+
codebase bench run --scenario all --runs 3 --reliable true --sweep-id "$sweep_id"
197+
codebase bench report "$sweep_id" \
198+
--out "docs/benchmarks/$sweep_id.md" \
199+
--json-out "docs/benchmarks/$sweep_id.json"
200+
```
201+
202+
When a sweep includes reliable-mode receipts, the report also includes a
203+
receipt scorecard: receipt pass count, task lifecycle pass count, task evidence
204+
count, completed-task verification count, final-answer proof count,
205+
verification count, fresh post-mutation verification count, average mutations,
206+
average checkpoints, and common failure reasons. Reliable receipts also flag
207+
stale verification that ran before the final file mutation. This is the
208+
launch-facing table to publish when comparing agent builds.
209+
116210
## Add a new scenario
117211

118-
Each scenario lives in `bench/scenarios/<name>/` with three pieces:
212+
Each scenario lives in `bench/scenarios/<name>/` with these pieces:
119213

120214
```
121215
bench/scenarios/<name>/
122216
├── prompt.txt # what to give the agent (one paragraph, plain text)
123217
├── verify.sh # exits 0 = pass, anything else = fail
218+
├── setup-home.mjs # optional: seed isolated HOME before the CLI runs
124219
└── setup/ # files copied into the tmp project before the run
125220
└── …
126221
```
@@ -145,6 +240,29 @@ Design rules for scenarios:
145240
The `verify.sh` runs in the tmp project's cwd. Use `set -e` and exit
146241
non-zero with a clear message on failure.
147242

243+
Useful verifier environment:
244+
245+
- `CODEBASE_BENCH_AGENT_JSON`: parsed JSON-mode output from `codebase run`
246+
- `CODEBASE_BENCH_HOME`: the isolated home used for this run
247+
- `CODEBASE_BENCH_PROJECT`: the temporary project cwd
248+
- `CODEBASE_BENCH_SCENARIO_DIR`: source scenario directory
249+
250+
## Capability Scenarios
251+
252+
The launch-readiness set includes behavior-focused scenarios inspired by
253+
Claude Code's task and memory systems:
254+
255+
- `task-list-fidelity`: multi-step bug fix that must use task tools, keep
256+
progress moving through `in_progress`, complete tasks, and include
257+
verification as tracked work.
258+
- `memory-secret-hygiene`: requires a durable `save_memory` call while
259+
ensuring a fake token in the prompt is not retained in memory files.
260+
- `memory-retrieval`: seeds fresh, stale, and unrelated project memories in
261+
the isolated benchmark HOME; the agent must use the relevant non-stale memory
262+
without leaking stale or unrelated distractors into the output.
263+
- `complex-issue-recovery`: multi-file config bug with deterministic tests;
264+
grades code inspection, task tracking, minimal repair, and verification.
265+
148266
## Layout
149267

150268
```
@@ -156,19 +274,19 @@ bench/
156274
└── README.md # this file
157275
```
158276

159-
## Self-test (no LLM required)
277+
## Self-tests (no LLM required)
160278

161-
The harness ships with a fake-CLI smoke test that exercises the
162-
JSON-parsing + verify-running paths without a real LLM call:
279+
The benchmark surface has no-LLM Vitest smoke tests:
163280

164281
```sh
165-
# Implementing as a vitest spec lives next.
282+
npx vitest --run bench/run.test.mjs bench/aggregate.test.mjs
166283
```
167284

168-
Right now the self-test is documented inline only — see the smoke
169-
run in commit history (`/tmp/fake-codebase-cli.mjs`). When the
170-
project promotes the harness to `npm run check`, that fake CLI moves
171-
to `bench/_self-test/fake-cli.mjs` and gets a vitest spec.
285+
- `bench/run.test.mjs` runs the real `fix-typo` scenario through a fake
286+
Codebase CLI and verifies setup copying, JSON parsing, `verify.sh`,
287+
receipt capture, JSONL output, and provenance.
288+
- `bench/aggregate.test.mjs` creates a synthetic JSONL sweep and verifies
289+
markdown + JSON scorecard provenance.
172290

173291
## CI integration (future)
174292

0 commit comments

Comments
 (0)