feat(examples): add sandboxed code review agent - #243
Open
Wsp030914 wants to merge 4 commits into
Open
Conversation
Fixes trpc-group#92 RELEASE NOTES: Added a sandboxed code review agent example.
Avoid Docker initialization during dry-run and clean staged skill links safely across POSIX and Windows runtimes.
Contributor
AI Code Review发现的问题🚨 Critical未发现 Critical 问题。
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #243 +/- ##
==========================================
Coverage ? 87.93985%
==========================================
Files ? 482
Lines ? 45157
Branches ? 0
==========================================
Hits ? 39711
Misses ? 5446
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Author
|
@codex review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这次做了什么
这个 PR 新增一个基于 Skill 的代码审查 Agent 示例,支持统一 diff、文件列表、Git 工作区和内置 fixture 输入,并生成可查询的 JSON / Markdown 报告和 SQLite 审计记录。
示例包含确定性规则扫描、finding 去重、secret 脱敏、policy-gated sandbox 执行、fake-model、dry-run、8 个验收 fixture,以及覆盖输入解析、策略、沙箱、持久化和报告的测试。
Fixes #92
整体流程
flowchart LR A[Diff / File List / Git / Fixture 输入] --> B[输入解析与归一化] B --> C[Skill 规则扫描] C --> D[Finding 去重 / 分组 / 脱敏] D --> E[Policy Filter 审计执行计划] E --> F{Decision} F -->|allow| G[Container Sandbox 执行] F -->|deny / review| H[跳过执行并记录原因] G --> I[SQLite 审计持久化] H --> I I --> J[JSON / Markdown 报告]为什么这样设计
这个示例的目标不是只演示一次模型 review,而是把代码审查拆成可以测试和审计的步骤:
输入与执行模式
支持四类输入:
默认 runtime 是 Container,Docker
network_mode=none,只 staged 固定 Skill 文件和归一化后的 review 输入。Local runtime 仅作为开发 fallback,必须显式设置TRPC_CODE_REVIEW_ALLOW_UNSAFE_LOCAL=1才能使用。fake-model 和 dry-run 模式都不需要模型 API Key,适合本地测试和 CI 验收。真实模型路径复用同一套 Skill、Filter、sandbox、storage 和 report 契约,模型凭据不会进入 sandbox 环境。
持久化与报告
SQLite 保存 task、Filter decision、sandbox run、finding 和 report 记录。
show命令可以按 task id 查询一次审查的持久化结果。报告包含:
验证范围
测试覆盖:
建议重点 Review
希望维护者重点关注:
Release Notes
新增一个带 policy-gated sandbox、SQLite 审计和结构化报告的 Skills-based 代码审查 Agent 示例。