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/supersede.ts CHANGED
@@ -27,6 +27,7 @@
27
27
  * 防线。
28
28
  */
29
29
  import {
30
+ appendUserMessage,
30
31
  buildCancelMessage,
31
32
  derivePlanSnapshot,
32
33
  flattenSubtasks,
@@ -383,7 +384,7 @@ export function supersedePlanRecord(session: any, record: any, args: any, deps:
383
384
  return deny(SUPERSEDE_CODES.WRITE_FAILED, `构造取代记录失败:${error?.message ?? String(error)}`)
384
385
  }
385
386
  try {
386
- session.append('user/message', message, { surfaceOp: 'append' })
387
+ appendUserMessage(session, message)
387
388
  } catch (error: any) {
388
389
  record.errors = [...(Array.isArray(record?.errors) ? record.errors : []),
389
390
  `写入取代记录失败:${error instanceof Error ? error.message : String(error)}`].slice(-20)
@@ -1247,10 +1247,18 @@ export function auditTaskUnderstanding(plan: any, context: PlanAuditContext = {}
1247
1247
  const found = fromConversation ?? resolvePronounAntecedentInline(reference.token, taskText)
1248
1248
  if (!found) return reference
1249
1249
  // Option letters are resolved only when the conversation lists that option
1250
- // as a listed choice ("A 方案" / "B 选项"), not a bare letter in a word.
1250
+ // as a listed choice, not a bare letter in a word. Listed-choice markers:
1251
+ // "C 方案" / "C 选项" and the enumeration forms "C=…" / "C=…" / "C:…" /
1252
+ // "C、…" / "C)…" / "C)…" / "C.…" / "C.…" (marker must be followed by
1253
+ // content). Q10-style reports enumerate options as "A=… / B=… / C=…";
1254
+ // [2.2.6] the old regex only accepted 方案/选项, so a plain "选C" was
1255
+ // falsely judged unresolvable, burned two full planner attempts (~12 min
1256
+ // of silent planning in session-a404d49d) and degraded a legitimate task.
1251
1257
  // Task-text entities never satisfy this rule on their own: the option must
1252
1258
  // be defined where the user chose it, i.e. in the conversation.
1253
- const listedOption = new RegExp('(?:^|[^A-Za-z])' + reference.token + '\\s*(?:方案|选项)')
1259
+ const listedOption = new RegExp(
1260
+ '(?:^|[^A-Za-z])' + reference.token + '\\s*(?:方案|选项|=|=|:|:|、|\\)|)|\\.|.)\\s*\\S',
1261
+ )
1254
1262
  if (/^[A-D]$/.test(reference.token) && !listedOption.test(conversation)) return reference
1255
1263
  /*
1256
1264
  * [T3] Record where the referent came from. Reusing 'context' for an
package/src/watchdog.ts CHANGED
@@ -94,6 +94,28 @@ export function describeError(value: unknown): string {
94
94
  return String(value)
95
95
  }
96
96
 
97
+ /**
98
+ * Warning window floor: two minutes. The approaching-deadline window is
99
+ * `max(timeoutMs × 0.2, WARN_FLOOR_MS)` (O-4b, design doc §2.3/§2.6 #9).
100
+ */
101
+ const WARN_FLOOR_MS = 120_000
102
+
103
+ /**
104
+ * What `onApproachingDeadline` reports once per armed warning cycle (O-4b).
105
+ *
106
+ * The warning is a signal, never a gate (design doc §5.3「预警是提示,不是拦截」):
107
+ * this module cannot extend anything on its own, and the payload only reports
108
+ * facts so the caller can decide whether to grant `extendMs`.
109
+ */
110
+ export interface ApproachingDeadlineInfo {
111
+ /** Which subtask is nearing its ceiling (optional `subtaskId` input; '' when absent). */
112
+ subtaskId: string
113
+ /** Milliseconds left before the current ceiling fires. */
114
+ remainingMs: number
115
+ /** The ceiling currently in force, ms measured from the attempt start. */
116
+ timeoutMs: number
117
+ }
118
+
97
119
  /** One live progress watchdog around a single child execution. */
98
120
  export interface ProgressWatchdog {
99
121
  /** Rejects once with the PlanError built by `makeError`; never resolves. */
@@ -104,6 +126,17 @@ export interface ProgressWatchdog {
104
126
  lastProgressAt(): number
105
127
  /** How many times the observed session log grew. */
106
128
  progressEvents(): number
129
+ /**
130
+ * Push the absolute ceiling (ms from the attempt start) to `newHardMs` and
131
+ * re-arm the one-shot approaching-deadline warning (O-4d). The watchdog never
132
+ * moves the ceiling by itself — only an explicit call here does.
133
+ */
134
+ extend(newHardMs: number): void
135
+ /**
136
+ * Alias of `extend` under the T4/T5 parallel-construction contract name:
137
+ * identical semantics and implementation — new ceiling plus warning re-arm.
138
+ */
139
+ rearmApproachingDeadline(newTimeoutMs: number): void
107
140
  }
108
141
 
109
142
  /**
@@ -115,6 +148,9 @@ export interface ProgressWatchdog {
115
148
  * @param input.pollMs - observation period.
116
149
  * @param input.makeError - builds the rejection for the decided reason.
117
150
  * @param input.onProgress - called after each observed log growth.
151
+ * @param input.onApproachingDeadline - called once per armed cycle when the
152
+ * remaining time enters `max(timeoutMs × 0.2, WARN_FLOOR_MS)` before the ceiling (O-4b).
153
+ * @param input.subtaskId - reported back inside `onApproachingDeadline` info (optional).
118
154
  * @param input.now - clock, injectable for tests.
119
155
  * @returns a watchdog handle.
120
156
  */
@@ -125,6 +161,8 @@ export function createProgressWatchdog(input: {
125
161
  makeError: (reason: Exclude<TimeoutReason, null>) => Error
126
162
  pollMs?: number
127
163
  onProgress?: (info: { now: number; seq: number; elapsedMs: number }) => void
164
+ onApproachingDeadline?: (info: ApproachingDeadlineInfo) => void
165
+ subtaskId?: string
128
166
  now?: () => number
129
167
  }): ProgressWatchdog {
130
168
  const clock = input.now ?? (() => Date.now())
@@ -134,6 +172,12 @@ export function createProgressWatchdog(input: {
134
172
  let lastSeq: number | null = null
135
173
  let growth = 0
136
174
  let settled = false
175
+ // [2.2.0][O-4b/O-4d] Absolute ceiling (ms from `startedAt`) currently in
176
+ // force. Only `rearm` below moves it — the warning itself never extends
177
+ // anything, so an un-extended ceiling still settles as `exhausted`.
178
+ let hardMs = Math.max(1, Math.floor(input.hardMs))
179
+ // [2.2.0][O-4b] One-shot warning latch per armed cycle; cleared by `rearm`.
180
+ let warned = false
137
181
  let timer: ReturnType<typeof setInterval> | null = null
138
182
  let rejectOnce: (error: Error) => void = () => {}
139
183
 
@@ -154,6 +198,34 @@ export function createProgressWatchdog(input: {
154
198
  rejectOnce(input.makeError(reason))
155
199
  }
156
200
 
201
+ // [2.2.0][O-4d] 推移绝对上限(自尝试起点计)并重新武装一次性预警。
202
+ // 看门狗自身没有延期能力:只有调用方显式调用才会动上限
203
+ // (design doc §5.3「预警是提示,不是拦截」)。
204
+ const rearm = (newTimeoutMs: number) => {
205
+ if (settled || !Number.isFinite(newTimeoutMs)) return
206
+ hardMs = Math.max(1, Math.floor(newTimeoutMs))
207
+ warned = false
208
+ }
209
+
210
+ // [2.2.0][O-4b] 即将超时预警:剩余 ≤ max(timeoutMs × 0.2, WARN_FLOOR_MS)
211
+ // (取大者)且到点之前(remainingMs > 0,D1「到点之前到达」)时触发一次;
212
+ // 同一武装周期内幂等(warned 闩锁),rearm 后按新时限重新武装。
213
+ const warnApproachingDeadline = (now: number) => {
214
+ if (warned || !input.onApproachingDeadline) return
215
+ const remainingMs = hardMs - (now - startedAt)
216
+ if (remainingMs <= 0 || remainingMs > Math.max(hardMs * 0.2, WARN_FLOOR_MS)) return
217
+ warned = true
218
+ try {
219
+ input.onApproachingDeadline({
220
+ subtaskId: input.subtaskId ?? '',
221
+ remainingMs,
222
+ timeoutMs: hardMs,
223
+ })
224
+ } catch {
225
+ // An observer must never break the watchdog.
226
+ }
227
+ }
228
+
157
229
  const poll = () => {
158
230
  if (settled) return
159
231
  const now = clock()
@@ -177,12 +249,13 @@ export function createProgressWatchdog(input: {
177
249
  }
178
250
  }
179
251
  }
252
+ warnApproachingDeadline(now)
180
253
  const reason = pickTimeoutReason({
181
254
  now,
182
255
  startedAt,
183
256
  lastProgressAt: lastProgress,
184
257
  idleMs: Math.max(1, Math.floor(input.idleMs)),
185
- hardMs: Math.max(1, Math.floor(input.hardMs)),
258
+ hardMs,
186
259
  progressObservable: lastSeq !== null,
187
260
  })
188
261
  if (reason) finish(reason)
@@ -203,5 +276,11 @@ export function createProgressWatchdog(input: {
203
276
  },
204
277
  lastProgressAt: () => lastProgress,
205
278
  progressEvents: () => growth,
279
+ extend: (newHardMs: number) => {
280
+ rearm(newHardMs)
281
+ },
282
+ rearmApproachingDeadline: (newTimeoutMs: number) => {
283
+ rearm(newTimeoutMs)
284
+ },
206
285
  }
207
286
  }
package/README.zh.md DELETED
@@ -1,239 +0,0 @@
1
- # dsh-workplan
2
-
3
- > **两个卖点,一句话:ISO/IEC 15408:2026 全套安全证据,5 条命令自己验;安装一条命令、零第三方运行时依赖。**
4
-
5
- [![verify](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml/badge.svg)](https://github.com/abbaababa/dsh-workplan/actions/workflows/verify.yml)
6
- [![version](https://img.shields.io/badge/version-2.1.5-blue.svg)](https://github.com/abbaababa/dsh-workplan/releases/tag/v2.1.5)
7
-
8
- 给 **DeepSeek Harness(DSH)** 加一段「先拆计划 → 真派部门子 Agent 去做 → 左侧栏实时看进度」的能力。不装 App、不改 DSH 源码、不换页面。
9
-
10
- - 对话里先出【任务分解】:阶段、子任务、部门、验收标准,一样不缺
11
- - 最多 5 个真实子 Agent 并行执行,结果写回会话
12
- - 左侧栏「任务进度」:谁在做、做到哪、哪件卡住了
13
-
14
- **English (US) — plain-language guide:** [README.en.md](README.en.md)
15
-
16
- ---
17
-
18
- ## 为什么敢拿 ISO/IEC 15408 当卖点,又不算吹牛
19
-
20
- **CC(Common Criteria,ISO/IEC 15408)的规矩是三方分工:开发者交材料 → 独立实验室评测 → 国家机构发证。软件不能给自己发证。** 所以「本插件已通过 CC 认证」这句话,没有证书编号就是假的——这种话我们不说。
21
-
22
- 我们做的是能自己做的那一半:**按 2026 版(不是 2022 版)标准的结构,把材料真做出来、公开出来,任何人都能自己核对。**
23
-
24
- | 我们公开的 | 对应标准 | 在哪儿 |
25
- |---|---|---|
26
- | 保护什么、防谁、边界在哪 | 安全目标(ST) | [docs/cc/SECURITY-TARGET.md](docs/cc/SECURITY-TARGET.md) |
27
- | 攻击面、7 条威胁、对策、残留风险 | 脆弱性评定(AVA) | [docs/cc/AVA-VULNERABILITY-ANALYSIS.md](docs/cc/AVA-VULNERABILITY-ANALYSIS.md) |
28
- | 逐类对照 + EAL1 就绪度 + 还缺什么 | 自评估 | [docs/cc/CC-2026-ASSESSMENT.md](docs/cc/CC-2026-ASSESSMENT.md) |
29
- | 第三方组件、许可证、哈希 | 生命周期(ALC) | [docs/SBOM.md](docs/SBOM.md) |
30
- | 漏洞怎么报、多久回、部署怎么配 | 安全策略 | [SECURITY.md](SECURITY.md) |
31
- | 470 项自动化测试(2026-11-03 独立复检实测 470/470 全绿),一条命令复跑 | 测试(ATE) | `npm run verify` |
32
-
33
- 现状(2026-11-03 独立复检报告结论,33 条差距逐条复核):**26 条已关闭(通过);4 条经判定为「不适用或固有残留」且判定本身成立;1 条(发布包 sha256 数值)属发布期执行件,脚本已就绪、随发布公布**。无新发现的代码类缺口。**必须如实披露的固有残留**:`ATE_IND.1`(测试执行需认可实验室见证)与 `AVA_VAN.2+`(独立渗透评测)——按 CC 规则只能由认可实验室完成,本项目以「公开自评估」口径如实标注,任何宣传材料都不省略这条。
34
-
35
- 版本口径(两个头都有官方来源佐证):证据包按 **ISO/IEC 15408:2026**(已列入 ISO 官方目录)的结构编写;现行国家认证体系(如德国 BSI)受理的版本仍为 **CC:2022**。所以我们说「**对齐 2026 结构、认证体系现行受理 CC:2022,公开全套自评证据 + 完整安装使用方法**」,不说「已通过 CC 认证」。
36
-
37
- 自己验,3 行,复制即用:
38
-
39
- ```bash
40
- git clone https://github.com/abbaababa/dsh-workplan.git && cd dsh-workplan
41
- npm ci && npm run verify # 期望:tests 470 / pass 470 / fail 0
42
- grep -RInE "child_process|execSync|eval\(|writeFileSync" src || echo "0 命中(预期)"
43
- ```
44
-
45
- > 一句话记住:**有证书是第三方给的,有证据是自己挣的。**
46
- >
47
- > **自我更正记录**:v1.8.1 公开更正了 v1.8.0 里三处「文档写得比代码多」的地方(图表路由其实不鉴权、自测并未覆盖鉴权与截断分支、EAL1 矩阵把一个自相矛盾的组件判成就绪),详情见 [CHANGELOG](CHANGELOG.md) 与 [自评估 §6.1](docs/cc/CC-2026-ASSESSMENT.md)。
48
-
49
- ## 它到底做了什么(用大白话讲)
50
-
51
- 平时你给 AI 一个复杂任务,它经常「一边想一边做」,做到一半你才发现方向不对。
52
-
53
- 这个插件把节奏改成三拍:
54
-
55
- 1. **先排计划**:你发出任务后、AI 真正动手前,它先写一份计划——分几个阶段、每个阶段几件具体工作、每件工作交给哪个部门、怎么做、什么算做完、可能卡在哪。
56
- 2. **计划先给你看**:这份计划以「任务分解」的形式出现在对话里,包含每一步的依据与验收标准,而不是一句话糊过去。
57
- 3. **真的派人去做**:确认后,每一件具体工作交给一个**真实的 DSH 子 Agent** 去执行(最多 5 个同时跑),结果写回会话;你在左侧栏「任务进度」里随时能看到谁在做、做到哪、哪件卡住了。
58
-
59
- 计划不是装饰品:主 Agent 必须先派发、等到部门结果回来,才能继续往下答。
60
-
61
- ## 装之前你需要什么
62
-
63
- | 要求 | 说明 |
64
- |---|---|
65
- | DeepSeek Harness | 官方 Web 版(`dsh web` / `--profile web` 跑的这套) |
66
- | Node.js | **22 或更高**(`node -v` 自查) |
67
- | 网络 | 安装时需要能访问 npm registry |
68
-
69
- ## 一键安装
70
-
71
- ```bash
72
- dsh plugin --profile web add dsh-workplan@2.1.5
73
- ```
74
-
75
- 装完**重启一次 DSH Web**(或重新载入当前页面)让插件生效。
76
-
77
- 没有 `dsh` 命令的话,先确认它在 PATH 里;用 `npx` 起的 DSH 可以直接用完整路径调用同一个 `dsh`。
78
-
79
- ### 从源码安装(可选,想改代码时用)
80
-
81
- ```bash
82
- git clone https://github.com/abbaababa/dsh-workplan.git
83
- cd dsh-workplan
84
- npm ci && npm run build
85
- dsh plugin --profile web add "$(pwd)"
86
- ```
87
-
88
- ## 装好以后怎么用(小白版)
89
-
90
- 1. 打开 DSH Web,随便发一个**有实际目标**的任务,例如「帮我把这个目录的测试补到 80% 覆盖」。
91
- 2. 等一两秒,对话里会出现一块【任务分解】:阶段、子任务、部门、验收标准齐全。
92
- 3. 你只需要正常对话;主 Agent 会按规则派发计划,遇到要拍板的地方会问你。
93
- 4. 点左侧栏的**「任务进度」**,就能看到:
94
-
95
- - 顶部五个数字:**几个任务 / 分配了多少件工作 / 做好了 / 正在做 / 卡住了**;
96
- - 计划卡:分「进行中」「已结束」「已完成」三组,右上角是完成率。「已结束」= 这一轮已经停了(没有东西在跑)但计划还没做完,卡片会写清停在哪儿(预算用完 / 卡住了 / 还没开始),说一句「继续」即可接着推进;
97
- - 展开任意计划:每个阶段的进度、每件具体工作由哪个部门负责、当前状态。
98
-
99
- 5. 进度数字背后的每一行,都来自同一份任务状态——**不会再出现「显示 0 个正在做、但下面明明写着正在做」这种自相矛盾**(1.4.3 专门修的就是这个,见下文)。
100
-
101
- 纯打招呼、道谢、问「做到哪了」不会触发拆解,不会平白多出一堆子 Agent。
102
-
103
- ## 九个模型工具(你不用直接调用)
104
-
105
- | 工具 | 作用 |
106
- |---|---|
107
- | `dsh_workplan_dispatch` | 派发当前计划,把结果写回会话。默认 `mode:"wait"` 等结束;`mode:"async"` 立刻返回、后台继续。重复调用是幂等的。 |
108
- | `dsh_workplan_status` | 只读:问到哪了。重启或刷新后也能从会话记录重建。 |
109
- | `dsh_workplan_update` | 主 Agent 核对结果、修正某个子任务状态与证据。带 `expectedRevision` 防覆盖,运行中默认拒绝(`force:true` 才覆盖)。子 Agent 不能调用。 |
110
- | `dsh_workplan_cancel` | 取消还没派发的计划,不会伪造任何「已完成」。 |
111
- | `dsh_workplan_replan` | 需求变更时就地修订:`cancel` / `replace` / `add`,旧行标为「已取代」保留可追溯,计划版本号递增。主 Agent 专用。 |
112
- | `dsh_workplan_escalate` | 子 Agent 执行中遇阻上报:问题、选项、建议进状态机,等主 Agent 指示;不再是「只能憋到结尾写 BLOCKED」。 |
113
- | `dsh_workplan_instruct` | 主 Agent 回答请示并下达指示;失败则挂起,子任务下次激活时注入。带 60s/180s 回执检查。 |
114
- | `dsh_workplan_handoff` | 处置跨部门需求:`list` / `assign` / `resolve` / `close`。未处置会拦住交付;对「待指示」的行 `resolve` 会直接把答复投递给子会话。 |
115
- | `dsh_workplan_followup` | 给预算/超时中止、但产物已落盘的直接子会话补一条收尾说明。 |
116
-
117
- 在 **plan 模式**下只会给你看计划,`dispatch` 会被明确拦下并说明原因,不会偷偷开跑。
118
-
119
- ## 部门怎么协作(1.11.0 的真实能力)
120
-
121
- 计划里的每件工作都带一个部门标签(工程研发、研究分析、设计、产品、数据、质量验证、安全、运维、文档写作、运营、法务合规、财务)。**标签决定提示词与统计口径,不是组织架构**:
122
-
123
- - 部门之间**不能直接对话**(这是刻意的权限边界);跨部门信息由主 Agent 转达,或落到双方都能读的工作区文件。但每个子 Agent 的提示词里会带上**兄弟部门的只读一览**(谁、做什么、产出什么、已完成摘要),需要协作就写进 `needs`;每条 needs 会自动登记成带编号的跨部门需求(`open → routed → answered/closed`),结果消息与 `status` 都能看到,**未处置就拦住交付**。主 Agent 用 `dsh_workplan_handoff` 逐条处置;提出需求的行若正在等指示,`resolve` 会把答复直接投递给该子会话。
124
- - 下游只看到 `dependsOn` 里上游的**摘要**与完整体检结果,看不到上游的完整对话。所以上游必须把「产物绝对路径 + 怎么验收」写进摘要;声明为 `file` 的产物会被逐个核实,**缺失就不给下游解锁**。
125
- - 子 Agent 在输出末尾回传结构化证据块(`status` / `acceptance` / `artifacts` / `needs`)。**非空输出不再等于完成**:`partial`、任一条验收失败、坏块都判受阻,只有全 `pass` 才可直接采信,其余在结果消息里标「未验证」等主 Agent 核对。
126
- - 阶段(stage)只是展示分组,**不是执行门槛**;真正决定先后的是 `dependsOn`。
127
-
128
- 完整的角色、数据契约、状态机、失败恢复与「改代码时必须同步的三处」,见 **[协作契约](https://github.com/abbaababa/dsh-workplan/blob/main/docs/collaboration.md)**;12 个部门的职责与交接清单见 **[部门职责与交接约定](https://github.com/abbaababa/dsh-workplan/blob/main/docs/departments.md)**。
129
-
130
- ## 预算、超时与续跑(知道这些就不会误以为卡死)
131
-
132
- | 项 | 默认值 | 怎么改 |
133
- |---|---|---|
134
- | 单轮派发预算 | 20 分钟 | `DSH_WORKPLAN_TOTAL_TIMEOUT_MS` |
135
- | 单个子 Agent 上限 | 15 分钟 | `DSH_WORKPLAN_CHILD_TIMEOUT_MS` |
136
- | 子 Agent 无进展判定 | 5 分钟 | `DSH_WORKPLAN_IDLE_TIMEOUT_MS` |
137
- | 自动续跑次数 | 4 次 | `DSH_WORKPLAN_MAX_RESUMES` |
138
- | 并发子 Agent | 5 个(固定) | — |
139
-
140
- 预算用尽不是失败:计划会变成「**本轮预算用尽,可续跑**」,已完成的不重跑,剩下的下次接着做。被判定卡住的子任务只卡它自己,不会拖垮整个计划;重试只会发生一次,第二次的提示词会带上一次的失败原因,不会原样重撞。
141
-
142
- 环境变量写在启动 DSH 的那个 shell 里,或者写进插件配置:
143
-
144
- ```jsonc
145
- // cordis.patch.yml 里的 config 字段
146
- { "totalTimeoutMs": 1800000 } // 30 分钟
147
- ```
148
-
149
- ## 安全与隐私(可以自己复核)
150
-
151
- - **没有第三方运行时依赖**:`dependencies` 是空的;装出来的只有这个插件自己的 JS、配置、图标和说明。
152
- - **不写你的磁盘**:源码里没有任何 `writeFileSync` / `appendFileSync` / `mkdirSync`(可 `grep` 验证);结果只写进 DSH 会话记录。
153
- - **不向外发数据**:源码里没有 `child_process`、没有对外 `fetch`/`http.request`;唯一的一次 `fetch` 是浏览器端请求**同源**的 `/dsh-workplan/plans`。
154
- - **面板数据要登录**:该路由走 DSH 自己的鉴权,未登录直接返回 401。
155
- - **图表库是本地自带**:`vendor/chart.umd.js`(Chart.js 4.6.1,MIT)随包分发,不加载任何 CDN 脚本。
156
-
157
- 自己复核:
158
-
159
- ```bash
160
- npm view dsh-workplan@latest dependencies # 应为空
161
- grep -RInE "writeFileSync|child_process|eval\(" src # 应无命中
162
- npm audit --omit=dev
163
- ```
164
-
165
- <details>
166
- <summary><b>1.5.0 改了什么(进度一眼可见)</b>(点开看)</summary>
167
-
168
- 1.5.0 只改展示层:把计划卡折叠态那行「本计划 0/8 做好了 + 一根 54×5px 的小条」换成图表组合。
169
-
170
- | 位置 | 改前 | 改后 |
171
- |---|---|---|
172
- | 折叠中的计划卡 | 12px 灰字 + 迷你条 + 「0 卡住了」;百分比只在鼠标悬停的 `title` 里 | 44px 环形图 + 24px 百分比 + `本计划 X/Y 做好了` + 一行「现在在做什么」(卡住优先,带任务名)+ 8px 四段构成条 + 状态图例 + 阶段步进条 |
173
- | 展开后的面板 | 一根计划级进度条 | 「分步进度」:每个阶段一行(名称、`完成/总数`、细条、状态),外加加权总体进度 |
174
- | 0% 的计划 | 迷你条填充宽度为 0,轨道又与卡片底色用同一个 token,等于没有图 | 四层信号:加粗的环轨、24px「0%」、整条灰色的「还没开始」构成条、虚线阶段槽 + 当前阶段描边 |
175
- | 0 个工作项的组头 | `未完成 0 / 已完成 0(完成率暂无数据)` | 整句删除,只留环上的 `—`;组内空态仍在(展开可见) |
176
-
177
- 「卡住了」这类数字一个都没少,只是换了呈现:图例始终是 `做好了 / 正在做 / 卡住了 / 还没开始` 四项带数字。
178
-
179
- **怎么看到效果**:插件的前端在 `client.js` 里,DSH Web 进程启动时加载它,所以先重启 DSH Web,再刷新 <http://127.0.0.1:3080>。不想改环境也能离线看对比:打开 [docs/preview/progress-visual-1.5.0.html](docs/preview/progress-visual-1.5.0.html)(`npm run preview` 可重新生成,它用同一份 CSS 渲染 1.4.3 与 1.5.0 的卡头)。
180
-
181
- 没有新增依赖,`plan.ts` / `runtime.ts` 无改动;回滚方式见 [CHANGELOG.md](CHANGELOG.md)。
182
-
183
- </details>
184
-
185
- <details>
186
- <summary><b>1.4.3 修了什么(为什么值得升级)</b>(点开看)</summary>
187
-
188
- 1.4.3 是一次**计数一致性**修复:插件曾同时维护「实时任务状态」和「缓存的统计快照」两份真相,导致面板数字和实际状态对不上(截图里「0 个正在做」但下面有任务正在做,就是它)。
189
-
190
- | 缺陷 | 表现 | 根因 |
191
- |---|---|---|
192
- | D1 | 面板数字长时间不更新 | 统计只在整批子 Agent 跑完后才重算,运行期间冻结 |
193
- | D2 | 同一份数据里两个数字互相矛盾 | 计数来自缓存,部门聚合来自实时状态 |
194
- | D3 | 「还没开始」的任务却显示 100%、带着上一次的执行者 | 预算重置绕过了状态机,旧字段没清 |
195
- | D4 | 同一类失败,进度有时 100 有时 0 | 两处代码对「卡住」的进度语义不一致 |
196
-
197
- 修法是**删掉缓存快照,只保留一份状态源**:所有数字在序列化时由同一函数现场派生,并配了 7 条不变量 + 变异测试防止回退。完整报告:[docs/fix-report-derived-counts-1.4.3.md](docs/fix-report-derived-counts-1.4.3.md)。
198
-
199
- </details>
200
-
201
- ## 常见问题
202
-
203
- **装完没反应?**
204
- 先重启 DSH Web;再确认 `~/.dsh/profiles/web/package.json` 的依赖里有 `dsh-workplan`。
205
-
206
- **面板一直是空的?**
207
- 面板只显示**当前会话**的计划。换一个会话、或这个会话还没产生计划时是空的,这是正常的。
208
-
209
- **数字和以前不一样了?**
210
- 1.4.3 之后数字来自真实状态而不是缓存,所以会比旧版本「更小、但更准」(旧版本的完成率经常虚高)。
211
-
212
- **子 Agent 卡住不动?**
213
- 5 分钟没有任何新事件会被判定卡住并单独标红;对主 Agent 说「续跑这个计划」即可从受阻处继续。
214
-
215
- ## 卸载
216
-
217
- ```bash
218
- dsh plugin --profile web remove dsh-workplan
219
- ```
220
-
221
- ## 开发与验证
222
-
223
- ```bash
224
- npm ci
225
- npm run check # tsc --noEmit
226
- npm test # 全部测试(数量随版本变化,以命令输出与 CI 为准),含计数不变量与进度图表用例
227
- npm run build # 编译 src/*.ts → lib/*.js、client.js
228
- npm run preview # 重新生成 docs/preview 里的 1.4.3 / 1.5.0 卡头对比页
229
- ```
230
-
231
- `lib/` 与 `client.js` 是**提交进仓库的构建产物**,CI 会重建并校验二者无差异。
232
-
233
- ## 许可证
234
-
235
- MIT,见 [LICENSE](LICENSE)。Chart.js 亦为 MIT。
236
-
237
- ---
238
-
239
- **English (US) — plain-language guide:** [README.en.md](README.en.md)