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
30 changes: 15 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "codebase"
workspaces: "codexray"
key: ${{ matrix.target }}

- name: Install protoc
Expand All @@ -70,8 +70,8 @@ jobs:
go-version-file: "go.mod"
cache: true

- name: Build Rust codebase (${{ matrix.target }})
working-directory: codebase
- name: Build Rust codexray (${{ matrix.target }})
working-directory: codexray
run: cargo build --release --target ${{ matrix.target }}
env:
CC_x86_64_apple_darwin: clang -arch x86_64
Expand All @@ -83,8 +83,8 @@ jobs:

mkdir -p dist/bin

# Copy codeactor-codebase built from Rust
cp codebase/target/${{ matrix.target }}/release/codeactor-codebase dist/bin/
# Copy codeactor-codexray built from Rust
cp codexray/target/${{ matrix.target }}/release/codeactor-codexray dist/bin/

# Download and extract fzf
echo "Downloading fzf from ${{ matrix.fzf_url }}"
Expand All @@ -102,7 +102,7 @@ jobs:
rm -rf /tmp/rg_extract /tmp/rg.tar.gz

# Set executable permissions
chmod +x dist/bin/codeactor-codebase dist/bin/fzf dist/bin/rg
chmod +x dist/bin/codeactor-codexray dist/bin/fzf dist/bin/rg

# Verify
ls -la dist/bin/
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "codebase"
workspaces: "codexray"
key: musl

- name: Install protoc
Expand All @@ -166,8 +166,8 @@ jobs:
go-version-file: "go.mod"
cache: true

- name: Build Rust codebase (static musl)
working-directory: codebase
- name: Build Rust codexray (static musl)
working-directory: codexray
run: |
export CC_x86_64_unknown_linux_musl=musl-gcc
export CXX_x86_64_unknown_linux_musl=musl-g++
Expand All @@ -178,8 +178,8 @@ jobs:
set -euo pipefail
mkdir -p dist/bin

# Copy codeactor-codebase (musl static)
cp codebase/target/x86_64-unknown-linux-musl/release/codeactor-codebase dist/bin/
# Copy codeactor-codexray (musl static)
cp codexray/target/x86_64-unknown-linux-musl/release/codeactor-codexray dist/bin/

# Download fzf
echo "Downloading fzf..."
Expand All @@ -196,7 +196,7 @@ jobs:
find /tmp/rg_extract -name rg -type f -exec mv {} dist/bin/rg \;
rm -rf /tmp/rg_extract /tmp/rg.tar.gz

chmod +x dist/bin/codeactor-codebase dist/bin/fzf dist/bin/rg
chmod +x dist/bin/codeactor-codexray dist/bin/fzf dist/bin/rg
ls -la dist/bin/

- name: Build Go codeactor (linux-x64-musl)
Expand All @@ -213,14 +213,14 @@ jobs:
- name: Verify static linking
run: |
echo "=== Verifying static linking ==="
file dist/bin/codeactor-codebase
file dist/bin/codeactor-codexray
echo ""
echo "=== Checking for dynamic symbols ==="
if command -v readelf &> /dev/null; then
readelf -d dist/bin/codeactor-codebase 2>&1 | head -20 || echo "(no dynamic section = fully static)"
readelf -d dist/bin/codeactor-codexray 2>&1 | head -20 || echo "(no dynamic section = fully static)"
fi
if command -v ldd &> /dev/null; then
ldd dist/bin/codeactor-codebase 2>&1 | head -10 || true
ldd dist/bin/codeactor-codexray 2>&1 | head -10 || true
fi

