dsh-workplan 1.11.0 → 1.12.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 +139 -0
- package/README.en.md +4 -3
- package/README.md +4 -3
- package/client.js +221 -24
- package/docs/collaboration.md +21 -18
- package/docs/departments.md +8 -7
- package/docs/release-notes-1.12.0.md +66 -0
- package/docs/release-record-1.11.0-20261102.md +63 -0
- package/docs/release-record-1.11.1-20261102.md +61 -0
- package/lib/auto-resume.js +35 -7
- package/lib/client.js +221 -24
- package/lib/departments.js +218 -0
- package/lib/host.js +30 -4
- package/lib/plan.js +221 -23
- package/lib/replan.js +76 -0
- package/lib/runtime.js +173 -15
- package/lib/understanding.js +749 -0
- package/package.json +1 -1
- package/src/auto-resume.ts +36 -7
- package/src/client.ts +268 -32
- package/src/departments.ts +244 -0
- package/src/host.ts +44 -8
- package/src/plan.ts +227 -23
- package/src/replan.ts +66 -0
- package/src/runtime.ts +187 -18
- package/src/understanding.ts +901 -0
package/lib/client.js
CHANGED
|
@@ -14,6 +14,7 @@ window.__ModuleLoader__.load({
|
|
|
14
14
|
const PANEL_ID = 'workplan';
|
|
15
15
|
const NS = 'dsh-workplan';
|
|
16
16
|
const { useState, useEffect, useCallback, useMemo } = React;
|
|
17
|
+
// [D-11] 面板统一称「执行角色」:role 仍是自由文本字段,只消除「负责人」与「角色」的口径冲突。
|
|
17
18
|
const LOCALE = {
|
|
18
19
|
"zh": {
|
|
19
20
|
"panel": "任务进度",
|
|
@@ -62,7 +63,7 @@ window.__ModuleLoader__.load({
|
|
|
62
63
|
"refresh": "刷新",
|
|
63
64
|
"updatedAt": "更新于",
|
|
64
65
|
"empty": "还没有任务进度",
|
|
65
|
-
"emptyHint": "
|
|
66
|
+
"emptyHint": "先发一句话说明你要做什么,系统会自动安排步骤和执行角色。",
|
|
66
67
|
"error": "读取失败",
|
|
67
68
|
"retry": "重试",
|
|
68
69
|
"phase": {
|
|
@@ -103,7 +104,8 @@ window.__ModuleLoader__.load({
|
|
|
103
104
|
"writing": "文档写作",
|
|
104
105
|
"operations": "运营",
|
|
105
106
|
"legal": "法务合规",
|
|
106
|
-
"finance": "财务"
|
|
107
|
+
"finance": "财务",
|
|
108
|
+
"unknown": "未知部门"
|
|
107
109
|
},
|
|
108
110
|
"stats": {
|
|
109
111
|
"done": "做好了",
|
|
@@ -117,7 +119,7 @@ window.__ModuleLoader__.load({
|
|
|
117
119
|
"stepSuffix": "步",
|
|
118
120
|
"workPrefix": "具体工作",
|
|
119
121
|
"who": "负责团队",
|
|
120
|
-
"person": "
|
|
122
|
+
"person": "执行角色",
|
|
121
123
|
"what": "要做出什么",
|
|
122
124
|
"how": "怎么做",
|
|
123
125
|
"doneWhen": "怎样算做好",
|
|
@@ -163,7 +165,7 @@ window.__ModuleLoader__.load({
|
|
|
163
165
|
"transformation": "什么情况下会变化",
|
|
164
166
|
"checkpoint": "这一步做完先检查",
|
|
165
167
|
"subtasks": "具体工作",
|
|
166
|
-
"role": "
|
|
168
|
+
"role": "执行角色",
|
|
167
169
|
"objective": "要做出什么",
|
|
168
170
|
"method": "怎么做",
|
|
169
171
|
"inputs": "开始前需要",
|
|
@@ -298,7 +300,8 @@ window.__ModuleLoader__.load({
|
|
|
298
300
|
"writing": "Writing",
|
|
299
301
|
"operations": "Operations",
|
|
300
302
|
"legal": "Legal",
|
|
301
|
-
"finance": "Finance"
|
|
303
|
+
"finance": "Finance",
|
|
304
|
+
"unknown": "Unknown department"
|
|
302
305
|
},
|
|
303
306
|
"stats": {
|
|
304
307
|
"done": "Done",
|
|
@@ -312,7 +315,7 @@ window.__ModuleLoader__.load({
|
|
|
312
315
|
"stepSuffix": "",
|
|
313
316
|
"workPrefix": "Work item",
|
|
314
317
|
"who": "Team",
|
|
315
|
-
"person": "
|
|
318
|
+
"person": "Execution role",
|
|
316
319
|
"what": "What to make",
|
|
317
320
|
"how": "How",
|
|
318
321
|
"doneWhen": "How we know it is good",
|
|
@@ -358,7 +361,7 @@ window.__ModuleLoader__.load({
|
|
|
358
361
|
"transformation": "What could change it",
|
|
359
362
|
"checkpoint": "Check before moving on",
|
|
360
363
|
"subtasks": "Work items",
|
|
361
|
-
"role": "
|
|
364
|
+
"role": "Execution role",
|
|
362
365
|
"objective": "What to make",
|
|
363
366
|
"method": "How",
|
|
364
367
|
"inputs": "Needed first",
|
|
@@ -806,9 +809,45 @@ window.__ModuleLoader__.load({
|
|
|
806
809
|
.dsh-wp-planoverview-title { font-size: 12px; font-weight: 650; letter-spacing: .2px; }
|
|
807
810
|
.dsh-wp-planoverview-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--dsw-alias-label-secondary, #475569); font-variant-numeric: tabular-nums; }
|
|
808
811
|
.dsh-wp-planrows { display: grid; }
|
|
809
|
-
|
|
812
|
+
/*
|
|
813
|
+
* [1.12.0] 「分步进度」每一行都是一个可点击的 disclosure(默认收起)。
|
|
814
|
+
*
|
|
815
|
+
* 收起态必须与改造前逐项一致:状态点、第 N 步:名称、进度条、done/total、
|
|
816
|
+
* 状态词;只多一个折叠指示箭头。展开按钮本身是原生 <button>,44px 触控高度,
|
|
817
|
+
* aria-expanded/aria-controls 由组件绑定,不复用 Collapse 的外层卡片留白。
|
|
818
|
+
*/
|
|
819
|
+
.dsh-wp-planrow { display: block; min-width: 0; border-top: 1px solid var(--dsw-alias-border-l1); }
|
|
810
820
|
.dsh-wp-planrow:first-child { border-top: 0; }
|
|
811
821
|
.dsh-wp-planrow[data-current="true"] { background: rgba(249,115,22,.06); border-radius: 8px; }
|
|
822
|
+
.dsh-wp-planrow-toggle {
|
|
823
|
+
display: grid;
|
|
824
|
+
grid-template-columns: 9px 7px minmax(0, 1fr) 48px auto auto;
|
|
825
|
+
align-items: center;
|
|
826
|
+
gap: 8px;
|
|
827
|
+
width: 100%;
|
|
828
|
+
min-height: 44px;
|
|
829
|
+
padding: 4px 6px;
|
|
830
|
+
border: 0;
|
|
831
|
+
border-radius: 8px;
|
|
832
|
+
background: transparent;
|
|
833
|
+
color: inherit;
|
|
834
|
+
font: inherit;
|
|
835
|
+
text-align: left;
|
|
836
|
+
cursor: pointer;
|
|
837
|
+
touch-action: manipulation;
|
|
838
|
+
}
|
|
839
|
+
.dsh-wp-planrow-toggle:hover { background: rgba(148,163,184,.10); }
|
|
840
|
+
.dsh-wp-planrow-toggle:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
|
|
841
|
+
.dsh-wp-planrow-chevron {
|
|
842
|
+
justify-self: center;
|
|
843
|
+
width: 8px;
|
|
844
|
+
height: 8px;
|
|
845
|
+
border-right: 2px solid var(--dsw-alias-label-secondary, #475569);
|
|
846
|
+
border-bottom: 2px solid var(--dsw-alias-label-secondary, #475569);
|
|
847
|
+
transform: rotate(-45deg);
|
|
848
|
+
transition: transform 160ms ease;
|
|
849
|
+
}
|
|
850
|
+
.dsh-wp-planrow[data-open="true"] .dsh-wp-planrow-chevron { transform: rotate(45deg); }
|
|
812
851
|
.dsh-wp-planrow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dsw-alias-state-idle-primary); }
|
|
813
852
|
.dsh-wp-planrow[data-tone="done"] .dsh-wp-planrow-dot { background: var(--dsh-wp-done); }
|
|
814
853
|
.dsh-wp-planrow[data-tone="active"] .dsh-wp-planrow-dot { background: var(--dsh-wp-active); }
|
|
@@ -820,6 +859,21 @@ window.__ModuleLoader__.load({
|
|
|
820
859
|
.dsh-wp-planrow[data-tone="blocked"] .dsh-wp-planrow-fill { background: var(--dsw-alias-state-error-primary); }
|
|
821
860
|
.dsh-wp-planrow-count { font-size: 12px; color: var(--dsw-alias-label-secondary, #475569); font-variant-numeric: tabular-nums; }
|
|
822
861
|
.dsh-wp-planrow-state { font-size: 11px; color: var(--dsw-alias-label-secondary, #475569); white-space: nowrap; }
|
|
862
|
+
.dsh-wp-planrow-panel { padding: 0 6px 10px 30px; min-width: 0; }
|
|
863
|
+
.dsh-wp-planrow-panel[hidden] { display: none; }
|
|
864
|
+
.dsh-wp-planrow-detail { display: grid; gap: 4px; font-size: 12px; color: var(--dsw-alias-label-secondary, #475569); overflow-wrap: anywhere; }
|
|
865
|
+
.dsh-wp-planrow-goal, .dsh-wp-planrow-checkpoint { line-height: 1.5; }
|
|
866
|
+
.dsh-wp-planrow-goal strong, .dsh-wp-planrow-checkpoint strong { color: var(--dsw-alias-label-primary, #0f172a); font-weight: 600; }
|
|
867
|
+
.dsh-wp-planrow-tasks { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 3px; }
|
|
868
|
+
.dsh-wp-planrow-task { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; min-width: 0; }
|
|
869
|
+
.dsh-wp-planrow-task-dot { flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; background: var(--dsw-alias-state-idle-primary); }
|
|
870
|
+
.dsh-wp-planrow-task[data-status="done"] .dsh-wp-planrow-task-dot { background: var(--dsh-wp-done); }
|
|
871
|
+
.dsh-wp-planrow-task[data-status="in_progress"] .dsh-wp-planrow-task-dot { background: var(--dsh-wp-active); }
|
|
872
|
+
.dsh-wp-planrow-task[data-status="blocked"] .dsh-wp-planrow-task-dot { background: var(--dsw-alias-state-error-primary); }
|
|
873
|
+
.dsh-wp-planrow-task-title { min-width: 0; color: var(--dsw-alias-label-primary, #0f172a); }
|
|
874
|
+
.dsh-wp-planrow-task-dept { color: var(--dsw-alias-label-secondary, #475569); }
|
|
875
|
+
.dsh-wp-planrow-task-state { margin-left: auto; white-space: nowrap; }
|
|
876
|
+
@media (prefers-reduced-motion: reduce) { .dsh-wp-planrow-chevron { transition: none; } }
|
|
823
877
|
.dsh-wp-sessions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 16px; align-items: start; }
|
|
824
878
|
.dsh-wp-session {
|
|
825
879
|
min-width: 0;
|
|
@@ -1124,7 +1178,14 @@ window.__ModuleLoader__.load({
|
|
|
1124
1178
|
function deptName(t, id) {
|
|
1125
1179
|
const key = `dept.${id}`;
|
|
1126
1180
|
const value = t(key);
|
|
1127
|
-
|
|
1181
|
+
/*
|
|
1182
|
+
* [1.12.0][D-09] 未知部门不再回显原文。
|
|
1183
|
+
*
|
|
1184
|
+
* 计划/回放里的非法值(拼错、旧版本、注入文本)不能成为面板分组标题
|
|
1185
|
+
* 或任务行文案。语言表缺键时统一显示「未知部门 / Unknown」,原文只
|
|
1186
|
+
* 留在服务端记录里供审计。
|
|
1187
|
+
*/
|
|
1188
|
+
return value === key ? t('dept.unknown') : value;
|
|
1128
1189
|
}
|
|
1129
1190
|
/*
|
|
1130
1191
|
* [1.11.0] 跨部门需求的四档文案(用户 m00687)。
|
|
@@ -1857,11 +1918,124 @@ window.__ModuleLoader__.load({
|
|
|
1857
1918
|
? h('span', { className: 'dsh-wp-planviz-alarm' }, `${counts.blocked} ${t('stats.blocked')}`)
|
|
1858
1919
|
: null, h('span', { className: 'dsh-wp-planviz-now', 'data-state': now.state }, h('span', { className: 'dsh-wp-planviz-now-dot', 'aria-hidden': 'true' }), h('span', { className: 'dsh-wp-planviz-now-text' }, now.text))), h(PlanSegments, { counts }), h(PlanLegend, { t, counts }), h(PlanStepper, { t, rows }));
|
|
1859
1920
|
}
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1921
|
+
/*
|
|
1922
|
+
* [1.12.0] 「分步进度」每一步的展开状态。
|
|
1923
|
+
*
|
|
1924
|
+
* 默认不展开;只有用户亲手点开/收起的步骤才写进 localStorage
|
|
1925
|
+
* (存的是「已展开的步骤 id」集合,而不是布尔值数组,新增步骤天然收起)。
|
|
1926
|
+
* 读不到 localStorage(隐私模式、旧 WebView、测试环境)时退回纯内存状态,
|
|
1927
|
+
* 不让存储失败影响交互。轮询刷新、重渲染、状态回放都不会改动这份状态。
|
|
1928
|
+
*/
|
|
1929
|
+
const PLANROW_STORAGE_PREFIX = 'dsh-workplan:planrow-open:v1';
|
|
1930
|
+
function planRowStorageKey(sessionId) {
|
|
1931
|
+
return `${PLANROW_STORAGE_PREFIX}:${String(sessionId ?? '')}`;
|
|
1932
|
+
}
|
|
1933
|
+
function readPlanRowOpen(sessionId) {
|
|
1934
|
+
try {
|
|
1935
|
+
const storage = typeof window !== 'undefined' ? window.localStorage : undefined;
|
|
1936
|
+
if (!storage || typeof storage.getItem !== 'function')
|
|
1937
|
+
return [];
|
|
1938
|
+
const raw = storage.getItem(planRowStorageKey(sessionId));
|
|
1939
|
+
if (!raw)
|
|
1940
|
+
return [];
|
|
1941
|
+
const parsed = JSON.parse(raw);
|
|
1942
|
+
if (!Array.isArray(parsed))
|
|
1943
|
+
return [];
|
|
1944
|
+
return Array.from(new Set(parsed.filter((id) => typeof id === 'string' && id !== '')));
|
|
1945
|
+
}
|
|
1946
|
+
catch {
|
|
1947
|
+
return [];
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
function writePlanRowOpen(sessionId, ids) {
|
|
1951
|
+
try {
|
|
1952
|
+
const storage = typeof window !== 'undefined' ? window.localStorage : undefined;
|
|
1953
|
+
if (!storage || typeof storage.setItem !== 'function')
|
|
1954
|
+
return;
|
|
1955
|
+
storage.setItem(planRowStorageKey(sessionId), JSON.stringify(ids));
|
|
1956
|
+
}
|
|
1957
|
+
catch {
|
|
1958
|
+
// 配额已满或存储被禁用:保留内存状态,不影响本次交互。
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
function planRowDomId(sessionId, rowId) {
|
|
1962
|
+
const safe = `${String(sessionId ?? '')}-${String(rowId ?? '')}`.replace(/[^A-Za-z0-9_-]+/g, '-');
|
|
1963
|
+
return `dsh-wp-planrow-${safe}`;
|
|
1964
|
+
}
|
|
1965
|
+
function planStepStateText(t, tone) {
|
|
1966
|
+
return tone === 'done'
|
|
1863
1967
|
? t('stats.done')
|
|
1864
|
-
: tone === 'active' ? t('stats.inProgress') : tone === 'blocked' ? t('stats.blocked') : t('stats.pending')
|
|
1968
|
+
: tone === 'active' ? t('stats.inProgress') : tone === 'blocked' ? t('stats.blocked') : t('stats.pending');
|
|
1969
|
+
}
|
|
1970
|
+
function planTaskStatus(value) {
|
|
1971
|
+
return value === 'done' || value === 'in_progress' || value === 'blocked' ? value : 'pending';
|
|
1972
|
+
}
|
|
1973
|
+
/*
|
|
1974
|
+
* 收起态与截图逐项一致:状态点、第 N 步:名称、进度条、done/total、状态词,
|
|
1975
|
+
* 只多一个折叠箭头。展开态放「该步摘要」(目标、检查点、子任务状态);
|
|
1976
|
+
* 完整明细仍由下方的阶段卡承担,避免 D-6 未拍板时出现两份完全相同的详情。
|
|
1977
|
+
*/
|
|
1978
|
+
function PlanStepRow({ t, row, stage, statuses, open, onToggle, panelId, }) {
|
|
1979
|
+
const width = row.total > 0 ? (row.done / row.total) * 100 : 0;
|
|
1980
|
+
const stop = (event) => {
|
|
1981
|
+
if (event && typeof event.stopPropagation === 'function')
|
|
1982
|
+
event.stopPropagation();
|
|
1983
|
+
};
|
|
1984
|
+
const handleClick = (event) => {
|
|
1985
|
+
stop(event);
|
|
1986
|
+
onToggle(!open);
|
|
1987
|
+
};
|
|
1988
|
+
const handleKeyDown = (event) => {
|
|
1989
|
+
const key = event?.key;
|
|
1990
|
+
// 原生 button 已经把 Enter/Space 变成 click;这里只阻止按键冒泡到外层卡片。
|
|
1991
|
+
if (key === 'Enter' || key === ' ' || key === 'Spacebar')
|
|
1992
|
+
stop(event);
|
|
1993
|
+
};
|
|
1994
|
+
const byId = new Map();
|
|
1995
|
+
for (const item of Array.isArray(statuses) ? statuses : []) {
|
|
1996
|
+
if (item && item.subtaskId != null)
|
|
1997
|
+
byId.set(String(item.subtaskId), item);
|
|
1998
|
+
}
|
|
1999
|
+
const subtasks = (Array.isArray(stage?.subtasks) ? stage.subtasks : [])
|
|
2000
|
+
.filter((subtask) => !subtask?.supersededAt);
|
|
2001
|
+
return h('section', {
|
|
2002
|
+
className: 'dsh-wp-planrow',
|
|
2003
|
+
'data-tone': row.tone,
|
|
2004
|
+
'data-current': row.current ? 'true' : 'false',
|
|
2005
|
+
'data-open': open ? 'true' : 'false',
|
|
2006
|
+
}, h('button', {
|
|
2007
|
+
type: 'button',
|
|
2008
|
+
className: 'dsh-wp-planrow-toggle',
|
|
2009
|
+
'aria-expanded': open,
|
|
2010
|
+
'aria-controls': panelId,
|
|
2011
|
+
onClick: handleClick,
|
|
2012
|
+
onKeyDown: handleKeyDown,
|
|
2013
|
+
}, h('span', { className: 'dsh-wp-planrow-chevron', 'aria-hidden': 'true' }), h('span', { className: 'dsh-wp-planrow-dot', 'aria-hidden': 'true' }), h('span', { className: 'dsh-wp-planrow-name' }, `${stageLabel(t, row.index)}:${row.name}`), h('span', { className: 'dsh-wp-planrow-bar' }, h('span', {
|
|
2014
|
+
className: 'dsh-wp-planrow-fill',
|
|
2015
|
+
'data-width': String(Math.round(width)),
|
|
2016
|
+
style: { width: `${width}%` },
|
|
2017
|
+
})), h('span', { className: 'dsh-wp-planrow-count' }, `${row.done}/${row.total}`), h('span', { className: 'dsh-wp-planrow-state' }, planStepStateText(t, row.tone))), h('div', { id: panelId, className: 'dsh-wp-planrow-panel', hidden: !open }, h('div', { className: 'dsh-wp-planrow-detail' }, stage?.goal
|
|
2018
|
+
? h('div', { className: 'dsh-wp-planrow-goal' }, h('strong', null, `${t('what')}:`), String(stage.goal))
|
|
2019
|
+
: null, stage?.checkpoint
|
|
2020
|
+
? h('div', { className: 'dsh-wp-planrow-checkpoint' }, h('strong', null, `${t('checkpoint')}:`), String(stage.checkpoint))
|
|
2021
|
+
: null, subtasks.length
|
|
2022
|
+
? h('ul', { className: 'dsh-wp-planrow-tasks' }, subtasks.map((subtask, index) => {
|
|
2023
|
+
const status = planTaskStatus(byId.get(String(subtask?.id))?.status);
|
|
2024
|
+
return h('li', {
|
|
2025
|
+
key: String(subtask?.id ?? index),
|
|
2026
|
+
className: 'dsh-wp-planrow-task',
|
|
2027
|
+
'data-status': status,
|
|
2028
|
+
}, h('span', { className: 'dsh-wp-planrow-task-dot', 'aria-hidden': 'true' }), h('span', { className: 'dsh-wp-planrow-task-title' }, `${t('workPrefix')} ${index + 1}:${String(subtask?.title ?? '')}`), h('span', { className: 'dsh-wp-planrow-task-dept' }, deptName(t, subtask?.department)), h('span', { className: 'dsh-wp-planrow-task-state' }, t(`status.${status}`)));
|
|
2029
|
+
}))
|
|
2030
|
+
: null)));
|
|
2031
|
+
}
|
|
2032
|
+
// 展开后的「分步进度」:逐阶段行 + 总体进度(与环/组头同一个计数口径)。
|
|
2033
|
+
function PlanOverview({ t, stats, counts, rows, stages, statuses, sessionId, openRows, onToggleRow, }) {
|
|
2034
|
+
const stagesById = new Map();
|
|
2035
|
+
for (const stage of Array.isArray(stages) ? stages : []) {
|
|
2036
|
+
if (stage?.id != null)
|
|
2037
|
+
stagesById.set(String(stage.id), stage);
|
|
2038
|
+
}
|
|
1865
2039
|
return h('div', {
|
|
1866
2040
|
className: 'dsh-wp-planoverview',
|
|
1867
2041
|
'data-plan-total': String(counts.total),
|
|
@@ -1877,22 +2051,35 @@ window.__ModuleLoader__.load({
|
|
|
1877
2051
|
*/
|
|
1878
2052
|
h('span', null, `${t('vizOverall')} ${counts.percent === null ? '—' : `${counts.percent}%`}`), h('span', null, `${counts.active} ${t('stats.inProgress')} · ${counts.pending} ${t('stats.pending')}`), counts.blocked > 0 ? h('span', null, `${counts.blocked} ${t('stats.blocked')}`) : null), rows.length
|
|
1879
2053
|
? h('div', { className: 'dsh-wp-planrows' }, rows.map((row) => {
|
|
1880
|
-
const
|
|
1881
|
-
return h(
|
|
2054
|
+
const panelId = `${planRowDomId(sessionId, row.id)}-panel`;
|
|
2055
|
+
return h(PlanStepRow, {
|
|
1882
2056
|
key: row.id,
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
})
|
|
2057
|
+
t,
|
|
2058
|
+
row,
|
|
2059
|
+
stage: stagesById.get(String(row.id)),
|
|
2060
|
+
statuses,
|
|
2061
|
+
open: openRows.includes(row.id),
|
|
2062
|
+
onToggle: (next) => onToggleRow(row.id, next),
|
|
2063
|
+
panelId,
|
|
2064
|
+
});
|
|
1891
2065
|
}))
|
|
1892
2066
|
: null);
|
|
1893
2067
|
}
|
|
1894
2068
|
function SessionCard({ session, t, open, onToggle }) {
|
|
1895
2069
|
const domId = `dsh-wp-session-${session.sessionId}`;
|
|
2070
|
+
/*
|
|
2071
|
+
* [1.12.0] 受控状态:展开哪几步只由这里决定,初始值只来自 localStorage
|
|
2072
|
+
* (默认空集)。不按「当前步骤」或进度自动展开,也不在数据更新时重置;
|
|
2073
|
+
* 卡片收起再展开时,PlanOverview 重新挂载也拿得到同一份选择。
|
|
2074
|
+
*/
|
|
2075
|
+
const [openPlanRows, setOpenPlanRows] = useState(() => readPlanRowOpen(session.sessionId));
|
|
2076
|
+
const togglePlanRow = (rowId, next) => {
|
|
2077
|
+
const nextOpen = next
|
|
2078
|
+
? [...openPlanRows.filter((id) => id !== rowId), rowId]
|
|
2079
|
+
: openPlanRows.filter((id) => id !== rowId);
|
|
2080
|
+
setOpenPlanRows(nextOpen);
|
|
2081
|
+
writePlanRowOpen(session.sessionId, nextOpen);
|
|
2082
|
+
};
|
|
1896
2083
|
const stats = session.stats || {};
|
|
1897
2084
|
// 1.5.0:折叠卡摘要=图表(环 + 百分比 + 四段构成条 + 图例 + 阶段步进条);
|
|
1898
2085
|
// 数字仍只来自 session.stats,与旧头部的口径完全一致,不引入第二套统计。
|
|
@@ -1919,7 +2106,17 @@ window.__ModuleLoader__.load({
|
|
|
1919
2106
|
badge: h(Pill, { tone }, phaseLabel(phase, session, t)),
|
|
1920
2107
|
}, session.updatedAt
|
|
1921
2108
|
? h('div', { className: 'dsh-wp-meta dsh-wp-session-updated' }, `${t('updatedAt')} ${formatTime(session.updatedAt)}`)
|
|
1922
|
-
: null, open === true ? h(PlanOverview, {
|
|
2109
|
+
: null, open === true ? h(PlanOverview, {
|
|
2110
|
+
t,
|
|
2111
|
+
stats,
|
|
2112
|
+
counts,
|
|
2113
|
+
rows: stageRows,
|
|
2114
|
+
stages: session.stages,
|
|
2115
|
+
statuses,
|
|
2116
|
+
sessionId: session.sessionId,
|
|
2117
|
+
openRows: openPlanRows,
|
|
2118
|
+
onToggleRow: togglePlanRow,
|
|
2119
|
+
}) : 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
2120
|
/*
|
|
1924
2121
|
* [1.11.0] 执行中收到的需求变更(T10 N5)。
|
|
1925
2122
|
*
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Department capability catalog (T10 / M2).
|
|
3
|
+
*
|
|
4
|
+
* Before 1.12.0 a department was nothing but a `{zh, en}` label: the planner
|
|
5
|
+
* prompt listed twelve names and `validatePlan` only checked that the value was
|
|
6
|
+
* one of the twelve keys. Nothing described what a department is responsible
|
|
7
|
+
* for, what it produces, or which task vocabulary belongs to it — so "部门分配
|
|
8
|
+
* 是否偏离" was not a question the code could answer.
|
|
9
|
+
*
|
|
10
|
+
* This module is the single source of truth for that missing semantic layer:
|
|
11
|
+
*
|
|
12
|
+
* - `responsibilities` — what the department owns (used by the planner prompt
|
|
13
|
+
* and by the child-agent prompt, so a department actually changes execution);
|
|
14
|
+
* - `outputs` — the typical deliverables (used to explain a match);
|
|
15
|
+
* - `keywords` — the vocabulary that identifies the department's work. These
|
|
16
|
+
* are deliberately concrete nouns/verbs, not generic words, because the
|
|
17
|
+
* matcher must be explainable and must not fire on every task.
|
|
18
|
+
*
|
|
19
|
+
* The catalog is pure data: no model call, no I/O, no configuration. That keeps
|
|
20
|
+
* the audit deterministic and testable, which is exactly what the acceptance
|
|
21
|
+
* criterion ("分配理由可追溯、可复跑") requires.
|
|
22
|
+
*
|
|
23
|
+
* Important boundary: a match is *evidence*, not authority. The model still
|
|
24
|
+
* chooses the department. The runtime only uses this catalog to detect a
|
|
25
|
+
* contradiction that is strong enough to be worth a retry (e.g. a picture-book
|
|
26
|
+
* task growing a penetration-testing subtask).
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Twelve departments, same ids and labels as `DEPARTMENTS` in plan.ts.
|
|
30
|
+
* A unit test asserts the two tables never drift.
|
|
31
|
+
*/
|
|
32
|
+
export const DEPARTMENT_CAPABILITIES = Object.freeze([
|
|
33
|
+
{
|
|
34
|
+
id: 'engineering',
|
|
35
|
+
zh: '工程研发',
|
|
36
|
+
en: 'Engineering',
|
|
37
|
+
responsibilities: ['代码实现与缺陷修复', '构建、编译与静态检查', '补丁应用与回归用例'],
|
|
38
|
+
outputs: ['代码或补丁', '构建产物', '回归测试结果'],
|
|
39
|
+
keywords: [
|
|
40
|
+
'代码', '实现', '修复', '补丁', 'patch', 'rebase', '构建', '编译', '重构',
|
|
41
|
+
'函数', '接口', '模块', '依赖', '提交', '合并', '分支', 'bug', 'tsc', '单元测试',
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'research',
|
|
46
|
+
zh: '研究分析',
|
|
47
|
+
en: 'Research',
|
|
48
|
+
responsibilities: ['调研与根因分析', '证据收集与交叉核对', '结论评估与方案对比'],
|
|
49
|
+
outputs: ['诊断报告', '证据索引', '分析与结论'],
|
|
50
|
+
keywords: [
|
|
51
|
+
'调研', '研究', '分析', '诊断', '证据', '评估', '根因', '审计', '对比',
|
|
52
|
+
'假设', '梳理', '阅读', '排查', '定性', '判定', '走查',
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'design',
|
|
57
|
+
zh: '设计',
|
|
58
|
+
en: 'Design',
|
|
59
|
+
responsibilities: ['交互与信息架构设计', '视觉、布局与样式', '原型与可用性验证'],
|
|
60
|
+
outputs: ['设计稿或原型', '交互说明', '视觉规范'],
|
|
61
|
+
keywords: [
|
|
62
|
+
'设计', '交互', '视觉', '布局', '原型', '样式', '配色', 'UI', 'UX',
|
|
63
|
+
'截图', '红圈', '折叠', '展开', '收起', '点击', '按钮', '页面', '组件', '渲染',
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 'product',
|
|
68
|
+
zh: '产品',
|
|
69
|
+
en: 'Product',
|
|
70
|
+
responsibilities: ['需求澄清与范围界定', '优先级与取舍', '验收标准与用户问题'],
|
|
71
|
+
outputs: ['需求单', '验收标准', '决策问题单'],
|
|
72
|
+
keywords: [
|
|
73
|
+
'需求', '范围', '优先级', '验收标准', '产品', '决策', '用户问题', '方案',
|
|
74
|
+
'取舍', '边界', '排期', '目标',
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 'data',
|
|
79
|
+
zh: '数据',
|
|
80
|
+
en: 'Data',
|
|
81
|
+
responsibilities: ['数据采集与清洗', '指标定义与统计', '数据集与可复现口径'],
|
|
82
|
+
outputs: ['数据集', '指标表', '统计脚本'],
|
|
83
|
+
keywords: [
|
|
84
|
+
'数据', '指标', '统计', '采集', '清洗', 'CSV', '行情', '回测', '量化',
|
|
85
|
+
'数据集', '样本', '口径', '权重', '收益率',
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 'qa',
|
|
90
|
+
zh: '质量验证',
|
|
91
|
+
en: 'QA',
|
|
92
|
+
responsibilities: ['测试设计与执行', '回归与验收证据', '缺陷复现与质量门禁'],
|
|
93
|
+
outputs: ['测试报告', '用例集', '缺陷清单'],
|
|
94
|
+
keywords: [
|
|
95
|
+
'测试', '用例', '回归', '验收', '复现', '缺陷', '质量', '断言',
|
|
96
|
+
'通过率', '门禁', 'npm test', 'fail', '端到端', '推演', '演练',
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: 'security',
|
|
101
|
+
zh: '安全',
|
|
102
|
+
en: 'Security',
|
|
103
|
+
responsibilities: ['安全审计与威胁建模', '漏洞与越权验证', '密钥与权限加固'],
|
|
104
|
+
outputs: ['安全报告', '漏洞清单', '加固建议'],
|
|
105
|
+
keywords: [
|
|
106
|
+
'安全', '漏洞', '渗透', '攻击', '越权', '权限', '密钥', '加密',
|
|
107
|
+
'威胁', '加固', '审计日志',
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: 'devops',
|
|
112
|
+
zh: '运维',
|
|
113
|
+
en: 'DevOps',
|
|
114
|
+
responsibilities: ['构建发布与制品管理', '流水线与部署', '监控与回滚'],
|
|
115
|
+
outputs: ['发布记录', '流水线配置', '回滚方案'],
|
|
116
|
+
keywords: [
|
|
117
|
+
'发布', '部署', '上线', 'CI', '流水线', '监控', '回滚', '镜像', '制品',
|
|
118
|
+
'npm', 'registry', 'tag', 'release', 'publish', '索引源',
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: 'writing',
|
|
123
|
+
zh: '文档写作',
|
|
124
|
+
en: 'Writing',
|
|
125
|
+
responsibilities: ['文档与报告撰写', '结构、措辞与排版', '版本说明与对外文案'],
|
|
126
|
+
outputs: ['文档或报告', 'README 或 CHANGELOG', '对外说明'],
|
|
127
|
+
keywords: [
|
|
128
|
+
'文档', '报告', '说明', '写作', '润色', 'README', 'CHANGELOG',
|
|
129
|
+
'排版', '措辞', '摘要', '变更说明', '对账', '对照表', '验收表',
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: 'operations',
|
|
134
|
+
zh: '运营',
|
|
135
|
+
en: 'Operations',
|
|
136
|
+
responsibilities: ['运营方案与活动策划', '用户增长与渠道', '客服与留存'],
|
|
137
|
+
outputs: ['运营方案', '活动计划', '渠道分析'],
|
|
138
|
+
keywords: ['运营', '活动', '增长', '渠道', '客服', '留存', '拉新', '转化'],
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: 'legal',
|
|
142
|
+
zh: '法务合规',
|
|
143
|
+
en: 'Legal',
|
|
144
|
+
responsibilities: ['合同与条款审查', '版权、许可与合规', '隐私与授权风险'],
|
|
145
|
+
outputs: ['法务意见', '合同条款', '合规清单'],
|
|
146
|
+
keywords: ['法务', '合同', '版权', '许可', '合规', '条款', '法律', '隐私', '授权', '侵权'],
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
id: 'finance',
|
|
150
|
+
zh: '财务',
|
|
151
|
+
en: 'Finance',
|
|
152
|
+
responsibilities: ['预算与成本核算', '结算与资金管理', '财务合规与凭证'],
|
|
153
|
+
outputs: ['预算表', '成本核算', '结算记录'],
|
|
154
|
+
keywords: ['财务', '预算', '成本', '结算', '发票', '报销', '资金', '利润', '现金流'],
|
|
155
|
+
},
|
|
156
|
+
]);
|
|
157
|
+
/** Departments whose domain keywords are strong enough to detect intrusion. */
|
|
158
|
+
export const DEPARTMENT_INTRUSION_GUARDED = Object.freeze([
|
|
159
|
+
'security',
|
|
160
|
+
'legal',
|
|
161
|
+
'finance',
|
|
162
|
+
'operations',
|
|
163
|
+
]);
|
|
164
|
+
const CAPABILITY_MAP = Object.freeze(Object.fromEntries(DEPARTMENT_CAPABILITIES.map((entry) => [entry.id, entry])));
|
|
165
|
+
export const DEPARTMENT_CAPABILITY_IDS = Object.freeze(DEPARTMENT_CAPABILITIES.map((entry) => entry.id));
|
|
166
|
+
export function departmentCapability(id) {
|
|
167
|
+
if (typeof id !== 'string')
|
|
168
|
+
return null;
|
|
169
|
+
return CAPABILITY_MAP[id] ?? null;
|
|
170
|
+
}
|
|
171
|
+
function escapeRegExp(value) {
|
|
172
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Keyword match that understands the difference between a CJK substring and a
|
|
176
|
+
* short ASCII token. `ui` must not match inside `build`; `rebase` may match
|
|
177
|
+
* inside `rebased` because that is still the same concept.
|
|
178
|
+
*/
|
|
179
|
+
export function keywordHit(text, keyword) {
|
|
180
|
+
if (typeof text !== 'string' || typeof keyword !== 'string')
|
|
181
|
+
return false;
|
|
182
|
+
const haystack = text.toLowerCase();
|
|
183
|
+
const needle = keyword.trim().toLowerCase();
|
|
184
|
+
if (!needle)
|
|
185
|
+
return false;
|
|
186
|
+
if (/^[a-z0-9+#./-]+$/.test(needle) && needle.length <= 3) {
|
|
187
|
+
return new RegExp(`(^|[^a-z0-9])${escapeRegExp(needle)}([^a-z0-9]|$)`).test(haystack);
|
|
188
|
+
}
|
|
189
|
+
return haystack.includes(needle);
|
|
190
|
+
}
|
|
191
|
+
/** All catalog keywords of one department that occur in `text`, in catalog order. */
|
|
192
|
+
export function matchDepartmentKeywords(text, departmentId) {
|
|
193
|
+
const capability = departmentCapability(departmentId);
|
|
194
|
+
if (!capability)
|
|
195
|
+
return [];
|
|
196
|
+
return capability.keywords.filter((keyword) => keywordHit(text, keyword));
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Rank every department against one piece of text.
|
|
200
|
+
*
|
|
201
|
+
* The score is the number of distinct catalog keywords found. It is a
|
|
202
|
+
* deliberately simple, explainable number: every point maps to a keyword the
|
|
203
|
+
* reader can see in the output. No weights are hidden.
|
|
204
|
+
*/
|
|
205
|
+
export function scoreDepartments(text) {
|
|
206
|
+
return DEPARTMENT_CAPABILITIES
|
|
207
|
+
.map((capability) => {
|
|
208
|
+
const matched = capability.keywords.filter((keyword) => keywordHit(text, keyword));
|
|
209
|
+
return {
|
|
210
|
+
id: capability.id,
|
|
211
|
+
zh: capability.zh,
|
|
212
|
+
en: capability.en,
|
|
213
|
+
score: matched.length,
|
|
214
|
+
matched,
|
|
215
|
+
};
|
|
216
|
+
})
|
|
217
|
+
.sort((a, b) => b.score - a.score || a.id.localeCompare(b.id));
|
|
218
|
+
}
|
package/lib/host.js
CHANGED
|
@@ -12,7 +12,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
12
12
|
* - the read-only dashboard route.
|
|
13
13
|
*/
|
|
14
14
|
import { applyHardeningHeaders, cancelToolOutputSchema, createWorkplanRuntime, dispatchToolOutputSchema, plannerOutputSchema, replanToolOutputSchema, statusToolOutputSchema, updateToolOutputSchema, } from './runtime.js';
|
|
15
|
-
import { isRecord } from './plan.js';
|
|
15
|
+
import { DEPARTMENT_IDS, isRecord } from './plan.js';
|
|
16
16
|
import { autoResumeEnabledFrom } from './auto-resume.js';
|
|
17
17
|
/*
|
|
18
18
|
* [1.8.14] Identity of the modules this process actually loaded (N1).
|
|
@@ -234,6 +234,17 @@ function createUpdateTool(runtime) {
|
|
|
234
234
|
type: 'string',
|
|
235
235
|
description: '补充说明;会显示在任务卡片中。',
|
|
236
236
|
},
|
|
237
|
+
/*
|
|
238
|
+
* [1.12.0][D-28] 结果消息指引的 `update + instruction` 必须真的能通过
|
|
239
|
+
* schema 校验。runtime 的 updateStatus 一直读 args.instruction,但这里
|
|
240
|
+
* 因 additionalProperties:false 从未声明该字段:严格宿主会直接拒绝,
|
|
241
|
+
* 模型只能看到「该动作不存在」。与 dsh_workplan_instruct 等价,二选一。
|
|
242
|
+
*/
|
|
243
|
+
instruction: {
|
|
244
|
+
type: 'string',
|
|
245
|
+
description: '待指示项(closure=escalated)的答复文本:与 status="in_progress" 一起使用,'
|
|
246
|
+
+ '会投递给子会话并把该行恢复为执行中。等价于 dsh_workplan_instruct。',
|
|
247
|
+
},
|
|
237
248
|
},
|
|
238
249
|
required: ['subtaskId', 'status'],
|
|
239
250
|
additionalProperties: false,
|
|
@@ -323,7 +334,12 @@ function createReplanTool(runtime) {
|
|
|
323
334
|
properties: {
|
|
324
335
|
id: { type: 'string', description: '接替行 ID(默认在旧 ID 后加 b);最长 16 字符,不能与现有 ID 重复。' },
|
|
325
336
|
title: { type: 'string' },
|
|
326
|
-
department: {
|
|
337
|
+
department: {
|
|
338
|
+
type: 'string',
|
|
339
|
+
/* [1.12.0][D-07] 与规划入口同源:模型先选合法 key,而不是先写自由文本再被运行期拒绝。 */
|
|
340
|
+
enum: [...DEPARTMENT_IDS],
|
|
341
|
+
description: '受影响的部门 key(必须是规划器枚举之一)。',
|
|
342
|
+
},
|
|
327
343
|
role: { type: 'string' },
|
|
328
344
|
objective: { type: 'string' },
|
|
329
345
|
method: { type: 'array', items: { type: 'string' } },
|
|
@@ -341,7 +357,12 @@ function createReplanTool(runtime) {
|
|
|
341
357
|
id: { type: 'string', description: '新行 ID;省略时自动生成 R<修订号>-<序号>。' },
|
|
342
358
|
title: { type: 'string' },
|
|
343
359
|
objective: { type: 'string' },
|
|
344
|
-
department: {
|
|
360
|
+
department: {
|
|
361
|
+
type: 'string',
|
|
362
|
+
/* [1.12.0][D-07] 同 replacement.department:枚举与规划入口同源。 */
|
|
363
|
+
enum: [...DEPARTMENT_IDS],
|
|
364
|
+
description: '新行所属部门 key(必须是规划器枚举之一)。',
|
|
365
|
+
},
|
|
345
366
|
role: { type: 'string' },
|
|
346
367
|
method: { type: 'array', items: { type: 'string' } },
|
|
347
368
|
inputs: { type: 'array', items: { type: 'string' } },
|
|
@@ -1016,6 +1037,11 @@ export function apply(ctx, config = {}) {
|
|
|
1016
1037
|
* 与 autoResume 用同一种写法:未配置时走默认值,而不是悄悄等于 false。
|
|
1017
1038
|
*/
|
|
1018
1039
|
strictEvidence: strictCompletionEnabledFrom(config.strictCompletion, settingEnv('DSH_WORKPLAN_STRICT_COMPLETION')),
|
|
1040
|
+
/*
|
|
1041
|
+
* [1.12.0] 自动派发三态:显式配置 > 显式环境变量 > 默认 true。
|
|
1042
|
+
* 与 autoResume / strictCompletion 同一写法,避免「没配置就等于关闭」。
|
|
1043
|
+
*/
|
|
1044
|
+
autoDispatch: strictCompletionEnabledFrom(config.autoDispatch, settingEnv('DSH_WORKPLAN_AUTO_DISPATCH')),
|
|
1019
1045
|
});
|
|
1020
1046
|
ctx.effect(() => ctx.systemPrompt.section({
|
|
1021
1047
|
name: 'dsh-workplan',
|
|
@@ -1120,7 +1146,7 @@ export function apply(ctx, config = {}) {
|
|
|
1120
1146
|
}
|
|
1121
1147
|
export const meta = {
|
|
1122
1148
|
name,
|
|
1123
|
-
version: '1.
|
|
1149
|
+
version: '1.12.0',
|
|
1124
1150
|
promptOrder: PROMPT_ORDER,
|
|
1125
1151
|
routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
|
|
1126
1152
|
};
|