@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.
Files changed (48) hide show
  1. package/README.md +1 -1
  2. package/bin/dsh.mjs +1 -1
  3. package/node_modules/@deepseek-ai/dsh-base/cordis.patch.yml +11 -0
  4. package/node_modules/@deepseek-ai/dsh-base/package.json +1 -0
  5. package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
  6. package/node_modules/@deepseek-ai/dsh-compaction-basic/README.i18n.yaml +2 -2
  7. package/node_modules/@deepseek-ai/dsh-compaction-basic/README.md +32 -3
  8. package/node_modules/@deepseek-ai/dsh-compaction-basic/README.zh.md +32 -3
  9. package/node_modules/@deepseek-ai/dsh-compaction-basic/lib/index.js +153 -3
  10. package/node_modules/@deepseek-ai/dsh-goal-round-driver/README.i18n.yaml +2 -2
  11. package/node_modules/@deepseek-ai/dsh-goal-round-driver/README.md +17 -2
  12. package/node_modules/@deepseek-ai/dsh-goal-round-driver/README.zh.md +17 -2
  13. package/node_modules/@deepseek-ai/dsh-goal-round-driver/lib/index.js +153 -2
  14. package/node_modules/@deepseek-ai/dsh-llm-cursor/README.i18n.yaml +2 -2
  15. package/node_modules/@deepseek-ai/dsh-llm-cursor/README.md +1 -1
  16. package/node_modules/@deepseek-ai/dsh-llm-cursor/README.zh.md +1 -1
  17. package/node_modules/@deepseek-ai/dsh-llm-cursor/lib/index.js +48 -24
  18. package/node_modules/@deepseek-ai/dsh-no-progress-reminder/README.i18n.yaml +6 -0
  19. package/node_modules/@deepseek-ai/dsh-no-progress-reminder/README.md +164 -0
  20. package/node_modules/@deepseek-ai/dsh-no-progress-reminder/README.zh.md +164 -0
  21. package/node_modules/@deepseek-ai/dsh-no-progress-reminder/lib/index.js +1516 -0
  22. package/node_modules/@deepseek-ai/dsh-no-progress-reminder/package.json +50 -0
  23. package/node_modules/@deepseek-ai/dsh-repeat-tool-reminder/README.i18n.yaml +2 -2
  24. package/node_modules/@deepseek-ai/dsh-repeat-tool-reminder/README.md +36 -11
  25. package/node_modules/@deepseek-ai/dsh-repeat-tool-reminder/README.zh.md +36 -11
  26. package/node_modules/@deepseek-ai/dsh-repeat-tool-reminder/lib/index.js +54 -7
  27. package/node_modules/@deepseek-ai/dsh-subagent/README.i18n.yaml +2 -2
  28. package/node_modules/@deepseek-ai/dsh-subagent/README.md +2 -2
  29. package/node_modules/@deepseek-ai/dsh-subagent/README.zh.md +2 -2
  30. package/node_modules/@deepseek-ai/dsh-subagent/lib/index.js +93 -32
  31. package/node_modules/@deepseek-ai/dsh-subagent/lib/types/continuation-messages.js +20 -7
  32. package/node_modules/@deepseek-ai/dsh-subagent/lib/types/diagnostic.js +39 -0
  33. package/node_modules/@deepseek-ai/dsh-subagent/lib/types/lifecycle.js +36 -4
  34. package/node_modules/@deepseek-ai/dsh-subagent/lib/types/out-of-process.js +1 -22
  35. package/node_modules/@deepseek-ai/dsh-tool-skill/README.i18n.yaml +2 -2
  36. package/node_modules/@deepseek-ai/dsh-tool-skill/README.md +21 -4
  37. package/node_modules/@deepseek-ai/dsh-tool-skill/README.zh.md +21 -4
  38. package/node_modules/@deepseek-ai/dsh-tool-skill/lib/index.js +194 -16
  39. package/node_modules/@deepseek-ai/dsh-tool-todo/README.i18n.yaml +2 -2
  40. package/node_modules/@deepseek-ai/dsh-tool-todo/README.md +3 -3
  41. package/node_modules/@deepseek-ai/dsh-tool-todo/README.zh.md +3 -3
  42. package/node_modules/@deepseek-ai/dsh-tool-todo/lib/index.js +32 -6
  43. package/node_modules/@deepseek-ai/dsh-tool-todo/lib/types/index.js +31 -5
  44. package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +2 -2
  45. package/node_modules/@deepseek-ai/dsh-tui-app/README.md +24 -18
  46. package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +24 -18
  47. package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +400 -100
  48. package/package.json +3 -1
