Skip to content

Commit 6af2173

Browse files
committed
docs(dox): add repository guidance
Add a DOX hierarchy for CLI source, docs, benchmarks, scripts, and extension ownership boundaries.
1 parent f48ba4f commit 6af2173

33 files changed

Lines changed: 885 additions & 0 deletions

File tree

.settings/AGENTS.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# DOX: CLI Settings
2+
3+
## Purpose
4+
5+
- Own durable architecture notes, standards, testing notes, and planning material for the CLI.
6+
7+
## Local Contracts
8+
9+
- Keep settings docs aligned with current source and package scripts.
10+
- Do not store secrets, local credentials, or personal machine paths unless they are examples.
11+
12+
## Work Guidance
13+
14+
- Put broad standards here; put source-local operational contracts in `src/**/AGENTS.md`.
15+
16+
## Verification
17+
18+
- Run `git diff --check`.
19+
20+
## Child DOX Index
21+
22+
- No child DOX files yet.

AGENTS.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# DOX Framework
2+
3+
- This repository uses the DOX `AGENTS.md` hierarchy: root instructions apply everywhere, and child `AGENTS.md` files add binding local contracts for their subtrees.
4+
- Before editing, read this file and every `AGENTS.md` on the path to each target. If a parent index points to a child that covers the target, read that child too.
5+
- If instructions conflict, the closest `AGENTS.md` controls local details, but child docs must not weaken root security, quality, release, or DOX rules.
6+
- After meaningful changes, update the closest owning `AGENTS.md` when purpose, contracts, workflows, verification, artifacts, or child indexes changed.
7+
- Keep DOX docs operational: document stable contracts and current checks, not diary notes or aspirational systems.
8+
9+
## Project Purpose
10+
11+
- `codebase-cli` is the open-source terminal agent for Codebase. It provides an interactive TUI, headless mode, model/provider routing, tools, MCP, auth, memories, permissions, hooks, subagents, tournaments, and release packaging.
12+
13+
## Repository Map
14+
15+
- `src/` — TypeScript source for the CLI and all runtime subsystems.
16+
- `bin/` — executable shim published as the `codebase` binary.
17+
- `dist/` — generated build output; do not edit by hand.
18+
- `docs/` — user/developer reference documentation.
19+
- `.settings/` — durable architecture, testing, and extension notes.
20+
- `bench/` — benchmark scenarios, runner, and reports.
21+
- `scripts/` — release/build/support automation.
22+
- `vscode-extension/` — companion editor extension.
23+
- `Formula/` — package-manager/release packaging assets.
24+
25+
## Local Contracts
26+
27+
- Keep the CLI safe-by-default: filesystem, shell, SSH, MCP, hooks, subagents, and git tools must validate paths, permissions, and command effects.
28+
- Preserve cross-platform behavior for macOS/Linux/Windows unless a file explicitly scopes itself.
29+
- Do not log API keys, OAuth tokens, refresh tokens, credentials file contents, MCP secrets, or user clipboard/image data.
30+
- Treat tests as part of the public contract. When behavior changes, update the matching `*.test.ts` file or document the intentional gap.
31+
- Generated `dist/` files are build artifacts. Source changes belong in `src/`.
32+
33+
## Work Guidance
34+
35+
- Prefer small focused modules with colocated tests.
36+
- Keep command UX plain and terminal-friendly; avoid hidden network calls or file mutations without permission flow.
37+
- Use existing abstractions from `pi` packages and local subsystem APIs rather than parallel agent/tool frameworks.
38+
39+
## Verification
40+
41+
- Standard gate: `npm run check`.
42+
- Type-only: `npm run typecheck`.
43+
- Lint/format: `npm run lint`, `npm run lint:fix`, or `npm run format`.
44+
- Tests: `npm test` or targeted `npx vitest --run <file>`.
45+
- Build/release packaging: `npm run build`; `npm run prepublishOnly` before publishing.
46+
- Documentation-only edits: `git diff --check`.
47+
48+
## Child DOX Index
49+
50+
- `src/AGENTS.md` — CLI source architecture and subsystem index.
51+
- `docs/AGENTS.md` — user/developer docs.
52+
- `.settings/AGENTS.md` — durable project standards and planning material.
53+
- `bench/AGENTS.md` — benchmarks.
54+
- `scripts/AGENTS.md` — automation scripts.
55+
- `vscode-extension/AGENTS.md` — companion VS Code extension.

bench/AGENTS.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# DOX: Benchmarks
2+
3+
## Purpose
4+
5+
- Own benchmark scenarios, runner scripts, aggregate reports, and benchmark result artifacts.
6+
7+
## Local Contracts
8+
9+
- Benchmark scenarios must be reproducible and should document model/provider assumptions.
10+
- Do not treat benchmark results as marketing claims unless methodology and dates are included.
11+
- Keep generated result files separate from source scenarios.
12+
13+
## Work Guidance
14+
15+
- Prefer small scenario fixtures with explicit expected behavior.
16+
- Record environment details when adding new result artifacts.
17+
18+
## Verification
19+
20+
- Run `npm run bench` or targeted benchmark scripts when changing runner/scenario behavior.
21+
- Run `npm run bench:report` after changing aggregation.
22+
23+
## Child DOX Index
24+
25+
- No child DOX files yet.

