dsh-seal-scripts 0.5.2 → 0.6.1

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.en.md CHANGED
@@ -7,326 +7,379 @@
7
7
  [![version](https://img.shields.io/npm/v/dsh-seal-scripts?color=4a7cff)](https://www.npmjs.com/package/dsh-seal-scripts)
8
8
  [![license](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
9
9
  [![node](https://img.shields.io/badge/node-%3E%3D18-339933)](https://nodejs.org)
10
- [![dsh](https://img.shields.io/badge/dsh-%3E%3D0.2.1--rc.2%20%3C1.0.0-6f42c1)](https://github.com/deepseek-ai/dsh)
10
+ [![dsh](https://img.shields.io/badge/dsh-%3E%3D0.2.2--rc.1%20%3C1.0.0-6f42c1)](https://github.com/deepseek-ai/dsh)
11
11
  [![deps](https://img.shields.io/badge/runtime%20deps-0-brightgreen)](./package.json)
12
12
 
13
- **Sealed scripts are the point of this plugin.** A command chain that just worked is sealed on the spot into an executable tool script: a directory, a manifest, one line in the system prompt. Next time it runs with a single sentence — no re-deriving commands, no rewriting the script, no asking you to repeat yourself.
13
+ **Sealed scripts**: a chain that just worked is sealed into a tool script — a directory, a manifest entry, one line in the system prompt; next time it runs with a single sentence.
14
14
 
15
- **Reviews are the base layer.** When DSH compacts the context, the shadowed transcript is written to disk as a review file, decays by calendar day, and is injected into context; when details matter, the model reads the original back from a clue. Reviews are also the raw material for sealing a workflow from an earlier session.
15
+ **Reviews**: when DSH compacts the context, the shadowed transcript is written to a review file, decays by calendar day and is injected back; the model can read the original from a clue. Reviews are also the raw material for sealing across sessions.
16
16
 
17
17
  ## Contents
18
18
 
19
- - [Features](#features)
20
- - [Install](#install)
21
- - [Quick start](#quick-start)
22
- - [Sealed scripts](#sealed-scripts)
23
- - [Reviews](#reviews-and-context-memory)
24
- - [Configuration](#configuration)
25
- - [Settings page](#settings-page)
26
- - [Data and backup](#data-and-backup)
27
- - [Compatibility](#compatibility-and-degradation)
28
- - [Known limitations](#known-limitations)
29
- - [Development](#development)
19
+ - [Features](#sec-features)
20
+ - [Install](#sec-install)
21
+ - [Quick start](#sec-quickstart)
22
+ - [Sealed scripts](#sec-tools)
23
+ - [Session management](#sec-sessions)
24
+ - [Reviews](#sec-reviews)
25
+ - [Configuration and settings page](#sec-config)
26
+ - [Data and backup](#sec-data)
27
+ - [Compatibility and degradation](#sec-compat)
28
+ - [Known limitations](#sec-limits)
29
+ - [Development](#sec-dev)
30
+
31
+ <a name="sec-features"></a>
30
32
 
31
33
  ## Features
32
34
 
33
- **Sealed scripts**
35
+ #### Sealed scripts
36
+
37
+ - **One chain → one tool script**: full script text, entry, args, steps, provenance, per-file sha256.
38
+ - **In the system prompt**: the toolSequence block lists every sealed tool, one line each.
39
+ - **Runs as written**: args as an argv array, never through a shell; interpreter chosen by the run field.
40
+ - **Verifiable**: sha256 compared before running; a hand-edited script is refused unless explicitly allowed.
41
+ - **Portable**: store-only zip; import previews first, index rebuilt from the files on disk.
34
42
 
35
- - **One working chain → one tool script**: full script text, entry, args, steps, provenance and a per-file sha256, written in one go.
36
- - **Present in the system prompt**: the tool list sits at the end of the prompt every turn (up to 24 entries), so the model knows what it can run.
37
- - **Runs as written**: arguments travel as an argv array and never pass through a shell; the interpreter comes from the run field (bash / node / powershell / cmd).
38
- - **Verifiable**: per-file sha256 is compared before running; a hand-edited script is refused unless you explicitly allow it.
39
- - **Portable**: the whole set packs into a store-only zip; import previews before writing and rebuilds the index from the files on disk.
43
+ #### Context reviews
40
44
 
41
- **Context reviews**
45
+ - **Captured on compaction**: no model call; tool calls and arguments kept verbatim.
46
+ - **Four-level decay**: original → summary → diary → keywords; a read bumps and pins the level.
47
+ - **Cross-workspace search**: workspace → children → siblings → parents; outer rings need permission.
48
+ - **Diary nudges**: asked once when the diary or keywords are empty.
42
49
 
43
- - **Written on compaction**: pure code, no model call; tool calls and their arguments are kept verbatim.
44
- - **Four-level decay**: today original → next-day summary → diary → keyword index; reading it bumps one level and pins it.
45
- - **Cross-workspace search**: this workspace → children → siblings → parents; outer rings need explicit permission.
46
- - **Diary nudges**: while keywords or the diary are still empty the model is asked to finish them in one call; the nudge disappears once they are written.
50
+ #### Engineering
47
51
 
48
- **Engineering**
52
+ - Zero runtime dependencies, Node built-ins only; UI and injected text follow DSH's 8 languages, model-facing errors and receipts are English.
53
+ - A missing host capability disables that block only.
54
+ - Plain-text data: copy `session-memory/` for a backup.
49
55
 
50
- - Zero runtime dependencies, Node built-ins only. The UI and injected text follow DSH's 8 languages (中文 / English / 日本語 / Español / Français / Deutsch / Русский / Português); model-facing errors and receipts are in English.
51
- - A missing host capability disables that block only — no crash, no blank settings page.
52
- - Plain-text data: copy `session-memory/` and you have a backup.
56
+ <a name="sec-install"></a>
53
57
 
54
58
  ## Install
55
59
 
56
- Add the package in the DSH plugin manager (package name, absolute local path, tarball, or Git URL):
60
+ Add the package in the plugin manager (package name, local path, tarball, or Git URL). `--profile` is required, e.g. `web`:
57
61
 
58
62
  ~~~bash
59
- # --profile is required (otherwise: required option "--profile" not specified)
60
63
  dsh plugin --profile web add dsh-seal-scripts
61
-
62
- # local directory: pnpm records it as a link dependency in that profile
63
64
  dsh plugin --profile web add /path/to/dsh-seal-scripts
64
65
  ~~~
65
66
 
66
- Or use Settings → Plugins → Add with a package name, absolute path, tarball, or Git URL. Restart the profile after installing.
67
+ The second line is a local directory, registered as a link dependency. Restart the profile to load it.
67
68
 
68
- Requirements:
69
-
70
- - host `@deepseek-ai/dsh` `>=0.2.1-rc.2`, `<1.0.0` (peer dependency, not forced)
71
- - Node `>=18` (without native zstd the built-in decoder takes over; functionality is unchanged)
69
+ Requirements: host `@deepseek-ai/dsh` `>=0.2.2-rc.1`, `<1.0.0` (peer, not forced); Node `>=18`.
72
70
 
73
71
  After the restart, Settings shows **Tool (script) manager**.
74
72
 
73
+ <a name="sec-quickstart"></a>
74
+
75
75
  ## Quick start
76
76
 
77
- 1. **Open the master switch**: Settings → Tool (script) manager → Options → turn on **Auto review**. It is off by default; without it no review is created and cross-session sealing has no raw material.
78
- 2. **Run a chain end to end**: scrape a page, transcode, pack, connect over SSH — anything that really worked and that you will need again.
77
+ 1. **Master switch**: Settings → Tool (script) manager → Options → turn on **Auto review** (off by default; nothing is created while off).
78
+ 2. **Run a chain end to end**.
79
79
  3. **Seal it**: ask the model to turn the steps above into a tool.
80
- 4. **Reuse it**: ask it to run `<id>`; add show me the commands first, do not run to preview.
81
-
82
- A sample session (output is illustrative):
80
+ 4. **Reuse it**: "run <id>"; add "show me the commands first, do not run" to preview.
83
81
 
84
82
  ~~~text
85
83
  You: turn that packaging flow into a tool
86
- Model: (calls session_tool_create_write) installed tool script dsh-plugin-pack at .../toolSequence/dsh-plugin-pack
87
- entry pack.sh, params source_dir out_dir; it enters the system prompt on the next assembly.
84
+ Model: (session_tool_create_write) installed dsh-plugin-pack at .../toolSequence/dsh-plugin-pack
85
+ entry pack.sh, params source_dir out_dir
88
86
 
89
87
  (new session)
90
- You: run dsh-plugin-pack, the source dir is /sdcard/Download/dsh-seal-scripts-0.4.6
91
- Model: (calls session_tool_call) exit 0, N files, sha256 matches the manifest
88
+ You: run dsh-plugin-pack, the source dir is /sdcard/Download/my-src
89
+ Model: (session_tool_call) exit 0, N files, sha256 matches the manifest
92
90
  ~~~
93
91
 
92
+ <a name="sec-tools"></a>
93
+
94
94
  ## Sealed scripts
95
95
 
96
- ### Why this is not a note
96
+ #### Why this is not a note
97
97
 
98
- Models are good at writing markdown about a method, and the note cannot run. They are also good at rebuilding commands on the spot, slightly differently each time. The artifact here is the script itself: the lines that worked, stored byte for byte, argument order included.
98
+ A note cannot run, and rebuilding commands on the spot differs every time. What gets stored is the script itself: the lines that worked, byte for byte, argument order included.
99
99
 
100
- ### How to trigger it
100
+ #### How to trigger it
101
101
 
102
102
  | What you say | What happens | When to use |
103
103
  |---|---|---|
104
104
  | turn the steps above into a tool | seals the steps that just ran | same session, commands still in context |
105
- | turn the workflow from an earlier session into a tool | reads review originals first with `session_tool_create_read` (every tool call and its arguments), then seals | new session, new machine, old history |
105
+ | turn the workflow from an earlier session into a tool | reads review originals first with `session_tool_create_read`, then seals | new session, new machine, old history |
106
106
 
107
- The chain must have worked. What gets stored is the version that ran, not a draft — editing after installing means re-sending the whole context.
107
+ The version that ran is stored, not a draft; editing after installing means re-sending the context.
108
108
 
109
- ### What gets created
109
+ #### What gets created
110
110
 
111
111
  ~~~
112
112
  $DSH_HOME/session-memory/toolSequence/
113
113
  _index.json registry: id, title, purpose, entry, args, steps, per-file sha256
114
114
  <id>/
115
- toolScript.json manifest: full script text, docs, hashes, provenance (review file + line)
115
+ toolScript.json manifest: full script text, docs, hashes, provenance
116
116
  <script> the file that actually runs (.sh / .js .mjs .cjs / .ps1 / .bat .cmd)
117
- README.md generated from the manifest at install time, for humans
118
- <notes>.md read-only notes: pitfalls, paths, benchmarks (never executed)
119
- _runs/ full stdout/stderr log of every run (not only when over a cap)
117
+ README.md generated from the manifest
118
+ <notes>.md read-only notes (never executed)
119
+ _runs/ full stdout/stderr log of every run
120
120
  <id>.bak-<timestamp>/ previous directory kept on reinstall or import
121
121
  ~~~
122
122
 
123
- ### How the model learns about it
123
+ #### How the model learns about it
124
124
 
125
- The end of the system prompt gains a toolSequence block: every sealed toolScript is listed (0.4.11 removed the entry and character caps), one line each — `· id (title): purpose|entry <entry>|args <p1> <p2>`. The purpose is shown in full. After sealing you never have to remind the model that the tool exists.
126
-
127
- When that list refreshes (option **When the list is refreshed**):
125
+ The system prompt gains a toolSequence block, one line each: `· id (title): purpose|entry <entry>|args <p1> <p2>`. No entry or character cap; purpose shown in full.
128
126
 
129
127
  | Mode | Behaviour | Cost |
130
128
  |---|---|---|
131
- | Before a new session (default) | computed once at the first assembly, then fixed until the session ends | installing or removing a tool mid-session leaves the prompt unchanged |
132
- | Live per session | computed every turn | one cache miss on the next message (the whole session is resent) |
129
+ | Before a new session (default) | computed at the first assembly, fixed until the session ends | installing or removing a tool mid-session leaves the prompt unchanged |
130
+ | Live per session | computed every turn | one cache miss on the next message |
133
131
 
134
- Changing that mode refreshes every remembered session to the current list — so there is a defined way out of the current session does not see the new tool case.
132
+ Changing the mode refreshes every remembered session immediately.
135
133
 
136
- ### The three tools
134
+ #### The three tools
137
135
 
138
136
  | Tool | Purpose | Key arguments |
139
137
  |---|---|---|
140
138
  | `session_tool_create_write` | seal a chain | `toolScript{ id, title, purpose, entry, scripts[], docs[], params, steps, timeoutMs }`; `replace` overwrites |
141
- | `session_tool_create_read` | read review originals (tool calls and results included), read-only | `file` or `date`+`nth`; `mode` = outline / raw / block; `cursor`, `chars` paging; `line`, `span` for one call |
139
+ | `session_tool_create_read` | read review originals, read-only | `file` or `date`+`nth`; `mode` = outline / raw / block; `cursor`, `chars`, `line`, `span` |
142
140
  | `session_tool_call` | run as written | `toolScript`, `step`, `args`, `stdin`, `cwd`, `dryRun`, `calls`, `stopOnError`, `allowDrift`, `timeoutMs`, `maxOutputBytes` |
143
141
 
144
- - Calling `session_tool_call` without arguments lists every tool script.
145
- - `dryRun: true` echoes the arguments and cwd without running.
146
- - `calls: []` runs the entries in order (no 20-entry cap since 0.4.11), reporting exit code, duration, stdout and stderr per entry.
142
+ - No arguments: lists every tool script.
143
+ - `dryRun: true`: echoes the arguments and cwd only.
144
+ - `calls: []`: runs in order, no count limit, reporting exit code, duration and logs per entry.
147
145
 
148
- ### Validation when sealing
146
+ #### Validation when sealing
149
147
 
150
148
  | Item | Rule |
151
149
  |---|---|
152
- | `id` | starts with a lowercase letter, 2–41 chars, only `a-z0-9-` |
153
- | file name | starts alphanumeric, no leading dot, no path separators, up to 61 chars |
150
+ | `id` | starts with a lowercase letter, only `a-z0-9-`, no length limit |
151
+ | file name | starts alphanumeric, letters, digits and . _ - only, no paths, no leading dot |
154
152
  | `run` vs extension | bash→`.sh`; node→`.js/.mjs/.cjs`; ps1→`.ps1`; cmd→`.bat/.cmd` |
155
- | size | no cap (0.4.11 removed the 64 KB and 512 KB limits) |
156
- | `title` / `purpose` | non-empty; any length, shown in full in the prompt |
157
- | `entry` / `steps` | must name files in `scripts`; entry defaults to the first script |
158
- | `timeoutMs` | any positive ms, clamped at run time to the host maxTimeoutMs |
159
- | docs | must be `.md`, may not be called `README.md`, no duplicates |
160
- | script body | non-empty; must not contain `<!--ovr:` (it would break review markers) |
153
+ | size | no cap |
154
+ | `title` / `purpose` | non-empty; any length |
155
+ | `entry` / `steps` | must name files in `scripts`; entry defaults to the first |
156
+ | `timeoutMs` | any positive ms, clamped to the host maxTimeoutMs, defaults to the host timeoutMs |
157
+ | docs | must be `.md`, not `README.md`, no duplicates |
158
+ | script body | non-empty; must not contain `<!--ovr:` |
161
159
  | same id exists | refused without `replace`; the error quotes the first 12 hex chars of the manifest sha256 |
162
160
 
163
- `steps` only declares pipeline order and never runs anything by itself; `params` only declares argv order and names are not validated.
161
+ `steps` only declares order and never chains; `params` only declares argv order and names are not validated.
164
162
 
165
- ### Execution semantics
163
+ #### Execution semantics
166
164
 
167
165
  | Item | Value |
168
166
  |---|---|
169
- | interpreter | bash→`bash` from PATH; node→current `process.execPath`; ps1→Windows PowerShell (or `pwsh` elsewhere); cmd→`%ComSpec% /d /c` (falls back to `sh` off Windows) |
170
- | argv | interpreter arguments + absolute script path + your args, passed as an array, never through a shell |
171
- | cwd | `workspace` (session workspace), `toolScript` (the script directory), or an absolute path inside either |
167
+ | interpreter | bash; node uses `process.execPath`; ps1 uses Windows PowerShell (`pwsh` elsewhere); cmd uses `%ComSpec% /d /c` (falls back to `sh` off Windows) |
168
+ | argv | interpreter args + absolute script path + args, as an array, never through a shell |
169
+ | cwd | `workspace`, `toolScript`, or an absolute path inside either |
172
170
  | environment | inherits `process.env`, plus `TOOL_NAME`, `TOOL_SCRIPT`, `TOOL_ROOT`, `DSH_HOME` |
173
- | timeout | follows the DSH terminal settings (120 s default, capped by DSH maxTimeoutMs); on expiry the process is NOT killed, it moves to the background and the reply carries pid and the log path; explicit stop: SIGTERM → 2 s → SIGKILL; process group on POSIX, `taskkill /T /F` on Windows |
174
- | output | defaults to DSH maxOutputBytes, no extra 1 MB ceiling; stdout/stderr go straight into `_runs/` and the reply carries the head plus the file path, and overflow is never dropped |
175
- | result | `{ exitCode, signal, timedOut, stdout, stderr, truncated, spill }`; success is not judged for the caller |
176
- | argument count | more arguments than `params` declares fails before running (they would shift); fewer is fine |
177
- | drift | sha256 is compared first; mismatch refuses, `allowDrift: true` allows it and marks the result |
178
- | containment | only files inside the tool script directory run; a script name missing from the manifest is refused |
171
+ | timeout | follows the DSH terminal settings (120 s default, capped by maxTimeoutMs); on expiry it moves to the background and the reply carries pid and the log path; explicit stop: SIGTERM → 2 s → SIGKILL; process group on POSIX, `taskkill /T /F` on Windows |
172
+ | output | DSH maxOutputBytes; every run written to `_runs/` and the reply carries the file path |
173
+ | result | `{ exitCode, signal, timedOut, background, pid, logFile, stdout, stderr, truncated, spill }` |
174
+ | argument count | more than `params` declares fails before running; fewer is fine |
175
+ | drift | sha256 compared first; mismatch refuses, `allowDrift: true` allows it and marks `drift` |
176
+ | containment | only files inside the script directory run; unknown script names refused |
177
+
178
+ #### Import / export
179
+
180
+ - **Export**: Sealed tools tab → Export. Packs `toolSequence.zip` (store) into the session workspace and returns the path — no browser download.
181
+ - **Import**: pick a zip → `dryRun` preview → confirm to write; an existing directory is kept as `.bak-<timestamp>`.
182
+ - `_index.json` in the package is not trusted; the index is rebuilt from disk. `_runs`, backups, escaping paths and invalid ids are skipped.
183
+ - No size cap; the zip-bomb guard compares extracted bytes + 16 MB against free disk space. zip64 and encrypted archives are not supported.
184
+
185
+ #### Clear cache
186
+
187
+ Two clicks (the first only changes the button label):
188
+
189
+ - **Deleted**: `<id>.bak-<timestamp>` rollback directories, every log in `_runs/`.
190
+ - **Kept**: `_index.json` and every `<id>/` directory.
191
+ - Only "valid id + `.bak-` + digits" directories count; a staged import package is skipped.
192
+ - One entry that cannot be removed does not abort the run; the receipt reports counts and bytes.
193
+
194
+ <a name="sec-sessions"></a>
195
+
196
+ ## Session management
197
+
198
+ The Sessions tab lists this machine's sessions grouped by workspace and manages each one: import a package, delete it, or delete it after producing a review.
199
+
200
+ #### The list
201
+
202
+ - **Grouped by workspace**: one block per workspace that has sessions, headed by the workspace path; empty workspaces take no space.
203
+ - **One row each**: the session title (the id in grey while a title does not exist yet), with an **Archived** badge when the session is archived.
204
+ - **Unreadable logs are named**: when a log cannot be decoded the list says so at the top instead of showing it as an empty session.
179
205
 
180
- ### Import / export
206
+ #### Import
181
207
 
182
- - **Export**: Sealed tools tab → Export. Packs `toolSequence.zip` (store, no compression) straight into the current session workspace and returns the real path — no browser download. No size limit since 0.4.11: entries are streamed to disk, so memory does not grow with the toolset.
183
- - **Import**: pick a zip → `dryRun` preview of what will be installed, overwritten and skipped → confirm to write. An existing directory is kept as `.bak-<timestamp>`.
184
- - `_index.json` inside the package is not trusted; the index is rebuilt from the files on disk. `_runs`, backup directories, escaping paths and invalid ids are skipped.
185
- - Limits: 64 MB per entry, 128 MB total; zip64 and encrypted archives are not supported.
208
+ - **One button**: the leftmost **Import** in the footer takes a `dsh-session-<id>.zip`; no hand-built directories. When the host cannot write zstd the button is disabled and says why.
209
+ - **Preview first**: the dry run says whether the id will be renamed and whether it hangs under that session as a branch; nothing is written until you confirm.
210
+ - **Openable immediately**: the log is packed the way DSH stores it (a one-line header frame plus a body frame) and then `attachSession` registers it; images and files land under the attachment store by sha256; the host is told the list gained a session, so the main window shows it at once, with no restart.
211
+ - **Collisions are not forced**: an id that already exists anywhere on this machine gets a new id and the original stays untouched; a same-workspace collision also hangs under that session as a branch (`parentSession`), another workspace gets a plain rename. A session that carries inherited history (`isSeeded:true`) records its real inherited count and still opens and branches.
212
+ - **Backed up first**: the workspace roster and projection cache are copied into `会话导入备份-<time>/` inside the target workspace before writing.
186
213
 
187
- ### Clear cache (0.5.1)
214
+ #### Delete
188
215
 
189
- The **Clear cache** button sits at the right end of the import / export row. It takes two clicks (the first only turns the button into "Confirm clear" and spells out what will go).
216
+ - **Two taps**: the first tap only turns the button into Confirm; the second deletes.
217
+ - **Live sessions are closed first**: cancel → wait idle → flush → release the write handle, then remove the directory; if it cannot be closed, the delete is refused and the log is kept.
218
+ - **Removed from the list**: the directory is deleted and the session is detached from its workspace, so it leaves the list at once.
219
+ - **Leftovers are reported**: when the engine still holds a reference, the receipt says so ("it may be remembered until restart") instead of pretending it is clean.
190
220
 
191
- - **Deleted**: every `<id>.bak-<timestamp>` rollback version (the old directory kept by a reinstall or an import), and every run log in `_runs/`.
192
- - **Kept**: `_index.json` and every `<id>/` toolScript directory — tools keep running and the index is not rebuilt. Those two live outside the index, which is exactly why the rest is safe to drop.
193
- - Only directories named "valid id + `.bak-` + digits" count as rollback versions; anything else is left alone (better to under-delete).
194
- - If an import is in flight, the package it staged inside `_runs/` is skipped and the receipt says how many were skipped.
195
- - One entry that cannot be removed (in use or no permission) does not abort the run: the rest still go, and the receipt says "N could not be removed".
196
- - The receipt reports how many rollback versions, how many run logs, and how many bytes were cleared.
221
+ #### Delete + review
222
+
223
+ - **Review first, then delete**: compact, wait for the review to be split out, validate, and only then delete.
224
+ - **No delete on failure**: any failing step keeps the session; the worst case is "compaction succeeded, split failed, session still there", and that compaction is irreversible.
225
+ - **Log**: each failing step writes a line to `session-memory/_compact-delete.log`, otherwise only one English error remains.
226
+ - **Result**: the review it produces shows up on the Reviews tab and decays by calendar day.
227
+
228
+ <a name="sec-reviews"></a>
197
229
 
198
230
  ## Reviews and context memory
199
231
 
200
- The problem reviews solve: after compaction the earlier detail is normally gone. Now the shadowed transcript is kept as a file and can be read back when it matters.
232
+ The shadowed transcript is kept as a file and can be read back when it matters.
201
233
 
202
- ### When a review is created
234
+ #### When a review is created
203
235
 
204
- - Only on **compaction**: when DSH compacts, the shadowed events are written as one review file (summary + original + an empty diary section).
205
- - Tool calls and their arguments are kept verbatim, never truncated — once the log is gone, this copy is the only original.
236
+ - Only on **compaction**: written as one review file (summary + original + empty diary).
237
+ - Tool calls and arguments are kept verbatim, never truncated.
206
238
  - Spawned subagent sessions produce nothing; with Auto review off, not even detection happens.
207
- - Delete + review in the Sessions tab triggers one on purpose: compact, wait for the review to land, confirm a new one appeared, and only then delete. Any failed step aborts the deletion.
239
+ - Delete + review triggers one on purpose: compact → confirm the review landed → delete. Any failed step aborts.
240
+ - Compaction runs through the host command registry: the service is mounted per agent preset and isolated, so the plugin root never calls it — `/compact` is executed by the command handler.
241
+ - Once compaction ends, the plugin reads the newest `compaction/summary` and splits the review.
242
+ - Every failed step is logged to `session-memory/_compact-delete.log` (trimmed to its last 64 KB past 256 KB).
208
243
 
209
- ### Four levels
244
+ #### Four levels
210
245
 
211
246
  | Day | Level | What the model sees |
212
247
  |---|---|---|
213
- | the day of compaction | 3 | the original dialogue (tool calls and errors filtered out) |
248
+ | the day of compaction | 3 | the original dialogue (tool calls and errors filtered) |
214
249
  | day 2 | 2 | the compaction summary |
215
- | days 3–28 | 1 | the diary (written by the model) |
216
- | day 29 and later | 0 | keywords plus the file name, as an index |
250
+ | days 3–28 | 1 | the diary |
251
+ | day 29 and later | 0 | keywords plus the file name |
217
252
 
218
- Days are local calendar days; the hour does not matter. When you point out a misremembered detail, the model reads the original back; only reading the workspace own copy bumps and pins the level (0→1, 1→2), and a pinned review stops decaying. Reviews of child, sibling and parent workspaces are read-only and do not change levels.
253
+ Local calendar days. Only reading this workspace's own review bumps and pins the level (0→1, 1→2) and stops decay; child, sibling and parent reviews are read-only.
219
254
 
220
- ### Cross-workspace search
255
+ #### Cross-workspace search
221
256
 
222
- The unit is a workspace review folder, not a filesystem walk. Order: this workspace → its children (deepest first) → siblings (deepest first) → the parent → the parent siblings → their level-1, level-2 children, and so on. Outer rings are only read when `allowOuter` is true; otherwise the count is reported.
257
+ The unit is a workspace review folder. Order: this workspace → children → siblings → the parent → the parent's siblings → their level-1 and level-2 children. Outer rings need `allowOuter`.
223
258
 
224
- Granularity: keywords first, then summary, then original; the block that matches is returned whole. Within a workspace, hits sort by level, then matched terms, then compaction time.
259
+ Hits go keywords first, then summary, then original; within a workspace they sort by level, matched terms, then compaction time.
225
260
 
226
- ### Diary nudges
261
+ #### Diary nudges
227
262
 
228
- At level 1 or 0 the model sees the diary or the keywords — both written by the model itself. While either is empty it is asked to finish, in one of two places:
263
+ At level 1 or 0, an empty diary or empty keywords trigger one nudge:
229
264
 
230
- - **In context** (default): appended to the review text in the same message; once written the text changes, the message is replaced and the nudge disappears.
231
- - **In the system prompt**: supplied as a trailing prompt section. Compliance differs between the two; pick the one that works for you.
265
+ - **In context** (default): appended to the review text, disappears once written.
266
+ - **In the system prompt**: a trailing prompt section.
232
267
 
233
- ### Injection and preview
268
+ #### Injection and preview
234
269
 
235
270
  - Reviews enter the context every turn, oldest first.
236
- - The preview box on the Reviews tab runs the same assembly function as the real injection: what you see is what that turn receives (selecting one review shows only that one).
237
- - If assembly fails (a review too large) it does not silently become no reviews; the model gets a diagnostic: how many, total size, the largest file, what to do.
271
+ - The preview box runs the same assembly function as the real injection (selecting one review shows only that one).
272
+ - A failed assembly gives the model a diagnostic (how many, total size, largest file) instead of silently showing no reviews.
238
273
 
239
- ### The two review tools
274
+ #### The two review tools
240
275
 
241
- With Auto review on, the plugin installs two more tools; with the switch off they do not appear.
276
+ Installed only while Auto review is on.
242
277
 
243
278
  | Tool | Purpose | Key arguments |
244
279
  |---|---|---|
245
- | `session_mem_read` | find a review from one clue: this workspace → children → (with permission) siblings and parents; one hit per call | `need` (required, the user's own words), `skip` (files already read), `allowOuter` (search sibling and parent workspaces) |
246
- | `session_mem_write` | read one review's original dialogue; write keywords and diary, many at once | `file` or `date`+`nth`; `keywords`, `diary`; batch with `writes[]` |
280
+ | `session_mem_read` | find a review from a clue, one hit per call | `need` (required), `skip`, `allowOuter` |
281
+ | `session_mem_write` | read one original; write keywords and diary, in batch | `file` or `date`+`nth`; `keywords`, `diary`; `writes[]` |
282
+
283
+ - Locator only = the Original section: dialogue only, tool calls stripped.
284
+ - Writing many uses `writes[]`; all-or-nothing.
285
+ - Neither tool changes depth.
286
+
287
+ #### How it relates to sealing
288
+
289
+ Reviews are the raw-material store: the model uses `session_tool_create_read` to recover commands and arguments, then `session_tool_create_write` to seal them.
247
290
 
248
- - Locator only, no content = that review's Original section: dialogue only, tool calls (▸/◂ and their output) stripped.
249
- - Writing many uses `writes[]`: all-or-nothing — one bad entry and the batch is not written.
250
- - Neither tool changes depth: only a read that hits this workspace's own review raises it one level and pins it.
291
+ <a name="sec-config"></a>
251
292
 
252
- ### How it relates to sealing
293
+ ## Configuration and settings page
253
294
 
254
- In one line: reviews are the raw-material store for sealing. Across sessions and machines the model uses `session_tool_create_read` to find the original commands and arguments, then `session_tool_create_write` to seal them. You do not need to tune the review side — turn on Auto review and keep the defaults.
295
+ There is one config file, `$DSH_HOME/session-memory/_options.json`; changes apply immediately and are shared by all workspaces. Settings → **Tool (script) manager** → **Options** edits the same file.
255
296
 
256
- ## Configuration
297
+ #### The four tabs
298
+
299
+ | Tab | Contents |
300
+ |---|---|
301
+ | Sealed tools (`toolList` in the English UI) | tool path, the injected prompt text, list toggle and refresh mode, import / export / clear cache |
302
+ | Sessions | sessions grouped by workspace; Delete, Delete + review (both confirmed) |
303
+ | Reviews | calendar filter, review list with depth badges, injection preview, delete one |
304
+ | Options | four groups: Sealed tools, Recall injection, Review content, Review depth |
257
305
 
258
- Stored in `$DSH_HOME/session-memory/_options.json`; changes apply immediately and are shared by all workspaces.
306
+ #### Every option field
259
307
 
260
308
  | Field | Values | Default | Meaning |
261
309
  |---|---|---|---|
262
310
  | `autoReviewEnabled` | bool | `false` | master switch: no reviews, no injection, no review tools when off |
263
- | `injectEnabled` | bool | `true` | recall injection and diary nudges (does not cover the tool list) |
311
+ | `injectEnabled` | bool | `true` | recall injection and diary nudges (not the tool list) |
264
312
  | `toolListEnabled` | bool | `true` | inject the toolSequence block and install/remove the three `session_tool_*` tools |
265
313
  | `toolListRefresh` | `newSession` / `realtime` | `newSession` | when the list is recomputed |
266
- | `fullLoad` | bool | `false` | keep tool calls and errors at level 3 (warned: full re-injection after every compaction) |
267
- | `reminderChannel` | `context` / `system` | `context` | diary nudge inside the review text or as a prompt section |
268
- | `stopLowering` | bool | `false` | every review keeps its recorded level; no daily decay |
269
- | `loadLevel` | `follow` / 0–3 | `follow` | force a level at load time (does not change the recorded depth) |
314
+ | `fullLoad` | bool | `false` | keep tool calls and errors at level 3 (full re-injection) |
315
+ | `reminderChannel` | `context` / `system` | `context` | where the diary nudge goes |
316
+ | `stopLowering` | bool | `false` | reviews keep their recorded level, no daily decay |
317
+ | `loadLevel` | `follow` / 0–3 | `follow` | force a level at load time (recorded depth unchanged) |
270
318
 
271
- Two couplings: with Auto review off, the effective `injectEnabled` is always false (the stored value is untouched); with Stop lowering on, Load level falls back to follow.
319
+ Two couplings: with Auto review off, `injectEnabled` reads as off (the stored value is untouched); with Stop lowering on, Load level falls back to follow.
272
320
 
273
- ## Settings page
321
+ #### UI language
274
322
 
275
- Settings → **Tool (script) manager**, four tabs:
323
+ Follows DSH: settings strings, injected review text, diary reminders and the toolSequence block all switch. A review file is written with the header and section titles of the language active **at capture time**; switching later only changes the display (all 8 spellings are accepted). Errors and receipts the tools return to the model are English.
276
324
 
277
- | Tab | Contents |
278
- |---|---|
279
- | Sealed tools (shown as `toolList` in the English UI) | tool path, the prompt text about to be injected, "Inject toolSequence list" toggle and refresh mode, import / export / clear cache |
280
-
281
- The UI language follows DSH only: every settings-page string, the review injection (preamble / heading / placeholders / body line markers), the diary reminder, and the toolSequence section all switch with it. A review file is written with the header and section titles of the language active **at capture time**; switching later only changes the display, never the file (all 8 spellings are accepted when reading). Errors and receipts the tools return to the model are English — they do not follow the UI language.
282
- | Sessions | sessions grouped by workspace (title, archived badge), Delete / Delete + review, both confirmed |
283
- | Reviews | calendar range filter, review list with depth badges, injection preview, delete one review |
284
- | Options | four groups: Sealed tools, Recall injection, Review content, Review depth |
325
+ <a name="sec-data"></a>
285
326
 
286
327
  ## Data and backup
287
328
 
288
329
  ~~~
289
330
  $DSH_HOME/session-memory/
290
331
  _options.json options
291
- _locale.json language (zh / en)
332
+ _locale.json language
292
333
  _health.json last success/failure per workspace
334
+ _compact-delete.log per-step diagnostics (trimmed past 256 KB)
293
335
  <workspace key>/
294
- <stamp>-<id>.md review text (the single source of truth, plain text, readable and searchable)
295
- <same name>.json load cache for that review (rebuilt from file time if lost)
296
- _assembly.json.migrated-* leftover of the old single-file index (never auto-deleted)
297
- toolSequence/ tool scripts (machine level, shared by all workspaces)
336
+ <stamp>-<id>.md review text (plain text, readable and searchable)
337
+ <same name>.json load cache (rebuilt from file time if lost)
338
+ _assembly.json.migrated-* leftover of the old index (never auto-deleted)
339
+ toolSequence/ tool scripts (machine level, shared)
298
340
  ~~~
299
341
 
300
- - The workspace key uses the same encoding as the host `sessions/` folders: `/` becomes `-`, non-ASCII becomes `~XXXX`.
342
+ - The workspace key uses the host `sessions/` encoding: `/` becomes `-`, non-ASCII becomes `~XXXX`.
301
343
  - Backup: copy the whole `session-memory/`. Migration: put it at the same place on the new machine and install the same plugin.
302
- - Uninstalling the plugin deletes no data.
344
+ - Uninstalling deletes no data.
345
+
346
+ <a name="sec-compat"></a>
303
347
 
304
348
  ## Compatibility and degradation
305
349
 
306
- Missing host capabilities disable the matching block; everything else keeps working (the settings page lists what is missing):
350
+ Missing host capabilities disable the matching block only (the settings page lists what is missing):
307
351
 
308
352
  | Missing | Effect |
309
353
  |---|---|
310
354
  | `systemPrompt.context` | recall injection off |
311
355
  | `systemPrompt.section` | diary nudge section and toolSequence block do not appear |
312
356
  | `tools.register` | none of the five tools is installed |
313
- | `webServer.register` | the settings endpoints are not installed |
314
- | `agents.create` / `resume` | only Delete live session / Delete + review are off |
357
+ | `webServer.register` | settings endpoints not installed |
358
+ | `agents.create` / `resume` | deleting a live session falls back to tier 2 (plugin-built teardown) |
359
+ | `commands.execute`, or `command-compact` not mounted | Delete + review is unavailable; plain delete still works |
360
+
361
+ Two tiers for deleting a live session: (1) the `dispose` returned by `agents.create` / `resume`, captured by the lifecycle hook; (2) no handle — the plugin builds its own `cancel({kind:'disposed'})` → `whenIdle()` → `scope.dispose()`. Tier 2 only stops the agent; unregistering belongs to the host closure with no public API, so the delete succeeds with a `warnings` entry (the settings page says the engine may still remember it until restart).
315
362
 
316
- Session logs are multi-frame zstd and are split by frame header before decoding; when `zlib.zstdDecompressSync` is absent the built-in decoder takes over, so Node 18 still reads titles.
363
+ Session logs are multi-frame zstd, split by frame header; without native `zlib.zstdDecompressSync` the built-in decoder takes over.
364
+
365
+ <a name="sec-limits"></a>
317
366
 
318
367
  ## Known limitations
319
368
 
320
- - Tool scripts have **no delete or edit in the UI**: delete by reinstalling (a `.bak-` is kept) or by removing the directory — the registry keeps the entry and later runs report that the directory is missing.
321
- - `steps` do not chain automatically; use `calls` for a sequence.
322
- - Reviews are created on compaction only; the Reviews tab has a calendar filter and no full-text search.
369
+ - Tool scripts have **no delete or edit in the UI**: reinstall to overwrite (a `.bak-` is kept) or remove the directory (the registry keeps the entry and later runs report a missing directory).
370
+ - `steps` never chain automatically; use `calls`.
371
+ - Reviews are created on compaction only; the Reviews tab has no full-text search.
323
372
  - Subagent sessions produce no reviews and no diary nudges.
324
- - Import and export cover tool scripts only, not reviews; copy `session-memory/` for those.
373
+ - Import and export cover tool scripts only; copy `session-memory/` for reviews.
374
+ - Delete + review needs `command-compact` mounted on that session's preset.
375
+ - With the plugin-built teardown, the engine may still remember the session until it restarts.
376
+
377
+ <a name="sec-dev"></a>
325
378
 
326
379
  ## Development
327
380
 
328
381
  ~~~
329
- index.js plugin entry (exports name / apply / inject only)
382
+ index.js plugin entry (exports name / apply / inject)
330
383
  cordis.patch.yml inserts the plugin into the host loader
331
384
  lib/core/ host-side logic: storage, decay, tool definitions, script runner
332
385
  lib/host/ host service adapters: 12 HTTP endpoints, capability probe, session delete
@@ -334,8 +387,8 @@ lib/client.js settings page (React, registered at settings.section)
334
387
  ~~~
335
388
 
336
389
  - Zero runtime dependencies, ESM, Node `>=18`.
337
- - Tests: `node --test test/*.test.mjs` (the test directory is not part of the published package).
338
- - Packaging: `npm pack`; the publish whitelist is the `files` field of `package.json`.
390
+ - Tests `node --test test/*.test.mjs` (not shipped in the package).
391
+ - Packaging `npm pack`; whitelist is the `files` field of `package.json`.
339
392
 
340
393
  ## License
341
394