local-diff-reviewer 0.1.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/README.md +179 -0
- package/SKILL.md +62 -0
- package/dist/cli/start.js +949 -0
- package/dist/web/assets/arc-CR7lDgfr.js +1 -0
- package/dist/web/assets/architecture-7EHR7CIX-nXR9vjYB.js +1 -0
- package/dist/web/assets/architectureDiagram-3BPJPVTR-B-Kf98tI.js +36 -0
- package/dist/web/assets/array-yLZkcI6Y.js +1 -0
- package/dist/web/assets/blockDiagram-GPEHLZMM-C6G2D8zB.js +132 -0
- package/dist/web/assets/c4Diagram-AAUBKEIU-B8Z0vFGi.js +10 -0
- package/dist/web/assets/channel-BLQGEX2L.js +1 -0
- package/dist/web/assets/chunk-2J33WTMH-BJYcz9p6.js +1 -0
- package/dist/web/assets/chunk-3OPIFGDE-CadWbiuZ.js +62 -0
- package/dist/web/assets/chunk-4BX2VUAB-p5TBPKfa.js +1 -0
- package/dist/web/assets/chunk-4EGX6M5U-Dm0Urt6c.js +1 -0
- package/dist/web/assets/chunk-55IACEB6-Cd7Tpfqt.js +1 -0
- package/dist/web/assets/chunk-5DO6E6H7-eFUPFW6j.js +1 -0
- package/dist/web/assets/chunk-5ZQYHXKU-rVi82pOk.js +2 -0
- package/dist/web/assets/chunk-727SXJPM-DCK60o1J.js +206 -0
- package/dist/web/assets/chunk-AQP2D5EJ-DsaTBCmF.js +231 -0
- package/dist/web/assets/chunk-BR22UD5L-CAPtHiCF.js +1 -0
- package/dist/web/assets/chunk-BSJP7CBP-Bhh_dCA1.js +1 -0
- package/dist/web/assets/chunk-CSCIHK7Q-BTxAxDrY.js +124 -0
- package/dist/web/assets/chunk-FHYWG6QK-DYV7MBXV.js +1 -0
- package/dist/web/assets/chunk-FMBD7UC4-DlFkGqeu.js +15 -0
- package/dist/web/assets/chunk-KSCS5N6A-BYPjHZNn.js +10 -0
- package/dist/web/assets/chunk-L5ZTLDWV-BMFnPCzP.js +1 -0
- package/dist/web/assets/chunk-LZXEDZCA-BKhHYjKh.js +2 -0
- package/dist/web/assets/chunk-MPE355IW-Bn5Gex5z.js +1 -0
- package/dist/web/assets/chunk-MZUSXYTE-DkK02s8r.js +1 -0
- package/dist/web/assets/chunk-N66VUXT2-BxW6-FUi.js +1 -0
- package/dist/web/assets/chunk-ND2GUHAM-7KRXvqPH.js +1 -0
- package/dist/web/assets/chunk-NNHCCRGN-D80gzfPm.js +159 -0
- package/dist/web/assets/chunk-NZK2D7GU-C2gmfVLG.js +1 -0
- package/dist/web/assets/chunk-O5CBEL6O-BDgBHpRo.js +70 -0
- package/dist/web/assets/chunk-PUPMXCY4-C8RfbV9f.js +1 -0
- package/dist/web/assets/chunk-QZHKN3VN-BGdvirFT.js +1 -0
- package/dist/web/assets/chunk-UIBZB4QT-JbcSSk3W.js +1 -0
- package/dist/web/assets/chunk-WCWK7LTN-DnI1dFXp.js +1 -0
- package/dist/web/assets/chunk-WU5MYG2G-VXAyXnrB.js +1 -0
- package/dist/web/assets/chunk-XPW4576I-CNcwF46w.js +32 -0
- package/dist/web/assets/classDiagram-4FO5ZUOK-DGbdorsF.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-CdJT8iZ_.js +1 -0
- package/dist/web/assets/cose-bilkent-S5V4N54A-DGxrNo18.js +1 -0
- package/dist/web/assets/cytoscape.esm-DBZzCT3P.js +321 -0
- package/dist/web/assets/dagre-BLlLfumR.js +1 -0
- package/dist/web/assets/dagre-BM42HDAG-DgS2nVEP.js +4 -0
- package/dist/web/assets/defaultLocale-Bld4b7vH.js +1 -0
- package/dist/web/assets/diagram-2AECGRRQ-CZ3HTlHq.js +43 -0
- package/dist/web/assets/diagram-5GNKFQAL-Q7ELSmIM.js +10 -0
- package/dist/web/assets/diagram-KO2AKTUF-E5adO5kX.js +3 -0
- package/dist/web/assets/diagram-LMA3HP47-DckjoLmV.js +24 -0
- package/dist/web/assets/diagram-OG6HWLK6-C6IV8tgf.js +24 -0
- package/dist/web/assets/dist-BBL8i-qs.js +1 -0
- package/dist/web/assets/erDiagram-TEJ5UH35-CtdFt0tH.js +85 -0
- package/dist/web/assets/eventmodeling-FCH6USID-C_CDGdeY.js +1 -0
- package/dist/web/assets/flowDiagram-I6XJVG4X-Cj3R7yTy.js +162 -0
- package/dist/web/assets/ganttDiagram-6RSMTGT7-Bb6ylSyS.js +292 -0
- package/dist/web/assets/gitGraph-WXDBUCRP-GdVUV9HW.js +1 -0
- package/dist/web/assets/gitGraphDiagram-PVQCEYII-DJHSJ07v.js +106 -0
- package/dist/web/assets/graphlib-DkOQ9ah2.js +1 -0
- package/dist/web/assets/index-Byh7XaFy.js +288 -0
- package/dist/web/assets/index-CND5NAGY.css +1 -0
- package/dist/web/assets/info-J43DQDTF-BWgpjD75.js +1 -0
- package/dist/web/assets/infoDiagram-5YYISTIA-1xrP_FxB.js +2 -0
- package/dist/web/assets/init-rddNFwID.js +1 -0
- package/dist/web/assets/ishikawaDiagram-YF4QCWOH-DxyBX-lT.js +70 -0
- package/dist/web/assets/journeyDiagram-JHISSGLW-DMcyhQOZ.js +139 -0
- package/dist/web/assets/kanban-definition-UN3LZRKU-qZQpCEuA.js +89 -0
- package/dist/web/assets/katex-D9DkQQYz.js +257 -0
- package/dist/web/assets/line-BJ3a5kXp.js +1 -0
- package/dist/web/assets/linear-WojM0Myz.js +1 -0
- package/dist/web/assets/mermaid-parser.core-CXQdsx5L.js +4 -0
- package/dist/web/assets/mermaid.core-D-XPCWky.js +9 -0
- package/dist/web/assets/mindmap-definition-RKZ34NQL-B3OxgBPA.js +96 -0
- package/dist/web/assets/ordinal-7rXhq2H9.js +1 -0
- package/dist/web/assets/packet-YPE3B663-Dtmistlh.js +1 -0
- package/dist/web/assets/path-BJQEcSo7.js +1 -0
- package/dist/web/assets/pie-LRSECV5Y-CRgiS3oB.js +1 -0
- package/dist/web/assets/pieDiagram-4H26LBE5-Div1l6Q1.js +30 -0
- package/dist/web/assets/quadrantDiagram-W4KKPZXB-CeXbRhNe.js +7 -0
- package/dist/web/assets/radar-GUYGQ44K-CF2B6KbU.js +1 -0
- package/dist/web/assets/requirementDiagram-4Y6WPE33-BlGgeVCv.js +84 -0
- package/dist/web/assets/rough.esm-KjoEK0it.js +1 -0
- package/dist/web/assets/sankeyDiagram-5OEKKPKP-BhwjPB4q.js +40 -0
- package/dist/web/assets/sequenceDiagram-3UESZ5HK-DNHlWYtx.js +162 -0
- package/dist/web/assets/src-Bn2XKj5Y.js +1 -0
- package/dist/web/assets/stateDiagram-AJRCARHV-CdZgtb-A.js +1 -0
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-C5vqR8l5.js +1 -0
- package/dist/web/assets/timeline-definition-PNZ67QCA-Ch-1WuO4.js +120 -0
- package/dist/web/assets/treeView-BLDUP644-Bdt69Bnk.js +1 -0
- package/dist/web/assets/treemap-LRROVOQU-BBya6zH4.js +1 -0
- package/dist/web/assets/vennDiagram-CIIHVFJN-BU0olyYI.js +34 -0
- package/dist/web/assets/wardley-L42UT6IY-B77cR16B.js +1 -0
- package/dist/web/assets/wardleyDiagram-YWT4CUSO-DXFmQa94.js +78 -0
- package/dist/web/assets/xychartDiagram-2RQKCTM6-BY6dYn-A.js +7 -0
- package/dist/web/index.html +13 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# diff-review
|
|
2
|
+
|
|
3
|
+
AI chat 里的本地代码审查工具。可以直接用 CLI 打开,也可以安装成 agent skill。
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
Try it first:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx local-diff-reviewer
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Install and use:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g local-diff-reviewer
|
|
17
|
+
local-diff-reviewer
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Enable use from AI agents:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx skills add limengyi/diff-review
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 功能边界
|
|
27
|
+
|
|
28
|
+
- 查看当前工作区 diff、staged diff、指定 revision diff。
|
|
29
|
+
- 代码文件使用 GitHub 风格 unified diff。
|
|
30
|
+
- Markdown 文件只展示 Preview,不提供 Diff / Preview 切换。
|
|
31
|
+
- 支持文件级评论、代码行级评论、Markdown source line 评论。
|
|
32
|
+
- 支持 submit / replied / resolved 评论状态。
|
|
33
|
+
- 一条 thread 下可以包含多条 comment;同一锚点的新评论会追加到已有 thread。
|
|
34
|
+
- 支持通过内部 `--comment` 参数预置 agent findings / replies。
|
|
35
|
+
- 支持复制极简 AI prompt。
|
|
36
|
+
|
|
37
|
+
## 评论定位原理(新手友好版)
|
|
38
|
+
|
|
39
|
+
很多人会直觉认为:评论只和“第几行”绑定。
|
|
40
|
+
比如删掉第 10 行后,原来第 11 行顶上来变成第 10 行,评论也应该跟着走。
|
|
41
|
+
|
|
42
|
+
这个工具不是这样做的。它用的是“锚点”定位,锚点至少包含:
|
|
43
|
+
|
|
44
|
+
- 文件路径(`filePath`)
|
|
45
|
+
- 行号(`lineNumber`)
|
|
46
|
+
- 行所在版本(`side`:旧版本 `old` / 新版本 `new`,代码 Diff 专用)
|
|
47
|
+
|
|
48
|
+
这意味着评论绑定的是“哪一个版本里的哪一行”,而不是“屏幕上现在第几行”。
|
|
49
|
+
|
|
50
|
+
### 为什么删除内容后评论可能不显示?
|
|
51
|
+
|
|
52
|
+
- 对代码 Diff 行评论:
|
|
53
|
+
- 如果评论当时加在被删除的旧行上,它的锚点是 `old + 行号`。
|
|
54
|
+
- 删除后右侧展示的是新版本内容(`new`),`old` 锚点找不到对应渲染位置时,就不会显示在行内。
|
|
55
|
+
- 对 Markdown 行评论:
|
|
56
|
+
- 评论绑定的是 source line(源文件行号)。
|
|
57
|
+
- 被评论的那段 Markdown 真被删掉后,预览里没有对应块可挂载,行内自然不显示。
|
|
58
|
+
|
|
59
|
+
### 一个非常短的例子
|
|
60
|
+
|
|
61
|
+
1. 你在 `old` 版本第 20 行加了评论。
|
|
62
|
+
2. 后续改动把第 20 行删除,并让后面内容上移。
|
|
63
|
+
3. 新内容虽然“占了第 20 行的位置”,但它属于 `new` 版本,不是原来的 `old` 行。
|
|
64
|
+
4. 所以系统不会把旧评论自动贴到新内容上。
|
|
65
|
+
|
|
66
|
+
这样做的好处是:避免评论“串行”到语义完全不同的内容上,减少误导。
|
|
67
|
+
|
|
68
|
+
复制出的 prompt 包含 thread id、定位信息和评论内容。thread id 用于让 agent 后续通过 `--comment '{"type":"reply",...}'` 精确回复原评论:
|
|
69
|
+
|
|
70
|
+
```text
|
|
71
|
+
[thread:<thread-id>]
|
|
72
|
+
文件路径:行号
|
|
73
|
+
评论内容
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
文件级评论不包含行号:
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
[thread:<thread-id>]
|
|
80
|
+
文件路径
|
|
81
|
+
评论内容
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## CLI 使用方式
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
local-diff-reviewer
|
|
88
|
+
local-diff-reviewer staged
|
|
89
|
+
local-diff-reviewer HEAD~1 HEAD
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
这三种模式分别表示:
|
|
93
|
+
|
|
94
|
+
- `working`:审查当前工作区里尚未 `git add` 的改动。
|
|
95
|
+
- `staged`:审查已经 `git add`、但还没有提交的改动。
|
|
96
|
+
- `revision`:审查两个 revision 之间的差异,例如 `local-diff-reviewer HEAD~1 HEAD` 会比较 `HEAD~1..HEAD`。
|
|
97
|
+
|
|
98
|
+
## Skill 使用方式
|
|
99
|
+
|
|
100
|
+
在 AI chat 中使用:
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
/diff-review
|
|
104
|
+
/diff-review staged
|
|
105
|
+
/diff-review HEAD~1 HEAD
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
安装 skill:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
npx skills add limengyi/diff-review
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
skill 会从目标 workspace 运行 `npx local-diff-reviewer [args...]`。
|
|
115
|
+
|
|
116
|
+
### 预置 agent 评论
|
|
117
|
+
|
|
118
|
+
CLI 支持重复传入 `--comment <json>`,用于在打开 UI 前把 agent 审查结果写入评论存储。
|
|
119
|
+
|
|
120
|
+
代码 diff 行评论:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npx local-diff-reviewer \
|
|
124
|
+
--comment '{"type":"thread","filePath":"src/foo.ts","position":{"side":"new","line":36},"body":"这里没有处理空数组,可能导致运行时报错。"}'
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Markdown source line 评论:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npx local-diff-reviewer \
|
|
131
|
+
--comment '{"type":"thread","filePath":"README.md","position":{"type":"markdown","line":22},"body":"这里可以补充 old/new side 的例子。"}'
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
文件级评论:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
npx local-diff-reviewer \
|
|
138
|
+
--comment '{"type":"thread","filePath":"src/foo.ts","body":"这个文件的错误处理策略需要统一。"}'
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
回复已有 thread:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npx local-diff-reviewer \
|
|
145
|
+
--comment '{"type":"reply","threadId":"<thread-id>","body":"同意,这里应该按 repoRoot 隔离评论存储。"}'
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`thread` 评论会以 `author: "agent"` 写入:如果同一锚点已经存在 thread,会作为新的 comment 追加进去;否则创建 replied thread。`reply` 会向目标 thread 追加一条 agent 回复并把状态切到 replied。为避免 agent finding 反复注入导致刷屏,同一 thread 内相同正文的 agent comment 会被视为重复并跳过。若路径不在当前 diff 中、行号无法定位或内容重复,脚本会跳过并在终端打印 warning。
|
|
149
|
+
|
|
150
|
+
当 agent 收到从 UI 复制出的 `[thread:<id>]` prompt 并完成处理后,应使用 `type: "reply"` 把处理结果写回原 thread,作为 `author: "agent"` 的 comment 保留在评论流里。回复内容应简要说明已修改什么,或说明为什么没有修改。
|
|
151
|
+
|
|
152
|
+
评论状态含义:
|
|
153
|
+
|
|
154
|
+
- `submit`:只有用户提交的评论,还没有 agent finding / reply。
|
|
155
|
+
- `replied`:已有 agent 内容,或从 resolved 重新打开。
|
|
156
|
+
- `resolved`:用户确认完成后的状态。
|
|
157
|
+
|
|
158
|
+
## 本地开发
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
npm install
|
|
162
|
+
npm run dev
|
|
163
|
+
npm run typecheck
|
|
164
|
+
npm run build
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
`npm run dev`(等价于 `npm run review:dev`)会启动 API 服务并打开 Vite dev server,前端代码修改会使用 Vite HMR 热更新。`npm run review` 优先使用已构建的 `dist/web`。
|
|
168
|
+
|
|
169
|
+
仅调试前端时可使用:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
npm run web:dev
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
注意:`web:dev` 只启动 Vite,不会启动 API 服务。
|
|
176
|
+
|
|
177
|
+
评论数据默认归档在 `~/.local/diff-review/logs`。Windows 下使用类似位置:
|
|
178
|
+
`%LOCALAPPDATA%\diff-review\logs`,如果未设置 `LOCALAPPDATA` 则退到
|
|
179
|
+
`~/AppData/Local/diff-review/logs`。
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: diff-review
|
|
3
|
+
description: Use when the user types /diff-review or asks to review the current workspace diff in a local GitHub-style viewer with comments, Markdown preview comments, and minimal AI prompt copying.
|
|
4
|
+
metadata:
|
|
5
|
+
short-description: Open a local diff review viewer
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Diff Review
|
|
9
|
+
|
|
10
|
+
Use this skill when the user asks for `/diff-review`, wants to inspect current workspace changes, staged changes, or a revision pair in a local review UI.
|
|
11
|
+
|
|
12
|
+
## Commands
|
|
13
|
+
|
|
14
|
+
- `/diff-review`: review current working tree diff.
|
|
15
|
+
- `/diff-review working`: review current working tree diff.
|
|
16
|
+
- `/diff-review staged`: review staged diff.
|
|
17
|
+
- `/diff-review <base> <target>`: review diff between two Git revisions.
|
|
18
|
+
|
|
19
|
+
Do not ask the user to run a shell CLI manually. Run the package command from the workspace root:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx local-diff-reviewer [args...]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
When you have concrete review findings or answers to existing review comments, preload them with one `--comment` JSON argument per comment before launching the viewer:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx local-diff-reviewer [args...] \
|
|
29
|
+
--comment '{"type":"thread","filePath":"src/foo.ts","position":{"side":"new","line":36},"body":"Explain the finding in the user language."}' \
|
|
30
|
+
--comment '{"type":"reply","threadId":"existing-thread-id","body":"Answer the existing thread as the agent."}'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
After the script prints a local URL, open it in the Codex browser when available. If browser automation is not available, report the URL.
|
|
34
|
+
|
|
35
|
+
When the user gives you copied prompt text containing `[thread:<id>]`, treat it as an existing review thread. After you answer or make code/doc changes for that thread, append a concise agent reply to the same thread with `--comment '{"type":"reply","threadId":"<id>","body":"..."}'` the next time you launch or refresh the viewer. If the viewer is already running and you can reach the API, post the same reply to `/api/threads/<id>/comments` with `author: "agent"`. Do this for every handled thread unless the user explicitly asks you not to write back. The reply should say what changed or why no change was made, not repeat the full diff.
|
|
36
|
+
|
|
37
|
+
## Review Scope
|
|
38
|
+
|
|
39
|
+
- Code files render as GitHub-style unified diffs.
|
|
40
|
+
- Markdown files (`.md`, `.mdx`) render only as preview, not as a Diff / Preview toggle.
|
|
41
|
+
- Markdown line comments anchor to source Markdown line numbers.
|
|
42
|
+
- Comments support submit/replied/resolved state.
|
|
43
|
+
- AI prompt copy output includes `[thread:<id>]`, file path, line number or Markdown source line, and comment body.
|
|
44
|
+
- Agent findings can be preloaded as comments with `--comment`.
|
|
45
|
+
- A thread can contain multiple comments. New findings for the same anchor are appended to the existing thread, and repeated agent comments with identical bodies in the same thread are skipped.
|
|
46
|
+
|
|
47
|
+
## Comment Arguments
|
|
48
|
+
|
|
49
|
+
- Use `type: "thread"` for each new finding.
|
|
50
|
+
- Use `type: "reply"` only when replying to an existing `threadId`.
|
|
51
|
+
- When handling copied `[thread:<id>]` prompt text, use `type: "reply"` for the completion/status response so the answer is preserved as an agent comment in the original thread.
|
|
52
|
+
- Write comment bodies in the language the user is using.
|
|
53
|
+
- Use `position.side: "new"` for lines that exist on the target side of the diff.
|
|
54
|
+
- Use `position.side: "old"` for lines that exist only on the deleted side.
|
|
55
|
+
- Omit `position` for file-level comments.
|
|
56
|
+
- Use `position: {"type":"markdown","line":N}` for Markdown source line comments.
|
|
57
|
+
- Use range comments only by passing `line: {"start":N,"end":M}`; the viewer anchors to the start line.
|
|
58
|
+
- Never copy secrets, tokens, passwords, API keys, private keys, or other credential-like material from the diff into `--comment` bodies or any command-line argument.
|
|
59
|
+
|
|
60
|
+
## Exclusions
|
|
61
|
+
|
|
62
|
+
Do not implement or offer GitHub PR integration, TUI, cloud sync, automatic AI calls, or a remote hosted review service.
|