dsh-seal-scripts 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -7,326 +7,344 @@
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
+ - [Reviews](#sec-reviews)
24
+ - [Configuration and settings page](#sec-config)
25
+ - [Data and backup](#sec-data)
26
+ - [Compatibility and degradation](#sec-compat)
27
+ - [Known limitations](#sec-limits)
28
+ - [Development](#sec-dev)
29
+
30
+ <a name="sec-features"></a>
30
31
 
31
32
  ## Features
32
33
 
33
- **Sealed scripts**
34
+ #### Sealed scripts
35
+
36
+ - **One chain → one tool script**: full script text, entry, args, steps, provenance, per-file sha256.
37
+ - **In the system prompt**: the toolSequence block lists every sealed tool, one line each.
38
+ - **Runs as written**: args as an argv array, never through a shell; interpreter chosen by the run field.
39
+ - **Verifiable**: sha256 compared before running; a hand-edited script is refused unless explicitly allowed.
40
+ - **Portable**: store-only zip; import previews first, index rebuilt from the files on disk.
34
41
 
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.
42
+ #### Context reviews
40
43
 
41
- **Context reviews**
44
+ - **Captured on compaction**: no model call; tool calls and arguments kept verbatim.
45
+ - **Four-level decay**: original → summary → diary → keywords; a read bumps and pins the level.
46
+ - **Cross-workspace search**: workspace → children → siblings → parents; outer rings need permission.
47
+ - **Diary nudges**: asked once when the diary or keywords are empty.
42
48
 
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.
49
+ #### Engineering
47
50
 
48
- **Engineering**
51
+ - Zero runtime dependencies, Node built-ins only; UI and injected text follow DSH's 8 languages, model-facing errors and receipts are English.
52
+ - A missing host capability disables that block only.
53
+ - Plain-text data: copy `session-memory/` for a backup.
49
54
 
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.
55
+ <a name="sec-install"></a>
53
56
 
54
57
  ## Install
55
58
 
56
- Add the package in the DSH plugin manager (package name, absolute local path, tarball, or Git URL):
59
+ Add the package in the plugin manager (package name, local path, tarball, or Git URL). `--profile` is required, e.g. `web`:
57
60
 
58
61
  ~~~bash
59
- # --profile is required (otherwise: required option "--profile" not specified)
60
62
  dsh plugin --profile web add dsh-seal-scripts
61
-
62
- # local directory: pnpm records it as a link dependency in that profile
63
63
  dsh plugin --profile web add /path/to/dsh-seal-scripts
64
64
  ~~~
65
65
 
66
- Or use Settings → Plugins → Add with a package name, absolute path, tarball, or Git URL. Restart the profile after installing.
66
+ The second line is a local directory, registered as a link dependency. Restart the profile to load it.
67
67
 
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)
68
+ Requirements: host `@deepseek-ai/dsh` `>=0.2.2-rc.1`, `<1.0.0` (peer, not forced); Node `>=18`.
72
69
 
73
70
  After the restart, Settings shows **Tool (script) manager**.
74
71
 
72
+ <a name="sec-quickstart"></a>
73
+
75
74
  ## Quick start
76
75
 
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.
76
+ 1. **Master switch**: Settings → Tool (script) manager → Options → turn on **Auto review** (off by default; nothing is created while off).
77
+ 2. **Run a chain end to end**.
79
78
  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):
79
+ 4. **Reuse it**: "run <id>"; add "show me the commands first, do not run" to preview.
83
80
 
84
81
  ~~~text
85
82
  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.
83
+ Model: (session_tool_create_write) installed dsh-plugin-pack at .../toolSequence/dsh-plugin-pack
84
+ entry pack.sh, params source_dir out_dir
88
85
 
89
86
  (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
87
+ You: run dsh-plugin-pack, the source dir is /sdcard/Download/my-src
88
+ Model: (session_tool_call) exit 0, N files, sha256 matches the manifest
92
89
  ~~~
93
90
 
91
+ <a name="sec-tools"></a>
92
+
94
93
  ## Sealed scripts
95
94
 
96
- ### Why this is not a note
95
+ #### Why this is not a note
97
96
 
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.
97
+ 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
98
 
100
- ### How to trigger it
99
+ #### How to trigger it
101
100
 
102
101
  | What you say | What happens | When to use |
103
102
  |---|---|---|
104
103
  | 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 |
104
+ | 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
105
 
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.
106
+ The version that ran is stored, not a draft; editing after installing means re-sending the context.
108
107
 
109
- ### What gets created
108
+ #### What gets created
110
109
 
111
110
  ~~~
112
111
  $DSH_HOME/session-memory/toolSequence/
113
112
  _index.json registry: id, title, purpose, entry, args, steps, per-file sha256
114
113
  <id>/
115
- toolScript.json manifest: full script text, docs, hashes, provenance (review file + line)
114
+ toolScript.json manifest: full script text, docs, hashes, provenance
116
115
  <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)
116
+ README.md generated from the manifest
117
+ <notes>.md read-only notes (never executed)
118
+ _runs/ full stdout/stderr log of every run
120
119
  <id>.bak-<timestamp>/ previous directory kept on reinstall or import
121
120
  ~~~
122
121
 
123
- ### How the model learns about it
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.
122
+ #### How the model learns about it
126
123
 
127
- When that list refreshes (option **When the list is refreshed**):
124
+ 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
125
 
129
126
  | Mode | Behaviour | Cost |
130
127
  |---|---|---|
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) |
128
+ | 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 |
129
+ | Live per session | computed every turn | one cache miss on the next message |
133
130
 
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.
131
+ Changing the mode refreshes every remembered session immediately.
135
132
 
136
- ### The three tools
133
+ #### The three tools
137
134
 
138
135
  | Tool | Purpose | Key arguments |
139
136
  |---|---|---|
140
137
  | `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 |
138
+ | `session_tool_create_read` | read review originals, read-only | `file` or `date`+`nth`; `mode` = outline / raw / block; `cursor`, `chars`, `line`, `span` |
142
139
  | `session_tool_call` | run as written | `toolScript`, `step`, `args`, `stdin`, `cwd`, `dryRun`, `calls`, `stopOnError`, `allowDrift`, `timeoutMs`, `maxOutputBytes` |
143
140
 
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.
141
+ - No arguments: lists every tool script.
142
+ - `dryRun: true`: echoes the arguments and cwd only.
143
+ - `calls: []`: runs in order, no count limit, reporting exit code, duration and logs per entry.
147
144
 
148
- ### Validation when sealing
145
+ #### Validation when sealing
149
146
 
150
147
  | Item | Rule |
151
148
  |---|---|
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 |
149
+ | `id` | starts with a lowercase letter, only `a-z0-9-`, no length limit |
150
+ | file name | starts alphanumeric, letters, digits and . _ - only, no paths, no leading dot |
154
151
  | `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) |
152
+ | size | no cap |
153
+ | `title` / `purpose` | non-empty; any length |
154
+ | `entry` / `steps` | must name files in `scripts`; entry defaults to the first |
155
+ | `timeoutMs` | any positive ms, clamped to the host maxTimeoutMs, defaults to the host timeoutMs |
156
+ | docs | must be `.md`, not `README.md`, no duplicates |
157
+ | script body | non-empty; must not contain `<!--ovr:` |
161
158
  | same id exists | refused without `replace`; the error quotes the first 12 hex chars of the manifest sha256 |
162
159
 
163
- `steps` only declares pipeline order and never runs anything by itself; `params` only declares argv order and names are not validated.
160
+ `steps` only declares order and never chains; `params` only declares argv order and names are not validated.
164
161
 
165
- ### Execution semantics
162
+ #### Execution semantics
166
163
 
167
164
  | Item | Value |
168
165
  |---|---|
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 |
166
+ | interpreter | bash; node uses `process.execPath`; ps1 uses Windows PowerShell (`pwsh` elsewhere); cmd uses `%ComSpec% /d /c` (falls back to `sh` off Windows) |
167
+ | argv | interpreter args + absolute script path + args, as an array, never through a shell |
168
+ | cwd | `workspace`, `toolScript`, or an absolute path inside either |
172
169
  | 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 |
170
+ | 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 |
171
+ | output | DSH maxOutputBytes; every run written to `_runs/` and the reply carries the file path |
172
+ | result | `{ exitCode, signal, timedOut, background, pid, logFile, stdout, stderr, truncated, spill }` |
173
+ | argument count | more than `params` declares fails before running; fewer is fine |
174
+ | drift | sha256 compared first; mismatch refuses, `allowDrift: true` allows it and marks `drift` |
175
+ | containment | only files inside the script directory run; unknown script names refused |
176
+
177
+ #### Import / export
179
178
 
180
- ### Import / export
179
+ - **Export**: Sealed tools tab → Export. Packs `toolSequence.zip` (store) into the session workspace and returns the path — no browser download.
180
+ - **Import**: pick a zip → `dryRun` preview → confirm to write; an existing directory is kept as `.bak-<timestamp>`.
181
+ - `_index.json` in the package is not trusted; the index is rebuilt from disk. `_runs`, backups, escaping paths and invalid ids are skipped.
182
+ - No size cap; the zip-bomb guard compares extracted bytes + 16 MB against free disk space. zip64 and encrypted archives are not supported.
181
183
 
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.
184
+ #### Clear cache
186
185
 
187
- ### Clear cache (0.5.1)
186
+ Two clicks (the first only changes the button label):
188
187
 
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).
188
+ - **Deleted**: `<id>.bak-<timestamp>` rollback directories, every log in `_runs/`.
189
+ - **Kept**: `_index.json` and every `<id>/` directory.
190
+ - Only "valid id + `.bak-` + digits" directories count; a staged import package is skipped.
191
+ - One entry that cannot be removed does not abort the run; the receipt reports counts and bytes.
190
192
 
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.
193
+ <a name="sec-reviews"></a>
197
194
 
198
195
  ## Reviews and context memory
199
196
 
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.
197
+ The shadowed transcript is kept as a file and can be read back when it matters.
201
198
 
202
- ### When a review is created
199
+ #### When a review is created
203
200
 
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.
201
+ - Only on **compaction**: written as one review file (summary + original + empty diary).
202
+ - Tool calls and arguments are kept verbatim, never truncated.
206
203
  - 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.
204
+ - Delete + review triggers one on purpose: compact → confirm the review landed → delete. Any failed step aborts.
205
+ - 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.
206
+ - Once compaction ends, the plugin reads the newest `compaction/summary` and splits the review.
207
+ - Every failed step is logged to `session-memory/_compact-delete.log` (trimmed to its last 64 KB past 256 KB).
208
208
 
209
- ### Four levels
209
+ #### Four levels
210
210
 
211
211
  | Day | Level | What the model sees |
212
212
  |---|---|---|
213
- | the day of compaction | 3 | the original dialogue (tool calls and errors filtered out) |
213
+ | the day of compaction | 3 | the original dialogue (tool calls and errors filtered) |
214
214
  | 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 |
215
+ | days 3–28 | 1 | the diary |
216
+ | day 29 and later | 0 | keywords plus the file name |
217
217
 
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.
218
+ 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
219
 
220
- ### Cross-workspace search
220
+ #### Cross-workspace search
221
221
 
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.
222
+ 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
223
 
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.
224
+ Hits go keywords first, then summary, then original; within a workspace they sort by level, matched terms, then compaction time.
225
225
 
226
- ### Diary nudges
226
+ #### Diary nudges
227
227
 
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:
228
+ At level 1 or 0, an empty diary or empty keywords trigger one nudge:
229
229
 
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.
230
+ - **In context** (default): appended to the review text, disappears once written.
231
+ - **In the system prompt**: a trailing prompt section.
232
232
 
233
- ### Injection and preview
233
+ #### Injection and preview
234
234
 
235
235
  - 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.
236
+ - The preview box runs the same assembly function as the real injection (selecting one review shows only that one).
237
+ - A failed assembly gives the model a diagnostic (how many, total size, largest file) instead of silently showing no reviews.
238
238
 
239
- ### The two review tools
239
+ #### The two review tools
240
240
 
241
- With Auto review on, the plugin installs two more tools; with the switch off they do not appear.
241
+ Installed only while Auto review is on.
242
242
 
243
243
  | Tool | Purpose | Key arguments |
244
244
  |---|---|---|
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[]` |
245
+ | `session_mem_read` | find a review from a clue, one hit per call | `need` (required), `skip`, `allowOuter` |
246
+ | `session_mem_write` | read one original; write keywords and diary, in batch | `file` or `date`+`nth`; `keywords`, `diary`; `writes[]` |
247
+
248
+ - Locator only = the Original section: dialogue only, tool calls stripped.
249
+ - Writing many uses `writes[]`; all-or-nothing.
250
+ - Neither tool changes depth.
251
+
252
+ #### How it relates to sealing
253
+
254
+ 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
255
 
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.
256
+ <a name="sec-config"></a>
251
257
 
252
- ### How it relates to sealing
258
+ ## Configuration and settings page
253
259
 
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.
260
+ 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
261
 
256
- ## Configuration
262
+ #### The four tabs
257
263
 
258
- Stored in `$DSH_HOME/session-memory/_options.json`; changes apply immediately and are shared by all workspaces.
264
+ | Tab | Contents |
265
+ |---|---|
266
+ | Sealed tools (`toolList` in the English UI) | tool path, the injected prompt text, list toggle and refresh mode, import / export / clear cache |
267
+ | Sessions | sessions grouped by workspace; Delete, Delete + review (both confirmed) |
268
+ | Reviews | calendar filter, review list with depth badges, injection preview, delete one |
269
+ | Options | four groups: Sealed tools, Recall injection, Review content, Review depth |
270
+
271
+ #### Every option field
259
272
 
260
273
  | Field | Values | Default | Meaning |
261
274
  |---|---|---|---|
262
275
  | `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) |
