Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 40 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

An AI-powered autonomous coding assistant built with a **Hub-and-Spoke multi-agent architecture** in Go, backed by a Rust-based code analysis engine.

CodeActor Agent orchestrates multiple specialized agents — Conductor, Repo-Analyst, Coding-Engineer, Chat-Assistant, and Meta-Agent — to autonomously analyze, plan, and execute complex software engineering tasks with self-correction capabilities.
CodeActor Agent orchestrates multiple specialized agents — Conductor, Repo-Analyst, Coding-Engineer, Chat-Assistant, DevOps-Operator, and Meta-Agent — to autonomously analyze, plan, and execute complex software engineering tasks with self-correction capabilities.

## Features

### Multi-Agent System
- **Hub-and-Spoke Architecture** — Central Conductor delegates tasks to specialized sub-agents (Repo analysis, Code editing, General chat)
- **Hub-and-Spoke Architecture** — Central Conductor delegates tasks to specialized sub-agents (Repo analysis, Code editing, General chat, DevOps operations)
- **Meta-Agent** — Autonomous agent designer that creates custom sub-agents at runtime for tasks beyond built-in agents' capabilities
- **Self-Correction** — `thinking` tool enables agents to analyze errors and recover without blind retries
- **Agent Disable** — Conditionally exclude sub-agents at startup via `--disable-agents=repo,coding,chat,meta`
- **Agent Disable** — Conditionally exclude sub-agents at startup via `--disable-agents=repo,coding,chat,meta,devops`
- **ImplPlan Tool** — Stateful implementation plan document for complex multi-step coding tasks

### Rich Tool System (17 tools)
Expand Down Expand Up @@ -42,8 +42,6 @@ CodeActor Agent orchestrates multiple specialized agents — Conductor, Repo-Ana
- **Call Graph Analysis** — Function-level call graphs with caller/callee relations, cycle detection, complexity scoring
- **Semantic Code Search** — Vector embeddings via LanceDB + SQLite cache, OpenAI `text-embedding-3-small`
- **Code Skeleton/Snippet** — Batch file skeleton extraction and per-function code snippet retrieval
- **File Watching** — Automatic re-indexing on file changes with 20s debounce
- **Auto-Launch** — Go binary automatically starts the Rust codebase server as a child process with dynamic port allocation, health-check polling, and cleanup on exit


## Screenshots
Expand Down Expand Up @@ -91,6 +89,7 @@ enable_streaming = true
conductor_max_steps = 30
coding_max_steps = 50
repo_max_steps = 30
devops_max_steps = 15
meta_max_steps = 30
meta_retry_count = 5
lang = "Chinese"
Expand Down Expand Up @@ -150,10 +149,11 @@ Server defaults to `localhost:9080`. Override via `--host`/`--port` or `CODECACT

| Agent | Tools | Count |
|-------|-------|-------|
| Conductor | `delegate_repo`, `delegate_coding`, `delegate_chat`, `delegate_meta`, `finish`, `read_file`, `search_by_regex`, `list_dir`, `print_dir_tree` | 9 |
| Conductor | `delegate_repo`, `delegate_coding`, `delegate_chat`, `delegate_devops`, `delegate_meta`, `finish`, `read_file`, `search_by_regex`, `list_dir`, `print_dir_tree` | 10 |
| CodingAgent | All 17 tools (file ops, search, shell, thinking, impl_plan, micro_agent) | 17 |
| RepoAgent | `read_file`, `search_by_regex`, `list_dir`, `print_dir_tree`, `semantic_search`, `query_code_skeleton`, `query_code_snippet` | 7 |
| ChatAgent | None (pure LLM conversation) | 0 |
| ChatAgent | `micro_agent`, `thinking`, `finish` | 3 |
| DevOpsAgent | `run_bash`, `read_file`, `list_dir`, `print_dir_tree`, `search_by_regex`, `thinking`, `micro_agent`, `finish` | 8 |

[Full architecture documentation →](docs/ARCHITECTURE.md)

Expand Down Expand Up @@ -185,6 +185,39 @@ Disable Meta-Agent via startup flag:
./codeactor tui --disable-agents=meta
```

## DevOps-Agent

The **DevOps-Agent** is the operations and infrastructure specialist — it handles all non-coding operational tasks by executing shell commands, inspecting the file system, and analyzing command output. When the Conductor encounters a task involving system administration, log inspection, process management, or ad-hoc shell commands, it delegates to the DevOps-Agent via `delegate_devops`.

### Capabilities