@@ -1,5 +1,148 @@
1
1
  import { isDeepStrictEqual } from "node:util";
2
- import { createUserMessage } from "@deepseek-ai/dsh-llm";
2
+ import { boundContextSummary, createUserMessage } from "@deepseek-ai/dsh-llm";
3
+ //#region lib/types/continue.js
4
+ /** Human continue-intent rearm and the model-visible continuation notice. */
5
+ const CONTINUE_PHRASES = new Set([
6
+ "continue",
7
+ "keep going",
8
+ "resume",
9
+ "go on",
10
+ "continue the work",
11
+ "continue with the work"
12
+ ]);
13
+ const MUTATING_TOOLS = new Set([
14
+ "edit",
15
+ "write",
16
+ "bash"
17
+ ]);
18
+ const NO_MUTATION_CLAUSE = "the previous turn made no file changes; do not repeat its plan";
19
+ const MUTATION_CLAUSE = "the previous turn changed the workspace; continue from the current files";
20
+ /** Human-readable unexpected values for logs. */
21
+ function renderThrown$1(value) {
22
+ return value instanceof Error ? value.message : String(value);
23
+ }
24
+ /** Concatenate text blocks from one claimed user message. */
25
+ function userMessageText(message) {
26
+ return message.content.filter((block) => block.type === "text").map((block) => block.text).join("");
27
+ }
28
+ /** Trim, drop one optional trailing period, and lowercase a candidate phrase. */
29
+ function canonicalizeContinueText(text) {
30
+ const trimmed = text.trim();
31
+ return (trimmed.endsWith(".") ? trimmed.slice(0, -1) : trimmed).trim().toLowerCase();
32
+ }
33
+ /** Whether text is exactly one closed continue phrase. */
34
+ function isContinuePhrase(text) {
35
+ return CONTINUE_PHRASES.has(canonicalizeContinueText(text));
36
+ }
37
+ /** Whether one claimed message is a human continue-intent. */
38
+ function isContinueIntentMessage(message) {
39
+ if (message.source.kind !== "user") return false;
40
+ const text = userMessageText(message);
41
+ if (isContinuePhrase(text)) return true;
42
+ const newline = text.indexOf("\n");
43
+ return newline >= 0 && isContinuePhrase(text.slice(0, newline));
44
+ }
45
+ /** Events from the last `turn/start` through its matching `turn/end`. */
46
+ function lastClosedTurn(events) {
47
+ const closed = events.findLast((event) => event.type === "turn/end");
48
+ if (closed === void 0) return [];
49
+ const start = events.findLastIndex((event) => event.type === "turn/start" && event.data.turn === closed.data.turn);
50
+ return events.slice(Math.max(start, 0), events.lastIndexOf(closed) + 1);
51
+ }
52
+ /** Whether that closed turn recorded a successful edit, write, or bash result. */
53
+ function lastClosedTurnMutatedWorkspace(session) {
54
+ const window = lastClosedTurn(session.snapshotEvents());
55
+ const names = /* @__PURE__ */ new Map();
56
+ for (const event of window) if (event.type === "tool/call") names.set(event.data.callId, event.data.name);
57
+ for (const event of window) {
58
+ if (event.type !== "tool/result") continue;
59
+ if (event.data.message.content[0].isError === true) continue;
60
+ const name = names.get(event.data.message.source.callId) ?? "";
61
+ if (MUTATING_TOOLS.has(name)) return true;
62
+ }
63
+ return false;
64
+ }
65
+ /** One-line resume outcome for the notice body. */
66
+ function continueStatusLine(goal, status) {
67
+ switch (status) {
68
+ case "resumed": return "The active goal was resumed";
69
+ case "armed": return "The active goal is already armed";
70
+ case "paused": return "The goal was not resumed because it is paused";
71
+ case "blocked": return `The goal was not resumed because it is blocked: ${goal.blockedReason?.message ?? "blocked"}`;
72
+ case "complete": return "The goal was not resumed because it is complete";
73
+ }
74
+ }
75
+ /** Build the plugin notice appended to an accepted continue-intent step. */
76
+ function renderContinueNotice(goal, status, mutated) {
77
+ const text = `${continueStatusLine(goal, status)}; ${mutated ? MUTATION_CLAUSE : NO_MUTATION_CLAUSE}.`;
78
+ return createUserMessage({
79
+ content: [{
80
+ type: "text",
81
+ text
82
+ }],
83
+ source: {
84
+ kind: "plugin",
85
+ plugin: "goal-round-driver",
86
+ form: "notice",
87
+ summary: boundContextSummary(text)
88
+ }
89
+ });
90
+ }
91
+ /** Human-authorized rearm of an active-disarmed goal that still has capacity. */
92
+ function resumeActiveDisarmed(ctx, agent, goal) {
93
+ try {
94
+ ctx.goals.resume(agent, {
95
+ id: goal.id,
96
+ revision: goal.revision
97
+ });
98
+ return "resumed";
99
+ } catch (error) {
100
+ ctx.logger.warn(`goal-round-driver: could not resume goal for agent "${agent.id}": ${renderThrown$1(error)}`);
101
+ return;
102
+ }
103
+ }
104
+ /** Decide whether continue-intent may rearm, and what the notice should claim. */
105
+ function authorizeContinue(ctx, agent, goal) {
106
+ switch (goal.phase) {
107
+ case "active":
108
+ if (goal.activation === "armed") return "armed";
109
+ if (goal.roundsStarted >= goal.maxGoalRounds) return void 0;
110
+ return resumeActiveDisarmed(ctx, agent, goal);
111
+ case "paused": return "paused";
112
+ case "blocked": return "blocked";
113
+ case "complete": return "complete";
114
+ }
115
+ }
116
+ /**
117
+ * Rearm an active-disarmed goal from a human continue-intent and build the notice.
118
+ * @param ctx - host context with the goal service.
119
+ * @param agent - live agent whose claimed batch is entering a step.
120
+ * @param messages - claimed pre-step batch.
121
+ * @returns a plugin notice when continue-intent applies to a current goal, otherwise `undefined`.
122
+ */
123
+ function applyContinueIntent(ctx, agent, messages) {
124
+ if (!messages.some(isContinueIntentMessage)) return void 0;
125
+ const goal = ctx.goals.get(agent);
126
+ if (goal === void 0) return void 0;
127
+ const status = authorizeContinue(ctx, agent, goal);
128
+ if (status === void 0) return void 0;
129
+ return renderContinueNotice(goal, status, lastClosedTurnMutatedWorkspace(agent.session));
130
+ }
131
+ /**
132
+ * Append a continue notice only to an accepted, non-aborted step.
133
+ * @param decision - downstream pre-step decision.
134
+ * @param notice - notice produced for this claimed batch, if any.
135
+ * @param aborted - whether the step signal aborted while downstream listeners ran.
136
+ * @returns the decision, with the notice appended on an accepted live step.
137
+ */
138
+ function attachContinueNotice(decision, notice, aborted) {
139
+ if (notice === void 0 || decision.kind !== "enter" || aborted) return decision;
140
+ return {
141
+ ...decision,
142
+ messages: [...decision.messages, notice]
143
+ };
144
+ }
145
+ //#endregion
3
146
  //#region lib/types/prompt.js
