@songtonyli/dsh-cli 0.1.22 → 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 (44) 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/package.json +3 -1
@@ -25,6 +25,138 @@ function SessionSeq(value) {
25
25
  return brandNumber(value);
26
26
  }
27
27
  //#endregion
28
+ //#region lib/types/unknown-skill.js
29
+ /**
30
+ * Model-facing unknown-skill diagnostics: closest catalog names, a capped
31
+ * name list, and the closed-catalog rule.
32
+ *
33
+ * @module @deepseek-ai/dsh-tool-skill/unknown-skill
34
+ */
35
+ /** Consecutive unknown loads on one live agent that close `skill` for the rest of the turn. */
36
+ const UNKNOWN_SKILL_STREAK_LIMIT = 3;
37
+ /** Maximum Levenshtein distance that still qualifies a catalog name as close. */
38
+ const MAX_CLOSE_SKILL_DISTANCE = 4;
39
+ /** Maximum closest catalog names included in an unknown-skill error. */
40
+ const MAX_CLOSE_SKILL_SUGGESTIONS = 3;
41
+ /** Maximum model-invocable names listed in an unknown-skill error. */
42
+ const MAX_LISTED_CATALOG_NAMES = 40;
43
+ /**
44
+ * Refusal after {@link UNKNOWN_SKILL_STREAK_LIMIT} consecutive unknown skill
45
+ * loads on the same live agent in the same turn.
46
+ */
47
+ const CLOSED_SKILL_CATALOG_THIS_TURN = "The skill catalog is closed this turn. The next action must be a task tool (read/edit/write/bash), not another skill load.";
48
+ /**
49
+ * First line of every unknown-skill error. Existing `toContain` assertions
50
+ * match this exact sentence.
51
+ * @param name - the requested skill name.
52
+ * @returns the historical unknown-skill sentence.
53
+ */
54
+ function unknownSkillLine(name) {
55
+ return `skill "${name}" is unknown or no longer available`;
56
+ }
57
+ /**
58
+ * Closed-catalog instruction appended to every unknown-skill error.
59
+ */
60
+ const CLOSED_SKILL_CATALOG_LINE = "The skill catalog is closed: use only listed names. Do not invent names.";
61
+ /**
62
+ * Levenshtein edit distance between two strings (insert, delete, substitute).
63
+ * @param left - first string.
64
+ * @param right - second string.
65
+ * @returns the non-negative edit distance.
66
+ */
67
+ function levenshteinDistance(left, right) {
68
+ if (left === right) return 0;
69
+ if (left.length === 0) return right.length;
70
+ if (right.length === 0) return left.length;
71
+ return levenshteinRows(left, right);
72
+ }
73
+ /**
74
+ * Whether `needle` is an ordered subsequence of `haystack`.
75
+ * @param needle - characters that must appear in order.
76
+ * @param haystack - string that may contain those characters.
77
+ * @returns whether every needle character appears in order in haystack.
78
+ */
79
+ function isSubsequenceOf(needle, haystack) {
80
+ let index = 0;
81
+ for (const character of haystack) {
82
+ if (character === needle[index]) index += 1;
83
+ if (index === needle.length) return true;
84
+ }
85
+ return index === needle.length;
86
+ }
87
+ /**
88
+ * Rank model-invocable catalog names nearest to a requested name.
89
+ * A candidate qualifies when its Levenshtein distance is at most
90
+ * {@link MAX_CLOSE_SKILL_DISTANCE} or it is a prefix or subsequence of the
91
+ * other string. The requested name itself is omitted.
92
+ * @param name - the requested skill name.
93
+ * @param catalogNames - model-invocable names in catalog order.
94
+ * @returns at most {@link MAX_CLOSE_SKILL_SUGGESTIONS} names, nearest first,
95
+ * then code-point order.
96
+ */
97
+ function rankClosestCatalogNames(name, catalogNames) {
98
+ return catalogNames.filter((candidate) => candidate !== name).map((candidate) => ({
99
+ candidate,
100
+ distance: levenshteinDistance(name, candidate)
101
+ })).filter((entry) => qualifiesCloseName(name, entry.candidate, entry.distance)).sort((left, right) => left.distance - right.distance || compareCatalogNames(left.candidate, right.candidate)).slice(0, 3).map((entry) => entry.candidate);
102
+ }
103
+ /**
104
+ * Build the model-facing unknown-skill error. The first line is
105
+ * {@link unknownSkillLine}; later lines add closest names or a no-match
106
+ * notice, the catalog list or an empty-catalog notice, and
107
+ * {@link CLOSED_SKILL_CATALOG_LINE}.
108
+ * @param name - the requested skill name.
109
+ * @param catalogNames - model-invocable names in catalog order.
110
+ * @returns the multiline error message without the tools `Error: ` wrapper.
111
+ */
112
+ function formatUnknownSkillError(name, catalogNames) {
113
+ return [
114
+ unknownSkillLine(name),
115
+ closestNamesLine(name, catalogNames),
116
+ catalogNames.length === 0 ? "The skill catalog is empty." : listedNamesLine(catalogNames),
117
+ CLOSED_SKILL_CATALOG_LINE
118
+ ].join("\n");
119
+ }
120
+ function qualifiesCloseName(name, candidate, distance) {
121
+ return distance <= 4 || candidate.startsWith(name) || name.startsWith(candidate) || isSubsequenceOf(name, candidate) || isSubsequenceOf(candidate, name);
122
+ }
123
+ function closestNamesLine(name, catalogNames) {
124
+ const closest = rankClosestCatalogNames(name, catalogNames);
125
+ return closest.length === 0 ? "No close catalog name matches." : `Closest catalog names: ${quoteNames(closest)}`;
126
+ }
127
+ function listedNamesLine(catalogNames) {
128
+ const shown = catalogNames.slice(0, 40);
129
+ const extra = catalogNames.length - shown.length;
130
+ const listed = `Valid skill names: ${quoteNames(shown)}`;
131
+ return extra === 0 ? listed : `${listed} (+${String(extra)} more)`;
132
+ }
133
+ function quoteNames(names) {
134
+ return names.map((name) => `\`${name}\``).join(", ");
135
+ }
136
+ /**
137
+ * Code-point order for catalog names, matching the skill registry sort.
138
+ * @param left - first name.
139
+ * @param right - second name.
140
+ * @returns negative when `left` precedes `right`, zero when equal, positive otherwise.
141
+ */
142
+ function compareCatalogNames(left, right) {
143
+ if (left < right) return -1;
144
+ if (left > right) return 1;
145
+ return 0;
146
+ }
147
+ function levenshteinRows(left, right) {
148
+ let previous = Array.from({ length: right.length + 1 }, (_, index) => index);
149
+ for (let i = 0; i < left.length; i += 1) {
150
+ const current = [i + 1];
151
+ for (let j = 0; j < right.length; j += 1) {
152
+ const substitution = left[i] === right[j] ? 0 : 1;
153
+ current.push(Math.min((current[j] ?? 0) + 1, (previous[j + 1] ?? 0) + 1, (previous[j] ?? 0) + substitution));
154
+ }
155
+ previous = current;
156
+ }
157
+ return previous[right.length] ?? 0;
158
+ }
159
+ //#endregion
28
160
  //#region lib/types/index.js
