robertoecf/adversarial-review

GitHub: robertoecf/adversarial-review

一个跨 AI 主机的对抗性审查插件,通过让不同模型独立审查同一工件并交叉验证发现,弥补单一模型审查的盲区。

Stars: 3 | Forks: 0

# 对抗性审查 用于编码工作流的跨主机对抗性审查。使用同一源码即可在 **Claude Code 和 Codex** 中运行 —— 它会检测你当前运行在哪个 agent 宿主中,并将繁重的审查任务路由到另一个 agent。 ## 原理 两个模型从不同角度检查同一个工件,比单独使用任何一个都能发现更多问题。它们各自具有不同的训练偏差、盲点和推理模式。两者之间的分歧能够揭示出最高价值的发现 —— 那些单一审查者会遗漏的问题。 此插件会自动执行该原则: - 运行在 **Claude Code** 中 → 外部审查者是 **Codex**(通过 ChatGPT 订阅认证使用 `codex exec` 和 `gpt-5.4 xhigh`) - 运行在 **Codex** 中 → 外部审查者是通过 `claude -p` 调用的 **Claude (Opus, xhigh)** - 两者都不可用 → 降级到 Gemini(3.1-pro → 3.1-flash-lite → 2.5-pro → 2.5-flash 级联) - 全部不可用 → 带有明确横幅提示的 **降级模式**:宿主自我审查,但会告知用户跨主机审查原则已被绕过 ## 工作原理 ``` SKILL.md (same file in both hosts) │ ├─ host runs lib/call-external.sh │ │ │ ├─ lib/detect-host.sh (override → env → PPID walk) │ ├─ partner = NOT host │ ├─ ADVERSARIAL_REVIEW_DEPTH = 1 (anti-recursion guard) │ ├─ try partner (codex exec OR claude -p) │ ├─ on fail → gemini cascade │ └─ on fail → degraded mode (exit 2) │ ├─ host runs its own independent analysis (no peeking at partner output) ├─ cross-validate: tag findings [cross-validated] / [external-only] / [host-only] └─ return unified output (P0–P3 severity, evidence, recommendation, partner-attribution) ``` 没有 haiku courier subagent(已在 0.5.0 中移除 —— 增加了复杂性却没有增加价值)。 主 session 直接负责调度和汇总。 ## 技能 | 技能 | 功能 | |---------------------------------------------------|-----------------------------------------------------------| | `/adversarial-review:adversarial-plan-review` | 实现前的计划审查。返回修订后的计划。 | | `/adversarial-review:coding-adversarial-review` | 对代码/diff/config进行红队审查。返回评审意见和补丁。 | | `/adversarial-review:prompt-optimize` | 提示词工程分析(单宿主,无外部调用)。 | | `/adversarial-review:review-all` | 对输入进行分类,并路由到上述相应的技能中。 | 在 Codex 中,运行安装脚本后,相同的技能也可通过 `$`(Codex 提示符前缀约定)使用。 ## 安装 ### Claude Code ``` # 添加 marketplace 并安装插件 claude plugin marketplace add ~/Documents/Repos/coding-plugins/adversarial-review claude plugin install adversarial-review@adversarial-review # 在当前会话中重新加载 /reload-plugins ``` ### Codex (额外步骤) ``` # 将每个 skills// Symlink 到 ~/.codex/skills/ bash ~/Documents/Repos/coding-plugins/adversarial-review/adapters/codex-skill/install.sh ``` 验证两者: ``` claude plugin list # should show adversarial-review enabled ls -la ~/.codex/skills/ # should show 4 symlinks back to this repo ``` ### 前置条件 必须至少认证一个外部伙伴 CLI 才能使跨主机审查生效(否则你将进入降级模式): ``` # 当 host=claude,partner=codex 时: codex login # 当 host=codex,partner=claude 时: claude # interactive once to register OAuth, then `claude -p` works headless # 可选 fallback: gemini auth login ``` 对于 ChatGPT 账户的 Codex 用户,还需要将以下内容添加到 `~/.codex/config.toml` 中: ``` forced_login_method = "chatgpt" ``` (如果没有此配置,即使 TUI 正常工作,`codex exec` 也会返回 404 "Model not found"。有关此陷阱的详细信息,请参阅 `references/codex-integration.md`。) ## 验证 ``` # 在 Claude Code 中检测 bash ~/Documents/Repos/coding-plugins/adversarial-review/lib/detect-host.sh # → claude # 在 Codex 内部检测 codex exec --sandbox read-only --skip-git-repo-check \ "bash $HOME/Documents/Repos/coding-plugins/adversarial-review/lib/detect-host.sh" # → codex # Override ADVERSARIAL_REVIEW_HOST=codex bash lib/detect-host.sh # → codex # Degraded mode(非破坏性冒烟测试) echo "test" | ADVERSARIAL_REVIEW_FORCE_DEGRADED=1 \ bash lib/call-external.sh # → exit 2,stdout 以 "⚠️ DEGRADED MODE" 开头 # Anti-recursion echo "test" | ADVERSARIAL_REVIEW_DEPTH=1 \ bash lib/call-external.sh # → exit 1,stderr "recursion detected" ``` ## 使用 ``` # 在 Claude Code 中 /adversarial-review:adversarial-plan-review # paste plan or point to file /adversarial-review:coding-adversarial-review # paste code, point to file, or "review uncommitted" /adversarial-review:prompt-optimize # paste a system prompt or skill definition /adversarial-review:review-all # paste anything — auto-routes # 在 Codex 中(运行 adapters/codex-skill/install.sh 之后) $adversarial-plan-review please review the plan I'm about to implement: ... $coding-adversarial-review review my changes: ... ``` ## 架构图 [![架构](https://excalidraw.com/og/5S7Pzstx9npv10zCbtwkV)](https://excalidraw.com/#json=5S7Pzstx9npv10zCbtwkV,AJzXgdXVwoc3ojldcMgGZA) ## 另请参阅 - `references/host-detection.md` — override → env → PPID 遍历优先级 - `references/codex-integration.md` — Codex CLI 细节 + `forced_login_method` 陷阱 - `references/claude-integration.md` — `claude -p --model opus --effort xhigh` - `references/fallback-chain.md` — 完整的级联和降级路径 - `AGENTS.md` — Agent 端规则(严重性、诚实度、反递归契约) - `CLAUDE.md` — Claude Code 开发工作流 ## 许可证 MIT
标签:AI代理, AI代码审查, AI辅助编程, CISA项目, Claude Code, Codex, DevSecOps, LLM, Shell脚本, Unmanaged PE, 上游代理, 多模型级联, 大模型, 对抗性审查, 应用安全, 提示词工程, 智能编排, 策略决策点, 计划验证, 跨模型协同