4
147
  /** Model-visible continuation prompt for one same-session goal round. */
5
148
  /**
@@ -278,7 +421,15 @@ function apply(ctx) {
278
421
  }
279
422
  ctx.on("agent/pre-step", async ({ agent, messages, signal }, next) => {
280
423
  const submitted = messages.find((message) => isGoalRoundSource(message.source));
281
- if (submitted === void 0) return next();
424
+ if (submitted === void 0) {
425
+ let notice;
426
+ try {
427
+ notice = applyContinueIntent(ctx, agent, messages);
428
+ } catch (error) {
429
+ ctx.logger.warn(`goal-round-driver: continue-intent handling failed for agent "${agent.id}": ${renderThrown(error)}`);
430
+ }
431
+ return attachContinueNotice(await next(), notice, signal.aborted);
432
+ }
282
433
  const { content, source } = submitted;
283
434
  const state = stateFor(agent);
284
435
  let valid = false;
@@ -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/llm/llm-cursor/README.md
5
- README.md: 115f31dabd27797f6e27f75ea58ec3d57574fe21
6
- README.zh.md: 64290a131aa904e94bf1be85dafbef69025c6fe1
5
+ README.md: c0715daa65f56dbc5ef7b039e41ac2e225f7e52f
6
+ README.zh.md: e21c4d085c8b61ffeaa0df84a5ee30dba865948a
@@ -84,7 +84,7 @@ Attribution headers required by `LlmAdapter` go on every HTTP/2 request, with Cu
84
84
 
85
85
  #### What the model sees
86
86
 
87
- One rebuilt Cursor `AgentRunRequest` whose `root_prompt_messages_json` carries the model-visible history: the system prompt as a `<rules>` user message, then each prior turn as a `<user_query>` user message, assistant messages holding text and `tool-call` parts named `mcp_dsh_<tool>`, and `tool` messages holding the results; thinking is not replayed. The current user action, requested model id, and MCP tool definitions with `providerIdentifier: dsh` complete the request. Consecutive user-role messages with no assistant between them — the human prompt plus runtime-context snapshots, skill catalogs, and other injected user messages — join in order into that turn's user text, because a Run has one `userMessageAction`. After locally executed tool calls, the in-flight turn is replayed with its results and the user action is the fixed notice `The results of your tool calls are in the tool messages above. Continue the task.`. The request context carries one global rule stating that Cursor's built-in tools return a rejection and naming the `mcp_dsh_` tools as the ones to call. Images reach the model as the harness's text-only placeholder because the route declares text-only input; no image bytes are sent. Cursor still offers its own built-in tools beside the harness MCP tools.
87
+ One rebuilt Cursor `AgentRunRequest` whose `root_prompt_messages_json` carries the model-visible history: the system prompt as a `<rules>` user message, then each prior human turn as a `<user_query>` user message, harness-injected catalogs, snapshots, and notices as separate user messages that are not wrapped in `<user_query>`, assistant messages holding text and `tool-call` parts named `mcp_dsh_<tool>`, and `tool` messages holding the results; thinking is not replayed. The current user action is the human prompt only — a Run has one `userMessageAction`, so skill catalogs and runtime snapshots ride the root prompt instead of joining that action. After locally executed tool calls, the in-flight turn is replayed with its results and the user action is the fixed notice `The results of your tool calls are in the tool messages above. Continue the task.`. The request context carries one global rule stating that Cursor's built-in tools return a rejection and naming the `mcp_dsh_` tools as the ones to call. Images reach the model as the harness's text-only placeholder because the route declares text-only input; no image bytes are sent. Cursor still offers its own built-in tools beside the harness MCP tools.
88
88
 
89
89
  #### Token effect
90
90
 
@@ -84,7 +84,7 @@ DSH 的每一步模型调用是一次新的 HTTP/2 Connect `Run`,由 harness
84
84
 
85
85
  #### 模型看见什么
86
86
 
87
- 一次重建的 Cursor `AgentRunRequest`,其 `root_prompt_messages_json` 承载模型可见的历史:系统提示作为 `<rules>` user 消息,然后每个先前轮次作为 `<user_query>` user 消息、承载文本和名为 `mcp_dsh_<tool>` 的 `tool-call` 部分的 assistant 消息,以及承载结果的 `tool` 消息;thinking 不重放。当前用户动作、请求的模型 id,以及 `providerIdentifier: dsh` 的 MCP 工具定义补全该请求。中间没有助手回复的连续 user 角色消息——人类提示加上运行时上下文快照、技能目录和其他注入的用户消息——按顺序拼进该轮的用户文本,因为一次 Run 只有一个 `userMessageAction`。本地执行工具调用之后,进行中的轮次连同其结果被重放,用户动作是固定提示 `The results of your tool calls are in the tool messages above. Continue the task.`。请求上下文带一条全局规则,声明 Cursor 内建工具会返回拒绝,并指出应调用 `mcp_dsh_` 工具。由于该路由声明只接受文本输入,图片以 harness 的纯文本占位符到达模型;不发送图片字节。Cursor 仍在 harness MCP 工具之外提供自己的内建工具。
87
+ 一次重建的 Cursor `AgentRunRequest`,其 `root_prompt_messages_json` 承载模型可见的历史:系统提示作为 `<rules>` user 消息,然后每个先前人类轮次作为 `<user_query>` user 消息,harness 注入的目录、快照和通知作为不被 `<user_query>` 包裹的独立 user 消息,assistant 消息承载文本和名为 `mcp_dsh_<tool>` 的 `tool-call` 部分,以及承载结果的 `tool` 消息;thinking 不重放。当前用户动作只有人类提示——一次 Run 只有一个 `userMessageAction`,因此 skill 目录和运行时快照走根提示,而不并入该动作。本地执行工具调用之后,进行中的轮次连同其结果被重放,用户动作是固定提示 `The results of your tool calls are in the tool messages above. Continue the task.`。请求上下文带一条全局规则,声明 Cursor 内建工具会返回拒绝,并指出应调用 `mcp_dsh_` 工具。由于该路由声明只接受文本输入,图片以 harness 的纯文本占位符到达模型;不发送图片字节。Cursor 仍在 harness MCP 工具之外提供自己的内建工具。
88
88
 
89
89
  #### Token 影响
90
90
 
@@ -1152,16 +1152,22 @@ function joinUserTexts(left, right) {
1152
1152
  if (right.length === 0) return left;
1153
1153
  return `${left}\n\n${right}`;
1154
1154
  }
1155
- function appendUserTurn(turns, text) {
1156
- const last = turns[turns.length - 1];
1157
- if (last !== void 0 && last.steps.length === 0) {
1158
- last.userText = joinUserTexts(last.userText, text);
1159
- return;
1160
- }
1161
- turns.push({
1162
- userText: text,
1155
+ function emptyTurn() {
1156
+ return {
1157
+ userText: "",
1158
+ contextText: "",
1163
1159
  steps: []
1164
- });
1160
+ };
1161
+ }
1162
+ function isHumanQuery(message) {
1163
+ return message.source.kind === "user";
1164
+ }
1165
+ function appendUserTurn(turns, text, asQuery) {
1166
+ const last = turns[turns.length - 1];
1167
+ const open = last !== void 0 && last.steps.length === 0 ? last : emptyTurn();
1168
+ if (open !== last) turns.push(open);
1169
+ if (asQuery) open.userText = joinUserTexts(open.userText, text);
1170
+ else open.contextText = joinUserTexts(open.contextText, text);
1165
1171
  }
1166
1172
  function parseArguments(raw) {
1167
1173
  try {
@@ -1251,10 +1257,11 @@ function createUserMessage(text, selectedContextBlob) {
1251
1257
  /**
1252
1258
  * Split harness messages into Cursor turns plus the action for this Run.
1253
1259
  *
1254
- * Consecutive user-role messages with no assistant steps between them join in
1255
- * order into one Cursor user text. A Run has a single `userMessageAction`, so
1256
- * runtime-context snapshots and skill catalogs that follow the human prompt
1257
- * ride that action instead of replacing it. History that ends in assistant
1260
+ * Consecutive human user-role messages with no assistant steps between them
1261
+ * join into one Cursor user query. Plugin catalogs, snapshots, and notices
1262
+ * join into `contextText` / `actionContext` instead, because a Run has a
1263
+ * single `userMessageAction` and Cursor wraps that action and each
1264
+ * historical `userText` in `<user_query>`. History that ends in assistant
1258
1265
  * steps, normally tool calls plus their local results, carries no new user
1259
1266
  * text and becomes a `continue` action.
1260
1267
  * @param options - assembled model request.
@@ -1288,13 +1295,10 @@ function conversationFromOptions(options) {
1288
1295
  continue;
1289
1296
  }
1290
1297
  if (message.role === "user") {
1291
- appendUserTurn(turns, textOf(message));
1298
+ appendUserTurn(turns, textOf(message), isHumanQuery(message));
1292
1299
  continue;
1293
1300
  }
1294
- if (turns.length === 0) turns.push({
1295
- userText: "",
1296
- steps: []
1297
- });
1301
+ if (turns.length === 0) turns.push(emptyTurn());
1298
1302
  const last = turns[turns.length - 1];
1299
1303
  for (const block of message.content) if (block.type === "text" && block.text.length > 0) last.steps.push({
1300
1304
  kind: "assistantText",
@@ -1322,7 +1326,8 @@ function conversationFromOptions(options) {
1322
1326
  action: {
1323
1327
  kind: "userMessage",
1324
1328
  text: ""
1325
- }
1329
+ },
1330
+ actionContext: ""
1326
1331
  };
1327
1332
  if (last.steps.length === 0) return {
1328
1333
  systemPrompt,
@@ -1330,12 +1335,14 @@ function conversationFromOptions(options) {
1330
1335
  action: {
1331
1336
  kind: "userMessage",
1332
1337
  text: last.userText
1333
- }
1338
+ },
1339
+ actionContext: last.contextText
1334
1340
  };
1335
1341
  return {
1336
1342
  systemPrompt,
1337
1343
  turns,
1338
- action: { kind: "continue" }
1344
+ action: { kind: "continue" },
1345
+ actionContext: ""
1339
1346
  };
1340
1347
  }
1341
1348
  /**
@@ -1365,9 +1372,10 @@ function buildRules() {
1365
1372
  * named `mcp_dsh_<tool>` as Cursor names them. Thinking is not replayed.
1366
1373
  * @param systemPrompt - rendered harness system prompt; `''` adds no rules.
1367
1374
  * @param turns - turns to replay, oldest first.
1375
+ * @param actionContext - harness context for the current action; omitted from `<user_query>`.
1368
1376
  * @returns prompt messages in order.
1369
1377
  */
