dsh-workplan 2.1.5 → 2.2.7

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/src/replan.ts CHANGED
@@ -20,6 +20,7 @@ import {
20
20
  MAX_STAGES,
21
21
  MAX_SUBTASKS,
22
22
  PLAN_VERSION,
23
+ REASONING_EFFORTS,
23
24
  applyStatus,
24
25
  flattenSubtasks,
25
26
  isRecord,
@@ -193,13 +194,25 @@ const REPLACEMENT_FIELDS = [
193
194
  'outputs',
194
195
  'acceptance',
195
196
  'risk',
197
+ // [2.2.0][T13b/推理等级] 替换行可显式改档位;未给时 mergeReplacement 继承旧行。
198
+ // [2.2.7][T4/五档+G1] 档位合法集合 = REASONING_EFFORTS(low / medium / high /
199
+ // xhigh / max),入口校验见 replanFieldError 的 reasoningEffort 分支——非法值
200
+ // 在 replan 期即拒绝,不再透传到计划对象、派发期才被静默回落。
201
+ 'reasoningEffort',
196
202
  ] as const
197
203
 
198
204
  /** 用调用方给的替换内容覆盖旧子任务的同名字段;未给字段原样继承。 */
199
205
  function mergeReplacement(old: any, replacement: any, id: string, reason: string): any {
200
206
  const next: any = clone(old)
201
207
  for (const key of REPLACEMENT_FIELDS) {
202
- if (replacement?.[key] !== undefined) next[key] = clone(replacement[key])
208
+ if (replacement?.[key] === undefined) continue
209
+ /*
210
+ * [2.2.7][T4/G1] reasoningEffort 显式 null 按「缺失」处理(与 plan.ts
211
+ * readSubtasks 的 hasEffort 语义对齐):替换行继承旧行档位,
212
+ * 不用 null 覆盖,避免派发期回落 high 与「继承旧行」语义分叉。
213
+ */
214
+ if (key === 'reasoningEffort' && replacement[key] === null) continue
215
+ next[key] = clone(replacement[key])
203
216
  }
204
217
  next.id = id
205
218
  delete next.supersededAt
@@ -245,6 +258,19 @@ function replanFieldError(raw: any): string | null {
245
258
  if (value.length > max) return `${key} 最长 ${max} 字符`
246
259
  return null
247
260
  }
261
+ /*
262
+ * [2.2.7][T4/五档+G1] reasoningEffort 入口白名单(replace/add 两路共用本函数):
263
+ * 与 plan.ts readSubtasks 语义对齐——缺失/显式 null 合法(replace 继承旧行、
264
+ * add 留给派发期回落 high),非缺失值必须是 REASONING_EFFORTS 五档之一
265
+ * (low / medium / high / xhigh / max),非法值拒绝、不改写。补上此校验前,
266
+ * 任意字符串可透传进计划对象,直到派发期才被 runtime 白名单静默回落。
267
+ */
268
+ const effort = raw?.reasoningEffort
269
+ const effortError = effort === undefined || effort === null
270
+ ? null
271
+ : typeof effort !== 'string' || !REASONING_EFFORTS.includes(effort)
272
+ ? 'reasoningEffort 必须是 low / medium / high / xhigh / max 之一(缺失合法:replace 继承旧行、add 派发期回落;非法值拒绝,不改写)'
273
+ : null
248
274
  return list('dependsOn', 12, 16)
249
275
  ?? list('method', 12, 800)
250
276
  ?? list('inputs', 12, 800)
@@ -254,6 +280,7 @@ function replanFieldError(raw: any): string | null {
254
280
  ?? one('title', 200)
255
281
  ?? one('objective', 2000)
256
282
  ?? one('risk', 1000)
283
+ ?? effortError
257
284
  }
258
285
 
259
286
  export function planReplan(plan: any, changes: any, options: any = {}): ReplanResult {
@@ -422,6 +449,10 @@ export function planReplan(plan: any, changes: any, options: any = {}): ReplanRe
422
449
  ? raw.acceptance.map((item: any) => truncate(String(item), 800))
423
450
  : ['复述完成的工作并给出可核对证据'],
424
451
  risk: truncate(String(raw.risk ?? '需求变更后新增,原计划未覆盖'), 1000),
452
+ // [2.2.0][T13b/推理等级] 只登记字段名:显式档位经 replanFieldError 五档白名单
453
+ // 校验后原样透传(low / medium / high / xhigh / max);缺失时本行不经
454
+ // readSubtasks,由派发期 runtime 回落 DEFAULT_REASONING_EFFORT(high)。
455
+ ...(typeof raw.reasoningEffort === 'string' ? { reasoningEffort: raw.reasoningEffort } : {}),
425
456
  insertedBy: 'replan',
426
457
  replannedReason: truncate(String(raw.reason ?? reason), MAX_REPLAN_REASON_CHARS),
427
458
  }