dsh-workplan 1.6.0 → 1.7.0
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 +57 -0
- package/README.en.md +19 -5
- package/README.md +19 -7
- package/client.js +91 -6
- package/lib/host.js +78 -6
- package/lib/plan.js +474 -11
- package/lib/runtime.js +495 -76
- package/package.json +1 -1
- package/src/client.ts +90 -8
- package/src/host.ts +81 -5
- package/src/plan.ts +476 -11
- package/src/runtime.ts +490 -73
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,60 @@
|
|
|
1
|
+
## 1.7.0 — 2026-10-30
|
|
2
|
+
|
|
3
|
+
**「协作契约」版:让主 Agent 与各部门在全程共享同一份事实。**
|
|
4
|
+
|
|
5
|
+
1.6.0 的协作审查([docs/review-collaboration-20261030.md](docs/review-collaboration-20261030.md),17 条断点 C1–C17)
|
|
6
|
+
暴露了同一个根因:**派出去的部门与主 Agent 之间没有可核对的契约**。派发期间主 Agent 全盲;
|
|
7
|
+
子 Agent 交回任何非空文本就算完成;依赖只看状态不看产物;主 Agent 的改判会被子 Agent 的结算覆盖,
|
|
8
|
+
也活不过一次刷新。本版把「谁在做什么、凭什么算做完、改判以谁为准」收敛成代码里唯一的判定表。
|
|
9
|
+
|
|
10
|
+
### 新增
|
|
11
|
+
|
|
12
|
+
- **结构化结果契约**(`src/plan.ts#adjudicateResult`、`#parseEvidenceBlock`):子 Agent 在输出末尾回传
|
|
13
|
+
`WORKPLAN_EVIDENCE` 块,含 `status` / `blockedReason` / `acceptance[]` / `artifacts[]` / `needs[]`。
|
|
14
|
+
八种情形写死在 `adjudicateResult`:`blocked` / `partial` → 受阻;任一验收 `fail` → 受阻(`failed`);
|
|
15
|
+
全 `pass` → 完成(`structured`);含 `unverified` → 完成但标 `unverified`;无块但首行 `BLOCKED:` → 旧格式受阻;
|
|
16
|
+
坏块 → 受阻(`unparsable`)。只有 `structured` 可直接采信,其余在结果消息「验收核对」段逐项列出,交给主 Agent 复核。
|
|
17
|
+
- **异步派发与只读观测**:`dsh_workplan_dispatch` 新增 `mode: "wait" | "async"`(默认 `wait`)。`async` 立即返回
|
|
18
|
+
`running: true` 与实时状态,本轮结束时仍自动写入 durable 结果消息;新增只读工具 `dsh_workplan_status`,
|
|
19
|
+
可从会话记录重建计划,刷新或重启后也能回答「做到哪了」。`wait` 遇到进行中的派发会**汇合**(`joined: true`)
|
|
20
|
+
并返回完整结果,不再只回一个 `alreadyRunning: true`。
|
|
21
|
+
- **写保护**:`dsh_workplan_update` 新增 `expectedRevision` 与 `force`。基于旧快照的写入返回 `STALE_WRITE`;
|
|
22
|
+
计划执行中改判运行中的子任务返回 `TASK_RUNNING`(`force: true` 才覆盖,并记录为人工改判)。每次写入递增
|
|
23
|
+
`revision`,人工改判以 durable `workplan-update` 消息落盘,刷新后仍然生效。
|
|
24
|
+
- **产物门禁**:结算时逐个核实子 Agent 声明的 `file` 产物,缺失的记入 `missingArtifacts`;依赖它的下游不解锁,
|
|
25
|
+
受阻文案点名上游 `T1「标题」`、原因与缺失文件。可用 `artifactGate: false` 关闭(排障/旧计划回放)。
|
|
26
|
+
- **跨部门 brief 与 needs 转达**:子 Agent 提示词带上「兄弟部门进展」(谁、做什么、产出什么、已完成摘要),
|
|
27
|
+
并明确「需要协作请写进 needs,由主 Agent 转达」;结果消息新增「跨部门待转达」段,要求逐条处理。
|
|
28
|
+
- **重试回灌**:重试只发生一次且规则确定——硬超时/中止/预算到点不重试,停滞或未完成且剩余时间足够才重试;
|
|
29
|
+
第二次尝试的提示词带上一次的 `code` 与原因,不再原样重撞同一堵墙。
|
|
30
|
+
- **时间预算预估**:规划器必须为每个子任务写 `estimateMinutes`,计划卡提示本轮预算是否够用。
|
|
31
|
+
|
|
32
|
+
### 修正
|
|
33
|
+
|
|
34
|
+
- 子 Agent 输出不再被二次截断:背景由「计划时刻采样并截断到 5000 字」改为派发前 `recentConversation` 的 7000 字,
|
|
35
|
+
`buildChildPrompt` 直接使用入参。
|
|
36
|
+
- 依赖受阻文案从「依赖未完成或上游受阻」改为带上上游标题、原因与缺失产物。
|
|
37
|
+
- 结构化证据块解析失败不再默认完成,而是显式 `blocked/unparsable`。
|
|
38
|
+
|
|
39
|
+
### 兼容与迁移
|
|
40
|
+
|
|
41
|
+
- 旧会话无需迁移:没有结构化块的旧结果按 `legacy` 读作「完成但未验证」,结果消息会提示主 Agent 复核;
|
|
42
|
+
`strict: false` 保留 1.6.0 的判定,供旧计划回放使用。
|
|
43
|
+
- `update` 原有参数与语义不变,新增参数全部可选。
|
|
44
|
+
- `PLAN_VERSION` 仍为 1;旧计划消息可原样回放。
|
|
45
|
+
|
|
46
|
+
### 文档
|
|
47
|
+
|
|
48
|
+
- 新增[协作契约](docs/collaboration.md)(角色、数据契约、状态机、失败恢复、写者所有权)与
|
|
49
|
+
[部门职责与交接约定](docs/departments.md);新增 [RELEASING.md](RELEASING.md) 发布清单;
|
|
50
|
+
更新中英文 README 至 1.7.0 并去掉过期的测试数字硬编码。
|
|
51
|
+
|
|
52
|
+
### 验收
|
|
53
|
+
|
|
54
|
+
- `npm test` 179 个用例全绿;新增 7 个测试文件,覆盖证据契约、派发模式、写保护、产物门禁、
|
|
55
|
+
跨部门 brief、重试回灌与 host 工具 schema;`npm run check` 通过。
|
|
56
|
+
- 原计划的 1.6.1(纯文档修复)已并入本版,不再单独发号。
|
|
57
|
+
|
|
1
58
|
## 1.6.0 — 2026-10-29
|
|
2
59
|
|
|
3
60
|
**「会话终止」收敛版**。用户截图圈出 `session-7129faea-d4bd-4ed5-a081-769496e07ceb`:
|
package/README.en.md
CHANGED
|
@@ -20,6 +20,19 @@ For every new task with a real goal, the plugin inserts three beats:
|
|
|
20
20
|
|
|
21
21
|
Greetings, thanks, and status questions ("how far along are we?") do not trigger a plan.
|
|
22
22
|
|
|
23
|
+
## How departments collaborate (what 1.7.0 actually does)
|
|
24
|
+
|
|
25
|
+
Every work item carries a department label (Engineering, Research, Design, Product, Data, QA, Security, DevOps, Writing, Operations, Legal, Finance). **The label drives the prompt and the stats, not an org chart**:
|
|
26
|
+
|
|
27
|
+
- Departments **cannot talk to each other directly**. Cross-department information goes through the main agent, or through files both sides can read.
|
|
28
|
+
- A downstream task sees only the **summary** of its `dependsOn` upstreams — not sibling tasks, not the upstream's full conversation. Upstreams must put the artifact's absolute path and acceptance steps in the summary.
|
|
29
|
+
- A stage is a display grouping, **not an execution gate**; `dependsOn` decides order.
|
|
30
|
+
- Each child receives a **read-only brief of its sibling tasks** (who, what, expected outputs, summaries of finished work). It cannot contact them directly: cooperation requests go into `needs`, and the result message collects them under "cross-department hand-offs" for the main agent.
|
|
31
|
+
- A child returns a structured evidence block (`status` / `acceptance` / `artifacts` / `needs`). **Non-empty output no longer means done**: `partial`, any failed acceptance item, or an unparsable block is blocked; only all-`pass` is trusted directly, everything else is flagged "unverified" for the main agent.
|
|
32
|
+
- Declared `file` artifacts are checked; a missing artifact keeps downstream tasks locked and names the upstream plus the missing file.
|
|
33
|
+
|
|
34
|
+
The full contract — roles, data shapes, state machine, recovery, and the three places to update together — is in **[Collaboration contract](https://github.com/abbaababa/dsh-workplan/blob/main/docs/collaboration.md)**; per-department duties and handoff checklists are in **[Departments and handoffs](https://github.com/abbaababa/dsh-workplan/blob/main/docs/departments.md)**.
|
|
35
|
+
|
|
23
36
|
## Requirements
|
|
24
37
|
|
|
25
38
|
| Item | Detail |
|
|
@@ -31,7 +44,7 @@ Greetings, thanks, and status questions ("how far along are we?") do not trigger
|
|
|
31
44
|
## Install
|
|
32
45
|
|
|
33
46
|
```bash
|
|
34
|
-
dsh plugin --profile web add dsh-workplan@1.
|
|
47
|
+
dsh plugin --profile web add dsh-workplan@1.7.0
|
|
35
48
|
```
|
|
36
49
|
|
|
37
50
|
Restart the DSH Web process (or reload the page) so the bundle is picked up.
|
|
@@ -62,8 +75,9 @@ Every number is derived from the same task state — the panel can no longer cla
|
|
|
62
75
|
|
|
63
76
|
| Tool | Purpose |
|
|
64
77
|
|---|---|
|
|
65
|
-
| `dsh_workplan_dispatch` | Dispatch the current plan
|
|
66
|
-
| `
|
|
78
|
+
| `dsh_workplan_dispatch` | Dispatch the current plan and write results back. `mode:"wait"` (default) waits for the round; `mode:"async"` returns immediately and keeps running in the background. Idempotent. |
|
|
79
|
+
| `dsh_workplan_status` | Read-only: ask how far along the plan is. Rebuilt from the session log, so it survives a restart or reload. |
|
|
80
|
+
| `dsh_workplan_update` | Main agent only: correct a subtask's status and evidence. Takes `expectedRevision` to prevent lost updates; in-flight subtasks are refused unless `force:true`. |
|
|
67
81
|
| `dsh_workplan_cancel` | Cancel a plan that has not been dispatched; never fabricates completion. |
|
|
68
82
|
|
|
69
83
|
In **plan mode** the plan is shown for review and `dispatch` is explicitly refused with a reason.
|
|
@@ -97,7 +111,7 @@ Limits can also be set in the plugin config:
|
|
|
97
111
|
Verify it yourself:
|
|
98
112
|
|
|
99
113
|
```bash
|
|
100
|
-
npm view dsh-workplan@
|
|
114
|
+
npm view dsh-workplan@latest dependencies
|
|
101
115
|
grep -RInE "writeFileSync|child_process|eval\(" src
|
|
102
116
|
npm audit --omit=dev
|
|
103
117
|
```
|
|
@@ -153,7 +167,7 @@ dsh plugin --profile web remove dsh-workplan
|
|
|
153
167
|
```bash
|
|
154
168
|
npm ci
|
|
155
169
|
npm run check # tsc --noEmit
|
|
156
|
-
npm test #
|
|
170
|
+
npm test # all tests (the count changes between versions; trust the output and CI), including count invariants and the progress chart
|
|
157
171
|
npm run build # src/*.ts → lib/*.js, client.js
|
|
158
172
|
npm run preview # regenerate the 1.4.3 / 1.5.0 card comparison under docs/preview
|
|
159
173
|
```
|
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
## 一键安装
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
dsh plugin --profile web add dsh-workplan@1.
|
|
36
|
+
dsh plugin --profile web add dsh-workplan@1.7.0
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
装完**重启一次 DSH Web**(或重新载入当前页面)让插件生效。
|
|
@@ -64,16 +64,28 @@ dsh plugin --profile web add "$(pwd)"
|
|
|
64
64
|
|
|
65
65
|
纯打招呼、道谢、问「做到哪了」不会触发拆解,不会平白多出一堆子 Agent。
|
|
66
66
|
|
|
67
|
-
##
|
|
67
|
+
## 四个模型工具(你不用直接调用)
|
|
68
68
|
|
|
69
69
|
| 工具 | 作用 |
|
|
70
70
|
|---|---|
|
|
71
|
-
| `dsh_workplan_dispatch` |
|
|
72
|
-
| `
|
|
71
|
+
| `dsh_workplan_dispatch` | 派发当前计划,把结果写回会话。默认 `mode:"wait"` 等结束;`mode:"async"` 立刻返回、后台继续。重复调用是幂等的。 |
|
|
72
|
+
| `dsh_workplan_status` | 只读:问到哪了。重启或刷新后也能从会话记录重建。 |
|
|
73
|
+
| `dsh_workplan_update` | 主 Agent 核对结果、修正某个子任务状态与证据。带 `expectedRevision` 防覆盖,运行中默认拒绝(`force:true` 才覆盖)。子 Agent 不能调用。 |
|
|
73
74
|
| `dsh_workplan_cancel` | 取消还没派发的计划,不会伪造任何「已完成」。 |
|
|
74
75
|
|
|
75
76
|
在 **plan 模式**下只会给你看计划,`dispatch` 会被明确拦下并说明原因,不会偷偷开跑。
|
|
76
77
|
|
|
78
|
+
## 部门怎么协作(1.7.0 的真实能力)
|
|
79
|
+
|
|
80
|
+
计划里的每件工作都带一个部门标签(工程研发、研究分析、设计、产品、数据、质量验证、安全、运维、文档写作、运营、法务合规、财务)。**标签决定提示词与统计口径,不是组织架构**:
|
|
81
|
+
|
|
82
|
+
- 部门之间**不能直接对话**;跨部门信息由主 Agent 转达,或落到双方都能读的工作区文件。但每个子 Agent 的提示词里会带上**兄弟部门的只读一览**(谁、做什么、产出什么、已完成摘要),需要协作就写进 `needs`,结果消息会汇总成「跨部门待转达」交给主 Agent 逐条处理。
|
|
83
|
+
- 下游只看到 `dependsOn` 里上游的**摘要**与完整体检结果,看不到上游的完整对话。所以上游必须把「产物绝对路径 + 怎么验收」写进摘要;声明为 `file` 的产物会被逐个核实,**缺失就不给下游解锁**。
|
|
84
|
+
- 子 Agent 在输出末尾回传结构化证据块(`status` / `acceptance` / `artifacts` / `needs`)。**非空输出不再等于完成**:`partial`、任一条验收失败、坏块都判受阻,只有全 `pass` 才可直接采信,其余在结果消息里标「未验证」等主 Agent 核对。
|
|
85
|
+
- 阶段(stage)只是展示分组,**不是执行门槛**;真正决定先后的是 `dependsOn`。
|
|
86
|
+
|
|
87
|
+
完整的角色、数据契约、状态机、失败恢复与「改代码时必须同步的三处」,见 **[协作契约](https://github.com/abbaababa/dsh-workplan/blob/main/docs/collaboration.md)**;12 个部门的职责与交接清单见 **[部门职责与交接约定](https://github.com/abbaababa/dsh-workplan/blob/main/docs/departments.md)**。
|
|
88
|
+
|
|
77
89
|
## 预算、超时与续跑(知道这些就不会误以为卡死)
|
|
78
90
|
|
|
79
91
|
| 项 | 默认值 | 怎么改 |
|
|
@@ -84,7 +96,7 @@ dsh plugin --profile web add "$(pwd)"
|
|
|
84
96
|
| 自动续跑次数 | 4 次 | `DSH_WORKPLAN_MAX_RESUMES` |
|
|
85
97
|
| 并发子 Agent | 5 个(固定) | — |
|
|
86
98
|
|
|
87
|
-
|
|
99
|
+
预算用尽不是失败:计划会变成「**本轮预算用尽,可续跑**」,已完成的不重跑,剩下的下次接着做。被判定卡住的子任务只卡它自己,不会拖垮整个计划;重试只会发生一次,第二次的提示词会带上一次的失败原因,不会原样重撞。
|
|
88
100
|
|
|
89
101
|
环境变量写在启动 DSH 的那个 shell 里,或者写进插件配置:
|
|
90
102
|
|
|
@@ -104,7 +116,7 @@ dsh plugin --profile web add "$(pwd)"
|
|
|
104
116
|
自己复核:
|
|
105
117
|
|
|
106
118
|
```bash
|
|
107
|
-
npm view dsh-workplan@
|
|
119
|
+
npm view dsh-workplan@latest dependencies # 应为空
|
|
108
120
|
grep -RInE "writeFileSync|child_process|eval\(" src # 应无命中
|
|
109
121
|
npm audit --omit=dev
|
|
110
122
|
```
|
|
@@ -164,7 +176,7 @@ dsh plugin --profile web remove dsh-workplan
|
|
|
164
176
|
```bash
|
|
165
177
|
npm ci
|
|
166
178
|
npm run check # tsc --noEmit
|
|
167
|
-
npm test #
|
|
179
|
+
npm test # 全部测试(数量随版本变化,以命令输出与 CI 为准),含计数不变量与进度图表用例
|
|
168
180
|
npm run build # 编译 src/*.ts → lib/*.js、client.js
|
|
169
181
|
npm run preview # 重新生成 docs/preview 里的 1.4.3 / 1.5.0 卡头对比页
|
|
170
182
|
```
|
package/client.js
CHANGED
|
@@ -178,6 +178,7 @@ window.__ModuleLoader__.load({
|
|
|
178
178
|
"overview": "进度总览",
|
|
179
179
|
"statusChart": "状态分布",
|
|
180
180
|
"taskChart": "每个任务的进度",
|
|
181
|
+
"backToTop": "回到顶部",
|
|
181
182
|
"jumpToTask": "跳转到任务明细",
|
|
182
183
|
"scopeAll": "当前各会话最新计划汇总",
|
|
183
184
|
"scopeThis": "本计划",
|
|
@@ -348,6 +349,7 @@ window.__ModuleLoader__.load({
|
|
|
348
349
|
"overview": "Progress overview",
|
|
349
350
|
"statusChart": "Status mix",
|
|
350
351
|
"taskChart": "Progress by task",
|
|
352
|
+
"backToTop": "Back to top",
|
|
351
353
|
"jumpToTask": "Jump to task details",
|
|
352
354
|
"scopeAll": "Latest plan per live session",
|
|
353
355
|
"scopeThis": "This plan",
|
|
@@ -533,6 +535,35 @@ window.__ModuleLoader__.load({
|
|
|
533
535
|
}
|
|
534
536
|
.dsh-wp-button:hover { background: var(--dsw-alias-bg-layer-2); }
|
|
535
537
|
.dsh-wp-button:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
|
|
538
|
+
/* [T4] 回到顶部:sticky 的包含块与粘附视口就是 .dsh-wp 的 padding box,
|
|
539
|
+
钉住的是面板可视区右下角。禁止 fixed(钉到浏览器视口)与 absolute
|
|
540
|
+
(随内容滚走)。始终挂载、用 visibility 藏显,避免显隐改变 scrollHeight。 */
|
|
541
|
+
.dsh-wp-backtop {
|
|
542
|
+
position: sticky;
|
|
543
|
+
bottom: 16px;
|
|
544
|
+
z-index: 30;
|
|
545
|
+
display: flex;
|
|
546
|
+
align-items: center;
|
|
547
|
+
justify-content: center;
|
|
548
|
+
width: 44px;
|
|
549
|
+
height: 44px;
|
|
550
|
+
margin: 12px 0 0 auto;
|
|
551
|
+
padding: 0;
|
|
552
|
+
border-radius: 50%;
|
|
553
|
+
border: 1px solid var(--dsw-alias-border-l1);
|
|
554
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
555
|
+
color: var(--dsw-alias-label-primary);
|
|
556
|
+
font: inherit;
|
|
557
|
+
font-size: 18px;
|
|
558
|
+
line-height: 1;
|
|
559
|
+
cursor: pointer;
|
|
560
|
+
touch-action: manipulation;
|
|
561
|
+
visibility: hidden;
|
|
562
|
+
box-shadow: 0 2px 8px rgba(15,23,42,.18);
|
|
563
|
+
}
|
|
564
|
+
.dsh-wp-backtop[data-visible="true"], .dsh-wp-backtop:focus-within { visibility: visible; }
|
|
565
|
+
.dsh-wp-backtop:hover { background: var(--dsw-alias-bg-layer-2); }
|
|
566
|
+
.dsh-wp-backtop:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
|
|
536
567
|
.dsh-wp-banner {
|
|
537
568
|
border: 1px solid var(--dsw-alias-border-l1);
|
|
538
569
|
background: var(--dsw-alias-bg-layer-1);
|
|
@@ -2085,6 +2116,8 @@ window.__ModuleLoader__.load({
|
|
|
2085
2116
|
}, h('div', { className: 'dsh-wp-bar-head' }, h('span', { className: 'dsh-wp-bar-title' }, session.title || t('panel')), h('span', { className: 'dsh-wp-bar-value' }, `${counts.done}/${counts.total}`)), h('div', { className: 'dsh-wp-bar-track' }, h('div', { className: `dsh-wp-bar-fill dsh-wp-bar-fill--${tone}`, style: { width: `${percent}%` } })), h('div', { className: 'dsh-wp-bar-meta' }, h('span', null, phaseLabel(phase, session, t)), h('span', null, `${percent}%`)));
|
|
2086
2117
|
}));
|
|
2087
2118
|
}
|
|
2119
|
+
/* [T4] 回到顶部的显示阈值(px):scrollTop 严格大于该值才显示。 */
|
|
2120
|
+
const BACK_TOP_THRESHOLD = 200;
|
|
2088
2121
|
function Dashboard({ t }) {
|
|
2089
2122
|
const { sessions, error, loading, updatedAt, reload } = usePlans();
|
|
2090
2123
|
const [openSessionId, setOpenSessionId] = useState(null);
|
|
@@ -2227,9 +2260,53 @@ window.__ModuleLoader__.load({
|
|
|
2227
2260
|
value: planPercent(planCount(session.stats?.done), planCount(session.stats?.total)) ?? 0,
|
|
2228
2261
|
};
|
|
2229
2262
|
}), [groups, t]);
|
|
2230
|
-
|
|
2263
|
+
/*
|
|
2264
|
+
* [T4] 回到顶部:用「状态当 ref」拿面板根节点(宿主兼容层不保证 useRef,
|
|
2265
|
+
* 见 GroupCharts 的同一处理),滚动目标只能是 .dsh-wp 这个 overflow 容器。
|
|
2266
|
+
*/
|
|
2267
|
+
const [panelEl, setPanelEl] = useState(null);
|
|
2268
|
+
const [showBackTop, setShowBackTop] = useState(false);
|
|
2269
|
+
useEffect(() => {
|
|
2270
|
+
const panel = panelEl;
|
|
2271
|
+
if (!panel || typeof panel.addEventListener !== 'function')
|
|
2272
|
+
return;
|
|
2273
|
+
const onScroll = () => setShowBackTop(Number(panel.scrollTop) > BACK_TOP_THRESHOLD);
|
|
2274
|
+
// 挂载与内容变化时先求一次初值:刷新后停在中间也必须显示按钮。
|
|
2275
|
+
onScroll();
|
|
2276
|
+
panel.addEventListener('scroll', onScroll, { passive: true });
|
|
2277
|
+
return () => panel.removeEventListener('scroll', onScroll);
|
|
2278
|
+
}, [panelEl, activeSessions.length]);
|
|
2279
|
+
const backToTop = useCallback((event) => {
|
|
2280
|
+
// 双保险:ref 尚未回填时,从事件目标向上找唯一的滚动容器。
|
|
2281
|
+
let panel = panelEl;
|
|
2282
|
+
if (!panel && event && event.currentTarget && typeof event.currentTarget.closest === 'function') {
|
|
2283
|
+
panel = event.currentTarget.closest('.dsh-wp');
|
|
2284
|
+
}
|
|
2285
|
+
if (!panel)
|
|
2286
|
+
return;
|
|
2287
|
+
const reduced = typeof window !== 'undefined' && typeof window.matchMedia === 'function'
|
|
2288
|
+
&& window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
2289
|
+
if (typeof panel.scrollTo === 'function') {
|
|
2290
|
+
try {
|
|
2291
|
+
panel.scrollTo({ top: 0, behavior: reduced ? 'auto' : 'smooth' });
|
|
2292
|
+
return;
|
|
2293
|
+
}
|
|
2294
|
+
catch (error) {
|
|
2295
|
+
/* 旧宿主不支持带参数的 scrollTo:落到下面的直接赋值。 */
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
panel.scrollTop = 0;
|
|
2299
|
+
}, [panelEl]);
|
|
2300
|
+
return h('div', {
|
|
2301
|
+
className: 'dsh-wp',
|
|
2302
|
+
ref: (node) => { if (node !== panelEl)
|
|
2303
|
+
setPanelEl(node); },
|
|
2304
|
+
}, h('header', { className: 'dsh-wp-header' }, h('div', null, h('h1', { className: 'dsh-wp-title' }, t('title')), h('p', { className: 'dsh-wp-subtitle' }, t('subtitle')), h('div', { className: 'dsh-wp-meta' }, updatedAt ? h('span', null, `${t('updatedAt')} ${formatTime(updatedAt)}`) : null, h('span', null, `${t('scopeAll')}:${activeSessions.length} ${t('sessionCount')},${t('taskBreakdown')} ${totals.total} ${t('subtaskCount')}`))), h('button', { type: 'button', className: 'dsh-wp-button', onClick: reload, disabled: loading }, t('refresh'))), error ? h(ErrorBanner, { message: error, onRetry: reload, t }) : null, activeSessions.length > 0 ? h('div', { className: 'dsh-wp-statbar', role: 'list' }, h('div', { className: 'dsh-wp-stat dsh-wp-stat--tasks', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, activeSessions.length), h('div', { className: 'dsh-wp-stat-label' }, t('sessionCount'))), h('div', { className: 'dsh-wp-stat', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, totals.total), h('div', { className: 'dsh-wp-stat-label' }, t('workItems'))), h('div', { className: 'dsh-wp-stat dsh-wp-stat--done', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, totals.done), h('div', { className: 'dsh-wp-stat-label' }, t('stats.done'))), h('div', { className: 'dsh-wp-stat dsh-wp-stat--active', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, totals.inProgress), h('div', { className: 'dsh-wp-stat-label' }, t('stats.inProgress'))), h('div', { className: 'dsh-wp-stat dsh-wp-stat--blocked', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, totals.blocked), h('div', { className: 'dsh-wp-stat-label' }, t('stats.blocked')))) : null, activeSessions.length > 0 ? h('div', { className: 'dsh-wp-scope-note' }, t('allPlansHint')) : null, activeSessions.length === 0
|
|
2231
2305
|
? h('div', { className: 'dsh-wp-empty' }, h('div', { style: { fontWeight: 650, marginBottom: '4px' } }, t('empty')), h('div', null, t('emptyHint')))
|
|
2232
2306
|
: h('div', { className: 'dsh-wp-groups' },
|
|
2307
|
+
// [用户要求] 总览块(完成率环 + 每个任务的进度)上移到分组之前:
|
|
2308
|
+
// 用户要求红圈的「每个任务的进度」必须显示在「进行中」组之上。
|
|
2309
|
+
activeSessions.length > 0 ? h('div', { className: 'dsh-wp-overview' }, h(Donut, { totals, t }), h(TaskBars, { sessions: activeSessions, t, onSelect: selectSession })) : null,
|
|
2233
2310
|
/*
|
|
2234
2311
|
* [1.6.0] 三组顺序:真的在跑 → 已结束(停在半路) → 已完成。
|
|
2235
2312
|
* 「已结束」夹在中间是有意为之:它是用户最需要立刻知道的那一档
|
|
@@ -2238,14 +2315,22 @@ window.__ModuleLoader__.load({
|
|
|
2238
2315
|
h(SessionGroup, { key: 'live', group: 'live', list: groups.live, urgent: groups.urgent, t, openSessionId, setOpenSessionId }), groups.ended.length > 0
|
|
2239
2316
|
? h(SessionGroup, { key: 'ended', group: 'ended', list: groups.ended, hasLive: groups.live.length > 0, urgent: groups.urgentEnded, t, openSessionId, setOpenSessionId })
|
|
2240
2317
|
: null, h(SessionGroup, { key: 'done', group: 'done', list: groups.finished, hasLive: groups.live.length > 0 || groups.ended.length > 0, urgent: 0, t, openSessionId, setOpenSessionId }),
|
|
2241
|
-
// 用户选择 B:总览块(完成率环 + 每个计划的进度条)同样下移到两组之后,
|
|
2242
|
-
// 让开屏第一屏直接是「进行中」组的任务卡(此前统计条 → 总览 → 说明行 →
|
|
2243
|
-
// 任务卡,第一张卡要下滑约一屏)。顶部只保留 5 格数字统计条与一行口径说明。
|
|
2244
|
-
activeSessions.length > 0 ? h('div', { className: 'dsh-wp-overview' }, h(Donut, { totals, t }), h(TaskBars, { sessions: activeSessions, t, onSelect: selectSession })) : null,
|
|
2245
2318
|
// 图表放两组之后:两张卡各 ≈246px,排在组前会让首屏看不到任何一张任务卡
|
|
2246
2319
|
// (设计稿 §8 第 12 条,T8 复核时复现在 1.4.2 源码里)。
|
|
2247
2320
|
// [1.6.0] 「未结束」= 进行中 + 已结束但未完成:两者都还没做完,都是用户要盯的对象。
|
|
2248
|
-
h(GroupCharts, { liveCount: groups.live.length + groups.ended.length, doneCount: groups.finished.length, liveBars, hiddenBars: Math.max(0, groups.live.length + groups.ended.length - 6), t }))
|
|
2321
|
+
h(GroupCharts, { liveCount: groups.live.length + groups.ended.length, doneCount: groups.finished.length, liveBars, hiddenBars: Math.max(0, groups.live.length + groups.ended.length - 6), t })),
|
|
2322
|
+
/*
|
|
2323
|
+
* [T4] 始终挂载的回到顶部按钮:作为 .dsh-wp 的最后一个直接子元素,
|
|
2324
|
+
* sticky 在面板滚动视口右下角;显隐只切换 data-visible,不增删节点。
|
|
2325
|
+
*/
|
|
2326
|
+
h('button', {
|
|
2327
|
+
type: 'button',
|
|
2328
|
+
className: 'dsh-wp-backtop',
|
|
2329
|
+
'data-visible': showBackTop ? 'true' : 'false',
|
|
2330
|
+
'aria-label': t('backToTop'),
|
|
2331
|
+
title: t('backToTop'),
|
|
2332
|
+
onClick: backToTop,
|
|
2333
|
+
}, h('span', { 'aria-hidden': 'true' }, '↑')));
|
|
2249
2334
|
}
|
|
2250
2335
|
function TurnCard({ sessionId, turn, t }) {
|
|
2251
2336
|
const { sessions } = usePlans(sessionId);
|
package/lib/host.js
CHANGED
|
@@ -8,7 +8,7 @@ import { readFileSync } from 'node:fs';
|
|
|
8
8
|
* - dsh_workplan_update and dsh_workplan_dispatch model tools;
|
|
9
9
|
* - the read-only dashboard route.
|
|
10
10
|
*/
|
|
11
|
-
import { createWorkplanRuntime, dispatchToolOutputSchema, plannerOutputSchema, updateToolOutputSchema, } from './runtime.js';
|
|
11
|
+
import { createWorkplanRuntime, dispatchToolOutputSchema, plannerOutputSchema, statusToolOutputSchema, updateToolOutputSchema, } from './runtime.js';
|
|
12
12
|
import { isRecord } from './plan.js';
|
|
13
13
|
function phaseLabel(phase) {
|
|
14
14
|
if (phase === 'paused')
|
|
@@ -31,7 +31,7 @@ export const name = 'dsh-workplan';
|
|
|
31
31
|
export const inject = ['tools', 'systemPrompt', 'llm', 'subagents', 'sessions'];
|
|
32
32
|
export const PROMPT_ORDER = 40;
|
|
33
33
|
const PROMPT_SECTION = [
|
|
34
|
-
'本会话已启用自动任务分解。系统会在每个新用户任务的第一个模型步骤前生成计划,并先把计划显示在对话里;收到【任务分解】后,必须先调用 dsh_workplan_dispatch
|
|
34
|
+
'本会话已启用自动任务分解。系统会在每个新用户任务的第一个模型步骤前生成计划,并先把计划显示在对话里;收到【任务分解】后,必须先调用 dsh_workplan_dispatch(默认 wait 等结果;预计较久时用 mode:"async" 先开跑),再做任何其他工具调用或回答。',
|
|
35
35
|
'如果当前是 plan 模式:不要调用 dsh_workplan_dispatch;先把计划展示给用户,等待用户审阅并退出 plan 模式后,再调用 dsh_workplan_dispatch 执行。',
|
|
36
36
|
'纯问候、寒暄、致谢、告别、简单确认(如「你好」「谢谢」「好的」「再见」)不生成计划,也不启动子 Agent;直接自然、简短地回答。只有包含实际目标、问题或交付物的消息才进行分解。',
|
|
37
37
|
'单独的「继续」「接着」「然后呢」「下一步」等没有新增任务内容的追问,不生成计划;由主 Agent 结合会话上下文继续,或先询问用户要延续哪件事。',
|
|
@@ -41,8 +41,25 @@ const PROMPT_SECTION = [
|
|
|
41
41
|
'2. 核对每个完成子任务的证据与验收标准,不合格的要用 dsh_workplan_update 标记为 blocked 或 in_progress;',
|
|
42
42
|
'3. 对受阻项向用户说明,必要时先询问再继续;',
|
|
43
43
|
'4. 不要声称未经验证的完成,不要重复派发已完成的子任务。',
|
|
44
|
+
'结果消息里每个完成项都带 verification 与 acceptance:`structured` 是子 Agent 逐条自检通过,`unverified` 是自述但未逐条确认,`failed` 是自检失败(已按受阻处理),`legacy` 是旧格式回传。只把 structured 当作可直接采信,其余必须你自己核对产物。',
|
|
45
|
+
'子 Agent 通过 `needs` 提出的跨部门需求会列在结果消息的「跨部门待转达」里:由你逐条处理(补派、向用户确认或直接完成),不要忽略。',
|
|
46
|
+
'长任务可以用 `dsh_workplan_dispatch({ mode: "async" })` 先开跑并立即答复用户,再用 `dsh_workplan_status` 查看进度;async 返回的是“已开跑”,不是“已完成”。',
|
|
44
47
|
'如果自动分解降级,先向用户说明失败原因并询问是否重试,在用户确认前不要开始执行任务。',
|
|
45
48
|
].join('\n');
|
|
49
|
+
/**
|
|
50
|
+
* Seconds a dispatch has been running, from the payload only.
|
|
51
|
+
*
|
|
52
|
+
* `elapsedMs` is authoritative; `startedAt` is the fallback for a payload that
|
|
53
|
+
* carries no elapsed value. Computing this inside the template mixed `??` with
|
|
54
|
+
* a conditional and could silently print the wrong number.
|
|
55
|
+
*/
|
|
56
|
+
function elapsedSeconds(result) {
|
|
57
|
+
const elapsed = Number(result?.elapsedMs);
|
|
58
|
+
if (Number.isFinite(elapsed) && elapsed >= 0)
|
|
59
|
+
return elapsed;
|
|
60
|
+
const startedAt = Number(result?.startedAt);
|
|
61
|
+
return Number.isFinite(startedAt) && startedAt > 0 ? Date.now() - startedAt : 0;
|
|
62
|
+
}
|
|
46
63
|
function textContent(text) {
|
|
47
64
|
return [{ type: 'text', text }];
|
|
48
65
|
}
|
|
@@ -92,6 +109,14 @@ function createUpdateTool(runtime) {
|
|
|
92
109
|
items: { type: 'string' },
|
|
93
110
|
description: '支持该状态的证据(文件、命令输出、验收结果)。',
|
|
94
111
|
},
|
|
112
|
+
expectedRevision: {
|
|
113
|
+
type: 'integer',
|
|
114
|
+
description: '你读取到的 revision。传入后若该子任务已被更新,会返回 STALE_WRITE 而不是覆盖新证据。',
|
|
115
|
+
},
|
|
116
|
+
force: {
|
|
117
|
+
type: 'boolean',
|
|
118
|
+
description: '计划执行中强行改判(默认拒绝并返回 TASK_RUNNING)。会记录为人工改判。',
|
|
119
|
+
},
|
|
95
120
|
note: {
|
|
96
121
|
type: 'string',
|
|
97
122
|
description: '补充说明;会显示在任务卡片中。',
|
|
@@ -108,7 +133,7 @@ function createUpdateTool(runtime) {
|
|
|
108
133
|
const text = result.ok
|
|
109
134
|
? `已更新子任务 ${String(result.subtaskId ?? '')}:${String(result.status ?? '')}`
|
|
110
135
|
+ `(完成 ${Number(stats.done ?? 0)}/${Number(stats.total ?? 0)},受阻 ${Number(stats.blocked ?? 0)})`
|
|
111
|
-
:
|
|
136
|
+
: `更新失败${result.code ? `(${String(result.code)})` : ''}:${String(result.error ?? result.hint ?? '未知错误')}`;
|
|
112
137
|
return textContent(text);
|
|
113
138
|
},
|
|
114
139
|
},
|
|
@@ -167,6 +192,43 @@ function createCancelTool(runtime) {
|
|
|
167
192
|
},
|
|
168
193
|
};
|
|
169
194
|
}
|
|
195
|
+
function createStatusTool(runtime) {
|
|
196
|
+
return {
|
|
197
|
+
name: 'dsh_workplan_status',
|
|
198
|
+
description: '只读查看当前计划各子任务的实时状态与进度,不启动任何 Agent、不改任何状态。'
|
|
199
|
+
+ '在 async 派发之后、或用户问“做到哪了”时使用;它是进度问题的唯一可信来源。',
|
|
200
|
+
parameters: {
|
|
201
|
+
type: 'object',
|
|
202
|
+
properties: {
|
|
203
|
+
planId: {
|
|
204
|
+
type: 'string',
|
|
205
|
+
description: '计划 ID;省略时使用当前会话最新计划。',
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
additionalProperties: false,
|
|
209
|
+
},
|
|
210
|
+
output: {
|
|
211
|
+
schema: statusToolOutputSchema(),
|
|
212
|
+
render(_args, value) {
|
|
213
|
+
const result = isRecord(value) ? value : {};
|
|
214
|
+
const stats = isRecord(result.stats) ? result.stats : {};
|
|
215
|
+
if (!result.ok)
|
|
216
|
+
return textContent(`查询失败:${String(result.error ?? '未知错误')}`);
|
|
217
|
+
const running = result.running === true;
|
|
218
|
+
return textContent(`计划 ${String(result.planId ?? '')}|${running ? '执行中' : '未在执行'}`
|
|
219
|
+
+ `|阶段:${phaseLabel(result.phase)}`
|
|
220
|
+
+ `|完成 ${Number(stats.done ?? 0)}/${Number(stats.total ?? 0)},受阻 ${Number(stats.blocked ?? 0)}`
|
|
221
|
+
+ (running && Number(result.elapsedMs ?? 0) > 0
|
|
222
|
+
? `|已 ${Math.round(Number(result.elapsedMs) / 1000)}s`
|
|
223
|
+
: ''));
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
async execute(args, exec) {
|
|
227
|
+
const parsed = asObject(args) ?? {};
|
|
228
|
+
return runtime.statusTool(exec.agent, parsed);
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
}
|
|
170
232
|
function createDispatchTool(runtime) {
|
|
171
233
|
return {
|
|
172
234
|
name: 'dsh_workplan_dispatch',
|
|
@@ -179,6 +241,12 @@ function createDispatchTool(runtime) {
|
|
|
179
241
|
type: 'string',
|
|
180
242
|
description: '计划 ID;省略时使用当前会话最新计划。',
|
|
181
243
|
},
|
|
244
|
+
mode: {
|
|
245
|
+
type: 'string',
|
|
246
|
+
enum: ['wait', 'async'],
|
|
247
|
+
description: '默认 wait:等本轮结束后返回完整结果。async:立即返回 running,'
|
|
248
|
+
+ '本轮结束时自动写入结果消息;期间用 dsh_workplan_status 查看进度。',
|
|
249
|
+
},
|
|
182
250
|
},
|
|
183
251
|
additionalProperties: false,
|
|
184
252
|
},
|
|
@@ -190,7 +258,10 @@ function createDispatchTool(runtime) {
|
|
|
190
258
|
return textContent(result.ok
|
|
191
259
|
? `计划 ${String(result.planId ?? '')} 当前阶段:${phaseLabel(result.phase)}`
|
|
192
260
|
+ `(完成 ${Number(stats.done ?? 0)}/${Number(stats.total ?? 0)},受阻 ${Number(stats.blocked ?? 0)})`
|
|
193
|
-
+ (result.alreadyRunning
|
|
261
|
+
+ (result.alreadyRunning || result.mode === 'async'
|
|
262
|
+
? `|已在执行(${Math.round(elapsedSeconds(result) / 1000)}s)`
|
|
263
|
+
: '')
|
|
264
|
+
+ (result.joined ? '|已加入进行中的派发并等到结果' : '')
|
|
194
265
|
// The hint carries the recovery instruction (resume, or take the work
|
|
195
266
|
// over directly); showing it in the rendered line keeps it visible
|
|
196
267
|
// even when only the summary is read.
|
|
@@ -243,6 +314,7 @@ export function apply(ctx, config = {}) {
|
|
|
243
314
|
}));
|
|
244
315
|
ctx.effect(() => ctx.tools.register(createUpdateTool(runtime)));
|
|
245
316
|
ctx.effect(() => ctx.tools.register(createCancelTool(runtime)));
|
|
317
|
+
ctx.effect(() => ctx.tools.register(createStatusTool(runtime)));
|
|
246
318
|
ctx.effect(() => ctx.tools.register(createDispatchTool(runtime)));
|
|
247
319
|
/*
|
|
248
320
|
* Plan mode produces a plan for review, not department execution. Denying
|
|
@@ -294,8 +366,8 @@ export function apply(ctx, config = {}) {
|
|
|
294
366
|
}
|
|
295
367
|
export const meta = {
|
|
296
368
|
name,
|
|
297
|
-
version: '1.
|
|
369
|
+
version: '1.7.0',
|
|
298
370
|
promptOrder: PROMPT_ORDER,
|
|
299
371
|
routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
|
|
300
372
|
};
|
|
301
|
-
export { PROMPT_SECTION, createCancelTool, createDispatchTool, createUpdateTool, plannerOutputSchema };
|
|
373
|
+
export { PROMPT_SECTION, createCancelTool, createDispatchTool, createStatusTool, createUpdateTool, plannerOutputSchema };
|