1370
- function buildPromptMessages(systemPrompt, turns) {
1378
+ function buildPromptMessages(systemPrompt, turns, actionContext = "") {
1371
1379
  const messages = [];
1372
1380
  if (systemPrompt.trim().length > 0) messages.push({
1373
1381
  role: "user",
@@ -1385,6 +1393,14 @@ function buildPromptMessages(systemPrompt, turns) {
1385
1393
  text: `<user_query>\n${query}\n</user_query>`
1386
1394
  }]
1387
1395
  });
1396
+ const context = turn.contextText.trim();
1397
+ if (context.length > 0) messages.push({
1398
+ role: "user",
1399
+ content: [{
1400
+ type: "text",
1401
+ text: context
1402
+ }]
1403
+ });
1388
1404
  let assistant = [];
1389
1405
  let results = [];
1390
1406
  const flush = () => {
@@ -1427,6 +1443,14 @@ function buildPromptMessages(systemPrompt, turns) {
1427
1443
  }
1428
1444
  flush();
1429
1445
  }
1446
+ const trailing = actionContext.trim();
1447
+ if (trailing.length > 0) messages.push({
1448
+ role: "user",
1449
+ content: [{
1450
+ type: "text",
1451
+ text: trailing
1452
+ }]
1453
+ });
1430
1454
  return messages;
1431
1455
  }
