dsh-bufeng 0.0.0-stage → 0.64.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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +68 -2
  3. package/bufeng.patch.yml +3 -0
  4. package/client/build-client.mjs +159 -0
  5. package/client/client.js +4038 -0
  6. package/client/src/board.js +133 -0
  7. package/client/src/capabilities.js +787 -0
  8. package/client/src/cards.js +263 -0
  9. package/client/src/data.js +43 -0
  10. package/client/src/graph.js +558 -0
  11. package/client/src/icons.js +88 -0
  12. package/client/src/projects.js +467 -0
  13. package/client/src/prompt.js +55 -0
  14. package/client/src/react.js +7 -0
  15. package/client/src/settings.js +407 -0
  16. package/client/src/styles.js +611 -0
  17. package/client/src/taskboard.js +321 -0
  18. package/client/src/taskgraph.js +145 -0
  19. package/client/src/ui.js +72 -0
  20. package/lib/acceptance-subject.js +71 -0
  21. package/lib/board/server.js +546 -0
  22. package/lib/board/snapshot.js +133 -0
  23. package/lib/board/taskview.js +151 -0
  24. package/lib/bootstrap.js +77 -0
  25. package/lib/catalog.js +385 -0
  26. package/lib/core.js +478 -0
  27. package/lib/data/capability-alias-catalog.json +301 -0
  28. package/lib/data/capability-alias.json +25 -0
  29. package/lib/domain.js +1342 -0
  30. package/lib/host-probe.js +176 -0
  31. package/lib/identity-hook.js +490 -0
  32. package/lib/index.js +119 -0
  33. package/lib/lessons.js +134 -0
  34. package/lib/metering.js +109 -0
  35. package/lib/scope.js +389 -0
  36. package/lib/session/child-watch.js +86 -0
  37. package/lib/session/evidence.js +118 -0
  38. package/lib/session/node-session.js +335 -0
  39. package/lib/session/queue.js +307 -0
  40. package/lib/session/reconcile.js +500 -0
  41. package/lib/tools/capabilities.js +1461 -0
  42. package/lib/tools/governance.js +579 -0
  43. package/lib/tools/index.js +33 -0
  44. package/lib/tools/project.js +500 -0
  45. package/lib/tools/readonly.js +566 -0
  46. package/lib/tools/recover.js +402 -0
  47. package/lib/tools/run.js +1609 -0
  48. package/lib/tools/skills.js +162 -0
  49. package/lib/tools/trees.js +637 -0
  50. package/lib/workspace-rmw.js +365 -0
  51. package/package.json +42 -4
