Skip to content

Commit 10e8067

Browse files
authored
Merge pull request #137 from stippi/code-assistant-crate-breakup
Code assistant crate breakup
2 parents 144774c + 4d8a0c3 commit 10e8067

377 files changed

Lines changed: 10367 additions & 9621 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,54 @@ Additional documentation is available in the `docs` folder if needed.
1313
- `cargo clippy --all-targets --all-features -- -D warnings` - Run linter
1414

1515
### Testing Specific Components
16-
- `cargo test --package code-assistant` - Test main crate
16+
- `cargo test --package code-assistant` - Test wiring binary
17+
- `cargo test --package code-assistant-core` - Test domain layer
18+
- `cargo test --package agent-core` - Test agent core
19+
- `cargo test --package tools-core` - Test tool framework
1720
- `cargo test --package llm` - Test LLM integration
1821
- `cargo test --package web` - Test web functionality
1922

2023
## Architecture Overview
2124

2225
This is a Rust-based tool for AI-assisted code tasks with multiple operational modes.
2326

24-
### Core Structure
25-
- **Workspace Layout**: Multi-crate workspace with 3 main crates:
26-
- `crates/code_assistant/` - Main application logic
27-
- `crates/llm/` - LLM provider integrations (Anthropic, OpenAI, Vertex, Ollama, etc.)
28-
- `crates/web/` - Web-related functionality (Perplexity, web fetches)
29-
30-
### Key Components
31-
- **Agent System** (`src/agent/`): Core AI agent logic with persistence and tool execution
32-
- **Tool System** (`src/tools/`): Extensible tool framework with implementations for file operations, command execution, and web searches
33-
- **UI Framework** (`src/ui/`): Dual interface support:
34-
- Terminal UI with rustyline
35-
- GUI using Zed's GPUI framework
36-
- **Session Management** (`src/session/`): Multi-session support with persistence
37-
- **MCP Server** (`src/mcp/`): Model Context Protocol server implementation
27+
### Crate Layers
28+
29+
```
30+
Layer 0 (generic): llm command_executor fs_explorer sandbox web git terminal terminal_output
31+
Layer 1 (generic): tools_core — tool trait, registry, render, spec, permissions
32+
Layer 2 (generic): agent_core — agent loop, hook traits, dialect trait, AgentUi trait
33+
Layer 3 (domain): code_assistant_core — sessions, persistence, UiEvent, tool impls,
34+
dialects (xml/caret), plugins, sub-agents, backend
35+
Layer 4 (frontends): ui_gpui ui_terminal (acp/ and mcp/ remain as modules in the binary)
36+
Layer 5 (binary): code_assistant — CLI, config, feature-gated frontend wiring
37+
```
38+
39+
The binary feature-gates `gpui-frontend` and `terminal-frontend` (both default).
40+
A `--no-default-features` build produces a headless binary without gpui.
41+
42+
### Key Entry Points
43+
- **Agent loop**: `crates/agent_core/src/runtime.rs`
44+
- **Domain agent wrapper**: `crates/code_assistant_core/src/agent/runner.rs`
45+
- **Tool trait & registry**: `crates/tools_core/src/`
46+
- **Tool implementations**: `crates/code_assistant_core/src/tools/`
47+
- **Tool dialects (xml/caret)**: `crates/code_assistant_core/src/tool_dialects/`
48+
- **Plugins/hooks**: `crates/code_assistant_core/src/plugins/`
49+
- **Session management**: `crates/code_assistant_core/src/session/`
50+
- **GPUI frontend**: `crates/ui_gpui/src/`
51+
- **Terminal frontend**: `crates/ui_terminal/src/`
52+
- **MCP server**: `crates/code_assistant/src/mcp/`
53+
- **ACP server**: `crates/code_assistant/src/acp/`
3854

3955
### Tool Architecture
40-
- **Core Framework** (`src/tools/core/`): Dynamic tool registry and execution system
41-
- **Tool Implementations** (`src/tools/impls/`): File operations, command execution, search, web fetch
42-
- **Tool Modes**:
43-
- `native` - Uses LLM provider's native tool calling
44-
- `xml` - Custom XML-based tool syntax in system messages
45-
- `caret` - Custom triple-caret-fenced tool syntax in system messages
46-
47-
### LLM Integration
56+
- **Core framework** (`tools_core`): `DynTool` trait, `ToolRegistry` (instance, not singleton), `ToolSpec` with capability tags
57+
- **Tool implementations** live in `code_assistant_core::tools`
58+
- **Tool modes** (configured per agent instance via `ToolDialect`):
59+
- `native` LLM provider's native tool calling (default in `agent_core`)
60+
- `xml` XML-based tool syntax in system messages
61+
- `caret` triple-caret-fenced tool syntax in system messages
62+
63+
### LLM Integration (`crates/llm/`)
4864
- Multi-provider support: Anthropic, OpenAI, Google Vertex, Ollama, OpenRouter, AI Core
4965
- Recording/playback system for debugging and testing
5066
- Configurable context windows and model selection
@@ -55,26 +71,25 @@ This is a Rust-based tool for AI-assisted code tasks with multiple operational m
5571
- Integrates with Claude Desktop as MCP server
5672

5773
### Agent Mode
58-
- Supports both terminal, Agent Client Protocol, and GUI interfaces
74+
- Supports terminal, Agent Client Protocol, and GPUI interfaces
5975
- State persistence for continuing sessions
6076

6177
## Development Notes
6278

6379
### Testing
64-
- Unit tests distributed across modules
65-
- Integration tests in `src/tests/`
66-
- Mock implementations for testing (`src/tests/mocks.rs`)
80+
- Unit tests distributed across modules; integration tests in `crates/code_assistant/src/tests/`
81+
- Mock implementations in `code_assistant_core` behind the `test-utils` feature
82+
- Use `tools::test_registry()` (exported under `test-utils`) for deterministic tool tests
6783

6884
### UI Development
69-
- GUI based on Zed's gpui and gpui-component with custom components
70-
- Streaming JSON/XML/Caret processors for real-time updates
85+
- GPUI frontend based on Zed's gpui and gpui-component with custom components
86+
- Streaming processors per dialect in `code_assistant_core::tool_dialects/{xml,caret}/stream.rs`
7187
- Theme support
7288

7389
### Tool Development
74-
- Implement `DynTool` trait for new tools
75-
- Register in tool registry
76-
- Support both sync and async operations
77-
- Follow existing patterns in `src/tools/impls/`
90+
- Implement `DynTool` / `Tool` traits from `tools_core`
91+
- Register in a `ToolRegistry` instance via `register_default_tools()` in `code_assistant_core`
92+
- Capability tags (e.g. `read_only`, `edits_files`) replace the old `ToolScope` enum
7893

7994
## UI Communication Architecture
8095

@@ -89,7 +104,7 @@ There are **two main communication patterns** between components and the UI:
89104

90105
2. **Backend thread communication** (session management):
91106
- Used for session management operations (create, delete, list sessions)
92-
- Has separate `BackendEvent`/`BackendResponse` types and channels
107+
- Has separate `BackendEvent`/`BackendResponse` types and channels (`code_assistant_core::backend`)
93108
- Handled by a second task running concurrently
94109
- Operations: `LoadSession`, `CreateNewSession`, `ListSessions`, etc.
95110

0 commit comments

Comments
 (0)