1432
1456
  function estimateInputTokens(rules, promptMessages, actionText, mcpTools) {
@@ -1450,7 +1474,7 @@ function actionText(action) {
1450
1474
  * @returns protobuf bytes and the blob store.
1451
1475
  */
1452
1476
  function buildCursorRun(options) {
1453
- const { systemPrompt, turns, action } = conversationFromOptions(options);
1477
+ const { systemPrompt, turns, action, actionContext } = conversationFromOptions(options);
1454
1478
  const mcpTools = buildMcpToolDefinitions(options.tools);
1455
1479
  const blobStore = /* @__PURE__ */ new Map();
1456
1480
  const encoder = new TextEncoder();
@@ -1459,7 +1483,7 @@ function buildCursorRun(options) {
1459
1483
  content: systemPrompt
1460
1484
  })), blobStore);
1461
1485
  const rules = buildRules();
1462
- const promptMessages = buildPromptMessages(systemPrompt, turns);
1486
+ const promptMessages = buildPromptMessages(systemPrompt, turns, actionContext);
1463
1487
  const promptBlobIds = promptMessages.map((message) => storeAsBlob(encoder.encode(JSON.stringify(message)), blobStore));
1464
1488
  const selectedCtxBlob = storeAsBlob(new Uint8Array(), blobStore);