- **Shell Command Execution** (`run_bash`) — Run any bash command with foreground/background support, danger detection, and workspace boundary checks
- **File System Inspection** — `read_file`, `list_dir`, `print_dir_tree`, `search_by_regex` for browsing logs, configs, and directories
- **Self-Correction** — `thinking` tool for analyzing command failures and adjusting approach before retrying
- **Isolated Analysis** — `micro_agent` for deep reasoning on command output or generating structured reports

### Example use cases

- Check disk usage, memory, and system resources
- Find all log files modified in the last 24 hours
- Restart services or check process status
- Inspect configuration files
- Run system diagnostics and generate reports
- Execute ad-hoc shell pipelines for data processing

### Configuration

```toml
[agent]
devops_max_steps = 15 # Max LLM steps for DevOps-Agent (default: 15)
```

Disable DevOps-Agent via startup flag:

```bash
./codeactor tui --disable-agents=devops
```

## Codebase Analysis Engine

The `codeactor-codebase` is a standalone **Rust** service that provides deep code analysis capabilities. It runs as a background HTTP server managed automatically by the Go binary.
Expand Down
47 changes: 40 additions & 7 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

基于 Go 语言开发的 **Hub-and-Spoke(中枢-辐条)多智能体架构** AI 自主编程助手,后端由 Rust 代码分析引擎支撑。

CodeActor Agent 协调多个专用智能体——指挥家(Conductor)、仓库分析员(Repo-Analyst)、编码工程师(Coding-Engineer)、对话助手(Chat-Assistant)和元代理(Meta-Agent)——自主完成复杂的软件工程任务,具备自我纠错能力。
CodeActor Agent 协调多个专用智能体——指挥家(Conductor)、仓库分析员(Repo-Analyst)、编码工程师(Coding-Engineer)、对话助手(Chat-Assistant)、运维操作员(DevOps-Operator)和元代理(Meta-Agent)——自主完成复杂的软件工程任务,具备自我纠错能力。

## 特性

