dsh-coding-enhanced 0.8.3 → 0.8.4
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 +3 -2
- package/docs/review-prompts-and-chain.md +319 -0
- package/lib/client.js +2 -2
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -407,8 +407,9 @@ already covers the “beautiful diff panel” case. Next:
|
|
|
407
407
|
- **P4 — external AI adversarial cross-review**: review-scoped tokens,
|
|
408
408
|
participants, verdicts, proposals.
|
|
409
409
|
|
|
410
|
-
See [the architecture](docs/web-review-architecture.md)
|
|
411
|
-
survey](docs/prior-art.md).
|
|
410
|
+
See [the architecture](docs/web-review-architecture.md), [the prior-art
|
|
411
|
+
survey](docs/prior-art.md), and [the review contract](docs/review-prompts-and-chain.md)
|
|
412
|
+
for the exact prompts and the full chain.
|
|
412
413
|
|
|
413
414
|
## 🛠️ Development
|
|
414
415
|
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# Review contract: prompts & chain
|
|
2
|
+
|
|
3
|
+
> Version: **0.8.4** · Date: 2026-11-22 · Source: `dsh-coding-enhanced`
|
|
4
|
+
>
|
|
5
|
+
> This document records the exact prompts, tool contracts and execution chain
|
|
6
|
+
> of the AI change-review workflow. It is intended as a reference for
|
|
7
|
+
> documentation and blog posts; the code is authoritative if the two differ.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. Positioning
|
|
12
|
+
|
|
13
|
+
`dsh-coding-enhanced` is **not another AI PR reviewer**. It is a workflow layer
|
|
14
|
+
for DSH agents:
|
|
15
|
+
|
|
16
|
+
- **Pre-write change gate** — native file tools are refused while Pre-review is on;
|
|
17
|
+
the agent queues `review_write` / `review_patch`; nothing lands until the user
|
|
18
|
+
finishes.
|
|
19
|
+
- **Workspace time machine** — per-turn shadow-git snapshots and multi-turn withdraw.
|
|
20
|
+
- **Non-blocking review handoff** — the plugin starts a persistent waiter child;
|
|
21
|
+
the main agent continues or ends its turn and is woken when the review finishes.
|
|
22
|
+
- **Remote + cross-AI** — planned: passkey web review and an external cross-review API.
|
|
23
|
+
|
|
24
|
+
The direct prior art is [`9087/dsh-diff-approval`](https://github.com/9087/dsh-diff-approval)
|
|
25
|
+
(a post-edit review panel). The differentiator is the **gate + withdraw + handoff**,
|
|
26
|
+
not the diff pixels. See [`prior-art.md`](prior-art.md).
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 2. Architecture
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
┌──────────────────────────── DSH host ────────────────────────────┐
|
|
34
|
+
│ main agent (session) │
|
|
35
|
+
│ ├─ system prompt (the velvet rope) │
|
|
36
|
+
│ ├─ native tools: read / write / edit / ... │
|
|
37
|
+
│ └─ review tools: review_write / review_patch / review_wait │
|
|
38
|
+
│ │
|
|
39
|
+
│ plugin: coding-enhanced (host, lib/index.js) │
|
|
40
|
+
│ ├─ native gate: tools/pre-execute │
|
|
41
|
+
│ ├─ review state: entries / notes / decisions / waitKey │
|
|
42
|
+
│ ├─ per-file notes validation │
|
|
43
|
+
│ ├─ auto waiter: ensureReviewWaiter → ctx.subagents │
|
|
44
|
+
│ ├─ shadow-git snapshots / withdraw │
|
|
45
|
+
│ ├─ settings / updates / RPC /api/coding-enhanced │
|
|
46
|
+
│ └─ client bundle (lib/client.js) │
|
|
47
|
+
│ │
|
|
48
|
+
│ ctx.subagents (manager) │
|
|
49
|
+
│ ├─ spawn provider: a fresh child agent │
|
|
50
|
+
│ └─ fork provider: a child seeded with the parent conversation │
|
|
51
|
+
│ │
|
|
52
|
+
│ review waiter child (spawn) ── review_wait ──► review state │
|
|
53
|
+
│ │ │
|
|
54
|
+
│ └── completion message ──► main agent wakes │
|
|
55
|
+
│ │
|
|
56
|
+
│ client │
|
|
57
|
+
│ ├─ input Review tools: Pre-review / AI explanations │
|
|
58
|
+
│ ├─ Code review tab: diff / AI rows / decisions / Finish │
|
|
59
|
+
│ └─ Settings / plugin page: Updates / About │
|
|
60
|
+
└──────────────────────────────────────────────────────────────────┘
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Components
|
|
64
|
+
|
|
65
|
+
| Layer | File | Responsibility |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| Host | `lib/index.js` | system prompt, tools, gate, review state, validation, waiter, settings, snapshots, RPC |
|
|
68
|
+
| Client | `lib/client.js` | Review tools popover, review tab, settings, plugin page, diff and AI rows |
|
|
69
|
+
| DSH | `ctx.tools`, `ctx.subagents`, `ctx.sessions` | tool registry, subagent manager, sessions |
|
|
70
|
+
| Bridge | `/api/coding-enhanced` | authenticated RPC between client and host |
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 3. The prompts
|
|
75
|
+
|
|
76
|
+
### 3.1 System prompt (injected every turn while the gate is on)
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
🎟️ FILE-EDIT VELVET ROPE: The human personally reviews every file change.
|
|
80
|
+
Queue every change with review_write (new file / full file) or review_patch
|
|
81
|
+
(unified diff) and include at least one note per changed file while AI
|
|
82
|
+
explanations are on; add line-level notes for user-requested, key or
|
|
83
|
+
hard-to-understand changes (no upper limit). Do not use write/edit/apply_patch/
|
|
84
|
+
str_replace_editor. The plugin starts or reuses the review waiter automatically:
|
|
85
|
+
after queueing, just continue or end the turn; never call review_wait and do
|
|
86
|
+
not manage a subagent. If a file is rejected, read the comment and revise.
|
|
87
|
+
This is house rules. 💅
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 3.2 `review_write`
|
|
91
|
+
|
|
92
|
+
```text
|
|
93
|
+
Queue a new file or a full-file rewrite for the user's review. This does not
|
|
94
|
+
write the file: the change is held in the Code review tab until the user
|
|
95
|
+
finishes. Use review_patch for edits to existing files. At least one notes
|
|
96
|
+
entry per changed file is required while AI explanations are on; prefer
|
|
97
|
+
line-level notes (line/hunk) for user-requested, key or hard-to-understand
|
|
98
|
+
changes. Each note is 1-2 sentences explaining why. The plugin starts or
|
|
99
|
+
reuses the review waiter automatically; just queue and continue, and never
|
|
100
|
+
call review_wait from the main agent.
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 3.3 `review_patch`
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
Queue a unified diff for the user's review. The patch must use ---/+++ headers
|
|
107
|
+
and @@ hunks with paths relative to the working directory; a/ and b/ prefixes
|
|
108
|
+
and diff --git headers are accepted. Use one patch per file when possible;
|
|
109
|
+
multiple files are allowed. This does not modify the workspace: the change is
|
|
110
|
+
held in the Code review tab until the user finishes. At least one notes entry
|
|
111
|
+
per changed file is required while AI explanations are on; prefer line-level
|
|
112
|
+
notes (line/hunk) for user-requested, key or hard-to-understand changes. Each
|
|
113
|
+
note is 1-2 sentences explaining why. The plugin starts or reuses the review
|
|
114
|
+
waiter automatically; just queue and continue, and never call review_wait
|
|
115
|
+
from the main agent.
|
|
116
|
+
|
|
117
|
+
Example:
|
|
118
|
+
--- a/src/app.ts
|
|
119
|
+
+++ b/src/app.ts
|
|
120
|
+
@@ -10,7 +10,9 @@
|
|
121
|
+
const app = createApp()
|
|
122
|
+
- app.use(oldRouter)
|
|
123
|
+
+ app.use(newRouter)
|
|
124
|
+
+ app.use(logger)
|
|
125
|
+
app.listen(3000)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 3.4 `review_wait`
|
|
129
|
+
|
|
130
|
+
```text
|
|
131
|
+
Wait for a review. Only a review waiter subagent should call this: pass the
|
|
132
|
+
reviewId and waitKey from review_write/review_patch. The main agent must not
|
|
133
|
+
call it; if it does, the call is refused so the turn never blocks. Returns one
|
|
134
|
+
structured result per file: applied, rejected (with the user's comment),
|
|
135
|
+
edited, or failed.
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 3.5 Native gate denial
|
|
139
|
+
|
|
140
|
+
```text
|
|
141
|
+
File changes must go through the review gate while Pre-review is on. Use
|
|
142
|
+
review_write (new file / full file) or review_patch (unified diff) with at
|
|
143
|
+
least one note per changed file; the plugin starts or reuses the review waiter
|
|
144
|
+
automatically; just continue. Never call review_wait from the main agent.
|
|
145
|
+
Shell commands are outside the review.
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 3.6 Per-file validation errors
|
|
149
|
+
|
|
150
|
+
Multi-file patch:
|
|
151
|
+
|
|
152
|
+
```text
|
|
153
|
+
AI explanations are on: add at least one note for each changed file.
|
|
154
|
+
Missing: <file1>, <file2>.
|
|
155
|
+
Turn off AI explanations in the input bar to queue without notes.
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Single-file write:
|
|
159
|
+
|
|
160
|
+
```text
|
|
161
|
+
AI explanations are on: add at least one note for this file. Use line-level
|
|
162
|
+
notes for user-requested, key or hard-to-understand changes. Turn off AI
|
|
163
|
+
explanations in the input bar to queue without notes.
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 3.7 UI strings (0.8.4)
|
|
167
|
+
|
|
168
|
+
```text
|
|
169
|
+
AI explanations
|
|
170
|
+
Require at least one note per changed file. Off: queue changes without notes.
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
```text
|
|
174
|
+
AI 解释
|
|
175
|
+
每个改动文件至少一条说明。关闭后排队不再要求解释。
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 4. The chain
|
|
181
|
+
|
|
182
|
+
```text
|
|
183
|
+
[input Review tools]
|
|
184
|
+
AI explanations toggle
|
|
185
|
+
│ setSettings({ aiExplain })
|
|
186
|
+
▼
|
|
187
|
+
[plugin host featureFlags]
|
|
188
|
+
│ system prompt + tool descriptions
|
|
189
|
+
▼
|
|
190
|
+
[main AI]
|
|
191
|
+
review_write / review_patch (notes)
|
|
192
|
+
│
|
|
193
|
+
▼
|
|
194
|
+
[host validation]
|
|
195
|
+
aiExplain on?
|
|
196
|
+
every changed file covered?
|
|
197
|
+
│
|
|
198
|
+
▼
|
|
199
|
+
[review state]
|
|
200
|
+
entries / notes / decisions / waitKey
|
|
201
|
+
│
|
|
202
|
+
├──────────────► [Code review tab]
|
|
203
|
+
│ diff + AI rows
|
|
204
|
+
│ Approve / Reject / Edit / Finish
|
|
205
|
+
│ │
|
|
206
|
+
│ ▼
|
|
207
|
+
│ host applies files
|
|
208
|
+
│
|
|
209
|
+
└──────────────► [ensureReviewWaiter]
|
|
210
|
+
scoped subagent tool → spawn child
|
|
211
|
+
child: review_wait(reviewId, waitKey)
|
|
212
|
+
│
|
|
213
|
+
▼
|
|
214
|
+
review finishes
|
|
215
|
+
│
|
|
216
|
+
▼
|
|
217
|
+
child returns per-file results
|
|
218
|
+
│
|
|
219
|
+
▼
|
|
220
|
+
parent completion → main agent wakes
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Steps
|
|
224
|
+
|
|
225
|
+
1. The user toggles **AI explanations** in the input bar; the client calls
|
|
226
|
+
`setSettings({ aiExplain })`; the host stores `featureFlags.aiExplain`.
|
|
227
|
+
2. The host injects the system prompt and the tool descriptions on the next turn.
|
|
228
|
+
3. The main agent calls `review_write` / `review_patch` with notes.
|
|
229
|
+
4. The host validates: when `aiExplain` is on, every changed file needs at least
|
|
230
|
+
one non-empty note; a multi-file patch names the missing files and refuses.
|
|
231
|
+
5. The change is staged in the review state; nothing is written to disk.
|
|
232
|
+
6. `ensureReviewWaiter` starts a waiter child through the agent-scoped
|
|
233
|
+
`subagent` tool (spawn), or reuses the persistent child with `sendMessage`.
|
|
234
|
+
7. The child calls `review_wait` with the reviewId and waitKey.
|
|
235
|
+
8. The user reviews in the Code review tab; **Finish** applies the files.
|
|
236
|
+
9. The child's `review_wait` returns the per-file outcomes; the child reports to
|
|
237
|
+
its parent; the main agent's next turn receives the result.
|
|
238
|
+
10. The next review reuses the same child; one persistent waiter per conversation.
|
|
239
|
+
|
|
240
|
+
### Endpoints and slots
|
|
241
|
+
|
|
242
|
+
- RPC: `POST /api/coding-enhanced` with `{ endpoint, payload }`
|
|
243
|
+
- Client slots: `conversation.input.right` (Review tools),
|
|
244
|
+
`conversation.chat.assistant-actions` (withdraw), review tab type,
|
|
245
|
+
`settings.section`, `plugins.bundle.config`.
|
|
246
|
+
- Host services: `tools`, `subagents`, `sessions`, `connection`, `systemPrompt`.
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## 5. Subagent design
|
|
251
|
+
|
|
252
|
+
### 5.1 spawn vs fork
|
|
253
|
+
|
|
254
|
+
| | spawn | fork |
|
|
255
|
+
|---|---|---|
|
|
256
|
+
| Tool | `subagent` | `subagent_fork` |
|
|
257
|
+
| Provider | `spawn` | `fork` |
|
|
258
|
+
| Child context | fresh; only the prompt | inherited completed conversation |
|
|
259
|
+
| Project understanding | needs a brief / reads files | has the conversation |
|
|
260
|
+
| Token cost | prompt + brief + output | inherited prefix (provider cache) + output |
|
|
261
|
+
| Isolation | high | lower |
|
|
262
|
+
| Use | review waiter; independent tasks | project-aware explanation; follow-ups |
|
|
263
|
+
|
|
264
|
+
### 5.2 What the waiter uses
|
|
265
|
+
|
|
266
|
+
**spawn.** The waiter only needs `reviewId` / `waitKey` and `review_wait`;
|
|
267
|
+
it does not need project detail. The child is persistent: the host stores
|
|
268
|
+
`reviewWaiters[sessionId]` and reuses it with `sendMessage`.
|
|
269
|
+
|
|
270
|
+
### 5.3 Why the parent explains, not a comment subagent
|
|
271
|
+
|
|
272
|
+
An earlier option (“Line AI B”) used a dedicated comment subagent. It was
|
|
273
|
+
dropped:
|
|
274
|
+
|
|
275
|
+
- the parent already has the full project and user intent;
|
|
276
|
+
- a fresh comment child needs a brief and still risks missing context;
|
|
277
|
+
- the parent's notes cost less than a second child context;
|
|
278
|
+
- the waiter child stays a pure `review_wait` observer.
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 6. Design decisions
|
|
283
|
+
|
|
284
|
+
- **The model writes; the host enforces.** Notes are required at the tool
|
|
285
|
+
boundary, not only in a prompt.
|
|
286
|
+
- **One explanation per changed file is the floor**, not the ceiling. Line-level
|
|
287
|
+
notes are recommended for user-requested, key or hard-to-understand changes.
|
|
288
|
+
- **No upper limit** on notes; the reviewer can ask for more.
|
|
289
|
+
- **The main agent cannot block.** `review_wait` is refused for the owner
|
|
290
|
+
session; only a child may wait.
|
|
291
|
+
- **One persistent waiter per conversation**, reused with `sendMessage`.
|
|
292
|
+
- **The gate covers native file tools**; shell writes are documented as outside
|
|
293
|
+
the review.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## 7. Caveats
|
|
298
|
+
|
|
299
|
+
- Shell commands can still write files outside the gate; a post-turn warning is
|
|
300
|
+
planned.
|
|
301
|
+
- The auto waiter uses the agent-scoped `subagent` tool; if the provider is
|
|
302
|
+
unavailable it falls back to a direct `spawn` activation, then to a manual
|
|
303
|
+
`review_wait` fallback.
|
|
304
|
+
- npm publishing uses Trusted Publishing (OIDC); the registry CDN may lag a few
|
|
305
|
+
minutes after the workflow succeeds.
|
|
306
|
+
- The review contract is versioned with the plugin; this document describes
|
|
307
|
+
0.8.4.
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## 8. Version history (review workflow)
|
|
312
|
+
|
|
313
|
+
| Version | Change |
|
|
314
|
+
|---|---|
|
|
315
|
+
| 0.6.0 | Non-blocking review waiter; per-file decisions |
|
|
316
|
+
| 0.7.0 | Gate coverage for `str_replace_editor` / `multi_edit` / `notebook_edit`; main `review_wait` refused; notes required; AI explanations toggle; wrap all rows |
|
|
317
|
+
| 0.8.0–0.8.2 | Plugin-owned persistent waiter via `ctx.subagents` (agent-scoped tool, `spawn`) |
|
|
318
|
+
| 0.8.3 | Parent-written explanations; per-file notes validation; comment subagent dropped |
|
|
319
|
+
| 0.8.4 | Copy fixes; this document |
|
package/lib/client.js
CHANGED
|
@@ -41,7 +41,7 @@ window.__ModuleLoader__.load({
|
|
|
41
41
|
reviewTools: 'Review tools',
|
|
42
42
|
autoReview: 'Pre-review',
|
|
43
43
|
aiExplain: 'AI explanations',
|
|
44
|
-
aiExplainDesc: 'Require
|
|
44
|
+
aiExplainDesc: 'Require at least one note per changed file. Off: queue changes without notes.',
|
|
45
45
|
autoReviewDesc: 'The agent must queue every edit with review_write / review_patch before it lands. Off: native write/edit.',
|
|
46
46
|
reviewFeatureOff: 'AI Change Review is off in Settings. Enable it first, then use this switch.',
|
|
47
47
|
reviewOn: 'On',
|
|
@@ -153,7 +153,7 @@ window.__ModuleLoader__.load({
|
|
|
153
153
|
reviewTools: 'Review 工具',
|
|
154
154
|
autoReview: 'AI 改动预审查',
|
|
155
155
|
aiExplain: 'AI 解释',
|
|
156
|
-
aiExplainDesc: '
|
|
156
|
+
aiExplainDesc: '每个改动文件至少一条说明。关闭后排队不再要求解释。',
|
|
157
157
|
autoReviewDesc: 'AI 的每次改动都必须先进入 review(review_write / review_patch)才能落盘。关闭后走原生 write/edit。',
|
|
158
158
|
reviewFeatureOff: '设置里的 AI Change Review 处于关闭状态,先启用后再用这个开关。',
|
|
159
159
|
reviewOn: '开',
|
package/lib/index.js
CHANGED
|
@@ -1445,7 +1445,7 @@ export function apply(ctx) {
|
|
|
1445
1445
|
|
|
1446
1446
|
ctx.tools.register(defineTool({
|
|
1447
1447
|
name: 'review_patch',
|
|
1448
|
-
description: 'Queue a unified diff for the user\'s review. The patch must use ---/+++ headers and @@ hunks with paths relative to the working directory; a/ and b/ prefixes and diff --git headers are accepted. Use one patch per file when possible; multiple files are allowed. This does not modify the workspace: the change is held in the Code review tab until the user finishes. At least one notes entry per changed file is required while AI explanations are on; prefer line-level notes (line/hunk) for user-requested, key or hard-to-understand changes. Each note is 1-2 sentences explaining why. The plugin starts or reuses the review waiter automatically; just queue and continue, and never call review_wait from the main agent. Example:\n--- a/src/app.ts\n+++ b/src/app.ts\n@@ -10,7 +10,9 @@\n const app = createApp()\n- app.use(oldRouter)\n+ app.use(newRouter)\n+ app.use(logger)\n app.listen(3000)
|
|
1448
|
+
description: 'Queue a unified diff for the user\'s review. The patch must use ---/+++ headers and @@ hunks with paths relative to the working directory; a/ and b/ prefixes and diff --git headers are accepted. Use one patch per file when possible; multiple files are allowed. This does not modify the workspace: the change is held in the Code review tab until the user finishes. At least one notes entry per changed file is required while AI explanations are on; prefer line-level notes (line/hunk) for user-requested, key or hard-to-understand changes. Each note is 1-2 sentences explaining why. The plugin starts or reuses the review waiter automatically; just queue and continue, and never call review_wait from the main agent. Example:\n--- a/src/app.ts\n+++ b/src/app.ts\n@@ -10,7 +10,9 @@\n const app = createApp()\n- app.use(oldRouter)\n+ app.use(newRouter)\n+ app.use(logger)\n app.listen(3000)',
|
|
1449
1449
|
parameters: {
|
|
1450
1450
|
patch: { type: 'string', required: true, description: 'A unified diff (---/+++/@@) to queue for review.' },
|
|
1451
1451
|
notes: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-coding-enhanced",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "The DSH change gate: queue AI edits before write, rewind turns with shadow-git snapshots, and hand review to a non-blocking waiter subagent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|