provider-independent terminal agent

Grow code.With care.

Bonsai is a local-first coding agent that can inspect, plan, edit, run, diagnose, verify, review, remember, and coordinate. Switch models without losing the conversation, and choose how much runs without asking.

cargo install --git https://github.com/strozynskiw/bonsai.git --tag v0.2.0 --locked
one Rust binary macOS + Linux 23 connections 18 themes
Pixel bonsai in a clay pot.
5 levelsone autonomy ladder
3 phasesplan · code · review
2 surfacesinteractive TUI + headless/CI
1 sessionswitch models without starting over

one continuous workflow

Think carefully. Act decisively. Prove the result.

Plan, implement, verify, and review in one resumable conversation.

✦ bonsai #12 active ⌂ your-project ⎇ master ⏱ 4s ctx 18% · cost $0.42 · cache 96% · ↑2m ↓14.1k
Chat · make the retry test deterministic
› make the retry backoff test deterministic
✦ thinking
Tracing the flaky assertion to wall-clock sleeps
Planning a Clock trait with a test double
Inspect · 2 tools
read src/net/retry.rs
grep "thread::sleep" · 2 matches
Edit · 3 tools · 2 ok / 1 failed · edited 2 files · +24 −9 · 4.1s
edit src/net/retry.rs · stale region → Error: text not found after read
edit src/net/retry.rs +11 −5
edit src/net/retry_test.rs +13 −4
Test · 1 tool · 12.4s
bash cargo test retry:: · 14 passed, 0 failed
The test raced the wall clock. Backoff now takes a Clock; tests drive a MockClock — no sleeps, fully deterministic.
TODO
Find the sleep-based race in the retry test
Inject a Clock trait, add a MockClock
Rewrite backoff assertions on mock time
Run the full retry suite
Input Ask the agent to inspect, edit, test, or explain…
Coding · gpt-5.6-sol (high) · balanced · sandbox on Tab focus · Shift+Tab cycle

The actual interface in forest, the default of 18 themes—switch coding and plan mode without losing the conversation.

the full workshop

More than chat with a shell attached.

Bonsai combines the engineering loop with the controls and evidence needed for longer, more autonomous runs.

BRANCH 01

Inspect → edit → run → verify

Read, grep, glob, Rust symbols, rust-analyzer navigation, atomic patches, shell commands, Git inspection, web fetch, image input for compatible models, background jobs, and todos—batched when their access paths do not conflict.

atomic editsLSPbackground tasksverification
BRANCH 02

Plan, code, review

Research in read-only plan mode, hand the canvas to coding with /start, then inspect pending changes in a read-only review pass. The conversation stays intact.

plan canvasself-review/test/commit/pr
BRANCH 03

Switch models, keep the session

Switch connections, models, and reasoning effort mid-conversation—including local OpenAI-compatible endpoints. Bind model-and-effort combinations to one-letter shortcuts. Metadata, pricing, context limits, and capabilities come from models.dev.

23 connections3 transportsreasoningprompt cache
BRANCH 04

Context that knows how to prune

Cache-aware compaction, exact tokenizers where available, /ctx diagnostics, the SMOL profile, read-result reuse, and task episodes with untrusted recall framing.

SMOLcompactionepisodesrecallcache analytics
BRANCH 05

Memory and sessions that persist

User preferences follow you; project facts can ship with the repository. Hybrid retrieval combines BM25 and embeddings to recall relevant entries on demand. Sessions, plans, todos, usage, and context resume from SQLite.

BM25 + embeddings/rememberresumesearch
BRANCH 06

Agents and peers, without the chaos

Delegate exploration and review to scoped read-only subagents. Coordinate separate Bonsai sessions with messages, changed-file visibility, advisory work claims, wait relationships, and wake-on-finish.

5 concurrent subagentspeersclaimsread isolation
BRANCH 07

Extensible with plain files

Layer project and global config. Add MCP over stdio or Streamable HTTP, lifecycle hooks, skills, custom agents, providers, and themes under explicit trust and effect boundaries.

MCPhooksskillscustom agentsthemes
BRANCH 08

Headless and CI-native

Text, JSON, or streaming JSON events; documented exit codes; turn, time, output, tool, and session budgets; observed-state completion reports; and recovery worktrees for autonomous mutations.