- name: Verify artifact
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ go.work.sum
# .idea/
# .vscode/
codeactor
codebase/config/config.toml
codexray/config/config.toml
36 changes: 18 additions & 18 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ Server defaults to `localhost:9080`. Override via `--host`/`--port` or `CODECACT
- **LLM**: `github.com/openai/openai-go/v3` (multi-provider: OpenAI-compatible, Bedrock)
- **HTTP/WS**: `gin-gonic/gin` + `olahol/melody`
- **TUI**: Bubble Tea
- **External**: `codeactor-codebase` (Rust, `127.0.0.1:12800`) — semantic search, repo investigation, call graph, code skeleton/snippet. See [Codebase Component](#codebase-component) below.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (typo): Consider standardizing the component name capitalization (e.g., CodeXRay Component) for consistency.

Elsewhere in the docs this is CodeXRay/CodeXRay Server, but here the link text and heading use Codexray. Please align this heading and link text with the canonical name (e.g. CodeXRay Component and #codexray-component).

Suggested implementation:

- **External**: `codeactor-codexray` (Rust, `127.0.0.1:12800`) — semantic search, repo investigation, call graph, code skeleton/snippet. See [CodeXRay Component](#codexray-component) below.

To fully align capitalization and anchors:

  1. Update the corresponding section heading from ## Codexray Component (or similar) to ## CodeXRay Component. On GitHub, this will still generate the #codexray-component anchor.
  2. Search the rest of CLAUDE.md for Codexray and update occurrences to the canonical CodeXRay / CodeXRay Server naming as appropriate, ensuring any manual anchors or references remain consistent (e.g. #codexray-component).

- **External**: `codeactor-codexray` (Rust, `127.0.0.1:12800`) — semantic search, repo investigation, call graph, code skeleton/snippet. See [Codexray Component](#codexray-component) below.
- **System deps**: `ripgrep` (rg), `fzf`

## Project Structure

```
codeactor-agent/
├── main.go # Entry point, CLI parsing, start codebase service
├── main.go # Entry point, CLI parsing, start codexray service
├── internal/
│ ├── app/
│ │ └── app.go # CodeActor: agent orchestration & init
Expand Down Expand Up @@ -131,9 +131,9 @@ codeactor-agent/
│ ├── memory/ # ConversationMemory (system/human/assistant/tool)
│ ├── config/ # Three-tier TOML config (tools > agents > global)
│ ├── diff/ # Unified diff computation
│ ├── embedbin/ # Embed Rust codebase binary
│ ├── embedbin/ # Embed Rust codexray binary
│ ├── datamanager/ # Task persistence (~/.codeactor/tasks/)
│ ├── globalctx/ # Global context (CodebaseURL, tool references)
│ ├── globalctx/ # Global context (CodexrayURL, tool references)
│ └── util/ # Error handling, crash recovery
├── pkg/messaging/ # Pub-Sub message bus
│ ├── message_event.go # MessageEvent definition
Expand All @@ -158,28 +158,28 @@ codeactor-agent/
6. **Context compression**: Multi-strategy (conservative/balanced/aggressive) context compression with priority-based message selection and LLM summarization to handle long conversations.
7. **WorkspaceGuard**: All file operations and bash commands are validated against workspace boundaries. Dangerous operations require user confirmation via Pub-Sub confirmation pipeline.

## Codebase Component
## Codexray Component

`codeactor-codebase` is a standalone **Rust** service that provides deep code analysis capabilities. It runs as a background HTTP server on `127.0.0.1:12800` (configurable via `config.toml` `[http] codebase_port`).
`codeactor-codexray` is a standalone **Rust** service that provides deep code analysis capabilities. It runs as a background HTTP server on `127.0.0.1:12800` (configurable via `config.toml` `[http] codexray_port`).

### Build & Run

```bash
cd codebase && cargo build --release
cd codexray && cargo build --release

# Start with target repo
./target/release/codeactor-codebase server --repo-path /path/to/project
./target/release/codeactor-codexray server --repo-path /path/to/project

# Custom address
./target/release/codeactor-codebase server --repo-path /path/to/project --address 0.0.0.0:8080
./target/release/codeactor-codexray server --repo-path /path/to/project --address 0.0.0.0:8080
```

The Go binary automatically launches `~/.codeactor/bin/codeactor-codebase` as a background process on startup (`main.go:startCodebaseServer()`). Logs go to `~/.codeactor/logs/codeactor-codebase/{date}.log`.
The Go binary automatically launches `~/.codeactor/bin/codeactor-codexray` as a background process on startup (`main.go:startCodexrayServer()`). Logs go to `~/.codeactor/logs/codeactor-codexray/{date}.log`.

### Architecture (Rust side)

```
codebase/src/
codexray/src/
├── main.rs # CLI entry: server / vectorize subcommands
├── config.rs # Config loading from ~/.codeactor/config/config.toml
├── codegraph/ # AST parsing + graph data structures
Expand Down Expand Up @@ -214,7 +214,7 @@ Core design: **single repo per process** — binds to one repo at startup via `-

### Embedding & Vector Search

