dsh-workplan 1.9.1 → 1.11.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 +317 -0
- package/README.en.md +8 -3
- package/README.md +9 -4
- package/client.js +195 -8
- package/docs/collaboration.md +16 -5
- package/docs/departments.md +2 -2
- package/docs/release-record-1.10.6-20261101.md +78 -0
- package/lib/auto-resume.js +175 -0
- package/lib/client.js +2742 -0
- package/lib/host.js +451 -4
- package/lib/plan.js +1011 -46
- package/lib/replan.js +602 -0
- package/lib/runtime.js +1826 -61
- package/package.json +2 -2
- package/src/auto-resume.ts +246 -0
- package/src/client.ts +212 -7
- package/src/host.ts +492 -3
- package/src/plan.ts +967 -41
- package/src/replan.ts +642 -0
- package/src/runtime.ts +1819 -57
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workplan",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
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",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"clean": "rm -rf dist dist-tests",
|
|
68
|
-
"build": "rm -rf dist && tsc -p tsconfig.json && cp dist
|
|
68
|
+
"build": "rm -rf dist && tsc -p tsconfig.json && cp dist/*.js lib/ && cp dist/client.js client.js",
|
|
69
69
|
"check": "tsc -p tsconfig.json --noEmit",
|
|
70
70
|
"test": "npm run build && rm -rf dist-tests && tsc -p tsconfig.test.json && node --test dist-tests/tests/*.test.js",
|
|
71
71
|
"verify": "npm run check && npm test",
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [1.10.4][auto-resume] Automatic continuation of a plan whose round budget ran out.
|
|
3
|
+
*
|
|
4
|
+
* Why this module exists
|
|
5
|
+
* ----------------------
|
|
6
|
+
* The 2026-11-01 incident: subtask T12 was killed by the whole-round budget
|
|
7
|
+
* (`TOTAL_TIMEOUT`, 20 min) at 15:31:26, reset to `pending`, and then **never
|
|
8
|
+
* ran again** — the plan stayed `paused` until a human dispatched it 24 minutes
|
|
9
|
+
* later. `shouldRetryAttempt()` is right to refuse `ABORTED`/`TOTAL_TIMEOUT`
|
|
10
|
+
* *inside* a round: that round has no budget left, so a retry would be cut by
|
|
11
|
+
* the same blade. The missing layer is not "retry the child"; it is
|
|
12
|
+
* "start the next round" — a new deadline, the same plan, and `done` work
|
|
13
|
+
* never re-run.
|
|
14
|
+
*
|
|
15
|
+
* This module owns only the decision table (`should we continue?`). It is a
|
|
16
|
+
* pure function with no timer, no I/O and no record mutation, so every branch
|
|
17
|
+
* can be pinned by a unit test without mounting the host. The runtime supplies
|
|
18
|
+
* the bookkeeping; `src/runtime.ts` owns the timer.
|
|
19
|
+
*
|
|
20
|
+
* Safety stance (the reason it is more than a loop)
|
|
21
|
+
* -------------------------------------------------
|
|
22
|
+
* Automatic recovery must never manufacture a green result. Therefore:
|
|
23
|
+
* - it only ever continues a `paused` plan; `blocked` means a real failure and
|
|
24
|
+
* is repaired by a human adjudication or the resume budget, never silently;
|
|
25
|
+
* - `done` rows are never re-run (the resumer calls `resetBlockedStatuses`,
|
|
26
|
+
* which only clears blocked/in_progress, and a paused round leaves them
|
|
27
|
+
* `pending`);
|
|
28
|
+
* - it never adjudicates evidence: every continuation goes through the normal
|
|
29
|
+
* child path (`settleFromOutput` → `deliveryReadiness`), so "all done" is
|
|
30
|
+
* still decided by structured evidence;
|
|
31
|
+
* - "all done but evidence gaps" stops here on purpose (`NOTHING_PENDING`):
|
|
32
|
+
* re-running a done subtask cannot fix a missing acceptance item, it only
|
|
33
|
+
* produces duplicate work and a chance to overwrite the evidence.
|
|
34
|
+
*
|
|
35
|
+
* Default: **off**. See `AUTO_RESUME_DEFAULTS.enabled`.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/** Tunables that are policy, not deployment config. */
|
|
39
|
+
export const AUTO_RESUME_DEFAULTS = Object.freeze({
|
|
40
|
+
/**
|
|
41
|
+
* [1.10.6] On by default.
|
|
42
|
+
*
|
|
43
|
+
* The 2026-11-01 user verdict on the previous "off by default" stance was
|
|
44
|
+
* unambiguous: a subtask killed by the round budget sat untouched for 1h57m
|
|
45
|
+
* and the only reason was a flag nobody had been told to flip. A recovery
|
|
46
|
+
* feature that ships silent is indistinguishable from a missing one.
|
|
47
|
+
*
|
|
48
|
+
* Every safety branch below still applies when this is on (cancel, plan mode,
|
|
49
|
+
* blocked rows, no-progress, attempt cap), and `autoResume: false` in the
|
|
50
|
+
* profile or `DSH_WORKPLAN_AUTO_RESUME=0` turns it off for one deployment.
|
|
51
|
+
*/
|
|
52
|
+
enabled: true,
|
|
53
|
+
/** How many continuation rounds one plan may start without a human. */
|
|
54
|
+
maxAttempts: 2,
|
|
55
|
+
/** Delay before the first continuation round. */
|
|
56
|
+
baseDelayMs: 30_000,
|
|
57
|
+
/** Upper bound of the exponential backoff. */
|
|
58
|
+
maxDelayMs: 300_000,
|
|
59
|
+
/** Consecutive continuation rounds that completed no new subtask before stopping. */
|
|
60
|
+
stallLimit: 1,
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
/** Hard cap for a configured attempt budget (0 disables the chain). */
|
|
64
|
+
export const AUTO_RESUME_MAX_ATTEMPTS_CAP = 4
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Clamp a configured attempt budget.
|
|
68
|
+
*
|
|
69
|
+
* Non-numeric input falls back to the default instead of disabling the feature
|
|
70
|
+
* silently; only an explicit in-range number is honoured.
|
|
71
|
+
*
|
|
72
|
+
* @param value - configured value, if any.
|
|
73
|
+
* @returns an integer within `[0, AUTO_RESUME_MAX_ATTEMPTS_CAP]`.
|
|
74
|
+
*/
|
|
75
|
+
export function autoResumeAttemptCap(value: any) {
|
|
76
|
+
const numeric = Number(value)
|
|
77
|
+
if (!Number.isFinite(numeric)) return AUTO_RESUME_DEFAULTS.maxAttempts
|
|
78
|
+
return Math.min(AUTO_RESUME_MAX_ATTEMPTS_CAP, Math.max(0, Math.floor(numeric)))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* [1.10.6] Resolve the feature flag from profile config + environment.
|
|
83
|
+
*
|
|
84
|
+
* Explicit config wins; an explicit environment value wins over the default;
|
|
85
|
+
* anything unset falls back to `AUTO_RESUME_DEFAULTS.enabled` (now true).
|
|
86
|
+
* Values are read the same way for both sources so `0/false/no/off` turn it off
|
|
87
|
+
* instead of being treated as "present, therefore on".
|
|
88
|
+
*
|
|
89
|
+
* @param configValue - `autoResume` from the profile config, if any.
|
|
90
|
+
* @param envValue - `DSH_WORKPLAN_AUTO_RESUME`, if set.
|
|
91
|
+
* @returns whether automatic continuation rounds are allowed.
|
|
92
|
+
*/
|
|
93
|
+
export function autoResumeEnabledFrom(configValue: any, envValue: any) {
|
|
94
|
+
if (typeof configValue === 'boolean') return configValue
|
|
95
|
+
const raw = envValue === undefined || envValue === null ? '' : String(envValue).trim()
|
|
96
|
+
if (raw !== '') {
|
|
97
|
+
if (/^(1|true|yes|on)$/i.test(raw)) return true
|
|
98
|
+
if (/^(0|false|no|off)$/i.test(raw)) return false
|
|
99
|
+
}
|
|
100
|
+
return AUTO_RESUME_DEFAULTS.enabled === true
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** `schedule` = arm the next round; `stop` = leave the plan to a human. */
|
|
104
|
+
export type AutoResumeAction = 'schedule' | 'stop'
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Why the machine stopped. Stable strings: the status tool exposes them and
|
|
108
|
+
* tests assert on the literal values.
|
|
109
|
+
*/
|
|
110
|
+
export type AutoResumeCode =
|
|
111
|
+
| 'SCHEDULED'
|
|
112
|
+
| 'AUTO_RESUME_DISABLED'
|
|
113
|
+
| 'NO_PLAN'
|
|
114
|
+
| 'CANCELLED'
|
|
115
|
+
| 'SUPERSEDED'
|
|
116
|
+
| 'ALREADY_RUNNING'
|
|
117
|
+
| 'PLAN_MODE'
|
|
118
|
+
| 'PHASE_NOT_PAUSED'
|
|
119
|
+
| 'NOTHING_PENDING'
|
|
120
|
+
| 'HAS_BLOCKED'
|
|
121
|
+
| 'BUDGET_EXHAUSTED'
|
|
122
|
+
| 'NO_PROGRESS'
|
|
123
|
+
|
|
124
|
+
/** Everything the decision needs; all fields are primitives by design. */
|
|
125
|
+
export interface AutoResumeInput {
|
|
126
|
+
/** Feature flag. */
|
|
127
|
+
enabled: boolean
|
|
128
|
+
/** `record.phase` at the moment the round ended. */
|
|
129
|
+
phase: string
|
|
130
|
+
/** The user stopped this plan. */
|
|
131
|
+
cancelled: boolean
|
|
132
|
+
/** Automatic decomposition degraded; there is no usable plan. */
|
|
133
|
+
degraded: boolean
|
|
134
|
+
/** The session is in plan mode (a plan is for review, not execution). */
|
|
135
|
+
planMode: boolean
|
|
136
|
+
/** A dispatch is still in flight. */
|
|
137
|
+
running: boolean
|
|
138
|
+
/** Defined subtasks. */
|
|
139
|
+
total: number
|
|
140
|
+
/** Subtasks currently `done`. */
|
|
141
|
+
done: number
|
|
142
|
+
/** Subtasks currently `pending`. */
|
|
143
|
+
pending: number
|
|
144
|
+
/** Subtasks currently `blocked`. */
|
|
145
|
+
blocked: number
|
|
146
|
+
/** Continuation rounds already started by this machine. */
|
|
147
|
+
attempt: number
|
|
148
|
+
/** Configured continuation budget. */
|
|
149
|
+
maxAttempts: number
|
|
150
|
+
/** Consecutive continuation rounds that added no `done` row. */
|
|
151
|
+
noProgressRounds: number
|
|
152
|
+
/** Stop after this many stalled rounds. */
|
|
153
|
+
stallLimit: number
|
|
154
|
+
/** Backoff base. */
|
|
155
|
+
baseDelayMs: number
|
|
156
|
+
/** Backoff ceiling. */
|
|
157
|
+
maxDelayMs: number
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface AutoResumeDecision {
|
|
161
|
+
action: AutoResumeAction
|
|
162
|
+
code: AutoResumeCode
|
|
163
|
+
/** Human/model readable; goes into `record.errors` and the status tool. */
|
|
164
|
+
reason: string
|
|
165
|
+
/** Attempt index of the round that would start (unchanged when stopping). */
|
|
166
|
+
attempt: number
|
|
167
|
+
/** Delay before that round; `0` when stopping. */
|
|
168
|
+
delayMs: number
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Decide whether one more round may start, and when.
|
|
173
|
+
*
|
|
174
|
+
* Branch order is the contract (first match wins):
|
|
175
|
+
* 1. feature flag / no plan
|
|
176
|
+
* 2. user stop (`cancelled`, `superseded`) — never resurrect a decision
|
|
177
|
+
* 3. already running / plan mode
|
|
178
|
+
* 4. only a `paused` phase is auto-continuable
|
|
179
|
+
* 5. nothing pending (includes "all done, evidence gap" — human work)
|
|
180
|
+
* 6. any `blocked` row — a real failure, not a budget artifact
|
|
181
|
+
* 7. attempt / progress budgets
|
|
182
|
+
*
|
|
183
|
+
* @param input - the frozen facts of the round that just ended.
|
|
184
|
+
* @returns the decision plus a model-readable reason.
|
|
185
|
+
*/
|
|
186
|
+
export function decideAutoResume(input: AutoResumeInput): AutoResumeDecision {
|
|
187
|
+
const attempt = Math.max(0, Math.floor(Number(input.attempt) || 0))
|
|
188
|
+
const maxAttempts = Math.max(0, Math.floor(Number(input.maxAttempts) || 0))
|
|
189
|
+
const stop = (code: AutoResumeCode, reason: string): AutoResumeDecision => ({
|
|
190
|
+
action: 'stop',
|
|
191
|
+
code,
|
|
192
|
+
reason,
|
|
193
|
+
attempt,
|
|
194
|
+
delayMs: 0,
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
if (input.enabled !== true) {
|
|
198
|
+
return stop('AUTO_RESUME_DISABLED', '自动续跑开关未开启(默认关闭)')
|
|
199
|
+
}
|
|
200
|
+
if (input.degraded === true || Number(input.total) <= 0) {
|
|
201
|
+
return stop('NO_PLAN', '没有可续跑的计划(自动分解降级或子任务数为 0)')
|
|
202
|
+
}
|
|
203
|
+
if (input.cancelled === true || input.phase === 'cancelled') {
|
|
204
|
+
return stop('CANCELLED', '用户已取消:自动重来等于违背停下的决定')
|
|
205
|
+
}
|
|
206
|
+
if (input.phase === 'superseded') {
|
|
207
|
+
return stop('SUPERSEDED', '责任已转移到承接计划,本计划不得自动续跑')
|
|
208
|
+
}
|
|
209
|
+
if (input.running === true) {
|
|
210
|
+
return stop('ALREADY_RUNNING', '已有一轮在跑,不能并发再开一轮')
|
|
211
|
+
}
|
|
212
|
+
if (input.planMode === true) {
|
|
213
|
+
return stop('PLAN_MODE', 'plan 模式下计划只供审阅,不自动执行')
|
|
214
|
+
}
|
|
215
|
+
if (input.phase !== 'paused') {
|
|
216
|
+
return stop('PHASE_NOT_PAUSED', `计划阶段是 ${String(input.phase ?? 'unknown')},只有 paused(预算到点)才自动续跑`)
|
|
217
|
+
}
|
|
218
|
+
if (Number(input.pending) <= 0) {
|
|
219
|
+
/*
|
|
220
|
+
* Also the evidence-gap case: all rows done but deliveryReady=false.
|
|
221
|
+
* Re-running done work is forbidden by the delivery contract; the gap can
|
|
222
|
+
* only be closed by a human re-adjudication, so stop and say so.
|
|
223
|
+
*/
|
|
224
|
+
return stop('NOTHING_PENDING', '没有 pending 项:若仍未就绪,那是证据缺口,需主 Agent 复核,不能靠重跑 done 项解决')
|
|
225
|
+
}
|
|
226
|
+
if (Number(input.blocked) > 0) {
|
|
227
|
+
return stop('HAS_BLOCKED', `存在 ${input.blocked} 个 blocked 子任务:那是真实失败,需人工改判或显式续跑,不自动修复`)
|
|
228
|
+
}
|
|
229
|
+
if (attempt >= maxAttempts) {
|
|
230
|
+
return stop('BUDGET_EXHAUSTED', `自动续跑已用满 ${maxAttempts} 轮,交给主 Agent 决定`)
|
|
231
|
+
}
|
|
232
|
+
if (Number(input.noProgressRounds) >= Math.max(1, Number(input.stallLimit) || 1)) {
|
|
233
|
+
return stop('NO_PROGRESS', `连续 ${input.noProgressRounds} 轮没有新增完成项,停止空转`)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const base = Math.max(0, Number(input.baseDelayMs) || 0)
|
|
237
|
+
const cap = Math.max(base, Number(input.maxDelayMs) || base)
|
|
238
|
+
const delayMs = Math.min(cap, base * Math.pow(2, attempt))
|
|
239
|
+
return {
|
|
240
|
+
action: 'schedule',
|
|
241
|
+
code: 'SCHEDULED',
|
|
242
|
+
reason: `第 ${attempt + 1}/${maxAttempts} 轮自动续跑将在 ${Math.round(delayMs / 1000)}s 后开始`,
|
|
243
|
+
attempt: attempt + 1,
|
|
244
|
+
delayMs,
|
|
245
|
+
}
|
|
246
|
+
}
|
package/src/client.ts
CHANGED
|
@@ -86,6 +86,13 @@ window.__ModuleLoader__.load({
|
|
|
86
86
|
"done": "做好了",
|
|
87
87
|
"blocked": "卡住了"
|
|
88
88
|
},
|
|
89
|
+
"handoff": {
|
|
90
|
+
"open": "待处置",
|
|
91
|
+
"routed": "已指派",
|
|
92
|
+
"answered": "已答复",
|
|
93
|
+
"closed": "无需动作"
|
|
94
|
+
},
|
|
95
|
+
"handoffs": "跨部门需求",
|
|
89
96
|
"dept": {
|
|
90
97
|
"engineering": "工程研发",
|
|
91
98
|
"research": "研究分析",
|
|
@@ -119,7 +126,23 @@ window.__ModuleLoader__.load({
|
|
|
119
126
|
"willDeliver": "做完交付",
|
|
120
127
|
"waitFor": "要等",
|
|
121
128
|
"blockedReason": "卡住原因",
|
|
129
|
+
"pendingReason": "还没做完的原因",
|
|
130
|
+
"lastErrorNote": "上一轮的失败记录(已完成,仅留档)",
|
|
131
|
+
"notDeliverable": "还不能交付",
|
|
132
|
+
"notDeliverableHint": "「全部做完」不等于「可以交付」:交付还需要每一行都有可核对的证据。下面是没有通过的部分。",
|
|
122
133
|
"progressLabel": "进度",
|
|
134
|
+
"closureReported": "已回报",
|
|
135
|
+
"closureDone": "完成 · 待回报",
|
|
136
|
+
"closureAssigned": "已下发 · 待回应",
|
|
137
|
+
"closureAcknowledged": "已回应 · 执行中",
|
|
138
|
+
"closureInstructed": "已给指示 · 待执行",
|
|
139
|
+
"closureEscalated": "待你决定",
|
|
140
|
+
"closureRunning": "执行中",
|
|
141
|
+
"closureNoAck": "指示还没被执行",
|
|
142
|
+
"changePending": "需求变更待落实",
|
|
143
|
+
"changePendingHint": "你在执行中提出的变更已记录,本轮不会中途改写正在跑的任务;本轮结束后会按新需求重规划,已发出的变更不会丢失。",
|
|
144
|
+
"closureReplanned": "已重规划",
|
|
145
|
+
"closureReplannedTo": "已重规划 → 修订 {ids}",
|
|
123
146
|
"more": "更多细节(不看也不影响理解)",
|
|
124
147
|
"why": "为什么这样安排",
|
|
125
148
|
"whyHint": "先找出最关键的问题,再按顺序解决;每一步做完先检查,再决定下一步。",
|
|
@@ -258,6 +281,13 @@ window.__ModuleLoader__.load({
|
|
|
258
281
|
"done": "Done",
|
|
259
282
|
"blocked": "Stuck"
|
|
260
283
|
},
|
|
284
|
+
"handoff": {
|
|
285
|
+
"open": "Open",
|
|
286
|
+
"routed": "Assigned",
|
|
287
|
+
"answered": "Answered",
|
|
288
|
+
"closed": "No action"
|
|
289
|
+
},
|
|
290
|
+
"handoffs": "Cross-team needs",
|
|
261
291
|
"dept": {
|
|
262
292
|
"engineering": "Engineering",
|
|
263
293
|
"research": "Research",
|
|
@@ -291,7 +321,23 @@ window.__ModuleLoader__.load({
|
|
|
291
321
|
"willDeliver": "What it delivers",
|
|
292
322
|
"waitFor": "Waits for",
|
|
293
323
|
"blockedReason": "Why it is stuck",
|
|
324
|
+
"pendingReason": "Why it is not finished yet",
|
|
325
|
+
"lastErrorNote": "Previous attempt's failure (done, kept for the record)",
|
|
326
|
+
"notDeliverable": "Not deliverable yet",
|
|
327
|
+
"notDeliverableHint": "All rows done does not mean deliverable: every row needs checkable evidence. The gaps are listed below.",
|
|
294
328
|
"progressLabel": "Progress",
|
|
329
|
+
"closureReported": "Reported back",
|
|
330
|
+
"closureDone": "Done · not reported",
|
|
331
|
+
"closureAssigned": "Sent · no reply yet",
|
|
332
|
+
"closureAcknowledged": "Acknowledged",
|
|
333
|
+
"closureInstructed": "Instruction sent",
|
|
334
|
+
"closureEscalated": "Needs your call",
|
|
335
|
+
"closureRunning": "Running",
|
|
336
|
+
"closureNoAck": "Instruction not started yet",
|
|
337
|
+
"changePending": "Change request pending",
|
|
338
|
+
"changePendingHint": "Your mid-run change is recorded. This round will not rewrite running work; the plan is replanned from your new requirements as soon as this round ends, so nothing is lost.",
|
|
339
|
+
"closureReplanned": "Replanned",
|
|
340
|
+
"closureReplannedTo": "Replanned → revised {ids}",
|
|
295
341
|
"more": "More detail (optional)",
|
|
296
342
|
"why": "Why it is arranged this way",
|
|
297
343
|
"whyHint": "Find the most important problem first, solve in order, and check after each step before deciding the next one.",
|
|
@@ -1081,6 +1127,19 @@ window.__ModuleLoader__.load({
|
|
|
1081
1127
|
return value === key ? String(id || '') : value
|
|
1082
1128
|
}
|
|
1083
1129
|
|
|
1130
|
+
/*
|
|
1131
|
+
* [1.11.0] 跨部门需求的四档文案(用户 m00687)。
|
|
1132
|
+
*
|
|
1133
|
+
* 客户端只做「状态值 → 文案」映射,不推导状态:服务端写 open/routed/
|
|
1134
|
+
* answered/closed,这里原样显示。未知值退回原文,避免把新状态误写成
|
|
1135
|
+
* “已答复”。
|
|
1136
|
+
*/
|
|
1137
|
+
function handoffStatusText(t: any, status: any) {
|
|
1138
|
+
const key = `handoff.${String(status ?? '')}`
|
|
1139
|
+
const value = t(key)
|
|
1140
|
+
return value === key ? String(status || '') : value
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1084
1143
|
function levelText(t: any, value: any) {
|
|
1085
1144
|
const key = `level.${value}`
|
|
1086
1145
|
const text = t(key)
|
|
@@ -1422,11 +1481,59 @@ window.__ModuleLoader__.load({
|
|
|
1422
1481
|
|
|
1423
1482
|
function SubtaskRow({ item, subtask, index, t }: any) {
|
|
1424
1483
|
const status = item?.status ?? 'pending'
|
|
1425
|
-
|
|
1484
|
+
/*
|
|
1485
|
+
* [1.11.0] 闭环徽标:完成 ≠ 已回报;被重规划的行灰化并指向后继。
|
|
1486
|
+
*
|
|
1487
|
+
* 这里只渲染 `serialisePlan` 下发的 `closure/replacedBy`,不在客户端
|
|
1488
|
+
* 推导任何状态(契约 §8.3:客户端不得维护本地状态机)。计划定义里的
|
|
1489
|
+
* `supersededAt` 是同一事实的镜像,只用于「状态行缺失」的历史载荷。
|
|
1490
|
+
*/
|
|
1491
|
+
const closure = item?.closure ?? (subtask?.supersededAt ? 'replanned' : null)
|
|
1492
|
+
const replacedBy = Array.isArray(item?.replacedBy)
|
|
1493
|
+
? item.replacedBy
|
|
1494
|
+
: (Array.isArray(subtask?.replacedBy) ? subtask.replacedBy : [])
|
|
1495
|
+
/*
|
|
1496
|
+
* [1.11.0] M9:闭环每一档都要在左侧栏可见。
|
|
1497
|
+
*
|
|
1498
|
+
* 只显示「已回报/已重规划」时,一条正在等主 Agent 决定的请示看起来就是
|
|
1499
|
+
* 普通「受阻」,主 Agent 与用户都无法从进度栏看出「它在等你拍板」。
|
|
1500
|
+
* 文案由服务端下发的 `closure` 决定,客户端不推导状态。
|
|
1501
|
+
*/
|
|
1502
|
+
const closureText = closure === 'replanned'
|
|
1503
|
+
? (replacedBy.length > 0 ? fill(t('closureReplannedTo'), { ids: replacedBy.join('、') }) : t('closureReplanned'))
|
|
1504
|
+
: closure === 'reported' ? t('closureReported')
|
|
1505
|
+
: closure === 'done' ? t('closureDone')
|
|
1506
|
+
: closure === 'assigned' ? t('closureAssigned')
|
|
1507
|
+
: closure === 'acknowledged' ? t('closureAcknowledged')
|
|
1508
|
+
: closure === 'instructed' ? t('closureInstructed')
|
|
1509
|
+
: closure === 'escalated' ? t('closureEscalated')
|
|
1510
|
+
/*
|
|
1511
|
+
* [1.11.0] 瞬态兜底(T10 N7):状态行已经 in_progress,
|
|
1512
|
+
* 但闭环字段还是 pending(旧载荷 / 重建中的一行)。没有
|
|
1513
|
+
* 徽标会让这一行看起来「没有闭环含义」,补一个只描述
|
|
1514
|
+
* 事实的「执行中」,不推断它是否已回报。
|
|
1515
|
+
*/
|
|
1516
|
+
: status === 'in_progress' ? t('closureRunning')
|
|
1517
|
+
: ''
|
|
1518
|
+
const closureLabel = closureText
|
|
1519
|
+
const closureTone = closure === 'reported' ? 'done'
|
|
1520
|
+
: closure === 'escalated' ? 'blocked'
|
|
1521
|
+
: closure === 'replanned' ? 'idle'
|
|
1522
|
+
: 'idle'
|
|
1523
|
+
/*
|
|
1524
|
+
* [1.11.0] 「指示已发出、子会话还没动」(T10 N4)。
|
|
1525
|
+
*
|
|
1526
|
+
* `instructionOverdue` 由 60s 定时器写、由子会话首次进展清除;它描述的
|
|
1527
|
+
* 是等待事实,不是失败,所以用 blocked 色提醒但不改 status。
|
|
1528
|
+
*/
|
|
1529
|
+
const instructionOverdue = item?.instructionOverdue === true
|
|
1530
|
+
const tone = closure === 'replanned' ? 'idle' : toneOfStatus(status)
|
|
1426
1531
|
const pct = clampPct(item?.progress ?? 0)
|
|
1427
1532
|
return h('div', { className: `dsh-wp-subtask dsh-wp-tone-${tone}` },
|
|
1428
1533
|
h('div', { className: 'dsh-wp-subtask-head' },
|
|
1429
1534
|
h('div', { className: 'dsh-wp-subtask-title' }, `${workLabel(t, index)}:${subtask.title}`),
|
|
1535
|
+
closureLabel ? h(Pill, { tone: closureTone }, closureLabel) : null,
|
|
1536
|
+
instructionOverdue ? h(Pill, { tone: 'blocked' }, t('closureNoAck')) : null,
|
|
1430
1537
|
h(Pill, { tone }, progressText(item, t)),
|
|
1431
1538
|
),
|
|
1432
1539
|
h('div', { className: 'dsh-wp-subtask-meta' },
|
|
@@ -1441,8 +1548,40 @@ window.__ModuleLoader__.load({
|
|
|
1441
1548
|
),
|
|
1442
1549
|
status === 'in_progress' ? h(Progress, { value: pct, tone }) : null,
|
|
1443
1550
|
status === 'in_progress' ? h('div', { className: 'dsh-wp-progress-meta' }, h('span', null, `${t('progressLabel')} ${pct}%`)) : null,
|
|
1551
|
+
/*
|
|
1552
|
+
* [1.11.0] 跨部门需求(用户 m00687):提出方、指派对象、答复都必须在
|
|
1553
|
+
* 进度栏可见。否则用户只能从结果消息的一段文字里猜「这条需求谁在办、
|
|
1554
|
+
* 办没办」,而交付门禁却已经因为它把整份计划拦住了。
|
|
1555
|
+
*/
|
|
1556
|
+
Array.isArray(item?.handoffs) && item.handoffs.length
|
|
1557
|
+
? h('div', { className: 'dsh-wp-subtask-body' },
|
|
1558
|
+
h('div', null, h('strong', null, `${t('handoffs')}:`)),
|
|
1559
|
+
h('ul', { className: 'dsh-wp-muted' },
|
|
1560
|
+
item.handoffs.map((handoff: any) => h('li', { key: String(handoff?.id ?? '') },
|
|
1561
|
+
`${String(handoff?.id ?? 'H?')} ${String(handoff?.request ?? '')}`
|
|
1562
|
+
+ `${handoff?.department ? ` → ${deptName(t, handoff.department)}` : ''}`
|
|
1563
|
+
+ `|${handoffStatusText(t, handoff?.status)}`
|
|
1564
|
+
+ `${handoff?.response ? `:${String(handoff.response)}` : ''}`,
|
|
1565
|
+
)),
|
|
1566
|
+
),
|
|
1567
|
+
)
|
|
1568
|
+
: null,
|
|
1444
1569
|
status !== 'blocked' && item?.summary ? h('p', { className: 'dsh-wp-muted' }, `${t('summary')}:${plainError(item.summary)}`) : null,
|
|
1445
|
-
|
|
1570
|
+
/*
|
|
1571
|
+
* [1.10.0] R-02:「卡住原因」只属于没做完的行。
|
|
1572
|
+
*
|
|
1573
|
+
* 1.9.1 无条件渲染 `item.error`,只要历史记录里残留一句失败文本,就会在
|
|
1574
|
+
* 一行 status=done 的卡片下面写「卡住原因:本轮预算用尽…」——「已完成」
|
|
1575
|
+
* 与「卡住了」同屏,正是用户截图里的矛盾。数据层已经保证 done 行没有
|
|
1576
|
+
* error(I12),这里再做一次呈现守卫:任何历史载荷、旧缓存都不会重现。
|
|
1577
|
+
*/
|
|
1578
|
+
item?.error && status !== 'done'
|
|
1579
|
+
? h('p', { className: 'dsh-wp-error-text' },
|
|
1580
|
+
`${t(status === 'blocked' ? 'blockedReason' : 'pendingReason')}:${plainError(item.error)}`)
|
|
1581
|
+
: null,
|
|
1582
|
+
status === 'done' && item?.lastError
|
|
1583
|
+
? h('p', { className: 'dsh-wp-muted' }, `${t('lastErrorNote')}:${plainError(item.lastError)}`)
|
|
1584
|
+
: null,
|
|
1446
1585
|
h('details', { className: 'dsh-wp-details' },
|
|
1447
1586
|
h('summary', null, t('more')),
|
|
1448
1587
|
h('div', { className: 'dsh-wp-grid', style: { marginTop: '8px' } },
|
|
@@ -1457,7 +1596,13 @@ window.__ModuleLoader__.load({
|
|
|
1457
1596
|
|
|
1458
1597
|
function StageCard({ stage, statuses, index, t }: any) {
|
|
1459
1598
|
const byId = useMemo(() => new Map((statuses || []).map((item: any) => [item.subtaskId, item])), [statuses])
|
|
1460
|
-
const
|
|
1599
|
+
const allItems = (stage.subtasks || []).map((subtask: any) => ({ subtask, item: byId.get(subtask.id) }))
|
|
1600
|
+
/*
|
|
1601
|
+
* [1.11.0] 被重规划替换/撤销的行仍然渲染(可追溯),但不进入阶段分母:
|
|
1602
|
+
* 否则「替换一项」会让阶段永远停在 4/5,用户看到的进度与总数互相矛盾。
|
|
1603
|
+
* 同一个 `supersededAt` 也决定了 `definedSubtaskCount` 的分母。
|
|
1604
|
+
*/
|
|
1605
|
+
const items = allItems.filter(({ subtask }: any) => !subtask.supersededAt)
|
|
1461
1606
|
const done = items.filter(({ item }: any) => item?.status === 'done').length
|
|
1462
1607
|
const blocked = items.filter(({ item }: any) => item?.status === 'blocked').length
|
|
1463
1608
|
const inProgress = items.some(({ item }: any) => item?.status === 'in_progress')
|
|
@@ -1484,7 +1629,7 @@ window.__ModuleLoader__.load({
|
|
|
1484
1629
|
},
|
|
1485
1630
|
h('div', { className: 'dsh-wp-stage-goal' }, `${t('what')}:${stage.goal}`),
|
|
1486
1631
|
h('div', { className: 'dsh-wp-checkpoint' }, `${t('checkpoint')}:${stage.checkpoint}`),
|
|
1487
|
-
|
|
1632
|
+
allItems.map(({ subtask, item }: any, subIndex: any) => h(SubtaskRow, { key: subtask.id, subtask, item, index: subIndex, t })),
|
|
1488
1633
|
),
|
|
1489
1634
|
)
|
|
1490
1635
|
}
|
|
@@ -1601,6 +1746,22 @@ window.__ModuleLoader__.load({
|
|
|
1601
1746
|
return total > 0 ? Math.round((done / total) * 100) : null
|
|
1602
1747
|
}
|
|
1603
1748
|
|
|
1749
|
+
/*
|
|
1750
|
+
* [1.10.0] C-11:100% 只有一个来源。
|
|
1751
|
+
*
|
|
1752
|
+
* `done/total` 是「行数」,服务端的 `stats.progress` 是「加权完成度」,
|
|
1753
|
+
* 二者在 12 done + 1 blocked@95 时分别是 92 与 95(T3 实测)。界面只展示
|
|
1754
|
+
* 一个数:行数百分比;但只要加权口径还差一点(或全部行 done 却不可交付),
|
|
1755
|
+
* 就不允许显示成 100——"100%" 在这一页上必须同时意味着「每行都做完」。
|
|
1756
|
+
*/
|
|
1757
|
+
function cappedPercent(raw: number | null, stats: any): number | null {
|
|
1758
|
+
if (raw === null) return null
|
|
1759
|
+
const weighted = Number(stats?.progress)
|
|
1760
|
+
if (raw >= 100 && Number.isFinite(weighted) && weighted < 100) return 99
|
|
1761
|
+
if (raw > 100) return 100
|
|
1762
|
+
return raw
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1604
1765
|
// 与 groupTotals 同一套口径:先夹到 [0,total],再让「正在做/还没开始」
|
|
1605
1766
|
// 吃掉剩余量,四段之和恒等于总数(构成条不会溢出或出现负宽度)。
|
|
1606
1767
|
function planCounts(stats: any): PlanCounts {
|
|
@@ -1610,7 +1771,7 @@ window.__ModuleLoader__.load({
|
|
|
1610
1771
|
const blocked = Math.min(planCount(source.blocked), total - done)
|
|
1611
1772
|
const active = Math.min(planCount(source.inProgress), total - done - blocked)
|
|
1612
1773
|
const pending = Math.max(0, total - done - blocked - active)
|
|
1613
|
-
return { total, done, active, blocked, pending, percent: planPercent(done, total) }
|
|
1774
|
+
return { total, done, active, blocked, pending, percent: cappedPercent(planPercent(done, total), source) }
|
|
1614
1775
|
}
|
|
1615
1776
|
|
|
1616
1777
|
/*
|
|
@@ -1692,7 +1853,18 @@ window.__ModuleLoader__.load({
|
|
|
1692
1853
|
const rows: PlanStageRow[] = []
|
|
1693
1854
|
const list = Array.isArray(stages) ? stages : []
|
|
1694
1855
|
list.forEach((stage: any, index: number) => {
|
|
1695
|
-
|
|
1856
|
+
/*
|
|
1857
|
+
* [1.11.0] 被重规划替换的旧行不参与阶段步进条(T10 N1)。
|
|
1858
|
+
*
|
|
1859
|
+
* 卡片头部按 `definedSubtaskCount` 已排除 `supersededAt`,这里却把
|
|
1860
|
+
* 计划定义里的全部行都算进分母,于是重规划后出现「头部 100%,
|
|
1861
|
+
* 阶段条 1/2 做好了」的双口径。旧行仍是审计记录(下面按状态行渲染、
|
|
1862
|
+
* 灰化),但不再是「还要做的工作」,所以不进入 total/done/active/
|
|
1863
|
+
* blocked 四个计数;一个阶段若只剩旧行,整段也不再显示。
|
|
1864
|
+
*/
|
|
1865
|
+
const allSubtasks = Array.isArray(stage?.subtasks) ? stage.subtasks : []
|
|
1866
|
+
const subtasks = allSubtasks.filter((subtask: any) => !subtask?.supersededAt)
|
|
1867
|
+
if (allSubtasks.length > 0 && subtasks.length === 0) return
|
|
1696
1868
|
let done = 0
|
|
1697
1869
|
let active = 0
|
|
1698
1870
|
let blocked = 0
|
|
@@ -1987,6 +2159,39 @@ window.__ModuleLoader__.load({
|
|
|
1987
2159
|
h('div', null, plainError(session.error || '')),
|
|
1988
2160
|
h('div', { className: 'dsh-wp-muted' }, t('degradedHint')),
|
|
1989
2161
|
) : null,
|
|
2162
|
+
/*
|
|
2163
|
+
* [1.11.0] 执行中收到的需求变更(T10 N5)。
|
|
2164
|
+
*
|
|
2165
|
+
* 服务端从 1.11.0 起把 `changeRequest` 放进每份载荷,但卡片原先
|
|
2166
|
+
* 一字不显示:用户提了变更、工具也回了「已记录」,进度栏却看不出
|
|
2167
|
+
* 来,只能等主 Agent 自己再解释一遍。这里只显示「已记录 + 原文 +
|
|
2168
|
+
* 何时生效」,不显示任何未落地的承诺。
|
|
2169
|
+
*/
|
|
2170
|
+
session.changeRequest?.status === 'pending'
|
|
2171
|
+
? h('div', { className: 'dsh-wp-banner dsh-wp-banner--degraded' },
|
|
2172
|
+
h('strong', null, t('changePending')),
|
|
2173
|
+
h('div', { className: 'dsh-wp-muted' }, t('changePendingHint')),
|
|
2174
|
+
typeof session.changeRequest.text === 'string' && session.changeRequest.text
|
|
2175
|
+
? h('div', { className: 'dsh-wp-error-text' }, plainError(session.changeRequest.text))
|
|
2176
|
+
: null,
|
|
2177
|
+
) : null,
|
|
2178
|
+
/*
|
|
2179
|
+
* [1.10.0] C-09:把服务端已经下发、却从来没人读的交付门禁搬上界面。
|
|
2180
|
+
*
|
|
2181
|
+
* 1.9.1 的载荷里一直带着 `deliveryReady / deliveryBlockers`(present 用的
|
|
2182
|
+
* 就是同一份判定),但 `client.ts` 一处都没消费。于是「13/13、100%、绿」,
|
|
2183
|
+
* 而 present 被拒——「进度 100% ≠ 可交付」这条事实在界面上完全不可见。
|
|
2184
|
+
*/
|
|
2185
|
+
session.deliveryReady === false
|
|
2186
|
+
? h('div', { className: 'dsh-wp-banner dsh-wp-banner--degraded' },
|
|
2187
|
+
h('strong', null, t('notDeliverable')),
|
|
2188
|
+
h('div', { className: 'dsh-wp-muted' }, t('notDeliverableHint')),
|
|
2189
|
+
Array.isArray(session.deliveryBlockers) && session.deliveryBlockers.length
|
|
2190
|
+
? h('ul', { className: 'dsh-wp-muted' },
|
|
2191
|
+
session.deliveryBlockers.slice(0, 6).map((blocker: any, index: any) =>
|
|
2192
|
+
h('li', { key: index }, plainError(String(blocker)))))
|
|
2193
|
+
: null,
|
|
2194
|
+
) : null,
|
|
1990
2195
|
h(Guide, { session, t }),
|
|
1991
2196
|
departments.length ? h('div', { className: 'dsh-wp-section' },
|
|
1992
2197
|
h('div', { className: 'dsh-wp-section-title' }, t('who')),
|
|
@@ -2594,7 +2799,7 @@ window.__ModuleLoader__.load({
|
|
|
2594
2799
|
return {
|
|
2595
2800
|
label: raw.length > 14 ? `${raw.slice(0, 14)}…` : raw,
|
|
2596
2801
|
// [1.5.2] 与卡片/组头同一个百分比函数,杜绝第二套口径。
|
|
2597
|
-
value: planPercent(planCount(session.stats?.done), planCount(session.stats?.total)) ?? 0,
|
|
2802
|
+
value: cappedPercent(planPercent(planCount(session.stats?.done), planCount(session.stats?.total)), session.stats) ?? 0,
|
|
2598
2803
|
}
|
|
2599
2804
|
}), [groups, t])
|
|
2600
2805
|
/*
|