1465
1489
  const turnBlobIds = [];
@@ -0,0 +1,6 @@
1
+ # Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
2
+ # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
+ # after editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write packages/guard/no-progress-reminder/README.md
5
+ README.md: b3232c1ef1147891a8a04086461af6636b8b4d8f
6
+ README.zh.md: f73119b47fde19554ff0326c282b88f4f97fab49
@@ -0,0 +1,164 @@
1
+ ---
2
+ description: "Advisory loop-hygiene guard that nudges the model after idle goal turns with no file mutation, for users and maintainers choosing, configuring, or debugging the plugin."
3
+ kind: "package-reference"
4
+ ---
5
+
6
+ # @deepseek-ai/dsh-no-progress-reminder
7
+
8
+ English | [中文](README.zh.md)
9
+
10
+ ## Summary
11
+
12
+ Use this package to nudge a model that spends whole turns on recap, skills, or todos while a goal is active and no file changes. After a configured number of idle turns, the next step receives a notice naming the count and asking for a read, edit, write, or bash call, or a blocker explanation. The notice is advisory and never blocks a tool. Continue does not clear the count; only a successful mutating tool or a cleared or completed goal does. The dsh base bundle enables it at five idle turns on the Cursor subscription route (`provider: cursor`).
13
+
14
+ ## Table of Contents
15
+
16
+ - [Use this package](#use-this-package)
17
+ - [Understand the implementation](#understand-the-implementation)
18
+ - [Further Exploration](#further-exploration)
19
+ - [Model Experience](#model-experience)
20
+ - [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
21
+ - [Dev Note](#dev-note)
22
+
23
+ -----
24
+
25
+ <a id="use-this-package"></a>
26
+ ## Use this package
27
+
28
+ Mount this plugin when a long goal-driven session on a Cursor subscription model should catch itself looping on recap, skills, or todos without changing a file. The `dsh` base bundle already runs it for the `cursor` route; tune the idle-turn count, mutating-tool patterns, goal requirement, or `providers` list below when you want the nudge on other routes, sooner, later, or without a current goal.
29
+
30
+ ### When to choose it
31
+
32
+ Choose it when the model works toward a standing goal for many turns and the failure you want to break is bookkeeping without tree mutations. Avoid it when idle analysis is legitimate and must run undisturbed, and when mutation happens through tool names outside the default `edit` / `write` / `bash` list — those names are configurable, but a missed pattern will keep counting.
33
+
34
+ ### Setting the idle count and mutating tools
35
+
36
+ When you want to change when the notice fires or which successful tools clear it, mount the plugin with configuration:
37
+
38
+ ```yaml
39
+ - name: '@deepseek-ai/dsh-no-progress-reminder'
40
+ config:
41
+ idleTurns: 5
42
+ mutatingTools: [edit, write, bash]
43
+ requireGoal: true
44
+ providers: [cursor]
45
+ ```
46
+
47
+ | Field | Default | Meaning |
48
+ |---|---|---|
49
+ | `idleTurns` | `5` | Whole turns without a successful mutating tool that trigger a notice |
50
+ | `mutatingTools` | `['edit', 'write', 'bash']` | Tool-name `*`-wildcard patterns whose successful calls reset the count |
51
+ | `requireGoal` | `true` | Count and inject only while a goals service is present and the agent's goal is `active` |
52
+ | `providers` | `['cursor']` | Provider routes that participate; empty matches none. Default is the Cursor subscription route |
53
+
54
+ Invalid `idleTurns` fails at startup with a clear error — a non-integer or a value below 1 — never a silent change of behavior. A missing goals service or a non-live agent with `requireGoal: true` is a no-op at call time, not a throw. The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-no-progress-reminder) documents every accepted value.
55
+
56
+ ### What you get
57
+
58
+ With the defaults, a Cursor subscription model that finishes five whole turns on an active goal without a successful `edit`, `write`, or `bash` call receives a notice on the next step naming that idle count and asking it to read, edit, write, or bash, or to explain what blocks it. A DeepSeek or pi-ai catalog route does not receive the notice. A later idle turn without a mutation receives the notice again (once per turn). A user continue does not clear the debt. A successful mutating tool, or a cleared or completed goal, resets the count. Notices appear as additional user messages attributed to the plugin.
59
+
60
+ -----
61
+
62
+ <a id="understand-the-implementation"></a>
63
+ ## Understand the implementation
64
+
65
+ <details>
66
+ <summary>Implementation internals — click to expand</summary>
67
+
68
+ This section explains how the guard counts idle turns and delivers notices, and points at the code that realizes it; the observable behavior is fully covered in [Use this package](#use-this-package).
69
+
70
+ ### Design philosophy
71
+
72
+ The guard is built on four commitments:
73
+
74
+ - **Advisory, not veto.** The guard appends a sourced user message on `agent/pre-step`; it never blocks or rewrites a tool call.
75
+ - **Count whole turns.** Detection increments on `turn/end`, so several bookkeeping tools in one turn still count as one idle turn.
76
+ - **Reset only on mutation or goal end.** A successful `tools/post-execute` whose name matches `mutatingTools`, or a `goal/change` whose operation is `clear` or `complete`, zeros the count. A user-kind message does not.
77
+ - **Fail loud at load.** `idleTurns` validates in `apply` and throws, never falling back to a hidden default inside the listeners.
78
+
79
+ ### Detection: the idle-turn counter
80
+
81
+ Each agent's counter lives in a `WeakMap<Agent, IdleState>`.
82
+
83
+ - **Goal gating.** When `requireGoal` is true, a turn is counted only if `ctx.get('goals')` exists, the agent is the registry's live instance, and `goals.get(agent)` has phase `active`. A missing goals service or a non-live agent does nothing. When `requireGoal` is false, every turn is eligible.
84
+ - **Mutation resets the current turn.** A matching successful call marks the open turn so its later `turn/end` does not increment.
85
+ - **Unmatched tools are transparent.** `todo_write`, `skill`, `get_goal`, and any name outside `mutatingTools` neither reset nor block counting.
86
+ - **Failed mutating calls do not reset.** Only `isError === false` clears the debt.
87
+ - **Per-agent keying.** One agent's idle run never trips another's notice.
88
+ - **In-memory only.** A session resumed from persistence starts with a fresh counter.
89
+
90
+ ### Notice delivery
91
+
92
+ Notices ride `agent/pre-step` as additional user messages (source `{kind: 'plugin', plugin: 'no-progress-reminder', form: 'notice', summary: 'no progress'}`). After `idleTurns` consecutive counted turns, the first pre-step of the next turn receives the notice; later steps of that same turn do not. A further idle turn injects again with the updated count. The guard always delegates via `next()` and appends its notice only onto an `enter` decision.
93
+
94
+ ### Source map
95
+
96
+ | File | Role |
97
+ |---|---|
98
+ | [`src/index.ts`](src/index.ts) | Plugin entry: `Config` schema, fail-loud validation, idle-turn listeners |
99
+ | — | No runtime invariant companion is published; the idle-turn chain is private to one listener set and exposes no package-owned event or snapshot that an independent companion can observe. |
100
+
101
+ </details>
102
+
103
+ -----
104
+
105
+ <a id="further-exploration"></a>
106
+ ## Further Exploration
107
+
108
+ Read these pages when the package-level contract is not enough. They move from the tools waterfall and goal service to the guard group map.
109
+
110
+ - [Tools subsystem reference](../../../docs/subsystems/tools.md) — the `tools/post-execute` waterfall and `agent/pre-step` decision this guard consumes.
111
+ - [Goal service](../../goal/goal/README.md) — the optional `ctx.goals` lookup this guard reads when `requireGoal` is true.
112
+ - [Generated configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-no-progress-reminder) — accepted config fields collected from plugin schemas.
113
+ - [guard group map](../README.md) — the sibling guard packages and the loop-hygiene family.
114
+
115
+ -----
116
+
117
+ <a id="model-experience"></a>
118
+ ## Model Experience
119
+
120
+ ### Idle-progress context message
121
+
122
+ #### What the model sees
123
+
124
+ After `idleTurns` consecutive counted turns with no successful mutating tool, that agent receives the notice below on the next step. No tool schema or normal-call text is added.
125
+
126
+ ##### Idle-progress notice
127
+
128
+ ```markdown
129
+ No file has changed in <N> turns. Your next tool call must be read, edit, write, or bash, or explain what blocks you.
130
+ ```
131
+
132
+ #### Token effect
133
+
134
+ Zero tokens before the threshold. Each notice is retained history for that agent; `<N>` is the counted idle-turn total at injection.
135
+
136
+ #### KV Cache effect
137
+
138
+ Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
139
+
140
+ ## Known Limitations and Deferred Work
141
+
142
+ <a id="known-limitations-and-deferred-work"></a>
143
+
144
+
145
+ These limits define when the guard is a poor fit. They are current package constraints, not a task backlog.
146
+
147
+ - **In-memory only** — a resumed session starts with a fresh counter, so idle debt does not survive process restart.
148
+ - **Advisory only** — the notice never blocks a tool call or forces a mutating tool.
149
+ - **Read does not reset** — a successful `read` is not in the default `mutatingTools` list, so inspection alone keeps the debt.
150
+ - **User continue does not reset** — a new user-kind message leaves the count unchanged.
151
+ - **Compaction does not reset** — a counter spanning a compaction checkpoint keeps counting.
152
+ - **No cross-agent sharing** — a parent and its subagent keep separate counters.
153
+
154
+ <a id="dev-note"></a>
155
+ ### Dev Note
156
+
157
+ <details>
158
+ <summary>Working context for maintainers — click to expand</summary>
159
+
160
+ This Dev Note is working context for maintainers: open questions and directions that are not decided. It is explicitly non-authoritative — shipped behavior, limits, and accepted rationale live in the sections above and the package code.
161
+
162
+ None.
163
+
164
+ </details>