Architecture
DeepSeek Rust CLI is built with a focus on modularity and async performance.
🏗️ Core Components
1. Agent Engine (src/agent/)
The brain of the system. It handles the conversation loop, context management, and decision-making for tool use.
2. TUI Layer (src/tui/)
Powered by crossterm. It provides a split-view interface with:
- Output Area: Real-time log of events, tool outputs, and agent thoughts with syntax highlighting via
StreamColorizer. - Input Area: 4-line dynamic footer including:
- Status: Spinner, task timer, and model info.
- Context: Current directory and real-time token usage.
- Command Bar: Interactive prompt with full cursor support.
- Task Queue: Horizontal visualization of queued and active commands.
3. API Client (src/api/)
A custom streaming client for the DeepSeek API, supporting both regular and reasoning (thought) content.
4. Tool Registry (src/tools/)
A centralized registry where tools are defined as traits. It handles:
- Validation: Ensuring paths and arguments are safe.
- Schema Generation: Providing the LLM with clear JSON schemas for each tool.
- Execution: Running tools with isolation and timeouts.
🔄 Execution Flow
- User enters a command in the TUI.
- The Agent processes mentions and historical context.
- The Agent calls the DeepSeek API.
- If a tool call is requested, the system checks for approval.
- Once approved, the tool executes and results are fed back to the Agent.
- The loop continues until the Agent completes the task.