dsh-workplan 2.0.4 → 2.1.1

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/lib/plan.js CHANGED
@@ -11,6 +11,7 @@ import { DEPARTMENT_CAPABILITIES, departmentCapability } from './departments.js'
11
11
  import { MAX_TASK_ANCHOR_CHARS } from './understanding.js';
12
12
  import { isMappingDigest, verifyMappingDigest } from './supersede-digest.js';
13
13
  import { phaseSummaryLine, threePhasePromptLines, validatePhaseEvidence } from './three-phase.js';
14
+ import { checkCommFormatCompliance, renderCommFormatRejection, renderCommFormatSpec, } from './comm-format.js';
14
15
  export const PLAN_VERSION = 1;
15
16
  /**
16
17
  * [1.9.0] 处置终态:cancelled(用户撤销)与 superseded(责任已转移)。
@@ -116,7 +117,7 @@ export const CLOSURES = Object.freeze([
116
117
  'replanned',
117
118
  ]);
118
119
  /** Why a `blocked` / `escalated` row stopped. Read by the dashboard and result message. */
119
- export const BLOCKED_KINDS = Object.freeze(['failed', 'timeout', 'no-ack', 'escalated']);
120
+ export const BLOCKED_KINDS = Object.freeze(['failed', 'timeout', 'no-ack', 'escalated', 'comm-format']);
120
121
  /**
121
122
  * [1.11.0] 合法闭环迁移(T4 §4 的 19 条,M1)。
122
123
  *
@@ -850,6 +851,124 @@ export function flattenSubtasks(plan) {
850
851
  }
851
852
  return out;
852
853
  }
854
+ /**
855
+ * [2.1.0] 只补结构、不补内容。
856
+ *
857
+ * 规划器返回的 JSON 常见三类损伤:少一个 `}`、多一个尾逗号、字符串里有裸换行。
858
+ * 旧实现直接 JSON.parse,一个字符之差就抛 INVALID_JSON,整个计划降级。
859
+ * 这里做的是纯结构修复:配对括号、去掉尾逗号、把字符串里的裸控制符转义。
860
+ * 绝不猜测、绝不编造任何字段或值——修不好就照旧抛错。
861
+ */
862
+ export function repairJsonStructure(input) {
863
+ const stack = [];
864
+ let inString = false;
865
+ let escaped = false;
866
+ let out = '';
867
+ for (let i = 0; i < input.length; i += 1) {
868
+ const ch = input[i];
869
+ if (inString) {
870
+ if (escaped) {
871
+ out += ch;
872
+ escaped = false;
873
+ continue;
874
+ }
875
+ if (ch === '\\') {
876
+ out += ch;
877
+ escaped = true;
878
+ continue;
879
+ }
880
+ if (ch === '"') {
881
+ inString = false;
882
+ out += ch;
883
+ continue;
884
+ }
885
+ if (ch === '\n') {
886
+ out += '\\n';
887
+ continue;
888
+ }
889
+ if (ch === '\r') {
890
+ out += '\\r';
891
+ continue;
892
+ }
893
+ if (ch === '\t') {
894
+ out += '\\t';
895
+ continue;
896
+ }
897
+ if (ch < ' ') {
898
+ out += `\\u${ch.charCodeAt(0).toString(16).padStart(4, '0')}`;
899
+ continue;
900
+ }
901
+ out += ch;
902
+ continue;
903
+ }
904
+ if (ch === '"') {
905
+ inString = true;
906
+ out += ch;
907
+ continue;
908
+ }
909
+ if (ch === '{' || ch === '[') {
910
+ stack.push(ch);
911
+ out += ch;
912
+ continue;
913
+ }
914
+ if (ch === '}' || ch === ']') {
915
+ const want = ch === '}' ? '{' : '[';
916
+ while (stack.length > 0 && stack[stack.length - 1] !== want) {
917
+ out += stack.pop() === '{' ? '}' : ']';
918
+ }
919
+ if (stack.length > 0)
920
+ stack.pop();
921
+ out += ch;
922
+ continue;
923
+ }
924
+ out += ch;
925
+ }
926
+ if (inString)
927
+ out += '"';
928
+ while (stack.length > 0)
929
+ out += stack.pop() === '{' ? '}' : ']';
930
+ return stripTrailingCommas(out);
931
+ }
932
+ function stripTrailingCommas(input) {
933
+ return input.replace(/,(\s*[}\]])/g, '$1');
934
+ }
935
+ /** 找到最后一个「成员边界」逗号(在任何嵌套深度上、且不在字符串内)。 */
936
+ function lastMemberComma(input) {
937
+ let inString = false;
938
+ let escaped = false;
939
+ let index = -1;
940
+ for (let i = 0; i < input.length; i += 1) {
941
+ const ch = input[i];
942
+ if (inString) {
943
+ if (escaped)
944
+ escaped = false;
945
+ else if (ch === '\\')
946
+ escaped = true;
947
+ else if (ch === '"')
948
+ inString = false;
949
+ continue;
950
+ }
951
+ if (ch === '"')
952
+ inString = true;
953
+ else if (ch === ',')
954
+ index = i;
955
+ }
956
+ return index;
957
+ }
958
+ /**
959
+ * 截断修复:规划器被 max tokens 截断时,最后一个成员通常是半截的。
960
+ * 从尾部逐个丢弃不完整成员,再补齐括号——丢掉的都是「本来就残缺、不能用」的内容。
961
+ */
962
+ function* truncatedCandidates(input, rounds = 24) {
963
+ let working = input;
964
+ for (let round = 0; round < rounds; round += 1) {
965
+ const cut = lastMemberComma(working);
966
+ if (cut <= 0)
967
+ return;
968
+ working = working.slice(0, cut);
969
+ yield repairJsonStructure(working);
970
+ }
971
+ }
853
972
  export function extractJson(text) {
854
973
  if (typeof text !== 'string' || text.trim() === '') {
855
974
  throw new PlanError('规划器没有返回内容', 'EMPTY_OUTPUT');
@@ -859,15 +978,34 @@ export function extractJson(text) {
859
978
  if (fenced)
860
979
  value = fenced[1].trim();
861
980
  const first = value.indexOf('{');
862
- const last = value.lastIndexOf('}');
863
- if (first < 0 || last <= first) {
981
+ if (first < 0) {
864
982
  throw new PlanError('规划器返回内容中没有 JSON 对象', 'NO_JSON');
865
983
  }
866
- const candidate = value.slice(first, last + 1);
984
+ const last = value.lastIndexOf('}');
985
+ // [2.1.0] 输出被截断时没有结尾 `}`,旧实现这里直接判 NO_JSON —— 改成仍以 `{` 起头做修复。
986
+ const candidate = last > first ? value.slice(first, last + 1) : value.slice(first);
867
987
  try {
868
988
  return JSON.parse(candidate);
869
989
  }
870
990
  catch (error) {
991
+ const repaired = repairJsonStructure(candidate);
992
+ try {
993
+ const value2 = JSON.parse(repaired);
994
+ console.warn('[dsh-workplan] 规划器 JSON 结构已修复(只补括号/逗号,未改内容)');
995
+ return value2;
996
+ }
997
+ catch {
998
+ for (const attempt of truncatedCandidates(repaired)) {
999
+ try {
1000
+ const value3 = JSON.parse(attempt);
1001
+ console.warn('[dsh-workplan] 规划器 JSON 被截断,已丢弃末尾残缺成员后解析成功');
1002
+ return value3;
1003
+ }
1004
+ catch {
1005
+ continue;
1006
+ }
1007
+ }
1008
+ }
871
1009
  throw new PlanError(`规划器返回的 JSON 无法解析:${error instanceof Error ? error.message : String(error)}`, 'INVALID_JSON');
872
1010
  }
873
1011
  }
@@ -1904,6 +2042,48 @@ function readEvidenceOptions(value) {
1904
2042
  .map((item) => truncate(typeof item === 'string' ? item : String(item ?? ''), 300))
1905
2043
  .filter(Boolean);
1906
2044
  }
2045
+ /**
2046
+ * [2.1.0] 顶层证据字段被误写进 `phases` 时,把它们提回顶层(用户 2026-11-05)。
2047
+ *
2048
+ * 事故(子会话 13b45af6 原文复核):子 Agent 的回执像这样——
2049
+ * {"status":"done","phases":{"planning":{…},"execution":{…},"verification":{…},
2050
+ * "acceptance":[…4 条…],"artifacts":[…]}}
2051
+ * 少了一个 `}`,于是 acceptance/artifacts 全部落进 `phases`。`closeOpenJson`
2052
+ * 在末尾补一个 `}` 后 JSON 合法,`readEvidenceAcceptance(payload.acceptance)`
2053
+ * 读到空数组,最终判成「验收项未被逐条回应(0/4)」——证据一条不缺,却被
2054
+ * 说成「没做验收」,且把责任推回子 Agent。这不是证据问题,是层级错位。
2055
+ *
2056
+ * 这里只做**位置归位**:字段名与值原样搬回顶层,不改内容、不补内容;顶层
2057
+ * 已有非空值时不覆盖(避免把真值盖掉)。归位后仍走完整门禁。
2058
+ */
2059
+ const HOISTABLE_EVIDENCE_KEYS = ['acceptance', 'artifacts', 'needs', 'question', 'options'];
2060
+ export function hoistEvidenceFields(payload) {
2061
+ if (!isRecord(payload) || !isRecord(payload.phases))
2062
+ return { payload, hoisted: [] };
2063
+ const phases = payload.phases;
2064
+ const next = { ...payload, phases: { ...phases } };
2065
+ const hoisted = [];
2066
+ for (const key of HOISTABLE_EVIDENCE_KEYS) {
2067
+ const top = next[key];
2068
+ const topEmpty = top === undefined || top === null
2069
+ || (Array.isArray(top) && top.length === 0)
2070
+ || (typeof top === 'string' && top.trim() === '');
2071
+ if (!topEmpty)
2072
+ continue;
2073
+ if (!(key in phases))
2074
+ continue;
2075
+ const value = phases[key];
2076
+ const hasValue = Array.isArray(value)
2077
+ ? value.length > 0
2078
+ : typeof value === 'string' ? value.trim() !== '' : false;
2079
+ if (!hasValue)
2080
+ continue;
2081
+ next[key] = value;
2082
+ delete next.phases[key];
2083
+ hoisted.push(key);
2084
+ }
2085
+ return hoisted.length > 0 ? { payload: next, hoisted } : { payload, hoisted };
2086
+ }
1907
2087
  /**
1908
2088
  * Parse the child's structured evidence block.
1909
2089
  *
@@ -2016,7 +2196,7 @@ export function repairEvidenceJson(text) {
2016
2196
  * 这里做的是**有界认领**:只认带 `status` 且至少还有一个证据字段的 JSON
2017
2197
  * 对象,绝不把任意 JSON(比如计划载荷、配置片段)当成回执。
2018
2198
  */
2019
- export function rescueEvidenceFromFence(output) {
2199
+ function rescueEvidence(output) {
2020
2200
  const text = typeof output === 'string' ? output : '';
2021
2201
  if (!text.includes('{'))
2022
2202
  return null;
@@ -2030,12 +2210,15 @@ export function rescueEvidenceFromFence(output) {
2030
2210
  if (first >= 0 && last > first)
2031
2211
  candidates.push(text.slice(first, last + 1));
2032
2212
  for (const candidate of candidates) {
2213
+ const body = String(candidate).trim();
2033
2214
  let value = null;
2215
+ let repaired = false;
2034
2216
  try {
2035
- value = JSON.parse(String(candidate).trim());
2217
+ value = JSON.parse(body);
2036
2218
  }
2037
2219
  catch {
2038
- value = repairEvidenceJson(String(candidate).trim());
2220
+ value = repairEvidenceJson(body);
2221
+ repaired = value !== null;
2039
2222
  }
2040
2223
  if (!isRecord(value))
2041
2224
  continue;
@@ -2045,17 +2228,29 @@ export function rescueEvidenceFromFence(output) {
2045
2228
  || Array.isArray(value.needs) || isRecord(value.phases) || typeof value.summary === 'string';
2046
2229
  if (!hasEvidence)
2047
2230
  continue;
2048
- return value;
2231
+ return { payload: value, raw: body, repaired };
2049
2232
  }
2050
2233
  return null;
2051
2234
  }
2235
+ export function rescueEvidenceFromFence(output) {
2236
+ const rescued = rescueEvidence(output);
2237
+ return rescued ? rescued.payload : null;
2238
+ }
2052
2239
  export function parseEvidenceBlock(output) {
2053
2240
  const text = typeof output === 'string' ? output : '';
2054
2241
  const begin = text.lastIndexOf(EVIDENCE_MARKER_BEGIN);
2055
2242
  if (begin < 0) {
2056
- const rescued = rescueEvidenceFromFence(text);
2243
+ const rescued = rescueEvidence(text);
2057
2244
  if (rescued) {
2058
- return { found: true, malformed: false, truncated: false, repaired: false, rescued: true, payload: rescued, raw: '' };
2245
+ return {
2246
+ found: true,
2247
+ malformed: false,
2248
+ truncated: false,
2249
+ repaired: rescued.repaired,
2250
+ rescued: true,
2251
+ payload: rescued.payload,
2252
+ raw: rescued.raw,
2253
+ };
2059
2254
  }
2060
2255
  return { found: false, malformed: false, truncated: false, repaired: false, rescued: false, payload: null, raw: '' };
2061
2256
  }
@@ -2160,7 +2355,8 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
2160
2355
  error: '子 Agent 未提供结构化证据块(完成必回报):结果块缺失,无法确认验收项是否真的通过',
2161
2356
  };
2162
2357
  }
2163
- const payload = parsed.payload;
2358
+ const hoistedEvidence = hoistEvidenceFields(parsed.payload);
2359
+ const payload = hoistedEvidence.payload;
2164
2360
  const acceptance = readEvidenceAcceptance(payload.acceptance);
2165
2361
  const artifacts = readEvidenceArtifacts(payload.artifacts);
2166
2362
  const needs = readEvidenceNeeds(payload.needs);
@@ -2235,6 +2431,19 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
2235
2431
  */
2236
2432
  const coverage = acceptanceCoverage(expectedAcceptance, acceptance);
2237
2433
  if (coverage.total > 0 && coverage.missing.length > 0) {
2434
+ /*
2435
+ * [2.1.0] 先把「为什么没读到」说清楚,再要求补证据。
2436
+ *
2437
+ * 旧文案只有一句「验收项未被逐条回应」,于是「真没回」「层级写错」
2438
+ * 「被截断」三种完全不同的原因长得一模一样,主 Agent 只能反复重派。
2439
+ */
2440
+ const rawText = String(parsed.raw ?? '');
2441
+ const rawHasAcceptance = /"acceptance"\s*:/.test(rawText);
2442
+ const hint = acceptance.length === 0 && rawHasAcceptance
2443
+ ? '(原始结果块里确实写了 acceptance,但没有落在顶层:通常是 phases 少一个 } 导致层级错位,已尝试自动归位仍未读到)'
2444
+ : parsed.repaired
2445
+ ? '(结果块 JSON 有语法错误,已修复;若 acceptance 位于错误点之后,会被一起裁掉)'
2446
+ : '';
2238
2447
  return {
2239
2448
  status: 'blocked',
2240
2449
  verification: 'unverified',
@@ -2242,7 +2451,7 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
2242
2451
  artifacts,
2243
2452
  needs,
2244
2453
  error: `验收项未被逐条回应(${coverage.covered}/${coverage.total}):缺少 ${coverage.missing
2245
- .map((item) => truncate(String(item), 120)).slice(0, 5).join(';')}。请按计划验收逐条给出证据后再回报。`,
2454
+ .map((item) => truncate(String(item), 120)).slice(0, 5).join(';')}${hint}。请按计划验收逐条给出证据后再回报。`,
2246
2455
  };
2247
2456
  }
2248
2457
  /*
@@ -2269,6 +2478,42 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
2269
2478
  phases: null,
2270
2479
  };
2271
2480
  }
2481
+ /*
2482
+ * [2.1.0] 沟通交流格式门禁(用户 2026-11-06 的强制要求,契约见
2483
+ * `src/comm-format.ts`)。
2484
+ *
2485
+ * 主 Agent 派发任务时随提示词附带《沟通交流格式规范》(renderCommFormatSpec),
2486
+ * 部门人员提交前须逐条自查;这里按同一份规范对「其它门禁都已通过、
2487
+ * 即将判 done」的结果做最终核验:任一不合规即退回(blocked/comm-format),
2488
+ * 不合规条目随下一次激活的 previousFailure 发回,通知其重新自查后重交。
2489
+ *
2490
+ * 只拦 done 路径:解析失败、验收缺口、三阶段缺失等已被上方门禁拦下的结果,
2491
+ * 维持原受阻原因,不用格式条目覆盖更有针对性的诊断。
2492
+ */
2493
+ const commFormat = requirePhases === false
2494
+ /*
2495
+ * [2.1.0] 兼容边界:`requirePhases:false` 是「历史回放 / 明确关闭新契约」
2496
+ * 的既有开关(1.13.0 语义)。格式契约只对实时执行生效,不得追溯否决
2497
+ * 旧会话日志里按当时规则合法的 done。
2498
+ */
2499
+ ? { compliant: true, violations: [], version: 0 }
2500
+ : checkCommFormatCompliance(payload, text, Array.isArray(expectedAcceptance) ? expectedAcceptance.length : 0);
2501
+ if (!commFormat.compliant) {
2502
+ return {
2503
+ status: 'blocked',
2504
+ verification: 'unverified',
2505
+ acceptance,
2506
+ artifacts,
2507
+ needs,
2508
+ error: `沟通交流格式不合规,结果已退回重交:${commFormat.violations
2509
+ .map((v) => `${v.ruleId} ${v.message}`)
2510
+ .slice(0, 6)
2511
+ .join(';')}`,
2512
+ blockedKind: 'comm-format',
2513
+ commFormatViolations: commFormat.violations,
2514
+ commFormatRejection: renderCommFormatRejection(commFormat),
2515
+ };
2516
+ }
2272
2517
  return {
2273
2518
  status: 'done',
2274
2519
  verification: hasUnverified ? 'unverified' : 'structured',
@@ -4014,5 +4259,16 @@ export function buildChildPrompt({ plan, subtask, stage, dependencyResults, cwd,
4014
4259
  '- needs 写需要其他部门配合的事项,每条写清「哪个部门 + 需要什么 + 用来做什么」;它会被登记为待处理需求,主 Agent 必须处置后计划才能交付。不要直连其他子 Agent。',
4015
4260
  '- question/options 只在受阻上报时填写;done 时保持空字符串/空数组。',
4016
4261
  '- 整块不超过 12000 字符;不要把这段模板本身抄进结果块。',
4262
+ '',
4263
+ /*
4264
+ * [2.1.0] 派发工作时附带统一沟通交流格式要求(用户 2026-11-06 的强制要求)。
4265
+ *
4266
+ * 规范文本与主 Agent 核验结果用的是同一份数据(src/comm-format.ts),
4267
+ * 「附带的要求」与「核验的尺子」由此不可能长成两个版本。
4268
+ */
4269
+ renderCommFormatSpec(),
4270
+ '提交前自查(强制):逐条对照上面《沟通交流格式规范》F1–F9,确认全部满足后再提交;'
4271
+ + '主 Agent 收到结果后按同一份规范逐条核验,任一不合规即立刻退回,你会收到列明不合规条目的退回通知,'
4272
+ + '须逐条修正、重新自查通过后再重新提交完整结果。',
4017
4273
  ].join('\n'));
4018
4274
  }
package/lib/runtime.js CHANGED
@@ -916,7 +916,13 @@ function settleFromOutput(record, subtask, output, guard, options) {
916
916
  ? { closure: 'done', blockedKind: null }
917
917
  : {
918
918
  closure: 'blocked',
919
- blockedKind: 'failed',
919
+ /*
920
+ * [2.1.0] 沟通交流格式退回是独立的受阻类型:工作本身可能已完成,
921
+ * 只是结果格式不合规,须退回重交。看板与主 Agent 据此区分
922
+ * 「做错了」与「交错了」;退回通知(不合规条目清单)已在
923
+ * error 字段里,由 adjudicateResult 写入。
924
+ */
925
+ blockedKind: verdict.blockedKind === 'comm-format' ? 'comm-format' : 'failed',
920
926
  }),
921
927
  }, guard);
922
928
  if (verdict.status === 'blocked') {
@@ -987,6 +993,41 @@ async function executeSubtask(ctx, record, stage, subtask, options) {
987
993
  ? options.attemptOffset
988
994
  : 1;
989
995
  let lastFailure = options.priorFailure ?? null;
996
+ /*
997
+ * [2.1.0] 格式退回通知必须在下一次激活送达部门人员(用户 2026-11-06 的
998
+ * 强制要求:不符合要求立刻退回,通知其重新检查格式后重交)。
999
+ *
1000
+ * 结果被 `adjudicateResult` 判为 blocked/comm-format 后,退回通知(不合规
1001
+ * 条目清单)落在状态行 error 里;主 Agent 把该行复位为 in_progress 后
1002
+ * blockedKind 保留(只有 settle 的 assigned/done 写入才会清它)。这里据此
1003
+ * 把退回通知作为 COMM_FORMAT_REJECTED 的上次失败原因带回子提示词,部门
1004
+ * 人员重跑时能看到「退回原因 + 逐条修正要求」,而不是从零重做、把同一
1005
+ * 格式错误再交一次。
1006
+ */
1007
+ if (!lastFailure) {
1008
+ const rejectedRow = Array.isArray(record.statuses)
1009
+ ? record.statuses.find((item) => item?.subtaskId === subtask.id)
1010
+ : null;
1011
+ if (rejectedRow?.blockedKind === 'comm-format' && typeof rejectedRow?.error === 'string' && rejectedRow.error.trim() !== '') {
1012
+ lastFailure = {
1013
+ attempt: 1,
1014
+ code: 'COMM_FORMAT_REJECTED',
1015
+ message: rejectedRow.error,
1016
+ };
1017
+ }
1018
+ else if (record.commFormatRejections && typeof record.commFormatRejections === 'object') {
1019
+ /*
1020
+ * [2.1.0] 续跑路径:受阻行已被 `resetBlockedStatuses` 重置,退回原因
1021
+ * 保存在本轮的 `commFormatRejections` 里(见 dispatchPlan 的重置前置抄写)。
1022
+ * 消费一次即删,避免同一条退回通知被后续任意一次重试重复带上。
1023
+ */
1024
+ const stored = record.commFormatRejections[String(subtask.id)];
1025
+ if (typeof stored === 'string' && stored.trim() !== '') {
1026
+ lastFailure = { attempt: 1, code: 'COMM_FORMAT_REJECTED', message: stored };
1027
+ delete record.commFormatRejections[String(subtask.id)];
1028
+ }
1029
+ }
1030
+ }
990
1031
  /*
991
1032
  * [1.8.6] The interrupt has to outlive the thrown error.
992
1033
  *
@@ -1068,7 +1109,11 @@ async function executeSubtask(ctx, record, stage, subtask, options) {
1068
1109
  cwd: options.cwd,
1069
1110
  conversationContext,
1070
1111
  statuses: record.statuses,
1071
- previousFailure: attempt > 1 ? lastFailure : null,
1112
+ /*
1113
+ * [2.1.0] 不再用 attempt>1 做门槛:被格式退回的行复位后第 1 次
1114
+ * 激活也必须带上退回通知,否则「退回」只是写了一行状态。
1115
+ */
1116
+ previousFailure: lastFailure ?? null,
1072
1117
  lessonsBrief,
1073
1118
  }),
1074
1119
  }],
@@ -1730,7 +1775,29 @@ export async function dispatchPlan(ctx, record, options) {
1730
1775
  const repairing = record.phase === 'blocked';
1731
1776
  if (repairing)
1732
1777
  record.resumeCount = Number(record.resumeCount ?? 0) + 1;
1778
+ /*
1779
+ * [2.1.0] 格式退回通知必须先抄下来,再重置受阻行。
1780
+ *
1781
+ * 用户 2026-11-06 的要求是「不符合要求立刻退回,通知其重新检查格式」。
1782
+ * `resetBlockedStatuses` 会把受阻行清成待跑(blockedKind / error 一并清掉),
1783
+ * 于是 executeSubtask 再也看不到「上一次是格式退回」,退回通知永远送不到
1784
+ * 部门人员——退回就只剩状态行上一个记号。这里在重置前把退回原因按子任务
1785
+ * 抄进本轮记录,由 executeSubtask 消费并随提示词发回;重置后这条信息仍
1786
+ * 生效于下一次激活,消费一次即删,不会污染后续无关重试。
1787
+ */
1788
+ const rejectedForRedo = [];
1789
+ for (const row of Array.isArray(record.statuses) ? record.statuses : []) {
1790
+ if (row?.blockedKind === 'comm-format' && typeof row?.error === 'string' && row.error.trim() !== '') {
1791
+ rejectedForRedo.push([String(row.subtaskId), row.error]);
1792
+ }
1793
+ }
1733
1794
  record.statuses = resetBlockedStatuses(record.statuses);
1795
+ if (rejectedForRedo.length > 0) {
1796
+ record.commFormatRejections = {
1797
+ ...(record.commFormatRejections && typeof record.commFormatRejections === 'object' ? record.commFormatRejections : {}),
1798
+ ...Object.fromEntries(rejectedForRedo),
1799
+ };
1800
+ }
1734
1801
  // A resume produces a new durable outcome; without clearing this flag the
1735
1802
  // second result message was never written and a page refresh replayed the
1736
1803
  // stale blocked state.
@@ -5245,7 +5312,7 @@ export function createWorkplanRuntime(ctx, options = {}) {
5245
5312
  * 不打印正文、非零退出。交互式会话维持原样(只 steer,不抛错)。
5246
5313
  */
5247
5314
  /*
5248
- * [2.0.5] U1=B:交互式会话放行,但必须留痕。
5315
+ * [2.1.0] U1=B:交互式会话放行,但必须留痕。
5249
5316
  *
5250
5317
  * 旧行为是 `return` 了事——用户看到回合正常结束,却没有任何地方写着
5251
5318
  * 「这个回合其实是没通过门禁被放出来的」。B 方案不动「不硬拦」这个
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workplan",
3
- "version": "2.0.4",
3
+ "version": "2.1.1",
4
4
  "description": "Automatic task decomposition, real department subagents, and a responsive workplan dashboard for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "license": "MIT",