|
| 1 | +# Codebuff |
| 2 | + |
| 3 | +Codebuff is a tool for editing codebases via natural-language instructions to Buffy (an expert AI programming assistant). |
| 4 | + |
| 5 | +## Goals |
| 6 | + |
| 7 | +- Make expert engineers faster (power-user focus). |
| 8 | +- Reduce time/effort for common programming tasks. |
| 9 | +- Improve via iteration/feedback (learn/adapt from usage). |
| 10 | + |
| 11 | +## Key Technologies |
| 12 | + |
| 13 | +- TypeScript monorepo (Bun workspaces) |
| 14 | +- Bun runtime + package manager |
| 15 | +- Next.js (web app + API routes) |
| 16 | +- Multiple LLM providers (Anthropic/OpenAI/Gemini/etc.) |
| 17 | + |
| 18 | +## Repo Map |
| 19 | + |
| 20 | +- `cli/` — TUI client (OpenTUI + React) and local UX |
| 21 | +- `sdk/` — JS/TS SDK used by the CLI and external users |
| 22 | +- `web/` — Next.js app + API routes (the "web API") |
| 23 | +- `packages/agent-runtime/` — agent runtime + tool handling (server-side) |
| 24 | +- `common/` — shared types, tools, schemas, utilities |
| 25 | +- `agents/` — main agents shipped with codebuff |
| 26 | +- `.agents/` — local agent templates (prompt + programmatic agents) |
| 27 | + |
| 28 | +## Request Flow |
| 29 | + |
| 30 | +1. CLI/SDK sends user input + context to the Codebuff web API. |
| 31 | +2. Agent runtime streams events/chunks back through SDK callbacks. |
| 32 | +3. Tools execute locally (file edits, terminal commands, search) to satisfy tool calls. |
| 33 | + |
| 34 | +## Conventions |
| 35 | + |
| 36 | +- Prefer `ErrorOr<T>` return values (`success(...)`/`failure(...)` in `common/src/util/error.ts`) over throwing. |
| 37 | +- Never force-push `main` unless explicitly requested. |
| 38 | +- To exclude files from a commit: stage only what you want (`git add <paths>`). Never use `git restore`/`git checkout HEAD -- <file>` to "uncommit" changes. |
| 39 | +- Run interactive git commands in tmux (anything that opens an editor or prompts). |
| 40 | +- Referral codes are applied via the CLI (web onboarding only instructs the user); see `web/src/app/api/referrals/helpers.ts`. |
| 41 | + |
| 42 | +## Docs |
| 43 | + |
| 44 | +- [`docs/architecture.md`](docs/architecture.md) — Package dependency graph, per-package details, architectural patterns |
| 45 | +- [`docs/request-flow.md`](docs/request-flow.md) — Full request lifecycle from CLI through server and back |
| 46 | +- [`docs/error-schema.md`](docs/error-schema.md) — Server error response formats and client-side handling |
| 47 | +- [`docs/development.md`](docs/development.md) — Dev setup, worktrees, logs, package management, DB migrations |
| 48 | +- [`docs/testing.md`](docs/testing.md) — DI over mocking, tmux CLI testing |
| 49 | +- [`docs/environment-variables.md`](docs/environment-variables.md) — Env var rules, DI helpers, loading order |
| 50 | +- [`docs/agents-and-tools.md`](docs/agents-and-tools.md) — Agent system, shell shims, tool definitions |
0 commit comments