dsh-coding-enhanced 0.0.0-stage β†’ 0.5.15

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
@@ -1,3 +1,455 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
2
 
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.
3
+ # dsh-coding-enhanced
4
+
5
+ **Improve your coding experience with a stronger sense of control in [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness).**
6
+
7
+ Review every AI file change before it lands Β· Undo the last turn when it goes wrong
8
+
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
10
+ ![DSH](https://img.shields.io/badge/DSH-0.2.x-4d6bfe)
11
+ ![Platform](https://img.shields.io/badge/platform-Desktop%20%7C%20Web-2da44e)
12
+ ![Status](https://img.shields.io/badge/status-beta-orange)
13
+
14
+ </div>
15
+
16
+ ---
17
+
18
+ **`dsh-coding-enhanced` is a growing bundle of coding-workflow enhancements for DSH**, shipped as one installable plugin. It contains **two independent sub-features today**, and new sub-features are added over time.
19
+
20
+ | | Sub-feature | What it gives you |
21
+ |---|---|---|
22
+ | πŸ›‘οΈ | **AI Change Review** | The agent queues every change with `review_write` / `review_patch`; they accumulate in one right-sidebar tab, and `review_wait` blocks until you approve, reject with instructions, or edit them yourself. |
23
+ | ↩️ | **Turn Withdraw** | Restore the workspace to before the latest turn and cancel that round in the model's context. |
24
+
25
+ Both live in one bundle and work independently β€” install once, use either.
26
+
27
+ ---
28
+
29
+ <a id="sub-features"></a>
30
+
31
+ ## 🧩 Sub-features
32
+
33
+ ### πŸ›‘οΈ 1. AI Change Review
34
+
35
+ DSH agents normally write files as they go. With this sub-feature, changes are
36
+ **queued** instead: the agent proposes every edit, they accumulate in one review
37
+ tab, and nothing touches disk until you finish.
38
+
39
+ ```text
40
+ β”Œβ”€ Code review Β· 3 files ───────────────────────────────────┐
41
+ β”‚ src/app.ts +12 βˆ’3 [Approve] β”‚
42
+ β”‚ @@ -10,7 +10,9 @@ β”‚
43
+ β”‚ 10 10 const app = createApp() β”‚
44
+ β”‚ - 11 app.use(oldRouter) β”‚
45
+ β”‚ + 11 app.use(newRouter) β”‚
46
+ β”‚ + 12 app.use(logger) β”‚
47
+ β”‚ [Reject] [Edit] β”‚
48
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
49
+ β”‚ src/config.ts +2 βˆ’0 [Approve] β”‚
50
+ β”‚ ... β”‚
51
+ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
52
+ β”‚ [Approve all] [Reject all] 2 pending [ Finish ] β”‚
53
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
54
+ ```
55
+
56
+ **How it flows**
57
+
58
+ 1. The agent calls **`review_write`** (new file / full rewrite) or
59
+ **`review_patch`** (a unified diff for edits) for every change. These tools
60
+ only queue the proposal β€” they never write.
61
+ 2. All queued changes appear in the **same** right-sidebar review tab, even
62
+ when the agent proposes them across several steps.
63
+ 3. When it has finished proposing, the agent calls **`review_wait`**. That call
64
+ blocks until you finish; it is how the agent waits for your unified answer.
65
+ 4. You **Approve**, **Reject** (with instructions), or **Edit** each file, then
66
+ **Finish**. Approved and hand-edited files are written; rejected files are
67
+ not. `review_wait` returns one structured result per file
68
+ (`applied` / `rejected` + your instruction / `edited` / `failed`), so the
69
+ agent can revise in the same turn.
70
+ 5. While the input-bar **Review tools** switch is on, the agent is instructed
71
+ to use these tools, and native `write` / `edit` / `apply_patch` are refused
72
+ by the plugin's tool gate. Turning the switch off returns it to native
73
+ editing. Shell commands (`bash`, `sed`, …) are outside the review.
74
+
75
+ **Review tab**
76
+
77
+ - Opens as a **right-sidebar tab**, like a file preview β€” not a pop-up.
78
+ - **Unified diff** per file: line numbers, hunk headers, coloured added/removed
79
+ lines, and a `new` chip for created files.
80
+ - Per-file **Approve** / **Reject**, plus an instruction box.
81
+ - **Edit** the proposed content in place. An edited file becomes a third, yellow
82
+ **Edited** outcome and is applied automatically.
83
+ - **Floating toolbox** at the bottom-right: `Approve all`, `Reject all`, the
84
+ undecided count, and `Finish`.
85
+ - While the agent is still proposing, a banner says so and the per-file
86
+ decisions and `Finish` stay locked; they unlock when the agent calls
87
+ `review_wait`.
88
+ - **Close the tab** to cancel: nothing is written, and a waiting `review_wait`
89
+ returns "review closed".
90
+ - A `N files to review` pill brings the tab back if you close it while pending.
91
+
92
+ **What the model sees**
93
+
94
+ | Your action | File on disk | `review_wait` result |
95
+ |---|---|---|
96
+ | **Approve** | the proposed content | applied |
97
+ | **Reject** + instruction | nothing | rejected + your instruction |
98
+ | **Edit** + **Finish** | **your text** | applied (edited by user) |
99
+ | **Close the tab** | nothing | `status: "canceled"` |
100
+ | **Turn ends without `review_wait`** | β€” | the review is submitted automatically so you can still finish it |
101
+
102
+ The queue/tool pair is what makes multiple changes reviewable in one page: the
103
+ agent never blocks on the first edit, so it can propose the whole turn before
104
+ asking for your decision.
105
+
106
+ **One card per file.** Multiple `review_patch` / `review_write` calls that touch
107
+ the same file are merged into a single card: one net diff from the original file
108
+ to the latest queued content, and one Approve/Reject/Edit decision. When a file
109
+ already has queued content, the next patch is applied on top of it, so the card
110
+ always shows the cumulative change.
111
+
112
+ **Patches, not `old_string`.** `review_patch` takes a standard unified diff:
113
+
114
+ ```diff
115
+ --- a/src/app.ts
116
+ +++ b/src/app.ts
117
+ @@ -10,7 +10,9 @@
118
+ const app = createApp()
119
+ - app.use(oldRouter)
120
+ + app.use(newRouter)
121
+ + app.use(logger)
122
+ app.listen(3000)
123
+ ```
124
+
125
+ - The `@@ -10,7 +10,9 @@` header is the line range β€” no separate line counting.
126
+ - The host seeds a temporary git worktree with the **current queued content**
127
+ and applies each file section with `git apply --recount`, so context matching,
128
+ offsets, multi-hunk and multi-file patches all behave like git.
129
+ - A patch that does not apply is refused **at queue time**; nothing is staged.
130
+ - Paths are relative to the working directory (`a/` / `b/` prefixes optional).
131
+ Deletes, renames, copies, binary patches and paths outside the working
132
+ directory are refused β€” use `review_write` for those cases.
133
+
134
+ ### ↩️ 2. Turn Withdraw
135
+
136
+ The last turn wrote something you did not want? Undo it in one click.
137
+
138
+ > **Deep dive:** [docs/withdraw.md](docs/withdraw.md) explains the function-level
139
+ > flow and the shadow-git repository separately. In one sentence: withdraw does
140
+ > not delete the turn β€” it restores the workspace from a shadow-git tree and
141
+ > appends one model-only surface replacement, while the append-only log keeps
142
+ > the original turn.
143
+
144
+ - **Snapshot at turn start** β€” a shadow git repository under
145
+ `$DSH_HOME/coding-enhanced` records the working directory before the turn's
146
+ first tool runs. It never writes into your repository.
147
+ - **Persisted across restarts** β€” snapshots are stored per turn in
148
+ `state.json` together with a git ref that keeps every retained tree alive.
149
+ Reinstalling or restarting the plugin no longer loses the withdraw mapping.
150
+ - **Multi-turn rewind** β€” the last **10** turns (configurable, 1–50) stay
151
+ withdrawable. Withdrawing turn *N* restores the workspace to before *N* and
152
+ cancels turns *N* through the latest in the model's context; the transcript
153
+ greys all of them. The action on older turns says **Withdraw from here** and
154
+ warns that later turns are canceled too.
155
+ - **Restore on withdraw** β€” modified, created and deleted files, symlinks and
156
+ executable bits all return to their pre-turn state.
157
+ - **Nested git repositories are included** β€” each one gets its own shadow
158
+ repository; its working files (excluding `.git`) are snapshotted and restored
159
+ too. Turn the *Snapshot nested git repositories* setting off to leave them
160
+ untouched; either way the response tells you which paths were skipped.
161
+ - **Cleanup** β€” snapshots beyond the retention count are dropped; `autoGc`
162
+ compacts the shadow repositories after pruning/withdrawing, and **Clean up
163
+ now** forces a compaction of every shadow repository.
164
+ - **Cancel the round** β€” the hidden turns are removed from the model's context
165
+ via a model-only surface replacement, while the append-only transcript keeps
166
+ them; their markers show `已撀销` and the restored file count.
167
+ - Only **completed** turns are withdrawable; an active turn shows a disabled
168
+ action.
169
+
170
+
171
+ ---
172
+
173
+ <a id="quick-start"></a>
174
+
175
+ ## πŸš€ Quick start
176
+
177
+ ### 1. Install
178
+
179
+ **DSH Desktop β€” Plugins panel (recommended)**
180
+
181
+ 1. Download `dsh-coding-enhanced-<version>.tgz` from the repository's
182
+ **Releases** page (or build it with `npm run pack`).
183
+ 2. Open **Plugins β†’ Add plugin**.
184
+ 3. Paste the tarball's absolute path (or its URL).
185
+ 4. **Install** β†’ **Enable now**.
186
+
187
+ **From GitHub (fastest)**
188
+
189
+ 1. Open **Plugins β†’ Add plugin**.
190
+ 2. Paste the repository URL:
191
+ `https://github.com/hello-2021/dsh-coding-enhanced`
192
+ 3. **Install** β†’ **Enable now**.
193
+
194
+ ```sh
195
+ dsh plugin --profile desktop add https://github.com/hello-2021/dsh-coding-enhanced
196
+ ```
197
+
198
+ DSH treats a GitHub repository URL as a git spec: it checks the repository with
199
+ `git ls-remote`, then pnpm clones the default branch. The package ships its
200
+ built `lib/`, so no build step is needed. A git install tracks the default
201
+ branch at install time and updates by uninstalling/reinstalling (the page has no
202
+ Versions section for git installs).
203
+
204
+ **Pinned release tarball** β€” download a `dsh-coding-enhanced-<version>.tgz`
205
+ from [Releases](https://github.com/hello-2021/dsh-coding-enhanced/releases) and
206
+ paste its URL; use this when you want a fixed version:
207
+
208
+ ```sh
209
+ dsh plugin --profile desktop add https://github.com/hello-2021/dsh-coding-enhanced/releases/download/v<version>/dsh-coding-enhanced-<version>.tgz
210
+ ```
211
+
212
+ > **npm install by name is prepared but not published.** The unscoped name
213
+ > `dsh-coding-enhanced` is currently free; see **Publishing** below.
214
+
215
+ **CLI (local tarball)**
216
+
217
+ ```sh
218
+ dsh plugin --profile desktop add /path/to/dsh-coding-enhanced-<version>.tgz
219
+ ```
220
+
221
+ **Development link** β€” in the same Add plugin dialog, use the absolute path of
222
+ this directory. DSH installs a link, so source edits apply on the next
223
+ recomposition or restart.
224
+
225
+ **Install by package name (npm)**
226
+
227
+ The package is **not on npm yet**; the unscoped name `dsh-coding-enhanced` is
228
+ currently free. Once published with `npm publish --access public`, the Add
229
+ plugin box accepts the bare name `dsh-coding-enhanced` (and
230
+ `dsh plugin add dsh-coding-enhanced` works).
231
+
232
+ **Discover / plugin market**
233
+
234
+ DSH's **Discover** tab is a reader for plugin **index JSON** files; the app does
235
+ not ship a central community catalog. Official entries are built into DSH;
236
+ third-party plugins become discoverable by publishing an index and sharing its
237
+ URL. This repository ships a format-1 index pinned to the v0.5.15 commit:
238
+
239
+ 1. Enable **Plugins β†’ More β†’ Experimental plugins β†’ Custom plugin indexes**.
240
+ 2. Open **Discover β†’ Add index source** and paste:
241
+ `https://raw.githubusercontent.com/hello-2021/dsh-coding-enhanced/main/market/index.json`
242
+ 3. Install **Coding Enhanced** from the index.
243
+
244
+ The index installs the pinned git commit, so it works before the package is on
245
+ npm. Regenerate it for a release with
246
+ `node scripts/market-index.mjs v<version>`.
247
+
248
+ ### 2. Choose features
249
+
250
+ Open **Settings β†’ Coding Enhanced** (the same controls appear on the plugin's page in the **Plugins** tab):
251
+
252
+ | Setting | Default | What it does |
253
+ |---|---|---|
254
+ | **AI Change Review** | on | the queued review gate for `review_write` / `review_patch` |
255
+ | **Turn Withdraw** | on | turn-start snapshots and the withdraw action |
256
+ | **Turns kept for withdraw** | 10 | how many recent turns stay withdrawable (1–50) |
257
+ | **Snapshot nested git repositories** | on | include nested repositories' working files (excluding `.git`) |
258
+ | **Automatic cleanup** | on | run `git gc` on shadow snapshots after pruning or withdrawing |
259
+ | **Clean up now** | β€” | prune extra snapshots and compact every shadow repository |
260
+
261
+ Settings apply immediately and persist in `$DSH_HOME/coding-enhanced/settings.json`.
262
+
263
+ ### 3. Review tools switch
264
+
265
+ Next to the model selector at the bottom-right of the message input, the shield
266
+ button opens **Review tools**:
267
+
268
+ | Auto review | What the agent gets |
269
+ |---|---|
270
+ | **on** | a system-prompt instruction to queue every edit with `review_write` / `review_patch`, then call `review_wait` and wait; the review tools are available |
271
+ | **off** | the review tools are not exposed; the agent uses normal `write` / `edit` |
272
+
273
+ This is a convenience switch, separate from **Settings β†’ Coding Enhanced β†’ AI
274
+ Change Review** (which enables the review tab and withdraw surfaces). More
275
+ review switches will be added to the same popover.
276
+
277
+ ### 4. Use the review gate
278
+
279
+ Ask the agent to change files β†’ it queues them with `review_write` / `review_patch` β†’ the **Code review** tab opens β†’ decide per file
280
+ β†’ **Finish**.
281
+
282
+ ### 5. Use withdraw
283
+
284
+ Click the undo icon in the assistant action row on the latest completed turn β†’
285
+ confirm.
286
+
287
+ > Uninstall at any time from **Plugins β†’ dsh-coding-enhanced β†’ Remove**. Your
288
+ > `$DSH_HOME/coding-enhanced` state is left in place.
289
+
290
+ ---
291
+
292
+ <a id="how-it-works"></a>
293
+
294
+ ## 🧠 How it works
295
+
296
+ <details>
297
+ <summary><b>Review gate pipeline</b></summary>
298
+
299
+ ```text
300
+ assistant message
301
+ β”‚ host stages one entry per write/edit
302
+ β–Ό
303
+ tools/pre-execute ── waits for your decision
304
+ β”‚
305
+ β”œβ”€β”€ Approve ──► tool runs normally
306
+ β”œβ”€β”€ Edit ──► tool runs, then post-execute writes your text
307
+ β”œβ”€β”€ Reject ──► deny + your instruction
308
+ └── Close ──► deny + "wait for the user"
309
+ ```
310
+
311
+ - **Host** (`lib/index.js`) listens to `assistant/message` to stage entries,
312
+ gates `write` / `edit` in `tools/pre-execute`, and applies edited content in
313
+ `tools/post-execute`. It serves `/api/coding-enhanced` over the authenticated
314
+ DSH `/api` bridge.
315
+ - **Browser** (`lib/client.js`) registers a page type with
316
+ `ctx.sidebarRightTabs` and its body with `sidebar.right.pane.tab`, plus a
317
+ watcher that opens the tab and the reopen pill.
318
+ - **Transport** inherits the bridge's loopback/Origin fence, cookie auth and
319
+ owner-Peer guard.
320
+
321
+ </details>
322
+
323
+ <details>
324
+ <summary><b>Withdraw pipeline</b></summary>
325
+
326
+ - A shadow git repository per workspace lives under
327
+ `$DSH_HOME/coding-enhanced/repos`. It is initialized on the first turn and
328
+ refreshed with `git add -A` at every turn start; the first tool call waits for
329
+ the snapshot.
330
+ - Withdraw diffs the current tree against the snapshot and restores every
331
+ changed path.
332
+ - The round is canceled with a model-only `user/message` surface replacement
333
+ covering its surface nodes. It must be a `user/message` because
334
+ `developer/message` is step-scoped and the replay validator rejects it after
335
+ `turn/end`; [docs/withdraw.md](docs/withdraw.md#7-why-the-old-implementation-corrupted-the-session)
336
+ walks through the exact failure.
337
+ - State lives in `$DSH_HOME/coding-enhanced/state.json`; old `withdraw-round`
338
+ directories are migrated automatically.
339
+
340
+ </details>
341
+
342
+ ---
343
+
344
+ <a id="limits"></a>
345
+
346
+ ## ⚠️ Limits
347
+
348
+ - While **AI Change Review** and the input-bar **Auto review** switch are on,
349
+ native `write` / `edit` / `apply_patch` are refused by the plugin's
350
+ `tools/pre-execute` policy; the agent must use `review_write` /
351
+ `review_patch`. Turning Auto review off allows native editing again. Shell
352
+ commands (`bash`, `sed`, `rm`, …) are not intercepted.
353
+ - **Editable text is capped at 200 KiB** per file. Binary and larger files are
354
+ review-only.
355
+ - **A pending review lives on the Host.** A page reload reopens it; a Host
356
+ restart drops it together with the blocked turn.
357
+ - **Withdraw covers retained turns** (`keepTurns`, default 10). Older snapshots
358
+ are pruned. Files matching the default excludes (`.git/`, `node_modules/`,
359
+ `.DS_Store`, `.dsh-coding-enhanced/`) are not snapshotted. Nested repositories
360
+ are snapshotted only while *Snapshot nested git repositories* is on; a nested
361
+ repository created during the turn is left in place and reported as skipped.
362
+ - **Web UI required.** The review tab needs the Desktop or `dsh web` profile;
363
+ headless and tui profiles have no review surface.
364
+ - **Feature switches** live in Settings β†’ Coding Enhanced and are stored in the
365
+ DSH home, not in the profile's YAML configuration.
366
+ - Two edits to the same file in one message are previewed cumulatively, in call
367
+ order.
368
+ - **Review view typography is relative** (`em`) and follows the application's
369
+ base font size; it is deliberately larger than the old fixed-pixel layout.
370
+
371
+ ---
372
+
373
+ <a id="roadmap"></a>
374
+
375
+ ## πŸ—ΊοΈ Roadmap
376
+
377
+ The bundle is intentionally a home for **more coding-workflow sub-features**.
378
+ Planned directions (not commitments):
379
+
380
+ - review coverage for `apply_patch` and shell edits;
381
+ - side-by-side diff mode and per-file folding;
382
+ - review history per session (reopen a finished review);
383
+ - per-project review policy (auto-approve patterns);
384
+ - redo for withdrawn turns.
385
+
386
+ Have an idea? Open an issue.
387
+
388
+ ---
389
+
390
+ <a id="development"></a>
391
+
392
+ ## πŸ› οΈ Development
393
+
394
+ No build step:
395
+
396
+ ```text
397
+ lib/index.js Host plugin (ESM)
398
+ lib/client.js Browser bundle (prebuilt lazy-CJS, served by dsh-client-modules)
399
+ docs/withdraw.md Turn withdraw mechanism (project + shadow-git views)
400
+ cordis.patch.yml Bundle layer (inserts the coding-enhanced row)
401
+ ```
402
+
403
+ ```sh
404
+ npm run pack # dist/dsh-coding-enhanced-<version>.tgz
405
+ ```
406
+
407
+ For fast iteration, install this directory as a **link** through
408
+ **Plugins β†’ Add plugin** and edit the source directly. When using the tarball
409
+ workflow, rebuild and reinstall after each change.
410
+
411
+ ### Publishing
412
+
413
+ The npm name is free but the package is not published yet. Two ways:
414
+
415
+ ```sh
416
+ npm login
417
+ npm publish --access public
418
+ ```
419
+
420
+ or add a repository secret `NPM_TOKEN` (an npm automation/granular token with
421
+ publish rights); `.github/workflows/npm-publish.yml` publishes on every `v*` tag
422
+ and on manual dispatch. Without the secret that workflow fails.
423
+
424
+ After a release, regenerate the market index and commit it:
425
+
426
+ ```sh
427
+ node scripts/market-index.mjs v<version>
428
+ ```
429
+
430
+ ---
431
+
432
+ <a id="release"></a>
433
+
434
+ ## πŸ“¦ Release
435
+
436
+ ```sh
437
+ npm run pack
438
+ git tag v<version>
439
+ git push origin main --tags
440
+ ```
441
+
442
+ The `release` workflow packs the tarball and attaches it to the GitHub release
443
+ for any `v*` tag.
444
+
445
+ ---
446
+
447
+ ## πŸ”’ Privacy
448
+
449
+ Everything runs locally. No network calls, no telemetry, no external services.
450
+ State stays in `$DSH_HOME/coding-enhanced`; review content is served only over
451
+ the authenticated local `/api` bridge.
452
+
453
+ ## πŸ“„ License
454
+
455
+ [MIT](LICENSE) Β© dsh-coding-enhanced contributors
@@ -0,0 +1,5 @@
1
+ # Bundle layer for dsh-coding-enhanced. The manager selects this bundle by
2
+ # package name; the loader resolves the row to the package's main entry.
3
+ - insert:
4
+ - id: coding-enhanced
5
+ name: dsh-coding-enhanced