276
+ | `injectEnabled` | bool | `true` | recall injection and diary nudges (not the tool list) |
264
277
  | `toolListEnabled` | bool | `true` | inject the toolSequence block and install/remove the three `session_tool_*` tools |
265
278
  | `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) |
270
-
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.
279
+ | `fullLoad` | bool | `false` | keep tool calls and errors at level 3 (full re-injection) |
280
+ | `reminderChannel` | `context` / `system` | `context` | where the diary nudge goes |
281
+ | `stopLowering` | bool | `false` | reviews keep their recorded level, no daily decay |
282
+ | `loadLevel` | `follow` / 0–3 | `follow` | force a level at load time (recorded depth unchanged) |
272
283
 
273
- ## Settings page
284
+ 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.
274
285
 
275
- Settings → **Tool (script) manager**, four tabs:
286
+ #### UI language
276
287
 
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 |
288
+ 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.
280
289
 
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 |
290
+ <a name="sec-data"></a>
285
291
 
286
292
  ## Data and backup
287
293
 
288
294
  ~~~
289
295
  $DSH_HOME/session-memory/
290
296
  _options.json options
291
- _locale.json language (zh / en)
297
+ _locale.json language
292
298
  _health.json last success/failure per workspace
299
+ _compact-delete.log per-step diagnostics (trimmed past 256 KB)
293
300
  <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)
301
+ <stamp>-<id>.md review text (plain text, readable and searchable)
302
+ <same name>.json load cache (rebuilt from file time if lost)
303
+ _assembly.json.migrated-* leftover of the old index (never auto-deleted)
304
+ toolSequence/ tool scripts (machine level, shared)
298
305
  ~~~
299
306
 
300
- - The workspace key uses the same encoding as the host `sessions/` folders: `/` becomes `-`, non-ASCII becomes `~XXXX`.
307
+ - The workspace key uses the host `sessions/` encoding: `/` becomes `-`, non-ASCII becomes `~XXXX`.
301
308
  - 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.
309
+ - Uninstalling deletes no data.
310
+
311
+ <a name="sec-compat"></a>
303
312
 
304
313
  ## Compatibility and degradation
305
314
 
306
- Missing host capabilities disable the matching block; everything else keeps working (the settings page lists what is missing):
315
+ Missing host capabilities disable the matching block only (the settings page lists what is missing):
307
316
 
308
317
  | Missing | Effect |
309
318
  |---|---|
310
319
  | `systemPrompt.context` | recall injection off |
311
320
  | `systemPrompt.section` | diary nudge section and toolSequence block do not appear |
312
321
  | `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 |
