mav2287/dual-agent-review

GitHub: mav2287/dual-agent-review

一个基于代码依赖图谱的 blast-radius 门控双智能体代码审查工具,用 Claude 与 Codex 协作并按实际变更影响范围决定审查深度。

Stars: 0 | Forks: 0

# dual-agent-review (`dar`) 一个小巧、独立的工具包,用于运行 **Claude-primary / Codex-surveyor** 代码审查循环,该循环由变更的**实际影响范围**而非 diff 大小来控制。 Claude Code 是集成者(专注于任务)。Codex 是广角的审查者和对抗者(只读)。依赖图会决定变更是否大到需要进行昂贵的审查——因此,对热点 symbol 的单行变更会得到审查,而 300 行的叶子节点变更则不会。 ## 环境要求:Claude Code + Codex 就这些。这个项目旨在只需在空白机器上安装以下软件即可运行: - **Claude Code** —— 集成者(并且它附带了 `dar` 所使用的 Node runtime)。 - **Codex CLI** —— 审查者/勘察者。 任何 repo 都需要 `git`,而 Node 随 Claude Code 一起提供。影响范围图是**使用纯 Node 程序内置**(`lib/graph.mjs`)的——不需要 Python,不需要 npm 包,也不需要安装任何其他东西。 **graphify 是可选的。** 如果恰好存在 [graphify](https://pypi.org/project/graphify/) 代码 知识图谱,`dar` 会将其更丰富的图谱作为加速器使用; 如果没有,内置的 Node 图谱就是默认选项,该工具的工作方式完全相同。 目前,精确的阈值控制涵盖了 JS/TS 和 shell repo;对于其他语言,原生图谱会安全降级,进行更多审查,直到添加相应的解析器。 它不是依赖树,也不是插件群——官方的 `openai/codex-plugin-cc` 插件是可选且互补的;`dar` 依赖于 Codex *CLI*,而不是该插件。 ## 安装 —— 即装即忘(推荐) 将其安装在 Claude Code 上,它会处理剩下的事情: ``` /plugin marketplace add mav2287/dual-agent-review /plugin install dual-agent-review ``` 在第一次会话中,该插件会自动引导一切——将 `dar` CLI 放到 PATH 中,激活审查循环,并且(如果存在 graphify)将其安装到两个 agent 中并连接其新鲜度钩子。从那时起,Claude 的行为会发生变化:`/dar-scope`、`/dar-plan-redteam`、`/dar-ripple`、`/dar-review` 变为可用,并且 `git commit` 高影响范围的变更时会弹出审查通知(默认为建议性通知;设置 `DAR_ENFORCE=block` 可进行硬性拦截,设置为 `off` 可静默处理)。 运行 `dar doctor --repo ` 进行验证。 ## 安装 —— 仅 CLI(不含插件) ``` git clone https://github.com/mav2287/dual-agent-review.git && cd dual-agent-review ./install.sh # symlinks `dar` onto PATH + skill/commands into ~/.claude dar setup --repo P # graphify into both agents, build P's graph, wire freshness ``` 它不会向目标 repo 的源代码写入任何内容。通过将 `examples/example.dar.config.sh` 复制到 `/.dar.config.sh` 来针对特定 repo 进行调整。 ## 使用 ``` # 仅 Triage — survey 还是跳过?(deterministic, ~1s, no LLM) dar probe --repo P --diff-base main # Gate 1:在 planning 前 survey blast radius dar scope --repo P --task "make unpublish flip isPublished on chapters" --diff-base main # Gate 2:在编写代码前对编写好的 plan 进行 red-team dar plan-redteam --repo P --plan plan.md --scope-map .dar-runs//scope-map.json # Gate 4:post-diff ripple check dar ripple --repo P --diff-base main --scope-map .dar-runs//scope-map.json ``` 在 Claude Code 内部,`dual-agent-review` 技能会编排整个循环 (限制、升级、协调);`/dar-scope`、`/dar-plan-redteam`、`/dar-ripple` 是手动入口点。 ## 门控机制如何运作 `dar probe` 会读取目标 repo 的 `graphify-out/graph.json`,找到变更的文件,并进行**反向依赖遍历**以计算消费者集合—— 扇出(有多少文件依赖于该变更)以及子系统扩散程度。如果满足以下任何条件,它就会进行审查:扇出超过阈值、扩散程度超过阈值、属于**热点路径**文件(认证、迁移、计费、共享基础管道)、**过期**的图谱条目,或**未解析**的 symbol。它**仅**在有明确证据证明其可控制时才会跳过。不确定性始终会导向审查——错误的跳过是一个无限制的 bug;而错误的审查只是有限的几分钟时间。 ## 布局 ``` .claude-plugin/ plugin.json + marketplace.json (Claude Code plugin manifest) hooks/hooks.json SessionStart bootstrap + PreToolUse git-commit gate bin/dar CLI entrypoint (auto-added to PATH by the plugin) lib/blast-radius.mjs blast-radius probe (reads graph.json) lib/codex.sh the one Codex invocation choke point (read-only, wedge-guarded) scripts/ bootstrap, precommit-gate, and gate scripts (scope/plan-redteam/ripple), setup, doctor schemas/ structured-output JSON Schemas (scope, plan-redteam, review) prompts/ adversarial role prompts (skepticism-first, no style nits) skills/dual-agent-review/SKILL.md orchestration skill (the loop, caps, escalation) commands/ Claude Code slash commands config/defaults.sh thresholds + hot-path patterns (override per repo) examples/ per-repo config overrides docs/ the playbook + calibration guide ``` 有关完整的设计、背后的证据以及校准协议,请参阅 `docs/dual-agent-workflow.md`。
标签:AI代理, Claude插件, Cutter, MITM代理, SOC Prime, 代码审查, 开发工具, 错误基检测, 静态代码分析