420f00494f
Sets up the Cargo workspace (harness-core, harness-tools, harness-providers, harness-mcp, harness-lsp, harness-app, harness-tui) and the ten architecture docs under docs/. harness-core gets its foundational types (session/message/part/model ids), an in-process event bus, a table-driven permission evaluate function, and a SQLite-backed storage actor with schema and roundtrip coverage. Every crate compiles empty and a bin stub prints its version.
3.2 KiB
3.2 KiB
AI Coding Harness — Design Overview
A terminal AI coding harness written in Rust, modeled on opencode (engine, tools, permissions) and oh-my-opencode-slim (multi-agent orchestration), with one deliberate departure: agent behavior is defined entirely in config + markdown files, not hardcoded prompts.
Goals
- Interface v1: ratatui TUI. The core is a library with a serializable event stream, so a future HTTP server (SSE) + web client slots in without rearchitecting.
- Providers: GitHub Copilot (OAuth device flow), OpenAI (API key), Anthropic (API key). Hand-written HTTP clients — no SDK dependency — normalized to a single
LlmEventstream type. - Multiagent: full orchestration in the oh-my-opencode-slim style — a
tasktool spawning subagent child sessions, background/parallel subagents, a job board injected into the orchestrator's context each turn, session reuse by alias, subagent depth limits. All agents (including the bundled defaults) are markdown definitions users can override, replace, or disable. - Integrations: MCP client (stdio), LSP diagnostics after edits, markdown-defined slash commands and skills.
- Permissions: opencode-style rulesets
{permission, pattern, action: allow|deny|ask}with last-match-wins wildcard evaluation and an async "ask" that blocks tool execution until the user replies in the TUI (once / always / reject).
Document map
| Doc | Contents |
|---|---|
| 01-architecture.md | Cargo workspace layout, crate boundaries, dependencies, domain model, event bus, channel topology |
| 02-engine.md | The agent loop (outer/inner), permission engine, retry, doom-loop guard, cancellation, compaction seam |
| 03-providers.md | Provider trait, wire codecs, Copilot/OpenAI/Anthropic specifics, auth flows and storage, cost accounting |
| 04-multiagent.md | Agent definitions and registry, task tool, background jobs, job board, session reuse, depth limits |
| 05-tools.md | Built-in tools, truncation, edit replacer strategy, permission keys |
| 06-config.md | Config files, precedence, schema, agent/command/skill markdown loading |
| 07-tui.md | Screen layout, event loop, streaming markdown rendering, modals, keybinds |
| 08-storage.md | SQLite schema, storage actor, write cadence, session resume |
| 09-integrations.md | MCP client, LSP diagnostics, commands and skills |
| 10-milestones.md | Phased milestone plan, testing strategy, risks, reference files |
Reference codebases
Findings in these documents come from direct exploration of:
~/repos/opencode— TypeScript, Effect-based. Core loop inpackages/opencode/src/session/{prompt,processor}.ts, tools inpackages/opencode/src/tool/, permissions inpackages/opencode/src/permission/index.ts, providers inpackages/opencode/src/plugin/{github-copilot,openai}/andpackages/llm/.~/repos/oh-my-opencode-slim— opencode plugin. Orchestration insrc/hooks/task-session-manager/,src/utils/background-job-board.ts; agent prompts insrc/agents/*.ts.