dsh-review-graph 0.0.0-stage → 1.0.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/CONTRIBUTING.md +55 -0
- package/LICENSE +21 -0
- package/README.en.md +122 -0
- package/README.md +97 -2
- package/client.js +4752 -0
- package/cordis.patch.yml +6 -0
- package/docs/DEVELOPMENT.md +460 -0
- package/docs/screenshot.png +0 -0
- package/icon.svg +8 -0
- package/index.js +1487 -0
- package/lib/analyze-core.mjs +558 -0
- package/lib/analyze.mjs +166 -0
- package/lib/diff.mjs +179 -0
- package/lib/flow.mjs +347 -0
- package/lib/git.mjs +478 -0
- package/locale/en.json +10 -0
- package/locale/zh.json +10 -0
- package/package.json +75 -4
- package/prism.bundle.js +602 -0
- package/vendor/prism/LICENSE +21 -0
- package/vendor/prism/NOTICE.md +15 -0
- package/vendor/prism/manifest.json +11 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
User-facing docs live in [README.md](README.md); implementation notes live in
|
|
4
|
+
[docs/DEVELOPMENT.md](docs/DEVELOPMENT.md).
|
|
5
|
+
|
|
6
|
+
Thanks for looking. A few things make a PR easy to land here.
|
|
7
|
+
|
|
8
|
+
## Before you open one
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm run verify # build + all self-checks; must be green
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The self-checks do not use the network and do not call a model: the AI half runs against a fake
|
|
15
|
+
adapter, and the client half is rendered with a fake React. That means a mistake like reading a name
|
|
16
|
+
that does not exist fails here instead of blanking a tab in the browser — which is exactly how
|
|
17
|
+
three blank-tab bugs got caught, so please keep that property.
|
|
18
|
+
|
|
19
|
+
## What is easy to get wrong
|
|
20
|
+
|
|
21
|
+
* **Never hand-place two things in a container.** Two overlays each anchored to the same corner, or
|
|
22
|
+
boxes positioned by arithmetic, is how buttons and nodes ended up overlapping. Put them in one
|
|
23
|
+
flex row, or in a slot on a fixed pitch, so the layout cannot collide.
|
|
24
|
+
* **A cache key is a promise.** If two different questions (another commit, another branch, a
|
|
25
|
+
changed excerpt) can produce the same key, the answer shown will be wrong rather than stale.
|
|
26
|
+
* **Do not silently truncate.** Sizing input down to suit one model's habits changes every model's
|
|
27
|
+
answer; send the whole thing and let the caller choose.
|
|
28
|
+
* **Declare the service you use.** A Cordis service is only reachable through the `ctx` that
|
|
29
|
+
declared it in `inject`, and a dotted name (`remote.workspaceFiles`) must be declared verbatim.
|
|
30
|
+
|
|
31
|
+
## Commits
|
|
32
|
+
|
|
33
|
+
Explain *why*, not *what*. The diff already says what changed.
|
|
34
|
+
|
|
35
|
+
## Releasing
|
|
36
|
+
|
|
37
|
+
The first version goes out by hand, because npm's trusted-publishing settings page only exists once the
|
|
38
|
+
package does:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm publish --otp=<code from the authenticator>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
After that, configure **Trusted publishing** on the package's settings page (repository
|
|
45
|
+
`huaxiaolong/dsh-review-graph`, workflow `publish.yml`) and let `.github/workflows/publish.yml` do the
|
|
46
|
+
rest — it needs no stored secret, and it publishes with provenance:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# bump version in package.json, commit, push
|
|
50
|
+
git tag v<version> && git push origin v<version>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Why OIDC rather than an `NPM_TOKEN`: npm is removing direct publish from tokens that bypass 2FA
|
|
54
|
+
(targeted for January 2027), so a stored token would stop working. Trusted publishing replaces it with a
|
|
55
|
+
short-lived credential minted per run.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 huaxiaolong <https://github.com/huaxiaolong>
|
|
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.en.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# dsh-review-graph
|
|
2
|
+
|
|
3
|
+
[中文](README.md) · English
|
|
4
|
+
|
|
5
|
+
**Which files call which, how far a change reaches, and where every edit actually is** — read it inside
|
|
6
|
+
the conversation instead of opening files one by one.
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
Three surfaces, in the conversation's middle column:
|
|
11
|
+
|
|
12
|
+
| What you want to know | What you get |
|
|
13
|
+
|---|---|
|
|
14
|
+
| Reach: who calls whom | **Relationship graph**: only the files this change touches, in lanes by call depth, with thin lines for the calls |
|
|
15
|
+
| Place: where it changed | Click any file → the **review pane** opens the whole change set at that file |
|
|
16
|
+
| Content: what changed | Red/green diff, **dual line numbers** (original and changed), **syntax highlighting** (297 languages), a left marker on the line you jumped to |
|
|
17
|
+
| Intent: which behaviour it belongs to | **Business flows (AI)**: on request, a **flow diagram** of the original and the changed side, each step anchored to a file and a line |
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
Requirements: DSH (Host and Web), and the workspace you review is a **git repository**.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# 1) from git (no account needed — recommended)
|
|
25
|
+
dsh plugin --profile <profile> add https://github.com/huaxiaolong/dsh-review-graph
|
|
26
|
+
|
|
27
|
+
# 2) from the release tarball (no npm account needed)
|
|
28
|
+
dsh plugin --profile <profile> add https://github.com/huaxiaolong/dsh-review-graph/releases/latest/download/dsh-review-graph-1.0.0.tgz
|
|
29
|
+
|
|
30
|
+
# 3) from npm
|
|
31
|
+
dsh plugin --profile <profile> add dsh-review-graph
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or in the GUI: **Plugins** in the sidebar → **Add plugin** → paste any of the above (package name, git
|
|
35
|
+
address, tarball URL, or a local path).
|
|
36
|
+
|
|
37
|
+
All three install the same code with the same capabilities; npm is one channel, not a requirement.
|
|
38
|
+
|
|
39
|
+
Restart DSH afterwards (the Host half is regenerated) and reload the page (the client half), then switch
|
|
40
|
+
the middle column to “Relationship graph”.
|
|
41
|
+
|
|
42
|
+
## Using it
|
|
43
|
+
|
|
44
|
+
### Relationship graph
|
|
45
|
+
|
|
46
|
+
* **One file, one box.** A column is one call depth; the leftmost column holds the entries — the files
|
|
47
|
+
nothing else in this change calls.
|
|
48
|
+
* **Colours:** blue means the file has references to or from other changed files; yellow means it has
|
|
49
|
+
none in this change (hover a box and it says so).
|
|
50
|
+
* **A single click on a file** opens the whole change set in the right column at that file. Lines run
|
|
51
|
+
from caller to callee.
|
|
52
|
+
* Top right: **⌃ hides the toolbar** (giving its height to the picture) and **Fit** frames everything
|
|
53
|
+
again. Bottom right: `-`, `+` and a percentage for zoom.
|
|
54
|
+
* When relationships are dense, only the strongest 600 are drawn with the count of what was left out
|
|
55
|
+
shown in the corner, plus a **Draw all references** button.
|
|
56
|
+
|
|
57
|
+
### Review pane (right column)
|
|
58
|
+
|
|
59
|
+
* The top switches the **change source**: uncommitted, unstaged, staged, a single commit, or a
|
|
60
|
+
comparison against a branch.
|
|
61
|
+
* The left rail lists every file in that source; `‹ ›` steps to the previous or next one. **The line you
|
|
62
|
+
jumped to carries a left marker** that does not cover the red/green fills.
|
|
63
|
+
* **Open in file** hands the whole file to DSH’s own preview, which has editor-grade highlighting.
|
|
64
|
+
|
|
65
|
+
### Business flows (AI) — nothing is generated until you ask
|
|
66
|
+
|
|
67
|
+
* **Generation starts on the button**, and it calls **the model you selected in the conversation**. Before
|
|
68
|
+
it runs, the card states exactly what would be sent: how many files, how large the excerpts are,
|
|
69
|
+
whether the conversation digest is included, and the output limit.
|
|
70
|
+
* The result is a **flow diagram with the original and the changed side by side**; clicking a step jumps
|
|
71
|
+
to its file and line.
|
|
72
|
+
* **Three cache layers**: re-opening the same material loads the previous answer without spending a
|
|
73
|
+
token; when the material has moved on, the previous answer is **kept and labelled out of date**, and
|
|
74
|
+
regenerating is your call.
|
|
75
|
+
* **View what was sent and the raw answer** shows the actual prompt and the model’s reply, for debugging.
|
|
76
|
+
|
|
77
|
+
## What costs money, and what leaves your machine
|
|
78
|
+
|
|
79
|
+
* **Only pressing Generate spends tokens.** The graph, the review pane, the diff and the highlighting are
|
|
80
|
+
all local and never touch the network.
|
|
81
|
+
* A generation sends the **change excerpts, the file and symbol structure, and (optionally) a
|
|
82
|
+
conversation digest** to the model you chose. **Excerpts are never truncated** — the whole diff goes in.
|
|
83
|
+
A change set larger than the model’s context window fails with a clear error rather than silently
|
|
84
|
+
handing you an answer with pieces missing.
|
|
85
|
+
* **The model is chosen in the conversation**, not here: this plugin offers no second model switch. It
|
|
86
|
+
exposes a reasoning-effort control only when your provider actually publishes the options.
|
|
87
|
+
* Cached answers live in `<DSH_HOME>/storages/review-graph-flows/`, at most 30 of them, mode `0600`.
|
|
88
|
+
Delete that directory to clear them.
|
|
89
|
+
|
|
90
|
+
## Limitations
|
|
91
|
+
|
|
92
|
+
* The graph covers files whose references can be **parsed statically** (JS/TS, Python, Go, Rust, Java and
|
|
93
|
+
others). Files that cannot be parsed appear as isolated (yellow) boxes.
|
|
94
|
+
* **Deleted files are absent** from the graph: they are no longer in the workspace index.
|
|
95
|
+
* With several entries, the busiest one is placed first and the others sit in the adjacent column.
|
|
96
|
+
* A workspace that is not a git repository says so plainly instead of showing an empty pane.
|
|
97
|
+
|
|
98
|
+
## When something goes wrong
|
|
99
|
+
|
|
100
|
+
| Symptom | Cause and what to do |
|
|
101
|
+
|---|---|
|
|
102
|
+
| The pane shows `review graph: xxx is not defined` | A plugin defect; that sentence is the cause. Paste it into an issue. (An error boundary produces it — previously this was a blank tab.) |
|
|
103
|
+
| Generation fails saying the output budget was spent on reasoning | The model used its whole budget thinking. Switch to a model that does not think out loud in the conversation, then generate again. |
|
|
104
|
+
| It says there is no cache right after you generated | Switching commit or branch clears the pane and re-checks; a changed conversation digest counts as out of date. |
|
|
105
|
+
| The graph shows a single file | Only one file changed, or the others have no statically parsable references. |
|
|
106
|
+
|
|
107
|
+
## Uninstall
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
dsh plugin --profile <profile> remove review-graph
|
|
111
|
+
rm -rf "$DSH_HOME/storages/review-graph-flows" # optional: the generated cache
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Development, architecture and self-checks
|
|
115
|
+
|
|
116
|
+
See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) (injection contract, layered design, the defect list, and
|
|
117
|
+
how to run the 358 self-checks).
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT © 2026 huaxiaolong. The inlined Prism.js is MIT as well; attribution and the way it is regenerated are
|
|
122
|
+
in [vendor/prism/NOTICE.md](vendor/prism/NOTICE.md).
|
package/README.md
CHANGED
|
@@ -1,3 +1,98 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-review-graph
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[English](README.en.md) · 中文
|
|
4
|
+
|
|
5
|
+
一次变更里**哪些文件互相调用、影响面多大、每处改动到底在哪一行**——在会话里直接看懂,不用在编辑器里一个个翻。
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
它把三件事放进会话中间栏:
|
|
10
|
+
|
|
11
|
+
| 你关心的 | 它给你什么 |
|
|
12
|
+
|---|---|
|
|
13
|
+
| 影响面:谁调用谁 | **变更关系图**:只显示本次改动的文件,按调用深度分列,细线表示调用关系 |
|
|
14
|
+
| 位置:改在哪 | 点任意文件 → 右侧**变更审查**打开整个变更集并定位到该文件 |
|
|
15
|
+
| 内容:改了什么 | 红绿差异、**原始/改动后双列行号**、**语法高亮**(297 种语言)、跳转行左侧标记 |
|
|
16
|
+
| 业务:对应哪块逻辑 | **业务流程 AI**:按需生成改动前/后对照的**流程图**,每一步标注文件与行 |
|
|
17
|
+
|
|
18
|
+
## 安装
|
|
19
|
+
|
|
20
|
+
要求:DSH(Host + Web 端),被审查的工作区是 **git 仓库**。
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# 1) 从 git(无需任何账号,推荐)
|
|
24
|
+
dsh plugin --profile <profile> add https://github.com/huaxiaolong/dsh-review-graph
|
|
25
|
+
|
|
26
|
+
# 2) 从 Release 里的 tarball(无需 npm 账号)
|
|
27
|
+
dsh plugin --profile <profile> add https://github.com/huaxiaolong/dsh-review-graph/releases/latest/download/dsh-review-graph-1.0.0.tgz
|
|
28
|
+
|
|
29
|
+
# 3) 从 npm
|
|
30
|
+
dsh plugin --profile <profile> add dsh-review-graph
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
或在 GUI 里:侧栏「**插件**」→ **Add plugin** → 粘贴上面任意一种(包名、git 地址、tarball 地址或本地路径)。
|
|
34
|
+
|
|
35
|
+
三种方式装的**是同一份代码**,能力完全相同;npm 只是其中一个渠道。
|
|
36
|
+
|
|
37
|
+
装完**重启 DSH**(Host 半边生效),刷新页面(Client 半边生效),然后在会话中间栏切到「变更关系图」。
|
|
38
|
+
|
|
39
|
+
## 用起来
|
|
40
|
+
|
|
41
|
+
### 变更关系图
|
|
42
|
+
|
|
43
|
+
* **一个文件一个框**,同一列 = 同一调用深度;最左一列是入口(本次改动里没有任何文件调用它)。
|
|
44
|
+
* **颜色**:蓝色 = 与其他改动文件有引用关系;黄色 = 本次改动里没有任何引用关系(悬停会写明)。
|
|
45
|
+
* **单击文件**:在右侧打开整个变更集并定位到该文件;连线从调用方指向被调用方。
|
|
46
|
+
* 右上:**⌃ 收起工具栏**(把高度让给图)、**适应窗口**(回到全景);右下:`-` / `+` / 百分比是缩放。
|
|
47
|
+
* 关系太密时只画最强的 600 条,左上角写明隐藏了多少,并给出「显示全部引用」。
|
|
48
|
+
|
|
49
|
+
### 变更审查(右侧栏)
|
|
50
|
+
|
|
51
|
+
* 顶部切换**变更来源**:未提交 / 未暂存 / 已暂存 / 单个 commit / 与某个分支对比。
|
|
52
|
+
* 左栏是这次来源里的全部改动文件,`‹ ›` 切上一个/下一个;**跳转过来的那一行左侧有竖条**(不影响红绿底色)。
|
|
53
|
+
* 「在文件中打开」用 DSH 自带的预览看整个文件(那里有编辑器级别的高亮)。
|
|
54
|
+
|
|
55
|
+
### 业务流程 AI(默认不生成)
|
|
56
|
+
|
|
57
|
+
* **点「生成」才开始**,调用的是**你在对话区选择的模型**。生成前卡片会写清:将发送几个文件的变更片段、多大、是否带对话摘要、输出上限。
|
|
58
|
+
* 结果是**改动前 / 改动后左右对照的流程图**,点任意节点跳到对应文件与行。
|
|
59
|
+
* **三层缓存**:同一份材料再打开→直接命中、不花 token;材料变了→**保留上一次结果并标「已过期」**,重新生成由你决定。
|
|
60
|
+
* 「查看发送内容与原始回答」能看到实际发出的提示词与模型原文(排查用)。
|
|
61
|
+
|
|
62
|
+
## 会花钱吗?会外发什么?
|
|
63
|
+
|
|
64
|
+
* **只有点「生成」才消耗 token**。关系图、审查、diff、语法高亮全部本地完成,不联网。
|
|
65
|
+
* 生成时会把**变更片段 + 文件/符号结构 +(可选)对话摘要**发给你选的模型。**变更片段不截断**——整份差异都会送进去;变更集过大可能超出模型上下文窗口,那会**明确报错**,不会悄悄截断给你一个少内容的答案。
|
|
66
|
+
* **模型只在对话区选**,本插件不提供第二个模型开关(只在 provider 公布档位时暴露推理强度)。
|
|
67
|
+
* 缓存落在 `<DSH_HOME>/storages/review-graph-flows/`,最多 30 份,权限 `0600`;删掉该目录即清空。
|
|
68
|
+
|
|
69
|
+
## 已知限制
|
|
70
|
+
|
|
71
|
+
* 关系图只覆盖**能静态解析出引用**的文件类型(JS/TS、Python、Go、Rust、Java 等);解析不出的文件会作为孤立节点(黄色)出现。
|
|
72
|
+
* **已删除的文件不在图里**(它已不在工作区索引中)。
|
|
73
|
+
* 有多个入口时,最"忙"的那个放最左,其余入口排在相邻列。
|
|
74
|
+
* 工作区不是 git 仓库时会明确提示,而不是给你一个空面板。
|
|
75
|
+
|
|
76
|
+
## 出问题时
|
|
77
|
+
|
|
78
|
+
| 现象 | 原因与处理 |
|
|
79
|
+
|---|---|
|
|
80
|
+
| 面板显示 `review graph: xxx is not defined` | 插件缺陷;那句话就是原因,直接贴进 issue(这是错误边界的结果,以前会变成空白页签) |
|
|
81
|
+
| 生成失败并说"占满输出预算" | 模型把额度全用在推理上;去**对话区**换一个不做长推理的模型再生成 |
|
|
82
|
+
| 刚生成过却说"没有缓存" | 切换 commit/分支会清空面板并重新判定;对话摘要变化算「已过期」 |
|
|
83
|
+
| 关系图里只有一个文件 | 本次只改了一个文件,或其余文件静态解析不出引用 |
|
|
84
|
+
|
|
85
|
+
## 卸载
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
dsh plugin --profile <profile> remove review-graph
|
|
89
|
+
rm -rf "$DSH_HOME/storages/review-graph-flows" # 可选:连同生成的缓存
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 开发、架构与自检
|
|
93
|
+
|
|
94
|
+
见 [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md)(注入契约、分层设计、缺陷清单、358 项自检怎么跑)。
|
|
95
|
+
|
|
96
|
+
## 许可证
|
|
97
|
+
|
|
98
|
+
MIT © 2026 huaxiaolong。内联的 Prism.js 同为 MIT,归属与再生成方式见 [vendor/prism/NOTICE.md](vendor/prism/NOTICE.md)。
|