快速上手
# Install via Homebrew (macOS/Linux) brew tap regent-vcs/tap brew install regent # Or via Go go install github.com/regent-vcs/regent/cmd/rgt@latest # Initialize in your project cd your-project rgt init # Work with Claude Code, Codex, or OpenCode normally — activity is tracked automatically # See what happened rgt log rgt blame src/file.go:42 rgt show <step-hash>
就这样。你的智能体活动现在可以被审计了。
演示
每个智能体交互回合都会自动捕获。无需手动提交。
示例
- 调试糟糕的重构——使用 `rgt log`、`rgt blame` 和 `rgt show` 追踪一个真实的计费回归问题。
你能获得什么
查看你的智能体实际做了什么
$ rgt log Step a1b2c3d | 2 min ago | Tool: Edit │ File: src/handler.go │ Added error handling to request handler │ + 5 lines, - 2 lines Step d4e5f6g | 5 min ago | Tool: Write │ File: tests/handler_test.go │ Created unit tests for handler │ + 23 lines Step f8g9h0i | 8 min ago | Tool: Bash │ Command: go mod tidy │ Cleaned up dependencies
溯源:这一行是由哪条提示词生成的?
$ rgt blame src/handler.go:42 Line 42: func handleRequest(w http.ResponseWriter, r *http.Request) { Step: a1b2c3d4e5f6 Session: claude-20260502-143021 Tool: Edit Prompt: "Add error handling to the request handler"
追踪多个并发会话
$ rgt sessions Active Sessions: claude_code:claude-20260502-143021 | 3 steps | Last: 2 min ago codex_cli:codex-20260502-091534 | 7 steps | Last: 2 hours ago $ rgt log --session claude_code:claude-20260502-143021 # Filter history by session
查看任何变更的完整上下文
$ rgt show a1b2c3d Step a1b2c3d4e5f6 Parent: d4e5f6g7h8i9 Session: claude-20260502-143021 Time: 2026-05-02 14:30:21 Tool: Edit File: src/handler.go Changes: + func handleRequest(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" { + http.Error(w, "Method not allowed", 405) + return + } - func handleRequest(w http.ResponseWriter, r *http.Request) { Conversation: User: "Add error handling to reject non-GET requests" Assistant: "I'll add method validation to the handler..."
为什么存在这个工具
AI 智能体没有自己的版本控制。
你知道这种痛苦:
- “五分钟前还是好的”
- “你为什么改了那个文件?”
- “回到重构之前”
- `/compact` 然后祈祷
- 把代码复制粘贴到一个新的对话中
三个早该存在的原语:
- `rgt log`——这个会话做了什么?
- `rgt blame`——这一行是由哪条提示词生成的?
- `rgt show`——检查任意步骤的完整上下文
我们给了智能体对我们代码库的写权限,但没有给它对应的 git 版本控制。re_gent 解决了这个问题。
工作原理
re_gent 将智能体活动存储在 `.regent/` 中(类似 `.git/`):
.regent/
├── objects/ # Content-addressed blobs (BLAKE3)
├── refs/ # Session pointers (one per agent)
├── index.db # SQLite query index
└── config.toml
每个使用工具的工具调用回合会创建一个 Step(步骤)——一个内容寻址的快照,记录了什么变了、为什么变、以及谁要求的:
Step { parent: <previous-step-hash> tree: <workspace-snapshot> causes: [{ tool_name: "Edit", args: <input>, result: <output> }] session_id: "claude_code:claude-20260502-143021" timestamp: "2026-05-02T14:30:21Z" }
Steps 形成一个有向无环图(DAG)。每个会话都有自己的分支。公共祖先会被去重。你将获得 git 级别的智能体活动审计能力。
技术细节:参见 POC.md 获取完整规范。
安装
通过 Homebrew(macOS/Linux)
brew tap regent-vcs/tap brew install regent
这会安装 `rgt` 命令,并自动为 bash、zsh 和 fish 设置 shell 补全。
通过 Go Install
go install github.com/regent-vcs/regent/cmd/rgt@latest
Shell 补全(手动设置):
# Bash rgt completion bash > /usr/local/etc/bash_completion.d/rgt # Zsh rgt completion zsh > "${fpath[1]}/_rgt" # Fish rgt completion fish > ~/.config/fish/completions/rgt.fish
从源码安装
git clone https://github.com/regent-vcs/regent
cd regent
go build -o rgt ./cmd/rgt
sudo mv rgt /usr/local/bin/二进制发布版
从 GitHub Releases 下载预构建的二进制文件
支持的工具
| 工具 | 状态 |
|---|---|
| Claude Code | 完整支持 |
| OpenAI Codex CLI | 完整支持 |
| OpenCode | 完整支持 |
| Cursor、Cline、Continue | 计划中 |
钩子在 `rgt init` 时自动配置。无需手动设置。
命令
| 命令 | 描述 |
|---|---|
| `rgt init` | 在当前目录初始化 `.regent/` 目录 |
| `rgt log` | 显示步骤历史(支持 `--session`、`-n`、`--json`、`--graph` 选项) |
| `rgt sessions` | 列出所有活跃的会话 |
| `rgt status` | 显示当前仓库状态 |
| `rgt show <step>` | 显示一个步骤的完整上下文(工具调用 + 对话内容) |
| `rgt blame <path>[:<line>]` | 显示文件中每一行的来源 |
| `rgt cat <hash>` | 通过哈希值检查任意对象 |
| `rgt version` | 打印版本信息 |
| rgt completion | 生成 Shell 补全脚本 |
特性
- 内容寻址存储 — BLAKE3 哈希,自动去重
- 快速查询 — SQLite 索引,亚 10 毫秒查询
- 每会话 DAG — 并发会话以独立引用方式追踪
- 对话追踪 — 在 /compact 和 /clear 操作后仍可保留
- 钩子驱动 — 透明集成 Claude Code、Codex 和 OpenCode
- 零配置 — 在 rgt init 时自动配置钩子
- 并发安全 — CAS 引用、ACID 事务
- 兼容 .gitignore — 支持 .regentignore
编辑器集成
VSCode 扩展
在编辑器中直接获取内联 blame 注释:
# From VSIX (Recommended) # Download the latest .vsix from: # https://github.com/regent-vcs/vscode-regent/releases # Then in VS Code: Extensions > ... > Install from VSIX... # From source (Development) git clone https://github.com/regent-vcs/vscode-regent cd vscode-regent npm install && npm run compile # Press F5 in VS Code to launch Extension Development Host
功能:
- 内联 blame 注释,显示每个步骤修改了哪一行
- 悬停提示,显示完整的步骤上下文(时间戳、工具名称、参数)
- 侧边栏中的会话时间线视图
- 一键访问对话历史
要求:必须安装 rgt CLI 并在项目中运行 rgt init。
查看扩展文档 →
re_gent 与 Git 对比
| Git | re_gent | |
|---|---|---|
| 追踪代码 | ✅ | ✅ |
| 追踪智能体活动 | ❌ | ✅ |
| 带提示词的 blame 功能 | ❌ | ✅ |
| 对话历史 | ❌ | ✅ |
| 并发会话 | ⚠️ 共享工作区冲突 | ✅ 独立的捕获会话引用 |
| 用途 | 开发者版本控制系统 | AI 智能体审计追踪 |
re_gent 是 git 的补充,而非替代。两者都可使用。
路线图
请参阅 ROADMAP.md 了解计划中的功能,包括:
- 非破坏性回退与分支操作
- 更多工具适配器(Cursor、Cline、Continue)
- 会话共享与合并支持
- 垃圾回收与完整性验证
贡献
欢迎贡献!请参阅 CONTRIBUTING.md 了解指南。
快速入门:
- QUICK_START.md — 5 分钟设置指南
- 适合新手的问题
在提交 PR 之前:
- 测试通过:go test ./... 和 go test -race ./...
- 代码检查通过:golangci-lint run
- 代码格式化:go fmt ./...
构建工具
- cobra — CLI 框架
- blake3 — BLAKE3 哈希
- go-diff — Myers 差异算法
- modernc.org/sqlite — 纯 Go SQLite
许可证
Apache License 2.0
由贡献者构建
Discord • 讨论 • 问题 • 技术规范