29
161
  /**
30
162
  * Durable session skill catalog and model-facing `skill` loader tool.
@@ -45,8 +177,13 @@ function catalogSourceEntries(skills, descriptionMaxLength) {
45
177
  description: catalogDescription(skill.description, descriptionMaxLength)
46
178
  }));
47
179
  }
180
+ /** Default routed providers that receive the per-turn unknown-skill hard-stop. */
181
+ const DEFAULT_CLOSED_CATALOG_PROVIDERS = ["cursor"];
48
182
  /** Validate and default the model-facing skill catalog configuration. */
49
- const Config = z.object({ catalogDescriptionMaxLength: z.number().default(DEFAULT_CATALOG_DESCRIPTION_MAX_LENGTH) });
183
+ const Config = z.object({
184
+ catalogDescriptionMaxLength: z.number().default(DEFAULT_CATALOG_DESCRIPTION_MAX_LENGTH),
185
+ closedCatalogProviders: z.array(z.string()).default(DEFAULT_CLOSED_CATALOG_PROVIDERS)
186
+ });
50
187
  /**
51
188
  * Register the model-facing skill loader and its visibility-matched
52
189
  * durable session catalog. The catalog is emitted only when the calling agent
@@ -56,6 +193,13 @@ const Config = z.object({ catalogDescriptionMaxLength: z.number().default(DEFAUL
56
193
  function apply(ctx, config = {}) {
57
194
  const catalogDescriptionMaxLength = config.catalogDescriptionMaxLength ?? DEFAULT_CATALOG_DESCRIPTION_MAX_LENGTH;
58
195
  assertPositiveInteger("catalogDescriptionMaxLength", catalogDescriptionMaxLength, 3);
196
+ const closedCatalogProviders = validateProviderList("closedCatalogProviders", config.closedCatalogProviders ?? DEFAULT_CLOSED_CATALOG_PROVIDERS);
197
+ const unknownStreaks = /* @__PURE__ */ new WeakMap();
198
+ ctx.on("session/event", (session, event) => {
199
+ if (event.type !== "turn/start") return;
200
+ const streak = unknownStreaks.get(session);
201
+ if (streak !== void 0) streak.consecutiveUnknown = 0;
202
+ });
59
203
  const skillTool = defineTool({
60
204
  name: "skill",
61
205
  description: "Load the full instructions for an available skill. Call this with the exact skill name from the session skill catalog before acting on a task that names or clearly matches that skill.",
@@ -136,24 +280,14 @@ function apply(ctx, config = {}) {
136
280
  }]
137
281
  },
