dsh-leader-agent 0.4.0 → 0.5.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/.agents/skills/doubao-tts/SKILL.md +158 -0
- package/.agents/skills/doubao-tts/scripts/tts.mjs +253 -0
- package/.agents/skills/e2e-scenarios/SKILL.md +15 -0
- package/.agents/skills/leader-mode/SKILL.md +3 -1
- package/.agents/skills/leader-mode/playbooks/implementation.md +1 -1
- package/.agents/skills/leader-mode/playbooks/program.md +1 -1
- package/.agents/skills/promo-stills/SKILL.md +107 -0
- package/.agents/skills/promo-stills/scripts/render.mjs +186 -0
- package/.agents/skills/promo-video/SKILL.md +134 -0
- package/.agents/skills/promo-video/references/copy-and-storyboard.md +74 -0
- package/.agents/skills/promo-video/references/qa.md +60 -0
- package/.agents/skills/promo-video/references/timeline-and-render.md +155 -0
- package/README.md +6 -16
- package/README_ZH.md +6 -18
- package/lib/client.js +611 -344
- package/package.json +1 -1
- package/src/client/board-card.js +104 -82
- package/src/client/board-projection.js +53 -0
- package/src/client/board-styles.js +221 -75
- package/src/client/board.js +85 -5
- package/src/client/card-detail-view.js +26 -0
- package/src/client/card-detail.js +36 -6
- package/src/client/icons.js +0 -7
- package/src/client/project-panel.js +51 -11
- package/src/client/project-section.js +30 -20
- package/src/host/cards/card-list-view.js +97 -0
- package/src/host/cards/store.js +36 -1
- package/src/host/index.js +9 -2
- package/src/host/projects/remote.js +24 -0
- package/src/host/tools/cards.js +259 -6
- package/src/host/tools/gate.js +32 -7
- package/src/shared/projects.js +1 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 卡片详情浮层(点卡面打开)。
|
|
3
3
|
*
|
|
4
|
-
* 卡面是窄栏,只放得下标题、链接与槽位;spec
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* 卡面是窄栏,只放得下标题、链接与槽位;spec 全文进详情。人工写操作只有
|
|
5
|
+
* **链接**与**删除**:链接经项目通道的 `updateCardLinks` 整体替换;删除经
|
|
6
|
+
* `deleteCard` 硬删,二次确认后生效。完成、置顶、重命名仍归 leader 的卡片
|
|
7
|
+
* 工具,界面不越权写。
|
|
7
8
|
*
|
|
8
9
|
* 浮层外壳(遮罩、Escape、焦点循环、关闭回焦)由 `modal-shell.js` 提供;这里用
|
|
9
10
|
* `headless` 模式自带头部——标题就是卡片标题本身,「卡片详情」这种无信息标题
|
|
@@ -16,11 +17,13 @@ import { createElement, useCallback, useEffect, useLayoutEffect, useRef, useStat
|
|
|
16
17
|
import { ModalShell } from './modal-shell.js'
|
|
17
18
|
import {
|
|
18
19
|
DETAIL_SPEC_EMPTY,
|
|
20
|
+
canDeleteCard,
|
|
19
21
|
canEditCardLinks,
|
|
20
22
|
detailSections,
|
|
21
23
|
statusLabel,
|
|
22
24
|
} from './card-detail-view.js'
|
|
23
25
|
import { CardLinksEditor } from './card-links-editor.js'
|
|
26
|
+
import { cardKind } from './board-projection.js'
|
|
24
27
|
import { isJumpableLink, linkRowKey } from './link-row.js'
|
|
25
28
|
import { Markdown } from './markdown.js'
|
|
26
29
|
import { productIcon } from './icons.js'
|
|
@@ -34,10 +37,11 @@ import { ensureBoardStyles } from './board-styles.js'
|
|
|
34
37
|
* @param {() => void} props.onClose - 关闭
|
|
35
38
|
* @param {(method: string, args: unknown[]) => Promise<unknown>} props.callRemote - 项目通道调用
|
|
36
39
|
* @param {(card: object) => void} [props.onUpdated] - 链接保存成功后的新卡片
|
|
40
|
+
* @param {() => void} [props.onDelete] - 请求删除当前卡片(由看板弹二次确认)
|
|
37
41
|
* @param {HTMLElement | null} [props.restoreFocus] - 关闭后焦点落点
|
|
38
42
|
* @returns {object} React 元素
|
|
39
43
|
*/
|
|
40
|
-
export function CardDetail({ card, onClose, callRemote, onUpdated, restoreFocus = null }) {
|
|
44
|
+
export function CardDetail({ card, onClose, callRemote, onUpdated, onDelete, restoreFocus = null }) {
|
|
41
45
|
const [editing, setEditing] = useState(false)
|
|
42
46
|
const editButton = useRef(null)
|
|
43
47
|
const wasEditing = useRef(false)
|
|
@@ -58,7 +62,9 @@ export function CardDetail({ card, onClose, callRemote, onUpdated, restoreFocus
|
|
|
58
62
|
}, [editing])
|
|
59
63
|
const sections = detailSections(card)
|
|
60
64
|
const done = card?.status === 'done'
|
|
65
|
+
const kind = cardKind(card)
|
|
61
66
|
const editable = canEditCardLinks(card)
|
|
67
|
+
const deletable = canDeleteCard(card)
|
|
62
68
|
|
|
63
69
|
/**
|
|
64
70
|
* 保存链接。
|
|
@@ -109,6 +115,14 @@ export function CardDetail({ card, onClose, callRemote, onUpdated, restoreFocus
|
|
|
109
115
|
{ className: 'dsh-leader-agent-card-detail-number' },
|
|
110
116
|
`#${card?.number ?? '?'}`,
|
|
111
117
|
),
|
|
118
|
+
kind === null
|
|
119
|
+
? null
|
|
120
|
+
: createElement(
|
|
121
|
+
'span',
|
|
122
|
+
{ className: 'dsh-leader-agent-card-detail-kind' },
|
|
123
|
+
createElement('span', { className: 'dsh-leader-agent-card-detail-kind-separator' }, '/'),
|
|
124
|
+
kind,
|
|
125
|
+
),
|
|
112
126
|
createElement(
|
|
113
127
|
'span',
|
|
114
128
|
{
|
|
@@ -165,11 +179,11 @@ export function CardDetail({ card, onClose, callRemote, onUpdated, restoreFocus
|
|
|
165
179
|
sections.links.map((link, index) => {
|
|
166
180
|
const row = createElement(
|
|
167
181
|
'span',
|
|
168
|
-
{ className: 'dsh-leader-agent-board-link-
|
|
182
|
+
{ className: 'dsh-leader-agent-board-link-body' },
|
|
169
183
|
productIcon('link-outline', { size: 12 }),
|
|
170
184
|
createElement(
|
|
171
185
|
'span',
|
|
172
|
-
{ className: 'dsh-leader-agent-board-link-
|
|
186
|
+
{ className: 'dsh-leader-agent-board-link-label' },
|
|
173
187
|
link.label ?? '',
|
|
174
188
|
),
|
|
175
189
|
link.purpose
|
|
@@ -202,6 +216,22 @@ export function CardDetail({ card, onClose, callRemote, onUpdated, restoreFocus
|
|
|
202
216
|
)
|
|
203
217
|
: null,
|
|
204
218
|
),
|
|
219
|
+
deletable && !editing && typeof onDelete === 'function'
|
|
220
|
+
? createElement(
|
|
221
|
+
'div',
|
|
222
|
+
{ className: 'dsh-leader-agent-card-detail-footer' },
|
|
223
|
+
createElement(
|
|
224
|
+
'button',
|
|
225
|
+
{
|
|
226
|
+
type: 'button',
|
|
227
|
+
className: 'dsh-leader-agent-card-detail-delete',
|
|
228
|
+
onClick: onDelete,
|
|
229
|
+
},
|
|
230
|
+
productIcon('trash-outline', { size: 14 }),
|
|
231
|
+
'删除卡片',
|
|
232
|
+
),
|
|
233
|
+
)
|
|
234
|
+
: null,
|
|
205
235
|
),
|
|
206
236
|
})
|
|
207
237
|
}
|
package/src/client/icons.js
CHANGED
|
@@ -29,13 +29,6 @@ const STROKE_WIDTH = 1
|
|
|
29
29
|
* 填充。
|
|
30
30
|
*/
|
|
31
31
|
const GLYPHS = {
|
|
32
|
-
'folder-open-outline': {
|
|
33
|
-
size: 16,
|
|
34
|
-
paths: [
|
|
35
|
-
{ d: 'M12.3994 13.5986H2.04956C1.49728 13.5986 1.04956 13.1509 1.04956 12.5986V3.40137C1.04956 2.84908 1.49728 2.40137 2.04956 2.40137H4.76632C5.01016 2.40137 5.24561 2.49046 5.42836 2.6519L6.94088 3.98799C7.12364 4.14943 7.35908 4.23852 7.60293 4.23852H12.3994C12.9517 4.23852 13.3994 4.68624 13.3994 5.23852V7.16991' },
|
|
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' },
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
32
|
// 应用格子:项目行首是 leader 会话的入口,用它替代目录图标——目录图标与宿主
|
|
40
33
|
// 工作区树同形,「项目」和「工作区」在侧边栏里分不开。路径原样取自宿主
|
|
41
34
|
// `apps-add-outline`(三格加一个「+」),三个 rect 折成等价 path,形状与宿主一致。
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
* **位置**:宽侧栏里区块插在「自动化任务」面板行之下、工作区列表之上。左栏正文
|
|
23
23
|
* 区只有 `sidebar.workspaces` 一个槽且已被官方工作区浏览占用,slot 机制没有装饰
|
|
24
24
|
* 或包装能力,第三方无法在它旁边插入并列区块——所以这里按宿主左栏的结构,在
|
|
25
|
-
* 面板列表之后安一个容器,用 portal
|
|
26
|
-
*
|
|
25
|
+
* 面板列表之后安一个容器,用 portal 把内容渲染进去;0.2.2 起面板列表与工作区
|
|
26
|
+
* 同处一个滚动网格,落点改到工作区容器顶部(见 `placementSpot`)。锚点找不到
|
|
27
|
+
* 时内容退回底部槽,不至于消失。
|
|
27
28
|
*
|
|
28
29
|
* 窄侧栏(56px 导轨)放不下列表,改为一个入口按钮 + 浮层。
|
|
29
30
|
*
|
|
@@ -752,10 +753,15 @@ export function ProjectPanel(props) {
|
|
|
752
753
|
}
|
|
753
754
|
|
|
754
755
|
/**
|
|
755
|
-
*
|
|
756
|
+
* 找左栏根容器:向上找到第一个子树里有面板列表 `nav` 的祖先。
|
|
756
757
|
*
|
|
757
|
-
* 插槽 occupant
|
|
758
|
-
*
|
|
758
|
+
* 插槽 occupant 在宿主树里的层数随宿主版本变,固定层数会失配。判据不能要求
|
|
759
|
+
* `nav` 是直接子元素:0.2.2 起宿主把面板列表与工作区一起包进滚动网格,`nav`
|
|
760
|
+
* 下沉了一层,按老判据会一路走到 `null`,区块只能退回栏底。
|
|
761
|
+
*
|
|
762
|
+
* 安全性来自锚点的位置,不是「`nav` 只在左栏出现」——会话、设置、聊天、输入
|
|
763
|
+
* 触发器等面也渲染 `<nav>`。锚点在 `sidebar.footer.action` 里,从 footer 向上
|
|
764
|
+
* 到左栏根之间没有别的 `nav`,所以第一个命中 `nav` 的祖先必然是左栏根。
|
|
759
765
|
*
|
|
760
766
|
* @param {Element} anchor - 锚点元素
|
|
761
767
|
* @returns {Element | null} 左栏根容器
|
|
@@ -763,19 +769,51 @@ export function ProjectPanel(props) {
|
|
|
763
769
|
function findSidebarRoot(anchor) {
|
|
764
770
|
let node = anchor.parentElement
|
|
765
771
|
while (node !== null) {
|
|
766
|
-
if (node.querySelector('
|
|
772
|
+
if (node.querySelector('nav') !== null) return node
|
|
767
773
|
node = node.parentElement
|
|
768
774
|
}
|
|
769
775
|
return null
|
|
770
776
|
}
|
|
771
777
|
|
|
778
|
+
/**
|
|
779
|
+
* 算出容器插在哪:面板列表之后、工作区列表之前。
|
|
780
|
+
*
|
|
781
|
+
* 两个版本的宿主结构不同,落点也不同:
|
|
782
|
+
*
|
|
783
|
+
* - 0.2.1:`nav` 是左栏根的直接子元素,下一个兄弟就是工作区容器。直接插在二者
|
|
784
|
+
* 之间。
|
|
785
|
+
* - 0.2.2 起:`nav` 与工作区同处一个滚动网格,`grid-template-rows` 固定为
|
|
786
|
+
* 「上留白 / 面板列表 / 2px 分隔 / 工作区」,网格第 1 行第 1 列是 4px × 8px
|
|
787
|
+
* 的空单元格(2px 分隔那行由 `::after` 占着)。在 `nav` 后面插新元素会被
|
|
788
|
+
* 自动摆进那一格,区块被压成 4px 宽的竖条,所以改为插进工作区容器的顶部——
|
|
789
|
+
* 视觉顺序仍是「面板列表 → 项目 → 工作区」,且跟随宿主一起滚动。
|
|
790
|
+
*
|
|
791
|
+
* `0.2.2` 分支把 `nav` 的下一个兄弟直接当成工作区容器,没有独立校验它确实是
|
|
792
|
+
* 工作区;宿主将来在两者之间再插元素时,容器会跟着插进那个元素里。e2e 兜底的
|
|
793
|
+
* 是「没退回 footer、宽度正常、在 `nav` 之后」,不是「任何结构下都插对」。
|
|
794
|
+
*
|
|
795
|
+
* 找不到可用落点时返回 null,内容退回原位渲染。
|
|
796
|
+
*
|
|
797
|
+
* @param {Element} root - 左栏根容器
|
|
798
|
+
* @param {Element} nav - 面板列表
|
|
799
|
+
* @returns {{ parent: Element, before: Element | null } | null} 落点
|
|
800
|
+
*/
|
|
801
|
+
function placementSpot(root, nav) {
|
|
802
|
+
if (nav.parentElement === root) {
|
|
803
|
+
return { parent: root, before: nav.nextElementSibling }
|
|
804
|
+
}
|
|
805
|
+
const region = nav.nextElementSibling
|
|
806
|
+
if (region === null) return null
|
|
807
|
+
return { parent: region, before: region.firstElementChild }
|
|
808
|
+
}
|
|
809
|
+
|
|
772
810
|
/**
|
|
773
811
|
* 把区块安到左栏的面板列表之下、工作区列表之上。
|
|
774
812
|
*
|
|
775
813
|
* 宿主左栏的正文区只有一个 `sidebar.workspaces` 槽(已被官方工作区浏览占用),
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
814
|
+
* 第三方插件没有并列区块的注册位,只能在宿主 DOM 里找落点(见
|
|
815
|
+
* {@link placementSpot})。宿主改版导致找不到锚点时,内容退回原处渲染,功能
|
|
816
|
+
* 不受影响。
|
|
779
817
|
*
|
|
780
818
|
* @param {object} props - 组件属性
|
|
781
819
|
* @param {object} props.children - 区块内容
|
|
@@ -790,12 +828,14 @@ function SidebarPlacement(props) {
|
|
|
790
828
|
if (anchor === null) return undefined
|
|
791
829
|
const root = findSidebarRoot(anchor)
|
|
792
830
|
if (root === null) return undefined
|
|
793
|
-
const nav = root.querySelector('
|
|
831
|
+
const nav = root.querySelector('nav')
|
|
794
832
|
if (nav === null) return undefined
|
|
833
|
+
const spot = placementSpot(root, nav)
|
|
834
|
+
if (spot === null) return undefined
|
|
795
835
|
const host = document.createElement('div')
|
|
796
836
|
host.setAttribute('data-dsh-leader-agent-projects', '')
|
|
797
837
|
host.style.flex = 'none'
|
|
798
|
-
|
|
838
|
+
spot.parent.insertBefore(host, spot.before)
|
|
799
839
|
setContainer(host)
|
|
800
840
|
return () => {
|
|
801
841
|
host.remove()
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* 结构是**项目树**:项目行下面挂着该项目目录里的会话。点项目行展开或收起子会话
|
|
5
5
|
* 列表;leader 会话的入口在行的「更多」菜单里(项目名不再承担两个动作)。
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* 排版对齐宿主的工作区浏览:小节标题的第一行文字与宿主「工作区」标题同一起点,
|
|
8
|
+
* 项目行用工作区行的高度、内边距、圆角与 hover 反馈(都取宿主 0.2.2 的几何);
|
|
9
|
+
* 行首槽位与官方工作区行同款——平时是宿主应用格子图标
|
|
9
10
|
* `apps-add-outline`(替代宿主的目录图标,免得「项目」与「工作区」在侧边栏里同形),悬停整行时换成
|
|
10
11
|
* 展开箭头,展开时箭头旋转朝下。图标是自带的内联路径
|
|
11
12
|
* (宿主 web 端运行时没有 sprite,见 `icons.js`)。
|
|
@@ -29,13 +30,20 @@ const STYLE_TEXT = `
|
|
|
29
30
|
flex-direction: column;
|
|
30
31
|
padding-right: var(--dsh-session-list-edge-inset, 0px);
|
|
31
32
|
}
|
|
33
|
+
/* 小节标题的左内边距与高度照宿主 0.2.2 的 sectionHeader:--dsh-sidebar-row-padding
|
|
34
|
+
(0.2.1 没有这个变量,退回那版的 4px)与 36px。上下外边距是本区块自己的取值——
|
|
35
|
+
宿主那份是 margin-top 无、margin-bottom 取 --workspace-toolbar-gap = 0px,
|
|
36
|
+
这里的 2/4 留的是与下方列表的间距。
|
|
37
|
+
标签必须是这一行的第一个内容——宿主的「工作区」标题从内边距处起排,前面多一个
|
|
38
|
+
图标槽就会把「项目」推右十几像素(0.2.2 实测 32 vs 19);收起箭头放在标签之后,
|
|
39
|
+
悬停才出现。 */
|
|
32
40
|
.dsh-leader-agent-project-header {
|
|
33
41
|
display: flex;
|
|
34
42
|
align-items: center;
|
|
35
43
|
gap: 4px;
|
|
36
44
|
height: 36px;
|
|
37
|
-
padding-left: 4px;
|
|
38
|
-
margin
|
|
45
|
+
padding-left: var(--dsh-sidebar-row-padding, 4px);
|
|
46
|
+
margin: 2px 0 4px;
|
|
39
47
|
box-sizing: border-box;
|
|
40
48
|
color: var(--dsw-alias-label-tertiary);
|
|
41
49
|
}
|
|
@@ -80,19 +88,28 @@ const STYLE_TEXT = `
|
|
|
80
88
|
}
|
|
81
89
|
}
|
|
82
90
|
/* 项目行之间留 2px 间距,照宿主工作区树的「groupSection 直接子元素相邻」规则。
|
|
83
|
-
行高
|
|
91
|
+
行高 32px(0.2.2 的 projectRow/sessionRow)、背景铺满整行,行间不留缝时上下
|
|
92
|
+
两行的 hover 底色会贴着拼成一整块。 */
|
|
84
93
|
.dsh-leader-agent-project-list > * + * {
|
|
85
94
|
margin-top: 2px;
|
|
86
95
|
}
|
|
87
96
|
.dsh-leader-agent-project-block {
|
|
88
97
|
position: relative;
|
|
89
98
|
}
|
|
99
|
+
/* 几何逐项照 0.2.2 的官方工作区行(Rows.module.css 的 projectRow):行高 32、
|
|
100
|
+
透明边框吃掉 paint-inset、padding-inline-start 只留 row_padding 与它的差。
|
|
101
|
+
旧写法是 padding: 0 8px,0.2.2 上内容比宿主行靠左 4px、hover 底色也多铺 3px,
|
|
102
|
+
与「工作区」行及本区块自己的会话行都对不齐。0.2.1 没有这几个变量,退回
|
|
103
|
+
8px / 无边框,正是那版硬编码的几何。 */
|
|
90
104
|
.dsh-leader-agent-project-row {
|
|
91
105
|
display: flex;
|
|
92
106
|
align-items: center;
|
|
93
107
|
gap: 6px;
|
|
94
|
-
height:
|
|
108
|
+
height: 32px;
|
|
95
109
|
padding: 0 8px;
|
|
110
|
+
padding-inline-start: calc(var(--dsh-sidebar-row-padding, 8px) - var(--dsh-sidebar-paint-inset, 0px));
|
|
111
|
+
border-inline: var(--dsh-sidebar-paint-inset, 0px) solid transparent;
|
|
112
|
+
background-clip: padding-box;
|
|
96
113
|
box-sizing: border-box;
|
|
97
114
|
border-radius: var(--dsw-radius-md);
|
|
98
115
|
color: var(--dsw-alias-label-primary);
|
|
@@ -156,7 +173,7 @@ const STYLE_TEXT = `
|
|
|
156
173
|
}
|
|
157
174
|
/* 行首槽位:默认应用格子图标(项目行就是 leader 会话的入口),悬停整行时换成展开箭头
|
|
158
175
|
(与官方工作区行同款)。里面的图标与加载圈都是 SVG:不把这层撑成 flex 的话,
|
|
159
|
-
SVG 按行盒基线排,圈会比行中心高 1.5px
|
|
176
|
+
SVG 按行盒基线排,圈会比行中心高 1.5px(行盒实测)。类名沿用 -folder 后缀:
|
|
160
177
|
槽位位置与宿主工作区行的目录图标同源,改字形不改槽位。 */
|
|
161
178
|
.dsh-leader-agent-project-lead-folder {
|
|
162
179
|
display: inline-flex;
|
|
@@ -199,9 +216,6 @@ const STYLE_TEXT = `
|
|
|
199
216
|
.dsh-leader-agent-project-header:hover .dsh-leader-agent-project-lead-arrow {
|
|
200
217
|
display: inline-flex;
|
|
201
218
|
}
|
|
202
|
-
.dsh-leader-agent-project-header:hover .dsh-leader-agent-project-lead-folder {
|
|
203
|
-
display: none;
|
|
204
|
-
}
|
|
205
219
|
}
|
|
206
220
|
@media (prefers-reduced-motion: reduce) {
|
|
207
221
|
.dsh-leader-agent-project-lead-arrow {
|
|
@@ -339,9 +353,9 @@ const STYLE_TEXT = `
|
|
|
339
353
|
}
|
|
340
354
|
/* 会话行逐项照官方工作区会话行(宿主 Rows.module.css 的 sessionRow 与
|
|
341
355
|
sessionRow 下的 title):行高 32、行内不设 gap(标题自带左右外边距)、文字用
|
|
342
|
-
|
|
343
|
-
padding 只留 row_padding
|
|
344
|
-
|
|
356
|
+
一级标签色。内边距照官方两代写法:0.2.2 起行用透明边框吃掉 paint-inset、
|
|
357
|
+
padding-inline-start 只留 row_padding 与它的差(右侧仍是 8),hover 背景才会比
|
|
358
|
+
内容窄一圈;0.2.1 这两个变量都不存在,落到 8 / 0,与那版硬编码的 8px 一致。 */
|
|
345
359
|
.dsh-leader-agent-session-row {
|
|
346
360
|
display: flex;
|
|
347
361
|
align-items: center;
|
|
@@ -349,7 +363,8 @@ const STYLE_TEXT = `
|
|
|
349
363
|
height: 32px;
|
|
350
364
|
border-inline: var(--dsh-sidebar-paint-inset, 0px) solid transparent;
|
|
351
365
|
background-clip: padding-box;
|
|
352
|
-
padding: 0
|
|
366
|
+
padding: 0 8px;
|
|
367
|
+
padding-inline-start: calc(var(--dsh-sidebar-row-padding, 8px) - var(--dsh-sidebar-paint-inset, 0px));
|
|
353
368
|
box-sizing: border-box;
|
|
354
369
|
border-radius: var(--dsw-radius-md);
|
|
355
370
|
color: var(--dsw-alias-label-primary);
|
|
@@ -548,14 +563,10 @@ export function ProjectSection(props) {
|
|
|
548
563
|
title: listExpanded ? '收起项目列表' : '展开项目列表',
|
|
549
564
|
onClick: onToggleList,
|
|
550
565
|
},
|
|
566
|
+
createElement('span', { className: 'dsh-leader-agent-project-header-label' }, '项目'),
|
|
551
567
|
createElement(
|
|
552
568
|
'span',
|
|
553
569
|
{ className: 'dsh-leader-agent-project-lead' },
|
|
554
|
-
createElement(
|
|
555
|
-
'span',
|
|
556
|
-
{ className: 'dsh-leader-agent-project-lead-folder' },
|
|
557
|
-
productIcon('folder-open-outline', { size: 16 }),
|
|
558
|
-
),
|
|
559
570
|
createElement(
|
|
560
571
|
'span',
|
|
561
572
|
{
|
|
@@ -565,7 +576,6 @@ export function ProjectSection(props) {
|
|
|
565
576
|
productIcon('triangle-right-fill', { size: 14 }),
|
|
566
577
|
),
|
|
567
578
|
),
|
|
568
|
-
createElement('span', { className: 'dsh-leader-agent-project-header-label' }, '项目'),
|
|
569
579
|
),
|
|
570
580
|
createElement(
|
|
571
581
|
'div',
|
|
@@ -27,6 +27,8 @@ export const LIST_MAX_CHARS = 6_000
|
|
|
27
27
|
export const LINK_LABEL_MAX_CHARS = 32
|
|
28
28
|
/** 列表里最多列几个链接标签。 */
|
|
29
29
|
export const MAX_LISTED_LINKS = 5
|
|
30
|
+
/** 读卡工具一次给出的规格页大小(按字符/码点计)。 */
|
|
31
|
+
export const SPEC_PAGE_CHARS = 2_000
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* 超长字段截断并标注原长。
|
|
@@ -147,6 +149,20 @@ function hasSpec(card) {
|
|
|
147
149
|
return typeof card.spec === 'string' && card.spec.trim().length > 0
|
|
148
150
|
}
|
|
149
151
|
|
|
152
|
+
/**
|
|
153
|
+
* 分类行:卡面头部的只读短标签。
|
|
154
|
+
*
|
|
155
|
+
* 与规格、链接一样显式成行:省略会让模型把「没有分类」读成「工具不给分类」,
|
|
156
|
+
* 而「这张卡该补分类」正是它会做的下一步动作。
|
|
157
|
+
*
|
|
158
|
+
* @param {object} card - 卡片
|
|
159
|
+
* @returns {string} 分类行
|
|
160
|
+
*/
|
|
161
|
+
function renderKind(card) {
|
|
162
|
+
const kind = typeof card.kind === 'string' ? card.kind.trim() : ''
|
|
163
|
+
return ` kind: ${kind === '' ? '无' : kind}`
|
|
164
|
+
}
|
|
165
|
+
|
|
150
166
|
/**
|
|
151
167
|
* 链接列表摘要:只给身份(标签),地址与用途留给单卡查询。
|
|
152
168
|
*
|
|
@@ -187,6 +203,7 @@ function renderSlots(card) {
|
|
|
187
203
|
*/
|
|
188
204
|
function renderCardBrief(card) {
|
|
189
205
|
const lines = [cardHeading(card)]
|
|
206
|
+
lines.push(renderKind(card))
|
|
190
207
|
lines.push(` spec: ${hasSpec(card) ? '有' : '无'}`)
|
|
191
208
|
lines.push(` links: ${summarizeLinks(card)}`)
|
|
192
209
|
const slots = renderSlots(card)
|
|
@@ -202,6 +219,7 @@ function renderCardBrief(card) {
|
|
|
202
219
|
*/
|
|
203
220
|
function renderCardDetail(card) {
|
|
204
221
|
const lines = [cardHeading(card)]
|
|
222
|
+
lines.push(renderKind(card))
|
|
205
223
|
if (hasSpec(card)) {
|
|
206
224
|
lines.push(' spec:', ...card.spec.split('\n').map((line) => ` ${line}`))
|
|
207
225
|
}
|
|
@@ -218,6 +236,85 @@ function renderCardDetail(card) {
|
|
|
218
236
|
return lines
|
|
219
237
|
}
|
|
220
238
|
|
|
239
|
+
/**
|
|
240
|
+
* 切一页规格。
|
|
241
|
+
*
|
|
242
|
+
* 规格可能很长(任务简报 + 验收标准),一次全给会灌满 worker 的上下文;读卡工具
|
|
243
|
+
* 按页取。偏移按**码点**计而不是 UTF-16 码元:emoji 之类的代理对被切开会出现半个
|
|
244
|
+
* 字符,`nextOffset` 也会与模型自己数出来的位置对不上。
|
|
245
|
+
*
|
|
246
|
+
* 越界直接抛错:静默给空片段会让模型以为规格已经读到末尾。
|
|
247
|
+
*
|
|
248
|
+
* @param {string | undefined} spec - 规格全文
|
|
249
|
+
* @param {number} offset - 起始码点位置
|
|
250
|
+
* @returns {{ text: string, offset: number, chars: number, total: number, hasMore: boolean, nextOffset?: number }} 本页
|
|
251
|
+
*/
|
|
252
|
+
export function sliceSpec(spec, offset = 0) {
|
|
253
|
+
if (!Number.isInteger(offset) || offset < 0) {
|
|
254
|
+
throw new Error(`read_card: specOffset 必须是非负整数,收到 ${String(offset)}`)
|
|
255
|
+
}
|
|
256
|
+
const chars = [...(typeof spec === 'string' ? spec : '')]
|
|
257
|
+
const total = chars.length
|
|
258
|
+
if (total === 0) {
|
|
259
|
+
if (offset !== 0) {
|
|
260
|
+
throw new Error('read_card: specOffset 超出范围(这张卡没有规格,offset 只能是 0)')
|
|
261
|
+
}
|
|
262
|
+
return { text: '', offset: 0, chars: 0, total: 0, hasMore: false }
|
|
263
|
+
}
|
|
264
|
+
if (offset >= total) {
|
|
265
|
+
throw new Error(`read_card: specOffset 超出范围(规格共 ${total} 字符,可传 0–${total - 1})`)
|
|
266
|
+
}
|
|
267
|
+
const end = Math.min(offset + SPEC_PAGE_CHARS, total)
|
|
268
|
+
const hasMore = end < total
|
|
269
|
+
return {
|
|
270
|
+
text: chars.slice(offset, end).join(''),
|
|
271
|
+
offset,
|
|
272
|
+
chars: end - offset,
|
|
273
|
+
total,
|
|
274
|
+
hasMore,
|
|
275
|
+
...hasMore ? { nextOffset: end } : {},
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 读卡视图:单卡事实 + 一页规格。
|
|
281
|
+
*
|
|
282
|
+
* 与 `list_cards` 的单卡查询(规格全文、不截断)分开:那条路径属于 leader,读的是
|
|
283
|
+
* 它自己维护的规格;worker 可能一次读好几张卡,按页给才不会把上下文灌满。
|
|
284
|
+
*
|
|
285
|
+
* @param {object} card - 卡片
|
|
286
|
+
* @param {{ offset: number, chars: number, total: number, hasMore: boolean, nextOffset?: number }} specPage - 规格窗口
|
|
287
|
+
* @returns {string} 给模型看的文本
|
|
288
|
+
*/
|
|
289
|
+
export function renderCardDetailText(card, specPage) {
|
|
290
|
+
const lines = [cardHeading(card)]
|
|
291
|
+
lines.push(renderKind(card))
|
|
292
|
+
if (card.status === 'archived') {
|
|
293
|
+
lines.push(' 这张卡已归档,归档是终态:没有新活可接,也不要再改它。')
|
|
294
|
+
}
|
|
295
|
+
if (specPage.total === 0) {
|
|
296
|
+
lines.push(' spec: 无')
|
|
297
|
+
} else {
|
|
298
|
+
lines.push(' spec:', ...specPage.text.split('\n').map((line) => ` ${line}`))
|
|
299
|
+
if (specPage.hasMore) {
|
|
300
|
+
lines.push(` spec 已读第 ${specPage.offset + 1}–${specPage.offset + specPage.chars} 个字符(共 ${specPage.total}),用 specOffset=${specPage.nextOffset} 继续读`)
|
|
301
|
+
} else if (specPage.offset > 0) {
|
|
302
|
+
lines.push(` spec 已读完(共 ${specPage.total} 字符)`)
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
if (Array.isArray(card.links) && card.links.length > 0) {
|
|
306
|
+
lines.push(' links:')
|
|
307
|
+
for (const link of card.links) {
|
|
308
|
+
const purpose = link?.purpose ? `(${link.purpose})` : ''
|
|
309
|
+
const url = link?.url ? `: ${link.url}` : ''
|
|
310
|
+
lines.push(` - ${link?.label ?? ''}${url}${purpose}`)
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const slots = renderSlots(card)
|
|
314
|
+
if (slots !== undefined) lines.push(slots)
|
|
315
|
+
return lines.join('\n')
|
|
316
|
+
}
|
|
317
|
+
|
|
221
318
|
/**
|
|
222
319
|
* 渲染查卡结果。
|
|
223
320
|
*
|
package/src/host/cards/store.js
CHANGED
|
@@ -154,13 +154,14 @@ export function createCardStore({ home, logger = () => {}, io = defaultIo, clock
|
|
|
154
154
|
* @param {object} input - 建卡输入
|
|
155
155
|
* @param {string} input.title - 任务标题
|
|
156
156
|
* @param {string} [input.spec] - 任务规格
|
|
157
|
+
* @param {string} [input.kind] - 分类标签;省略表示未分类
|
|
157
158
|
* @param {object[]} [input.links] - 链接条目
|
|
158
159
|
* @param {object} [input.slots] - 槽位绑定
|
|
159
160
|
* @param {string} [input.projectId] - 所属项目 id;宿主按调用方会话判定
|
|
160
161
|
* @param {string} [input.createdBy] - 建卡会话 id
|
|
161
162
|
* @returns {Promise<object>} 新建的卡片
|
|
162
163
|
*/
|
|
163
|
-
async create({ title, spec, links, slots, projectId, createdBy }) {
|
|
164
|
+
async create({ title, spec, kind, links, slots, projectId, createdBy }) {
|
|
164
165
|
return serialize(async () => {
|
|
165
166
|
const store = await readStore(file, recoverFromCorruption, io)
|
|
166
167
|
const now = clock()
|
|
@@ -170,6 +171,7 @@ export function createCardStore({ home, logger = () => {}, io = defaultIo, clock
|
|
|
170
171
|
revision: 0,
|
|
171
172
|
title,
|
|
172
173
|
...spec === undefined ? {} : { spec },
|
|
174
|
+
...kind === undefined ? {} : { kind },
|
|
173
175
|
status: 'active',
|
|
174
176
|
...links === undefined ? {} : { links },
|
|
175
177
|
...slots === undefined ? {} : { slots },
|
|
@@ -193,6 +195,7 @@ export function createCardStore({ home, logger = () => {}, io = defaultIo, clock
|
|
|
193
195
|
* @param {number} [input.expectedRevision] - 期望的内容版本
|
|
194
196
|
* @param {string} [input.title] - 新标题
|
|
195
197
|
* @param {string} [input.spec] - 新规格
|
|
198
|
+
* @param {string} [input.kind] - 新分类;空串表示清除分类
|
|
196
199
|
* @param {string} [input.status] - 新状态
|
|
197
200
|
* @param {object[]} [input.links] - 新链接条目(整体替换)
|
|
198
201
|
* @param {object[]} [input.addLinks] - 追加的链接条目(按 id 合并,与 `links` 互斥)
|
|
@@ -205,6 +208,7 @@ export function createCardStore({ home, logger = () => {}, io = defaultIo, clock
|
|
|
205
208
|
expectedRevision,
|
|
206
209
|
title,
|
|
207
210
|
spec,
|
|
211
|
+
kind,
|
|
208
212
|
status,
|
|
209
213
|
links,
|
|
210
214
|
addLinks,
|
|
@@ -244,6 +248,11 @@ export function createCardStore({ home, logger = () => {}, io = defaultIo, clock
|
|
|
244
248
|
const next = { ...card }
|
|
245
249
|
if (title !== undefined) next.title = title
|
|
246
250
|
if (spec !== undefined) next.spec = spec
|
|
251
|
+
// 空串是「清除分类」——卡片字段省略即未分类,不留空字符串占位
|
|
252
|
+
if (kind !== undefined) {
|
|
253
|
+
if (kind === '') delete next.kind
|
|
254
|
+
else next.kind = kind
|
|
255
|
+
}
|
|
247
256
|
if (links !== undefined) next.links = links
|
|
248
257
|
if (addLinks !== undefined) next.links = mergeLinks(card.links, addLinks)
|
|
249
258
|
if (slots !== undefined) next.slots = slots
|
|
@@ -277,6 +286,32 @@ export function createCardStore({ home, logger = () => {}, io = defaultIo, clock
|
|
|
277
286
|
})
|
|
278
287
|
},
|
|
279
288
|
|
|
289
|
+
/**
|
|
290
|
+
* 从卡片库删除一张卡。
|
|
291
|
+
*
|
|
292
|
+
* 删除是破坏性操作,没有 tombstone 可恢复;编号原样保留在 `counter` 里,
|
|
293
|
+
* 不分配给下一张卡。索引同步重建,避免已删卡继续给会话注入角色与卡片事实。
|
|
294
|
+
*
|
|
295
|
+
* 卡片不存在时返回 `undefined`:调用方(看板的人工删除)按幂等成功收尾,
|
|
296
|
+
* 不把「别人已经删了」报成失败。
|
|
297
|
+
*
|
|
298
|
+
* @param {object} input - 删除输入
|
|
299
|
+
* @param {string} input.id - 卡片 id
|
|
300
|
+
* @returns {Promise<object | undefined>} 被删卡片;不存在时 undefined
|
|
301
|
+
*/
|
|
302
|
+
async remove({ id }) {
|
|
303
|
+
return serialize(async () => {
|
|
304
|
+
const store = await readStore(file, recoverFromCorruption, io)
|
|
305
|
+
const index = store.cards.findIndex((item) => item.id === id)
|
|
306
|
+
if (index === -1) return undefined
|
|
307
|
+
const [card] = store.cards.splice(index, 1)
|
|
308
|
+
// counter 原样保留:删掉的编号不能被下一张卡复用(`@#n` 引用不能换人)。
|
|
309
|
+
await writeStore(store)
|
|
310
|
+
rebuildIndexes(store.cards, slotIndex, cardIndex)
|
|
311
|
+
return card
|
|
312
|
+
})
|
|
313
|
+
},
|
|
314
|
+
|
|
280
315
|
/**
|
|
281
316
|
* 把某个槽位绑到一个会话上(派工时用,会话 id 事先已知)。
|
|
282
317
|
*
|
package/src/host/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import { createSkillProvider } from './skills.js'
|
|
|
19
19
|
import { createSpawnWorkerTool } from './tools/spawn-worker.js'
|
|
20
20
|
import { createMessageWorkerTool } from './tools/message-worker.js'
|
|
21
21
|
import { createReadWorkerTool } from './tools/read-worker.js'
|
|
22
|
-
import { createCreateCardTool, createUpdateCardTool, createListCardsTool } from './tools/cards.js'
|
|
22
|
+
import { createCreateCardTool, createUpdateCardTool, createListCardsTool, createReadCardTool } from './tools/cards.js'
|
|
23
23
|
import { createNotificationStore } from './notification-store.js'
|
|
24
24
|
import { resolveDshHome } from './home-paths.js'
|
|
25
25
|
import { createWorkerRegistry } from './worker-registry.js'
|
|
@@ -72,7 +72,8 @@ export const inject = ['skills', 'tools', 'systemPrompt']
|
|
|
72
72
|
* 写卡身份判定;传了 `cards` 就必须传它
|
|
73
73
|
* @param {(sessionId: string | undefined) => boolean} [options.isWorkerSession] - worker 判定;
|
|
74
74
|
* 与 `cardBindingsOf` 一起限定 worker 的写卡范围
|
|
75
|
-
* @param {(sessionId: string) => Promise<object[]>} [options.cardBindingsOf] -
|
|
75
|
+
* @param {(sessionId: string) => Promise<object[]>} [options.cardBindingsOf] - 会话挂着的卡;
|
|
76
|
+
* 与 `isWorkerSession` 一起限定 worker 的写卡范围,`read_card` 用它反查默认要读的卡
|
|
76
77
|
* @returns {object[]} 工具定义
|
|
77
78
|
*/
|
|
78
79
|
export function createBundleTools({
|
|
@@ -111,6 +112,12 @@ export function createBundleTools({
|
|
|
111
112
|
cardBindingsOf,
|
|
112
113
|
}),
|
|
113
114
|
createListCardsTool({ store: cards, resolveProject }),
|
|
115
|
+
createReadCardTool({
|
|
116
|
+
store: cards,
|
|
117
|
+
resolveProject,
|
|
118
|
+
isWorkerSession,
|
|
119
|
+
cardBindingsOf,
|
|
120
|
+
}),
|
|
114
121
|
]
|
|
115
122
|
}
|
|
116
123
|
|
|
@@ -242,6 +242,30 @@ export function createProjectRemote({ service, cards, workers, workerSessions, c
|
|
|
242
242
|
return this.cards.update({ id, links: prepared })
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
+
/**
|
|
246
|
+
* 删除一张卡片。
|
|
247
|
+
*
|
|
248
|
+
* 看板详情浮层的删除入口走这里:人工确认后直接转调卡片存储的 `remove`,
|
|
249
|
+
* 与会话工具无关。删除是硬删、不可撤销,编号不回收;卡片上的槽位绑定在
|
|
250
|
+
* 存储层重建索引时一并解除。
|
|
251
|
+
*
|
|
252
|
+
* 卡片已经不在了时报 `notFound`,按幂等成功收尾——详情浮层拿的是打开
|
|
253
|
+
* 瞬间的快照,别人先删掉是正常并发,不该把「已经不存在」报成删除失败。
|
|
254
|
+
* 与 `updateCardLinks` 一样不做项目归属校验:`direct` 调用拿不到调用方
|
|
255
|
+
* 会话,这是单机单用户威胁模型下的既有取舍。
|
|
256
|
+
*
|
|
257
|
+
* @param {string} id - 卡片 id
|
|
258
|
+
* @returns {Promise<{removed: boolean, notFound?: boolean, reason?: string}>} 删除结果
|
|
259
|
+
*/
|
|
260
|
+
async deleteCard(id) {
|
|
261
|
+
if (typeof id !== 'string' || id === '') throw new Error('deleteCard: id 不能为空')
|
|
262
|
+
const removed = await this.cards.remove({ id })
|
|
263
|
+
if (removed === undefined) {
|
|
264
|
+
return { removed: false, notFound: true, reason: '卡片不存在。' }
|
|
265
|
+
}
|
|
266
|
+
return { removed: true }
|
|
267
|
+
}
|
|
268
|
+
|
|
245
269
|
/**
|
|
246
270
|
* 项目的槽位显示名字典。
|
|
247
271
|
*
|