docs/AGENTS.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# DOX: CLI Docs
2+
3+
## Purpose
4+
5+
- Own user/developer documentation for installing, migrating, configuring, and operating the CLI.
6+
7+
## Local Contracts
8+
9+
- Keep command names, flags, shortcuts, and config paths aligned with source code.
10+
- Do not document unreleased behavior as available unless clearly marked.
11+
- Avoid fabricated claims about provider support, benchmarks, or security guarantees.
12+
13+
## Work Guidance
14+
15+
- Prefer runnable examples and concise troubleshooting steps.
16+
- Link to source-owned settings when docs describe extension/config behavior.
17+
18+
## Verification
19+
20+
- Run `git diff --check`.
21+
- For command docs, verify the command exists in `src/commands/` or CLI help.
22+
23+
## Child DOX Index
24+
25+
- No child DOX files yet.

scripts/AGENTS.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# DOX: Scripts
2+
3+
## Purpose
4+
5+
- Own release, build, migration, and support automation scripts outside `src/`.
6+
7+
## Local Contracts
8+
9+
- Scripts must fail loudly on missing prerequisites and should avoid destructive actions unless explicitly named/flagged.
10+
- Do not print secrets, auth tokens, npm tokens, or local credential contents.
11+
- Keep release scripts aligned with `package.json` scripts.
12+
13+
## Work Guidance
14+
15+
- Prefer idempotent scripts and clear usage output.
16+
- Keep generated outputs out of source control unless intentionally versioned.
17+
18+
## Verification
19+
20+
- Run script help/dry-run where available.
21+
- Run `git diff --check`.
22+
23+
## Child DOX Index
24+
25+
- No child DOX files yet.

src/AGENTS.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# DOX: CLI Source
2+
3+
## Purpose
4+
5+
- Own all TypeScript runtime source for the terminal CLI, including agent orchestration, tools, TUI, auth, MCP, memory, permissions, hooks, config, sessions, and headless/server modes.
6+
7+
## Ownership
8+
9+
- `agent/` owns model-turn orchestration and agent-level features.
10+
- `tools/` owns tool implementations and permission/effect boundaries.
11+
- `ui/` and `ui-pi/` own interactive terminal interfaces.
12+
- `auth/` owns cloud auth, OAuth, token refresh, and credential storage.
13+
- `mcp/` owns MCP config, clients, protocol translation, and tool adaptation.
14+
- `memory/` owns durable memory extraction/injection/store.
15+
- `permissions/` owns command/effect allow/block state.
16+
- `commands/` owns slash-command registry and command handlers.
17+
- `config/` owns local/global config stores and output styles.
18+
- `hooks/` owns lifecycle hook loading/execution.
19+
- `sessions/` and `checkpoint/` own durable conversation/file-state rollback data.
20+
- `skills/`, `subagents/`, `ssh/`, `plan/`, `projects/`, and `app-server/` own their named subsystems.
21+
22+
## Local Contracts
23+
24+
- Public command behavior and CLI flags are user-facing API.
25+
- Tool effects must be explicit and permission-aware.
26+
- Path handling must resolve inside the intended cwd/worktree and handle symlinks/platform temp paths carefully.
27+
- Long-running work must stream status and remain interruptible.
28+
- Tests should avoid relying on host-specific absolute temp path spellings.
29+
30+
## Work Guidance
31+
32+
- Keep tests near source files and name them `<module>.test.ts`.
33+
- Prefer dependency injection for network/filesystem/process boundaries so tests can run offline.
34+
- Avoid importing from `dist/`; source imports should target `src/` modules.
35+
36+
## Verification
37+
38+
- Run targeted Vitest for touched subsystem files.
39+
- Run `npm run check` for cross-cutting source changes.
40+
- Run `npm run build` after changes affecting exported types, bin entrypoints, or package output.
41+
42+
## Child DOX Index
43+
44+
- `agent/AGENTS.md` — agent orchestration, tournament, rewind, prompts, models.
45+
- `tools/AGENTS.md` — tool implementations and permission boundaries.
46+
- `ui/AGENTS.md` — React/Ink TUI.
47+
- `ui-pi/AGENTS.md` — pi-based TUI/runtime widgets.
48+
- `auth/AGENTS.md` — OAuth/cloud credentials.
49+
- `mcp/AGENTS.md` — MCP clients/config/tool bridge.
50+
- `memory/AGENTS.md` — durable memory.
51+
- `permissions/AGENTS.md` — permission stores and command-prefix policy.
52+
- `commands/AGENTS.md` — slash commands and registry.
53+
- `config/AGENTS.md` — config, local LLM, output styles.
54+
- `hooks/AGENTS.md` — lifecycle hooks.
55+
- `sessions/AGENTS.md` — session persistence.
56+
- `checkpoint/AGENTS.md` — file/conversation checkpoint state.
57+
- `compaction/AGENTS.md` — conversation compaction and token budgeting.
58+
- `diagnostics/AGENTS.md` — health/check diagnostics.
59+
- `dotenv/AGENTS.md` — environment file loading.
60+
- `glue/AGENTS.md` — cloud glue APIs for intent/narration.
61+
- `headless/AGENTS.md` — non-interactive CLI runner.
62+
- `projects/AGENTS.md` — cloud project APIs and project commands.
63+
- `clipboard/AGENTS.md` — clipboard copy/image handling.
64+
- `user-queries/AGENTS.md` — queued user query persistence.
65+
- `skills/AGENTS.md` — skill loaders and registry.
66+
- `ssh/AGENTS.md` — SSH host config and command execution.
67+
- `subagents/AGENTS.md` — subagent definitions.
68+
- `plan/AGENTS.md` — plan mode.
69+
- `app-server/AGENTS.md` — local app/server protocol.