138
282
  async execute(args, exec) {
283
+ const streak = streakFor(exec.agent, unknownStreaks, closedCatalogProviders);
284
+ if (streak !== void 0 && streak.consecutiveUnknown >= 3) throw new Error(CLOSED_SKILL_CATALOG_THIS_TURN);
139
285
  if (!isSkillName(args.name)) throw new Error(`invalid skill name "${args.name}"`);
140
- const lookup = {
286
+ return await loadModelInvocableSkill(ctx, args.name, {
141
287
  cwd: exec.agent?.session.header.cwd,
142
288
  signal: exec.signal,
143
289
  scope: exec.agent
144
- };
145
- const summary = (await ctx.skills.list(lookup)).find((skill) => skill.name === args.name);
146
- if (!summary) throw new Error(`skill "${args.name}" is unknown or no longer available`);
147
- if (!isModelInvocable(summary)) throw new Error(`skill "${args.name}" is not available for model invocation`);
148
- const skill = await ctx.skills.get(args.name, lookup);
149
- if (!skill) throw new Error(`skill "${args.name}" is unknown or no longer available`);
150
- if (!isModelInvocable(skill)) throw new Error(`skill "${args.name}" is not available for model invocation`);
151
- return {
152
- name: skill.name,
153
- provider: skill.provider,
154
- ...skill.resourceBase !== void 0 ? { resourceBase: { ...skill.resourceBase } } : {},
155
- content: skill.content
156
- };
290
+ }, streak);
157
291
  },
158
292
  presentCall(args) {
159
293
  return {
@@ -235,6 +369,50 @@ function apply(ctx, config = {}) {
235
369
  };
236
370
  });
237
371
  }