@@ -0,0 +1,88 @@
1
+ /**
2
+ * client/src/icons.js — v0.24.0「星枢」三角色 SVG 资产(方案 A 定稿,形状/配色源=tmp/icons/v0.24.0-角色图标候选.html)。
3
+ * 三角色 × 三档(16/24/48):总管=紫罗盘中枢节点(radialGradient ga1 #a5b4fc→#5b21b6,辐射三链路+罗盘针)、
4
+ * 都管=青盾带队节点(linearGradient ga2 #2dd4bf→#0f766e)、成员=琥珀齿轮(linearGradient ga3 #fbbf24→#d97706)。
5
+ * 渐变 id 同页多实例去重:每实例 uid 后缀(ga1-<uid>),uid 由调用方给(节点 id/任务 id/固定串),缺省走模块内自增。
6
+ * 依赖方向:仅依赖 react(与 ui/data/styles 同层;供 graph/cards/tasks/settings/board 引用,禁止反向)。
7
+ */
8
+ import { h } from './react.js';
9
+
10
+ /* kind → 角色:兼容新旧账本数据值(root=新账本根节点 kind;orchestrator=旧账本兼容读)+ 显示词(总管/都管/队长/成员) */
11
+ const KIND_ROLE = {
12
+ "root": "orchestrator", "orchestrator": "orchestrator", "总管": "orchestrator",
13
+ "leader": "leader", "都管": "leader", "队长": "leader",
14
+ "member": "member", "成员": "member",
15
+ };
16
+
17
+ /* v0.24.0 根节点判定:root=新账本根节点 kind,orchestrator=旧账本兼容读——graph 根收集/过滤与 board hasOrch 共用,防多处漂移 */
18
+ export function isRootKind(k) {
19
+ return k === "root" || k === "orchestrator";
20
+ }
21
+
22
+ let uidSeq = 0;
23
+ const uidOf = (uid) => uid || "u" + (++uidSeq);
24
+
25
+ /* 三枚形状 1:1 取自候选页方案 A(viewBox 0 0 64 64,等比缩放到 size);uid 保证 defs 渐变 id 同页唯一 */
26
+ function xingshuSvg(role, uid, size) {
27
+ const s = size || 16;
28
+ if (role === "orchestrator") {
29
+ const g = "ga1-" + uidOf(uid);
30
+ return h("svg", { width: s, height: s, viewBox: "0 0 64 64", "aria-hidden": true, style: { flex: "none" } },
31
+ h("defs", null, h("radialGradient", { id: g, cx: "35%", cy: "30%" },
32
+ h("stop", { offset: "0%", stopColor: "#a5b4fc" }),
33
+ h("stop", { offset: "100%", stopColor: "#5b21b6" }))),
34
+ h("g", { stroke: "#c7d2fe", strokeWidth: 2.5 },
35
+ h("line", { x1: 32, y1: 30, x2: 11, y2: 13 }),
36
+ h("line", { x1: 32, y1: 30, x2: 53, y2: 13 }),
37
+ h("line", { x1: 32, y1: 30, x2: 32, y2: 56 })),
38
+ h("circle", { cx: 11, cy: 13, r: 3.6, fill: "#a5b4fc" }),
39
+ h("circle", { cx: 53, cy: 13, r: 3.6, fill: "#a5b4fc" }),
40
+ h("circle", { cx: 32, cy: 56, r: 3.6, fill: "#a5b4fc" }),
41
+ h("circle", { cx: 32, cy: 30, r: 13.5, fill: "url(#" + g + ")" }),
42
+ h("path", { d: "M32 19.5 L36.6 30 L27.4 30 Z", fill: "#eef2ff" }),
43
+ h("path", { d: "M32 40.5 L36.6 30 L27.4 30 Z", fill: "#ffffff", opacity: 0.55 }),
44
+ h("circle", { cx: 32, cy: 30, r: 13.5, fill: "none", stroke: "#ffffff", strokeOpacity: 0.35, strokeWidth: 1.5 }));
45
+ }
46
+ if (role === "leader") {
47
+ const g = "ga2-" + uidOf(uid);
48
+ return h("svg", { width: s, height: s, viewBox: "0 0 64 64", "aria-hidden": true, style: { flex: "none" } },
49
+ h("defs", null, h("linearGradient", { id: g, x1: 0, y1: 0, x2: 0, y2: 1 },
50
+ h("stop", { offset: "0%", stopColor: "#2dd4bf" }),
51
+ h("stop", { offset: "100%", stopColor: "#0f766e" }))),
52
+ h("path", { d: "M32 7 L52 14.5 V31 C52 45.5 43.5 53.5 32 57.5 C20.5 53.5 12 45.5 12 31 V14.5 Z", fill: "url(#" + g + ")" }),
53
+ h("circle", { cx: 32, cy: 25.5, r: 4.6, fill: "#ccfbf1" }),
54
+ h("g", { stroke: "#99f6e4", strokeWidth: 2.6 },
55
+ h("line", { x1: 32, y1: 25.5, x2: 23.5, y2: 42 }),
56
+ h("line", { x1: 32, y1: 25.5, x2: 40.5, y2: 42 })),
57
+ h("circle", { cx: 23.5, cy: 42, r: 3.2, fill: "#99f6e4" }),
58
+ h("circle", { cx: 40.5, cy: 42, r: 3.2, fill: "#99f6e4" }));
59
+ }
60
+ const g = "ga3-" + uidOf(uid);
61
+ return h("svg", { width: s, height: s, viewBox: "0 0 64 64", "aria-hidden": true, style: { flex: "none" } },
62
+ h("defs", null, h("linearGradient", { id: g, x1: 0, y1: 0, x2: 0, y2: 1 },
63
+ h("stop", { offset: "0%", stopColor: "#fbbf24" }),
64
+ h("stop", { offset: "100%", stopColor: "#d97706" }))),
65
+ h("g", { fill: "url(#" + g + ")" },
66
+ h("circle", { cx: 32, cy: 32, r: 14 }),
67
+ h("rect", { x: 29.4, y: 6, width: 5.2, height: 11, rx: 2.2 }),
68
+ h("rect", { x: 29.4, y: 47, width: 5.2, height: 11, rx: 2.2 }),
69
+ h("rect", { x: 29.4, y: 6, width: 5.2, height: 11, rx: 2.2, transform: "rotate(45 32 32)" }),
70
+ h("rect", { x: 29.4, y: 47, width: 5.2, height: 11, rx: 2.2, transform: "rotate(45 32 32)" }),
71
+ h("rect", { x: 29.4, y: 6, width: 5.2, height: 11, rx: 2.2, transform: "rotate(90 32 32)" }),
72
+ h("rect", { x: 29.4, y: 47, width: 5.2, height: 11, rx: 2.2, transform: "rotate(90 32 32)" }),
73
+ h("rect", { x: 29.4, y: 6, width: 5.2, height: 11, rx: 2.2, transform: "rotate(135 32 32)" }),
74
+ h("rect", { x: 29.4, y: 47, width: 5.2, height: 11, rx: 2.2, transform: "rotate(135 32 32)" })),
75
+ h("circle", { cx: 32, cy: 32, r: 6, fill: "#fffbeb" }),
76
+ h("circle", { cx: 32, cy: 32, r: 2.4, fill: "#d97706" }));
77
+ }
78
+
79
+ /* 主入口:kind 收数据值或显示词,未知一律按成员兜底 */
80
+ export function RoleIcon({ kind, uid, size }) {
81
+ return xingshuSvg(KIND_ROLE[kind] || "member", uid, size);
82
+ }
83
+
84
+ /* 三档定档导出:16(节点卡/任务行标记)· 24(设置页图例)· 48(空态/展示位) */
85
+ export const ROLE_ICON_SIZES = [16, 24, 48];
86
+ export function RoleIconSm({ kind, uid }) { return xingshuSvg(KIND_ROLE[kind] || "member", uid, 16); }
87
+ export function RoleIconMd({ kind, uid }) { return xingshuSvg(KIND_ROLE[kind] || "member", uid, 24); }
88
+ export function RoleIconLg({ kind, uid }) { return xingshuSvg(KIND_ROLE[kind] || "member", uid, 48); }
@@ -0,0 +1,467 @@
1
+ /**
2
+ * client/src/projects.js — 项目概览(v0.15.0 项目制;v0.40.1 四 tab P0 项目页)。
3
+ *
4
+ * 项目=业务目录 + 说明 + 归属都管;这里展示「目录 × 任务 × 编制」的关联,
5
+ * 不复制智能体能力面。项目上下文(projectNote)只说明归属,不展开正文。
6
+ * v0.41.0:项目卡新增都管下拉(LeaderCtl)——选中即绑定/换绑、选「解绑…」清空,
7
+ * POST /bufeng/api/project/leader(看板=总管代行),与 bufeng_project update
8
+ * leaderNodeId 同一校验路径;推翻 v0.39.1「看板只读」口径(ADR 注记见 docs/决策/)。
9
+ * v0.42.0(方案 B,客户 2026-10-23 拍板):项目 tab 从「每项目一整屏堆叠」改为
10
+ * 「列表 + 详情」——①工具条=搜索(名/描述/路径)+治理过滤 chips(带实时计数)+排序;
11
+ * ②列表=吸附表头+六列行(项目[名+都管徽章+缺目录标]/任务四数/分布条/都管[行内迷你
12
+ * 下拉,stopPropagation 隔离行点击]/活跃/路径),默认前 12+「展开全部」;③详情=复用
13
+ * ProjectCard(v0.41.0 完整都管下拉)+任务流卡+右侧三小卡,「↑ 收起详情」。列表状态
14
+ * (搜索词/chip/排序/展开/选中行)存组件 state——SSE 全帧刷新(重渲染)不重置;点击
15
+ * chip/搜索词变化即重置展开态。排序字段一律用快照真实投影(lastTaskAt 缺省排末尾/
16
+ * name/tasksByStatus/taskCount)。旧快照(无都管三键):行内下拉与徽章整段不渲染,
17
+ * 「都管未绑定/⚠️ 悬挂」两枚 chip 不出(同 LeaderCtl 既有口径,防误报)。
18
+ * v0.43.0 阶段2A(k-mvl3hrlo0nc):项目行新增编制覆盖徽标 covBadgeOf——绿=coverage.present&&complete
19
+ * 「✅ 覆盖齐备」data-bf-covbadge="ok";黄=有缺口「⚠️ 覆盖缺口 N」/未定义矩阵「⚠️ 未定义覆盖矩阵」
20
+ * data-bf-covbadge="gap";缺口时环节名直显(covGapLineOf:gaps[].name+reason 中文短标签)。
21
+ * 防御口径同 leaderBadgeOf:旧快照 coverage 键 undefined 整段不渲染;纯展示零请求、行点击语义不变。
22
+ */
23
+ import { h, useState } from './react.js';
24
+ import { fmtTime, DIM, LINE, TaskDot, TaskStateWord } from './ui.js';
25
+
26
+ const COLORS = { running: '#4f7cf0', pending: '#d8a516', queued: '#d8a516', done: '#2f9e44', failed: '#e5484d', cancelled: '#8b94a7' };
27
+ const pct = (n, total) => (total ? Math.round((n / total) * 1000) / 10 : 0);
28
+
29
+ function countTasks(tasks) {
30
+ const c = { running: 0, pending: 0, queued: 0, done: 0, failed: 0, cancelled: 0 };
31
+ for (const k of tasks || []) if (c[k.status] !== undefined) c[k.status]++;
32
+ return c;
33
+ }
34
+
35
+ /* ---------- 都管下拉(v0.41.0 客户需求「项目都管分配,添加下拉选」):
36
+ * 选中即绑定/换绑、选「解绑…」=清空(POST body {projectId, leaderNodeId: string|null})。
37
+ * 账本为权威:写成功先本地对齐(override),SSE 全帧刷新即校准;busy 禁用,错误红字回落。
38
+ * v0.42.0:mini 形态=列表行内直改(onClick stopPropagation——点下拉不触发行点击/行选中;
39
+ * onChange 同样止泡防 select 事件冒泡;回执收进行内小字)。POST 语义两形态完全一致。 ---------- */
40
+ function leaderGroupsOf(snap) {
41
+ const groups = [];
42
+ for (const t of (snap && snap.trees) || []) {
43
+ if (t.status && t.status !== "active") continue; // 归档树不可绑定(resolveProjectLeader 只认 active 树)
44
+ const leaders = (t.nodes || []).filter((n) => n.kind === "leader" && n.status !== "retired");
45
+ if (leaders.length) groups.push({ tree: t, leaders });
46
+ }
47
+ return groups;
48
+ }
49
+
50
+ // v0.39.x A1 都管三态徽章(v0.42.0 抽共用:详情卡+列表行同源;旧快照三键皆 undefined=不渲染,防误报)
51
+ const leaderKnownOf = (p) => p.leaderNodeId !== undefined || p.leader !== undefined || p.leaderStale !== undefined;
52
+ const leaderBadgeOf = (p) => {
53
+ const leader = p.leader || null;
54
+ if (!leaderKnownOf(p)) return null;
55
+ if (leader) return h("span", { className: "bf-badge", style: { color: "#8fd6a7", borderColor: "#2f6b45", background: "#122018" },
56
+ title: "项目绑定都管:" + leader.name + "(" + leader.status + ")· 派单按绑定都管路由" }, "🧭 " + leader.name);
57
+ if (p.leaderStale) return h("span", { className: "bf-badge", style: { color: "#e0b45c", borderColor: "#6b5426", background: "#211c12" },
58
+ title: "绑定的都管已失效(id 不存在/非都管/归档树/退役)——派单会被拒;用 bufeng_project update leaderNodeId=<id> 重新绑定" }, "⚠️ 都管悬挂");
59
+ return h("span", { className: "bf-badge", style: { color: "#8b94a7", borderColor: "#39414f", background: "#171b22" },
60
+ title: "项目未绑定都管——下拉选择绑定,或 bufeng_project update leaderNodeId=<都管 id>;绑定后派单按都管路由" }, "都管未绑定");
61
+ };
62
+
63
+ /* ---------- v0.43.0 阶段2A 编制覆盖徽标(k-mvl3hrlo0nc):绿=矩阵齐备 / 黄=有缺口或未定义矩阵 ----------
64
+ * 防御口径同 leaderBadgeOf:旧快照 coverage 键 undefined(或非对象)→ 整段不渲染,不得抛错。
65
+ * 纯展示:零网络请求、无 onClick(行点击开详情的既有交互语义不变);data-bf-covbadge="ok"|"gap"
66
+ * 供 sim 定位;缺口时环节名直显(gaps[].name + reason 中文短标签),no-plan 的唯一缺口=未定义本身不重复直显。 ---------- */
67
+ const COV_REASON_LABEL = { "no-plan": "未定义矩阵", "node-missing": "节点缺失", "node-retired": "节点已退役", "no-seat": "无人接" };
68
+ const covGapNamesOf = (cov) => (Array.isArray(cov && cov.gaps) ? cov.gaps : [])
69
+ .map((g) => String((g && g.name) || "(未名环节)") + "·" + (COV_REASON_LABEL[g && g.reason] || "待核对"));
70
+ const covBadgeOf = (p) => {
71
+ const cov = p.coverage;
72
+ if (!cov || typeof cov !== "object") return null; // 旧快照:不渲染徽标(防误报,同 leaderBadgeOf)
73
+ if (cov.present && cov.complete) return h("span", { className: "bf-badge", "data-bf-covbadge": "ok",
74
+ style: { color: "#8fd6a7", borderColor: "#2f6b45", background: "#122018" },
75
+ title: "编制覆盖矩阵齐备:" + (cov.stageCount !== undefined ? cov.stageCount + " 个环节全有席位" : "环节全有席位") }, "✅ 覆盖齐备");
76
+ const n = cov.gapCount !== undefined ? cov.gapCount : covGapNamesOf(cov).length;
77
+ const noPlan = !cov.present;
78
+ const names = covGapNamesOf(cov);
79
+ return h("span", { className: "bf-badge", "data-bf-covbadge": "gap",
80
+ style: { color: "#e0b45c", borderColor: "#6b5426", background: "#211c12" },
81
+ title: noPlan ? "项目未定义覆盖矩阵——bufeng_project update coveragePlan 配置环节×席位,或 bufeng_capabilities { action: \"coverage\" } 查看"
82
+ : "覆盖缺口 " + n + ":" + names.join("、") + "——bufeng_project update coveragePlan 补齐矩阵" },
83
+ noPlan ? "⚠️ 未定义覆盖矩阵" : "⚠️ 覆盖缺口 " + n);
84
+ };
85
+ const covGapLineOf = (p) => { // 缺口环节名直显行(仅矩阵已定义且真有缺口;no-plan 缺口=未定义本身,徽标文案已覆盖)
86
+ const cov = p.coverage;
87
+ if (!cov || typeof cov !== "object" || !cov.present || cov.complete) return null;
88
+ const names = covGapNamesOf(cov);
89
+ if (!names.length) return null;
90
+ return h("span", { className: "bf-meta", "data-bf-covgaps": p.id,
91
+ style: { flexBasis: "100%", minWidth: 0, color: "#e0b45c", fontSize: 10.5,
92
+ whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" },
93
+ title: "缺失环节:" + names.join("、") }, names.join("、"));
94
+ };
95
+
96
+ function LeaderCtl({ p, snap, mini }) {
97
+ const [busy, setBusy] = useState(false);
98
+ const [err, setErr] = useState("");
99
+ const [okMsg, setOkMsg] = useState("");
100
+ const [override, setOverride] = useState(undefined); // 写成功即时对齐(undefined=跟随快照)
101
+ if (!leaderKnownOf(p)) return null; // 旧快照三键皆 undefined:整段不渲染(同徽章口径,防误报)
102
+ const ledgerCur = p.leader ? p.leader.nodeId : (p.leaderStale ? p.leaderNodeId : null);
103
+ const cur = override !== undefined ? override : ledgerCur;
104
+ const groups = leaderGroupsOf(snap);
105
+ const curLabel = cur ? (p.leader ? p.leader.name + "(" + p.leader.status + ")" : "⚠️ 悬挂:" + String(cur)) : "未绑定";
106
+ const post = async (nodeId, okText) => {
107
+ if (busy) return;
108
+ setBusy(true); setErr(""); setOkMsg("");
109
+ try {
110
+ const r = await fetch("/bufeng/api/project/leader", { method: "POST",
111
+ headers: { "content-type": "application/json" },
112
+ body: JSON.stringify({ projectId: p.id, leaderNodeId: nodeId }) });
113
+ const j = await r.json().catch(() => ({}));
114
+ if (r.ok && j && j.ok) {
115
+ setOverride(nodeId);
116
+ setOkMsg(okText);
117
+ setTimeout(() => setOkMsg((s) => (s === okText ? "" : s)), 5000);
118
+ } else {
119
+ setErr((j && j.error) ? String(j.error) : "保存失败(HTTP " + r.status + ")");
120
+ }
121
+ } catch (e) {
122
+ setErr("保存失败:" + String((e && e.message) || e));
123
+ }
124
+ setBusy(false);
125
+ };
126
+ const onPick = (v) => {
127
+ if (busy || v === (cur ?? "")) return; // 选中现值=幂等不发包
128
+ if (v === "") post(null, "已解绑都管");
129
+ else {
130
+ let name = v;
131
+ for (const g of groups) { const hit = g.leaders.find((n) => n.id === v); if (hit) { name = hit.name; break; } }
132
+ post(v, "已绑定都管 " + name);
133
+ }
134
+ };
135
+ const options = [
136
+ h("option", { value: "" }, cur ? "解绑…" : "(未绑定)"),
137
+ !groups.length ? h("option", { value: "__none", disabled: true }, "(暂无可绑定都管)") : null,
138
+ groups.map((g) => h("optgroup", { key: g.tree.id, label: g.tree.name },
139
+ g.leaders.map((n) => h("option", { key: n.id, value: n.id },
140
+ n.name + " · " + n.status + (n.membersCount ? " · " + n.membersCount + "成员" : ""))))),
141
+ p.leaderStale && cur ? h("option", { value: cur, disabled: true }, "⚠️ 悬挂绑定(id 已失效)") : null];
142
+ if (mini) {
143
+ return h("span", { className: "bf-meta", "data-bf-leadminictl": p.id,
144
+ style: { display: "flex", alignItems: "center", gap: 5, minWidth: 0, flexWrap: "wrap" } },
145
+ h("select", { className: "bf-model-sel", "data-bf-leadmini": p.id, "data-bf-projectid": p.id,
146
+ value: cur ?? "", disabled: busy, "aria-label": "项目都管(行内直改)",
147
+ title: "行内直改:选择即绑定/换绑;选「解绑…」清空绑定。等同 bufeng_project update leaderNodeId;点击下拉不会打开行详情",
148
+ style: { maxWidth: 168 },
149
+ onClick: (e) => { if (e && e.stopPropagation) e.stopPropagation(); },
150
+ onChange: (e) => { if (e && e.stopPropagation) e.stopPropagation(); onPick(e.target.value); } },
151
+ options),
152
+ okMsg ? h("span", { "data-bf-leadok": p.id, style: { color: "var(--dsw-alias-state-success-primary, #2f9e44)", whiteSpace: "nowrap" } }, "✓ " + okMsg) : null,
153
+ err ? h("span", { "data-bf-leaderr": p.id, style: { color: "var(--dsw-alias-state-error-label, #e5484d)", whiteSpace: "nowrap" }, title: err }, "✕ " + err) : null);
154
+ }
155
+ return h("div", { className: "bf-meta", "data-bf-leaderctl": p.id,
156
+ style: { marginTop: 3, display: "flex", alignItems: "center", gap: 7, flexWrap: "wrap" } },
157
+ h("span", null, "都管:", h("span", { title: "当前绑定(账本为准,SSE 刷新校准)" }, curLabel)),
158
+ h("select", { className: "bf-model-sel", "data-bf-leadersel": "1", "data-bf-projectid": p.id,
159
+ value: cur ?? "", disabled: busy, "aria-label": "项目都管",
160
+ title: "下拉选择即绑定/换绑;选「解绑…」清空绑定。等同 bufeng_project update leaderNodeId=<id|null>;绑定后派单按绑定都管路由",
161
+ onChange: (e) => onPick(e.target.value) },
162
+ options),
163
+ okMsg ? h("span", { style: { color: "var(--dsw-alias-state-success-primary, #2f9e44)" } }, "✓ " + okMsg) : null,
164
+ err ? h("span", { style: { color: "var(--dsw-alias-state-error-label, #e5484d)" }, title: err }, "✕ " + err) : null);
165
+ }
166
+
167
+ /* ---------- 项目卡:统计 / 分布 / 最近任务 / 参与智能体(v0.42.0 起由详情区复用) ---------- */
168
+ function ProjectCard({ p, tasks, snap }) {
169
+ const mine = (tasks || []).filter((k) => k.projectId === p.id);
170
+ const st = p.tasksByStatus || countTasks(mine);
171
+ const total = p.taskCount !== undefined ? p.taskCount : mine.length;
172
+ const recent = mine.slice(0, 3);
173
+
174
+ const leaderBadge = leaderBadgeOf(p); // v0.41.0 都管三态(旧快照三键皆 undefined=不渲染,防误报)
175
+ const leader = p.leader || null;
176
+
177
+ // 参与智能体:任务窗口里出现过的节点;同树全量节点用于计数
178
+ const allNodes = [];
179
+ for (const t of (snap && snap.trees) || []) for (const n of t.nodes || []) allNodes.push({ ...n, treeId: t.id, treeName: t.name });
180
+ const byId = {}; for (const n of allNodes) byId[n.id] = n;
181
+ const nodeIds = Array.from(new Set(mine.map((k) => k.nodeId).filter(Boolean)));
182
+ const participants = nodeIds.map((id) => byId[id]).filter(Boolean);
183
+ const boundLeaderNode = leader ? byId[leader.nodeId] : null;
184
+ const treeId = boundLeaderNode ? boundLeaderNode.treeId : (leader && leader.treeId) || null;
185
+ const treeNodes = treeId ? allNodes.filter((n) => n.treeId === treeId) : [];
186
+ const treeRunning = treeNodes.filter((n) => n.status === "running").length;
187
+
188
+ const seg = (key, label) => st[key] ? h("i", { key, title: label + " " + st[key],
189
+ style: { display: "block", height: "100%", width: pct(st[key], total) + "%", background: COLORS[key] } }) : null;
190
+ const stat = (key, label) => h("div", { style: { background: "rgba(128,128,128,0.06)", border: "1px solid rgba(128,128,128,0.18)", borderRadius: 8, padding: "8px 10px" } },
191
+ h("div", { style: { font: "700 22px/1.15 sans-serif", color: COLORS[key] } }, String(st[key] || 0)),
192
+ h("div", { className: "bf-meta", style: { marginTop: 2 } }, label));
193
+
194
+ return h("div", { className: "bf-card", "data-bf-projectcard": p.id,
195
+ style: { width: "100%", padding: 0, boxSizing: "border-box",
196
+ border: p.missing ? "1px solid var(--dsw-alias-state-error-primary, #e5484d)" : undefined } },
197
+ h("div", { style: { padding: "14px 16px 12px", display: "flex", flexDirection: "column", gap: 10 } },
198
+ h("div", { style: { display: "flex", alignItems: "flex-start", gap: 10 } },
199
+ h("div", { style: { width: 40, height: 40, flex: "none", borderRadius: 9, display: "flex", alignItems: "center", justifyContent: "center",
200
+ background: "rgba(79,124,240,0.14)", border: "1px solid rgba(79,124,240,0.32)", fontSize: 19 } }, "📁"),
201
+ h("div", { style: { minWidth: 0, flex: 1 } },
202
+ h("div", { style: { display: "flex", alignItems: "center", gap: 7, flexWrap: "wrap" } },
203
+ h("span", { style: { font: "650 20px/1.3 sans-serif", color: "var(--dsw-alias-label-primary, #eee)" } }, p.name),
204
+ leaderBadge,
205
+ p.missing ? h("span", { style: { color: "#e5484d", fontSize: 11 } }, "⚠️ 目录缺失") : null),
206
+ p.desc ? h("div", { className: "bf-meta", style: { marginTop: 3, whiteSpace: "normal", lineHeight: 1.6 } }, p.desc) : null)),
207
+ h("div", { className: "bf-meta", style: { fontFamily: "var(--ds-font-family-code, monospace)", padding: "5px 8px",
208
+ border: "1px solid rgba(128,128,128,0.18)", borderRadius: 6, background: "rgba(0,0,0,0.12)" }, title: p.path }, "⌂ " + p.path),
209
+ h("div", { style: { border: "1px dashed rgba(128,128,128,0.28)", borderRadius: 7, padding: "7px 9px", fontSize: 11, lineHeight: 1.65, color: "#98a6bb" } },
210
+ h("b", { style: { color: "#c4d2e8" } }, "项目上下文"), " 项目名 / 描述 / 路径 + 目录纪律(projectNote),只随绑定 projectId 的本次任务注入;不属于智能体自身提示词。"),
211
+ h(LeaderCtl, { p, snap }),
212
+ h("div", { style: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 8 } },
213
+ stat("running", "运行中"), stat("done", "已完成"), stat("failed", "失败"), stat("cancelled", "已取消")),
214
+ h("div", null,
215
+ h("div", { style: { display: "flex", alignItems: "center", gap: 8 } },
216
+ h("span", { className: "bf-meta" }, "任务分布"),
217
+ h("span", { style: { flex: 1 } }),
218
+ h("span", { className: "bf-meta" }, "共 " + total + " 条")),
219
+ h("div", { style: { display: "flex", height: 6, marginTop: 5, borderRadius: 99, overflow: "hidden", background: "rgba(128,128,128,0.14)" } },
220
+ seg("done", "完成"), seg("failed", "失败"), seg("running", "运行中"), seg("queued", "排队"), seg("cancelled", "取消")),
221
+ h("div", { className: "bf-meta", style: { marginTop: 5, display: "flex", gap: 12, flexWrap: "wrap" } },
222
+ h("span", null, "● 完成 " + (st.done || 0)), h("span", null, "● 失败 " + (st.failed || 0)),
223
+ h("span", null, "● 运行 " + (st.running || 0)), h("span", null, "● 取消 " + (st.cancelled || 0)))),
224
+ h("div", { style: { borderTop: "1px solid rgba(128,128,128,0.14)", paddingTop: 8 } },
225
+ h("div", { className: "bf-meta", style: { marginBottom: 3 } }, "最近任务"),
226
+ recent.length ? recent.map((k) => h("div", { key: k.id, style: { display: "flex", alignItems: "center", gap: 6, minWidth: 0, padding: "2px 0" } },
227
+ h(TaskDot, { s: k.status }),
228
+ h("span", { className: "bf-tb-title", style: { flex: 1, minWidth: 0 }, title: k.title }, k.title || k.id),
229
+ h(TaskStateWord, { s: k.status }),
230
+ h("span", { className: "bf-meta", style: { flex: "none" } }, fmtTime(k.createdAt)))) : h("div", { className: "bf-meta" }, "窗口内无记录")),
231
+ h("div", { style: { borderTop: "1px solid rgba(128,128,128,0.14)", paddingTop: 8 } },
232
+ h("div", { className: "bf-meta", style: { marginBottom: 4 } }, "参与智能体"),
233
+ participants.length ? participants.map((n) => h("span", { key: n.id, className: "bf-badge", style: { marginRight: 5, marginBottom: 4, display: "inline-flex" } },
234
+ h(TaskDot, { s: n.status }), h("span", { style: { marginLeft: 4 } }, n.name))) : h("span", { className: "bf-meta" }, "窗口内无任务")),
235
+ h("div", { className: "bf-meta", style: { borderTop: "1px dashed rgba(128,128,128,0.22)", paddingTop: 7, lineHeight: 1.65 } },
236
+ "项目页不复制编制:角色 / 系统在「智能体概览」,任务 / 项目装配在「任务详情」;项目只提供目录、任务与绑定。")));
237
+ }
238
+
239
+ /* ---------- v0.42.0 方案 B:工具条(搜索/chips/排序)+ 列表(前 12 展开)+ 详情 ---------- */
240
+ const PAGE = 12;
241
+ const ROW_GRID = "minmax(170px,1.25fr) 148px minmax(90px,0.9fr) 200px 100px minmax(90px,0.8fr)";
242
+ const CHIPS = [
243
+ ["all", "全部"],
244
+ ["running", "● 运行中"],
245
+ ["failed", "● 有失败"],
246
+ ["unbound", "都管未绑定"],
247
+ ["stale", "⚠️ 悬挂"],
248
+ ["missing", "⚠️ 目录缺失"],
249
+ ];
250
+ const SORTS = [
251
+ ["active", "最近活跃 ↓"],
252
+ ["name", "名称 A→Z"],
253
+ ["failed", "失败数 ↓"],
254
+ ["total", "总任务 ↓"],
255
+ ];
256
+ const stOf = (p) => p.tasksByStatus || {};
257
+
258
+ function chipHit(kind, p) {
259
+ if (kind === "running") return (stOf(p).running || 0) > 0;
260
+ if (kind === "failed") return (stOf(p).failed || 0) > 0;
261
+ if (kind === "unbound") return leaderKnownOf(p) && !p.leaderNodeId && !p.leader && !p.leaderStale;
262
+ if (kind === "stale") return !!p.leaderStale;
263
+ if (kind === "missing") return !!p.missing;
264
+ return true;
265
+ }
266
+
267
+ function sortCmp(kind) {
268
+ // 排序字段一律快照真实投影(lastTaskAt/name/tasksByStatus/taskCount);lastTaskAt 缺省排末尾
269
+ if (kind === "name") return (a, b) => String(a.name || "").localeCompare(String(b.name || ""), "zh");
270
+ if (kind === "failed") return (a, b) => ((stOf(b).failed || 0) - (stOf(a).failed || 0));
271
+ if (kind === "total") return (a, b) => ((b.taskCount || 0) - (a.taskCount || 0));
272
+ return (a, b) => { // active:最近活跃 ↓(默认)
273
+ const av = a.lastTaskAt ? String(a.lastTaskAt) : null;
274
+ const bv = b.lastTaskAt ? String(b.lastTaskAt) : null;
275
+ if (!av && !bv) return 0;
276
+ if (!bv) return -1;
277
+ if (!av) return 1;
278
+ return bv.localeCompare(av);
279
+ };
280
+ }
281
+
282
+ function filteredProjects(projects, q, chip, sort) {
283
+ let list = projects.slice();
284
+ const term = String(q || "").trim().toLowerCase();
285
+ if (term) list = list.filter((p) => (String(p.name || "") + "\n" + String(p.desc || "") + "\n" + String(p.path || "")).toLowerCase().indexOf(term) >= 0);
286
+ if (chip && chip !== "all") list = list.filter((p) => chipHit(chip, p));
287
+ list.sort(sortCmp(sort));
288
+ return list;
289
+ }
290
+
291
+ function ProjectListHead() {
292
+ return h("div", { "data-bf-phead": "1",
293
+ style: { display: "grid", gridTemplateColumns: ROW_GRID, gap: 12, alignItems: "center", padding: "8px 14px",
294
+ position: "sticky", top: 0, zIndex: 2, background: "rgba(128,128,128,0.06)",
295
+ borderBottom: "1px solid rgba(128,128,128,0.18)" } },
296
+ h("span", { className: "bf-meta" }, "项目"),
297
+ h("span", { className: "bf-meta" }, "任务(跑/成/败/消)"),
298
+ h("span", { className: "bf-meta" }, "分布"),
299
+ h("span", { className: "bf-meta" }, "都管(行内直改)"),
300
+ h("span", { className: "bf-meta", style: { textAlign: "right" } }, "活跃"),
301
+ h("span", { className: "bf-meta" }, "路径"));
302
+ }
303
+
304
+ function ProjectRow({ p, snap, selected, first, onPick }) {
305
+ const st = stOf(p);
306
+ const total = p.taskCount || 0;
307
+ const seg = (key) => st[key] ? h("i", { key, title: key + " " + st[key],
308
+ style: { display: "block", height: "100%", width: pct(st[key], total) + "%", background: COLORS[key] } }) : null;
309
+ const num = (n, label, color) => h("span", { style: { whiteSpace: "nowrap" } },
310
+ h("b", { style: { color, fontSize: 12.5 } }, String(n || 0)),
311
+ h("span", { className: "bf-meta", style: { fontSize: 10.5 } }, label));
312
+ const rowProps = { key: p.id, "data-bf-prow": p.id, onClick: onPick,
313
+ style: { display: "grid", gridTemplateColumns: ROW_GRID, gap: 12, alignItems: "center", padding: "8px 14px",
314
+ borderTop: first ? undefined : "1px solid rgba(128,128,128,0.10)", cursor: "pointer",
315
+ background: selected ? "rgba(79,124,240,0.10)" : undefined,
316
+ boxShadow: selected ? "inset 3px 0 0 #4f7cf0" : undefined } };
317
+ if (selected) rowProps["data-bf-prowsel"] = p.id; // 选中行高亮锚(仅选中行渲染,供测试/无障碍识别)
318
+ return h("div", rowProps,
319
+ h("div", { style: { display: "flex", alignItems: "center", gap: 6, minWidth: 0, flexWrap: "wrap" } },
320
+ h("span", null, "📁"),
321
+ h("span", { "data-bf-pname": p.id, title: p.name,
322
+ style: { fontWeight: 650, fontSize: 13, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", maxWidth: "100%" } }, p.name),
323
+ leaderBadgeOf(p),
324
+ covBadgeOf(p), // v0.43.0 阶段2A:编制覆盖徽标(旧快照无键不渲染,同 leaderBadgeOf 防御口径)
325
+ covGapLineOf(p), // 缺口环节名直显(换行小字,行点击语义不变)
326
+ p.missing ? h("span", { style: { color: "#e5484d", fontSize: 11 } }, "⚠️ 缺目录") : null),
327
+ h("div", { "data-bf-pnums": p.id, title: "任务四数:运行/完成/失败/取消", style: { display: "flex", alignItems: "baseline", gap: 5 } },
328
+ num(st.running || 0, "跑", COLORS.running), num(st.done || 0, "成", COLORS.done),
329
+ num(st.failed || 0, "败", COLORS.failed), num(st.cancelled || 0, "消", COLORS.cancelled)),
330
+ h("div", { "data-bf-pbar": p.id, style: { display: "flex", height: 6, borderRadius: 99, overflow: "hidden", background: "rgba(128,128,128,0.14)" } },
331
+ seg("done"), seg("failed"), seg("running"), seg("queued"), seg("cancelled")),
332
+ h("div", { style: { minWidth: 0 } }, h(LeaderCtl, { p, snap, mini: true })),
333
+ h("div", { style: { textAlign: "right", fontSize: 11, lineHeight: 1.5 } },
334
+ h("div", null, "最近 " + (p.lastTaskAt ? fmtTime(p.lastTaskAt) : "—")),
335
+ h("div", { className: "bf-meta" }, "共 " + total + " 条")),
336
+ h("div", { "data-bf-ppath": p.id, title: p.path,
337
+ style: { fontFamily: "var(--ds-font-family-code, monospace)", fontSize: 10.5, whiteSpace: "nowrap",
338
+ overflow: "hidden", textOverflow: "ellipsis", direction: "rtl", textAlign: "left" } }, p.path));
339
+ }
340
+
341
+ /* ---------- 详情:复用项目卡(完整都管下拉)+ 任务流卡 + 右侧三小卡 ---------- */
342
+ function ProjectDetail({ p, snap, projCount }) {
343
+ const leader = p.leader || null;
344
+ const st = p.tasksByStatus || {};
345
+ const total = p.taskCount || 0;
346
+ const allNodes = [];
347
+ for (const t of snap.trees || []) for (const n of t.nodes || []) allNodes.push({ ...n, treeId: t.id });
348
+ const nameById = {}; for (const n of allNodes) nameById[n.id] = n.name;
349
+ const treeId = leader ? leader.treeId : null;
350
+ const treeNodes = treeId ? allNodes.filter((n) => n.treeId === treeId) : [];
351
+ const flow = (snap.tasks || []).filter((k) => k.projectId === p.id).slice(0, 6);
352
+ return h("div", { "data-bf-pdetail": "1", style: { display: "grid", gridTemplateColumns: "minmax(0,1fr) 300px", gap: 10, alignItems: "start" } },
353
+ h("div", null,
354
+ h(ProjectCard, { p, tasks: snap.tasks, snap }),
355
+ h("div", { className: "bf-card", style: { marginTop: 10, padding: "10px 12px" } },
356
+ h("div", { className: "bf-meta", style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 4 } },
357
+ h("b", { style: { color: "var(--dsw-alias-label-primary, #eee)" } }, "项目任务流"),
358
+ h("span", null, "最近 6 条 · 点击任务看链路"),
359
+ h("span", { style: { flex: 1 } }),
360
+ h("span", null, "共 " + total + " 条")),
361
+ flow.length ? flow.map((k) => h("div", { key: k.id, style: { display: "flex", alignItems: "center", gap: 7, padding: "4px 0", borderTop: "1px solid rgba(128,128,128,0.10)" } },
362
+ h(TaskDot, { s: k.status }),
363
+ h("span", { className: "bf-tb-title", style: { flex: 1, minWidth: 0, fontWeight: 400 }, title: k.title }, k.title || k.id),
364
+ h("span", { className: "bf-meta", style: { width: 100, flex: "none", textAlign: "right" } }, (k.nodeId && nameById[k.nodeId]) || k.nodeId || "—"),
365
+ h("span", { className: "bf-meta", style: { width: 78, flex: "none", textAlign: "right" } }, fmtTime(k.createdAt)),
366
+ h(TaskStateWord, { s: k.status }))) : h("div", { className: "bf-meta" }, "窗口内无任务"))),
367
+ h("div", { style: { display: "flex", flexDirection: "column", gap: 8 } },
368
+ h("div", { className: "bf-card", style: { padding: "9px 11px" } },
369
+ h("div", { className: "bf-meta", style: { marginBottom: 4 } }, "项目根"),
370
+ h("div", { className: "bf-meta", style: { fontFamily: "var(--ds-font-family-code, monospace)", wordBreak: "break-all", whiteSpace: "normal", lineHeight: 1.6 } }, DATA_ROOT(snap)),
371
+ h("div", { className: "bf-meta", style: { marginTop: 3 } }, "默认工作区 " + (snap.defaultWorkspace || "—")),
372
+ h("div", { className: "bf-meta", style: { marginTop: 3 } }, "状态 " + (p.missing ? "⚠️ 目录缺失" : "目录正常 · 可派单"))),
373
+ h("div", { className: "bf-card", style: { padding: "9px 11px" } },
374
+ h("div", { className: "bf-meta", style: { marginBottom: 4 } }, "项目 × 编制"),
375
+ h("div", { className: "bf-meta" }, "项目数 " + projCount),
376
+ h("div", { className: "bf-meta" }, "绑定都管 " + (leader ? leader.name : (p.leaderStale ? "⚠️ 悬挂" : "未绑定"))),
377
+ h("div", { className: "bf-meta" }, "编制 " + (treeNodes.length ? treeNodes.length + " · " + treeNodes.filter((n) => n.status === "running").length + " 在岗" : "—")),
378
+ h("div", { className: "bf-meta", style: { marginTop: 5, lineHeight: 1.65 } }, "项目只负责目录/任务/绑定;能力面与角色提示词在概览。")),
379
+ h("div", { className: "bf-card", style: { padding: "9px 11px" } },
380
+ h("div", { className: "bf-meta", style: { marginBottom: 4 } }, "项目健康"),
381
+ h("div", { className: "bf-meta" }, "失败任务 " + (st.failed || 0)),
382
+ h("div", { className: "bf-meta" }, "最近运行 " + (p.lastTaskAt ? fmtTime(p.lastTaskAt) : "—")),
383
+ h("div", { className: "bf-meta" }, "目录缺失 " + (p.missing ? "是" : "无")))));
384
+ }
385
+
386
+ /* ---------- 项目页(v0.42.0 方案 B:工具条+列表+详情)---------- */
387
+ function ProjectsPane({ snap }) {
388
+ const projects = snap.projects || [];
389
+ const [q, setQ] = useState(""); // 搜索词(项目名/描述/路径)
390
+ const [chip, setChip] = useState("all"); // 治理过滤 chip
391
+ const [sort, setSort] = useState("active"); // 排序
392
+ const [expand, setExpand] = useState(false); // 列表展开全部(默认前 12)
393
+ const [sel, setSel] = useState(null); // 选中行(详情项目 id)
394
+ const root = snap.projectsRoot || "";
395
+ const note = snap.projectsRootDefaultNote;
396
+ const rootLabel = (note !== undefined && note !== "")
397
+ ? note.replace(/^未改配[::]/, "未改配,")
398
+ : (root || (note === "" ? "(已改配:项目根未取到,见 bufeng_config)" : "(未取到;发现失败回退 ~/.dsh/bufeng/projects)"));
399
+
400
+ if (!projects.length) {
401
+ return h("div", { className: "bf-card", style: { width: "100%", padding: "10px 12px", boxSizing: "border-box", ...DIM } },
402
+ "暂无项目 —— 项目=业务目录+说明,与智能体编制分离。让总管识别业务后代建(bufeng_project create),",
403
+ h("br"), "或在会话里直接创建;项目根:", h("span", { style: { fontFamily: "var(--ds-font-family-code, monospace)" } }, rootLabel),
404
+ ",可用 bufeng_config projectsRoot 更换。");
405
+ }
406
+
407
+ // 列表状态(搜索词/chip/排序/展开/选中行)存组件 state——SSE 全帧刷新(重渲染)不重置
408
+ const filtered = filteredProjects(projects, q, chip, sort);
409
+ const shown = expand ? filtered : filtered.slice(0, PAGE);
410
+ const selP = sel ? projects.find((p) => p.id === sel) : null;
411
+ const hasLeader = projects.some((p) => leaderKnownOf(p)); // 旧快照无都管三键:两枚都管 chip 不出(无键可算,防误报)
412
+ const chips = hasLeader ? CHIPS : CHIPS.filter(([k]) => k !== "unbound" && k !== "stale");
413
+ const nOf = (k) => projects.filter((p) => chipHit(k, p)).length;
414
+
415
+ return h("div", { style: { display: "flex", flexDirection: "column", gap: 10, width: "100%" } },
416
+ h("div", { className: "bf-meta", style: { padding: "0 2px" } },
417
+ "项目根:", h("span", { style: { fontFamily: "var(--ds-font-family-code, monospace)" }, title: "bufeng_config projectsRoot=<绝对路径> 可更换(改后新建项目落新根)" }, rootLabel),
418
+ " · 共 " + projects.length + " 个项目"),
419
+ /* ① 工具条:搜索 + 治理过滤 chips(实时计数)+ 排序 */
420
+ h("div", { className: "bf-card", "data-bf-ptoolbar": "1",
421
+ style: { display: "flex", gap: 8, alignItems: "center", flexWrap: "wrap", padding: "9px 12px", width: "100%", boxSizing: "border-box" } },
422
+ h("input", { type: "text", "data-bf-psearch": "1", placeholder: "🔍 搜项目名 / 描述 / 路径…", value: q,
423
+ title: "按项目名 / 描述 / 路径模糊过滤",
424
+ style: { flex: "1 1 200px", minWidth: 170, background: "rgba(0,0,0,0.16)", border: "1px solid " + LINE, color: "inherit",
425
+ borderRadius: 8, padding: "6px 10px", font: "inherit", boxSizing: "border-box" },
426
+ onChange: (e) => { setQ(e.target.value); setExpand(false); } }),
427
+ h("div", { style: { display: "flex", gap: 5, flexWrap: "wrap" } },
428
+ chips.map(([k, label]) => h("button", { key: k, "data-bf-pchip": k,
429
+ onClick: () => { setChip(k); setExpand(false); },
430
+ title: "过滤:" + label,
431
+ style: { appearance: "none", cursor: "pointer", font: "600 11.5px/1 sans-serif", borderRadius: 99, padding: "5px 11px",
432
+ color: chip === k ? "#bcd0ff" : "#98a6bb",
433
+ border: "1px solid " + (chip === k ? "rgba(79,124,240,0.5)" : "rgba(128,128,128,0.25)"),
434
+ background: chip === k ? "rgba(79,124,240,0.12)" : "transparent" } },
435
+ label + " " + nOf(k)))),
436
+ h("select", { className: "bf-model-sel", "data-bf-psort": "1", value: sort, "aria-label": "排序",
437
+ title: "排序:最近活跃↓(默认,最近有任务的项目置顶;无记录排末尾)/ 名称 A→Z / 失败数↓ / 总任务↓", style: { maxWidth: 130 },
438
+ onChange: (e) => setSort(e.target.value) },
439
+ SORTS.map(([k, label]) => h("option", { key: k, value: k }, label)))),
440
+ /* ② 列表:吸附表头 + 六列行 + 默认前 12 / 展开全部 */
441
+ h("div", { className: "bf-card", "data-bf-plist": "1", style: { overflow: "hidden", width: "100%", boxSizing: "border-box" } },
442
+ h(ProjectListHead),
443
+ shown.length ? shown.map((p, i) => h(ProjectRow, { p, snap, selected: sel === p.id, first: i === 0,
444
+ onPick: () => setSel(p.id) }))
445
+ : h("div", { "data-bf-pempty": "1", className: "bf-meta", style: { padding: "18px 14px", textAlign: "center" } },
446
+ "没有符合条件的项目 —— 换个搜索词或过滤 chip 试试"),
447
+ filtered.length > PAGE ? h("button", { "data-bf-pexpand": "1",
448
+ onClick: () => setExpand(!expand),
449
+ title: expand ? "收起,只显前 " + PAGE + " 个" : "展开全部过滤后项目",
450
+ style: { width: "100%", appearance: "none", border: "none", borderTop: "1px solid rgba(128,128,128,0.18)",
451
+ background: "rgba(79,124,240,0.05)", color: "#bcd0ff", font: "600 12px/1 sans-serif", padding: "10px 0", cursor: "pointer" } },
452
+ expand ? "▲ 收起,只显前 " + PAGE + " 个" : "▼ 展开全部 " + filtered.length + " 个项目(当前显示前 " + PAGE + " 个)") : null),
453
+ /* ③ 详情:复用项目卡(完整都管下拉)+ 任务流 + 右侧三小卡 */
454
+ selP ? h("div", { style: { display: "flex", flexDirection: "column", gap: 8 } },
455
+ h("div", { style: { display: "flex", alignItems: "center", gap: 8 } },
456
+ h("button", { "data-bf-pcollapse": "1", onClick: () => setSel(null),
457
+ title: "收起详情回到纯列表",
458
+ style: { appearance: "none", border: "1px solid rgba(128,128,128,0.25)", background: "transparent", color: "#98a6bb",
459
+ font: "600 12px/1 sans-serif", padding: "5px 11px", borderRadius: 7, cursor: "pointer" } },
460
+ "↑ 收起详情"),
461
+ h("span", { className: "bf-meta" }, "当前详情:", h("b", { style: { color: "var(--dsw-alias-label-primary, #eee)" } }, selP.name))),
462
+ h(ProjectDetail, { p: selP, snap, projCount: projects.length })) : null);
463
+ }
464
+
465
+ function DATA_ROOT(snap) { return (snap && snap.projectsRoot) || "—"; }
466
+
467
+ export { ProjectsPane };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * client/src/prompt.js — 任务提示词装配(task.promptManifest → 7 段只读视图)。
3
+ * 同一组件同时用于任务看板「提示词装配」子 tab 与智能体抽屉「本次任务」scope,避免两处漂移。
4
+ */
5
+ import { h } from './react.js';
6
+ import { clip, DIM } from './ui.js';
7
+
8
+ export function segLabel(s) {
9
+ return ({
10
+ head: '身份段', nodeSystemPrompt: '节点补充指令', projectNote: '项目上下文', lessonsNote: '教训',
11
+ wsNote: '工作区', taskTitle: '任务标题', taskDetail: '任务详情', acceptanceNote: '验收标准', duties: '职责约束',
12
+ })[s] || s;
13
+ }
14
+
15
+ export function promptBody(s, k, maps) {
16
+ const node = k.nodeId ? maps.nodeById[k.nodeId] : null;
17
+ const proj = k.projectId ? maps.projById[k.projectId] : null;
18
+ if (s.seg === 'nodeSystemPrompt') {
19
+ const txt = (node && node.systemPrompt) || '';
20
+ return txt ? h('pre', { className: 'bf-tp-pre' }, txt) : h('span', { className: 'bf-meta' }, '节点未设置补充指令(该段为空,不投递)');
21
+ }
22
+ if (s.seg === 'projectNote') {
23
+ return proj ? h('div', null,
24
+ h('div', { className: 'bf-tp-kv' }, h('span', null, '项目'), h('b', null, proj.name || proj.id)),
25
+ h('div', { className: 'bf-tp-kv' }, h('span', null, '目录'), h('b', { className: 'bf-mono' }, proj.path || '—')),
26
+ h('div', { className: 'bf-tp-kv' }, h('span', null, '说明'), h('b', null, clip(proj.desc || '—', 120))),
27
+ h('div', { className: 'bf-tp-note' }, '只注入本次任务,不属于智能体自身提示词'))
28
+ : h('span', { className: 'bf-meta' }, '本任务未绑定 projectId,无项目段');
29
+ }
30
+ if (s.seg === 'taskTitle') return h('div', null, k.title || k.id);
31
+ if (s.seg === 'taskDetail') return k.detail
32
+ ? h('pre', { className: 'bf-tp-pre' }, k.detail)
33
+ : h('div', { className: 'bf-tp-note' }, '任务正文未在 /api/tasks 返回;投递内容指纹 sha ' + (s.sha || '—'));
34
+ if (s.seg === 'acceptanceNote') return h('pre', { className: 'bf-tp-pre' }, k.acceptance || '(无验收标准)');
35
+ if (s.seg === 'duties') return h('div', { className: 'bf-tp-note' }, '职责模板在 lib/domain.js,按 kind 生成;随插件发版。sha ' + (s.sha || '—'));
36
+ if (s.seg === 'head') return h('div', null,
37
+ h('div', { className: 'bf-tp-kv' }, h('span', null, '节点'), h('b', null, (node && node.name) || k.nodeId || '—')),
38
+ h('div', { className: 'bf-tp-kv' }, h('span', null, 'kind'), h('b', null, (node && (node.kindLabel || node.kind)) || '—')),
39
+ h('div', { className: 'bf-tp-note' }, '身份段由 name/role/kind/tree 生成,不单独存正文'));
40
+ return h('span', { className: 'bf-meta' }, '来源:' + (s.source || '—'));
41
+ }
42
+
43
+ export function PromptAssembly({ k, maps }) {
44
+ const segs = Array.isArray(k.promptManifest) ? k.promptManifest : [];
45
+ if (!segs.length) return h('div', { className: 'bf-card', style: { ...DIM, padding: '8px 12px' } }, '无 promptManifest 快照(旧任务/旧宿主),无法还原装配顺序。');
46
+ return h('div', { 'data-bf-promptasm': '1', className: 'bf-tp' },
47
+ h('div', { className: 'bf-tp-head' }, h('b', null, '本次任务提示词装配'), h('span', { style: DIM }, segs.length + ' 段 · 投递时快照 · 只读')),
48
+ segs.map((s, i) => h('div', { key: (s.seg || 'seg') + ':' + i, className: 'bf-tp-seg', 'data-bf-promptseg': s.seg || '' },
49
+ h('div', { className: 'bf-tp-idx' }, String(i + 1)),
50
+ h('div', { className: 'bf-tp-body' },
51
+ h('div', { className: 'bf-tp-segtitle' },
52
+ h('b', null, segLabel(s.seg)), h('span', { className: 'bf-tp-layer' }, s.layer || ''),
53
+ h('span', { style: { flex: 1 } }), h('code', null, s.sha || '—')),
54
+ promptBody(s, k, maps)))));
55
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * client/src/react.js — 宿主 react 桥。
3
+ * bundle 内唯一 require("react") 的模块;其余模块一律 import { h, ... } from './react.js'。
4
+ */
5
+ const { createElement: h, useState, useEffect, useRef, useMemo, useCallback } = require("react");
6
+
7
+ export { h, useState, useEffect, useRef, useMemo, useCallback };