@songtonyli/dsh-cli 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@deepseek-ai/dsh-base/cordis.patch.yml +11 -0
- package/node_modules/@deepseek-ai/dsh-base/package.json +1 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-compaction-basic/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-compaction-basic/README.md +32 -3
- package/node_modules/@deepseek-ai/dsh-compaction-basic/README.zh.md +32 -3
- package/node_modules/@deepseek-ai/dsh-compaction-basic/lib/index.js +153 -3
- package/node_modules/@deepseek-ai/dsh-goal-round-driver/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-goal-round-driver/README.md +17 -2
- package/node_modules/@deepseek-ai/dsh-goal-round-driver/README.zh.md +17 -2
- package/node_modules/@deepseek-ai/dsh-goal-round-driver/lib/index.js +153 -2
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.md +1 -1
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.zh.md +1 -1
- package/node_modules/@deepseek-ai/dsh-llm-cursor/lib/index.js +48 -24
- package/node_modules/@deepseek-ai/dsh-no-progress-reminder/README.i18n.yaml +6 -0
- package/node_modules/@deepseek-ai/dsh-no-progress-reminder/README.md +164 -0
- package/node_modules/@deepseek-ai/dsh-no-progress-reminder/README.zh.md +164 -0
- package/node_modules/@deepseek-ai/dsh-no-progress-reminder/lib/index.js +1516 -0
- package/node_modules/@deepseek-ai/dsh-no-progress-reminder/package.json +50 -0
- package/node_modules/@deepseek-ai/dsh-repeat-tool-reminder/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-repeat-tool-reminder/README.md +36 -11
- package/node_modules/@deepseek-ai/dsh-repeat-tool-reminder/README.zh.md +36 -11
- package/node_modules/@deepseek-ai/dsh-repeat-tool-reminder/lib/index.js +54 -7
- package/node_modules/@deepseek-ai/dsh-subagent/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-subagent/README.md +2 -2
- package/node_modules/@deepseek-ai/dsh-subagent/README.zh.md +2 -2
- package/node_modules/@deepseek-ai/dsh-subagent/lib/index.js +93 -32
- package/node_modules/@deepseek-ai/dsh-subagent/lib/types/continuation-messages.js +20 -7
- package/node_modules/@deepseek-ai/dsh-subagent/lib/types/diagnostic.js +39 -0
- package/node_modules/@deepseek-ai/dsh-subagent/lib/types/lifecycle.js +36 -4
- package/node_modules/@deepseek-ai/dsh-subagent/lib/types/out-of-process.js +1 -22
- package/node_modules/@deepseek-ai/dsh-tool-skill/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-skill/README.md +21 -4
- package/node_modules/@deepseek-ai/dsh-tool-skill/README.zh.md +21 -4
- package/node_modules/@deepseek-ai/dsh-tool-skill/lib/index.js +194 -16
- package/node_modules/@deepseek-ai/dsh-tool-todo/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tool-todo/README.md +3 -3
- package/node_modules/@deepseek-ai/dsh-tool-todo/README.zh.md +3 -3
- package/node_modules/@deepseek-ai/dsh-tool-todo/lib/index.js +32 -6
- package/node_modules/@deepseek-ai/dsh-tool-todo/lib/types/index.js +31 -5
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +24 -18
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +24 -18
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +400 -100
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ workspace and no build step. Native packages that ship one build per platform
|
|
|
26
26
|
ripgrep, the PTY backend's addons, sharp, koffi, and the Landlock launcher — are
|
|
27
27
|
ordinary optional dependencies, so npm resolves the right one for your machine.
|
|
28
28
|
|
|
29
|
-
Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.
|
|
29
|
+
Requires Node `^22.19.0 || >=24.0.0`. Version 0.1.23; `dsh --version`
|
|
30
30
|
also reports the harness build the package was assembled from.
|
|
31
31
|
|
|
32
32
|
## License
|
package/bin/dsh.mjs
CHANGED
|
@@ -18,7 +18,7 @@ const argv = process.argv.slice(2)
|
|
|
18
18
|
// version this package publishes. Reporting only one of the two would make an
|
|
19
19
|
// ordinary `npm install @songtonyli/dsh-cli@x` look like it installed something else.
|
|
20
20
|
if (argv.length === 1 && (argv[0] === '--version' || argv[0] === '-V')) {
|
|
21
|
-
console.log('@songtonyli/dsh-cli 0.1.
|
|
21
|
+
console.log('@songtonyli/dsh-cli 0.1.23 (deepseek-harness 0.1.6-alpha.2)')
|
|
22
22
|
process.exit(0)
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -302,6 +302,8 @@
|
|
|
302
302
|
|
|
303
303
|
- id: tool-skill
|
|
304
304
|
name: '@deepseek-ai/dsh-tool-skill'
|
|
305
|
+
config:
|
|
306
|
+
closedCatalogProviders: [cursor]
|
|
305
307
|
|
|
306
308
|
- id: commands
|
|
307
309
|
name: '@deepseek-ai/dsh-commands'
|
|
@@ -456,6 +458,15 @@
|
|
|
456
458
|
config:
|
|
457
459
|
thresholds: [3, 5, 8]
|
|
458
460
|
argumentsPreviewChars: 500
|
|
461
|
+
blockThreshold: 2
|
|
462
|
+
blockProviders: [cursor]
|
|
463
|
+
|
|
464
|
+
# Idle-goal turns with no successful edit/write/bash.
|
|
465
|
+
- id: no-progress-reminder
|
|
466
|
+
name: '@deepseek-ai/dsh-no-progress-reminder'
|
|
467
|
+
config:
|
|
468
|
+
idleTurns: 5
|
|
469
|
+
providers: [cursor]
|
|
459
470
|
|
|
460
471
|
# The shared base enables the stable model-facing web_search and web_fetch
|
|
461
472
|
# tools. The Web app disables this host row and composes both tools per agent
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"@deepseek-ai/dsh-plan-mode": "0.1.6-alpha.2",
|
|
69
69
|
"@deepseek-ai/dsh-pwsh-sandbox": "0.1.6-alpha.2",
|
|
70
70
|
"@deepseek-ai/dsh-repeat-tool-reminder": "0.1.6-alpha.2",
|
|
71
|
+
"@deepseek-ai/dsh-no-progress-reminder": "0.1.6-alpha.2",
|
|
71
72
|
"@deepseek-ai/dsh-sandbox-local": "0.1.6-alpha.2",
|
|
72
73
|
"@deepseek-ai/dsh-sandbox-policy": "0.1.6-alpha.2",
|
|
73
74
|
"@deepseek-ai/dsh-session": "0.1.6-alpha.2",
|
|
@@ -160,7 +160,7 @@ window.__ModuleLoader__.load({
|
|
|
160
160
|
const SCROLLBAR_LINGER_MS = 2e3;
|
|
161
161
|
/** Format complete-build metadata for the local brand badge. */
|
|
162
162
|
function localBuildVersion() {
|
|
163
|
-
return `0.1.6-alpha.2-
|
|
163
|
+
return `0.1.6-alpha.2-33b866e-dirty`;
|
|
164
164
|
}
|
|
165
165
|
/** Each panel row subscribes only to its own selection state. */
|
|
166
166
|
function PanelRow({ id, label, wide, usePanelInfo, selectPanel, renderSlot }) {
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/compaction/compaction-basic/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 108e5d2eac97a0174aa4c6f9508ae7179aa76478
|
|
6
|
+
README.zh.md: e45cbbd7116086049ac681209a1b86bc1a71993a
|
|
@@ -134,6 +134,7 @@ The transaction validates the surface span and the durable lock, appends `compac
|
|
|
134
134
|
| [`src/index.ts`](src/index.ts) | Plugin entry: `BasicCompactionEngine`, automatic listeners, entry-point dispatch |
|
|
135
135
|
| [`src/region.ts`](src/region.ts) | Retention selection and the shared bracket-first compaction transaction |
|
|
136
136
|
| [`src/summarizer.ts`](src/summarizer.ts) | Default `ctx.llm.stream()` summarization, checkpoint framing, safe-summary projection |
|
|
137
|
+
| [`src/work-state.ts`](src/work-state.ts) | Model-switch work-state notice admitted after a `model-selection` notice whose incoming route is `cursor` |
|
|
137
138
|
| [`src/config.ts`](src/config.ts) | Load-time validation and routed-model policy resolution |
|
|
138
139
|
| [`src/types.ts`](src/types.ts) | `BasicCompactionConfig` and resolved policy vocabulary |
|
|
139
140
|
| — | No runtime invariant companion is published; this package exposes no independent event sequence or mutable data relation beyond contracts enforced at its owning seam. The durable bracket remains observable in the session log. |
|
|
@@ -163,7 +164,7 @@ Read these pages when the package-level contract is not enough; they move from t
|
|
|
163
164
|
|
|
164
165
|
#### What the model sees
|
|
165
166
|
|
|
166
|
-
After a successful step crosses the threshold, oversized tool results are first rewritten when the optional pruner is loaded. If summarization remains necessary, the next request receives the checkpoint preamble below, a blank line, `<compacted-summary>`, the data-dependent summary, and `</compacted-summary>`. Overflow recovery rebuilds the immediate retry from whatever replacement advanced the surface. A checkpoint replaces the selected older range and is followed by the retained recent units.
|
|
167
|
+
After a successful step crosses the threshold, oversized tool results are first rewritten when the optional pruner is loaded. If summarization remains necessary, the next request receives the checkpoint preamble below, a blank line, `<compacted-summary>`, the data-dependent summary, and `</compacted-summary>`. Overflow recovery rebuilds the immediate retry from whatever replacement advanced the surface. A checkpoint replaces the selected older range and is followed by the retained recent units. When an admitted step already includes a `model-selection` notice whose incoming route is the Cursor subscription (`cursor`), this backend appends one more user-role notice sourced `{ kind: 'plugin', plugin: 'compaction-basic', form: 'notice', summary: 'work state' }`. Cross-provider notices name `cursor/<model>`; a same-provider Cursor switch keeps a bare model id and uses the previous request header. A switch onto DeepSeek or a pi-ai catalog route does not receive the notice. That notice tells the successor to treat the latest `<compacted-summary>` (when history has one) and durable session/workspace state as authority, not to re-inspect completed work or re-derive a recorded plan, and to take the checkpoint Next Step or a state-changing tool (read only if a named file is missing). If the previous turn made no successful `edit`, `write`, or `bash` call, the notice includes `the previous turn made no file changes; do not repeat its plan`.
|
|
167
168
|
|
|
168
169
|
##### Conversation checkpoint preamble
|
|
169
170
|
|
|
@@ -171,6 +172,18 @@ After a successful step crosses the threshold, oversized tool results are first
|
|
|
171
172
|
This is an automatically generated checkpoint condensing an earlier span of the conversation to free up context. Treat the captured context as established background and build on it without restating it. Continue the task directly from the messages that follow, without acknowledging this checkpoint.
|
|
172
173
|
```
|
|
173
174
|
|
|
175
|
+
##### Model-switch work-state notice with a checkpoint
|
|
176
|
+
|
|
177
|
+
```markdown
|
|
178
|
+
[work state: treat the latest <compacted-summary> and durable session/workspace state as authority; do not re-inspect completed work or re-derive a plan already recorded; the next action is the checkpoint's Next Step, or a state-changing tool (read only if a named file is missing); the previous turn made no file changes; do not repeat its plan]
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
##### Model-switch work-state notice without a checkpoint
|
|
182
|
+
|
|
183
|
+
```markdown
|
|
184
|
+
[work state: do not re-inspect completed work or re-derive a plan already recorded; the next action is a state-changing tool (read only if a named file is missing); the previous turn made no file changes; do not repeat its plan]
|
|
185
|
+
```
|
|
186
|
+
|
|
174
187
|
#### Token effect
|
|
175
188
|
|
|
176
189
|
Model-free pruning can avoid the auxiliary call entirely; otherwise it reduces that call's transcript before the summary replaces an older range. The replacement reduces future input history rather than appending a second copy. A summary remains until a later compaction replaces it, while an indivisible non-tool unit can still exceed the budget.
|
|
@@ -208,11 +221,26 @@ Output EXACTLY the Markdown structure below: keep every section, in order. Use t
|
|
|
208
221
|
- [explicitly requested work not yet completed]
|
|
209
222
|
|
|
210
223
|
## Current Work
|
|
211
|
-
- [precisely what was in progress at this checkpoint]
|
|
224
|
+
- [precisely what was in progress at this checkpoint; if inspection of owners/files already happened, state that explicitly so a successor must NOT reopen "inspect owners"]
|
|
212
225
|
|
|
213
226
|
## Next Step
|
|
214
227
|
- [the single next action, directly in line with the most recent request, or "(none)"]
|
|
215
228
|
|
|
229
|
+
## Files Read
|
|
230
|
+
- [exact path: key facts already extracted; do not tell the successor to re-read unless the file changed]
|
|
231
|
+
|
|
232
|
+
## Decisions Taken
|
|
233
|
+
- [decision: what was chosen and why it is binding]
|
|
234
|
+
|
|
235
|
+
## Edits Applied
|
|
236
|
+
- [path: what changed]
|
|
237
|
+
|
|
238
|
+
## Edits Planned But Not Applied
|
|
239
|
+
- [path or area: what remains to write]
|
|
240
|
+
|
|
241
|
+
## Last Tool Results
|
|
242
|
+
- [last few tool names + one-line outcomes; quote error text verbatim]
|
|
243
|
+
|
|
216
244
|
## Critical Context
|
|
217
245
|
- [decisions and their rationale, constraints, user preferences, open questions, data needed to continue]
|
|
218
246
|
|
|
@@ -221,7 +249,8 @@ Rules:
|
|
|
221
249
|
- Capture user feedback and explicit instructions faithfully, especially corrections.
|
|
222
250
|
- Do NOT mention this summarization request or that the context was compacted.
|
|
223
251
|
- Output only the checkpoint text: do not call any tool or take any other action.
|
|
224
|
-
- If
|
|
252
|
+
- If inspection of owners/files already happened, state that explicitly under Current Work so a successor must NOT reopen "inspect owners".
|
|
253
|
+
- If the conversation already contains a <compacted-summary> block, it is a PRIOR checkpoint. Do not copy it forward verbatim: preserve still-true facts and still-true decisions, drop stale ones, and merge newer information into a single consolidated summary under the same structure.
|
|
225
254
|
```
|
|
226
255
|
|
|
227
256
|
#### Token effect
|
|
@@ -134,6 +134,7 @@ kind: "package-reference"
|
|
|
134
134
|
| [`src/index.ts`](src/index.ts) | 插件入口:`BasicCompactionEngine`、自动 listener、入口点分发 |
|
|
135
135
|
| [`src/region.ts`](src/region.ts) | 保留选择与共享的先记录标记压缩事务 |
|
|
136
136
|
| [`src/summarizer.ts`](src/summarizer.ts) | 默认 `ctx.llm.stream()` 摘要、检查点框定、安全摘要投影 |
|
|
137
|
+
| [`src/work-state.ts`](src/work-state.ts) | 在入站路由为 `cursor` 的 `model-selection` 通知之后接纳的模型切换工作状态通知 |
|
|
137
138
|
| [`src/config.ts`](src/config.ts) | 加载时验证与路由模型策略解析 |
|
|
138
139
|
| [`src/types.ts`](src/types.ts) | `BasicCompactionConfig` 与已解析策略词汇 |
|
|
139
140
|
| — | 不发布运行时不变式配套条目;除所属 seam 强制执行的约定外,本包不公开独立事件序列或可变数据关系。持久标记对仍可在会话日志中观察。 |
|
|
@@ -163,7 +164,7 @@ kind: "package-reference"
|
|
|
163
164
|
|
|
164
165
|
#### 模型看到的内容
|
|
165
166
|
|
|
166
|
-
成功步骤越过阈值后,如果已加载可选修剪器,超大工具结果会先被改写。如果仍需摘要,下一个请求会收到下方检查点前导、一个空行、`<compacted-summary>`、根据数据生成的摘要以及 `</compacted-summary
|
|
167
|
+
成功步骤越过阈值后,如果已加载可选修剪器,超大工具结果会先被改写。如果仍需摘要,下一个请求会收到下方检查点前导、一个空行、`<compacted-summary>`、根据数据生成的摘要以及 `</compacted-summary>`。溢出恢复会根据使表层前进的任何替换重建立即重试。检查点会替换已选较早范围,后面跟随已保留的近期单元。当已接纳步骤已经包含一条入站路由为 Cursor 订阅(`cursor`)的 `model-selection` 通知时,此后端再追加一条来源为 `{ kind: 'plugin', plugin: 'compaction-basic', form: 'notice', summary: 'work state' }` 的 user 角色通知。跨提供方通知会写出 `cursor/<model>`;同一 Cursor 提供方内的切换保留裸模型 id,并使用上一条请求头。切换到 DeepSeek 或 pi-ai 目录路由时不会收到该通知。该通知要求后继模型把最新 `<compacted-summary>`(历史中已有时)与持久会话/工作区状态视为权威,不要重新检查已完成工作或重新推导已记录计划,并执行检查点的 Next Step 或一次改变状态的工具调用(仅当某个具名文件缺失时才 read)。如果上一轮没有成功的 `edit`、`write` 或 `bash` 调用,通知还会包含 `the previous turn made no file changes; do not repeat its plan`。
|
|
167
168
|
|
|
168
169
|
##### 会话检查点前导
|
|
169
170
|
|
|
@@ -171,6 +172,18 @@ kind: "package-reference"
|
|
|
171
172
|
This is an automatically generated checkpoint condensing an earlier span of the conversation to free up context. Treat the captured context as established background and build on it without restating it. Continue the task directly from the messages that follow, without acknowledging this checkpoint.
|
|
172
173
|
```
|
|
173
174
|
|
|
175
|
+
##### 带检查点的模型切换工作状态通知
|
|
176
|
+
|
|
177
|
+
```markdown
|
|
178
|
+
[work state: treat the latest <compacted-summary> and durable session/workspace state as authority; do not re-inspect completed work or re-derive a plan already recorded; the next action is the checkpoint's Next Step, or a state-changing tool (read only if a named file is missing); the previous turn made no file changes; do not repeat its plan]
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
##### 无检查点的模型切换工作状态通知
|
|
182
|
+
|
|
183
|
+
```markdown
|
|
184
|
+
[work state: do not re-inspect completed work or re-derive a plan already recorded; the next action is a state-changing tool (read only if a named file is missing); the previous turn made no file changes; do not repeat its plan]
|
|
185
|
+
```
|
|
186
|
+
|
|
174
187
|
#### Token 影响
|
|
175
188
|
|
|
176
189
|
不依赖模型的剪枝可以完全避免辅助调用;否则它会在摘要替换较早范围之前缩减该调用的 transcript(文本记录)。替换会缩减未来输入历史,而非追加第二份副本。摘要会保留到后续压缩将其替换,但不可分的非工具单元仍可能超出预算。
|
|
@@ -208,11 +221,26 @@ Output EXACTLY the Markdown structure below: keep every section, in order. Use t
|
|
|
208
221
|
- [explicitly requested work not yet completed]
|
|
209
222
|
|
|
210
223
|
## Current Work
|
|
211
|
-
- [precisely what was in progress at this checkpoint]
|
|
224
|
+
- [precisely what was in progress at this checkpoint; if inspection of owners/files already happened, state that explicitly so a successor must NOT reopen "inspect owners"]
|
|
212
225
|
|
|
213
226
|
## Next Step
|
|
214
227
|
- [the single next action, directly in line with the most recent request, or "(none)"]
|
|
215
228
|
|
|
229
|
+
## Files Read
|
|
230
|
+
- [exact path: key facts already extracted; do not tell the successor to re-read unless the file changed]
|
|
231
|
+
|
|
232
|
+
## Decisions Taken
|
|
233
|
+
- [decision: what was chosen and why it is binding]
|
|
234
|
+
|
|
235
|
+
## Edits Applied
|
|
236
|
+
- [path: what changed]
|
|
237
|
+
|
|
238
|
+
## Edits Planned But Not Applied
|
|
239
|
+
- [path or area: what remains to write]
|
|
240
|
+
|
|
241
|
+
## Last Tool Results
|
|
242
|
+
- [last few tool names + one-line outcomes; quote error text verbatim]
|
|
243
|
+
|
|
216
244
|
## Critical Context
|
|
217
245
|
- [decisions and their rationale, constraints, user preferences, open questions, data needed to continue]
|
|
218
246
|
|
|
@@ -221,7 +249,8 @@ Rules:
|
|
|
221
249
|
- Capture user feedback and explicit instructions faithfully, especially corrections.
|
|
222
250
|
- Do NOT mention this summarization request or that the context was compacted.
|
|
223
251
|
- Output only the checkpoint text: do not call any tool or take any other action.
|
|
224
|
-
- If
|
|
252
|
+
- If inspection of owners/files already happened, state that explicitly under Current Work so a successor must NOT reopen "inspect owners".
|
|
253
|
+
- If the conversation already contains a <compacted-summary> block, it is a PRIOR checkpoint. Do not copy it forward verbatim: preserve still-true facts and still-true decisions, drop stale ones, and merge newer information into a single consolidated summary under the same structure.
|
|
225
254
|
```
|
|
226
255
|
|
|
227
256
|
#### Token 影响
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
2
|
import { CompactionEngine, CompactionId, ManualCompactionError, compactCheckpointSource, toolPairingBalancedAfter, toolPairingBalancedBefore } from "@deepseek-ai/dsh-compaction";
|
|
3
|
-
import { BlockAssembler, CONTEXT_WINDOW_EXCEEDED_CODE, LlmError, contentHasImage, createUserMessage, errorChain } from "@deepseek-ai/dsh-llm";
|
|
3
|
+
import { BlockAssembler, CONTEXT_WINDOW_EXCEEDED_CODE, LlmError, boundContextSummary, contentHasImage, createUserMessage, errorChain } from "@deepseek-ai/dsh-llm";
|
|
4
4
|
import { assertNever, deepFreeze } from "@deepseek-ai/dsh-util-values";
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
6
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -238,11 +238,26 @@ const COMPACTION_INSTRUCTION = [
|
|
|
238
238
|
"- [explicitly requested work not yet completed]",
|
|
239
239
|
"",
|
|
240
240
|
"## Current Work",
|
|
241
|
-
"- [precisely what was in progress at this checkpoint]",
|
|
241
|
+
"- [precisely what was in progress at this checkpoint; if inspection of owners/files already happened, state that explicitly so a successor must NOT reopen \"inspect owners\"]",
|
|
242
242
|
"",
|
|
243
243
|
"## Next Step",
|
|
244
244
|
"- [the single next action, directly in line with the most recent request, or \"(none)\"]",
|
|
245
245
|
"",
|
|
246
|
+
"## Files Read",
|
|
247
|
+
"- [exact path: key facts already extracted; do not tell the successor to re-read unless the file changed]",
|
|
248
|
+
"",
|
|
249
|
+
"## Decisions Taken",
|
|
250
|
+
"- [decision: what was chosen and why it is binding]",
|
|
251
|
+
"",
|
|
252
|
+
"## Edits Applied",
|
|
253
|
+
"- [path: what changed]",
|
|
254
|
+
"",
|
|
255
|
+
"## Edits Planned But Not Applied",
|
|
256
|
+
"- [path or area: what remains to write]",
|
|
257
|
+
"",
|
|
258
|
+
"## Last Tool Results",
|
|
259
|
+
"- [last few tool names + one-line outcomes; quote error text verbatim]",
|
|
260
|
+
"",
|
|
246
261
|
"## Critical Context",
|
|
247
262
|
"- [decisions and their rationale, constraints, user preferences, open questions, data needed to continue]",
|
|
248
263
|
"",
|
|
@@ -251,7 +266,8 @@ const COMPACTION_INSTRUCTION = [
|
|
|
251
266
|
"- Capture user feedback and explicit instructions faithfully, especially corrections.",
|
|
252
267
|
"- Do NOT mention this summarization request or that the context was compacted.",
|
|
253
268
|
"- Output only the checkpoint text: do not call any tool or take any other action.",
|
|
254
|
-
|
|
269
|
+
"- If inspection of owners/files already happened, state that explicitly under Current Work so a successor must NOT reopen \"inspect owners\".",
|
|
270
|
+
`- If the conversation already contains a ${SUMMARY_OPEN_TAG} block, it is a PRIOR checkpoint. Do not copy it forward verbatim: preserve still-true facts and still-true decisions, drop stale ones, and merge newer information into a single consolidated summary under the same structure.`
|
|
255
271
|
].join("\n");
|
|
256
272
|
/** Framing that makes the replacement user message established context. */
|
|
257
273
|
const CHECKPOINT_PREAMBLE = "This is an automatically generated checkpoint condensing an earlier span of the conversation to free up context. Treat the captured context as established background and build on it without restating it. Continue the task directly from the messages that follow, without acknowledging this checkpoint.";
|
|
@@ -712,6 +728,139 @@ function inspectCompactionEntryState(session) {
|
|
|
712
728
|
};
|
|
713
729
|
}
|
|
714
730
|
//#endregion
|
|
731
|
+
//#region lib/types/work-state.js
|
|
732
|
+
/**
|
|
733
|
+
* Model-switch work-state notice admitted after a model-selection notice
|
|
734
|
+
* whose incoming route is the Cursor subscription (`cursor`).
|
|
735
|
+
*
|
|
736
|
+
* @module @deepseek-ai/dsh-compaction-basic/work-state
|
|
737
|
+
*/
|
|
738
|
+
const WORK_STATE_PLUGIN = "compaction-basic";
|
|
739
|
+
const WORK_STATE_SUMMARY = "work state";
|
|
740
|
+
const COMPACTED_SUMMARY_TAG = "<compacted-summary>";
|
|
741
|
+
const CONTINUES_WITH = /the session continues with ([^\]]+)/;
|
|
742
|
+
const CURSOR_PROVIDER = "cursor";
|
|
743
|
+
const FILE_CHANGING_TOOLS = new Set([
|
|
744
|
+
"edit",
|
|
745
|
+
"write",
|
|
746
|
+
"bash"
|
|
747
|
+
]);
|
|
748
|
+
const NO_FILE_CHANGES = "the previous turn made no file changes; do not repeat its plan";
|
|
749
|
+
const WITH_CHECKPOINT = "treat the latest <compacted-summary> and durable session/workspace state as authority; do not re-inspect completed work or re-derive a plan already recorded; the next action is the checkpoint's Next Step, or a state-changing tool (read only if a named file is missing)";
|
|
750
|
+
const WITHOUT_CHECKPOINT = "do not re-inspect completed work or re-derive a plan already recorded; the next action is a state-changing tool (read only if a named file is missing)";
|
|
751
|
+
/**
|
|
752
|
+
* Listen for model-selection notices whose incoming route is `cursor`,
|
|
753
|
+
* including `auto: false` backends.
|
|
754
|
+
* @param ctx - plugin context that owns the listeners.
|
|
755
|
+
* @returns nothing; listeners dispose with the context fiber.
|
|
756
|
+
*/
|
|
757
|
+
function installWorkStateNotice(ctx) {
|
|
758
|
+
ctx.on("agent/pre-step", onWorkStatePreStep);
|
|
759
|
+
ctx.on("agent/created", ({ agent }) => {
|
|
760
|
+
agent.ctx.on("agent/pre-step", onWorkStatePreStep, { prepend: true });
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
async function onWorkStatePreStep({ agent }, next) {
|
|
764
|
+
return appendWorkStateNotice(agent.session, await next());
|
|
765
|
+
}
|
|
766
|
+
function appendWorkStateNotice(session, decision) {
|
|
767
|
+
if (decision.kind !== "enter") return decision;
|
|
768
|
+
if (!decision.messages.some(isModelSelectionNotice)) return decision;
|
|
769
|
+
if (!incomingCursorRoute(session, decision.messages)) return decision;
|
|
770
|
+
if (decision.messages.some(isWorkStateNotice)) return decision;
|
|
771
|
+
return {
|
|
772
|
+
...decision,
|
|
773
|
+
messages: [...decision.messages, createWorkStateNotice(session, decision.messages)]
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Whether the incoming model-selection route is the Cursor subscription.
|
|
778
|
+
* The durable request header is still the previous route, so a
|
|
779
|
+
* cursor→other switch must not inject. A `provider/model` label is
|
|
780
|
+
* cross-provider; a bare model id is same-provider and uses that header.
|
|
781
|
+
*/
|
|
782
|
+
function incomingCursorRoute(session, admitted) {
|
|
783
|
+
const to = incomingRouteLabel(admitted);
|
|
784
|
+
if (to === void 0) return false;
|
|
785
|
+
if (to.startsWith(`${CURSOR_PROVIDER}/`)) return true;
|
|
786
|
+
if (to.includes("/")) return false;
|
|
787
|
+
return session.requestHeader()?.config.provider === CURSOR_PROVIDER;
|
|
788
|
+
}
|
|
789
|
+
function incomingRouteLabel(admitted) {
|
|
790
|
+
for (const message of admitted) {
|
|
791
|
+
if (!isModelSelectionNotice(message)) continue;
|
|
792
|
+
for (const block of message.content) {
|
|
793
|
+
if (block.type !== "text") continue;
|
|
794
|
+
const match = CONTINUES_WITH.exec(block.text);
|
|
795
|
+
if (match !== null) return match[1];
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
function createWorkStateNotice(session, admitted) {
|
|
800
|
+
return createUserMessage({
|
|
801
|
+
content: [{
|
|
802
|
+
type: "text",
|
|
803
|
+
text: workStateNoticeText(historyHasCompactedSummary(session, admitted), previousTurnChangedFiles(session))
|
|
804
|
+
}],
|
|
805
|
+
source: {
|
|
806
|
+
kind: "plugin",
|
|
807
|
+
plugin: WORK_STATE_PLUGIN,
|
|
808
|
+
form: "notice",
|
|
809
|
+
summary: boundContextSummary(WORK_STATE_SUMMARY)
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
function workStateNoticeText(hasCheckpoint, previousTurnChangedFiles) {
|
|
814
|
+
const body = hasCheckpoint ? WITH_CHECKPOINT : WITHOUT_CHECKPOINT;
|
|
815
|
+
return previousTurnChangedFiles ? `[work state: ${body}]` : `[work state: ${body}; ${NO_FILE_CHANGES}]`;
|
|
816
|
+
}
|
|
817
|
+
function isModelSelectionNotice(message) {
|
|
818
|
+
return message.source.kind === "plugin" && message.source.plugin === "model-selection";
|
|
819
|
+
}
|
|
820
|
+
function isWorkStateNotice(message) {
|
|
821
|
+
return message.source.kind === "plugin" && message.source.plugin === WORK_STATE_PLUGIN;
|
|
822
|
+
}
|
|
823
|
+
function historyHasCompactedSummary(session, admitted) {
|
|
824
|
+
return [...session.deriveMessages(), ...admitted].some(messageHasCompactedSummary);
|
|
825
|
+
}
|
|
826
|
+
function messageHasCompactedSummary(message) {
|
|
827
|
+
return message.content.some((block) => block.type === "text" && block.text.includes(COMPACTED_SUMMARY_TAG));
|
|
828
|
+
}
|
|
829
|
+
function previousTurnChangedFiles(session) {
|
|
830
|
+
const state = {
|
|
831
|
+
names: /* @__PURE__ */ new Map(),
|
|
832
|
+
last: false,
|
|
833
|
+
current: false
|
|
834
|
+
};
|
|
835
|
+
for (const event of session.snapshotEvents()) applyTurnFileChange(state, event);
|
|
836
|
+
return state.last;
|
|
837
|
+
}
|
|
838
|
+
/** Fold one log event into whether the last completed turn changed files. */
|
|
839
|
+
function applyTurnFileChange(state, event) {
|
|
840
|
+
switch (event.type) {
|
|
841
|
+
case "turn/start":
|
|
842
|
+
state.names.clear();
|
|
843
|
+
state.current = false;
|
|
844
|
+
return;
|
|
845
|
+
case "tool/call":
|
|
846
|
+
state.names.set(event.data.callId, event.data.name);
|
|
847
|
+
return;
|
|
848
|
+
case "tool/result":
|
|
849
|
+
if (fileChangingSuccess(event, state.names)) state.current = true;
|
|
850
|
+
return;
|
|
851
|
+
case "turn/end":
|
|
852
|
+
state.last = state.current;
|
|
853
|
+
return;
|
|
854
|
+
default: return;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
function fileChangingSuccess(event, names) {
|
|
858
|
+
const name = names.get(event.data.message.source.callId);
|
|
859
|
+
/* v8 ignore next -- a valid log pairs every tool/result with a same-turn tool/call. */
|
|
860
|
+
if (name === void 0) return false;
|
|
861
|
+
return FILE_CHANGING_TOOLS.has(name) && !event.data.message.content[0].isError;
|
|
862
|
+
}
|
|
863
|
+
//#endregion
|
|
715
864
|
//#region lib/types/index.js
|
|
716
865
|
/**
|
|
717
866
|
* Basic replay-aware compaction backend.
|
|
@@ -791,6 +940,7 @@ var BasicCompactionEngine = class extends CompactionEngine {
|
|
|
791
940
|
constructor(ctx, config = {}) {
|
|
792
941
|
super(ctx);
|
|
793
942
|
this.config = resolveConfig(config);
|
|
943
|
+
installWorkStateNotice(ctx);
|
|
794
944
|
if (this.config.auto) this._registerAutomaticCompaction();
|
|
795
945
|
}
|
|
796
946
|
/**
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/goal/goal-round-driver/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 97a8365650f40fd836104ef90beb3e0711072f30
|
|
6
|
+
README.zh.md: d7ebc96a7bc4c6dce7e84fa9603ac7240f4231e6
|
|
@@ -54,7 +54,7 @@ A round starts only at whole-agent idle, and completion, pause, and blocking sup
|
|
|
54
54
|
|
|
55
55
|
### After resume, fork, or unload
|
|
56
56
|
|
|
57
|
-
Mounting the driver over an existing agent never arms a goal, and after session resume or fork an active goal stays disarmed until an explicit human-authorized resume — the
|
|
57
|
+
Mounting the driver over an existing agent never arms a goal, and after session resume or fork an active goal stays disarmed until an explicit human-authorized resume. The driver does not rearm on plugin mount or session resume by itself. A direct human continue-intent — a user message whose whole text or first line is exactly `continue`, `keep going`, `resume`, `go on`, `continue the work`, or `continue with the work`, optionally with a trailing period — rearms an active-disarmed goal that still has round capacity and appends a notice stating whether the goal was resumed, already armed, or not resumed because it is paused, blocked, or complete, plus whether the last closed turn mutated the workspace. Durable paused goals stay paused; `/goal resume` owns those. Unloading the plugin cancels any in-flight round and ensures no later round starts.
|
|
58
58
|
|
|
59
59
|
-----
|
|
60
60
|
|
|
@@ -69,7 +69,7 @@ This section explains how the driver schedules rounds without races; the observa
|
|
|
69
69
|
### Design
|
|
70
70
|
|
|
71
71
|
- **Reservation, then admission.** At idle the driver reserves `roundsStarted + 1` for the current `{ goalId, revision }`, queues one `<goal_round>` prompt with a goal message source, and only an entered `user/message` increments `roundsStarted`. A reservation rejected as stale does not consume the round number.
|
|
72
|
-
- **Race fences.** The `agent/pre-step` listener verifies the complete claimed record against the current goal both before and after downstream listeners, so a stale, cancelled, or competing prompt is rejected before its step enters. Human work that arrives before a reservation makes automatic work yield until the agent is idle again.
|
|
72
|
+
- **Race fences.** The `agent/pre-step` listener verifies the complete claimed record against the current goal both before and after downstream listeners, so a stale, cancelled, or competing prompt is rejected before its step enters. A claimed batch without a goal-round source may rearm from a human continue-intent, and that path always calls `next()`. Human work that arrives before a reservation makes automatic work yield until the agent is idle again.
|
|
73
73
|
- **Durability checkpoint.** `goal/changed` creates a durability obligation: before queuing work the driver awaits `ctx.sessions.flush()` and rechecks the goal revision and competing input after the await. A flush failure arriving through `agent/error` disarms continuation before another round can start.
|
|
74
74
|
- **Fail-closed teardown.** Teardown closes admission, disarms every live goal, cancels active work with the `parent` cause, and awaits the driver plus agent quiescence while its event fence remains installed.
|
|
75
75
|
|
|
@@ -78,6 +78,7 @@ This section explains how the driver schedules rounds without races; the observa
|
|
|
78
78
|
| File | Role |
|
|
79
79
|
|---|---|
|
|
80
80
|
| [`src/index.ts`](src/index.ts) | Plugin entry: driver state machine, race fences, teardown |
|
|
81
|
+
| [`src/continue.ts`](src/continue.ts) | Human continue-intent detection, rearm, and notice |
|
|
81
82
|
| [`src/prompt.ts`](src/prompt.ts) | The retained `<goal_round>` continuation prompt |
|
|
82
83
|
| [`src/invariant.ts`](src/invariant.ts) | Invariant companion: goal-round messages must match the package-owned prompt |
|
|
83
84
|
|
|
@@ -116,6 +117,20 @@ One fixed instruction block plus the objective is added per admitted round. Late
|
|
|
116
117
|
|
|
117
118
|
Append-only within an epoch: each admitted round extends the existing conversation after its reusable prefix. Compaction may replace the derived-history suffix and move the reusable boundary.
|
|
118
119
|
|
|
120
|
+
### Continue-intent notice
|
|
121
|
+
|
|
122
|
+
#### What the model sees
|
|
123
|
+
|
|
124
|
+
When a claimed human message is a continue-intent and a current goal exists, the driver appends one plugin notice. The notice states that the goal was resumed, is already armed, or was not resumed because it is paused, blocked, or complete. It also includes exactly one of these clauses: `the previous turn made no file changes; do not repeat its plan` or `the previous turn changed the workspace; continue from the current files`.
|
|
125
|
+
|
|
126
|
+
#### Token effect
|
|
127
|
+
|
|
128
|
+
One additional user-role notice is appended to that accepted step. Later requests resend it until compaction shadows it.
|
|
129
|
+
|
|
130
|
+
#### KV Cache effect
|
|
131
|
+
|
|
132
|
+
Append-only within the current epoch: the notice extends the conversation after the reusable prefix.
|
|
133
|
+
|
|
119
134
|
## Known Limitations and Deferred Work
|
|
120
135
|
|
|
121
136
|
<a id="known-limitations-and-deferred-work"></a>
|
|
@@ -54,7 +54,7 @@ Round 只在整个 agent 进入 idle 时启动;完成、暂停和阻塞会阻
|
|
|
54
54
|
|
|
55
55
|
### resume、fork 或卸载之后
|
|
56
56
|
|
|
57
|
-
把驱动器挂载到现有 agent 上绝不会启用任何 goal 的续行;会话 resume 或 fork 后,active 的 goal 会保持停用续行,直到用户明确授权 resume
|
|
57
|
+
把驱动器挂载到现有 agent 上绝不会启用任何 goal 的续行;会话 resume 或 fork 后,active 的 goal 会保持停用续行,直到用户明确授权 resume。驱动器不会在插件挂载或会话 resume 时自行重新启用续行。直接的人类 continue-intent——整段文本或首行恰好是 `continue`、`keep going`、`resume`、`go on`、`continue the work` 或 `continue with the work`(可带一个尾随句号)的用户消息——会为仍有 Round 额度的 active-disarmed goal 重新启用续行,并追加一条通知,说明 goal 已 resume、本已 armed,或因 paused、blocked、complete 而未 resume,以及上一已关闭轮次是否改动了工作区。持久 paused 的 goal 保持暂停;由 `/goal resume` 负责恢复。卸载插件会取消进行中的 Round,并确保不再启动后续 Round。
|
|
58
58
|
|
|
59
59
|
-----
|
|
60
60
|
|
|
@@ -69,7 +69,7 @@ Round 只在整个 agent 进入 idle 时启动;完成、暂停和阻塞会阻
|
|
|
69
69
|
### 设计
|
|
70
70
|
|
|
71
71
|
- **先预留,后准入。** idle 时驱动器为当前 `{ goalId, revision }` 预留 `roundsStarted + 1`,排入一条携带 goal 消息来源的 `<goal_round>` 提示词;只有进入步骤的 `user/message` 才会增加 `roundsStarted`。因陈旧而被拒绝的预留不会消耗 Round 编号。
|
|
72
|
-
- **竞态防护。** `agent/pre-step` 监听器会在下游监听器前后验证完整的已领取记录与当前 goal
|
|
72
|
+
- **竞态防护。** `agent/pre-step` 监听器会在下游监听器前后验证完整的已领取记录与当前 goal,因此陈旧、已取消或竞争中的提示词会在其步骤进入前被拒绝。不含 goal-round 来源的已领取批次可按人类 continue-intent 重新启用续行,且该路径必须调用 `next()`。在预留前到达的人类工作会让自动工作让行,直到 agent 重新进入 idle。
|
|
73
73
|
- **持久性检查点。** `goal/changed` 会产生持久性义务:排队工作前,驱动器会等待 `ctx.sessions.flush()`,并在等待后重新检查 goal revision 与竞争输入。通过 `agent/error` 到达的 flush 失败会停用续行,避免另一 Round 启动。
|
|
74
74
|
- **fail-closed teardown。** Teardown 会关闭准入、停用所有活跃 goal 的续行、以 `parent` 原因取消进行中的工作,并在事件防护仍生效的情况下等待驱动器和 agent 完全停稳。
|
|
75
75
|
|
|
@@ -78,6 +78,7 @@ Round 只在整个 agent 进入 idle 时启动;完成、暂停和阻塞会阻
|
|
|
78
78
|
| 文件 | 职责 |
|
|
79
79
|
|---|---|
|
|
80
80
|
| [`src/index.ts`](src/index.ts) | 插件入口:驱动器状态机、竞态防护、teardown |
|
|
81
|
+
| [`src/continue.ts`](src/continue.ts) | 人类 continue-intent 检测、重新启用续行与通知 |
|
|
81
82
|
| [`src/prompt.ts`](src/prompt.ts) | 保留的 `<goal_round>` 续行提示词 |
|
|
82
83
|
| [`src/invariant.ts`](src/invariant.ts) | 不变式伴生:goal-round 消息必须与包自有提示词一致 |
|
|
83
84
|
|
|
@@ -116,6 +117,20 @@ Round 只在整个 agent 进入 idle 时启动;完成、暂停和阻塞会阻
|
|
|
116
117
|
|
|
117
118
|
在一个 epoch 内仅追加:每个已准入 Round 都会在可复用前缀后扩展现有对话。压缩可能替换派生历史后缀,并移动可复用边界。
|
|
118
119
|
|
|
120
|
+
### Continue-intent 通知
|
|
121
|
+
|
|
122
|
+
#### 模型看到的内容
|
|
123
|
+
|
|
124
|
+
当已领取的人类消息是 continue-intent 且当前存在 goal 时,驱动器会追加一条插件通知。通知会说明 goal 已 resume、本已 armed,或因 paused、blocked、complete 而未 resume。它还会恰好包含以下子句之一:`the previous turn made no file changes; do not repeat its plan` 或 `the previous turn changed the workspace; continue from the current files`。
|
|
125
|
+
|
|
126
|
+
#### Token 影响
|
|
127
|
+
|
|
128
|
+
该被接受的步骤会额外追加一条用户角色通知。后续请求会重新发送它,直到压缩(compaction)将其遮蔽。
|
|
129
|
+
|
|
130
|
+
#### KV Cache 影响
|
|
131
|
+
|
|
132
|
+
在当前 epoch 内仅追加:该通知会在可复用前缀后扩展对话。
|
|
133
|
+
|
|
119
134
|
## 已知限制与延期工作
|
|
120
135
|
|
|
121
136
|
<a id="known-limitations-and-deferred-work"></a>
|