dsh-seal-scripts 0.6.1 → 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 +226 -231
- package/README.md +108 -106
- package/lib/client.js +215 -32
- 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,385 +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
|
-
- [
|
|
23
|
-
- [Session management](#sec-sessions)
|
|
18
|
+
- [Sealing](#sec-tools)
|
|
24
19
|
- [Reviews](#sec-reviews)
|
|
25
|
-
- [
|
|
20
|
+
- [Session management](#sec-sessions)
|
|
21
|
+
- [Configuration](#sec-config)
|
|
26
22
|
- [Data and backup](#sec-data)
|
|
27
|
-
- [Compatibility
|
|
23
|
+
- [Compatibility](#sec-compat)
|
|
28
24
|
- [Known limitations](#sec-limits)
|
|
29
25
|
- [Development](#sec-dev)
|
|
30
26
|
|
|
31
|
-
<a name="sec-
|
|
32
|
-
|
|
33
|
-
## Features
|
|
27
|
+
<a name="sec-class"></a>
|
|
34
28
|
|
|
35
|
-
|
|
29
|
+
## CLI solidification
|
|
36
30
|
|
|
37
|
-
|
|
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.
|
|
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:
|
|
42
32
|
|
|
43
|
-
|
|
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.
|
|
44
59
|
|
|
45
|
-
-
|
|
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.
|
|
60
|
+
<a name="sec-install"></a>
|
|
49
61
|
|
|
50
|
-
|
|
62
|
+
## Install
|
|
51
63
|
|
|
52
|
-
|
|
53
|
-
- A missing host capability disables that block only.
|
|
54
|
-
- Plain-text data: copy `session-memory/` for a backup.
|
|
64
|
+
Add the package through the plugin manager (package name, local path, tarball or Git). `--profile` is required, e.g. `web`:
|
|
55
65
|
|
|
56
|
-
|
|
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
|
+
```
|
|
57
71
|
|
|
58
|
-
|
|
72
|
+
`dsh plugin` forwards its arguments to pnpm inside the profile directory, so the npm route works too:
|
|
59
73
|
|
|
60
|
-
|
|
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
|
+
```
|
|
61
78
|
|
|
62
|
-
|
|
63
|
-
dsh plugin --profile web add dsh-seal-scripts
|
|
64
|
-
dsh plugin --profile web add /path/to/dsh-seal-scripts
|
|
65
|
-
~~~
|
|
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.
|
|
66
80
|
|
|
67
|
-
|
|
81
|
+
Reload the profile after installing.
|
|
68
82
|
|
|
69
|
-
|
|
83
|
+
Requires host `@deepseek-ai/dsh` `>=0.2.2-rc.1`, `<1.0.0` (peer, optional) and Node `>=18`.
|
|
70
84
|
|
|
71
|
-
|
|
85
|
+
A **Tool (script) manager** section appearing in settings means it loaded.
|
|
72
86
|
|
|
73
87
|
<a name="sec-quickstart"></a>
|
|
74
88
|
|
|
75
89
|
## Quick start
|
|
76
90
|
|
|
77
|
-
1.
|
|
78
|
-
2.
|
|
79
|
-
3.
|
|
80
|
-
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`.
|
|
81
95
|
|
|
82
|
-
|
|
83
|
-
You:
|
|
84
|
-
Model:
|
|
85
|
-
|
|
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
|
|
86
100
|
|
|
87
101
|
(new session)
|
|
88
|
-
You:
|
|
89
|
-
Model:
|
|
90
|
-
|
|
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
|
+
```
|
|
91
105
|
|
|
92
106
|
<a name="sec-tools"></a>
|
|
93
107
|
|
|
94
|
-
##
|
|
108
|
+
## Sealing
|
|
95
109
|
|
|
96
|
-
####
|
|
110
|
+
#### Triggers
|
|
97
111
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
#### How to trigger it
|
|
101
|
-
|
|
102
|
-
| What you say | What happens | When to use |
|
|
112
|
+
| You say | It does | Good for |
|
|
103
113
|
|---|---|---|
|
|
104
|
-
|
|
|
105
|
-
|
|
|
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 |
|
|
106
116
|
|
|
107
|
-
The
|
|
117
|
+
The sealed copy is the one that ran, not a draft. Editing afterwards means resending the context (or `replace`).
|
|
108
118
|
|
|
109
|
-
####
|
|
119
|
+
#### Layout
|
|
110
120
|
|
|
111
|
-
|
|
121
|
+
```text
|
|
112
122
|
$DSH_HOME/session-memory/toolSequence/
|
|
113
|
-
_index.json
|
|
123
|
+
_index.json catalog: id, title, purpose, entry, params, steps, per-file sha256
|
|
114
124
|
<id>/
|
|
115
|
-
toolScript.json manifest:
|
|
116
|
-
<script> the file
|
|
125
|
+
toolScript.json manifest: script text, docs, hashes, provenance
|
|
126
|
+
<script> the executed file (.sh / .js .mjs .cjs / .ps1 / .bat .cmd)
|
|
117
127
|
README.md generated from the manifest
|
|
118
128
|
<notes>.md read-only notes (never executed)
|
|
119
|
-
_runs/ full stdout/stderr
|
|
120
|
-
<id>.bak-<
|
|
121
|
-
|
|
129
|
+
_runs/ full stdout/stderr per run
|
|
130
|
+
<id>.bak-<ts>/ kept on replace / import
|
|
131
|
+
```
|
|
122
132
|
|
|
123
|
-
####
|
|
133
|
+
#### System-prompt injection
|
|
124
134
|
|
|
125
|
-
|
|
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.
|
|
126
136
|
|
|
127
137
|
| Mode | Behaviour | Cost |
|
|
128
138
|
|---|---|---|
|
|
129
|
-
| Before a new session (default) |
|
|
130
|
-
|
|
|
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 |
|
|
131
141
|
|
|
132
|
-
|
|
142
|
+
Switching modes refreshes every remembered session immediately.
|
|
133
143
|
|
|
134
|
-
####
|
|
144
|
+
#### Tools
|
|
135
145
|
|
|
136
146
|
| Tool | Purpose | Key arguments |
|
|
137
147
|
|---|---|---|
|
|
138
|
-
| `session_tool_create_write` |
|
|
139
|
-
| `session_tool_create_read` |
|
|
140
|
-
| `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` |
|
|
141
151
|
|
|
142
|
-
- No arguments:
|
|
143
|
-
- `dryRun: true`:
|
|
144
|
-
- `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.
|
|
145
155
|
|
|
146
|
-
####
|
|
156
|
+
#### Seal-time validation
|
|
147
157
|
|
|
148
158
|
| Item | Rule |
|
|
149
159
|
|---|---|
|
|
150
|
-
| `id` |
|
|
151
|
-
|
|
|
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 |
|
|
152
162
|
| `run` vs extension | bash→`.sh`; node→`.js/.mjs/.cjs`; ps1→`.ps1`; cmd→`.bat/.cmd` |
|
|
153
|
-
|
|
|
154
|
-
| `title` / `purpose` |
|
|
155
|
-
| `entry` / `steps` |
|
|
156
|
-
| `timeoutMs` |
|
|
157
|
-
|
|
|
158
|
-
|
|
|
159
|
-
|
|
|
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 |
|
|
160
170
|
|
|
161
|
-
`steps`
|
|
171
|
+
`steps` declares order only (no auto chaining); `params` declares argv order only (names unvalidated).
|
|
162
172
|
|
|
163
|
-
#### Execution
|
|
173
|
+
#### Execution
|
|
164
174
|
|
|
165
175
|
| Item | Value |
|
|
166
176
|
|---|---|
|
|
167
|
-
|
|
|
168
|
-
| 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 |
|
|
169
179
|
| cwd | `workspace`, `toolScript`, or an absolute path inside either |
|
|
170
|
-
|
|
|
171
|
-
|
|
|
172
|
-
|
|
|
173
|
-
|
|
|
174
|
-
|
|
|
175
|
-
|
|
|
176
|
-
|
|
|
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 |
|
|
177
187
|
|
|
178
188
|
#### Import / export
|
|
179
189
|
|
|
180
|
-
- **Export**:
|
|
181
|
-
- **Import**: pick a zip → `dryRun` preview → confirm
|
|
182
|
-
- `_index.json`
|
|
183
|
-
- 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.
|
|
184
194
|
|
|
185
|
-
####
|
|
195
|
+
#### Clearing caches
|
|
186
196
|
|
|
187
197
|
Two clicks (the first only changes the button label):
|
|
188
198
|
|
|
189
|
-
- **
|
|
190
|
-
- **
|
|
191
|
-
- Only "valid id + `.bak-` + digits" directories
|
|
192
|
-
- 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.
|
|
193
203
|
|
|
194
|
-
<a name="sec-
|
|
204
|
+
<a name="sec-reviews"></a>
|
|
195
205
|
|
|
196
|
-
##
|
|
206
|
+
## Reviews
|
|
197
207
|
|
|
198
|
-
|
|
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.
|
|
199
209
|
|
|
200
|
-
|
|
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).
|
|
201
215
|
|
|
202
|
-
|
|
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.
|
|
216
|
+
#### Four levels
|
|
205
217
|
|
|
206
|
-
|
|
218
|
+
| When | Level | Model sees |
|
|
219
|
+
|---|---|---|
|
|
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 |
|
|
207
224
|
|
|
208
|
-
|
|
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.
|
|
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.
|
|
213
226
|
|
|
214
|
-
####
|
|
227
|
+
#### Search scope
|
|
215
228
|
|
|
216
|
-
|
|
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.
|
|
229
|
+
Order: this workspace → children → siblings → parent → parent's siblings → their 1–2 levels of children. Outer rings require `allowOuter`.
|
|
220
230
|
|
|
221
|
-
|
|
231
|
+
Match order: keywords, then summary, then original text; within a workspace by level, hit count, compaction time.
|
|
222
232
|
|
|
223
|
-
|
|
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.
|
|
233
|
+
#### Reminders
|
|
227
234
|
|
|
228
|
-
|
|
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.
|
|
229
236
|
|
|
230
|
-
|
|
237
|
+
#### Injection and preview
|
|
231
238
|
|
|
232
|
-
|
|
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".
|
|
233
242
|
|
|
234
|
-
####
|
|
243
|
+
#### Review tools
|
|
235
244
|
|
|
236
|
-
|
|
237
|
-
- Tool calls and arguments are kept verbatim, never truncated.
|
|
238
|
-
- Spawned subagent sessions produce nothing; with Auto review off, not even detection happens.
|
|
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).
|
|
245
|
+
Installed only when "Automatic review" is on.
|
|
243
246
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
| Day | Level | What the model sees |
|
|
247
|
+
| Tool | Purpose | Key arguments |
|
|
247
248
|
|---|---|---|
|
|
248
|
-
|
|
|
249
|
-
|
|
|
250
|
-
| days 3–28 | 1 | the diary |
|
|
251
|
-
| day 29 and later | 0 | keywords plus the file name |
|
|
252
|
-
|
|
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.
|
|
254
|
-
|
|
255
|
-
#### Cross-workspace search
|
|
256
|
-
|
|
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`.
|
|
258
|
-
|
|
259
|
-
Hits go keywords first, then summary, then original; within a workspace they sort by level, matched terms, then compaction time.
|
|
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[]` |
|
|
260
251
|
|
|
261
|
-
|
|
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.
|
|
262
255
|
|
|
263
|
-
|
|
256
|
+
<a name="sec-sessions"></a>
|
|
264
257
|
|
|
265
|
-
|
|
266
|
-
- **In the system prompt**: a trailing prompt section.
|
|
258
|
+
## Session management
|
|
267
259
|
|
|
268
|
-
|
|
260
|
+
The Sessions tab lists local sessions grouped by workspace, reading persisted logs. Each workspace starts collapsed; click its path to expand.
|
|
269
261
|
|
|
270
|
-
-
|
|
271
|
-
-
|
|
272
|
-
-
|
|
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.
|
|
273
267
|
|
|
274
|
-
####
|
|
268
|
+
#### Import
|
|
275
269
|
|
|
276
|
-
|
|
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.
|
|
277
275
|
|
|
278
|
-
|
|
279
|
-
|---|---|---|
|
|
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[]` |
|
|
276
|
+
#### Delete
|
|
282
277
|
|
|
283
|
-
-
|
|
284
|
-
-
|
|
285
|
-
-
|
|
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".
|
|
286
282
|
|
|
287
|
-
####
|
|
283
|
+
#### Delete and review
|
|
288
284
|
|
|
289
|
-
|
|
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.
|
|
290
288
|
|
|
291
289
|
<a name="sec-config"></a>
|
|
292
290
|
|
|
293
|
-
## Configuration
|
|
291
|
+
## Configuration
|
|
294
292
|
|
|
295
|
-
There is one config file, `$DSH_HOME/session-memory/_options.json
|
|
296
|
-
|
|
297
|
-
#### The four tabs
|
|
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.
|
|
298
294
|
|
|
299
295
|
| Tab | Contents |
|
|
300
296
|
|---|---|
|
|
301
|
-
|
|
|
302
|
-
| Sessions |
|
|
303
|
-
| Reviews |
|
|
304
|
-
| Options |
|
|
305
|
-
|
|
306
|
-
#### 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 |
|
|
307
301
|
|
|
308
302
|
| Field | Values | Default | Meaning |
|
|
309
303
|
|---|---|---|---|
|
|
310
|
-
| `autoReviewEnabled` | bool | `false` |
|
|
311
|
-
| `injectEnabled` | bool | `true` |
|
|
312
|
-
| `toolListEnabled` | bool | `true` |
|
|
313
|
-
| `toolListRefresh` | `newSession` / `realtime` | `newSession` |
|
|
314
|
-
| `fullLoad` | bool | `false` |
|
|
315
|
-
| `reminderChannel` | `context` / `system` | `context` |
|
|
316
|
-
| `stopLowering` | bool | `false` |
|
|
317
|
-
| `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) |
|
|
318
312
|
|
|
319
|
-
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.
|
|
320
314
|
|
|
321
|
-
####
|
|
315
|
+
#### Language
|
|
322
316
|
|
|
323
|
-
|
|
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.
|
|
324
318
|
|
|
325
319
|
<a name="sec-data"></a>
|
|
326
320
|
|
|
327
321
|
## Data and backup
|
|
328
322
|
|
|
329
|
-
|
|
323
|
+
```text
|
|
330
324
|
$DSH_HOME/session-memory/
|
|
331
325
|
_options.json options
|
|
332
326
|
_locale.json language
|
|
333
327
|
_health.json last success/failure per workspace
|
|
334
|
-
_compact-delete.log
|
|
328
|
+
_compact-delete.log compaction and delete-and-review diagnostics (>256 KB truncated)
|
|
335
329
|
<workspace key>/
|
|
336
|
-
<
|
|
337
|
-
<same
|
|
338
|
-
_assembly.json.migrated-*
|
|
339
|
-
toolSequence/ tool scripts (machine
|
|
340
|
-
|
|
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
|
+
```
|
|
341
335
|
|
|
342
|
-
-
|
|
343
|
-
- Backup
|
|
344
|
-
- 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.
|
|
345
339
|
|
|
346
340
|
<a name="sec-compat"></a>
|
|
347
341
|
|
|
348
|
-
## Compatibility
|
|
342
|
+
## Compatibility
|
|
349
343
|
|
|
350
|
-
Missing host capabilities disable the matching
|
|
344
|
+
Missing host capabilities disable the matching part only (the settings page lists what is missing):
|
|
351
345
|
|
|
352
346
|
| Missing | Effect |
|
|
353
347
|
|---|---|
|
|
354
|
-
| `systemPrompt.context` |
|
|
355
|
-
| `systemPrompt.section` | diary
|
|
356
|
-
| `tools.register` |
|
|
357
|
-
| `webServer.register` | settings
|
|
358
|
-
| `agents.create` / `resume` |
|
|
359
|
-
| `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 |
|
|
360
354
|
|
|
361
|
-
|
|
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)").
|
|
362
356
|
|
|
363
|
-
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.
|
|
364
358
|
|
|
365
359
|
<a name="sec-limits"></a>
|
|
366
360
|
|
|
367
361
|
## Known limitations
|
|
368
362
|
|
|
369
|
-
- 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").
|
|
370
364
|
- `steps` never chain automatically; use `calls`.
|
|
371
|
-
- Reviews are
|
|
372
|
-
- Subagent sessions produce no reviews and no diary
|
|
373
|
-
- Import
|
|
374
|
-
- Delete
|
|
375
|
-
-
|
|
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.
|
|
376
371
|
|
|
377
372
|
<a name="sec-dev"></a>
|
|
378
373
|
|
|
379
374
|
## Development
|
|
380
375
|
|
|
381
|
-
|
|
376
|
+
```text
|
|
382
377
|
index.js plugin entry (exports name / apply / inject)
|
|
383
378
|
cordis.patch.yml inserts the plugin into the host loader
|
|
384
|
-
lib/core/ host-side logic:
|
|
385
|
-
lib/host/ host service adapters:
|
|
386
|
-
lib/client.js settings
|
|
387
|
-
|
|
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
|
+
```
|
|
388
383
|
|
|
389
384
|
- Zero runtime dependencies, ESM, Node `>=18`.
|
|
390
|
-
- Tests `node --test test/*.test.mjs` (not shipped
|
|
391
|
-
-
|
|
385
|
+
- Tests: `node --test test/*.test.mjs` (not shipped).
|
|
386
|
+
- Package: `npm pack`, whitelist in `package.json` `files`.
|
|
392
387
|
|
|
393
388
|
## License
|
|
394
389
|
|