### 多智能体系统
- **中枢-辐条架构** — 中央 Conductor 将任务委派给专用子智能体(仓库分析、代码编辑、通用对话)
- **中枢-辐条架构** — 中央 Conductor 将任务委派给专用子智能体(仓库分析、代码编辑、通用对话、运维操作
- **元代理(Meta-Agent)** — 自主设计代理,在运行时为超出内置 Agent 能力的任务动态创建自定义子智能体
- **自我修正** — `thinking` 工具使 Agent 能够在出错时分析原因并恢复,避免盲目重试
- **Agent 禁用** — 通过 `--disable-agents=repo,coding,chat,meta` 在启动时有条件地排除子智能体
- **Agent 禁用** — 通过 `--disable-agents=repo,coding,chat,meta,devops` 在启动时有条件地排除子智能体
- **ImplPlan 工具** — 状态化实现计划文档,用于复杂多步骤编码任务的分步规划

### 丰富工具系统(17 个工具)
Expand Down Expand Up @@ -42,8 +42,6 @@ CodeActor Agent 协调多个专用智能体——指挥家(Conductor)、仓
- **调用图分析** — 函数级调用图,含调用者/被调者关系、环路检测、复杂度评分
- **语义代码搜索** — 通过 LanceDB + SQLite 缓存的向量嵌入(OpenAI `text-embedding-3-small`)
- **代码骨架/片段** — 批量文件骨架提取和按函数的代码片段检索
- **文件监听** — 基于 `notify` 的文件系统监听,20s 防抖自动重索引
- **自动启动** — Go 二进制自动以子进程方式启动 Rust codebase 服务器,包含动态端口分配、健康检查轮询和退出清理

## 效果截图

Expand Down Expand Up @@ -90,6 +88,7 @@ enable_streaming = true
conductor_max_steps = 30
coding_max_steps = 50
repo_max_steps = 30
devops_max_steps = 15
meta_max_steps = 30
meta_retry_count = 5
lang = "Chinese"
Expand Down Expand Up @@ -149,10 +148,11 @@ node index.js history # 列出最近任务

| Agent | 工具 | 数量 |
|-------|-------|-------|
| Conductor | `delegate_repo`、`delegate_coding`、`delegate_chat`、`delegate_meta`、`finish`、`read_file`、`search_by_regex`、`list_dir`、`print_dir_tree` | 9 |
| Conductor | `delegate_repo`、`delegate_coding`、`delegate_chat`、`delegate_devops`、`delegate_meta`、`finish`、`read_file`、`search_by_regex`、`list_dir`、`print_dir_tree` | 10 |
| CodingAgent | 全部 17 个工具(文件、搜索、Shell、thinking、impl_plan、micro_agent) | 17 |
| RepoAgent | `read_file`、`search_by_regex`、`list_dir`、`print_dir_tree`、`semantic_search`、`query_code_skeleton`、`query_code_snippet` | 7 |
| ChatAgent | 无(纯 LLM 对话) | 0 |
| ChatAgent | `micro_agent`、`thinking`、`finish` | 3 |
| DevOpsAgent | `run_bash`、`read_file`、`list_dir`、`print_dir_tree`、`search_by_regex`、`thinking`、`micro_agent`、`finish` | 8 |

[完整架构文档 →](docs/ARCHITECTURE.md)

Expand Down Expand Up @@ -184,6 +184,39 @@ meta_retry_count = 5 # JSON 解析失败重试次数(默认 5)
./codeactor tui --disable-agents=meta
```

## DevOps-Agent(运维代理)

**DevOps-Agent** 是运维和基础设施专家——通过执行 Shell 命令、检查文件系统和分析命令输出来处理所有非编码的运维任务。当 Conductor 遇到系统管理、日志检查、进程管理或 ad-hoc shell 命令类任务时,会通过 `delegate_devops` 委派给 DevOps-Agent。

### 核心能力

- **Shell 命令执行** (`run_bash`) — 运行任意 bash 命令,支持前台/后台运行,含危险检测和工作空间边界检查
- **文件系统检查** — `read_file`、`list_dir`、`print_dir_tree`、`search_by_regex` 用于浏览日志、配置和目录
- **自我修正** — 使用 `thinking` 工具分析命令失败原因,调整策略后重试
- **独立分析** — 使用 `micro_agent` 对命令输出进行深度推理或生成结构化报告

### 示例用例

- 检查磁盘使用率、内存和系统资源
- 查找最近 24 小时内修改的所有日志文件
- 重启服务或检查进程状态
- 检查配置文件
- 运行系统诊断并生成报告
- 执行 ad-hoc shell 管道进行数据处理

### 配置

```toml
[agent]
devops_max_steps = 15 # DevOps-Agent 最大 LLM 步数(默认 15)
```

通过启动参数禁用 DevOps-Agent:

```bash
./codeactor tui --disable-agents=devops
```

## Codebase 分析引擎

`codeactor-codebase` 是一个独立的 **Rust** 服务,提供深度代码分析能力。它作为后台 HTTP 服务器运行,由 Go 二进制自动管理。
Expand Down
45 changes: 25 additions & 20 deletions docs/architecture.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 14 additions & 3 deletions i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ type translations struct {
HistoryConfirmDelete string
// Confirmation dialog
ConfirmDialogHelp string
// Command mode
CommandModePrompt string
CommandModeTips string
}

var langMap = map[Language]translations{
Expand Down Expand Up @@ -78,6 +81,8 @@ var langMap = map[Language]translations{
HistoryKeyClearFilter: "ctrl+u: 清除过滤",
HistoryConfirmDelete: "确认删除此会话?(y = 确认, 其他键 = 取消)",
ConfirmDialogHelp: "←/→ 选择 enter 确认 a 允许 s 全部允许 d/esc 拒绝",
CommandModePrompt: "命令模式",
CommandModeTips: "f:下翻页 b:上翻页 i:输入 esc:取消",
},
LangEnglish: {
Title: "CodeActor AI Assistant",
Expand Down Expand Up @@ -109,7 +114,9 @@ var langMap = map[Language]translations{
HistoryKeyBack: "esc: back",
HistoryKeyClearFilter: "ctrl+u: clear filter",
HistoryConfirmDelete: "Delete this conversation? (y = confirm, any other key = cancel)",
ConfirmDialogHelp: "\u2190/\u2192 choose enter confirm a allow s all d/esc deny",
ConfirmDialogHelp: "←/→ choose enter confirm a allow s all d/esc deny",
CommandModePrompt: "COMMAND",
CommandModeTips: "f:pgdn b:pgup i:input esc:cancel",
},
}

Expand Down Expand Up @@ -190,8 +197,12 @@ func (lm *LanguageManager) GetText(key string) string {
case "HistoryConfirmDelete":
return translations.HistoryConfirmDelete
case "ConfirmDialogHelp":
return translations.ConfirmDialogHelp
default:
return translations.ConfirmDialogHelp
case "CommandModePrompt":
return translations.CommandModePrompt
case "CommandModeTips":
return translations.CommandModeTips
default:
return fmt.Sprintf("[Missing translation: %s]", key)
}
}
Loading