372
+ function streakFor(agent, streaks, providers) {
373
+ if (agent === void 0 || !isClosedCatalogRoute(agent, providers)) return void 0;
374
+ const existing = streaks.get(agent.session);
375
+ if (existing !== void 0) return existing;
376
+ const created = { consecutiveUnknown: 0 };
377
+ streaks.set(agent.session, created);
378
+ return created;
379
+ }
380
+ /** Whether this agent's current or selected provider is in the hard-stop list. */
381
+ function isClosedCatalogRoute(agent, providers) {
382
+ const provider = agent.session.requestHeader?.()?.config.provider ?? agent.options?.provider;
383
+ return provider !== void 0 && providers.includes(provider);
384
+ }
385
+ function validateProviderList(field, values) {
386
+ for (const value of values) if (value.length === 0) throw new Error(`tool-skill: ${field} entries must be non-empty`);
387
+ return [...values];
388
+ }
389
+ function throwUnknownSkill(name, catalogNames, streak) {
390
+ if (streak !== void 0) streak.consecutiveUnknown += 1;
391
+ throw new Error(formatUnknownSkillError(name, catalogNames));
392
+ }
393
+ function assertModelInvocable(name, skill) {
394
+ if (!isModelInvocable(skill)) throw new Error(`skill "${name}" is not available for model invocation`);
395
+ }
396
+ function loadedSkill(skill) {
397
+ return {
398
+ name: skill.name,
399
+ provider: skill.provider,
400
+ ...skill.resourceBase !== void 0 ? { resourceBase: { ...skill.resourceBase } } : {},
401
+ content: skill.content
402
+ };
403
+ }
404
+ async function loadModelInvocableSkill(ctx, name, lookup, streak) {
405
+ const summaries = await ctx.skills.list(lookup);
406
+ const catalogNames = summaries.filter(isModelInvocable).map((skill) => skill.name);
407
+ const summary = summaries.find((skill) => skill.name === name);
408
+ if (summary === void 0) throwUnknownSkill(name, catalogNames, streak);
409
+ assertModelInvocable(name, summary);
410
+ const skill = await ctx.skills.get(name, lookup);
411
+ if (skill === void 0) throwUnknownSkill(name, catalogNames, streak);
412
+ assertModelInvocable(name, skill);
413
+ if (streak !== void 0) streak.consecutiveUnknown = 0;
414
+ return loadedSkill(skill);
415
+ }
238
416
  function renderCatalogMessage(entries) {
239
417
  return createUserMessage({
240
418
  content: [{
@@ -393,4 +571,4 @@ function invokedSkillNames(messages) {
393
571
  return names;
394
572
  }
395
573
  //#endregion
396
- export { Config, apply, inject, name };
574
+ export { CLOSED_SKILL_CATALOG_LINE, CLOSED_SKILL_CATALOG_THIS_TURN, Config, MAX_CLOSE_SKILL_DISTANCE, MAX_CLOSE_SKILL_SUGGESTIONS, MAX_LISTED_CATALOG_NAMES, UNKNOWN_SKILL_STREAK_LIMIT, apply, compareCatalogNames, formatUnknownSkillError, inject, isSubsequenceOf, levenshteinDistance, name, rankClosestCatalogNames, unknownSkillLine };
@@ -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/todo/tool-todo/README.md
5
- README.md: 0547688d833f10ae9504496d703ed7532e397e3e
6
- README.zh.md: 1bf055cb769455802620a7d7c77dc80851456ffe
5
+ README.md: 55fd51cdc51f6144e138c760f66b632ffdf8c813
6
+ README.zh.md: d59c887156414405bea4687c937035c699ac7e83
@@ -49,7 +49,7 @@ The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-a
49
49
 
50
50
  ### What each call does
51
51
 
52
- The agent sends the ENTIRE list on every update; the new list replaces the previous one, so there are no partial updates or per-item edits. Each item is a short task description plus a status of `pending`, `in_progress`, or `completed`. A successful update returns the new counts — `Updated todo list: <pending> pending, <inProgress> in progress, <completed> completed.` — and the UI shows the new plan. Updates fail visibly when a task description is empty or duplicated, when an item carries fields beyond the description and status, or — when parallel work is disabled — when more than one task is marked in progress.
52
+ The agent sends the ENTIRE list on every update; the new list replaces the previous one, so there are no partial updates or per-item edits. Each item is a short task description plus a status of `pending`, `in_progress`, or `completed`. A successful update that changes the list returns `Updated todo list: <pending> pending, <inProgress> in progress, <completed> completed.` and the UI shows the new plan; rewriting the same canonical list returns `todo list unchanged` without appending another snapshot. Updates fail visibly when a task description is empty or duplicated, when an item carries fields beyond the description and status, or — when parallel work is disabled — when more than one task is marked in progress.
53
53
 
54
54
  ### Single owner
55
55
 
@@ -99,7 +99,7 @@ The invariant companion registers on `ctx.invariants`, validates existing and ne
99
99
 
100
100
  ### Call mechanics
101
101
 
102
- Each call validates the submitted list against the schema, rejects incoherent input, and on success appends the full snapshot as a `todo/write` session event and returns the new counts; the current list is always the most recent `todo/write` in the log (last-write-wins on replay). See [src/index.ts](src/index.ts) for the exact validation and append steps.
102
+ Each call validates the submitted list against the schema and rejects incoherent input. A list that differs from the latest `todo/write` snapshot appends a new snapshot and returns the updated counts; a canonical match — trimmed unique content plus status, same order — returns success without appending. The current list is always the most recent `todo/write` in the log (last-write-wins on replay). See [src/index.ts](src/index.ts) for the exact validation and append steps.
103
103
 
104
104
  </details>
105
105
 
@@ -140,7 +140,7 @@ Prefix-stable while the definition and visibility are unchanged. Plugin lifecycl
140
140
 
141
141
  #### What the model sees
142
142
 
143
- Each assistant tool call retains the entire replacement list in its arguments. Success returns exactly `Updated todo list: <pending> pending, <inProgress> in progress, <completed> completed.` Stable failures are ``Error: invalid todo: `content` must be a non-empty string``, `Error: invalid todos: duplicate content "<content>"`, `Error: todo_write requires an owning agent session`, and — only where the deployment set `allowParallelInProgress: false` — `Error: invalid todos: at most one task may be in_progress (got <n>)`. The full `todo/write` session event is UI and replay state, not a second model message.
143
+ Each assistant tool call retains the entire replacement list in its arguments. Success returns exactly `Updated todo list: <pending> pending, <inProgress> in progress, <completed> completed.` when the list changed, and exactly `todo list unchanged` when the canonical list already matches the latest snapshot. Stable failures are ``Error: invalid todo: `content` must be a non-empty string``, `Error: invalid todos: duplicate content "<content>"`, `Error: todo_write requires an owning agent session`, and — only where the deployment set `allowParallelInProgress: false` — `Error: invalid todos: at most one task may be in_progress (got <n>)`. The full `todo/write` session event is UI and replay state, not a second model message.
144
144
 
145
145
  #### Token effect
146
146
 
@@ -49,7 +49,7 @@ kind: "package-reference"
49
49
 
50
50
  ### 每次调用做什么
51
51
 
52
- agent 每次更新都发送完整列表;新列表替换旧列表,因此没有部分更新或逐项编辑。每个条目是一句简短的任务描述,外加 `pending`、`in_progress` 或 `completed` 状态。成功的更新会返回新的计数——`Updated todo list: <pending> pending, <inProgress> in progress, <completed> completed.`——UI 随即展示新计划。任务描述为空或重复、条目带有描述与状态之外的字段、或(禁用并行时)多个任务被标记为进行中,这些情况下更新都会明确失败。
52
+ agent 每次更新都发送完整列表;新列表替换旧列表,因此没有部分更新或逐项编辑。每个条目是一句简短的任务描述,外加 `pending`、`in_progress` 或 `completed` 状态。改变列表的成功更新会返回 `Updated todo list: <pending> pending, <inProgress> in progress, <completed> completed.`,UI 随即展示新计划;重写同一份规范列表则返回 `todo list unchanged`,且不再追加快照。任务描述为空或重复、条目带有描述与状态之外的字段、或(禁用并行时)多个任务被标记为进行中,这些情况下更新都会明确失败。
53
53
 
54
54
  ### 单一所有者
55
55
 
@@ -99,7 +99,7 @@ agent 每次更新都发送完整列表;新列表替换旧列表,因此没
99
99
 
100
100
  ### 调用机制
101
101
 
102
- 每次调用都会先校验提交的列表是否符合 schema,拒绝不一致的输入,成功后把完整快照作为 `todo/write` 会话事件追加并返回新的计数;当前列表始终是日志中最近一次 `todo/write`(回放时后写覆盖先写)。确切的校验与追加步骤见 [src/index.ts](src/index.ts)。
102
+ 每次调用都会先校验提交的列表是否符合 schema,并拒绝不一致的输入。与最近一次 `todo/write` 快照不同的列表会追加新快照并返回更新后的计数;规范匹配——去空白后的唯一 content 加 status、顺序相同——则成功返回且不追加。当前列表始终是日志中最近一次 `todo/write`(回放时后写覆盖先写)。确切的校验与追加步骤见 [src/index.ts](src/index.ts)。
103
103
 
104
104
  </details>
105
105
 
@@ -140,7 +140,7 @@ agent 每次更新都发送完整列表;新列表替换旧列表,因此没
140
140
 
141
141
  #### 模型看到什么
142
142
 
143
- 每次 assistant 工具调用都会在参数中保留整个替换列表。成功时原样返回 `Updated todo list: <pending> pending, <inProgress> in progress, <completed> completed.`。稳定失败文本为 ``Error: invalid todo: `content` must be a non-empty string``、`Error: invalid todos: duplicate content "<content>"`、`Error: todo_write requires an owning agent session`,以及——仅在部署设置 `allowParallelInProgress: false` 时——`Error: invalid todos: at most one task may be in_progress (got <n>)`。完整的 `todo/write` 会话事件是 UI 与回放状态,而非第二条模型消息。
143
+ 每次 assistant 工具调用都会在参数中保留整个替换列表。成功时,列表已变化则原样返回 `Updated todo list: <pending> pending, <inProgress> in progress, <completed> completed.`,规范列表已与最近快照相同则原样返回 `todo list unchanged`。稳定失败文本为 ``Error: invalid todo: `content` must be a non-empty string``、`Error: invalid todos: duplicate content "<content>"`、`Error: todo_write requires an owning agent session`,以及——仅在部署设置 `allowParallelInProgress: false` 时——`Error: invalid todos: at most one task may be in_progress (got <n>)`。完整的 `todo/write` 会话事件是 UI 与回放状态,而非第二条模型消息。
144
144
 
145
145
  #### Token 影响
146
146
 
@@ -3,9 +3,10 @@ import { z as z$1 } from "zod";
3
3
  import { defineTool } from "@deepseek-ai/dsh-tools";
4
4
  //#region lib/types/index.js
5
5
  /**
6
- * Model-facing whole-list replacement. Each call appends a `todo/write` snapshot to the calling
7
- * agent's session; replay is last-write-wins, and UIs render from session events. A non-agent
8
- * caller has no owning list and is rejected. Named exports preserve loader injection metadata.
6
+ * Model-facing whole-list replacement. A changing write appends a `todo/write` snapshot to the
7
+ * calling agent's session; an identical canonical list succeeds without appending. Replay is
8
+ * last-write-wins, and UIs render from session events. A non-agent caller has no owning list and
9
+ * is rejected. Named exports preserve loader injection metadata.
9
10
  * @module @deepseek-ai/dsh-tool-todo
10
11
  */
11
12
  const name = "tool-todo";
@@ -60,6 +61,24 @@ function toTodoList(raw, allowParallel) {
60
61
  if (!allowParallel && active > 1) throw new Error(`invalid todos: at most one task may be in_progress (got ${active})`);
61
62
  return todos;
62
63
  }
64
+ /**
65
+ * Compare two canonical lists: trimmed unique content plus status, same order.
66
+ * @param left - one canonical list.
67
+ * @param right - the other canonical list.
68
+ * @returns whether every item matches at the same index.
69
+ */
70
+ function sameTodoList(left, right) {
71
+ return JSON.stringify(left) === JSON.stringify(right);
72
+ }
73
+ /**
74
+ * Read the latest whole-list snapshot from the owning session log. The standing-plan
75
+ * projection is not this source: `turn/start` clears it while the durable write remains.
76
+ * @param session - the calling agent's session.
77
+ * @returns the latest `todo/write` list, or `undefined` before the first write.
78
+ */
79
+ function latestWrittenTodos(session) {
80
+ return session.snapshotEvents().findLast((event) => event.type === "todo/write")?.data.todos;
81
+ }
63
82
  /** Wire payload schema of the `todos` projection (whole list or pre-first-write null). */
64
83
  const todosProjectionSchema = z$1.union([z$1.array(z$1.object({
65
84
  content: z$1.string(),
@@ -159,18 +178,24 @@ function apply(ctx, config) {
159
178
  required: true
160
179
  }
161
180
  }
181
+ },
182
+ unchanged: {
183
+ type: "boolean",
184
+ required: true
162
185
  }
163
186
  }
164
187
  },
165
188
  render: (_args, value) => [{
166
189
  type: "text",
167
- text: `Updated todo list: ${value.counts.pending} pending, ${value.counts.inProgress} in progress, ${value.counts.completed} completed.`
190
+ text: value.unchanged ? "todo list unchanged" : `Updated todo list: ${value.counts.pending} pending, ${value.counts.inProgress} in progress, ${value.counts.completed} completed.`
168
191
  }]
169
192
  },
170
193
  execute(args, exec) {
171
194
  const todos = toTodoList(args.todos, allowParallel);
172
195
  if (!exec.agent) throw new Error("todo_write requires an owning agent session");
173
- exec.agent.session.append("todo/write", { todos });
196
+ const previous = latestWrittenTodos(exec.agent.session);
197
+ const unchanged = previous !== void 0 && sameTodoList(previous, todos);
198
+ if (!unchanged) exec.agent.session.append("todo/write", { todos });
174
199
  const count = (status) => todos.filter((t) => t.status === status).length;
175
200
  return Promise.resolve({
176
201
  todos: todos.map((todo) => ({
@@ -181,7 +206,8 @@ function apply(ctx, config) {
181
206
  pending: count("pending"),
182
207
  inProgress: count("in_progress"),
183
208
  completed: count("completed")
184
- }
209
+ },
210
+ unchanged
185
211
  });
186
212
  },
187
213
  presentCall: (args) => ({
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Model-facing whole-list replacement. Each call appends a `todo/write` snapshot to the calling
3
- * agent's session; replay is last-write-wins, and UIs render from session events. A non-agent
4
- * caller has no owning list and is rejected. Named exports preserve loader injection metadata.
2
+ * Model-facing whole-list replacement. A changing write appends a `todo/write` snapshot to the
3
+ * calling agent's session; an identical canonical list succeeds without appending. Replay is
4
+ * last-write-wins, and UIs render from session events. A non-agent caller has no owning list and
5
+ * is rejected. Named exports preserve loader injection metadata.
5
6
  * @module @deepseek-ai/dsh-tool-todo
6
7
  */
7
8
  import z from '@deepseek-ai/schemastery';
@@ -74,6 +75,24 @@ function toTodoList(raw, allowParallel) {
74
75
  }
75
76
  return todos;
76
77
  }
78
+ /**
79
+ * Compare two canonical lists: trimmed unique content plus status, same order.
80
+ * @param left - one canonical list.
81
+ * @param right - the other canonical list.
82
+ * @returns whether every item matches at the same index.
83
+ */
84
+ function sameTodoList(left, right) {
85
+ return JSON.stringify(left) === JSON.stringify(right);
86
+ }
87
+ /**
88
+ * Read the latest whole-list snapshot from the owning session log. The standing-plan
89
+ * projection is not this source: `turn/start` clears it while the durable write remains.
90
+ * @param session - the calling agent's session.
91
+ * @returns the latest `todo/write` list, or `undefined` before the first write.
92
+ */
93
+ function latestWrittenTodos(session) {
94
+ return session.snapshotEvents().findLast(event => event.type === 'todo/write')?.data.todos;
95
+ }
77
96
  /** Wire payload schema of the `todos` projection (whole list or pre-first-write null). */
78
97
  const todosProjectionSchema = zod.union([
79
98
  zod.array(zod.object({
@@ -158,11 +177,14 @@ export function apply(ctx, config) {
158
177
  completed: { type: 'integer', required: true },
159
178
  },
160
179
  },
180
+ unchanged: { type: 'boolean', required: true },
161
181
  },
162
182
  },
163
183
  render: (_args, value) => [{
164
184
  type: 'text',
165
- text: `Updated todo list: ${value.counts.pending} pending, ${value.counts.inProgress} in progress, ${value.counts.completed} completed.`,
185
+ text: value.unchanged
186
+ ? 'todo list unchanged'
187
+ : `Updated todo list: ${value.counts.pending} pending, ${value.counts.inProgress} in progress, ${value.counts.completed} completed.`,
166
188
  }],
167
189
  },
168
190
  execute(args, exec) {
@@ -172,7 +194,10 @@ export function apply(ctx, config) {
172
194
  // session) has nowhere to write it. Reject rather than silently no-op.
173
195
  throw new Error('todo_write requires an owning agent session');
174
196
  }
175
- exec.agent.session.append('todo/write', { todos });
197
+ const previous = latestWrittenTodos(exec.agent.session);
198
+ const unchanged = previous !== undefined && sameTodoList(previous, todos);
199
+ if (!unchanged)
200
+ exec.agent.session.append('todo/write', { todos });
176
201
  const count = (status) => todos.filter(t => t.status === status).length;
177
202
  return Promise.resolve({
178
203
  todos: todos.map(todo => ({ content: todo.content, status: todo.status })),
@@ -181,6 +206,7 @@ export function apply(ctx, config) {
181
206
  inProgress: count('in_progress'),
182
207
  completed: count('completed'),
183
208
  },
209
+ unchanged,
184
210
  });
185
211
  },
186
212
  presentCall: args => ({ card: 'generic', title: 'Update todo list', kind: 'other', rawInput: args.todos }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@songtonyli/dsh-cli",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "The dsh terminal agent: an interactive TUI over the DeepSeek Harness, with its whole Node runtime bundled in one install.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -189,6 +189,7 @@
189
189
  "@deepseek-ai/dsh-mcp-resources": "0.1.6-alpha.2",
190
190
  "@deepseek-ai/dsh-message-feedback": "0.1.6-alpha.2",
191
191
  "@deepseek-ai/dsh-native-command": "0.1.6-alpha.2",
192
+ "@deepseek-ai/dsh-no-progress-reminder": "0.1.6-alpha.2",
192
193
  "@deepseek-ai/dsh-office-to-pdf": "0.1.6-alpha.2",
193
194
  "@deepseek-ai/dsh-output-retention": "0.1.6-alpha.2",
194
195
  "@deepseek-ai/dsh-package-manifest": "0.1.6-alpha.2",
@@ -785,6 +786,7 @@
785
786
  "@deepseek-ai/dsh-mcp-resources",
786
787
  "@deepseek-ai/dsh-message-feedback",
787
788
  "@deepseek-ai/dsh-native-command",
789
+ "@deepseek-ai/dsh-no-progress-reminder",
788
790
  "@deepseek-ai/dsh-office-to-pdf",
789
791
  "@deepseek-ai/dsh-output-retention",
790
792
  "@deepseek-ai/dsh-package-manifest",