dsh-workplan 2.3.0 → 2.3.2
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/CHANGELOG.md +7 -0
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/docs/release-notes-2.3.2.md +7 -0
- package/docs/release-record-2.3.0-20261110.md +23 -0
- package/lib/host.js +1 -1
- package/lib/plan.js +174 -8
- package/lib/runtime.js +21 -2
- package/package.json +1 -1
- package/src/host.ts +1 -1
- package/src/plan.ts +167 -7
- package/src/runtime.ts +21 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## 2.3.2 — 2026-11-10
|
|
2
|
+
|
|
3
|
+
- **D1 用户附件全链路可见**(修复「规划器/子 Agent 看不见用户图片」盲区,commit 8b48796):`messageText` 把 image/file/document 块渲染为含 attachment-id 的标注行,任务文本→锚点→派发提示→回放上下文同源覆盖;接收方以 attachment-id 直读附件,不再请示往返。全量回归 718/0/0。
|
|
4
|
+
- **D2 规划器 JSON 语法三层兜底**(修复「INVALID_JSON×3、86.9 秒白烧降级」,commit b49a395):P0 `repairJsonStructure` 扩能——字符串外补缺失逗号、全角标点归一、栈空多余闭合括号丢弃,六类高频损伤本地修复不再重掷;P1 `parseFailureHint`——不可修复时抛错携带「错误位置 + 断点±60 原文 + 只修该处语法」定向回喂重试(不再全量盲掷);P2 规划器 prompt 半角/逗号/括号自检硬约束。回归 724/0/0,T3 两轮独立复核通过。
|
|
5
|
+
- **QA-1 值篡改红线修复**:既有 `stripTrailingCommas` 正则不感知字符串边界、会吃掉值内 `", }"`——改为字符串边界感知实现并加回归锁(探针 TAMPER-3 转绿)。
|
|
6
|
+
- 注:2.3.1 未单独发布(其改动即上述 D1,随本版一并上线)。
|
|
7
|
+
|
|
1
8
|
## 2.3.0 — 2026-11-10
|
|
2
9
|
|
|
3
10
|
- 专家执行时间机制优化(用户 2026-11-10 要求,四点):
|
package/README.en.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **Two selling points, one line: a full ISO/IEC 15408:2026 evidence pack you can verify with 5 commands, and a one-command install with zero runtime dependencies.**
|
|
4
4
|
|
|
5
5
|
[](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml)
|
|
6
|
-
[](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.3.2)
|
|
7
7
|
|
|
8
8
|
Adds "plan first → dispatch real department subagents → watch progress in the sidebar" to **DeepSeek Harness (DSH)**. No app, no DSH source patch, no page replacement.
|
|
9
9
|
|
|
@@ -80,7 +80,7 @@ The full contract — roles, data shapes, state machine, recovery, and the three
|
|
|
80
80
|
## Install
|
|
81
81
|
|
|
82
82
|
```bash
|
|
83
|
-
dsh plugin --profile web add dsh-workplan@2.3.
|
|
83
|
+
dsh plugin --profile web add dsh-workplan@2.3.2
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
Restart the DSH Web process (or reload the page) so the bundle is picked up.
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **两个卖点,一句话:ISO/IEC 15408:2026 全套安全证据,5 条命令自己验;安装一条命令、零第三方运行时依赖。**
|
|
4
4
|
|
|
5
5
|
[](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml)
|
|
6
|
-
[](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.3.2)
|
|
7
7
|
|
|
8
8
|
给 **DeepSeek Harness(DSH)** 加一段「先拆计划 → 真派部门子 Agent 去做 → 左侧栏实时看进度」的能力。不装 App、不改 DSH 源码、不换页面。
|
|
9
9
|
|
|
@@ -69,7 +69,7 @@ grep -RInE "child_process|execSync|eval\(|writeFileSync" src || echo "0 命中
|
|
|
69
69
|
## 一键安装
|
|
70
70
|
|
|
71
71
|
```bash
|
|
72
|
-
dsh plugin --profile web add dsh-workplan@2.3.
|
|
72
|
+
dsh plugin --profile web add dsh-workplan@2.3.2
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
装完**重启一次 DSH Web**(或重新载入当前页面)让插件生效。
|
package/README.zh.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **两个卖点,一句话:ISO/IEC 15408:2026 全套安全证据,5 条命令自己验;安装一条命令、零第三方运行时依赖。**
|
|
4
4
|
|
|
5
5
|
[](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml)
|
|
6
|
-
[](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.3.2)
|
|
7
7
|
|
|
8
8
|
给 **DeepSeek Harness(DSH)** 加一段「先拆计划 → 真派部门子 Agent 去做 → 左侧栏实时看进度」的能力。不装 App、不改 DSH 源码、不换页面。
|
|
9
9
|
|
|
@@ -69,7 +69,7 @@ grep -RInE "child_process|execSync|eval\(|writeFileSync" src || echo "0 命中
|
|
|
69
69
|
## 一键安装
|
|
70
70
|
|
|
71
71
|
```bash
|
|
72
|
-
dsh plugin --profile web add dsh-workplan@2.3.
|
|
72
|
+
dsh plugin --profile web add dsh-workplan@2.3.2
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
装完**重启一次 DSH Web**(或重新载入当前页面)让插件生效。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# 发布记录 — dsh-workplan 2.3.0(2026-11-10)
|
|
2
|
+
|
|
3
|
+
## 本次内容:专家执行时间机制优化(用户 2026-11-10 四项要求)
|
|
4
|
+
- 要求1 前半段:专家开工预告(timeNotice)落档后,插件即时向主会话推送【专家预估上报】,明确「请把此预期执行时间告知用户」(src/runtime.ts recordTimeNotice→appendUserMessage);主 Agent 义务写入 7a 条款(src/host.ts)。
|
|
5
|
+
- 要求1 后半段:超时后主 Agent 用 extendMs 放宽成功,插件自动向执行中专家投递【延期告知】= 最新执行时间 + 约剩余量 + 「必须在保证工作质量的前提下高效率执行」(notifyExpertOfExtension,回执 childNotified,投递留档 timeJournal)。
|
|
6
|
+
- 要求2:同一子任务第 2 次超时(TAKEOVER_AFTER_TIMEOUTS=2)置 takeoverRequired,生成接手包 takeoverBrief(landedRefs/completedArtifacts 只读保护、remainingOutputs 仅含未完成部分);mergePreservedArtifacts 只增不减,代码硬编码「禁止丢弃、禁止删除或覆盖、禁止整步重跑」;plan.ts resetBlockedStatuses 对该行跳过重派。
|
|
7
|
+
- 向后兼容:全部走 StatusEntry 未知字段直写通道 + 回放白名单透传(timeoutCount/takeoverRequired/takeoverBrief),不改既有判定语义。
|
|
8
|
+
|
|
9
|
+
## 验证证据
|
|
10
|
+
- 静态检查:npm run check(tsc --noEmit)exit 0;npm run build exit 0。
|
|
11
|
+
- 产物可复现:重建后 16 个 lib/*.js + client.js sha256 逐一 OK(H1 新鲜度门禁通过)。
|
|
12
|
+
- 全量回归:node scripts/run-tests.mjs pass=716 fail=0 cancelled=0 exit=0(reports/t3-full-suite-summary-2.3.0.txt)。
|
|
13
|
+
- 场景验证:tests/qa-time-mechanism-scenarios-t3.test.ts 场景A/B/C/D 5/5 pass;场景C断言产物 sha256 接手前后一致、保护清单只增不减。
|
|
14
|
+
- 版本一致性:version-sync 测试 2/2 pass;6 个声明位(package.json/lock×2/src/host.ts/lib/host.js/tool-surface fixture)= 2.3.0;三语 README 徽章与安装行同步 2.3.0。
|
|
15
|
+
|
|
16
|
+
## 发布链路(RELEASING.md §0–§7)
|
|
17
|
+
- commit 8e5b91c「Release 2.3.0」→ 已推送 origin/main;tag v2.3.0(aa8b1ef,指向 8e5b91c)。
|
|
18
|
+
- GitHub Release:https://github.com/abbaababa/dsh-workplan/releases/tag/v2.3.0,制品 dsh-workplan-2.3.0.tgz sha256=0347f615b7b5bb863493afa9ff515a275941d87b85db6468bc5c2992287c4f36(按 tag 干净检出 npm ci+build+pack 产出),制品下载 HTTP 200。
|
|
19
|
+
- npm 索引源:npm publish 成功(+ dsh-workplan@2.3.0);npm view dsh-workplan@2.3.0 version=2.3.0,tarball=https://registry.npmjs.org/dsh-workplan/-/dsh-workplan-2.3.0.tgz。
|
|
20
|
+
- 上游条目源(awesome-dsh-plugin):PR #13893 已更新至 v2.3.0(fork 分支 bump229 commit b8d1cc5,tarball 指本次 Release),标题/描述同步;上游仓库合并权限不在本账号(MergePullRequest 被拒,属 RELEASING.md §5 明示边界——合并后上游 CI 自动发 dsh-plugin-catalog)。
|
|
21
|
+
|
|
22
|
+
## 运行态生效
|
|
23
|
+
本机运行中的 DSH 仍加载旧字节;需用户手动重启后,v2.3.0 机制才在运行态生效(重启后用 dsh_workplan_status 核对版本指纹)。
|
package/lib/host.js
CHANGED
|
@@ -1452,7 +1452,7 @@ export function apply(ctx, config = {}) {
|
|
|
1452
1452
|
}
|
|
1453
1453
|
export const meta = {
|
|
1454
1454
|
name,
|
|
1455
|
-
version: '2.3.
|
|
1455
|
+
version: '2.3.2',
|
|
1456
1456
|
promptOrder: PROMPT_ORDER,
|
|
1457
1457
|
routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
|
|
1458
1458
|
};
|
package/lib/plan.js
CHANGED
|
@@ -215,10 +215,46 @@ export function truncate(value, max) {
|
|
|
215
215
|
export function messageText(message) {
|
|
216
216
|
if (!message || !Array.isArray(message.content))
|
|
217
217
|
return '';
|
|
218
|
-
|
|
218
|
+
const texts = message.content
|
|
219
219
|
.filter((block) => block && block.type === 'text' && typeof block.text === 'string')
|
|
220
|
-
.map((block) => block.text)
|
|
221
|
-
|
|
220
|
+
.map((block) => block.text);
|
|
221
|
+
/*
|
|
222
|
+
* [2.3.1][D1] 附件事实渲染(用户 2026-11-10 点名的严重缺陷:规划器与 fresh
|
|
223
|
+
* 子 Agent 看不见用户图片)。
|
|
224
|
+
*
|
|
225
|
+
* 旧实现只收 text 块:image/file 块的 attachment 元数据(attachmentId/名称/
|
|
226
|
+
* 尺寸)在到达规划器 taskText 之前就被整块丢弃,专家被迫 escalate 请示
|
|
227
|
+
* 「截图在哪」,往返吃掉整段时间预算(wp-73bb2cd4 事故实证:修复主链 8 分钟、
|
|
228
|
+
* 往返 17 分钟)。
|
|
229
|
+
*
|
|
230
|
+
* 现在把附件渲染成一行标注并入文本面,taskText→taskAnchor→派发锚点块→回放
|
|
231
|
+
* 上下文全部同源受益;标注含 attachment-id(官方读图工具接受该 id 作为
|
|
232
|
+
* path),接收方可直接读取,不再靠猜。
|
|
233
|
+
* 消费方安全审计(2026-11-10):plan/result/cancel/update 四类 marker 解析
|
|
234
|
+
* 消息永不含图片块;replan/supersede 为用户消息子串匹配,附加行零误伤。
|
|
235
|
+
*/
|
|
236
|
+
const notes = message.content
|
|
237
|
+
.filter((block) => block && (block.type === 'image' || block.type === 'file' || block.type === 'document') && (block.attachment ?? block.file))
|
|
238
|
+
.map((block) => renderAttachmentNote(block))
|
|
239
|
+
.filter((line) => line !== '');
|
|
240
|
+
if (notes.length === 0)
|
|
241
|
+
return texts.join('\n');
|
|
242
|
+
return [...texts, ...notes].join('\n');
|
|
243
|
+
}
|
|
244
|
+
/** [2.3.1][D1] 单个附件块的只读标注行;元数据缺失时返回空串(不泄漏、不猜测)。 */
|
|
245
|
+
function renderAttachmentNote(block) {
|
|
246
|
+
const att = block.attachment ?? block.file ?? {};
|
|
247
|
+
const id = typeof att.attachmentId === 'string' ? att.attachmentId : '';
|
|
248
|
+
const name = typeof att.name === 'string' ? att.name : (typeof att.filename === 'string' ? att.filename : '');
|
|
249
|
+
if (!id && !name)
|
|
250
|
+
return '';
|
|
251
|
+
const media = typeof att.mediaType === 'string' ? att.mediaType : '';
|
|
252
|
+
const size = Number.isFinite(Number(att.width)) && Number.isFinite(Number(att.height))
|
|
253
|
+
? `|${String(att.width)}x${String(att.height)}` : '';
|
|
254
|
+
return `[用户附件] ${block.type === 'image' ? '图片' : '文件'} "${name || '未命名'}"`
|
|
255
|
+
+ (media ? `|mediaType=${media}` : '') + size
|
|
256
|
+
+ (id ? `|attachment-id: ${id}` : '')
|
|
257
|
+
+ '|如需其内容:把 attachment-id 作为 path 传给可用的读图/视觉工具直接读取,禁止凭空猜测附件内容。';
|
|
222
258
|
}
|
|
223
259
|
/*
|
|
224
260
|
* [1.8.12] 不能让正文里的「包名:行号」变成跨会话引用。
|
|
@@ -967,12 +1003,37 @@ export function flattenSubtasks(plan) {
|
|
|
967
1003
|
* 规划器返回的 JSON 常见三类损伤:少一个 `}`、多一个尾逗号、字符串里有裸换行。
|
|
968
1004
|
* 旧实现直接 JSON.parse,一个字符之差就抛 INVALID_JSON,整个计划降级。
|
|
969
1005
|
* 这里做的是纯结构修复:配对括号、去掉尾逗号、把字符串里的裸控制符转义。
|
|
1006
|
+
*
|
|
1007
|
+
* [2.3.2][D2-P0] D2 现场(qwen3.8-flash INVALID_JSON ×3、86.9 秒白烧)实测穿透的
|
|
1008
|
+
* 三类损伤——成员间漏逗号、字符串外全角标点、多余闭合括号——在同一趟扫描内补齐。
|
|
1009
|
+
* 旧实现只「补」不「插/删/归一」,这三类必然失败后靠全量重掷碰运气。三条新规则
|
|
1010
|
+
* 全部满足「只修结构、绝不碰内容」红线:
|
|
1011
|
+
* 1. 插逗号:容器内(栈非空)值结束符(`"`/`}`/`]`/数字/true|false|null)之后
|
|
1012
|
+
* 紧邻下一个起点 token 且无分隔符 → 插入 `,`;深度 0 不插(不吞多对象文档);
|
|
1013
|
+
* 2. 归一半角:仅字符串外 `,`→`,`、`:`→`:`、`“`/`”`→`"`;字符串内一字不动;
|
|
1014
|
+
* 3. 删多余闭合:栈已空时出现的 `}`/`]` 直接丢弃(旧实现原样保留 → 必解析失败)。
|
|
970
1015
|
* 绝不猜测、绝不编造任何字段或值——修不好就照旧抛错。
|
|
971
1016
|
*/
|
|
972
1017
|
export function repairJsonStructure(input) {
|
|
973
1018
|
const stack = [];
|
|
974
1019
|
let inString = false;
|
|
975
1020
|
let escaped = false;
|
|
1021
|
+
// [2.3.2] afterValue = 上一个字符串外记号是「完整值收尾」(闭合引号/闭合括号/裸 token 结束)。
|
|
1022
|
+
let afterValue = false;
|
|
1023
|
+
// [2.3.2] inToken = 正在读数字或 true/false/null 这类裸 token(须等它结束才可能插逗号)。
|
|
1024
|
+
let inToken = false;
|
|
1025
|
+
// [2.3.2] 字符串定界样式:全角引号开的字符串须由 `”`(或半角 `"`)闭合,
|
|
1026
|
+
// 否则 `{“a”:1}` 的 `”` 会被当作字符串内容吞掉;半角字符串不受影响。
|
|
1027
|
+
let stringUnicode = false;
|
|
1028
|
+
const isTokenChar = (ch) => (ch >= '0' && ch <= '9')
|
|
1029
|
+
|| (ch >= 'a' && ch <= 'z')
|
|
1030
|
+
|| (ch >= 'A' && ch <= 'Z')
|
|
1031
|
+
|| ch === '.' || ch === '+' || ch === '-';
|
|
1032
|
+
const separatorBefore = () => {
|
|
1033
|
+
// 只在「值收尾 → 新值起点」且确有容器时才插逗号;键后接冒号、值后接闭合都不走这里。
|
|
1034
|
+
if (afterValue && stack.length > 0)
|
|
1035
|
+
out += ',';
|
|
1036
|
+
};
|
|
976
1037
|
let out = '';
|
|
977
1038
|
for (let i = 0; i < input.length; i += 1) {
|
|
978
1039
|
const ch = input[i];
|
|
@@ -987,9 +1048,10 @@ export function repairJsonStructure(input) {
|
|
|
987
1048
|
escaped = true;
|
|
988
1049
|
continue;
|
|
989
1050
|
}
|
|
990
|
-
if (ch === '"') {
|
|
1051
|
+
if (ch === '"' || (stringUnicode && ch === '”')) {
|
|
991
1052
|
inString = false;
|
|
992
|
-
|
|
1053
|
+
afterValue = true;
|
|
1054
|
+
out += '"';
|
|
993
1055
|
continue;
|
|
994
1056
|
}
|
|
995
1057
|
if (ch === '\n') {
|
|
@@ -1011,17 +1073,40 @@ export function repairJsonStructure(input) {
|
|
|
1011
1073
|
out += ch;
|
|
1012
1074
|
continue;
|
|
1013
1075
|
}
|
|
1076
|
+
if (inToken && !isTokenChar(ch)) {
|
|
1077
|
+
inToken = false;
|
|
1078
|
+
afterValue = true;
|
|
1079
|
+
}
|
|
1014
1080
|
if (ch === '"') {
|
|
1081
|
+
separatorBefore();
|
|
1015
1082
|
inString = true;
|
|
1083
|
+
stringUnicode = false;
|
|
1084
|
+
afterValue = false;
|
|
1016
1085
|
out += ch;
|
|
1017
1086
|
continue;
|
|
1018
1087
|
}
|
|
1088
|
+
// [2.3.2] 全角引号 → 半角双引号开字符串(仅字符串外;归一只动标点不动内容)。
|
|
1089
|
+
if (ch === '“' || ch === '”' || ch === '"') {
|
|
1090
|
+
separatorBefore();
|
|
1091
|
+
inString = true;
|
|
1092
|
+
stringUnicode = true;
|
|
1093
|
+
afterValue = false;
|
|
1094
|
+
out += '"';
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1019
1097
|
if (ch === '{' || ch === '[') {
|
|
1098
|
+
separatorBefore();
|
|
1020
1099
|
stack.push(ch);
|
|
1100
|
+
afterValue = false;
|
|
1021
1101
|
out += ch;
|
|
1022
1102
|
continue;
|
|
1023
1103
|
}
|
|
1024
1104
|
if (ch === '}' || ch === ']') {
|
|
1105
|
+
// [2.3.2] 规则 3:栈空 = 这个闭合符在语法上无处安放,丢弃(旧实现保留 → E 类穿透)。
|
|
1106
|
+
if (stack.length === 0) {
|
|
1107
|
+
afterValue = true;
|
|
1108
|
+
continue;
|
|
1109
|
+
}
|
|
1025
1110
|
const want = ch === '}' ? '{' : '[';
|
|
1026
1111
|
while (stack.length > 0 && stack[stack.length - 1] !== want) {
|
|
1027
1112
|
out += stack.pop() === '{' ? '}' : ']';
|
|
@@ -1029,6 +1114,26 @@ export function repairJsonStructure(input) {
|
|
|
1029
1114
|
if (stack.length > 0)
|
|
1030
1115
|
stack.pop();
|
|
1031
1116
|
out += ch;
|
|
1117
|
+
afterValue = true;
|
|
1118
|
+
continue;
|
|
1119
|
+
}
|
|
1120
|
+
if (ch === ',' || ch === ',') {
|
|
1121
|
+
// [2.3.2] 规则 2:字符串外全角逗号归一为半角。
|
|
1122
|
+
out += ',';
|
|
1123
|
+
afterValue = false;
|
|
1124
|
+
continue;
|
|
1125
|
+
}
|
|
1126
|
+
if (ch === ':' || ch === ':') {
|
|
1127
|
+
// [2.3.2] 规则 2:字符串外全角冒号归一为半角;键后的冒号不是「新值起点」,不插逗号。
|
|
1128
|
+
out += ':';
|
|
1129
|
+
afterValue = false;
|
|
1130
|
+
continue;
|
|
1131
|
+
}
|
|
1132
|
+
if (isTokenChar(ch)) {
|
|
1133
|
+
separatorBefore();
|
|
1134
|
+
inToken = true;
|
|
1135
|
+
afterValue = false;
|
|
1136
|
+
out += ch;
|
|
1032
1137
|
continue;
|
|
1033
1138
|
}
|
|
1034
1139
|
out += ch;
|
|
@@ -1040,7 +1145,46 @@ export function repairJsonStructure(input) {
|
|
|
1040
1145
|
return stripTrailingCommas(out);
|
|
1041
1146
|
}
|
|
1042
1147
|
function stripTrailingCommas(input) {
|
|
1043
|
-
|
|
1148
|
+
/*
|
|
1149
|
+
* [2.3.2][D2-QA-1 修复] 字符串边界感知的尾逗号删除(T3 审查红线发现)。
|
|
1150
|
+
*
|
|
1151
|
+
* 旧实现正则 /,(\s*[}\]])/g 不感知字符串边界,会吃掉字符串值内部的
|
|
1152
|
+
* 「半角逗号+空白+闭括号」——`{"note":"p, } q"}` 被改成 `"p } q"`,是值
|
|
1153
|
+
* 篡改(缺陷自 2.1.0 既有,本补丁 P0 扩能后其可达面被扩大;T3 探针
|
|
1154
|
+
* TAMPER-3 实锤并定性为既有)。现在只有字符串外的逗号才会被删,
|
|
1155
|
+
* 与旧语义一致(只删逗号、保留其间空白与闭括号)。
|
|
1156
|
+
*/
|
|
1157
|
+
let inString = false;
|
|
1158
|
+
let escaped = false;
|
|
1159
|
+
let out = '';
|
|
1160
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
1161
|
+
const ch = input[i];
|
|
1162
|
+
if (inString) {
|
|
1163
|
+
out += ch;
|
|
1164
|
+
if (escaped)
|
|
1165
|
+
escaped = false;
|
|
1166
|
+
else if (ch === '\\')
|
|
1167
|
+
escaped = true;
|
|
1168
|
+
else if (ch === '"')
|
|
1169
|
+
inString = false;
|
|
1170
|
+
continue;
|
|
1171
|
+
}
|
|
1172
|
+
if (ch === '"') {
|
|
1173
|
+
inString = true;
|
|
1174
|
+
out += ch;
|
|
1175
|
+
continue;
|
|
1176
|
+
}
|
|
1177
|
+
if (ch === ',') {
|
|
1178
|
+
let j = i + 1;
|
|
1179
|
+
while (j < input.length && input[j].trim() === '')
|
|
1180
|
+
j += 1;
|
|
1181
|
+
const next = input[j];
|
|
1182
|
+
if (next === '}' || next === ']')
|
|
1183
|
+
continue;
|
|
1184
|
+
}
|
|
1185
|
+
out += ch;
|
|
1186
|
+
}
|
|
1187
|
+
return out;
|
|
1044
1188
|
}
|
|
1045
1189
|
/** 找到最后一个「成员边界」逗号(在任何嵌套深度上、且不在字符串内)。 */
|
|
1046
1190
|
function lastMemberComma(input) {
|
|
@@ -1079,6 +1223,25 @@ function* truncatedCandidates(input, rounds = 24) {
|
|
|
1079
1223
|
yield repairJsonStructure(working);
|
|
1080
1224
|
}
|
|
1081
1225
|
}
|
|
1226
|
+
/**
|
|
1227
|
+
* [2.3.2][D2-P1] 定向位置反馈:旧实现回喂只有「末尾 120 字符」,断点在 6KB 文档
|
|
1228
|
+
* 中部时模型依然盲,只能整段重掷(×3 ≈86.9 秒白烧的机制根因之一)。V8 对长输入的
|
|
1229
|
+
* 解析错误带 `at position N`,这里据此从候选文本切出断点 ±60 字符原文随错误一并
|
|
1230
|
+
* 回喂(runtime 的 lastErrors 直接透传该 message),让下一次请求是「定向修复」而
|
|
1231
|
+
* 非「盲目重生成」。短输入的新式消息本身已带上下文,正则不中则原样返回。
|
|
1232
|
+
*/
|
|
1233
|
+
function parseFailureHint(candidate, error) {
|
|
1234
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1235
|
+
const match = /at position (\d+)/.exec(message);
|
|
1236
|
+
if (!match)
|
|
1237
|
+
return '';
|
|
1238
|
+
const position = Math.min(Number(match[1]), candidate.length);
|
|
1239
|
+
const from = Math.max(0, position - 60);
|
|
1240
|
+
const to = Math.min(candidate.length, position + 60);
|
|
1241
|
+
const snippet = candidate.slice(from, to).replace(/\s+/g, ' ');
|
|
1242
|
+
return `;错误位置 ${position},断点附近原文(字符 ${from}-${to}):${JSON.stringify(snippet)}`
|
|
1243
|
+
+ '——请只修复该处 JSON 语法后重新输出完整对象,不得改动任何字段值';
|
|
1244
|
+
}
|
|
1082
1245
|
export function extractJson(text) {
|
|
1083
1246
|
if (typeof text !== 'string' || text.trim() === '') {
|
|
1084
1247
|
throw new PlanError('规划器没有返回内容', 'EMPTY_OUTPUT');
|
|
@@ -1101,7 +1264,7 @@ export function extractJson(text) {
|
|
|
1101
1264
|
const repaired = repairJsonStructure(candidate);
|
|
1102
1265
|
try {
|
|
1103
1266
|
const value2 = JSON.parse(repaired);
|
|
1104
|
-
console.warn('[dsh-workplan] 规划器 JSON
|
|
1267
|
+
console.warn('[dsh-workplan] 规划器 JSON 结构已修复(只动括号/逗号/字符串外全角标点,未改内容)');
|
|
1105
1268
|
return value2;
|
|
1106
1269
|
}
|
|
1107
1270
|
catch {
|
|
@@ -1116,7 +1279,8 @@ export function extractJson(text) {
|
|
|
1116
1279
|
}
|
|
1117
1280
|
}
|
|
1118
1281
|
}
|
|
1119
|
-
|
|
1282
|
+
// [2.3.2][D2-P1] 抛出前附断点原文切片:重试请求据此定向修复,不再盲掷全文。
|
|
1283
|
+
throw new PlanError(`规划器返回的 JSON 无法解析:${error instanceof Error ? error.message : String(error)}${parseFailureHint(candidate, error)}`, 'INVALID_JSON');
|
|
1120
1284
|
}
|
|
1121
1285
|
}
|
|
1122
1286
|
export function departmentLabel(id, language = 'zh') {
|
|
@@ -1193,6 +1357,8 @@ export function buildPlannerPrompt(taskText, cwd, conversationContext = '', budg
|
|
|
1193
1357
|
'- 子任务必须可独立执行、可验收;不要为了凑数拆无意义任务。',
|
|
1194
1358
|
'- 子任务由子 Agent 独立执行:它们没有派发权限、不能重启服务、不能安装或升级依赖。禁止把「调用 dsh_workplan_dispatch」「重启/停止 dsh web」「安装或升级插件」这类只有主 Agent 才能执行的动作写进子任务;确实需要时,写成“给出结论或建议,由主 Agent 执行”。',
|
|
1195
1359
|
'- 单个子任务无须在 10 分钟内完成——10 分钟只是拆步规模建议,不是完成期限、也不构成承诺;实际时长由执行专家开工预告协商决定,不设固定完成时间;动手重的任务要拆成多个小步,避免整条计划被一个慢子任务拖住。',
|
|
1360
|
+
// [2.3.2][D2-P2] 半角/逗号/括号自检硬约束:与解析层兜底(P0)互为防线,中文模型全角标点高发。
|
|
1361
|
+
'- JSON 只允许半角标点(, : " { } [ ]);对象与数组的相邻成员之间必须有逗号;输出前自检括号成对、每个字符串以半角"闭合。',
|
|
1196
1362
|
'- 不要输出 Markdown 代码围栏、解释或前后缀;只输出一个 JSON 对象。',
|
|
1197
1363
|
'',
|
|
1198
1364
|
'本轮时间预算(硬事实,请据此规划规模):',
|
package/lib/runtime.js
CHANGED
|
@@ -948,7 +948,9 @@ export async function runPlanner(ctx, options) {
|
|
|
948
948
|
message,
|
|
949
949
|
`输出共 ${lastText.length} 字符,末尾原文:${JSON.stringify(tail)}`,
|
|
950
950
|
closed
|
|
951
|
-
|
|
951
|
+
// [2.3.2][D2-P1] 定向修复指令:message 已含「错误位置 + 断点附近原文」(extractJson
|
|
952
|
+
// 的 parseFailureHint),这里明确要求只修语法、不动内容,替代旧「整段重掷」。
|
|
953
|
+
? '末尾已闭合 → 断点在正文中间,属语法写错(漏逗号/括号不匹配):请按上文「错误位置/断点附近原文」只修复该处语法,禁止改动字段值与整体结构'
|
|
952
954
|
: '末尾未闭合(没有结尾 })→ 疑似输出被截断,请给出更紧凑的完整 JSON',
|
|
953
955
|
];
|
|
954
956
|
}
|
|
@@ -4114,6 +4116,23 @@ export function reconstructFromSession(session, targetPlanId) {
|
|
|
4114
4116
|
});
|
|
4115
4117
|
continue;
|
|
4116
4118
|
}
|
|
4119
|
+
/*
|
|
4120
|
+
* [2.3.0][hotfix] 回放兼容「已回报行 + 旧版 closure:'done' 错误快照」(用户 2026-11-10 截图:
|
|
4121
|
+
* wp-3080d01d T6/T7「非法闭环迁移:reported → done」回放忽略)。
|
|
4122
|
+
*
|
|
4123
|
+
* 2.0.4 之前 live 侧 applyStatus 把 reported 行的 closure 误写回 'done',durable 改判
|
|
4124
|
+
* 消息因此嵌着这个错误快照。2.2.6 D-1 给回放补了 closure 透传,但没有豁免这一组合:
|
|
4125
|
+
* 回放大方把 'done' 当显式闭环意图传给迁移表 → reported → done 被拒 → 整条改判
|
|
4126
|
+
* (含 verification/acceptance 证据)被裸 catch 吞掉,重启后行退回缺证据态。
|
|
4127
|
+
*
|
|
4128
|
+
* 口径与 2.0.4 live 侧镜像:事件 closure='done' 且当前行 closure='reported' 时,这是
|
|
4129
|
+
* 「复核补齐」而非「退回未回报」,丢弃该显式值,让 done 分支按 2.0.4 保留已回报事实。
|
|
4130
|
+
* 其余透传分支(escalated/instructed 等,D-1 语义)零改动。
|
|
4131
|
+
*/
|
|
4132
|
+
const preReplayRow = snap.statuses.find((item) => item?.subtaskId === update.subtaskId);
|
|
4133
|
+
const replayClosure = typeof update.closure === 'string'
|
|
4134
|
+
? (update.closure === 'done' && preReplayRow?.closure === 'reported' ? undefined : update.closure)
|
|
4135
|
+
: undefined;
|
|
4117
4136
|
snap.statuses = applyStatus(snap.statuses, update.subtaskId, {
|
|
4118
4137
|
/*
|
|
4119
4138
|
* handoff 的 durable 记录携带的是状态快照,不是一次状态迁移。
|
|
@@ -4132,7 +4151,7 @@ export function reconstructFromSession(session, targetPlanId) {
|
|
|
4132
4151
|
* 重启后「待指示」行永久卡死(2026-11-08 wp-3c8c84b2 T2 实证,
|
|
4133
4152
|
* 见 artifacts/2.2.5-post-restart-regression.md §4 D-1)。
|
|
4134
4153
|
*/
|
|
4135
|
-
closure:
|
|
4154
|
+
closure: replayClosure,
|
|
4136
4155
|
progress: typeof update.progress === 'number' ? update.progress : undefined,
|
|
4137
4156
|
summary: typeof update.note === 'string' ? update.note : undefined,
|
|
4138
4157
|
// [1.8.13] Evidence written through the update tool must survive replay.
|
package/package.json
CHANGED
package/src/host.ts
CHANGED
|
@@ -1581,7 +1581,7 @@ export function apply(ctx: any, config: WorkplanConfig = {}) {
|
|
|
1581
1581
|
|
|
1582
1582
|
export const meta = {
|
|
1583
1583
|
name,
|
|
1584
|
-
version: '2.3.
|
|
1584
|
+
version: '2.3.2',
|
|
1585
1585
|
promptOrder: PROMPT_ORDER,
|
|
1586
1586
|
routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
|
|
1587
1587
|
}
|
package/src/plan.ts
CHANGED
|
@@ -251,10 +251,45 @@ export function truncate(value: any, max: any) {
|
|
|
251
251
|
|
|
252
252
|
export function messageText(message: any) {
|
|
253
253
|
if (!message || !Array.isArray(message.content)) return ''
|
|
254
|
-
|
|
254
|
+
const texts = message.content
|
|
255
255
|
.filter((block: any) => block && block.type === 'text' && typeof block.text === 'string')
|
|
256
256
|
.map((block: any) => block.text)
|
|
257
|
-
|
|
257
|
+
/*
|
|
258
|
+
* [2.3.1][D1] 附件事实渲染(用户 2026-11-10 点名的严重缺陷:规划器与 fresh
|
|
259
|
+
* 子 Agent 看不见用户图片)。
|
|
260
|
+
*
|
|
261
|
+
* 旧实现只收 text 块:image/file 块的 attachment 元数据(attachmentId/名称/
|
|
262
|
+
* 尺寸)在到达规划器 taskText 之前就被整块丢弃,专家被迫 escalate 请示
|
|
263
|
+
* 「截图在哪」,往返吃掉整段时间预算(wp-73bb2cd4 事故实证:修复主链 8 分钟、
|
|
264
|
+
* 往返 17 分钟)。
|
|
265
|
+
*
|
|
266
|
+
* 现在把附件渲染成一行标注并入文本面,taskText→taskAnchor→派发锚点块→回放
|
|
267
|
+
* 上下文全部同源受益;标注含 attachment-id(官方读图工具接受该 id 作为
|
|
268
|
+
* path),接收方可直接读取,不再靠猜。
|
|
269
|
+
* 消费方安全审计(2026-11-10):plan/result/cancel/update 四类 marker 解析
|
|
270
|
+
* 消息永不含图片块;replan/supersede 为用户消息子串匹配,附加行零误伤。
|
|
271
|
+
*/
|
|
272
|
+
const notes = message.content
|
|
273
|
+
.filter((block: any) => block && (block.type === 'image' || block.type === 'file' || block.type === 'document') && (block.attachment ?? block.file))
|
|
274
|
+
.map((block: any) => renderAttachmentNote(block))
|
|
275
|
+
.filter((line: string) => line !== '')
|
|
276
|
+
if (notes.length === 0) return texts.join('\n')
|
|
277
|
+
return [...texts, ...notes].join('\n')
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** [2.3.1][D1] 单个附件块的只读标注行;元数据缺失时返回空串(不泄漏、不猜测)。 */
|
|
281
|
+
function renderAttachmentNote(block: any) {
|
|
282
|
+
const att = block.attachment ?? block.file ?? {}
|
|
283
|
+
const id = typeof att.attachmentId === 'string' ? att.attachmentId : ''
|
|
284
|
+
const name = typeof att.name === 'string' ? att.name : (typeof att.filename === 'string' ? att.filename : '')
|
|
285
|
+
if (!id && !name) return ''
|
|
286
|
+
const media = typeof att.mediaType === 'string' ? att.mediaType : ''
|
|
287
|
+
const size = Number.isFinite(Number(att.width)) && Number.isFinite(Number(att.height))
|
|
288
|
+
? `|${String(att.width)}x${String(att.height)}` : ''
|
|
289
|
+
return `[用户附件] ${block.type === 'image' ? '图片' : '文件'} "${name || '未命名'}"`
|
|
290
|
+
+ (media ? `|mediaType=${media}` : '') + size
|
|
291
|
+
+ (id ? `|attachment-id: ${id}` : '')
|
|
292
|
+
+ '|如需其内容:把 attachment-id 作为 path 传给可用的读图/视觉工具直接读取,禁止凭空猜测附件内容。'
|
|
258
293
|
}
|
|
259
294
|
|
|
260
295
|
/*
|
|
@@ -1040,12 +1075,37 @@ export function flattenSubtasks(plan: any): Array<{ stage: any; subtask: any }>
|
|
|
1040
1075
|
* 规划器返回的 JSON 常见三类损伤:少一个 `}`、多一个尾逗号、字符串里有裸换行。
|
|
1041
1076
|
* 旧实现直接 JSON.parse,一个字符之差就抛 INVALID_JSON,整个计划降级。
|
|
1042
1077
|
* 这里做的是纯结构修复:配对括号、去掉尾逗号、把字符串里的裸控制符转义。
|
|
1078
|
+
*
|
|
1079
|
+
* [2.3.2][D2-P0] D2 现场(qwen3.8-flash INVALID_JSON ×3、86.9 秒白烧)实测穿透的
|
|
1080
|
+
* 三类损伤——成员间漏逗号、字符串外全角标点、多余闭合括号——在同一趟扫描内补齐。
|
|
1081
|
+
* 旧实现只「补」不「插/删/归一」,这三类必然失败后靠全量重掷碰运气。三条新规则
|
|
1082
|
+
* 全部满足「只修结构、绝不碰内容」红线:
|
|
1083
|
+
* 1. 插逗号:容器内(栈非空)值结束符(`"`/`}`/`]`/数字/true|false|null)之后
|
|
1084
|
+
* 紧邻下一个起点 token 且无分隔符 → 插入 `,`;深度 0 不插(不吞多对象文档);
|
|
1085
|
+
* 2. 归一半角:仅字符串外 `,`→`,`、`:`→`:`、`“`/`”`→`"`;字符串内一字不动;
|
|
1086
|
+
* 3. 删多余闭合:栈已空时出现的 `}`/`]` 直接丢弃(旧实现原样保留 → 必解析失败)。
|
|
1043
1087
|
* 绝不猜测、绝不编造任何字段或值——修不好就照旧抛错。
|
|
1044
1088
|
*/
|
|
1045
1089
|
export function repairJsonStructure(input: string): string {
|
|
1046
1090
|
const stack: string[] = []
|
|
1047
1091
|
let inString = false
|
|
1048
1092
|
let escaped = false
|
|
1093
|
+
// [2.3.2] afterValue = 上一个字符串外记号是「完整值收尾」(闭合引号/闭合括号/裸 token 结束)。
|
|
1094
|
+
let afterValue = false
|
|
1095
|
+
// [2.3.2] inToken = 正在读数字或 true/false/null 这类裸 token(须等它结束才可能插逗号)。
|
|
1096
|
+
let inToken = false
|
|
1097
|
+
// [2.3.2] 字符串定界样式:全角引号开的字符串须由 `”`(或半角 `"`)闭合,
|
|
1098
|
+
// 否则 `{“a”:1}` 的 `”` 会被当作字符串内容吞掉;半角字符串不受影响。
|
|
1099
|
+
let stringUnicode = false
|
|
1100
|
+
const isTokenChar = (ch: string) =>
|
|
1101
|
+
(ch >= '0' && ch <= '9')
|
|
1102
|
+
|| (ch >= 'a' && ch <= 'z')
|
|
1103
|
+
|| (ch >= 'A' && ch <= 'Z')
|
|
1104
|
+
|| ch === '.' || ch === '+' || ch === '-'
|
|
1105
|
+
const separatorBefore = () => {
|
|
1106
|
+
// 只在「值收尾 → 新值起点」且确有容器时才插逗号;键后接冒号、值后接闭合都不走这里。
|
|
1107
|
+
if (afterValue && stack.length > 0) out += ','
|
|
1108
|
+
}
|
|
1049
1109
|
let out = ''
|
|
1050
1110
|
for (let i = 0; i < input.length; i += 1) {
|
|
1051
1111
|
const ch = input[i] as string
|
|
@@ -1060,9 +1120,10 @@ export function repairJsonStructure(input: string): string {
|
|
|
1060
1120
|
escaped = true
|
|
1061
1121
|
continue
|
|
1062
1122
|
}
|
|
1063
|
-
if (ch === '"') {
|
|
1123
|
+
if (ch === '"' || (stringUnicode && ch === '”')) {
|
|
1064
1124
|
inString = false
|
|
1065
|
-
|
|
1125
|
+
afterValue = true
|
|
1126
|
+
out += '"'
|
|
1066
1127
|
continue
|
|
1067
1128
|
}
|
|
1068
1129
|
if (ch === '\n') {
|
|
@@ -1084,23 +1145,66 @@ export function repairJsonStructure(input: string): string {
|
|
|
1084
1145
|
out += ch
|
|
1085
1146
|
continue
|
|
1086
1147
|
}
|
|
1148
|
+
if (inToken && !isTokenChar(ch)) {
|
|
1149
|
+
inToken = false
|
|
1150
|
+
afterValue = true
|
|
1151
|
+
}
|
|
1087
1152
|
if (ch === '"') {
|
|
1153
|
+
separatorBefore()
|
|
1088
1154
|
inString = true
|
|
1155
|
+
stringUnicode = false
|
|
1156
|
+
afterValue = false
|
|
1089
1157
|
out += ch
|
|
1090
1158
|
continue
|
|
1091
1159
|
}
|
|
1160
|
+
// [2.3.2] 全角引号 → 半角双引号开字符串(仅字符串外;归一只动标点不动内容)。
|
|
1161
|
+
if (ch === '“' || ch === '”' || ch === '"') {
|
|
1162
|
+
separatorBefore()
|
|
1163
|
+
inString = true
|
|
1164
|
+
stringUnicode = true
|
|
1165
|
+
afterValue = false
|
|
1166
|
+
out += '"'
|
|
1167
|
+
continue
|
|
1168
|
+
}
|
|
1092
1169
|
if (ch === '{' || ch === '[') {
|
|
1170
|
+
separatorBefore()
|
|
1093
1171
|
stack.push(ch)
|
|
1172
|
+
afterValue = false
|
|
1094
1173
|
out += ch
|
|
1095
1174
|
continue
|
|
1096
1175
|
}
|
|
1097
1176
|
if (ch === '}' || ch === ']') {
|
|
1177
|
+
// [2.3.2] 规则 3:栈空 = 这个闭合符在语法上无处安放,丢弃(旧实现保留 → E 类穿透)。
|
|
1178
|
+
if (stack.length === 0) {
|
|
1179
|
+
afterValue = true
|
|
1180
|
+
continue
|
|
1181
|
+
}
|
|
1098
1182
|
const want = ch === '}' ? '{' : '['
|
|
1099
1183
|
while (stack.length > 0 && stack[stack.length - 1] !== want) {
|
|
1100
1184
|
out += stack.pop() === '{' ? '}' : ']'
|
|
1101
1185
|
}
|
|
1102
1186
|
if (stack.length > 0) stack.pop()
|
|
1103
1187
|
out += ch
|
|
1188
|
+
afterValue = true
|
|
1189
|
+
continue
|
|
1190
|
+
}
|
|
1191
|
+
if (ch === ',' || ch === ',') {
|
|
1192
|
+
// [2.3.2] 规则 2:字符串外全角逗号归一为半角。
|
|
1193
|
+
out += ','
|
|
1194
|
+
afterValue = false
|
|
1195
|
+
continue
|
|
1196
|
+
}
|
|
1197
|
+
if (ch === ':' || ch === ':') {
|
|
1198
|
+
// [2.3.2] 规则 2:字符串外全角冒号归一为半角;键后的冒号不是「新值起点」,不插逗号。
|
|
1199
|
+
out += ':'
|
|
1200
|
+
afterValue = false
|
|
1201
|
+
continue
|
|
1202
|
+
}
|
|
1203
|
+
if (isTokenChar(ch)) {
|
|
1204
|
+
separatorBefore()
|
|
1205
|
+
inToken = true
|
|
1206
|
+
afterValue = false
|
|
1207
|
+
out += ch
|
|
1104
1208
|
continue
|
|
1105
1209
|
}
|
|
1106
1210
|
out += ch
|
|
@@ -1111,7 +1215,41 @@ export function repairJsonStructure(input: string): string {
|
|
|
1111
1215
|
}
|
|
1112
1216
|
|
|
1113
1217
|
function stripTrailingCommas(input: string): string {
|
|
1114
|
-
|
|
1218
|
+
/*
|
|
1219
|
+
* [2.3.2][D2-QA-1 修复] 字符串边界感知的尾逗号删除(T3 审查红线发现)。
|
|
1220
|
+
*
|
|
1221
|
+
* 旧实现正则 /,(\s*[}\]])/g 不感知字符串边界,会吃掉字符串值内部的
|
|
1222
|
+
* 「半角逗号+空白+闭括号」——`{"note":"p, } q"}` 被改成 `"p } q"`,是值
|
|
1223
|
+
* 篡改(缺陷自 2.1.0 既有,本补丁 P0 扩能后其可达面被扩大;T3 探针
|
|
1224
|
+
* TAMPER-3 实锤并定性为既有)。现在只有字符串外的逗号才会被删,
|
|
1225
|
+
* 与旧语义一致(只删逗号、保留其间空白与闭括号)。
|
|
1226
|
+
*/
|
|
1227
|
+
let inString = false
|
|
1228
|
+
let escaped = false
|
|
1229
|
+
let out = ''
|
|
1230
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
1231
|
+
const ch = input[i] as string
|
|
1232
|
+
if (inString) {
|
|
1233
|
+
out += ch
|
|
1234
|
+
if (escaped) escaped = false
|
|
1235
|
+
else if (ch === '\\') escaped = true
|
|
1236
|
+
else if (ch === '"') inString = false
|
|
1237
|
+
continue
|
|
1238
|
+
}
|
|
1239
|
+
if (ch === '"') {
|
|
1240
|
+
inString = true
|
|
1241
|
+
out += ch
|
|
1242
|
+
continue
|
|
1243
|
+
}
|
|
1244
|
+
if (ch === ',') {
|
|
1245
|
+
let j = i + 1
|
|
1246
|
+
while (j < input.length && (input[j] as string).trim() === '') j += 1
|
|
1247
|
+
const next = input[j]
|
|
1248
|
+
if (next === '}' || next === ']') continue
|
|
1249
|
+
}
|
|
1250
|
+
out += ch
|
|
1251
|
+
}
|
|
1252
|
+
return out
|
|
1115
1253
|
}
|
|
1116
1254
|
|
|
1117
1255
|
/** 找到最后一个「成员边界」逗号(在任何嵌套深度上、且不在字符串内)。 */
|
|
@@ -1147,6 +1285,25 @@ function* truncatedCandidates(input: string, rounds = 24): Generator<string> {
|
|
|
1147
1285
|
}
|
|
1148
1286
|
}
|
|
1149
1287
|
|
|
1288
|
+
/**
|
|
1289
|
+
* [2.3.2][D2-P1] 定向位置反馈:旧实现回喂只有「末尾 120 字符」,断点在 6KB 文档
|
|
1290
|
+
* 中部时模型依然盲,只能整段重掷(×3 ≈86.9 秒白烧的机制根因之一)。V8 对长输入的
|
|
1291
|
+
* 解析错误带 `at position N`,这里据此从候选文本切出断点 ±60 字符原文随错误一并
|
|
1292
|
+
* 回喂(runtime 的 lastErrors 直接透传该 message),让下一次请求是「定向修复」而
|
|
1293
|
+
* 非「盲目重生成」。短输入的新式消息本身已带上下文,正则不中则原样返回。
|
|
1294
|
+
*/
|
|
1295
|
+
function parseFailureHint(candidate: string, error: unknown): string {
|
|
1296
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
1297
|
+
const match = /at position (\d+)/.exec(message)
|
|
1298
|
+
if (!match) return ''
|
|
1299
|
+
const position = Math.min(Number(match[1]), candidate.length)
|
|
1300
|
+
const from = Math.max(0, position - 60)
|
|
1301
|
+
const to = Math.min(candidate.length, position + 60)
|
|
1302
|
+
const snippet = candidate.slice(from, to).replace(/\s+/g, ' ')
|
|
1303
|
+
return `;错误位置 ${position},断点附近原文(字符 ${from}-${to}):${JSON.stringify(snippet)}`
|
|
1304
|
+
+ '——请只修复该处 JSON 语法后重新输出完整对象,不得改动任何字段值'
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1150
1307
|
export function extractJson(text: any) {
|
|
1151
1308
|
if (typeof text !== 'string' || text.trim() === '') {
|
|
1152
1309
|
throw new PlanError('规划器没有返回内容', 'EMPTY_OUTPUT')
|
|
@@ -1168,7 +1325,7 @@ export function extractJson(text: any) {
|
|
|
1168
1325
|
const repaired = repairJsonStructure(candidate)
|
|
1169
1326
|
try {
|
|
1170
1327
|
const value2 = JSON.parse(repaired)
|
|
1171
|
-
console.warn('[dsh-workplan] 规划器 JSON
|
|
1328
|
+
console.warn('[dsh-workplan] 规划器 JSON 结构已修复(只动括号/逗号/字符串外全角标点,未改内容)')
|
|
1172
1329
|
return value2
|
|
1173
1330
|
} catch {
|
|
1174
1331
|
for (const attempt of truncatedCandidates(repaired)) {
|
|
@@ -1181,7 +1338,8 @@ export function extractJson(text: any) {
|
|
|
1181
1338
|
}
|
|
1182
1339
|
}
|
|
1183
1340
|
}
|
|
1184
|
-
|
|
1341
|
+
// [2.3.2][D2-P1] 抛出前附断点原文切片:重试请求据此定向修复,不再盲掷全文。
|
|
1342
|
+
throw new PlanError(`规划器返回的 JSON 无法解析:${error instanceof Error ? error.message : String(error)}${parseFailureHint(candidate, error)}`, 'INVALID_JSON')
|
|
1185
1343
|
}
|
|
1186
1344
|
}
|
|
1187
1345
|
|
|
@@ -1260,6 +1418,8 @@ export function buildPlannerPrompt(taskText: any, cwd: any, conversationContext:
|
|
|
1260
1418
|
'- 子任务必须可独立执行、可验收;不要为了凑数拆无意义任务。',
|
|
1261
1419
|
'- 子任务由子 Agent 独立执行:它们没有派发权限、不能重启服务、不能安装或升级依赖。禁止把「调用 dsh_workplan_dispatch」「重启/停止 dsh web」「安装或升级插件」这类只有主 Agent 才能执行的动作写进子任务;确实需要时,写成“给出结论或建议,由主 Agent 执行”。',
|
|
1262
1420
|
'- 单个子任务无须在 10 分钟内完成——10 分钟只是拆步规模建议,不是完成期限、也不构成承诺;实际时长由执行专家开工预告协商决定,不设固定完成时间;动手重的任务要拆成多个小步,避免整条计划被一个慢子任务拖住。',
|
|
1421
|
+
// [2.3.2][D2-P2] 半角/逗号/括号自检硬约束:与解析层兜底(P0)互为防线,中文模型全角标点高发。
|
|
1422
|
+
'- JSON 只允许半角标点(, : " { } [ ]);对象与数组的相邻成员之间必须有逗号;输出前自检括号成对、每个字符串以半角"闭合。',
|
|
1263
1423
|
'- 不要输出 Markdown 代码围栏、解释或前后缀;只输出一个 JSON 对象。',
|
|
1264
1424
|
'',
|
|
1265
1425
|
'本轮时间预算(硬事实,请据此规划规模):',
|
package/src/runtime.ts
CHANGED
|
@@ -1044,7 +1044,9 @@ export async function runPlanner(ctx: any, options: any) {
|
|
|
1044
1044
|
message,
|
|
1045
1045
|
`输出共 ${lastText.length} 字符,末尾原文:${JSON.stringify(tail)}`,
|
|
1046
1046
|
closed
|
|
1047
|
-
|
|
1047
|
+
// [2.3.2][D2-P1] 定向修复指令:message 已含「错误位置 + 断点附近原文」(extractJson
|
|
1048
|
+
// 的 parseFailureHint),这里明确要求只修语法、不动内容,替代旧「整段重掷」。
|
|
1049
|
+
? '末尾已闭合 → 断点在正文中间,属语法写错(漏逗号/括号不匹配):请按上文「错误位置/断点附近原文」只修复该处语法,禁止改动字段值与整体结构'
|
|
1048
1050
|
: '末尾未闭合(没有结尾 })→ 疑似输出被截断,请给出更紧凑的完整 JSON',
|
|
1049
1051
|
]
|
|
1050
1052
|
}
|
|
@@ -4197,6 +4199,23 @@ export function reconstructFromSession(session: any, targetPlanId?: string) {
|
|
|
4197
4199
|
})
|
|
4198
4200
|
continue
|
|
4199
4201
|
}
|
|
4202
|
+
/*
|
|
4203
|
+
* [2.3.0][hotfix] 回放兼容「已回报行 + 旧版 closure:'done' 错误快照」(用户 2026-11-10 截图:
|
|
4204
|
+
* wp-3080d01d T6/T7「非法闭环迁移:reported → done」回放忽略)。
|
|
4205
|
+
*
|
|
4206
|
+
* 2.0.4 之前 live 侧 applyStatus 把 reported 行的 closure 误写回 'done',durable 改判
|
|
4207
|
+
* 消息因此嵌着这个错误快照。2.2.6 D-1 给回放补了 closure 透传,但没有豁免这一组合:
|
|
4208
|
+
* 回放大方把 'done' 当显式闭环意图传给迁移表 → reported → done 被拒 → 整条改判
|
|
4209
|
+
* (含 verification/acceptance 证据)被裸 catch 吞掉,重启后行退回缺证据态。
|
|
4210
|
+
*
|
|
4211
|
+
* 口径与 2.0.4 live 侧镜像:事件 closure='done' 且当前行 closure='reported' 时,这是
|
|
4212
|
+
* 「复核补齐」而非「退回未回报」,丢弃该显式值,让 done 分支按 2.0.4 保留已回报事实。
|
|
4213
|
+
* 其余透传分支(escalated/instructed 等,D-1 语义)零改动。
|
|
4214
|
+
*/
|
|
4215
|
+
const preReplayRow = snap.statuses.find((item: any) => item?.subtaskId === update.subtaskId)
|
|
4216
|
+
const replayClosure: string | undefined = typeof update.closure === 'string'
|
|
4217
|
+
? (update.closure === 'done' && preReplayRow?.closure === 'reported' ? undefined : update.closure)
|
|
4218
|
+
: undefined
|
|
4200
4219
|
snap.statuses = applyStatus(snap.statuses, update.subtaskId, {
|
|
4201
4220
|
/*
|
|
4202
4221
|
* handoff 的 durable 记录携带的是状态快照,不是一次状态迁移。
|
|
@@ -4215,7 +4234,7 @@ export function reconstructFromSession(session: any, targetPlanId?: string) {
|
|
|
4215
4234
|
* 重启后「待指示」行永久卡死(2026-11-08 wp-3c8c84b2 T2 实证,
|
|
4216
4235
|
* 见 artifacts/2.2.5-post-restart-regression.md §4 D-1)。
|
|
4217
4236
|
*/
|
|
4218
|
-
closure:
|
|
4237
|
+
closure: replayClosure,
|
|
4219
4238
|
progress: typeof update.progress === 'number' ? update.progress : undefined,
|
|
4220
4239
|
summary: typeof update.note === 'string' ? update.note : undefined,
|
|
4221
4240
|
// [1.8.13] Evidence written through the update tool must survive replay.
|