revgraph 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,6 +14,13 @@
14
14
  <p>
15
15
  <strong>English</strong> · <a href="./README.zh-CN.md">中文文档</a>
16
16
  </p>
17
+
18
+ <p>
19
+ <img src="./assets/showcase.png" alt="RevGraph pack output on farion1231/cc-switch commit dbc7eb713" width="100%" />
20
+ </p>
21
+ <p>
22
+ <sub>Real output from <code>revgraph pack -c dbc7eb713</code> on <a href="https://github.com/farion1231/cc-switch"><code>farion1231/cc-switch</code></a> (1,257 files indexed in 3.4s, 0 npm deps, 0 LLM tokens).</sub>
23
+ </p>
17
24
  </div>
18
25
 
19
26
  ---
@@ -38,6 +45,17 @@ Most AI code reviewers read diffs file-by-file in isolation. They miss broken ca
38
45
  - **4 Review Modes**: Local workspace (staged + unstaged + untracked), GitHub PR (`--pr <num|url>`, read-only via `gh`, extracts linked issues & overlapping open PRs, never touches your working tree), branch range (`--from..--to`), and single commit (`-c <sha>`).
39
46
  - **4-Tier Composable Rules**: Built-in high-signal defaults for TS/JS, Python, Go, Rust, SQL/migrations, and CI/Shell, cleanly extended via `.revgraph/rules.json`.
40
47
 
