dsh-seal-scripts 0.6.0 → 0.6.2
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 +229 -199
- package/README.md +109 -72
- package/lib/client.js +499 -41
- package/lib/core/index.js +4 -1
- package/lib/host/capabilities.js +4 -0
- package/lib/host/import-session.js +498 -0
- package/lib/host/routes/sessions.js +47 -1
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[简体中文](./README.md) | **English**
|
|
4
4
|
|
|
5
|
-
> Seal the
|
|
5
|
+
> Seal a proven CLI chain into a tool script with a contract, replayable as written, with the session's actual call history as raw material.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.com/package/dsh-seal-scripts)
|
|
8
8
|
[](./LICENSE)
|
|
@@ -10,350 +10,380 @@
|
|
|
10
10
|
[](https://github.com/deepseek-ai/dsh)
|
|
11
11
|
[](./package.json)
|
|
12
12
|
|
|
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
|
-
|
|
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
|
-
|
|
17
13
|
## Contents
|
|
18
14
|
|
|
19
|
-
- [
|
|
15
|
+
- [CLI solidification](#sec-class)
|
|
20
16
|
- [Install](#sec-install)
|
|
21
17
|
- [Quick start](#sec-quickstart)
|
|
22
|
-
- [
|
|
18
|
+
- [Sealing](#sec-tools)
|
|
23
19
|
- [Reviews](#sec-reviews)
|
|
24
|
-
- [
|
|
20
|
+
- [Session management](#sec-sessions)
|
|
21
|
+
- [Configuration](#sec-config)
|
|
25
22
|
- [Data and backup](#sec-data)
|
|
26
|
-
- [Compatibility
|
|
23
|
+
- [Compatibility](#sec-compat)
|
|
27
24
|
- [Known limitations](#sec-limits)
|
|
28
25
|
- [Development](#sec-dev)
|
|
29
26
|
|
|
30
|
-
<a name="sec-
|
|
27
|
+
<a name="sec-class"></a>
|
|
31
28
|
|
|
32
|
-
##
|
|
29
|
+
## CLI solidification
|
|
33
30
|
|
|
34
|
-
|
|
31
|
+
The binary sits on the machine, but **how to call it is composed by the model every time**; composed correctly, it is still correct only once. Solidifying means storing that run together with its contract, as a tool you can call again:
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
| Sealed | Where it lives | Effect on replay |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| Command text | `scripts[].content` + per-file sha256 | Byte-for-byte replay; hand edits rejected before running |
|
|
36
|
+
| Argument contract | `params` (argv order) + arity check | Extra arguments fail before running; fewer are allowed |
|
|
37
|
+
| Interpreter | `run` (bash / node / ps1 / cmd) | No environment guessing |
|
|
38
|
+
| Working directory | `cwd`: `workspace` / `toolScript` / inside either | No forgotten `cd`; paths outside are rejected |
|
|
39
|
+
| Runtime bounds | `timeoutMs`, output cap, timeout to background | Long jobs do not stall the chat; logs in `_runs/` |
|
|
40
|
+
| Provenance | `provenance`, hashes in `toolScript.json` | Knows which conversation it came from and whether it changed |
|
|
41
|
+
|
|
42
|
+
Four steps:
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
1 run it the model uses the CLI normally (ffmpeg / gh / git / its own script)
|
|
46
|
+
2 seal it session_tool_create_write -> toolSequence/<id>/ dir + manifest + sha256
|
|
47
|
+
3 announce the tool-group list at the end of the system prompt:
|
|
48
|
+
id (title): purpose | entry | params
|
|
49
|
+
4 replay session_tool_call{toolScript:"<id>", args:[...]} -> same argv, exit code reported
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
How it differs from typing the command:
|
|
53
|
+
|
|
54
|
+
- Script text is checked by sha256; hand edits are rejected (`allowDrift` overrides).
|
|
55
|
+
- argv array, never a shell; more args than `params` declares fails before running.
|
|
56
|
+
- Interpreter and cwd are fixed; only files inside the tool directory run, unknown script names rejected.
|
|
57
|
+
- A non-zero exit code fails the tool call; no fake success.
|
|
58
|
+
- The tool list stays in the system prompt; the whole set travels as a zip with an import preview.
|
|
41
59
|
|
|
42
|
-
|
|
60
|
+
<a name="sec-install"></a>
|
|
43
61
|
|
|
44
|
-
|
|
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.
|
|
62
|
+
## Install
|
|
48
63
|
|
|
49
|
-
|
|
64
|
+
Add the package through the plugin manager (package name, local path, tarball or Git). `--profile` is required, e.g. `web`:
|
|
50
65
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
66
|
+
```bash
|
|
67
|
+
dsh plugin --profile web add dsh-seal-scripts # latest from the registry
|
|
68
|
+
dsh plugin --profile web add dsh-seal-scripts@0.6.2 # pin a version
|
|
69
|
+
dsh plugin --profile web add /path/to/dsh-seal-scripts # local dir, linked dependency
|
|
70
|
+
```
|
|
54
71
|
|
|
55
|
-
|
|
72
|
+
`dsh plugin` forwards its arguments to pnpm inside the profile directory, so the npm route works too:
|
|
56
73
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
74
|
+
```bash
|
|
75
|
+
npm i dsh-seal-scripts # install into the current Node environment
|
|
76
|
+
npx dsh plugin --profile web add dsh-seal-scripts
|
|
77
|
+
```
|
|
60
78
|
|
|
61
|
-
|
|
62
|
-
dsh plugin --profile web add dsh-seal-scripts
|
|
63
|
-
dsh plugin --profile web add /path/to/dsh-seal-scripts
|
|
64
|
-
~~~
|
|
79
|
+
`npm i` alone only fills `node_modules`; it does not register the plugin into a profile — the command above (or the plugin manager) does that by package name.
|
|
65
80
|
|
|
66
|
-
|
|
81
|
+
Reload the profile after installing.
|
|
67
82
|
|
|
68
|
-
|
|
83
|
+
Requires host `@deepseek-ai/dsh` `>=0.2.2-rc.1`, `<1.0.0` (peer, optional) and Node `>=18`.
|
|
69
84
|
|
|
70
|
-
|
|
85
|
+
A **Tool (script) manager** section appearing in settings means it loaded.
|
|
71
86
|
|
|
72
87
|
<a name="sec-quickstart"></a>
|
|
73
88
|
|
|
74
89
|
## Quick start
|
|
75
90
|
|
|
76
|
-
1.
|
|
77
|
-
2.
|
|
78
|
-
3.
|
|
79
|
-
4.
|
|
91
|
+
1. Settings → Tool (script) manager → Options → enable "Automatic review" (off by default).
|
|
92
|
+
2. Run a command chain until it works.
|
|
93
|
+
3. Say "turn the above into a tool"; the model calls `session_tool_create_write`.
|
|
94
|
+
4. Say "run <id>"; add "show the command first, don't run it" for a `dryRun`.
|
|
80
95
|
|
|
81
|
-
|
|
82
|
-
You:
|
|
83
|
-
Model:
|
|
84
|
-
|
|
96
|
+
```text
|
|
97
|
+
You: turn that packaging flow into a tool
|
|
98
|
+
Model: (session_tool_create_write) installed dsh-plugin-pack at …/toolSequence/dsh-plugin-pack
|
|
99
|
+
entry pack.sh, params source_dir out_dir
|
|
85
100
|
|
|
86
101
|
(new session)
|
|
87
|
-
You:
|
|
88
|
-
Model:
|
|
89
|
-
|
|
102
|
+
You: run dsh-plugin-pack on /sdcard/Download/my-src
|
|
103
|
+
Model: (session_tool_call) exit 0, N files, sha256 matches the manifest
|
|
104
|
+
```
|
|
90
105
|
|
|
91
106
|
<a name="sec-tools"></a>
|
|
92
107
|
|
|
93
|
-
##
|
|
94
|
-
|
|
95
|
-
#### Why this is not a note
|
|
108
|
+
## Sealing
|
|
96
109
|
|
|
97
|
-
|
|
110
|
+
#### Triggers
|
|
98
111
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
| What you say | What happens | When to use |
|
|
112
|
+
| You say | It does | Good for |
|
|
102
113
|
|---|---|---|
|
|
103
|
-
|
|
|
104
|
-
|
|
|
114
|
+
| Turn the above into a tool | Seals the steps that just ran | Same session, commands still in context |
|
|
115
|
+
| Turn that older session into a tool | Reads the review text via `session_tool_create_read`, then seals | New session, new machine |
|
|
105
116
|
|
|
106
|
-
The
|
|
117
|
+
The sealed copy is the one that ran, not a draft. Editing afterwards means resending the context (or `replace`).
|
|
107
118
|
|
|
108
|
-
####
|
|
119
|
+
#### Layout
|
|
109
120
|
|
|
110
|
-
|
|
121
|
+
```text
|
|
111
122
|
$DSH_HOME/session-memory/toolSequence/
|
|
112
|
-
_index.json
|
|
123
|
+
_index.json catalog: id, title, purpose, entry, params, steps, per-file sha256
|
|
113
124
|
<id>/
|
|
114
|
-
toolScript.json manifest:
|
|
115
|
-
<script> the file
|
|
125
|
+
toolScript.json manifest: script text, docs, hashes, provenance
|
|
126
|
+
<script> the executed file (.sh / .js .mjs .cjs / .ps1 / .bat .cmd)
|
|
116
127
|
README.md generated from the manifest
|
|
117
128
|
<notes>.md read-only notes (never executed)
|
|
118
|
-
_runs/ full stdout/stderr
|
|
119
|
-
<id>.bak-<
|
|
120
|
-
|
|
129
|
+
_runs/ full stdout/stderr per run
|
|
130
|
+
<id>.bak-<ts>/ kept on replace / import
|
|
131
|
+
```
|
|
121
132
|
|
|
122
|
-
####
|
|
133
|
+
#### System-prompt injection
|
|
123
134
|
|
|
124
|
-
|
|
135
|
+
A "tool group" section is appended to the system prompt, one line per tool: `id (title): purpose | entry | params`. No count or length cap; the whole purpose text is used.
|
|
125
136
|
|
|
126
137
|
| Mode | Behaviour | Cost |
|
|
127
138
|
|---|---|---|
|
|
128
|
-
| Before a new session (default) |
|
|
129
|
-
|
|
|
139
|
+
| Before a new session (default) | Computed once on first assembly, fixed for the session | Installing/removing mid-session leaves the prompt unchanged |
|
|
140
|
+
| Realtime | Recomputed every turn | One cache miss after each change |
|
|
130
141
|
|
|
131
|
-
|
|
142
|
+
Switching modes refreshes every remembered session immediately.
|
|
132
143
|
|
|
133
|
-
####
|
|
144
|
+
#### Tools
|
|
134
145
|
|
|
135
146
|
| Tool | Purpose | Key arguments |
|
|
136
147
|
|---|---|---|
|
|
137
|
-
| `session_tool_create_write` |
|
|
138
|
-
| `session_tool_create_read` |
|
|
139
|
-
| `session_tool_call` |
|
|
148
|
+
| `session_tool_create_write` | Seal a chain | `toolScript{ id, title, purpose, entry, scripts[], docs[], params, steps, timeoutMs }`; `replace` |
|
|
149
|
+
| `session_tool_create_read` | Read review source text | `file` or `date`+`nth`; `mode` = outline / raw / block; `cursor`, `chars`, `line`, `span` |
|
|
150
|
+
| `session_tool_call` | Replay as written | `toolScript`, `step`, `args`, `stdin`, `cwd`, `dryRun`, `calls`, `stopOnError`, `allowDrift`, `timeoutMs`, `maxOutputBytes` |
|
|
140
151
|
|
|
141
|
-
- No arguments:
|
|
142
|
-
- `dryRun: true`:
|
|
143
|
-
- `calls: []`:
|
|
152
|
+
- No arguments: list all tool scripts.
|
|
153
|
+
- `dryRun: true`: echo argv and cwd only.
|
|
154
|
+
- `calls: []`: run in order, unlimited entries, per-entry exit code, duration and log.
|
|
144
155
|
|
|
145
|
-
####
|
|
156
|
+
#### Seal-time validation
|
|
146
157
|
|
|
147
158
|
| Item | Rule |
|
|
148
159
|
|---|---|
|
|
149
|
-
| `id` |
|
|
150
|
-
|
|
|
160
|
+
| `id` | Starts with a lowercase letter, `a-z0-9-` only, no length limit |
|
|
161
|
+
| File names | Start alphanumeric; letters, digits, `. _ -` only; no paths, no leading dot |
|
|
151
162
|
| `run` vs extension | bash→`.sh`; node→`.js/.mjs/.cjs`; ps1→`.ps1`; cmd→`.bat/.cmd` |
|
|
152
|
-
|
|
|
153
|
-
| `title` / `purpose` |
|
|
154
|
-
| `entry` / `steps` |
|
|
155
|
-
| `timeoutMs` |
|
|
156
|
-
|
|
|
157
|
-
|
|
|
158
|
-
|
|
|
163
|
+
| Size | No limit |
|
|
164
|
+
| `title` / `purpose` | Non-empty; purpose unlimited |
|
|
165
|
+
| `entry` / `steps` | Must name files in `scripts`; entry defaults to the first |
|
|
166
|
+
| `timeoutMs` | Positive ms; clamped to the host maxTimeoutMs at run time |
|
|
167
|
+
| Notes | Must be `.md`, not `README.md`, no duplicates |
|
|
168
|
+
| Body | Non-empty; must not contain `<!--ovr:` |
|
|
169
|
+
| Existing name | Rejected without `replace`, returning the first 12 chars of the manifest sha256 |
|
|
159
170
|
|
|
160
|
-
`steps`
|
|
171
|
+
`steps` declares order only (no auto chaining); `params` declares argv order only (names unvalidated).
|
|
161
172
|
|
|
162
|
-
#### Execution
|
|
173
|
+
#### Execution
|
|
163
174
|
|
|
164
175
|
| Item | Value |
|
|
165
176
|
|---|---|
|
|
166
|
-
|
|
|
167
|
-
| argv |
|
|
177
|
+
| Interpreter | bash; node via `process.execPath`; ps1 via Windows PowerShell (else `pwsh`); cmd via `%ComSpec% /d /c` (else `sh`) |
|
|
178
|
+
| argv | Interpreter flags + absolute script path + args, array form, never a shell |
|
|
168
179
|
| cwd | `workspace`, `toolScript`, or an absolute path inside either |
|
|
169
|
-
|
|
|
170
|
-
|
|
|
171
|
-
|
|
|
172
|
-
|
|
|
173
|
-
|
|
|
174
|
-
|
|
|
175
|
-
|
|
|
180
|
+
| Env | Inherits `process.env` plus `TOOL_NAME`, `TOOL_SCRIPT`, `TOOL_ROOT`, `DSH_HOME` |
|
|
181
|
+
| Timeout | Follows the DSH terminal settings (120 s default, maxTimeoutMs cap); on expiry the run moves to the background with pid and log path; stop = SIGTERM then SIGKILL after 2 s; process group on POSIX, `taskkill /T /F` on Windows |
|
|
182
|
+
| Output | DSH maxOutputBytes by default; every run is written to `_runs/` and the result carries the path |
|
|
183
|
+
| Return | `{ exitCode, signal, timedOut, background, pid, logFile, stdout, stderr, truncated, spill }` |
|
|
184
|
+
| Arity | More args than `params` fails before running; fewer is allowed |
|
|
185
|
+
| Drift | sha256 compared before running; mismatch rejected unless `allowDrift: true` (marked `drift`) |
|
|
186
|
+
| Scope | Only files inside the tool directory; unknown script names rejected |
|
|
176
187
|
|
|
177
188
|
#### Import / export
|
|
178
189
|
|
|
179
|
-
- **Export**:
|
|
180
|
-
- **Import**: pick a zip → `dryRun` preview → confirm
|
|
181
|
-
- `_index.json`
|
|
182
|
-
- No size
|
|
190
|
+
- **Export**: Tools tab → Export, packed as `toolSequence.zip` (store) into the current workspace, returning the path (no browser download).
|
|
191
|
+
- **Import**: pick a zip → `dryRun` preview → confirm; same-name directories kept as `.bak-<ts>`.
|
|
192
|
+
- The archive's `_index.json` is ignored; the index is rebuilt from landed files. `_runs`, backups, out-of-scope paths and invalid ids are skipped.
|
|
193
|
+
- No size limit; zip bombs are judged by "unpacked bytes + 16 MB vs free disk". No zip64, no encryption.
|
|
183
194
|
|
|
184
|
-
####
|
|
195
|
+
#### Clearing caches
|
|
185
196
|
|
|
186
197
|
Two clicks (the first only changes the button label):
|
|
187
198
|
|
|
188
|
-
- **
|
|
189
|
-
- **
|
|
190
|
-
- Only "valid id + `.bak-` + digits" directories
|
|
191
|
-
- One
|
|
199
|
+
- **Deletes**: `<id>.bak-<ts>` rollback directories and all `_runs/` logs.
|
|
200
|
+
- **Keeps**: `_index.json` and every `<id>/` directory.
|
|
201
|
+
- Only "valid id + `.bak-` + digits" directories; in-progress import temp dirs are skipped.
|
|
202
|
+
- One failure does not abort the sweep; the result reports counts and bytes.
|
|
192
203
|
|
|
193
204
|
<a name="sec-reviews"></a>
|
|
194
205
|
|
|
195
|
-
## Reviews
|
|
196
|
-
|
|
197
|
-
The shadowed transcript is kept as a file and can be read back when it matters.
|
|
206
|
+
## Reviews
|
|
198
207
|
|
|
199
|
-
|
|
208
|
+
Reviews are the raw material for sealing: when a session is compacted, **tool calls and their arguments are persisted verbatim**, so the model can later recover the exact chain and seal it with `session_tool_create_write`. Without reviews, sealing can only happen inside a single session.
|
|
200
209
|
|
|
201
|
-
-
|
|
202
|
-
-
|
|
203
|
-
-
|
|
204
|
-
-
|
|
205
|
-
-
|
|
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).
|
|
210
|
+
- Produced only on **compaction**: summary + original text + empty diary; tool calls and arguments kept verbatim.
|
|
211
|
+
- Not produced for subagent sessions; nothing is even checked while "Automatic review" is off.
|
|
212
|
+
- "Delete and review" triggers the chain explicitly; the session is deleted only after the review lands.
|
|
213
|
+
- Compaction runs through the host command table (`/compact` by the command handler); the latest `compaction/summary` is split into a review.
|
|
214
|
+
- Every failed step is logged to `session-memory/_compact-delete.log` (last 64 KB kept past 256 KB).
|
|
208
215
|
|
|
209
216
|
#### Four levels
|
|
210
217
|
|
|
211
|
-
|
|
|
218
|
+
| When | Level | Model sees |
|
|
212
219
|
|---|---|---|
|
|
213
|
-
|
|
|
214
|
-
|
|
|
215
|
-
|
|
|
216
|
-
| day 29
|
|
220
|
+
| Compaction day | 3 | Original dialogue (tool calls and errors filtered) |
|
|
221
|
+
| Day 2 | 2 | Compaction summary |
|
|
222
|
+
| Day 3–28 | 1 | Diary |
|
|
223
|
+
| From day 29 | 0 | Keywords + file name |
|
|
217
224
|
|
|
218
|
-
|
|
225
|
+
Calendar days, local time. Only this workspace's own review, when read out, gains a level and locks (0→1, 1→2); child, sibling and parent workspaces are read-only and do not count.
|
|
219
226
|
|
|
220
|
-
####
|
|
227
|
+
#### Search scope
|
|
221
228
|
|
|
222
|
-
|
|
229
|
+
Order: this workspace → children → siblings → parent → parent's siblings → their 1–2 levels of children. Outer rings require `allowOuter`.
|
|
223
230
|
|
|
224
|
-
|
|
231
|
+
Match order: keywords, then summary, then original text; within a workspace by level, hit count, compaction time.
|
|
225
232
|
|
|
226
|
-
####
|
|
233
|
+
#### Reminders
|
|
227
234
|
|
|
228
|
-
At level 1 or 0, an empty diary or
|
|
229
|
-
|
|
230
|
-
- **In context** (default): appended to the review text, disappears once written.
|
|
231
|
-
- **In the system prompt**: a trailing prompt section.
|
|
235
|
+
At level 1 or 0, an empty diary or keyword set triggers one reminder: inline in the review body by default (it disappears once written), or as a system-prompt section.
|
|
232
236
|
|
|
233
237
|
#### Injection and preview
|
|
234
238
|
|
|
235
|
-
- Reviews
|
|
236
|
-
- The preview
|
|
237
|
-
-
|
|
239
|
+
- Reviews are injected each turn, oldest first.
|
|
240
|
+
- The settings preview uses the same assembly function as real injection.
|
|
241
|
+
- Assembly failure yields a diagnostic (how many, how large, which is largest), never "no reviews".
|
|
238
242
|
|
|
239
|
-
####
|
|
243
|
+
#### Review tools
|
|
240
244
|
|
|
241
|
-
Installed only
|
|
245
|
+
Installed only when "Automatic review" is on.
|
|
242
246
|
|
|
243
247
|
| Tool | Purpose | Key arguments |
|
|
244
248
|
|---|---|---|
|
|
245
|
-
| `session_mem_read` |
|
|
246
|
-
| `session_mem_write` |
|
|
249
|
+
| `session_mem_read` | Find a review by clue, one per call | `need` (required), `skip`, `allowOuter` |
|
|
250
|
+
| `session_mem_write` | Read one review's original text; write keywords and diary, batched | `file` or `date`+`nth`; `keywords`, `diary`; `writes[]` |
|
|
247
251
|
|
|
248
|
-
- Locator
|
|
249
|
-
-
|
|
250
|
-
- Neither tool changes
|
|
252
|
+
- Locator without content = read the "original" section: dialogue only, tool calls stripped.
|
|
253
|
+
- Batch via `writes[]`: all entries must validate before anything is written.
|
|
254
|
+
- Neither tool changes a review's level.
|
|
251
255
|
|
|
252
|
-
|
|
256
|
+
<a name="sec-sessions"></a>
|
|
253
257
|
|
|
254
|
-
|
|
258
|
+
## Session management
|
|
255
259
|
|
|
256
|
-
|
|
260
|
+
The Sessions tab lists local sessions grouped by workspace, reading persisted logs. Each workspace starts collapsed; click its path to expand.
|
|
261
|
+
|
|
262
|
+
- Each group is a collapsible workspace header (collapsed by default) with the session count on the right; the selected workspace keeps a blue dot while collapsed; empty workspaces are omitted.
|
|
263
|
+
- Import / Delete / Delete and review sit in the page header, so you do not have to scroll to the bottom of the list.
|
|
264
|
+
- The whole settings section shares one page scrollbar; only the preview boxes (tool list, review) keep their own inner scrollbar.
|
|
265
|
+
- One row per session: title (id placeholder in grey when not yet known), "Archived" badge when applicable.
|
|
266
|
+
- Unreadable logs are reported at the top instead of being shown as empty sessions.
|
|
267
|
+
|
|
268
|
+
#### Import
|
|
269
|
+
|
|
270
|
+
- "Import" at the far left of the page header; pick `dsh-session-<id>.zip`. Disabled with a reason when the host cannot write zstd.
|
|
271
|
+
- Dry run first (new id? branch?), write only after confirmation.
|
|
272
|
+
- Log becomes "header frame + body frame", then `attachSession`; images and files land in the attachment store by sha256; the host list is notified, no restart needed.
|
|
273
|
+
- A colliding id gets a new id, the original untouched; collisions inside the same workspace attach as a branch (`parentSession`).
|
|
274
|
+
- `workspace.json` and the directory registry are backed up into `会话导入备份-<time>/` before writing.
|
|
275
|
+
|
|
276
|
+
#### Delete
|
|
257
277
|
|
|
258
|
-
|
|
278
|
+
- Two-click confirmation.
|
|
279
|
+
- Live sessions are cancelled → idled → flushed → disposed before the directory is removed; refusal keeps the logs.
|
|
280
|
+
- The workspace entry is removed too, so the row disappears.
|
|
281
|
+
- If the engine still holds a reference the result says "may still remember it until restart".
|
|
259
282
|
|
|
260
|
-
|
|
283
|
+
#### Delete and review
|
|
261
284
|
|
|
262
|
-
|
|
285
|
+
- Compress into a review, wait for extraction, verify, then delete; any failure keeps the session.
|
|
286
|
+
- Every failed step is logged to `session-memory/_compact-delete.log`.
|
|
287
|
+
- The review appears on the Reviews tab and decays by calendar day.
|
|
288
|
+
|
|
289
|
+
<a name="sec-config"></a>
|
|
290
|
+
|
|
291
|
+
## Configuration
|
|
292
|
+
|
|
293
|
+
There is one config file, `$DSH_HOME/session-memory/_options.json`, shared by all workspaces and applied immediately. Settings → **Tool (script) manager** → **Options** edits the same file.
|
|
263
294
|
|
|
264
295
|
| Tab | Contents |
|
|
265
296
|
|---|---|
|
|
266
|
-
|
|
|
267
|
-
| Sessions |
|
|
268
|
-
| Reviews |
|
|
269
|
-
| Options |
|
|
270
|
-
|
|
271
|
-
#### Every option field
|
|
297
|
+
| Tools | Tool path, injected prompt text, list switch and refresh mode, import / export / clear cache |
|
|
298
|
+
| Sessions | Sessions grouped by workspace; import, delete, delete-and-review (both confirmed) |
|
|
299
|
+
| Reviews | Calendar filter, review list with level badges, injection preview, delete one |
|
|
300
|
+
| Options | Four groups: sealing, review injection, review content, review depth |
|
|
272
301
|
|
|
273
302
|
| Field | Values | Default | Meaning |
|
|
274
303
|
|---|---|---|---|
|
|
275
|
-
| `autoReviewEnabled` | bool | `false` |
|
|
276
|
-
| `injectEnabled` | bool | `true` |
|
|
277
|
-
| `toolListEnabled` | bool | `true` |
|
|
278
|
-
| `toolListRefresh` | `newSession` / `realtime` | `newSession` |
|
|
279
|
-
| `fullLoad` | bool | `false` |
|
|
280
|
-
| `reminderChannel` | `context` / `system` | `context` |
|
|
281
|
-
| `stopLowering` | bool | `false` |
|
|
282
|
-
| `loadLevel` | `follow` / 0–3 | `follow` |
|
|
304
|
+
| `autoReviewEnabled` | bool | `false` | Master switch: no reviews, no injection, no review tools when off |
|
|
305
|
+
| `injectEnabled` | bool | `true` | Review injection and diary reminders (not the tool list) |
|
|
306
|
+
| `toolListEnabled` | bool | `true` | Inject the tool list and install the three `session_tool_*` tools |
|
|
307
|
+
| `toolListRefresh` | `newSession` / `realtime` | `newSession` | When the list is recomputed |
|
|
308
|
+
| `fullLoad` | bool | `false` | Keep tool calls and errors at level 3 (reloads everything) |
|
|
309
|
+
| `reminderChannel` | `context` / `system` | `context` | Where diary reminders appear |
|
|
310
|
+
| `stopLowering` | bool | `false` | Reviews keep their recorded level and stop decaying |
|
|
311
|
+
| `loadLevel` | `follow` / 0–3 | `follow` | Force a level at load time (does not change the recorded level) |
|
|
283
312
|
|
|
284
|
-
Two
|
|
313
|
+
Two interactions: with automatic review off, review injection counts as off (the stored value is kept); with "stop lowering" on, the load level falls back to follow.
|
|
285
314
|
|
|
286
|
-
####
|
|
315
|
+
#### Language
|
|
287
316
|
|
|
288
|
-
|
|
317
|
+
UI text, injected review bodies, diary reminders and the tool list follow the DSH language setting. Review files record their headers in the language current **when written**; switching language only changes display (all 8 variants are recognised). Tool errors and receipts returned to the model are English.
|
|
289
318
|
|
|
290
319
|
<a name="sec-data"></a>
|
|
291
320
|
|
|
292
321
|
## Data and backup
|
|
293
322
|
|
|
294
|
-
|
|
323
|
+
```text
|
|
295
324
|
$DSH_HOME/session-memory/
|
|
296
325
|
_options.json options
|
|
297
326
|
_locale.json language
|
|
298
327
|
_health.json last success/failure per workspace
|
|
299
|
-
_compact-delete.log
|
|
328
|
+
_compact-delete.log compaction and delete-and-review diagnostics (>256 KB truncated)
|
|
300
329
|
<workspace key>/
|
|
301
|
-
<
|
|
302
|
-
<same
|
|
303
|
-
_assembly.json.migrated-*
|
|
304
|
-
toolSequence/ tool scripts (machine
|
|
305
|
-
|
|
330
|
+
<ts>-<id>.md review body (plain text, readable and editable)
|
|
331
|
+
<same>.json load cache (rebuilt from file times if lost)
|
|
332
|
+
_assembly.json.migrated-* legacy index leftovers (never deleted automatically)
|
|
333
|
+
toolSequence/ tool scripts (machine-wide, shared by all workspaces)
|
|
334
|
+
```
|
|
306
335
|
|
|
307
|
-
-
|
|
308
|
-
- Backup
|
|
309
|
-
- Uninstalling
|
|
336
|
+
- Workspace keys use the host's `sessions/` encoding: `/` becomes `-`, non-ASCII as `~XXXX`.
|
|
337
|
+
- Backup = copy the whole `session-memory/`; migrate = same path on the new machine plus the same plugin.
|
|
338
|
+
- Uninstalling does not delete data.
|
|
310
339
|
|
|
311
340
|
<a name="sec-compat"></a>
|
|
312
341
|
|
|
313
|
-
## Compatibility
|
|
342
|
+
## Compatibility
|
|
314
343
|
|
|
315
|
-
Missing host capabilities disable the matching
|
|
344
|
+
Missing host capabilities disable the matching part only (the settings page lists what is missing):
|
|
316
345
|
|
|
317
346
|
| Missing | Effect |
|
|
318
347
|
|---|---|
|
|
319
|
-
| `systemPrompt.context` |
|
|
320
|
-
| `systemPrompt.section` | diary
|
|
321
|
-
| `tools.register` |
|
|
322
|
-
| `webServer.register` | settings
|
|
323
|
-
| `agents.create` / `resume` |
|
|
324
|
-
| `commands.execute
|
|
348
|
+
| `systemPrompt.context` | Review injection off |
|
|
349
|
+
| `systemPrompt.section` | No diary-reminder or tool-list section |
|
|
350
|
+
| `tools.register` | None of the five tools is installed |
|
|
351
|
+
| `webServer.register` | No settings API |
|
|
352
|
+
| `agents.create` / `resume` | Deleting a live session drops to fallback teardown |
|
|
353
|
+
| `commands.execute` or no `command-compact` in the preset | Delete-and-review unavailable; plain delete works |
|
|
325
354
|
|
|
326
|
-
|
|
355
|
+
Deleting a live session has two paths: ① the `dispose` returned by `agents.create` / `resume`, captured by the lifecycle; ② without a handle, a synthetic `cancel({kind:'disposed'})` → `whenIdle()` → `scope.dispose()`. Path ② can stop the agent but cannot unregister it from the host closure, so the delete succeeds with `warnings` ("deleted (may be remembered until engine restart)").
|
|
327
356
|
|
|
328
|
-
Session logs are multi-frame zstd,
|
|
357
|
+
Session logs are multi-frame zstd, decoded frame by frame; the built-in decoder is used when `zlib.zstdDecompressSync` is unavailable. Importing sessions needs host zstd compression: without `zstdCompress` the Import button is disabled with a reason.
|
|
329
358
|
|
|
330
359
|
<a name="sec-limits"></a>
|
|
331
360
|
|
|
332
361
|
## Known limitations
|
|
333
362
|
|
|
334
|
-
- Tool scripts have **no delete or edit
|
|
363
|
+
- Tool scripts have **no UI for delete or edit**: replace them (keeping `.bak-`) or remove the directory by hand (the index keeps the entry and runs fail with "directory not found").
|
|
335
364
|
- `steps` never chain automatically; use `calls`.
|
|
336
|
-
- Reviews are
|
|
337
|
-
- Subagent sessions produce no reviews and no diary
|
|
338
|
-
- Import
|
|
339
|
-
- Delete
|
|
340
|
-
-
|
|
365
|
+
- Reviews are produced only on compaction; the Reviews tab has a calendar filter but no full-text search.
|
|
366
|
+
- Subagent sessions produce no reviews and get no diary reminders.
|
|
367
|
+
- Import/export covers tool scripts only; reviews travel by copying `session-memory/`. Session zips are a separate import on the Sessions tab.
|
|
368
|
+
- Delete-and-review requires the preset to provide `command-compact`.
|
|
369
|
+
- Fallback teardown may leave the session remembered until the engine restarts.
|
|
370
|
+
- A freshly imported cold session shows `Untitled` in the sidebar until the host's title projection loads.
|
|
341
371
|
|
|
342
372
|
<a name="sec-dev"></a>
|
|
343
373
|
|
|
344
374
|
## Development
|
|
345
375
|
|
|
346
|
-
|
|
376
|
+
```text
|
|
347
377
|
index.js plugin entry (exports name / apply / inject)
|
|
348
378
|
cordis.patch.yml inserts the plugin into the host loader
|
|
349
|
-
lib/core/ host-side logic:
|
|
350
|
-
lib/host/ host service adapters:
|
|
351
|
-
lib/client.js settings
|
|
352
|
-
|
|
379
|
+
lib/core/ host-side logic: persistence, decay, tool definitions, script runner
|
|
380
|
+
lib/host/ host service adapters: HTTP endpoints, capability probing, session import/delete
|
|
381
|
+
lib/client.js settings UI (React, registered into settings.section)
|
|
382
|
+
```
|
|
353
383
|
|
|
354
384
|
- Zero runtime dependencies, ESM, Node `>=18`.
|
|
355
|
-
- Tests `node --test test/*.test.mjs` (not shipped
|
|
356
|
-
-
|
|
385
|
+
- Tests: `node --test test/*.test.mjs` (not shipped).
|
|
386
|
+
- Package: `npm pack`, whitelist in `package.json` `files`.
|
|
357
387
|
|
|
358
388
|
## License
|
|
359
389
|
|