dsh-leader-agent 0.3.1 → 0.4.1
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/.agents/skills/e2e-scenarios/SKILL.md +63 -0
- package/.agents/skills/leader-mode/playbooks/program.md +1 -1
- package/README.md +4 -4
- package/README_ZH.md +4 -4
- package/lib/client.js +510 -149
- package/package.json +2 -2
- package/src/client/{worker-report-styles.js → agent-bubble-styles.js} +28 -28
- package/src/client/agent-bubble-view.js +142 -0
- package/src/client/board-projection.js +39 -0
- package/src/client/board-styles.js +25 -1
- package/src/client/board.js +27 -1
- package/src/client/bubble-clock.js +30 -0
- package/src/client/card-links-editor.js +1 -1
- package/src/client/icons.js +16 -15
- package/src/client/index.js +30 -20
- package/src/client/markdown.js +1 -1
- package/src/client/project-panel.js +97 -18
- package/src/client/project-section.js +26 -16
- package/src/client/session-completion.js +89 -0
- package/src/client/session-watermark.js +70 -23
- package/src/client/worker-report-avatar.js +1 -1
- package/src/client/worker-report-definition.js +3 -2
- package/src/client/worker-report-view.js +22 -156
- package/src/client/worker-task-definition.js +72 -0
- package/src/client/worker-task-styles.js +97 -0
- package/src/client/worker-task-view.js +84 -0
- package/src/host/dispatch.js +26 -21
- package/src/host/message.js +0 -25
- package/src/host/projects/service.js +49 -37
- package/src/host/tools/message-worker.js +7 -7
- package/src/host/worker-sessions.js +71 -11
- package/src/host/worker-transcript.js +5 -4
- package/src/shared/message-text.js +64 -0
- package/src/shared/worker-report.js +6 -41
- package/src/shared/worker-task.js +33 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-leader-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Leader-driven dispatch for DeepSeek Harness: protocol skills, project bootstrap, and a delivery board.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"test": "node --test tests/*.test.js",
|
|
34
34
|
"test:coverage": "node scripts/verify-coverage.mjs",
|
|
35
|
-
"e2e": "npm run build:client &&
|
|
35
|
+
"e2e": "npm run build:client && for f in tests/e2e/*.e2e.js; do node --test \"$f\" || exit 1; done",
|
|
36
36
|
"e2e:install": "playwright install chromium",
|
|
37
37
|
"check": "node scripts/verify-agent-note-format.mjs && node scripts/verify-doc-tool-names.mjs && node scripts/verify-doc-budgets.mjs && node scripts/check-syntax.mjs && node scripts/verify-coverage.mjs",
|
|
38
38
|
"build:client": "node build/client.mjs",
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* worker
|
|
2
|
+
* worker 回报的左侧 agent 气泡样式。
|
|
3
3
|
*
|
|
4
4
|
* 颜色与圆角全部走宿主 `--dsw-*` 令牌,不写死色值。组件能从基线模块 import,样式
|
|
5
5
|
* 拿不到:宿主包的 CSS module 在构建期编译成哈希类名、映射留在宿主产物里(包的
|
|
6
6
|
* `./src/*` 导出指向源码,`files` 只发 `lib/`),跨 bundle 能引用的只有 CSS 变量。
|
|
7
7
|
*
|
|
8
|
-
* @module dsh-leader-agent/client/
|
|
8
|
+
* @module dsh-leader-agent/client/agent-bubble-styles
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const STYLE_ID = 'dsh-leader-agent-
|
|
11
|
+
const STYLE_ID = 'dsh-leader-agent-agent-bubble'
|
|
12
12
|
|
|
13
13
|
const STYLE_TEXT = `
|
|
14
|
-
.dsh-leader-agent-
|
|
14
|
+
.dsh-leader-agent-agent-bubble {
|
|
15
15
|
display: flex;
|
|
16
16
|
flex-direction: column;
|
|
17
17
|
align-items: flex-start;
|
|
@@ -19,20 +19,20 @@ const STYLE_TEXT = `
|
|
|
19
19
|
width: 100%;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
.dsh-leader-agent-
|
|
22
|
+
.dsh-leader-agent-agent-bubble__identity {
|
|
23
23
|
display: flex;
|
|
24
24
|
align-items: center;
|
|
25
25
|
gap: 6px;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.dsh-leader-agent-
|
|
28
|
+
.dsh-leader-agent-agent-bubble__avatar {
|
|
29
29
|
width: 20px;
|
|
30
30
|
height: 20px;
|
|
31
31
|
border-radius: 5px;
|
|
32
32
|
flex-shrink: 0;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
.dsh-leader-agent-
|
|
35
|
+
.dsh-leader-agent-agent-bubble__name {
|
|
36
36
|
font-size: 12px;
|
|
37
37
|
font-weight: 500;
|
|
38
38
|
color: var(--dsw-alias-label-secondary);
|
|
@@ -43,14 +43,14 @@ const STYLE_TEXT = `
|
|
|
43
43
|
font-family: inherit;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
.dsh-leader-agent-
|
|
46
|
+
.dsh-leader-agent-agent-bubble__name:hover {
|
|
47
47
|
color: var(--dsw-alias-label-primary);
|
|
48
48
|
text-decoration: underline;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
.dsh-leader-agent-
|
|
51
|
+
.dsh-leader-agent-agent-bubble__bubble {
|
|
52
52
|
/* 行高取 compact 变体的值,与 MarkdownText 内部排版一致,否则折叠水位会差半行 */
|
|
53
|
-
--dsh-leader-agent-
|
|
53
|
+
--dsh-leader-agent-bubble-line: calc(20px + var(--dsh-content-font-delta-secondary, 0px));
|
|
54
54
|
box-sizing: border-box;
|
|
55
55
|
display: flex;
|
|
56
56
|
flex-direction: column;
|
|
@@ -65,12 +65,12 @@ const STYLE_TEXT = `
|
|
|
65
65
|
border-radius: var(--dsw-radius-xl);
|
|
66
66
|
padding: 10px 16px 12px;
|
|
67
67
|
font-size: var(--dsh-content-font-size, 14px);
|
|
68
|
-
line-height: var(--dsh-leader-agent-
|
|
68
|
+
line-height: var(--dsh-leader-agent-bubble-line);
|
|
69
69
|
color: var(--dsw-alias-label-primary);
|
|
70
70
|
word-break: break-word;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
.dsh-leader-agent-
|
|
73
|
+
.dsh-leader-agent-agent-bubble__content {
|
|
74
74
|
/* flex 容器里 align-items: flex-start 会让子项按内容收缩,显式撑满才不会提前换行 */
|
|
75
75
|
width: 100%;
|
|
76
76
|
}
|
|
@@ -78,30 +78,30 @@ const STYLE_TEXT = `
|
|
|
78
78
|
/* 同 card-detail-text:compact 变体把正文压成三级标签色、链接变成 inherit。
|
|
79
79
|
容器类 + data-markdown-variant 是 (0,2,0),压过 .compact 的 (0,1,0);
|
|
80
80
|
链接到 (0,2,1),压过 .compact a 的 (0,1,1)——特异性更高,不靠注入顺序。 */
|
|
81
|
-
.dsh-leader-agent-
|
|
81
|
+
.dsh-leader-agent-agent-bubble__bubble [data-markdown-variant='compact'] {
|
|
82
82
|
color: var(--dsw-alias-label-primary);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
.dsh-leader-agent-
|
|
85
|
+
.dsh-leader-agent-agent-bubble__bubble [data-markdown-variant='compact'] a {
|
|
86
86
|
color: var(--dsw-alias-link);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
/*
|
|
90
|
-
|
|
91
|
-
.dsh-leader-agent-
|
|
89
|
+
/* 纯文本正文:worker 回报的旧消息(没有 report,回退整条通知正文)与失败原因走这里。
|
|
90
|
+
逐行内容交给 Markdown 会被软换行折成一段。 */
|
|
91
|
+
.dsh-leader-agent-agent-bubble__plain {
|
|
92
92
|
white-space: pre-wrap;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
/*
|
|
95
|
+
/* 默认只露两行:一次回报动辄一屏,先给摘要,细节按需展开。
|
|
96
96
|
正文是块级元素(段落、列表、代码块),line-clamp 只能截纯文本行;按行高算
|
|
97
97
|
max-height 才对块级内容生效。多出的 4px 是 compact 段落的上边距,不加会把第二行
|
|
98
98
|
的下缘裁掉。裁剪只落在正文层,气泡内的展开按钮不跟着被截。 */
|
|
99
|
-
.dsh-leader-agent-
|
|
100
|
-
max-height: calc(2 * var(--dsh-leader-agent-
|
|
99
|
+
.dsh-leader-agent-agent-bubble__content[data-collapsed='true'] {
|
|
100
|
+
max-height: calc(2 * var(--dsh-leader-agent-bubble-line) + 4px);
|
|
101
101
|
overflow: hidden;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
.dsh-leader-agent-
|
|
104
|
+
.dsh-leader-agent-agent-bubble__toggle {
|
|
105
105
|
align-self: flex-start;
|
|
106
106
|
padding: 0 2px;
|
|
107
107
|
border: none;
|
|
@@ -113,23 +113,23 @@ const STYLE_TEXT = `
|
|
|
113
113
|
cursor: pointer;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
.dsh-leader-agent-
|
|
116
|
+
.dsh-leader-agent-agent-bubble__toggle:hover {
|
|
117
117
|
color: var(--dsw-alias-label-secondary);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
.dsh-leader-agent-
|
|
120
|
+
.dsh-leader-agent-agent-bubble__meta {
|
|
121
121
|
display: flex;
|
|
122
122
|
align-items: center;
|
|
123
123
|
gap: 6px;
|
|
124
124
|
padding-left: 2px;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
.dsh-leader-agent-
|
|
127
|
+
.dsh-leader-agent-agent-bubble__time {
|
|
128
128
|
font-size: 11px;
|
|
129
129
|
color: var(--dsw-alias-label-tertiary);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
.dsh-leader-agent-
|
|
132
|
+
.dsh-leader-agent-agent-bubble__copy {
|
|
133
133
|
display: inline-flex;
|
|
134
134
|
align-items: center;
|
|
135
135
|
justify-content: center;
|
|
@@ -143,17 +143,17 @@ const STYLE_TEXT = `
|
|
|
143
143
|
cursor: pointer;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
.dsh-leader-agent-
|
|
146
|
+
.dsh-leader-agent-agent-bubble__copy:hover {
|
|
147
147
|
background: color-mix(in srgb, var(--dsw-alias-label-primary) 8%, transparent);
|
|
148
148
|
color: var(--dsw-alias-label-secondary);
|
|
149
149
|
}
|
|
150
150
|
`
|
|
151
151
|
|
|
152
152
|
/**
|
|
153
|
-
* 注入
|
|
153
|
+
* 注入 agent 气泡的样式(同一页面只注入一次)。
|
|
154
154
|
* @returns {void}
|
|
155
155
|
*/
|
|
156
|
-
export function
|
|
156
|
+
export function ensureAgentBubbleStyles() {
|
|
157
157
|
if (typeof document === 'undefined') return
|
|
158
158
|
if (document.getElementById(STYLE_ID) !== null) return
|
|
159
159
|
const style = document.createElement('style')
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* worker 回报气泡的渲染组件。
|
|
3
|
+
*
|
|
4
|
+
* 形态:身份头(头像 + 名字)在气泡上方单独一行,气泡本身左对齐、用宿主消息气泡
|
|
5
|
+
* 的底色、无描边——读起来像另一个 agent 在说话,而不是用户在说话。
|
|
6
|
+
*
|
|
7
|
+
* 正文按 `format` 交给宿主基线的 `MarkdownText`,逐行协议字段回退纯文本。默认只
|
|
8
|
+
* 露两行,超出时给「展示更多」;气泡下方一行是时间与复制按钮,与官方消息的底部
|
|
9
|
+
* chrome 同形。
|
|
10
|
+
*
|
|
11
|
+
* @module dsh-leader-agent/client/agent-bubble-view
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { createElement, useLayoutEffect, useRef, useState } from 'react'
|
|
15
|
+
import { agentAvatarDataUri } from './worker-report-avatar.js'
|
|
16
|
+
import { ensureAgentBubbleStyles } from './agent-bubble-styles.js'
|
|
17
|
+
import { formatBubbleClock } from './bubble-clock.js'
|
|
18
|
+
import { Markdown } from './markdown.js'
|
|
19
|
+
import { productIcon } from './icons.js'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 渲染一条 worker 回报气泡。
|
|
23
|
+
*
|
|
24
|
+
* @param {object} props - 组件属性
|
|
25
|
+
* @param {string} props.name - 说话方的显示名(身份头文本)
|
|
26
|
+
* @param {string} props.avatarSeed - 头像种子;同名恒同图
|
|
27
|
+
* @param {string} props.openTitle - 身份按钮的 title 提示
|
|
28
|
+
* @param {() => void} [props.onOpenName] - 点击身份名时的动作(通常打开说话方的会话)
|
|
29
|
+
* @param {string} props.body - 气泡正文
|
|
30
|
+
* @param {'markdown' | 'text'} props.format - 正文渲染方式
|
|
31
|
+
* @param {number} props.time - 消息时间(毫秒)
|
|
32
|
+
* @returns {object} React 元素
|
|
33
|
+
*/
|
|
34
|
+
export function AgentBubble({ name, avatarSeed, openTitle, onOpenName, body, format, time }) {
|
|
35
|
+
const [copied, setCopied] = useState(false)
|
|
36
|
+
/** 是否展开全文。默认折叠:一条消息常常一屏,先给摘要。 */
|
|
37
|
+
const [expanded, setExpanded] = useState(false)
|
|
38
|
+
/** 折叠后是否真的有两行以上的内容——没有就不必给「展示更多」。 */
|
|
39
|
+
const [overflowing, setOverflowing] = useState(false)
|
|
40
|
+
const bubbleRef = useRef(null)
|
|
41
|
+
|
|
42
|
+
// 样式必须在测量之前进 DOM,所以放在 layout 阶段而不是被动 effect:后者晚于
|
|
43
|
+
// 绘制,首帧的 clamp 规则还没生效,`scrollHeight === clientHeight` 会量成「没
|
|
44
|
+
// 溢出」,气泡先铺开全文再收起。注入本身幂等,跟着 body 变化重入也无所谓。
|
|
45
|
+
//
|
|
46
|
+
// 只有折叠态才量:展开后 `scrollHeight === clientHeight`,一量就会把按钮收掉,
|
|
47
|
+
// 用户也就点不回折叠了。宽度变化(窗口缩放、字体档位)要重算,所以也听 resize。
|
|
48
|
+
useLayoutEffect(() => {
|
|
49
|
+
ensureAgentBubbleStyles()
|
|
50
|
+
const element = bubbleRef.current
|
|
51
|
+
if (element === null || expanded) return undefined
|
|
52
|
+
const measure = () => { setOverflowing(element.scrollHeight > element.clientHeight + 1) }
|
|
53
|
+
measure()
|
|
54
|
+
if (typeof ResizeObserver === 'undefined') return undefined
|
|
55
|
+
const observer = new ResizeObserver(measure)
|
|
56
|
+
observer.observe(element)
|
|
57
|
+
return () => observer.disconnect()
|
|
58
|
+
}, [body, expanded])
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 把正文复制到剪贴板。
|
|
62
|
+
* @returns {Promise<void>} 复制完成
|
|
63
|
+
*/
|
|
64
|
+
const copy = async () => {
|
|
65
|
+
try {
|
|
66
|
+
await navigator.clipboard.writeText(body)
|
|
67
|
+
} catch {
|
|
68
|
+
// 剪贴板不可用(非安全上下文或权限被拒):静默跳过,不打断阅读。
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
setCopied(true)
|
|
72
|
+
setTimeout(() => setCopied(false), 1500)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return createElement(
|
|
76
|
+
'div',
|
|
77
|
+
{ className: 'dsh-leader-agent-agent-bubble' },
|
|
78
|
+
createElement(
|
|
79
|
+
'div',
|
|
80
|
+
{ className: 'dsh-leader-agent-agent-bubble__identity' },
|
|
81
|
+
createElement('img', {
|
|
82
|
+
className: 'dsh-leader-agent-agent-bubble__avatar',
|
|
83
|
+
src: agentAvatarDataUri(avatarSeed),
|
|
84
|
+
alt: '',
|
|
85
|
+
}),
|
|
86
|
+
createElement(
|
|
87
|
+
'button',
|
|
88
|
+
{
|
|
89
|
+
type: 'button',
|
|
90
|
+
className: 'dsh-leader-agent-agent-bubble__name',
|
|
91
|
+
title: openTitle,
|
|
92
|
+
onClick: () => onOpenName?.(),
|
|
93
|
+
},
|
|
94
|
+
name,
|
|
95
|
+
),
|
|
96
|
+
),
|
|
97
|
+
createElement(
|
|
98
|
+
'div',
|
|
99
|
+
{ className: 'dsh-leader-agent-agent-bubble__bubble' },
|
|
100
|
+
// 裁剪只发生在正文层:按钮在气泡内、正文外,否则展开开关会跟着两行水位被裁掉
|
|
101
|
+
createElement(
|
|
102
|
+
'div',
|
|
103
|
+
{
|
|
104
|
+
ref: bubbleRef,
|
|
105
|
+
className: 'dsh-leader-agent-agent-bubble__content',
|
|
106
|
+
'data-collapsed': expanded ? undefined : 'true',
|
|
107
|
+
},
|
|
108
|
+
format === 'markdown'
|
|
109
|
+
? createElement(Markdown, { source: body })
|
|
110
|
+
: createElement('div', { className: 'dsh-leader-agent-agent-bubble__plain' }, body),
|
|
111
|
+
),
|
|
112
|
+
overflowing
|
|
113
|
+
? createElement(
|
|
114
|
+
'button',
|
|
115
|
+
{
|
|
116
|
+
type: 'button',
|
|
117
|
+
className: 'dsh-leader-agent-agent-bubble__toggle',
|
|
118
|
+
'aria-expanded': expanded,
|
|
119
|
+
onClick: () => setExpanded((value) => !value),
|
|
120
|
+
},
|
|
121
|
+
expanded ? '收起' : '展示更多',
|
|
122
|
+
)
|
|
123
|
+
: null,
|
|
124
|
+
),
|
|
125
|
+
createElement(
|
|
126
|
+
'div',
|
|
127
|
+
{ className: 'dsh-leader-agent-agent-bubble__meta' },
|
|
128
|
+
createElement('span', { className: 'dsh-leader-agent-agent-bubble__time' }, formatBubbleClock(time)),
|
|
129
|
+
createElement(
|
|
130
|
+
'button',
|
|
131
|
+
{
|
|
132
|
+
type: 'button',
|
|
133
|
+
className: 'dsh-leader-agent-agent-bubble__copy',
|
|
134
|
+
'aria-label': copied ? '已复制' : '复制',
|
|
135
|
+
title: copied ? '已复制' : '复制',
|
|
136
|
+
onClick: () => { void copy() },
|
|
137
|
+
},
|
|
138
|
+
productIcon(copied ? 'check-outline' : 'copy-outline', { size: 14 }),
|
|
139
|
+
),
|
|
140
|
+
),
|
|
141
|
+
)
|
|
142
|
+
}
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* @module dsh-leader-agent/client/board-projection
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import { foldRows, nextRowWatermark } from './session-watermark.js'
|
|
20
|
+
|
|
19
21
|
/**
|
|
20
22
|
* 停滞阈值:名下有会话但 24h 无活动。
|
|
21
23
|
*/
|
|
@@ -248,6 +250,43 @@ export function sortDoneCards(cards) {
|
|
|
248
250
|
})
|
|
249
251
|
}
|
|
250
252
|
|
|
253
|
+
/**
|
|
254
|
+
* done 折叠区分页:默认露出一页,点「展开其余」再加一页。
|
|
255
|
+
*
|
|
256
|
+
* 页大小比宿主会话列表(5 条)大:已完成卡是历史浏览,30 张一页更省点击。
|
|
257
|
+
*/
|
|
258
|
+
export const DONE_PAGE_SIZE = 30
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* 按水位切出 done 折叠区的可见卡片。
|
|
262
|
+
*
|
|
263
|
+
* 口径与项目树的会话折叠共用 `session-watermark.js` 的 `foldRows`:默认露出
|
|
264
|
+
* 一页,点「展开其余」再加一页,剩余不超过一页时一次放完;展开到最后一页后
|
|
265
|
+
* 按钮变成「收起」,收起回落到基线。已完成卡没有运行中 / 完成未读这类注意力
|
|
266
|
+
* 状态,基线就是一页。
|
|
267
|
+
*
|
|
268
|
+
* @param {readonly object[]} cards - 已排序的 done 卡
|
|
269
|
+
* @param {number} watermark - 用户展开出来的水位(0 表示没展开过)
|
|
270
|
+
* @returns {{ rows: object[], hiddenCount: number, expanded: boolean, expandLabel: string }} 视图
|
|
271
|
+
*/
|
|
272
|
+
export function foldDoneCards(cards, watermark) {
|
|
273
|
+
return foldRows(cards, watermark, { pageSize: DONE_PAGE_SIZE, noun: '卡片' })
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* 点「展开其余」之后的新水位。
|
|
278
|
+
*
|
|
279
|
+
* 共享口径见 `nextRowWatermark`:剩余不超过一整页时一次放完(Infinity),
|
|
280
|
+
* 否则在当前可见数上再加一页。
|
|
281
|
+
*
|
|
282
|
+
* @param {number} hiddenCount - 当前被藏起来的张数
|
|
283
|
+
* @param {number} visibleCount - 当前可见张数
|
|
284
|
+
* @returns {number} 新水位
|
|
285
|
+
*/
|
|
286
|
+
export function nextDoneWatermark(hiddenCount, visibleCount) {
|
|
287
|
+
return nextRowWatermark(hiddenCount, visibleCount, DONE_PAGE_SIZE)
|
|
288
|
+
}
|
|
289
|
+
|
|
251
290
|
/**
|
|
252
291
|
* 把一次改卡的结果合进看板列表。
|
|
253
292
|
*
|
|
@@ -405,7 +405,8 @@ const STYLE_TEXT = `
|
|
|
405
405
|
.dsh-leader-agent-board-done-title {
|
|
406
406
|
flex: 1;
|
|
407
407
|
min-width: 0;
|
|
408
|
-
|
|
408
|
+
/* 与卡号同字号:完成区是历史浏览,字号不该比卡号更抢眼 */
|
|
409
|
+
font-size: 11px;
|
|
409
410
|
line-height: 20px;
|
|
410
411
|
color: var(--dsw-alias-label-tertiary);
|
|
411
412
|
overflow: hidden;
|
|
@@ -475,6 +476,29 @@ const STYLE_TEXT = `
|
|
|
475
476
|
color: var(--dsw-alias-label-tertiary);
|
|
476
477
|
}
|
|
477
478
|
|
|
479
|
+
/* 「展开其余 / 收起」:外观照宿主工作区树的 overflow 按钮(12px、三级标签色、
|
|
480
|
+
等宽行高,悬停提亮到二级色),左内边距与 done 行卡面对齐 */
|
|
481
|
+
.dsh-leader-agent-board-done-more {
|
|
482
|
+
box-sizing: border-box;
|
|
483
|
+
width: 100%;
|
|
484
|
+
height: 28px;
|
|
485
|
+
padding: 0 10px;
|
|
486
|
+
border: 0;
|
|
487
|
+
border-radius: var(--dsw-radius-sm);
|
|
488
|
+
background: transparent;
|
|
489
|
+
color: var(--dsw-alias-label-tertiary);
|
|
490
|
+
font-size: 12px;
|
|
491
|
+
line-height: 28px;
|
|
492
|
+
text-align: left;
|
|
493
|
+
cursor: pointer;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
@media (hover: hover) {
|
|
497
|
+
.dsh-leader-agent-board-done-more:hover {
|
|
498
|
+
color: var(--dsw-alias-label-secondary);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
478
502
|
/* 骨架与空态 */
|
|
479
503
|
.dsh-leader-agent-board-skeleton {
|
|
480
504
|
height: 64px;
|
package/src/client/board.js
CHANGED
|
@@ -21,10 +21,12 @@
|
|
|
21
21
|
|
|
22
22
|
import { createElement, useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
23
23
|
import {
|
|
24
|
+
foldDoneCards,
|
|
24
25
|
mergeCardSnapshot,
|
|
25
26
|
mergeCardUpdate,
|
|
26
27
|
mergeDetailCard,
|
|
27
28
|
mergeSessionState,
|
|
29
|
+
nextDoneWatermark,
|
|
28
30
|
slotBindingsOf,
|
|
29
31
|
sortActiveCards,
|
|
30
32
|
sortDoneCards,
|
|
@@ -357,6 +359,8 @@ function BoardPanel({ sessionId, getSessions, getUiWorkspace, useSessionStatus,
|
|
|
357
359
|
const [loaded, setLoaded] = useState(false)
|
|
358
360
|
const [detail, setDetail] = useState(null)
|
|
359
361
|
const [doneOpen, setDoneOpen] = useState(false)
|
|
362
|
+
// 已完成区的页码:组件本地状态,收起再展开不回退(宿主会话列表同样不持久化)。
|
|
363
|
+
const [doneWatermark, setDoneWatermark] = useState(0)
|
|
360
364
|
const [now, setNow] = useState(() => Date.now())
|
|
361
365
|
|
|
362
366
|
useEffect(() => {
|
|
@@ -467,6 +471,7 @@ function BoardPanel({ sessionId, getSessions, getUiWorkspace, useSessionStatus,
|
|
|
467
471
|
),
|
|
468
472
|
done: sortDoneCards(cardList.filter((card) => card.status === 'done')),
|
|
469
473
|
}), [cardList, states])
|
|
474
|
+
const doneFold = foldDoneCards(done, doneWatermark)
|
|
470
475
|
|
|
471
476
|
const openSession = useCallback((targetSessionId) => {
|
|
472
477
|
const uiWorkspace = getUiWorkspace?.()
|
|
@@ -625,7 +630,7 @@ function BoardPanel({ sessionId, getSessions, getUiWorkspace, useSessionStatus,
|
|
|
625
630
|
? createElement(
|
|
626
631
|
'div',
|
|
627
632
|
{ className: 'dsh-leader-agent-board-group' },
|
|
628
|
-
|
|
633
|
+
doneFold.rows.map((card) => createElement(BoardCard, {
|
|
629
634
|
key: card.id,
|
|
630
635
|
card,
|
|
631
636
|
states,
|
|
@@ -635,6 +640,27 @@ function BoardPanel({ sessionId, getSessions, getUiWorkspace, useSessionStatus,
|
|
|
635
640
|
onOpenDetail: openDetail,
|
|
636
641
|
onOpenSession: openSession,
|
|
637
642
|
})),
|
|
643
|
+
doneFold.hiddenCount === 0 && !doneFold.expanded
|
|
644
|
+
? null
|
|
645
|
+
: createElement(
|
|
646
|
+
'button',
|
|
647
|
+
{
|
|
648
|
+
type: 'button',
|
|
649
|
+
className: 'dsh-leader-agent-board-done-more',
|
|
650
|
+
'aria-expanded': doneFold.expanded,
|
|
651
|
+
onClick: () => {
|
|
652
|
+
if (doneFold.expanded) {
|
|
653
|
+
setDoneWatermark(0)
|
|
654
|
+
return
|
|
655
|
+
}
|
|
656
|
+
setDoneWatermark((value) => nextDoneWatermark(
|
|
657
|
+
doneFold.hiddenCount,
|
|
658
|
+
Math.max(value, done.length - doneFold.hiddenCount),
|
|
659
|
+
))
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
doneFold.expanded ? '收起' : doneFold.expandLabel,
|
|
663
|
+
),
|
|
638
664
|
)
|
|
639
665
|
: null,
|
|
640
666
|
)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 消息气泡的时间文本。
|
|
3
|
+
*
|
|
4
|
+
* 两个气泡(leader 任务、worker 回报)共用同一口径:与宿主的
|
|
5
|
+
* `formatMessageClock` 对齐(zh-CN 模板)——今天只显示时分;同年往日显示
|
|
6
|
+
* 「M月D日 时分」;跨年再加年份。宿主按 i18n 模板渲染(英文环境下是 `M/D`),
|
|
7
|
+
* 本仓不做多语言,固定用中文形态。
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-leader-agent/client/bubble-clock
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 把时间戳格式成消息时钟。
|
|
14
|
+
*
|
|
15
|
+
* @param {number} time - 毫秒时间戳
|
|
16
|
+
* @returns {string} 时钟文本
|
|
17
|
+
*/
|
|
18
|
+
export function formatBubbleClock(time) {
|
|
19
|
+
const date = new Date(time)
|
|
20
|
+
const now = new Date()
|
|
21
|
+
const clock = `${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`
|
|
22
|
+
if (date.getFullYear() === now.getFullYear()
|
|
23
|
+
&& date.getMonth() === now.getMonth()
|
|
24
|
+
&& date.getDate() === now.getDate()) {
|
|
25
|
+
return clock
|
|
26
|
+
}
|
|
27
|
+
const day = `${date.getMonth() + 1}月${date.getDate()}日`
|
|
28
|
+
const md = date.getFullYear() === now.getFullYear() ? day : `${date.getFullYear()}年${day}`
|
|
29
|
+
return `${md} ${clock}`
|
|
30
|
+
}
|
package/src/client/icons.js
CHANGED
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
* 运行时才渲染,拿不到那份构建期产物,于是 `<use>` 引用一律落空(图标尺寸为
|
|
8
8
|
* 0×0,完全不可见)。
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
* `
|
|
12
|
-
*
|
|
10
|
+
* 因此这里内联需要的字形路径。字形照宿主 `dsh-client-ui-primitives` 的组件
|
|
11
|
+
* 路径内联(`0.2.1-rc.5` 在 `icons/index.tsx`,regular 字重、描边 1px);
|
|
12
|
+
* `artwork.ts` 的 sprite 重构从 `0.2.2-alpha.2+` 起才有,按 rc.5 对照
|
|
13
|
+
* `artwork.ts` 会找不到文件。内联本身不依赖宿主版本,锚点只为可追溯;代价是
|
|
14
|
+
* 宿主改图标时本仓要同步——这条耦合与「手写 Typert 协议形状」同类,已记在
|
|
15
|
+
* note 的边界段。
|
|
13
16
|
*
|
|
14
17
|
* @module dsh-leader-agent/client/icons
|
|
15
18
|
*/
|
|
@@ -33,19 +36,17 @@ const GLYPHS = {
|
|
|
33
36
|
{ d: 'M2.55911 7.93683C2.67584 7.49906 3.07229 7.19446 3.52536 7.19446H13.6491C14.3061 7.19446 14.7846 7.81725 14.6153 8.45209L13.4411 12.856C13.3244 13.2938 12.9279 13.5984 12.4748 13.5984H2.35113C1.69411 13.5984 1.21562 12.9756 1.38489 12.3407L2.55911 7.93683Z' },
|
|
34
37
|
],
|
|
35
38
|
},
|
|
36
|
-
|
|
39
|
+
// 应用格子:项目行首是 leader 会话的入口,用它替代目录图标——目录图标与宿主
|
|
40
|
+
// 工作区树同形,「项目」和「工作区」在侧边栏里分不开。路径原样取自宿主
|
|
41
|
+
// `apps-add-outline`(三格加一个「+」),三个 rect 折成等价 path,形状与宿主一致。
|
|
42
|
+
// 「+」与分区标题右侧的添加项目按钮同形,是有意接受的:这里只作入口标识,不加动作。
|
|
43
|
+
'apps-add-outline': {
|
|
37
44
|
size: 16,
|
|
38
45
|
paths: [
|
|
39
|
-
{ d: '
|
|
40
|
-
{ d: 'M3.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
'folder-open': {
|
|
44
|
-
size: 16,
|
|
45
|
-
paths: [
|
|
46
|
-
{ d: 'M2.55912 7.93683C2.67584 7.49906 3.0723 7.19446 3.52536 7.19446H13.6491C14.3061 7.19446 14.7846 7.81725 14.6153 8.45209L13.4411 12.856C13.3244 13.2938 12.9279 13.5984 12.4748 13.5984H2.35113C1.69411 13.5984 1.21562 12.9756 1.38489 12.3407L2.55912 7.93683Z', fill: true, opacity: 0.16 },
|
|
47
|
-
{ d: 'M13.6491 6.69446C14.6346 6.69453 15.3522 7.62895 15.0983 8.58118L13.9245 12.9845C13.7494 13.6412 13.1539 14.0988 12.4743 14.0988H2.35126C1.36574 14.0988 0.648153 13.1643 0.902044 12.212L2.07587 7.80774C2.25102 7.15128 2.84567 6.69455 3.52509 6.69446H13.6491ZM3.52509 7.69446C3.29865 7.69455 3.10004 7.84674 3.04169 8.06555L1.86786 12.4698C1.78345 12.7872 2.02285 13.0988 2.35126 13.0988H12.4743C12.7007 13.0988 12.8992 12.9463 12.9577 12.7277L14.1325 8.32336C14.2171 8.00598 13.9776 7.69453 13.6491 7.69446H3.52509Z', fill: true },
|
|
48
|
-
{ d: 'M4.7666 1.90137C5.13227 1.90144 5.48571 2.03525 5.75977 2.27734L7.27246 3.61328C7.36379 3.69382 7.48174 3.73828 7.60352 3.73828H12.3994C13.2276 3.73841 13.8993 4.41005 13.8994 5.23828V6.7168C13.8183 6.70327 13.735 6.69436 13.6494 6.69434H12.8994V5.23828C12.8993 4.96233 12.6754 4.73841 12.3994 4.73828H7.60352C7.23781 4.73828 6.88446 4.60438 6.61035 4.3623L5.09766 3.02637C5.00636 2.94576 4.88838 2.90144 4.7666 2.90137H2.0498C1.77366 2.90137 1.5498 3.12523 1.5498 3.40137V9.78223L0.902344 12.2119C0.648452 13.1642 1.36604 14.0986 2.35156 14.0986H2.0498C1.2214 14.0986 0.549838 13.427 0.549805 12.5986V3.40137C0.549805 2.57294 1.22138 1.90137 2.0498 1.90137H4.7666Z', fill: true },
|
|
46
|
+
{ d: 'M3.25 2.25h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1Z' },
|
|
47
|
+
{ d: 'M3.25 9.75h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1Z' },
|
|
48
|
+
{ d: 'M10.75 9.75h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1Z' },
|
|
49
|
+
{ d: 'M11.75 1.75v5M9.25 4.25h5' },
|
|
49
50
|
],
|
|
50
51
|
},
|
|
51
52
|
'triangle-right-fill': {
|
|
@@ -176,7 +177,7 @@ const GLYPHS = {
|
|
|
176
177
|
/**
|
|
177
178
|
* 造一个产品图标元素。
|
|
178
179
|
*
|
|
179
|
-
* @param {string} glyph - 字形名,如 `
|
|
180
|
+
* @param {string} glyph - 字形名,如 `apps-add-outline`
|
|
180
181
|
* @param {object} [options] - 选项
|
|
181
182
|
* @param {number} [options.size] - 边长,默认取字形自带值
|
|
182
183
|
* @returns {object} React 元素
|
package/src/client/index.js
CHANGED
|
@@ -27,6 +27,8 @@ import { createReadySignal } from './ready-signal.js'
|
|
|
27
27
|
import { ToastOverlay } from './toast-view.js'
|
|
28
28
|
import { WORKER_REPORT_NODE_KIND, workerReportDefinition } from './worker-report-definition.js'
|
|
29
29
|
import { WorkerReportView } from './worker-report-view.js'
|
|
30
|
+
import { WORKER_TASK_NODE_KIND, workerTaskDefinition } from './worker-task-definition.js'
|
|
31
|
+
import { WorkerTaskView } from './worker-task-view.js'
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* 本插件在宿主注册表里的身份:tab 类型 id、面板与入口的注册键都用它。
|
|
@@ -141,7 +143,7 @@ export function apply(ctx) {
|
|
|
141
143
|
// 引导卡与视图入口共用输入框上方那个 dock 槽:新建项目后 leader 会话里
|
|
142
144
|
// 一句话都没有,卡在这里说清下一步,发出第一句话即消失。
|
|
143
145
|
mountGuideCard(conversationCtx)
|
|
144
|
-
|
|
146
|
+
mountMessageBubbles(conversationCtx)
|
|
145
147
|
})
|
|
146
148
|
|
|
147
149
|
// 项目命名空间挂在官方 gateway client 的 `ctx.remote` 上。远程通道由官方
|
|
@@ -184,29 +186,37 @@ function mountBoardMonitor(ctx) {
|
|
|
184
186
|
}
|
|
185
187
|
|
|
186
188
|
/**
|
|
187
|
-
* 注册
|
|
189
|
+
* 注册 agent 消息的会话节点定义与渲染器。
|
|
188
190
|
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
+
* 两类消息共用同一套注册机制:leader 派给 worker 的任务(worker 会话里,渲染成
|
|
192
|
+
* 右侧用户气泡)与 worker 的回报(leader 会话里,渲染成左侧 agent 气泡)。定义都用
|
|
193
|
+
* exclusive claim 接管带自家 `source.kind` 的 `user/message`,让它们不再走官方
|
|
194
|
+
* 上下文行;渲染器按节点 kind 注册,键必须等于 kind。
|
|
191
195
|
*
|
|
192
196
|
* @param {object} ctx - 客户端 Cordis 上下文(已注入 `uiConversation`)
|
|
193
197
|
* @returns {void}
|
|
194
198
|
*/
|
|
195
|
-
function
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
function mountMessageBubbles(ctx) {
|
|
200
|
+
const bubbles = [
|
|
201
|
+
{ kind: WORKER_TASK_NODE_KIND, definition: workerTaskDefinition, view: WorkerTaskView, label: 'leader 任务' },
|
|
202
|
+
{ kind: WORKER_REPORT_NODE_KIND, definition: workerReportDefinition, view: WorkerReportView, label: 'worker 回报' },
|
|
203
|
+
]
|
|
204
|
+
for (const bubble of bubbles) {
|
|
205
|
+
try {
|
|
206
|
+
ctx.uiConversation.events.register(bubble.definition)
|
|
207
|
+
} catch (error) {
|
|
208
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
209
|
+
ctx.logger?.error?.(`dsh-leader-agent: ${bubble.label}节点注册失败:${message}`)
|
|
210
|
+
continue
|
|
211
|
+
}
|
|
212
|
+
ctx.effect(() => ctx.slots.inject('conversation.chat.node', () => ctx.slots.register({
|
|
213
|
+
name: 'conversation.chat.node',
|
|
214
|
+
key: bubble.kind,
|
|
215
|
+
// `uiWorkspace` 只挂在 web-app bundle 上,写进 inject 的服务缺失会让整个插件
|
|
216
|
+
// 挂起——惰性获取,点击名字时才取。
|
|
217
|
+
inject: () => ({
|
|
218
|
+
openSession: (sessionId) => ctx.get('uiWorkspace')?.openSession(sessionId),
|
|
219
|
+
}),
|
|
220
|
+
}, bubble.view)), `dsh-leader-agent ${bubble.label}渲染器`)
|
|
202
221
|
}
|
|
203
|
-
ctx.effect(() => ctx.slots.inject('conversation.chat.node', () => ctx.slots.register({
|
|
204
|
-
name: 'conversation.chat.node',
|
|
205
|
-
key: WORKER_REPORT_NODE_KIND,
|
|
206
|
-
// `uiWorkspace` 只挂在 web-app bundle 上,写进 inject 的服务缺失会让整个插件
|
|
207
|
-
// 挂起——惰性获取,点击名字时才取。
|
|
208
|
-
inject: () => ({
|
|
209
|
-
openSession: (sessionId) => ctx.get('uiWorkspace')?.openSession(sessionId),
|
|
210
|
-
}),
|
|
211
|
-
}, WorkerReportView)), 'dsh-leader-agent worker 回报渲染器')
|
|
212
222
|
}
|
package/src/client/markdown.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* 的 `require` 解析到同一实例。宿主自己的聊天消息就用这个组件,这里复用它,不另
|
|
7
7
|
* 带一份解析器,也不引第三方 Markdown 依赖。
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* 调用点都在窄容器里(详情浮层、worker 回报气泡、任务气泡),因此固定 `variant: 'compact'`:
|
|
10
10
|
* 13px 字号、统一粗细的标题、4px 块间距——`body` 变体是文档排版,标题与段间距会
|
|
11
11
|
* 把气泡撑成文档页。
|
|
12
12
|
*
|