322
+ | `webServer.register` | settings endpoints not installed |
323
+ | `agents.create` / `resume` | deleting a live session falls back to tier 2 (plugin-built teardown) |
324
+ | `commands.execute`, or `command-compact` not mounted | Delete + review is unavailable; plain delete still works |
315
325
 
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.
326
+ 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).
327
+
328
+ Session logs are multi-frame zstd, split by frame header; without native `zlib.zstdDecompressSync` the built-in decoder takes over.
329
+
330
+ <a name="sec-limits"></a>
317
331
 
318
332
  ## Known limitations
319
333
 
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.
334
+ - 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).
335
+ - `steps` never chain automatically; use `calls`.
336
+ - Reviews are created on compaction only; the Reviews tab has no full-text search.
323
337
  - Subagent sessions produce no reviews and no diary nudges.
324
- - Import and export cover tool scripts only, not reviews; copy `session-memory/` for those.
338
+ - Import and export cover tool scripts only; copy `session-memory/` for reviews.
339
+ - Delete + review needs `command-compact` mounted on that session's preset.
340
+ - With the plugin-built teardown, the engine may still remember the session until it restarts.
341
+
342
+ <a name="sec-dev"></a>
325
343
 
326
344
  ## Development
327
345
 
328
346
  ~~~
329
- index.js plugin entry (exports name / apply / inject only)
347
+ index.js plugin entry (exports name / apply / inject)
330
348
  cordis.patch.yml inserts the plugin into the host loader
331
349
  lib/core/ host-side logic: storage, decay, tool definitions, script runner
332
350
  lib/host/ host service adapters: 12 HTTP endpoints, capability probe, session delete
@@ -334,8 +352,8 @@ lib/client.js settings page (React, registered at settings.section)
334
352
  ~~~
335
353
 
336
354
  - 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`.
355
+ - Tests `node --test test/*.test.mjs` (not shipped in the package).
356
+ - Packaging `npm pack`; whitelist is the `files` field of `package.json`.
339
357
 
340
358
  ## License
341
359