- Updated markdown rendering logic to use more concise methods for obtaining vector lengths. - Changed review status display to use the correct flag from settings. - Cleaned up sidebar rendering code for better formatting and readability. - Enhanced status bar rendering with improved string formatting and consistent style application. - Refined workflow panel rendering, ensuring consistent style usage and improved readability. - Added architecture overview and detailed documentation for backend, data, dependencies, and frontend structures.
3.0 KiB
3.0 KiB
Backend Architecture
Provider Layer
The provider abstraction in dto/provider/ and service/provider.rs wraps LLM API calls:
- Configuration:
model/app_config.rsloads Anthropic/OpenAI-compatible endpoint settings - Authentication:
service/oauth/handles OAuth 2.0 with PKCE flow and token management - Requests:
dto/provider/request.rsbuilds provider-agnostic request structs - Responses:
dto/provider/response.rsparses streaming and non-streaming responses - Token tracking:
dto/provider/usage.rstracks token consumption
IPC (Inter-Process Communication)
The daemon-client protocol in src/ipc/:
- Transport: Unix domain sockets
- Framing: Length-prefixed frames with
serde_jsonserialization (ipc/frame.rs) - State Sync: Full state push from daemon after each action (
ipc/snapshot.rs); diff-based updates for efficiency (ipc/diff.rs) - Protocol:
ipc/protocol.rsdefines message types (Action, StateSnapshot, etc.)
Flow:
Client ──Action──▶ Daemon ──apply_action()──▶ State mutated
│
└──StatePayload──▶ Client (render)
Workflow Engine
Located in src/app/workflow/:
- Script DSL (
engine.rs): Executes the workflow script language (agent/parallel/pipeline/phase). Supports subagent spawning with schema-validated output, concurrency limiting, and budget tracking. - Hive Mind (
hive_mind.rs): Core Intelligence spawns a CognitiveCyclePlan — ordered cycles of parallel processing nodes. Each node has a directive and access tier (read/write/full). Node outputs merge into a shared collective state in real time. Final consensus synthesis completes the convergence. - Docs (
docs.rs): Deterministic (not LLM) convergence writer — records every node's output + final consensus todocs/runs/.
MCP (Model Context Protocol)
src/app/mcp/manager.rs manages MCP client connections:
- Uses the
rmcpcrate for the MCP protocol - Supports stdio-based transport (child process) and streamable HTTP
- Tool discovery via
list_tools()and dynamic tool registration
LSP Integration
src/app/lsp/ provides Language Server Protocol support:
- Auto-provisioner (
provisioner.rs): Detects and starts LSP servers for Rust, TypeScript, Python, Go, and other languages - Client (
client.rs): JSON-RPC-based LSP client with typed notifications - Tools (
tool/lsp/mod.rs): 7 LSP tools (connect, hover, completion, definition, references, diagnostics, disconnect)
Background Bash
src/app/bgbash/ manages long-running shell jobs:
- Control (
control.rs): Job lifecycle management (spawn, signal, terminate) using Unix process groups - Job (
job.rs): Individual job state tracking with output buffering and progress monitoring
Review System
src/app/subagent/auto.rs spawns background reviews:
- Quick review after every edit
- Background test generation
- Architecture review
- Security review
- All retry once on failure, escalate to blocking error if retry also fails