stream-jsonbudgetsrecoveryeval harness
BRANCH 09

A terminal you can live in

Keyboard and mouse input, queued steering, selection and copy, diff cards, live task views, model and provider pickers, Serenity transcript mode, truecolor/256-color adaptation, and 18 built-in themes.

18 themesserenitydiffsusage dashboard
BRANCH 10

Honest about what happened

Usage, cost, retries, cache reads, verification freshness, file changes, authorization decisions, caveats, and budget exhaustion come from durable evidence—not the model’s recollection.

typed outcomestyped effects/perf/usage

autonomy without ambiguity

Choose how far it can grow.

Autonomy decides what may run without asking. The sandbox decides what a child process can physically touch. They are separate controls.

askno effects auto-run
conservativereads auto-run
balanceddaily dev loop
auto-accepthigh risk allowed
yoloautonomy guards off
▣ OS-level sandbox

macOS Seatbelt or Linux Bubblewrap confines writes to approved roots and denies network by default. Yolo does not silently disable it.

◇ Permission memory

Allow once, for the session, or for the project. Rules cannot re-enable the hard-deny floor.

◎ Workspace trust

Project-supplied config, hooks, MCP servers, skills, agents, and steering files remain inert until the repository is trusted.

! Untrusted stays data

Web, MCP, recalled history, files, and background output are framed so content cannot promote itself to instructions.

context lifecycle

Long sessions should get wiser, not heavier.

Bonsai measures each request, preserves cache-friendly prefixes, and prunes or reuses bulky results. Task episodes keep archived bytes available for recall.

▓▒░

Cache-aware compaction

Stable prefixes stay stable. Superseded reads and bulky tool output are reclaimed before a larger context rewrite is needed.

smol

SMOL profile

A deliberately compact prompt and tool surface for smaller or local models. Toggle it with /smol.

#01

Task episodes

Finished task spans archive as whole units — one compact card replaces the span when that actually saves context — instead of splitting message groups.

↶?

Recall on demand

The model can search or page archived bytes back in through an untrusted frame. Repeated live recalls collapse to pointers.

#42 · this session● working
src/agent/*
#39 · migration● working
claim: full test suite
#44 · docs○ idle
changed: README.md
explore agent● running
provider registry
review agent✓ done
1 finding

a coordinated grove

Parallel work that knows about itself.

Use subagents for focused, read-only work inside a turn. Use peers to coordinate separate Bonsai sessions in the same repository.

01Subagents stay lean. They return conclusions, not their entire internal transcript.
02Peers expose changed files. See which files a peer changed before your assumptions go stale.
03Claims reduce duplicate work. Advertise the full test suite or another expensive shared task.
04Wake when ready. Park a turn until a working peer finishes, then resume automatically.

use it your way

Interactive when you want it. Scriptable when you need it.

The TUI and headless mode share the same agent, persistence, permissions, budgets, and verification semantics.

$ bonsai

 /autonomy balanced      # routine dev loop runs without asking
 /sandbox on             # OS-level command confinement
 /model 3                # switch model mid-conversation
 fix the flaky retry test, then review your diff

# the agent inspects, edits, and self-reviews in the live transcript

 /test                   # run the configured test verification profile
 /commit                 # commit the reviewed diff

catalog-driven connections · switch connections or models without restarting the conversation

OpenCode Go OpenCode Zen OpenAI API Codex Anthropic API MiniMax API MiniMax Coding Plan Z.AI API Z.AI Coding Plan Moonshot AI API Kimi Coding Plan MiMo API MiMo Coding Plan DeepSeek API Qwen Cloud API Qwen Cloud Token Plan OpenRouter OpenAI-compatible Anthropic-compatible + custom connections

ready to grow

One binary.
The whole workshop.

Install with Cargo straight from GitHub (needs a stable Rust toolchain; the binary lands in ~/.cargo/bin). The first command installs the latest release; the second tracks master. To update, rerun with the new tag — or add --force to refresh a master build. Prebuilt binaries are planned for a later release.

cargo install --git https://github.com/strozynskiw/bonsai.git --tag v0.2.0 --locked
cargo install --git https://github.com/strozynskiw/bonsai.git --locked bonsai