The codebase service supports semantic code search via vector embeddings:
The codexray service supports semantic code search via vector embeddings:
- **Embedding model**: Configurable (default: `text-embedding-3-small`, 1536 dimensions)
- **Vector store**: LanceDB for vector indexing
- **Cache**: SQLite for embedding cache (avoids re-embedding unchanged code)
Expand All @@ -225,9 +225,9 @@ The codebase service supports semantic code search via vector embeddings:

| Layer | File | Usage |
|-------|------|-------|
| Startup | `main.go:216-257` | `startCodebaseServer()` launches the Rust binary as a background process |
| Global state | `internal/globalctx/global_context.go:20,31` | `CodebaseURL` field + `RepoOps *RepoOperationsTool` |
| Initialization | `internal/app/app.go:62,73` | Sets `CodebaseURL=http://127.0.0.1:12800`, creates `RepoOperationsTool` |
| Startup | `main.go:216-257` | `startCodexrayServer()` launches the Rust binary as a background process |
| Global state | `internal/globalctx/global_context.go:20,31` | `CodexrayURL` field + `RepoOps *RepoOperationsTool` |
| Initialization | `internal/app/app.go:62,73` | Sets `CodexrayURL=http://127.0.0.1:12800`, creates `RepoOperationsTool` |
| Tool wrapper | `internal/tools/repo_operations.go` | `RepoOperationsTool` with 3 methods: `ExecuteSemanticSearch`, `ExecuteQueryCodeSkeleton`, `ExecuteQueryCodeSnippet` |
| RepoAgent | `internal/agents/repo.go:105-139` | `doPreInvestigate()` calls `POST /investigate_repo` before each Run |
| Tool routing | `internal/agents/conductor.go:298-303`, `coding.go:59-63`, `repo.go:75-79` | Routes `semantic_search`/`query_code_skeleton`/`query_code_snippet` to `RepoOps` |
Expand All @@ -236,15 +236,15 @@ The codebase service supports semantic code search via vector embeddings:

```toml
[http]
codebase_port = 12800
codexray_port = 12800

[codebase]
[codexray]
enable_embedding = true
# 数据目录自动生成在 $HOME/.codeactor/data/
# embedding/ — 全局共享索引(BM25 + LanceDB 向量库)
# graph/ — 项目隔离数据(按 project_id 分目录)

[codebase.embedding]
[codexray.embedding]
model = "text-embedding-3-small"
api_token = "sk-..."
api_base_url = "https://api.openai.com/v1"
Expand Down
28 changes: 14 additions & 14 deletions CODEACTOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
| 类别 | 技术 | 版本 | 用途 |
|------|------|------|------|
| **主程序** | Go | 1.24+ | 核心实现语言,模块名 `codeactor` |
| **代码引擎** | Rust | 1.70+ (Tokio) | `codeactor-codebase` 服务,运行在 `127.0.0.1:12800` |
| **代码引擎** | Rust | 1.70+ (Tokio) | `codeactor-codexray` 服务,运行在 `127.0.0.1:12800` |
| **LLM 抽象层** | `github.com/openai/openai-go/v3` | - | 多 LLM 提供商的统一接口 (OpenAI-compatible) |
| **HTTP 框架** | `gin-gonic/gin` | - | REST API 服务器 |
| **WebSocket** | `olahol/melody` | - | WebSocket 连接管理 |
Expand All @@ -73,7 +73,7 @@

| 依赖 | 用途 |
|------|------|
| `codeactor-codebase` (Rust) | 代码分析服务(语义搜索、骨架提取、依赖分析) |
| `codeactor-codexray` (Rust) | 代码分析服务(语义搜索、骨架提取、依赖分析) |
| `ripgrep` (rg) | 全文正则搜索 |
| `fzf` | 模糊文件搜索 |

Expand Down Expand Up @@ -138,7 +138,7 @@
| `print_dir_tree` | 文件 | 打印目录树 |
| `search_replace_in_file` | 编辑 | 精准代码块替换 |
| `search_by_regex` | 搜索 | ripgrep 全文正则搜索 |
| `semantic_search` | 仓库 | 语义搜索(调用 codebase 服务) |
| `semantic_search` | 仓库 | 语义搜索(调用 codexray 服务) |
| `query_code_skeleton` | 仓库 | 查询代码骨架 |
| `query_code_snippet` | 仓库 | 查询函数实现 |
| `run_bash` | 系统 | 执行 Shell 命令 |
Expand Down Expand Up @@ -166,7 +166,7 @@
| `search_by_regex` | 搜索 | ripgrep 全文正则搜索 |
| `list_dir` | 文件 | 列出目录内容 |
| `print_dir_tree` | 文件 | 打印目录树 |
| `semantic_search` | 仓库 | 语义搜索(调用 codebase 服务) |
| `semantic_search` | 仓库 | 语义搜索(调用 codexray 服务) |
| `query_code_skeleton` | 仓库 | 查询代码骨架 |
| `query_code_snippet` | 仓库 | 查询函数实现 |

Expand Down Expand Up @@ -268,7 +268,7 @@ type ExecutorConfig struct {
| `print_dir_tree` | 文件 | R | 打印目录树 |
| `search_replace_in_file` | 编辑 | E | 精准代码块替换 |
| `search_by_regex` | 搜索 | R | ripgrep 全文正则搜索 |
| `semantic_search` | 仓库 | R | 语义搜索(调用 codebase 服务) |
| `semantic_search` | 仓库 | R | 语义搜索(调用 codexray 服务) |
| `query_code_skeleton` | 仓库 | R | 查询代码骨架 |
| `query_code_snippet` | 仓库 | R | 查询函数实现 |
| `run_bash` | 系统 | S | 执行 Shell 命令 |
Expand Down Expand Up @@ -331,7 +331,7 @@ search_by_regex(
#### semantic_search

```go
// 调用 codebase Rust 服务进行语义搜索
// 调用 codexray Rust 服务进行语义搜索
semantic_search(
query: string, // 自然语言或代码片段
limit: int // 返回结果数量上限
Expand Down Expand Up @@ -461,7 +461,7 @@ Agent → MessagePublisher → MessageDispatcher → TUIConsumer / WebSocketCons
```
1. 用户输入 (TUI 或 HTTP POST /api/start_task)
2. TaskManager.CreateTask() - 生成 UUID,创建 Memory
3. ExecuteTask() - 初始化 codebase 索引,启动消息分发
3. ExecuteTask() - 初始化 codexray 索引,启动消息分发
4. ConductorAgent.Run() - 进入循环
5. Conductor 循环 (最多 maxSteps 步):
├── 构造 messages: [SystemPrompt, ...Memory.Messages]
Expand Down Expand Up @@ -505,7 +505,7 @@ codeactor-agent/
│ ├── config/ # 配置加载
│ ├── datamanager/ # 数据存储
│ ├── diff/ # 差异计算 (unified diff)
│ ├── embedbin/ # 嵌入二进制 (Rust codebase 服务)
│ ├── embedbin/ # 嵌入二进制 (Rust codexray 服务)
│ ├── globalctx/ # 全局上下文
│ ├── http/ # HTTP API
│ ├── llm/ # LLM 抽象层
Expand All @@ -528,7 +528,7 @@ codeactor-agent/
│ ├── tui/ # 终端界面
│ └── util/ # 工具函数
├── pkg/messaging/ # 消息总线
├── codebase/ # Rust 代码引擎 (独立二进制)
├── codexray/ # Rust 代码引擎 (独立二进制)
│ ├── src/
│ │ ├── codegraph/ # AST 解析 + 调用图 (tree-sitter, petgraph)
│ │ ├── http/ # Axum HTTP 服务
Expand All @@ -553,8 +553,8 @@ codeactor-agent/
# 构建主程序
go build -o codeactor .

# 构建 Rust codebase 服务
cd codebase && cargo build --release
# 构建 Rust codexray 服务
cd codexray && cargo build --release
```

### 6.2 运行模式
Expand Down Expand Up @@ -646,7 +646,7 @@ thinking.use_provider = "xiaomi"
|------|------|
| 任务 Memory | `~/.codeactor/tasks/{taskID}.json` |
| LLM 日志 | `~/.codeactor/logs/llm-{date}.log` |
| Codebase 日志 | `~/.codeactor/logs/codeactor-codebase/{date}.log` |
| Codexray 日志 | `~/.codeactor/logs/codeactor-codexray/{date}.log` |

---

Expand Down Expand Up @@ -759,7 +759,7 @@ Thought Process:
| `internal/tools/` | 工具适配器 |
| `internal/memory/` | 任务记忆管理 |
| `pkg/messaging/` | Pub-Sub 消息总线 |
| `codebase/` | Rust 代码引擎 |
| `codexray/` | Rust 代码引擎 |
| `clients/nodejs-cli/` | Node.js CLI 客户端 |
| `config/config.toml` | 示例配置文件 |
| `docs/` | 补充文档 |
Expand All @@ -772,7 +772,7 @@ go build -o codeactor . # 构建
./codeactor tui # TUI 模式
./codeactor http # HTTP 模式
go test ./internal/... -v -count=1 # 测试
cd codebase && cargo build # Rust 构建
cd codexray && cargo build # Rust 构建
```

### C. 安全机制
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ User Query

### Download Pre-built Binary (Recommended)

Download the latest all-in-one release for your platform from the [GitHub Releases page](https://github.com/iohub/codeactor-agent/releases). The binary bundles the **codebase intelligence engine** (Rust), **fzf** (fuzzy finder), and **ripgrep** (regex search) — everything you need is included. Just extract and run `./codeactor` — zero dependencies, zero configuration.
Download the latest all-in-one release for your platform from the [GitHub Releases page](https://github.com/iohub/codeactor-agent/releases). The binary bundles the **codexray intelligence engine** (Rust), **fzf** (fuzzy finder), and **ripgrep** (regex search) — everything you need is included. Just extract and run `./codeactor` — zero dependencies, zero configuration.

### Prerequisites (for building from source)
- Go 1.24+
Expand Down
2 changes: 1 addition & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@

### 下载预编译包(推荐)

从 [GitHub Releases 页面](https://github.com/iohub/codeactor-agent/releases) 下载最新的 all-in-one 二进制包。包内已集成 **codebase 代码智能引擎**(Rust)、**fzf**(模糊搜索)和 **ripgrep**(正则搜索)——所有依赖一应俱全。解压后直接运行 `./codeactor`,零依赖、零配置,开箱即用。
从 [GitHub Releases 页面](https://github.com/iohub/codeactor-agent/releases) 下载最新的 all-in-one 二进制包。包内已集成 **codexray 代码智能引擎**(Rust)、**fzf**(模糊搜索)和 **ripgrep**(正则搜索)——所有依赖一应俱全。解压后直接运行 `./codeactor`,零依赖、零配置,开箱即用。

### 前置要求(从源码编译)
- Go 1.24+
Expand Down
10 changes: 5 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ set -euo pipefail
readonly SCRIPT_NAME="$(basename "$0")"
readonly SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
readonly DIST_DIR="${SCRIPT_DIR}/dist/bin"
readonly RUST_PROJECT_DIR="${SCRIPT_DIR}/codebase"
readonly RUST_PROJECT_DIR="${SCRIPT_DIR}/codexray"
readonly GO_PROJECT_DIR="${SCRIPT_DIR}"

# 产物名称
readonly RUST_BIN="codeactor-codebase"
readonly RUST_BIN="codeactor-codexray"
readonly GO_BIN="codeactor"

# 保留的文件模式(不清理的文件)
Expand Down Expand Up @@ -222,7 +222,7 @@ build_rust() {
cd "$RUST_PROJECT_DIR"
start_time=$(date +%s%N)

local cargo_flags="-p codeactor-codebase"
local cargo_flags="-p codeactor-codexray"
cargo_flags+=" --manifest-path ${RUST_PROJECT_DIR}/Cargo.toml"
if [[ "${BUILD_TYPE}" == "release" ]]; then
cargo_flags+=" --release"
Expand Down Expand Up @@ -400,7 +400,7 @@ ${BOLD}示例:${RESET}
DEBUG=1 ${SCRIPT_NAME} # 显示调试信息

${BOLD}产物:${RESET}
dist/bin/codeactor-codebase # Rust 子项目产物
dist/bin/codeactor-codexray # Rust 子项目产物
./codeactor # Go 主项目产物

EOF
Expand Down Expand Up @@ -485,7 +485,7 @@ cmd_build() {
# 先构建 Rust(除非跳过)
if [[ "${SKIP_RUST}" != "true" ]]; then
# 只在构建 Rust 前清理
log_info "building codebase"
log_info "building codexray"
build_rust || exit 1
else
log_warning "⊘ 跳过 Rust 构建 (SKIP_RUST=true)"
Expand Down
File renamed without changes.
Loading
Loading