src/agent/AGENTS.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# DOX: Agent
2+
3+
## Purpose
4+
5+
- Own agent turn orchestration, project-file context, prompts, model routing, effort settings, event streams, rewind, WIP snapshots, and tournament workflows.
6+
7+
## Local Contracts
8+
9+
- Agent state changes must emit stable events consumed by UI/headless flows.
10+
- Rewind and checkpoint behavior must keep conversation and filesystem state consistent.
11+
- Tournaments must isolate contestant worktrees and avoid merging failed/unsafe outputs.
12+
- Model selection should respect user config, live overrides, local/cloud capability, and BYOK settings.
13+
14+
## Work Guidance
15+
16+
- Keep prompt changes paired with tests that assert critical invariants.
17+
- Use existing event types rather than ad hoc UI strings as contracts.
18+
19+
## Verification
20+
21+
- Run `npx vitest --run src/agent`.
22+
- For tournament/worktree changes, include real-worktree tests when feasible.
23+
24+
## Child DOX Index
25+
26+
- No child DOX files yet.

src/app-server/AGENTS.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# DOX: App Server
2+
3+
## Purpose
4+
5+
- Own the local app-server protocol and server used to communicate with companion app/UI surfaces.
6+
7+
## Local Contracts
8+
9+
- Keep protocol messages versioned or backwards-compatible when possible.
10+
- Validate inbound messages before dispatching work.
11+
- Do not expose localhost server capabilities beyond intended clients without auth/origin checks.
12+
13+
## Work Guidance
14+
15+
- Keep protocol definitions central in `protocol.ts`.
16+
- Test request/response and lifecycle behavior with server tests.
17+
18+
## Verification
19+
20+
- Run `npx vitest --run src/app-server`.
21+
22+
## Child DOX Index
23+
24+
- No child DOX files yet.

src/auth/AGENTS.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# DOX: Auth
2+
3+
## Purpose
4+
5+
- Own cloud authentication: browser/device OAuth flows, callback server, PKCE, token exchange/refresh, credential file storage, CLI auth commands, and credential validation.
6+
7+
## Local Contracts
8+
9+
- Credential files must be permission-hardened and never logged in full.
10+
- Refresh/token exchange code must handle expiry, invalid JSON, version mismatch, and concurrent refresh safely.
11+
- OAuth state, PKCE verifier, and redirect handling must defend against replay/mismatch.
12+
13+
## Work Guidance
14+
15+
- Keep network calls injectable for tests.
16+
- Prefer clear recovery messages that tell users how to re-authenticate.
17+
18+
## Verification
19+
20+
- Run `npx vitest --run src/auth`.
21+
- Run `npm run check` for credential or token-manager changes.
22+
23+
## Child DOX Index
24+
25+
- No child DOX files yet.

src/checkpoint/AGENTS.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# DOX: Checkpoint
2+
3+
## Purpose
4+
5+
- Own checkpoint storage used to rewind file and conversation state after tool actions.
6+
7+
## Local Contracts
8+
9+
- Checkpoints must capture enough state to undo edits without disturbing unrelated user changes.
10+
- Store paths must stay project-scoped and safe for concurrent sessions where practical.
11+
- Rewind behavior must clearly report what was restored and what could not be restored.
12+
13+
## Work Guidance
14+
15+
- Keep checkpoint metadata explicit and versionable.
16+
- Test dirty-tree, untracked-file, and missing-file scenarios when changing store behavior.
17+
18+
## Verification
19+
20+
- Run `npx vitest --run src/checkpoint` and related `agent/conversation-rewind` tests.
21+
22+
## Child DOX Index
23+
24+
- No child DOX files yet.

0 commit comments

Comments
 (0)