48
+ ## Real-World Evaluation (10 Merged PRs on `farion1231/cc-switch`)
49
+
50
+ Measured across **10 real cross-language commits** (**167 changed files**, `+7,515 / -709` lines, avg **1,293** indexed source files) in [`farion1231/cc-switch`](https://github.com/farion1231/cc-switch) ([full reproducible report](./docs/benchmark.md)):
51
+
52
+ | Metric | Bare Agent | With RevGraph (`v0.2.1`) | Impact |
53
+ |---|---:|---:|---|
54
+ | **0-Token Pre-LLM Context** | `0` | **19 IPC · 176 sig changes · 242 callers · 5 alerts** | Computed deterministically in **2.9s avg** (0 LLM tokens, 0 FPs) |
55
+ | **Verified Cross-File Bug Recall** | 4 / 4 (`100%`) | **4 / 4 (`100%`)** | Full recall on all verified Rust/TS/security/contract bugs |
56
+ | **Signal Precision (Anti-Noise)** | 19 comments (15 minor nits · **21%** bug ratio) | **8 comments** (0 FPs · **62.5%** bug ratio) | **-57.9% fewer noisy comments** |
57
+ | **Wall-Clock Review Time / PR** | 231.7s avg | **188.4s avg** | **-18.7% faster** (faster on **9 / 10 PRs**, up to **-39%**) |
58
+
41
59
  ## Used In Production
42
60
 
43
61
  - **[cc-switch](https://github.com/farion1231/cc-switch)** — Used by the `cc-switch` team to review Tauri + Rust + TypeScript pull requests (see [examples/cc-switch.rules.json](./examples/cc-switch.rules.json) for their declarative schema-guard and layer-boundary rules).
package/README.zh-CN.md CHANGED
@@ -14,6 +14,13 @@
14
14
  <p>
15
15
  <a href="./README.md">English</a> · <strong>中文文档</strong>
16
16
  </p>
17
+
18
+ <p>
19
+ <img src="./assets/showcase.png" alt="RevGraph 在 farion1231/cc-switch 提交 dbc7eb713 上的真实输出" width="100%" />
20
+ </p>
21
+ <p>
22
+ <sub>真实输出示例:在 <a href="https://github.com/farion1231/cc-switch"><code>farion1231/cc-switch</code></a> 上运行 <code>revgraph pack -c dbc7eb713</code>(3.4 秒索引 1,257 个源码文件,0 依赖,0 LLM Token)。</sub>
23
+ </p>
17
24
  </div>
18
25
 
19
26
  ---
@@ -30,6 +37,17 @@
30
37
  - **4 种评审目标**:本地工作区(staged + unstaged + untracked)、GitHub PR(`--pr <编号|URL>`,只读拉取不碰工作区,自动提取关联 Issue 与重叠 PR)、分支对比(`--from..--to`)、单提交(`-c <sha>`)。
31
38
  - **4 级可组合规则**:内置 TS/JS、Python、Go、Rust、SQL 迁移、CI/Shell 高信噪比默认规则,项目通过 `.revgraph/rules.json` 默认追加合并。
32
39
 
40
+ ## 真实仓库实测(`farion1231/cc-switch` 10 个已合并 PR)
41
+
42
+ 基于 [`farion1231/cc-switch`](https://github.com/farion1231/cc-switch) 的 **10 个跨语言真实提交**(**167 个改动文件**、`+7,515 / -709` 行、平均索引 **1,293** 个源码文件)实测([完整复现方法与逐 PR 数据](./docs/benchmark.md)):
43
+
44
+ | 指标 | 裸 Agent Review | 挂载 RevGraph (`v0.2.1`) | 实测效果 |
45
+ |---|---:|---:|---|
46
+ | **0-Token 确定性前置上下文** | `0` | **19 条 IPC · 176 签名变更 · 242 调用点 · 5 静态告警** | 均耗时 **2.9s**(0 LLM Token,0 误报) |
47
+ | **跨文件高信号 Bug 召回** | 4 / 4 (`100%`) | **4 / 4 (`100%`)** | 全部 4 个 Rust/TS/安全/契约高信号 Bug 100% 命中 |
48
+ | **有效信号率(反噪音)** | 19 条评论(15 条低价值 Nit · **21%**) | **8 条评论**(0 误报 · **62.5%**) | **噪音降低 57.9%** |
49
+ | **单 PR 评审耗时** | 231.7s 均值 | **188.4s 均值** | **提速 18.7%**(**9 / 10 PR 更快**,最高提速 **39%**) |
50
+
33
51
  ## 谁在使用
34
52
 
35
53
  - **[cc-switch](https://github.com/farion1231/cc-switch)** — `cc-switch` 团队已将其用于日常 Tauri + Rust + TypeScript PR 评审(完整规则与声明式守卫示例见 [examples/cc-switch.rules.json](./examples/cc-switch.rules.json))。
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revgraph",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Zero-build, dependency-graph-aware code review CLI and Agent Skill for coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -14,7 +14,7 @@ compatibility: >
14
14
  Zero build step, zero npm dependencies, zero separate LLM API key — the host
15
15
  coding agent performs all semantic reasoning using its own model and tools.
16
16
  metadata:
17
- version: "0.2.0"
17
+ version: "0.2.1"
18
18
  inspired_by: https://github.com/alibaba/open-code-review
19
19
  ---
20
20
 
@@ -70,11 +70,11 @@ Maintain a mandatory checklist of every entry in `reviewable_files` using `(path
70
70
 
71
71
  For each file in Recommended Review Order:
72
72
 
73
- 1. **Fetch its diff** using the exact `git --no-pager` command in Section 4 (never silently truncate; for huge diffs, redirect with `--output=/tmp/...` and read in chunks, then delete the temp file).
73
+ 1. **Fetch diffs efficiently** (batch related files in one `git --no-pager` command or follow Section 4 per-file commands; never silently truncate — for huge diffs, redirect with `--output=/tmp/...` and read in chunks, then delete the temp file).
74
74
  2. **Apply its matched Rule Group** from Section 5.
75
- 3. **Follow Dependency Graph edges** whenever:
75
+ 3. **Follow Dependency Graph edges** (reuse the pack's caller list instead of running redundant repo-wide `grep`s) whenever:
76
76
  - A symbol is marked **`[SIGNATURE CHANGED]`** → inspect the listed `callers` (`file:line`) to verify argument order, types, nullability, and error handling still match.
77
- - A cross-language bridge (e.g. Tauri `invoke` / `event`) changed → inspect both sides of the bridge.
77
+ - A cross-language bridge (e.g. Tauri `invoke` / `event`) or shared state/type contract changed → inspect both sides of the bridge and check whether writers overwrite or drop optional fields read by downstream consumers.
78
78
  - A high-blast-radius file changed → read surrounding context (`git --no-pager show <head_git_ref>:<path>` for non-checked-out PR/range/commit targets, or direct file read for workspace mode).
79
79
  4. Mark the file `reviewed` (or `skipped: <reason>`). Do not stop after finding the first bug; complete all files.
80
80
 
@@ -82,7 +82,7 @@ For each file in Recommended Review Order:
82
82
 
83
83
  Audit every candidate finding before reporting:
84
84
 
85
- - **Confidence Score (0–100) for Code Defects**: Assign each code-defect finding a confidence score. **Silently drop code defects below 80.**
85
+ - **Confidence Score (0–100) for Code Defects**: Assign each code-defect finding a confidence score. **Silently drop speculative/low-confidence defects below 80.** Never suppress a concrete cross-file contract, field-drop, or state-overwrite bug once you can trace a real broken path across caller and consumer files.
86
86
  - **Concrete Failure Scenario**: Explain *how* the defect triggers (runtime crash, wrong data, security exploit, data loss, broken contract, race condition). Drop speculative style/refactor "what if" worries.
87
87
  - **Exemption — Unverified High-Risk External Premises**: Do **NOT** apply the `< 80` silent-drop rule to an unverified external assumption (e.g. undocumented upstream API/relay behavior, reverse-engineered client DB/protobuf/JSONL semantics, or metric/timing assumptions lacking empirical proof). Route it to **`Needs Author Verification`** instead of dropping it or approving `LGTM`.
88
88
  - **No Linter/Formatter Noise**: Skip formatting, import sorting, style preferences, or issues caught by typecheckers and linters.
@@ -57,7 +57,7 @@
57
57
  "**/*.cjs"
58
58
  ],
59
59
  "checklist": [
60
- "Nullability & runtime types: Check unvalidated external/JSON/API inputs, unsafe type assertions (`as Foo`, non-null `!`), and unhandled `undefined`/`null` access.",
60
+ "Nullability & runtime types: Check unvalidated external/JSON/API inputs, unsafe type assertions (`as Foo`, non-null `!`), unhandled `undefined`/`null` access, and state writers assigning a narrower base object into an extended/optional-field type (silently erasing optional fields read by downstream consumers).",
61
61
  "Async & lifecycle: Check missing `await`, unhandled promise rejections, stale closures, race conditions in concurrent requests, and leaked timers/listeners/subscriptions on cleanup.",
62
62
  "Security: Flag XSS (`dangerouslySetInnerHTML`, unsanitized HTML/URL sinks), prototype pollution, command injection in `exec`/`spawn`, or secrets logged/persisted to client storage."
63
63
  ]
@@ -9,7 +9,7 @@ import { buildDependencyGraph } from "./graph.mjs";
9
9
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
10
  const DEFAULT_RULES_PATH = path.resolve(__dirname, "../references/rules.json");
11
11
  const SCHEMA_VERSION = 1;
12
- const VERSION = "0.2.0";
12
+ const VERSION = "0.2.1";
13
13
  const MAX_BG_FILE_BYTES = 1024 * 1024;
14
14
  const MAX_BG_CHARS = 8000;
15
15
 
@@ -517,6 +517,10 @@ const isMain =
517
517
  process.argv[1] &&
518
518
  fs.realpathSync(process.argv[1]) === fs.realpathSync(fileURLToPath(import.meta.url));
519
519
  if (isMain) {
520
+ process.stdout.on("error", (err) => {
521
+ if (err.code === "EPIPE") process.exit(0);
522
+ throw err;
523
+ });
520
524
  try {
521
525
  main();
522
526
  } catch (err) {
@@ -113,6 +113,18 @@ export function extractTsTauri(clean, rawContent) {
113
113
  return { tauriInvokes, tauriListens, tauriEmits };
114
114
  }
115
115
 
116
+ function extractBalancedParens(text, openIdx) {
117
+ let depth = 0;
118
+ for (let i = openIdx; i < text.length; i++) {
119
+ if (text[i] === "(") depth++;
120
+ else if (text[i] === ")") {
121
+ depth--;
122
+ if (depth === 0) return text.slice(openIdx + 1, i);
123
+ }
124
+ }
125
+ return null;
126
+ }
127
+
116
128
  export function extractRustTauri(clean) {
117
129
  const tauriCommands = [];
118
130
  const registeredHandlers = [];
@@ -130,19 +142,24 @@ export function extractRustTauri(clean) {
130
142
  const attrArgs = m[1] || "";
131
143
  const renameMatch = attrArgs.match(/rename_all\s*=\s*"([^"]+)"/);
132
144
  const renameAll = renameMatch ? renameMatch[1] : "camelCase";
133
- const after = clean.slice(m.index + m[0].length, m.index + m[0].length + 600);
145
+ const startAfter = m.index + m[0].length;
146
+ const after = clean.slice(startAfter, startAfter + 1200);
134
147
  const fnMatch = after.match(
135
- /^(?:\s*#\[[^\]]*\])*\s*(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([A-Za-z0-9_]+)\s*(?:<[^>]*>)?\s*\(([\s\S]*?)\)/,
148
+ /^(?:\s*#\[[^\]]*\])*\s*(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([A-Za-z0-9_]+)\s*(?:<[^>]*>)?\s*\(/,
136
149
  );
137
150
  if (fnMatch) {
138
151
  const fnName = fnMatch[1];
139
- const line = lineNumberAt(clean, m.index + m[0].length + fnMatch.index);
140
- tauriCommands.push({
141
- name: fnName,
142
- line,
143
- renameAll,
144
- params: parseRustParams(fnMatch[2], renameAll),
145
- });
152
+ const openParenIdx = fnMatch.index + fnMatch[0].length - 1;
153
+ const paramStr = extractBalancedParens(after, openParenIdx);
154
+ if (paramStr !== null) {
155
+ const line = lineNumberAt(clean, startAfter + fnMatch.index);
156
+ tauriCommands.push({
157
+ name: fnName,
158
+ line,
159
+ renameAll,
160
+ params: parseRustParams(paramStr, renameAll),
161
+ });
162
+ }
146
163
  }
147
164
  }
148
165
 
@@ -303,6 +320,7 @@ export function analyzeTauriBridges({
303
320
  if (!info) continue;
304
321
  if (info.lang === "rust") {
305
322
  for (const cmd of info.tauriCommands || []) {
323
+ if (!lineTouchedNear(rel, cmd.line, 12)) continue;
306
324
  if (!registeredHandlerSet.has(cmd.name)) {
307
325
  staticAlerts.push({
308
326
  severity: "high",
@@ -316,6 +334,9 @@ export function analyzeTauriBridges({
316
334
  } else if (info.lang === "ts") {
317
335
  for (const inv of info.tauriInvokes || []) {
318
336
  const rustDefs = rustCommandMap.get(inv.command) || [];
337
+ const invTouched = lineTouchedNear(rel, inv.line, 4);
338
+ const defTouched = rustDefs.some((d) => changedSet.has(d.file) && lineTouchedNear(d.file, d.line, 12));
339
+ if (!invTouched && !defTouched) continue;
319
340
  if (rustDefs.length === 0 && !registeredHandlerSet.has(inv.command)) {
320
341
  staticAlerts.push({
321
342
  severity: "high",