dsh-workplan 1.10.6 → 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/lib/client.js CHANGED
@@ -84,6 +84,13 @@ window.__ModuleLoader__.load({
84
84
  "done": "做好了",
85
85
  "blocked": "卡住了"
86
86
  },
87
+ "handoff": {
88
+ "open": "待处置",
89
+ "routed": "已指派",
90
+ "answered": "已答复",
91
+ "closed": "无需动作"
92
+ },
93
+ "handoffs": "跨部门需求",
87
94
  "dept": {
88
95
  "engineering": "工程研发",
89
96
  "research": "研究分析",
@@ -122,6 +129,18 @@ window.__ModuleLoader__.load({
122
129
  "notDeliverable": "还不能交付",
123
130
  "notDeliverableHint": "「全部做完」不等于「可以交付」:交付还需要每一行都有可核对的证据。下面是没有通过的部分。",
124
131
  "progressLabel": "进度",
132
+ "closureReported": "已回报",
133
+ "closureDone": "完成 · 待回报",
134
+ "closureAssigned": "已下发 · 待回应",
135
+ "closureAcknowledged": "已回应 · 执行中",
136
+ "closureInstructed": "已给指示 · 待执行",
137
+ "closureEscalated": "待你决定",
138
+ "closureRunning": "执行中",
139
+ "closureNoAck": "指示还没被执行",
140
+ "changePending": "需求变更待落实",
141
+ "changePendingHint": "你在执行中提出的变更已记录,本轮不会中途改写正在跑的任务;本轮结束后会按新需求重规划,已发出的变更不会丢失。",
142
+ "closureReplanned": "已重规划",
143
+ "closureReplannedTo": "已重规划 → 修订 {ids}",
125
144
  "more": "更多细节(不看也不影响理解)",
126
145
  "why": "为什么这样安排",
127
146
  "whyHint": "先找出最关键的问题,再按顺序解决;每一步做完先检查,再决定下一步。",
@@ -260,6 +279,13 @@ window.__ModuleLoader__.load({
260
279
  "done": "Done",
261
280
  "blocked": "Stuck"
262
281
  },
282
+ "handoff": {
283
+ "open": "Open",
284
+ "routed": "Assigned",
285
+ "answered": "Answered",
286
+ "closed": "No action"
287
+ },
288
+ "handoffs": "Cross-team needs",
263
289
  "dept": {
264
290
  "engineering": "Engineering",
265
291
  "research": "Research",
@@ -298,6 +324,18 @@ window.__ModuleLoader__.load({
298
324
  "notDeliverable": "Not deliverable yet",
299
325
  "notDeliverableHint": "All rows done does not mean deliverable: every row needs checkable evidence. The gaps are listed below.",
300
326
  "progressLabel": "Progress",
327
+ "closureReported": "Reported back",
328
+ "closureDone": "Done · not reported",
329
+ "closureAssigned": "Sent · no reply yet",
330
+ "closureAcknowledged": "Acknowledged",
331
+ "closureInstructed": "Instruction sent",
332
+ "closureEscalated": "Needs your call",
333
+ "closureRunning": "Running",
334
+ "closureNoAck": "Instruction not started yet",
335
+ "changePending": "Change request pending",
336
+ "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.",
337
+ "closureReplanned": "Replanned",
338
+ "closureReplannedTo": "Replanned → revised {ids}",
301
339
  "more": "More detail (optional)",
302
340
  "why": "Why it is arranged this way",
303
341
  "whyHint": "Find the most important problem first, solve in order, and check after each step before deciding the next one.",
@@ -1088,6 +1126,18 @@ window.__ModuleLoader__.load({
1088
1126
  const value = t(key);
1089
1127
  return value === key ? String(id || '') : value;
1090
1128
  }
1129
+ /*
1130
+ * [1.11.0] 跨部门需求的四档文案(用户 m00687)。
1131
+ *
1132
+ * 客户端只做「状态值 → 文案」映射,不推导状态:服务端写 open/routed/
1133
+ * answered/closed,这里原样显示。未知值退回原文,避免把新状态误写成
1134
+ * “已答复”。
1135
+ */
1136
+ function handoffStatusText(t, status) {
1137
+ const key = `handoff.${String(status ?? '')}`;
1138
+ const value = t(key);
1139
+ return value === key ? String(status || '') : value;
1140
+ }
1091
1141
  function levelText(t, value) {
1092
1142
  const key = `level.${value}`;
1093
1143
  const text = t(key);
@@ -1378,9 +1428,66 @@ window.__ModuleLoader__.load({
1378
1428
  }
1379
1429
  function SubtaskRow({ item, subtask, index, t }) {
1380
1430
  const status = item?.status ?? 'pending';
1381
- const tone = toneOfStatus(status);
1431
+ /*
1432
+ * [1.11.0] 闭环徽标:完成 ≠ 已回报;被重规划的行灰化并指向后继。
1433
+ *
1434
+ * 这里只渲染 `serialisePlan` 下发的 `closure/replacedBy`,不在客户端
1435
+ * 推导任何状态(契约 §8.3:客户端不得维护本地状态机)。计划定义里的
1436
+ * `supersededAt` 是同一事实的镜像,只用于「状态行缺失」的历史载荷。
1437
+ */
1438
+ const closure = item?.closure ?? (subtask?.supersededAt ? 'replanned' : null);
1439
+ const replacedBy = Array.isArray(item?.replacedBy)
1440
+ ? item.replacedBy
1441
+ : (Array.isArray(subtask?.replacedBy) ? subtask.replacedBy : []);
1442
+ /*
1443
+ * [1.11.0] M9:闭环每一档都要在左侧栏可见。
1444
+ *
1445
+ * 只显示「已回报/已重规划」时,一条正在等主 Agent 决定的请示看起来就是
1446
+ * 普通「受阻」,主 Agent 与用户都无法从进度栏看出「它在等你拍板」。
1447
+ * 文案由服务端下发的 `closure` 决定,客户端不推导状态。
1448
+ */
1449
+ const closureText = closure === 'replanned'
1450
+ ? (replacedBy.length > 0 ? fill(t('closureReplannedTo'), { ids: replacedBy.join('、') }) : t('closureReplanned'))
1451
+ : closure === 'reported' ? t('closureReported')
1452
+ : closure === 'done' ? t('closureDone')
1453
+ : closure === 'assigned' ? t('closureAssigned')
1454
+ : closure === 'acknowledged' ? t('closureAcknowledged')
1455
+ : closure === 'instructed' ? t('closureInstructed')
1456
+ : closure === 'escalated' ? t('closureEscalated')
1457
+ /*
1458
+ * [1.11.0] 瞬态兜底(T10 N7):状态行已经 in_progress,
1459
+ * 但闭环字段还是 pending(旧载荷 / 重建中的一行)。没有
1460
+ * 徽标会让这一行看起来「没有闭环含义」,补一个只描述
1461
+ * 事实的「执行中」,不推断它是否已回报。
1462
+ */
1463
+ : status === 'in_progress' ? t('closureRunning')
1464
+ : '';
1465
+ const closureLabel = closureText;
1466
+ const closureTone = closure === 'reported' ? 'done'
1467
+ : closure === 'escalated' ? 'blocked'
1468
+ : closure === 'replanned' ? 'idle'
1469
+ : 'idle';
1470
+ /*
1471
+ * [1.11.0] 「指示已发出、子会话还没动」(T10 N4)。
1472
+ *
1473
+ * `instructionOverdue` 由 60s 定时器写、由子会话首次进展清除;它描述的
1474
+ * 是等待事实,不是失败,所以用 blocked 色提醒但不改 status。
1475
+ */
1476
+ const instructionOverdue = item?.instructionOverdue === true;
1477
+ const tone = closure === 'replanned' ? 'idle' : toneOfStatus(status);
1382
1478
  const pct = clampPct(item?.progress ?? 0);
1383
- return h('div', { className: `dsh-wp-subtask dsh-wp-tone-${tone}` }, h('div', { className: 'dsh-wp-subtask-head' }, h('div', { className: 'dsh-wp-subtask-title' }, `${workLabel(t, index)}:${subtask.title}`), h(Pill, { tone }, progressText(item, t))), h('div', { className: 'dsh-wp-subtask-meta' }, h('span', null, `${t('who')}:${deptName(t, subtask.department)} · ${subtask.role}`)), h('div', { className: 'dsh-wp-subtask-body' }, h('p', null, h('strong', null, `${t('what')}:`), subtask.objective), h('div', null, h('strong', null, `${t('how')}:`), h(Bullets, { items: subtask.method })), h('div', null, h('strong', null, `${t('doneWhen')}:`), h(Bullets, { items: subtask.acceptance })), subtask.outputs?.length ? h('div', null, h('strong', null, `${t('willDeliver')}:`), h(Bullets, { items: subtask.outputs })) : null, subtask.dependsOn?.length ? h('p', { className: 'dsh-wp-muted' }, `${t('waitFor')}:先等前面的工作做完,才能开始这一步。`) : null), status === 'in_progress' ? h(Progress, { value: pct, tone }) : null, status === 'in_progress' ? h('div', { className: 'dsh-wp-progress-meta' }, h('span', null, `${t('progressLabel')} ${pct}%`)) : null, status !== 'blocked' && item?.summary ? h('p', { className: 'dsh-wp-muted' }, `${t('summary')}:${plainError(item.summary)}`) : null,
1479
+ return h('div', { className: `dsh-wp-subtask dsh-wp-tone-${tone}` }, h('div', { className: 'dsh-wp-subtask-head' }, h('div', { className: 'dsh-wp-subtask-title' }, `${workLabel(t, index)}:${subtask.title}`), closureLabel ? h(Pill, { tone: closureTone }, closureLabel) : null, instructionOverdue ? h(Pill, { tone: 'blocked' }, t('closureNoAck')) : null, h(Pill, { tone }, progressText(item, t))), h('div', { className: 'dsh-wp-subtask-meta' }, h('span', null, `${t('who')}:${deptName(t, subtask.department)} · ${subtask.role}`)), h('div', { className: 'dsh-wp-subtask-body' }, h('p', null, h('strong', null, `${t('what')}:`), subtask.objective), h('div', null, h('strong', null, `${t('how')}:`), h(Bullets, { items: subtask.method })), h('div', null, h('strong', null, `${t('doneWhen')}:`), h(Bullets, { items: subtask.acceptance })), subtask.outputs?.length ? h('div', null, h('strong', null, `${t('willDeliver')}:`), h(Bullets, { items: subtask.outputs })) : null, subtask.dependsOn?.length ? h('p', { className: 'dsh-wp-muted' }, `${t('waitFor')}:先等前面的工作做完,才能开始这一步。`) : null), status === 'in_progress' ? h(Progress, { value: pct, tone }) : null, status === 'in_progress' ? h('div', { className: 'dsh-wp-progress-meta' }, h('span', null, `${t('progressLabel')} ${pct}%`)) : null,
1480
+ /*
1481
+ * [1.11.0] 跨部门需求(用户 m00687):提出方、指派对象、答复都必须在
1482
+ * 进度栏可见。否则用户只能从结果消息的一段文字里猜「这条需求谁在办、
1483
+ * 办没办」,而交付门禁却已经因为它把整份计划拦住了。
1484
+ */
1485
+ Array.isArray(item?.handoffs) && item.handoffs.length
1486
+ ? h('div', { className: 'dsh-wp-subtask-body' }, h('div', null, h('strong', null, `${t('handoffs')}:`)), h('ul', { className: 'dsh-wp-muted' }, item.handoffs.map((handoff) => h('li', { key: String(handoff?.id ?? '') }, `${String(handoff?.id ?? 'H?')} ${String(handoff?.request ?? '')}`
1487
+ + `${handoff?.department ? ` → ${deptName(t, handoff.department)}` : ''}`
1488
+ + `|${handoffStatusText(t, handoff?.status)}`
1489
+ + `${handoff?.response ? `:${String(handoff.response)}` : ''}`))))
1490
+ : null, status !== 'blocked' && item?.summary ? h('p', { className: 'dsh-wp-muted' }, `${t('summary')}:${plainError(item.summary)}`) : null,
1384
1491
  /*
1385
1492
  * [1.10.0] R-02:「卡住原因」只属于没做完的行。
1386
1493
  *
@@ -1397,7 +1504,13 @@ window.__ModuleLoader__.load({
1397
1504
  }
1398
1505
  function StageCard({ stage, statuses, index, t }) {
1399
1506
  const byId = useMemo(() => new Map((statuses || []).map((item) => [item.subtaskId, item])), [statuses]);
1400
- const items = (stage.subtasks || []).map((subtask) => ({ subtask, item: byId.get(subtask.id) }));
1507
+ const allItems = (stage.subtasks || []).map((subtask) => ({ subtask, item: byId.get(subtask.id) }));
1508
+ /*
1509
+ * [1.11.0] 被重规划替换/撤销的行仍然渲染(可追溯),但不进入阶段分母:
1510
+ * 否则「替换一项」会让阶段永远停在 4/5,用户看到的进度与总数互相矛盾。
1511
+ * 同一个 `supersededAt` 也决定了 `definedSubtaskCount` 的分母。
1512
+ */
1513
+ const items = allItems.filter(({ subtask }) => !subtask.supersededAt);
1401
1514
  const done = items.filter(({ item }) => item?.status === 'done').length;
1402
1515
  const blocked = items.filter(({ item }) => item?.status === 'blocked').length;
1403
1516
  const inProgress = items.some(({ item }) => item?.status === 'in_progress');
@@ -1420,7 +1533,7 @@ window.__ModuleLoader__.load({
1420
1533
  title: `${stageLabel(t, index)}:${stage.name}`,
1421
1534
  meta: `${done}/${items.length} ${t('stats.done')}`,
1422
1535
  badge: h(Pill, { tone }, stateText),
1423
- }, h('div', { className: 'dsh-wp-stage-goal' }, `${t('what')}:${stage.goal}`), h('div', { className: 'dsh-wp-checkpoint' }, `${t('checkpoint')}:${stage.checkpoint}`), items.map(({ subtask, item }, subIndex) => h(SubtaskRow, { key: subtask.id, subtask, item, index: subIndex, t }))));
1536
+ }, h('div', { className: 'dsh-wp-stage-goal' }, `${t('what')}:${stage.goal}`), h('div', { className: 'dsh-wp-checkpoint' }, `${t('checkpoint')}:${stage.checkpoint}`), allItems.map(({ subtask, item }, subIndex) => h(SubtaskRow, { key: subtask.id, subtask, item, index: subIndex, t }))));
1424
1537
  }
1425
1538
  function Analysis({ session, t }) {
1426
1539
  const task = session.taskUnderstanding || {};
@@ -1561,7 +1674,19 @@ window.__ModuleLoader__.load({
1561
1674
  const rows = [];
1562
1675
  const list = Array.isArray(stages) ? stages : [];
1563
1676
  list.forEach((stage, index) => {
1564
- const subtasks = Array.isArray(stage?.subtasks) ? stage.subtasks : [];
1677
+ /*
1678
+ * [1.11.0] 被重规划替换的旧行不参与阶段步进条(T10 N1)。
1679
+ *
1680
+ * 卡片头部按 `definedSubtaskCount` 已排除 `supersededAt`,这里却把
1681
+ * 计划定义里的全部行都算进分母,于是重规划后出现「头部 100%,
1682
+ * 阶段条 1/2 做好了」的双口径。旧行仍是审计记录(下面按状态行渲染、
1683
+ * 灰化),但不再是「还要做的工作」,所以不进入 total/done/active/
1684
+ * blocked 四个计数;一个阶段若只剩旧行,整段也不再显示。
1685
+ */
1686
+ const allSubtasks = Array.isArray(stage?.subtasks) ? stage.subtasks : [];
1687
+ const subtasks = allSubtasks.filter((subtask) => !subtask?.supersededAt);
1688
+ if (allSubtasks.length > 0 && subtasks.length === 0)
1689
+ return;
1565
1690
  let done = 0;
1566
1691
  let active = 0;
1567
1692
  let blocked = 0;
@@ -1795,6 +1920,18 @@ window.__ModuleLoader__.load({
1795
1920
  }, session.updatedAt
1796
1921
  ? h('div', { className: 'dsh-wp-meta dsh-wp-session-updated' }, `${t('updatedAt')} ${formatTime(session.updatedAt)}`)
1797
1922
  : null, open === true ? h(PlanOverview, { t, stats, counts, rows: stageRows }) : null, session.degraded ? h('div', { className: 'dsh-wp-banner dsh-wp-banner--degraded' }, h('strong', null, t('degraded')), h('div', null, plainError(session.error || '')), h('div', { className: 'dsh-wp-muted' }, t('degradedHint'))) : null,
1923
+ /*
1924
+ * [1.11.0] 执行中收到的需求变更(T10 N5)。
1925
+ *
1926
+ * 服务端从 1.11.0 起把 `changeRequest` 放进每份载荷,但卡片原先
1927
+ * 一字不显示:用户提了变更、工具也回了「已记录」,进度栏却看不出
1928
+ * 来,只能等主 Agent 自己再解释一遍。这里只显示「已记录 + 原文 +
1929
+ * 何时生效」,不显示任何未落地的承诺。
1930
+ */
1931
+ session.changeRequest?.status === 'pending'
1932
+ ? h('div', { className: 'dsh-wp-banner dsh-wp-banner--degraded' }, h('strong', null, t('changePending')), h('div', { className: 'dsh-wp-muted' }, t('changePendingHint')), typeof session.changeRequest.text === 'string' && session.changeRequest.text
1933
+ ? h('div', { className: 'dsh-wp-error-text' }, plainError(session.changeRequest.text))
1934
+ : null) : null,
1798
1935
  /*
1799
1936
  * [1.10.0] C-09:把服务端已经下发、却从来没人读的交付门禁搬上界面。
1800
1937
  *