revgraph 0.0.0-stage → 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 revgraph contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,137 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
+ <img src="./assets/logo.svg" alt="RevGraph Logo" width="112" height="112" />
3
+ <h1>RevGraph</h1>
4
+ <p><strong>Zero-build, dependency-graph-aware code review CLI &amp; Agent Skill for coding agents.</strong></p>
2
5
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
6
+ <p>
7
+ <a href="https://www.npmjs.com/package/revgraph"><img src="https://img.shields.io/npm/v/revgraph?color=cb3837&label=npm" alt="npm version" /></a>
8
+ <a href="https://github.com/allenxu09/RevGraph/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License" /></a>
9
+ <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&logoColor=white" alt="Node.js >= 20" /></a>
10
+ <a href="https://github.com/allenxu09/RevGraph"><img src="https://img.shields.io/badge/dependencies-0-brightgreen" alt="Zero Dependencies" /></a>
11
+ <a href="https://github.com/allenxu09/RevGraph/stargazers"><img src="https://img.shields.io/github/stars/allenxu09/RevGraph?style=flat" alt="GitHub Stars" /></a>
12
+ </p>
13
+
14
+ <p>
15
+ <strong>English</strong> · <a href="./README.zh-CN.md">中文文档</a>
16
+ </p>
17
+ </div>
18
+
19
+ ---
20
+
21
+ Inspired by [alibaba/open-code-review](https://github.com/alibaba/open-code-review) Delegation Mode, `revgraph` gives your coding agent (Claude Code, Codex, Cursor, Antigravity, etc.) deterministic **dependency & blast-radius intelligence** before it reads a single line of diff — with **zero npm dependencies, zero build step, and zero extra LLM API key**.
22
+
23
+ ## Why RevGraph?
24
+
25
+ Most AI code reviewers read diffs file-by-file in isolation. They miss broken callers, signature drift, cross-module impact, and review consumers before contracts.
26
+
27
+ `revgraph` splits the work cleanly:
28
+ - **Deterministic CLI (Node.js ≥ 20, zero dependencies)** computes Git diff scope, multi-language dependency graphs, 1–2 hop changed-symbol callers, pre-LLM static alerts, topological bottom-up review order, and grouped review rules.
29
+ - **Your host coding agent** performs semantic review using its existing model subscription and codebase tools.
30
+
31
+ ### Key Features
32
+
33
+ - **Multi-language Dependency & Impact Graph**: Automatic `git ls-files` discovery (respects `.gitignore` and monorepos) with lightweight zero-dependency parsers for **TypeScript / JavaScript**, **Python**, **Go**, and **Rust** — plus **auto-detected Tauri IPC/event bridges** when `src-tauri/` is present.
34
+ - **Changed-Symbol & Caller Tracking**: Flags `[SIGNATURE CHANGED]` symbols and lists 1–2 hop cross-file call sites (`file:line`).
35
+ - **Automatic Bottom-Up Review Order**: Orders contracts/schemas and leaf dependencies before consumers, with tests and docs last.
36
+ - **Deterministic Pre-LLM Alerts**: Catches `BROKEN_IMPORT` (deleted files still imported), `POTENTIAL_OVERLAPPING_PR` (duplicate open PR/Draft detection), `LARGE_PR` scope warnings, declarative project guards via `rules.json` (`diff_regex` / `import_regex`), and Tauri IPC mismatches before spending a single LLM token.
37
+ - **Pre-Review Governance Triage & Premise Gate**: Optional `.revgraph/policy.md` (`--policy`) enables fast-exit 4-way verdicts (`LGTM` / `Request Changes` / `Hold` / `Redirect`) that decouple code quality from merge readiness, plus `Needs Author Verification` so unverified external assumptions are never silently dropped into `LGTM`.
38
+ - **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
+ - **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
+
41
+ ## Used In Production
42
+
43
+ - **[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).
44
+
45
+ ## Quick Start
46
+
47
+ ### Install as an Agent Skill (Recommended)
48
+
49
+ ```bash
50
+ npx skills add allenxu09/RevGraph
51
+ ```
52
+
53
+ The `skills/revgraph/` folder is completely self-contained (`SKILL.md` + `scripts/` + `references/rules.json`), so your agent can run it immediately without installing a global binary.
54
+
55
+ Then just ask your agent:
56
+ - *"Review my uncommitted changes with revgraph"*
57
+ - *"Review PR #123 using revgraph"*
58
+ - *"Review branch diff from main to HEAD"*
59
+
60
+ ### Or Use as a Standalone CLI
61
+
62
+ ```bash
63
+ npm install -g revgraph
64
+ # or run without global install:
65
+ npx revgraph pack
66
+ ```
67
+
68
+ ### CLI Commands
69
+
70
+ ```bash
71
+ # Full context pack: preview + dependency graph + static alerts + grouped rules
72
+ revgraph pack
73
+ revgraph pack --pr 123
74
+ revgraph pack --from main --to HEAD
75
+ revgraph pack -c <sha>
76
+ revgraph pack -b "Refactored auth token refresh" --format json --output /tmp/pack.json
77
+
78
+ # Individual stages
79
+ revgraph preview --from main --to HEAD
80
+ revgraph graph --pr 123
81
+ revgraph rules src/auth.ts src/api.ts
82
+ ```
83
+
84
+ ## Customizing Rules
85
+
86
+ `revgraph` merges rules across 4 tiers (highest priority first):
87
+ 1. `--rule <path>`
88
+ 2. `<repo>/.revgraph/rules.json`
89
+ 3. `~/.revgraph/rules.json`
90
+ 4. Built-in `references/rules.json`
91
+
92
+ By default, repo/user rules **extend** built-in defaults. Set `"extends": false` to disable lower-priority layers, or `"override": true` on an individual rule to replace built-in rules for matched files.
93
+
94
+ Example `.revgraph/rules.json`:
95
+
96
+ ```json
97
+ {
98
+ "version": 1,
99
+ "default_excludes": ["generated/**"],
100
+ "static_alerts": [
101
+ {
102
+ "id": "SCHEMA_VERSION_GUARD",
103
+ "severity": "critical",
104
+ "patterns": ["src/db/**"],
105
+ "diff_regex": "\\bSCHEMA_VERSION\\b",
106
+ "message": "Schema version changed — verify forward-only migration safety."
107
+ }
108
+ ],
109
+ "rules": [
110
+ {
111
+ "id": "payments",
112
+ "name": "Payment & Billing",
113
+ "patterns": ["src/billing/**"],
114
+ "checklist": [
115
+ "Verify idempotency keys on all external payment API calls.",
116
+ "Ensure amounts use integer minor units, never floating-point arithmetic."
117
+ ]
118
+ }
119
+ ]
120
+ }
121
+ ```
122
+
123
+ See [examples/cc-switch.rules.json](./examples/cc-switch.rules.json) for a full real-world Tauri + Rust + TypeScript project configuration.
124
+
125
+ ## Requirements & Testing
126
+
127
+ - Node.js `>= 20`
128
+ - Git
129
+ - Optional: GitHub CLI (`gh`) for `--pr <num|url>` mode
130
+
131
+ ```bash
132
+ npm test
133
+ ```
134
+
135
+ ## License
136
+
137
+ MIT
@@ -0,0 +1,85 @@
1
+ <div align="center">
2
+ <img src="./assets/logo.svg" alt="RevGraph Logo" width="112" height="112" />
3
+ <h1>RevGraph</h1>
4
+ <p><strong>零构建、带依赖影响图的轻量代码评审 CLI 与 Agent Skill。</strong></p>
5
+
6
+ <p>
7
+ <a href="https://www.npmjs.com/package/revgraph"><img src="https://img.shields.io/npm/v/revgraph?color=cb3837&label=npm" alt="npm version" /></a>
8
+ <a href="https://github.com/allenxu09/RevGraph/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License" /></a>
9
+ <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D20-339933?logo=node.js&logoColor=white" alt="Node.js >= 20" /></a>
10
+ <a href="https://github.com/allenxu09/RevGraph"><img src="https://img.shields.io/badge/dependencies-0-brightgreen" alt="Zero Dependencies" /></a>
11
+ <a href="https://github.com/allenxu09/RevGraph/stargazers"><img src="https://img.shields.io/github/stars/allenxu09/RevGraph?style=flat" alt="GitHub Stars" /></a>
12
+ </p>
13
+
14
+ <p>
15
+ <a href="./README.md">English</a> · <strong>中文文档</strong>
16
+ </p>
17
+ </div>
18
+
19
+ ---
20
+
21
+ 受 [alibaba/open-code-review](https://github.com/alibaba/open-code-review) Delegation Mode 启发,`revgraph` 在宿主 Coding Agent(Claude Code、Codex、Cursor、Antigravity 等)开始读 Diff 之前,先用确定性脚本生成**模块依赖图、变更符号调用链、静态告警、自底向上评审顺序与分组规则**——**零第三方依赖、零编译步骤、无需额外配置 LLM API Key**。
22
+
23
+ ## 核心能力
24
+
25
+ - **四语言依赖图 + 自动 Monorepo 发现**:基于 `git ls-files` 自动遵守 `.gitignore`,内置零依赖轻量解析器覆盖 **TypeScript / JavaScript、Python、Go、Rust**;检测到 `src-tauri/` 时自动启用 **Tauri IPC / Event 跨语言桥接检测**(非 Tauri 仓库零开销零噪音)。
26
+ - **变更符号与 1–2 跳调用方追踪**:自动标记 `[SIGNATURE CHANGED]`,列出跨文件调用点(`file:line`)与爆炸半径(Blast Radius)。
27
+ - **自动自底向上 Review 顺序**:按依赖图拓扑顺序先审契约/底层被依赖模块,再审消费方,测试与文档垫底。
28
+ - **Pre-LLM 确定性静态告警**:内置删文件断链检测(`BROKEN_IMPORT`)、开放中重复 PR 探测(`POTENTIAL_OVERLAPPING_PR`)、大 PR 提示(`LARGE_PR`)、`rules.json` 声明式守卫(`diff_regex` / `import_regex`)及可选 Tauri IPC 校验。
29
+ - **Pre-Review 治理分诊与前提校验门控**:支持可选 `.revgraph/policy.md`(`--policy`),通过 4 路 Verdict(`LGTM` / `Request Changes` / `Hold` / `Redirect`)与 Fast-Exit 将代码质量与合入策略解耦;引入 `Needs Author Verification`,避免未验证的高风险外部假设被 `<80` 过滤静默吞掉。
30
+ - **4 种评审目标**:本地工作区(staged + unstaged + untracked)、GitHub PR(`--pr <编号|URL>`,只读拉取不碰工作区,自动提取关联 Issue 与重叠 PR)、分支对比(`--from..--to`)、单提交(`-c <sha>`)。
31
+ - **4 级可组合规则**:内置 TS/JS、Python、Go、Rust、SQL 迁移、CI/Shell 高信噪比默认规则,项目通过 `.revgraph/rules.json` 默认追加合并。
32
+
33
+ ## 谁在使用
34
+
35
+ - **[cc-switch](https://github.com/farion1231/cc-switch)** — `cc-switch` 团队已将其用于日常 Tauri + Rust + TypeScript PR 评审(完整规则与声明式守卫示例见 [examples/cc-switch.rules.json](./examples/cc-switch.rules.json))。
36
+
37
+ ## 快速开始
38
+
39
+ ### 作为 Agent Skill 安装(推荐)
40
+
41
+ ```bash
42
+ npx skills add allenxu09/RevGraph
43
+ ```
44
+
45
+ `skills/revgraph/` 完全自包含,安装后无需再单独装全局 CLI,直接对你的 Agent 说:
46
+ - *“用 revgraph review 我当前的本地改动”*
47
+ - *“用 revgraph 评审 PR #123”*
48
+
49
+ ### 作为独立 CLI 使用
50
+
51
+ ```bash
52
+ npm install -g revgraph
53
+ # 或免安装直接运行:
54
+ npx revgraph pack
55
+
56
+ # 一键生成完整评审上下文包(Preview + 依赖图 + 静态告警 + 分组规则)
57
+ revgraph pack
58
+ revgraph pack --pr 123
59
+ revgraph pack --from main --to HEAD
60
+ revgraph pack -c <sha>
61
+ revgraph pack -b "重构鉴权刷新逻辑" --format json --output /tmp/pack.json
62
+
63
+ # 单阶段子命令
64
+ revgraph preview
65
+ revgraph graph
66
+ revgraph rules
67
+ ```
68
+
69
+ ## 自定义规则
70
+
71
+ 规则按以下 4 级合并(优先级从高到低):
72
+ 1. `--rule <path>`
73
+ 2. `<repo>/.revgraph/rules.json`
74
+ 3. `~/.revgraph/rules.json`
75
+ 4. 内置 `references/rules.json`
76
+
77
+ 项目/用户配置默认**扩展合并**内置规则;设置 `"extends": false` 可关闭下层默认规则,或在单条规则上设 `"override": true` 替换内置规则。完整项目示例见 [examples/cc-switch.rules.json](./examples/cc-switch.rules.json)。
78
+
79
+ ## 运行测试
80
+
81
+ ```bash
82
+ npm test
83
+ ```
84
+
85
+ 需要 Node.js `>= 20` 与 Git(`--pr` 模式需 `gh` CLI)。协议:MIT。
@@ -0,0 +1,62 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128" role="img" aria-label="RevGraph logo">
2
+ <defs>
3
+ <linearGradient id="bg" x1="0%" y1="0%" x2="100%" y2="100%">
4
+ <stop offset="0%" stop-color="#0F172A"/>
5
+ <stop offset="100%" stop-color="#1E293B"/>
6
+ </linearGradient>
7
+ <linearGradient id="edgeBlue" x1="0%" y1="0%" x2="100%" y2="0%">
8
+ <stop offset="0%" stop-color="#38BDF8"/>
9
+ <stop offset="100%" stop-color="#818CF8"/>
10
+ </linearGradient>
11
+ <linearGradient id="edgeAmber" x1="0%" y1="0%" x2="100%" y2="100%">
12
+ <stop offset="0%" stop-color="#F59E0B"/>
13
+ <stop offset="100%" stop-color="#FB7185"/>
14
+ </linearGradient>
15
+ <linearGradient id="nodeGold" x1="0%" y1="0%" x2="100%" y2="100%">
16
+ <stop offset="0%" stop-color="#FBBF24"/>
17
+ <stop offset="100%" stop-color="#F59E0B"/>
18
+ </linearGradient>
19
+ <linearGradient id="nodeCyan" x1="0%" y1="0%" x2="100%" y2="100%">
20
+ <stop offset="0%" stop-color="#38BDF8"/>
21
+ <stop offset="100%" stop-color="#0EA5E9"/>
22
+ </linearGradient>
23
+ <linearGradient id="nodeGreen" x1="0%" y1="0%" x2="100%" y2="100%">
24
+ <stop offset="0%" stop-color="#34D399"/>
25
+ <stop offset="100%" stop-color="#10B981"/>
26
+ </linearGradient>
27
+ </defs>
28
+
29
+ <!-- Container -->
30
+ <rect x="4" y="4" width="120" height="120" rx="28" fill="url(#bg)" stroke="#334155" stroke-width="2"/>
31
+
32
+ <!-- Subtle background grid dots -->
33
+ <g fill="#334155" opacity="0.45">
34
+ <circle cx="28" cy="28" r="1.5"/>
35
+ <circle cx="64" cy="28" r="1.5"/>
36
+ <circle cx="100" cy="28" r="1.5"/>
37
+ <circle cx="28" cy="100" r="1.5"/>
38
+ <circle cx="64" cy="100" r="1.5"/>
39
+ <circle cx="100" cy="100" r="1.5"/>
40
+ </g>
41
+
42
+ <!-- Impact blast halo around changed node -->
43
+ <circle cx="88" cy="64" r="24" fill="none" stroke="#F59E0B" stroke-width="1.5" stroke-dasharray="4 4" opacity="0.5"/>
44
+ <circle cx="88" cy="64" r="17" fill="#F59E0B" opacity="0.14"/>
45
+
46
+ <!-- Dependency edges -->
47
+ <path d="M 38 38 C 56 38, 62 56, 75 60" fill="none" stroke="url(#edgeBlue)" stroke-width="4" stroke-linecap="round"/>
48
+ <path d="M 38 90 C 56 90, 62 72, 75 68" fill="none" stroke="url(#edgeAmber)" stroke-width="4" stroke-linecap="round"/>
49
+ <path d="M 34 46 L 34 82" fill="none" stroke="#475569" stroke-width="3" stroke-linecap="round" stroke-dasharray="4 4"/>
50
+
51
+ <!-- Top-left caller node (added / diff +) -->
52
+ <circle cx="34" cy="38" r="12" fill="url(#nodeGreen)" stroke="#0F172A" stroke-width="3"/>
53
+ <path d="M 30 38 H 38 M 34 34 V 42" stroke="#0F172A" stroke-width="2.4" stroke-linecap="round"/>
54
+
55
+ <!-- Bottom-left caller node -->
56
+ <circle cx="34" cy="90" r="11" fill="url(#nodeCyan)" stroke="#0F172A" stroke-width="3"/>
57
+ <circle cx="34" cy="90" r="3.5" fill="#0F172A"/>
58
+
59
+ <!-- Right focal changed contract node -->
60
+ <circle cx="88" cy="64" r="14" fill="url(#nodeGold)" stroke="#0F172A" stroke-width="3"/>
61
+ <path d="M 83 64 L 86.5 67.5 L 93.5 60.5" fill="none" stroke="#0F172A" stroke-width="2.8" stroke-linecap="round" stroke-linejoin="round"/>
62
+ </svg>
@@ -0,0 +1,77 @@
1
+ {
2
+ "version": 1,
3
+ "default_excludes": [
4
+ "src-tauri/gen/**"
5
+ ],
6
+ "static_alerts": [
7
+ {
8
+ "id": "SCHEMA_VERSION_MODIFIED",
9
+ "severity": "critical",
10
+ "patterns": [
11
+ "src-tauri/src/database/**"
12
+ ],
13
+ "diff_regex": "\\bconst\\s+SCHEMA_VERSION\\b",
14
+ "message": "Diff modifies `const SCHEMA_VERSION`. Verify maintainer authorization and forward-only migration safety."
15
+ },
16
+ {
17
+ "id": "LAYER_BOUNDARY_WARNING",
18
+ "severity": "medium",
19
+ "patterns": [
20
+ "src-tauri/src/commands/**"
21
+ ],
22
+ "import_regex": "^src-tauri/src/database/dao/",
23
+ "message": "Command file imports database DAO directly; verify whether business logic belongs in `src-tauri/src/services/`."
24
+ }
25
+ ],
26
+ "rules": [
27
+ {
28
+ "id": "database-migration",
29
+ "name": "Database & Schema Migration",
30
+ "patterns": [
31
+ "src-tauri/src/database/**",
32
+ "src-tauri/src/store.rs"
33
+ ],
34
+ "checklist": [
35
+ "Upgrade safety: Verify existing user SQLite databases migrate cleanly without data loss, missing `DEFAULT` values on `ALTER TABLE ADD COLUMN`, or broken foreign keys.",
36
+ "Backup compatibility: Ensure backup export/import handles new tables/columns and older backup files gracefully.",
37
+ "Concurrency & SQL safety: Confirm DB Mutex is never held across `.await` points and all dynamic values use parameterized bindings."
38
+ ]
39
+ },
40
+ {
41
+ "id": "tauri-ipc-backend",
42
+ "name": "Tauri Commands & IPC Layer",
43
+ "patterns": [
44
+ "src-tauri/src/commands/**",
45
+ "src-tauri/src/lib.rs"
46
+ ],
47
+ "checklist": [
48
+ "Command registration: Every new or renamed `#[tauri::command]` must be registered in `tauri::generate_handler![...]`.",
49
+ "IPC argument contract: Check `rename_all` casing (Tauri v2 defaults to camelCase) against frontend `invoke()` argument keys.",
50
+ "Thin command layer: Validate input and delegate business logic to services."
51
+ ]
52
+ },
53
+ {
54
+ "id": "live-config-writers",
55
+ "name": "Live Config Writers & Multi-Tool Sync",
56
+ "patterns": [
57
+ "src-tauri/src/*_config.rs",
58
+ "src-tauri/src/live/**",
59
+ "src-tauri/src/mcp/**"
60
+ ],
61
+ "checklist": [
62
+ "Atomic writes & unknown-key preservation: Write live config files atomically (temp file + rename) without clobbering unrelated user keys.",
63
+ "Cross-platform paths: Check Windows path separators/WSL2 paths, macOS vs Linux config directories, and test isolation."
64
+ ]
65
+ },
66
+ {
67
+ "id": "i18n-locales",
68
+ "name": "i18n Locale Consistency",
69
+ "patterns": [
70
+ "src/i18n/locales/**"
71
+ ],
72
+ "checklist": [
73
+ "Locale parity: Verify newly added or renamed keys exist across all shipped locale files and preserve `{{placeholder}}` interpolation variables."
74
+ ]
75
+ }
76
+ ]
77
+ }
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "revgraph",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Zero-build, dependency-graph-aware code review CLI and Agent Skill for coding agents",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/allenxu09/RevGraph.git"
10
+ },
11
+ "homepage": "https://github.com/allenxu09/RevGraph#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/allenxu09/RevGraph/issues"
14
+ },
15
+ "engines": {
16
+ "node": ">=20.0.0"
17
+ },
18
+ "bin": {
19
+ "revgraph": "skills/revgraph/scripts/cli.mjs"
20
+ },
21
+ "files": [
22
+ "skills/revgraph",
23
+ "examples",
24
+ "assets",
25
+ "README.md",
26
+ "README.zh-CN.md",
27
+ "LICENSE"
28
+ ],
29
+ "scripts": {
30
+ "test": "node --test test/*.test.mjs"
31
+ },
32
+ "keywords": [
33
+ "code-review",
34
+ "ai-code-review",
35
+ "agent-skill",
36
+ "dependency-graph",
37
+ "impact-analysis",
38
+ "cli",
39
+ "claude-code",
40
+ "codex",
41
+ "cursor"
42
+ ]
43
+ }
@@ -0,0 +1,153 @@
1
+ ---
2
+ name: revgraph
3
+ description: >
4
+ Zero-build, dependency-graph-aware code and PR review workflow for coding
5
+ agents (inspired by alibaba/open-code-review Delegation Mode). Use whenever
6
+ the user asks to review a GitHub PR (number or URL), branch diff, commit, or
7
+ local workspace changes. Deterministically computes file scope, multi-language
8
+ dependency graphs (TS/JS, Python, Go, Rust + auto-detected Tauri IPC), 1-2 hop
9
+ changed-symbol callers, bottom-up review order, static alerts, and grouped
10
+ rules before the host agent performs high-signal semantic review.
11
+ license: MIT
12
+ compatibility: >
13
+ Requires Node.js >= 20 and Git. Optional `gh` CLI for `--pr <num|url>` mode.
14
+ Zero build step, zero npm dependencies, zero separate LLM API key — the host
15
+ coding agent performs all semantic reasoning using its own model and tools.
16
+ metadata:
17
+ version: "0.2.0"
18
+ inspired_by: https://github.com/alibaba/open-code-review
19
+ ---
20
+
21
+ # revgraph — Dependency-Graph Code Review Workflow
22
+
23
+ A lightweight, cross-agent code review skill that separates deterministic engineering from LLM reasoning:
24
+
25
+ - **Deterministic CLI (`scripts/cli.mjs`)** handles Git diff scoping, file filtering, repository dependency graph indexing (TS/JS, Python, Go, Rust, plus auto-detected Tauri IPC), 1–2 hop changed-symbol caller lookup, pre-LLM static alerts, topological bottom-up review ordering, and grouped rule resolution.
26
+ - **Host Coding Agent (you)** performs semantic code review using the context pack, diffs, and repository read tools — no separate LLM endpoint or binary required.
27
+
28
+ ## Workflow
29
+
30
+ ### Step 1: Generate the Review Pack (1 Command)
31
+
32
+ Invoke the CLI bundled in this skill directory (`<skill-dir>/scripts/cli.mjs`), or `revgraph` directly if installed in `$PATH`:
33
+
34
+ ```bash
35
+ node <skill-dir>/scripts/cli.mjs pack [target-flags] --format markdown
36
+ ```
37
+
38
+ **Target flags by scenario:**
39
+
40
+ | User Intent | Command |
41
+ |-------------|---------|
42
+ | Review local uncommitted changes | `pack` |
43
+ | Review GitHub PR #123 or URL | `pack --pr 123` |
44
+ | Review feature branch vs main | `pack --from main --to HEAD` |
45
+ | Review a single commit | `pack -c <sha>` |
46
+ | Pass business/requirement context | Append `-b "context"` or `-B /path/to/spec.md` |
47
+ | Machine-readable JSON output | Append `--format json` |
48
+ | Large PR (avoid stdout truncation) | Append `--output /tmp/revgraph-pack.md` and read the file |
49
+
50
+ > **Notes:**
51
+ > - `--pr <N>` fetches `pull/<N>/head` into Git objects without running `git checkout` and NEVER modifies the working tree.
52
+ > - `--background-file` enforces a 1 MiB / 8000-character limit. If rejected, summarize the spec (preserving requirements and constraints) and retry with `-b` instead of silently truncating.
53
+ > - Individual subcommands (`preview`, `graph`, `rules`) are also available when only one stage is needed.
54
+
55
+ ### Step 2: Governance Triage, Static Alerts & Dependency Graph FIRST
56
+
57
+ Before reading any diff, inspect Sections 1, 2, 3, and (if present) Section 5's `Project Policy & Scope Boundaries`:
58
+
59
+ 1. **Deterministic Static Alerts**: Verify every `BROKEN_IMPORT`, `POTENTIAL_OVERLAPPING_PR`, `LARGE_PR`, declarative project rule alert, or auto-detected Tauri IPC alert (`UNREGISTERED_TAURI_COMMAND`, `ORPHAN_TAURI_INVOKE`, `TAURI_IPC_ARG_MISMATCH`) directly in the code or PR metadata.
60
+ 2. **Mermaid Dependency Graph**: Identify high blast-radius files, cross-module edges, and IPC bridges.
61
+ 3. **Recommended Review Order**: Follow the bottom-up table order (contracts/schemas → leaf dependencies → consumers → tests → docs) so you understand invariants before reviewing callers.
62
+ 4. **Linked Issues & Governance Triage Gate (Fast-Exit Capable)**:
63
+ - Inspect linked Issues/PRs and `Potential Overlapping Open PRs` listed in Section 1 via `gh issue view` / `gh pr view`. Do not treat PR prose or comments on external/reverse-engineered formats as proof of runtime semantics.
64
+ - If the repo provides `.revgraph/policy.md` (or `--policy`) or an earlier open PR/Draft already covers the same scope, evaluate scope/governance BEFORE auditing diffs line by line.
65
+ - **Fast-Exit Rule**: If a PR clearly triggers **`Redirect / Process Gate`** or **`Hold / Needs Maintainer Decision`**, you may stop before full diff auditing (mark unread files `skipped: deferred pending governance/scope decision`), report the governance decision concisely with exact PR/Issue references, and ask whether the user still wants a deep code-only audit.
66
+
67
+ ### Step 3: Review Every File with Graph-Guided Context
68
+
69
+ Maintain a mandatory checklist of every entry in `reviewable_files` using `(path, status)` as identity (workspace mode can report the same path twice when a staged deletion is recreated untracked). Every file MUST end as `reviewed` or `skipped` (with a concrete reason).
70
+
71
+ For each file in Recommended Review Order:
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).
74
+ 2. **Apply its matched Rule Group** from Section 5.
75
+ 3. **Follow Dependency Graph edges** whenever:
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.
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
+ 4. Mark the file `reviewed` (or `skipped: <reason>`). Do not stop after finding the first bug; complete all files.
80
+
81
+ ### Step 4: Precision Filtering & Premise Gate (Anti-Noise Pass)
82
+
83
+ Audit every candidate finding before reporting:
84
+
85
+ - **Confidence Score (0–100) for Code Defects**: Assign each code-defect finding a confidence score. **Silently drop code defects below 80.**
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
+ - **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
+ - **No Linter/Formatter Noise**: Skip formatting, import sorting, style preferences, or issues caught by typecheckers and linters.
89
+ - **Nit Cap**: Cap `Nit` findings at **5** (summarize extras as `+N similar nits`).
90
+ - **Verify against Target Snapshot**: For `--pr`, `--from..--to`, or `-c`, verify line numbers against `<head_git_ref>`, not a stale working tree.
91
+
92
+ ### Step 5: Report Format
93
+
94
+ Respond concisely in the user's language (e.g., Chinese if the user wrote Chinese), decoupling **code quality** from **merge readiness** with the 4-way verdict:
95
+
96
+ ```markdown
97
+ ## Code Review Summary
98
+
99
+ - **Target**: <PR # / branch range / commit / workspace>
100
+ - **Verdict**: <`LGTM` | `Request Changes` | `Hold / Needs Maintainer Decision` | `Redirect / Process Gate`>
101
+ - **Coverage**: X/Y files reviewed (Z skipped: <reasons if any>) | 100% accounted
102
+ - **Blast Radius & Graph Highlights**: <1–3 bullets on key dependency impact>
103
+
104
+ ### Governance / Scope Decision *(include when Verdict is `Hold` or `Redirect`)*
105
+ - **Gate Triggered**: `[duplicate-pr | policy-gate | scope-boundary | architectural-direction]`
106
+ - **Rationale**: Concrete policy/scope explanation (acknowledge code strengths objectively if audited).
107
+ - **Recommended Action**: Specific next step with PR/Issue references.
108
+
109
+ ### Critical / Blocking
110
+ - **`path/to/file.ts:42`** `[bug | security | contract | concurrency]` `[confidence: 95]`
111
+ - **Impact Path**: `caller.ts:18` → `target.ts:42` (when cross-file)
112
+ - **Failure Scenario**: Concrete explanation of what breaks and why.
113
+ - **Fix**: Specific actionable fix.
114
+
115
+ ### Important
116
+ ...
117
+
118
+ ### Needs Author Verification (Blocks LGTM)
119
+ *(Include whenever a high-risk external premise lacks empirical proof; exempt from `< 80` silent drop.)*
120
+ - **`path/to/file.ts:42`** `[premise | external-schema | metrics]`
121
+ - **Unverified Assumption**: What the change assumes about external data or protocol behavior.
122
+ - **Risk if Wrong**: Concrete breakage or distortion.
123
+ - **Evidence Requested**: Exact data/verification needed before approval.
124
+
125
+ ### Nit (max 5)
126
+ ...
127
+ ```
128
+
129
+ - **`LGTM`**: ONLY when Governance/Scope passes and `Critical / Blocking`, `Important`, and `Needs Author Verification` are all empty. If only `Nit` items remain, lead with **`No blocking issues.`**
130
+ - **`Request Changes`**: Direction/scope is acceptable, but `Critical / Blocking`, `Important`, or `Needs Author Verification` items must be resolved first.
131
+ - **`Hold / Needs Maintainer Decision`**: Scope or architectural direction needs maintainer sign-off even if the code is clean. Never output `LGTM`.
132
+ - **`Redirect / Process Gate`**: Duplicates an open PR/Draft or skips a mandatory repo policy gate. Never output `LGTM`.
133
+ - Never post GitHub PR approvals/comments or push commits unless the user explicitly asks.
134
+
135
+ ### Step 6: Fix Mode (Opt-In Only)
136
+
137
+ - **Default**: Review only — NEVER edit repository files.
138
+ - If the user explicitly asks to **"review and fix"**, apply `Critical` and `Important` fixes directly, re-run relevant checks/tests, and summarize the changes.
139
+
140
+ ## Customizing Rules & Governance Policy
141
+
142
+ Rules merge across 4 priority tiers (highest first):
143
+ 1. `--rule <path>`
144
+ 2. `<repo>/.revgraph/rules.json`
145
+ 3. `~/.revgraph/rules.json`
146
+ 4. Built-in `references/rules.json`
147
+
148
+ User/repo configs extend built-in defaults by default. Set `"extends": false` to disable lower-priority layers, or `"override": true` on an individual rule to replace built-in rules for files matching its patterns.
149
+
150
+ Optional governance policy resolution (first existing file wins):
151
+ 1. `--policy <path>`
152
+ 2. `<repo>/.revgraph/policy.md`
153
+ 3. `~/.revgraph/policy.md`