taskboard-workbench 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +132 -0
- package/LICENSE +21 -0
- package/README.md +121 -2
- package/cli/tb.mjs +314 -0
- package/cordis.patch.yml +5 -0
- package/index.js +633 -0
- package/lib/client.js +522 -0
- package/package.json +83 -4
- package/spec//345/233/242/351/230/237agent.md +171 -0
- package/src/core/advance.mjs +192 -0
- package/src/core/agent-teams.mjs +48 -0
- package/src/core/binding.mjs +44 -0
- package/src/core/config.mjs +22 -0
- package/src/core/debug-dispatch.mjs +94 -0
- package/src/core/delivery.mjs +93 -0
- package/src/core/deps.mjs +53 -0
- package/src/core/diagnostics.mjs +648 -0
- package/src/core/domain.mjs +235 -0
- package/src/core/empty-state.mjs +240 -0
- package/src/core/errors.mjs +139 -0
- package/src/core/executor.mjs +645 -0
- package/src/core/human-review.mjs +773 -0
- package/src/core/intake.mjs +116 -0
- package/src/core/kickoff.mjs +147 -0
- package/src/core/loop.mjs +498 -0
- package/src/core/memory.mjs +193 -0
- package/src/core/next-step.mjs +377 -0
- package/src/core/notify.mjs +183 -0
- package/src/core/owner.mjs +41 -0
- package/src/core/requirements.mjs +262 -0
- package/src/core/review.mjs +82 -0
- package/src/core/session-naming.mjs +64 -0
- package/src/core/split-ask.mjs +107 -0
- package/src/core/store.mjs +3103 -0
- package/src/core/team.mjs +170 -0
- package/src/core/verify.mjs +170 -0
- package/src/core/watchdog.mjs +144 -0
- package/src/host/ai-elaborator.mjs +26 -0
- package/src/host/team-engine.mjs +125 -0
- package/src/host/tool-surface.mjs +205 -0
- package/src/server/api.mjs +1974 -0
- package/src/server/events.mjs +32 -0
- package/src/server/kickoff.mjs +46 -0
- package/src/server/server.mjs +211 -0
- package/src/server/verify.mjs +112 -0
- package/tools/env-check.mjs +35 -0
- package/tools/seed.mjs +67 -0
- package/web/app.js +5237 -0
- package/web/index.html +15 -0
- package/web/tokens.css +1139 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* notify.mjs —— 通知订阅与唤醒(FR-81)的**纯函数**部分。
|
|
3
|
+
*
|
|
4
|
+
* 职责边界:只做"哪些事件算终态 / 该推哪些 / 推什么文本 / 汇总结果",**不碰 db、不碰宿主会话通道**
|
|
5
|
+
* (落库在 `store.mjs`,投递通道由调用方注入)。这样"什么算终态"这条口径可以被单测穷举。
|
|
6
|
+
*
|
|
7
|
+
* 三模式语义(本项目口径,见需求 FR-81 与轮次记录):
|
|
8
|
+
* - `notify` :只通知——在任务里**留一条评论**(工作台可见),不打扰任何会话;
|
|
9
|
+
* - `notify+wake` :通知并唤醒——留评论 + 把摘要**投递到目标会话**;
|
|
10
|
+
* - `wake` :只唤醒——只投一条**极简**唤醒信号,不留评论。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const NOTIFY_DELIVERY_MODES = Object.freeze(["notify", "notify+wake", "wake"]);
|
|
14
|
+
|
|
15
|
+
/** 本次尝试"成功收场"(产出待验收)的口径 —— 见 `store.endTaskRun` 的调用点。 */
|
|
16
|
+
export const COMPLETED_RUN_OUTCOMES = Object.freeze(["success"]);
|
|
17
|
+
/** 本次尝试"以失败/受阻收场"的口径(含崩溃与超时)。 */
|
|
18
|
+
export const BLOCKED_RUN_OUTCOMES = Object.freeze(["blocked", "failed", "crash", "timeout"]);
|
|
19
|
+
/** 这些收场**不推送**:回收/人工退回/人工释放/无结论 —— 任务还会被重新派发,不是终态。 */
|
|
20
|
+
export const IGNORED_RUN_OUTCOMES = Object.freeze(["reclaimed", "cancelled", "released", "ended"]);
|
|
21
|
+
|
|
22
|
+
export const NOTIFY_KIND_LABELS = Object.freeze({
|
|
23
|
+
completed: "完成(产出待验收)",
|
|
24
|
+
blocked: "受阻",
|
|
25
|
+
auto_blocked: "自动阻断(同因复发 → 人工兜底)",
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 归一化交付模式。非法值**不抛错**(返回 `valid:false` + `reason`),由调用方决定转成哪种错误。
|
|
30
|
+
* `wake` = 是否要投递会话;`comment` = 是否要在任务里留痕。
|
|
31
|
+
*/
|
|
32
|
+
export function normalizeDeliveryMode(mode) {
|
|
33
|
+
const m = String(mode ?? "").trim();
|
|
34
|
+
const valid = NOTIFY_DELIVERY_MODES.includes(m);
|
|
35
|
+
return {
|
|
36
|
+
mode: valid ? m : null,
|
|
37
|
+
valid,
|
|
38
|
+
reason: valid ? null : `未知交付模式:${mode ?? "(空)"}(可选 ${NOTIFY_DELIVERY_MODES.join(" / ")})`,
|
|
39
|
+
wake: valid && m.includes("wake"),
|
|
40
|
+
comment: valid && m !== "wake",
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 单条事件是否属于"要推送的终态",以及属于哪一类。
|
|
46
|
+
* 判定表(与轮次记录一致,改动必须同步文档):
|
|
47
|
+
* - `run_ended` `success` → completed;`blocked|failed|crash|timeout` → blocked;`reclaimed|cancelled|released|ended` → 不推
|
|
48
|
+
* - `blocked` `to=blocked` 且 detail 含"人工兜底" → auto_blocked;`to=blocked` → blocked;`to=todo`(依赖未就绪)→ 不推
|
|
49
|
+
* - `status_changed` `to=done` → completed;`to=blocked` → blocked;其余(含 in_review)**不单独判终态**
|
|
50
|
+
* - 其它类型(评论/心跳/失败记账/评审…)→ 不推
|
|
51
|
+
*/
|
|
52
|
+
export function isTerminalNotifyEvent(event) {
|
|
53
|
+
const type = String(event?.type ?? "");
|
|
54
|
+
const to = event?.to == null ? null : String(event.to);
|
|
55
|
+
const detail = String(event?.detail ?? "");
|
|
56
|
+
if (type === "run_ended") {
|
|
57
|
+
if (COMPLETED_RUN_OUTCOMES.includes(to)) {
|
|
58
|
+
return { notifiable: true, kind: "completed", terminal: true, reason: "本次执行成功(产出待验收)" };
|
|
59
|
+
}
|
|
60
|
+
if (BLOCKED_RUN_OUTCOMES.includes(to)) {
|
|
61
|
+
return { notifiable: true, kind: "blocked", terminal: true, reason: `本次执行以「${to}」收场` };
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
notifiable: false, kind: null, terminal: false,
|
|
65
|
+
reason: IGNORED_RUN_OUTCOMES.includes(to) ? `非终态收场(${to}),等重新派发` : `未知收场:${to ?? "(空)"}`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (type === "blocked") {
|
|
69
|
+
if (to !== "blocked") {
|
|
70
|
+
return { notifiable: false, kind: null, terminal: false, reason: "依赖未就绪 → 回「可开工」,不算终态阻断" };
|
|
71
|
+
}
|
|
72
|
+
// 复发升级到人工兜底(`store.blockTask` 的 detail 带"人工兜底"字样)——与人工阻断分开报,好让人一眼看出"这是循环"。
|
|
73
|
+
const triaged = /人工兜底/.test(detail);
|
|
74
|
+
return {
|
|
75
|
+
notifiable: true, kind: triaged ? "auto_blocked" : "blocked", terminal: true,
|
|
76
|
+
reason: triaged ? "同因重复阻断已升级「人工兜底」" : "已置受阻",
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (type === "status_changed") {
|
|
80
|
+
if (to === "done") return { notifiable: true, kind: "completed", terminal: true, reason: "人工确认完成" };
|
|
81
|
+
if (to === "blocked") return { notifiable: true, kind: "blocked", terminal: true, reason: "人工置受阻" };
|
|
82
|
+
return { notifiable: false, kind: null, terminal: false, reason: `状态变化不是终态:${to ?? "(空)"}` };
|
|
83
|
+
}
|
|
84
|
+
return { notifiable: false, kind: null, terminal: false, reason: `该事件类型不参与通知:${type || "(空)"}` };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 从(按 cursor 升序的)事件流里挑出**待推送**的事件:
|
|
89
|
+
* - 非终态直接跳过;
|
|
90
|
+
* - **同一任务只留首条终态**(`run_ended success` 与随后的 `status_changed` 不会重复推一个人);
|
|
91
|
+
* - 游标推进到"见到的最大 cursor"(包含被跳过的事件——它们已经消费过,不必再扫)。
|
|
92
|
+
* 返回的每条事件额外带 `kind`,供消息构造与汇总直接使用。
|
|
93
|
+
*/
|
|
94
|
+
export function selectNotifyEvents(events, { since = 0 } = {}) {
|
|
95
|
+
const list = Array.isArray(events) ? events : [];
|
|
96
|
+
const threshold = Math.max(0, Number(since) || 0);
|
|
97
|
+
const seen = new Set();
|
|
98
|
+
const picked = [];
|
|
99
|
+
let cursor = threshold;
|
|
100
|
+
let scanned = 0;
|
|
101
|
+
let skipped = 0;
|
|
102
|
+
let deduped = 0;
|
|
103
|
+
for (const event of list) {
|
|
104
|
+
const c = Number(event?.cursor ?? 0);
|
|
105
|
+
if (Number.isFinite(c) && c > cursor) cursor = c;
|
|
106
|
+
scanned += 1;
|
|
107
|
+
// 已经在 `since` 之前推送过的事件不再推(幂等:调用方即使多查了一段也不会重复推)
|
|
108
|
+
if (!Number.isFinite(c) || c <= threshold) { skipped += 1; continue; }
|
|
109
|
+
const verdict = isTerminalNotifyEvent(event);
|
|
110
|
+
if (!verdict.notifiable) { skipped += 1; continue; }
|
|
111
|
+
const key = String(event?.taskId ?? event?.identifier ?? "");
|
|
112
|
+
if (seen.has(key)) { deduped += 1; continue; }
|
|
113
|
+
seen.add(key);
|
|
114
|
+
picked.push({ ...event, kind: verdict.kind, notifyKind: verdict.kind });
|
|
115
|
+
}
|
|
116
|
+
return { events: picked, cursor, scanned, skipped, deduped };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 构造消息体。`events` 应为 `selectNotifyEvents` 的产出(已按任务去重)。
|
|
121
|
+
* `taskOf(taskId)` 由调用方注入(查任务拿编号/标题)。
|
|
122
|
+
* 返回:`prompt`(要投递到会话的文本;`notify` 模式为 null)、`commentBody`(要在任务里留痕的文本;`wake` 模式为 null)。
|
|
123
|
+
*/
|
|
124
|
+
export function buildNotifyMessage({ project = null, events = [], mode = "notify+wake", taskOf = null } = {}) {
|
|
125
|
+
const norm = normalizeDeliveryMode(mode);
|
|
126
|
+
if (!norm.valid) throw new Error(norm.reason);
|
|
127
|
+
const list = Array.isArray(events) ? events : [];
|
|
128
|
+
const lookup = typeof taskOf === "function" ? taskOf : () => null;
|
|
129
|
+
const byTask = new Map();
|
|
130
|
+
const taskIds = [];
|
|
131
|
+
for (const event of list) {
|
|
132
|
+
const tid = String(event?.taskId ?? "");
|
|
133
|
+
if (!byTask.has(tid)) {
|
|
134
|
+
const task = tid ? lookup(tid) : null;
|
|
135
|
+
const identifier = task?.identifier ?? String(event?.identifier ?? tid ?? "(未知任务)");
|
|
136
|
+
byTask.set(tid, { task, identifier, title: task?.title ?? null, kinds: new Set() });
|
|
137
|
+
if (tid) taskIds.push(tid);
|
|
138
|
+
}
|
|
139
|
+
byTask.get(tid).kinds.add(String(event?.kind ?? "blocked"));
|
|
140
|
+
}
|
|
141
|
+
const entries = [...byTask.values()];
|
|
142
|
+
const kinds = [...new Set(entries.flatMap((e) => [...e.kinds]))];
|
|
143
|
+
if (!entries.length) return { prompt: null, commentBody: null, taskIds, mode: norm.mode, kinds: [] };
|
|
144
|
+
const projectLabel = project?.name ? `${project.name}(${project.id})` : String(project?.id ?? "(项目)");
|
|
145
|
+
const labelOf = (kind) => NOTIFY_KIND_LABELS[kind] ?? String(kind);
|
|
146
|
+
if (norm.mode === "wake") {
|
|
147
|
+
const head = entries.length === 1 ? `任务 ${entries[0].identifier} 已到终态` : `${entries.length} 个任务已到终态`;
|
|
148
|
+
return {
|
|
149
|
+
prompt: `【唤醒】任务工作台:${projectLabel} ${head}(${kinds.map(labelOf).join("/")})。请查看任务详情并处理;本条只做唤醒,无需回执。`,
|
|
150
|
+
commentBody: null, taskIds, mode: norm.mode, kinds,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const lines = [`【任务工作台 · 通知】${projectLabel} 有 ${entries.length} 个任务到了终态:`];
|
|
154
|
+
for (const entry of entries) {
|
|
155
|
+
lines.push(`· ${entry.identifier}${entry.title ? ` ${entry.title}` : ""} — ${[...entry.kinds].map(labelOf).join("/")}`);
|
|
156
|
+
}
|
|
157
|
+
lines.push("下一步:完成 → 请人工验收(执行侧不得置 done);受阻/自动阻断 → 按任务详情的诊断建议恢复,或人工解除。");
|
|
158
|
+
const prompt = norm.wake ? lines.join("\n") : null;
|
|
159
|
+
const commentBody = `【FR-81 通知】${entries.length} 个任务到终态:${entries.map((e) => `${e.identifier}(${[...e.kinds].map(labelOf).join("/")})`).join("、")}${norm.wake ? ";已同时唤醒目标会话。" : "(仅通知,未投递会话)。"}`;
|
|
160
|
+
return { prompt, commentBody, taskIds, mode: norm.mode, kinds };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** 一轮 flush 的汇总(API/UI 与轮次记录共用同一口径)。 */
|
|
164
|
+
export function summarizeNotifyDelivery(results = []) {
|
|
165
|
+
const list = Array.isArray(results) ? results : [];
|
|
166
|
+
const summary = { total: 0, delivered: 0, failed: 0, pending: 0, commented: 0, noop: 0, byMode: {} };
|
|
167
|
+
for (const r of list) {
|
|
168
|
+
summary.total += 1;
|
|
169
|
+
const mode = String(r?.mode ?? "unknown");
|
|
170
|
+
summary.byMode[mode] = (summary.byMode[mode] ?? 0) + 1;
|
|
171
|
+
const count = Number(r?.count ?? 0);
|
|
172
|
+
if (r?.delivered) {
|
|
173
|
+
summary.delivered += 1;
|
|
174
|
+
summary.commented += Number(r?.commented ?? 0);
|
|
175
|
+
} else if (r?.error) {
|
|
176
|
+
summary.failed += 1;
|
|
177
|
+
summary.pending += count; // 失败:事件仍在队列里,下轮自动重试
|
|
178
|
+
} else {
|
|
179
|
+
summary.noop += 1; // 无待推送(游标后没有终态事件)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return summary;
|
|
183
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* owner.mjs —— 负责人(owner)的一等字段辅助:规范化 + 历史标签约定的迁移解析。
|
|
3
|
+
*
|
|
4
|
+
* 背景:t21 用 `owner:<role>` 标签承载负责人;t24 起 owner 是 tasks 表的正式列,
|
|
5
|
+
* 本模块只保留「读取历史标签」的能力用于一次性迁移,新数据一律写 owner 列。
|
|
6
|
+
*/
|
|
7
|
+
import { TbError } from "./errors.mjs";
|
|
8
|
+
|
|
9
|
+
/** 历史标签前缀(仅迁移期使用) */
|
|
10
|
+
export const OWNER_LABEL_PREFIX = "owner:";
|
|
11
|
+
export const OWNER_MAX_LENGTH = 40;
|
|
12
|
+
|
|
13
|
+
/** 规范化 owner:trim、压缩内部空白、空串 → null;超长报错。 */
|
|
14
|
+
export function normalizeOwner(value) {
|
|
15
|
+
if (value === undefined || value === null) return null;
|
|
16
|
+
const owner = String(value).trim().replace(/\s+/g, " ");
|
|
17
|
+
if (owner === "") return null;
|
|
18
|
+
if (owner.length > OWNER_MAX_LENGTH) {
|
|
19
|
+
throw new TbError("INVALID_FIELD", `owner 过长(上限 ${OWNER_MAX_LENGTH}):${owner}`);
|
|
20
|
+
}
|
|
21
|
+
return owner;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 从 labels 中拆出历史 owner 标签。
|
|
26
|
+
* @returns {{ owner: string, labels: string[] }} owner 为空串表示没有历史标签;labels 已剔除 owner 标签。
|
|
27
|
+
*/
|
|
28
|
+
export function splitOwnerLabels(input) {
|
|
29
|
+
const labels = Array.isArray(input) ? input : [];
|
|
30
|
+
const kept = [];
|
|
31
|
+
let owner = "";
|
|
32
|
+
for (const item of labels) {
|
|
33
|
+
if (typeof item === "string" && item.startsWith(OWNER_LABEL_PREFIX)) {
|
|
34
|
+
const value = item.slice(OWNER_LABEL_PREFIX.length).trim();
|
|
35
|
+
if (value) owner = value;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
kept.push(item);
|
|
39
|
+
}
|
|
40
|
+
return { owner, labels: kept };
|
|
41
|
+
}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* requirements.mjs —— 需求域纯函数层(FR-34/35/36/37)。
|
|
3
|
+
* 不触碰文件系统与数据库,可单独测试。核心层不依赖 DSH。
|
|
4
|
+
*
|
|
5
|
+
* 注意(MVP 边界):本模块的"条目化"用**规则解析**(从需求文档抽取候选),
|
|
6
|
+
* 不使用任何会话/智能体(MVP 红线:不碰执行侧)。AI 版条目化属切片2。
|
|
7
|
+
*/
|
|
8
|
+
import { normalizeLabels } from "./domain.mjs";
|
|
9
|
+
import { invalidField, TbError } from "./errors.mjs";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 需求条目状态:draft=待确认(资料引入)/ open=已确认(在办)/ done=已完成(关联任务已收口,人工确认)/
|
|
13
|
+
* closed=已关闭(不再做:作废、并入他条、明确不做)。
|
|
14
|
+
*
|
|
15
|
+
* FR-91(2026-10-22 真机反馈):「新增需求是否完成&关闭等状态更新」—— 此前只有 draft/open/closed,
|
|
16
|
+
* 「这条需求做完了没有」没有落点,需求层与任务层对不上账。新增 `done`,并明确 `done`/`closed` 都是
|
|
17
|
+
* **终态**(`REQUIREMENT_DONE_STATUSES`),终态由**人**确认(自动只给建议,见 `summarizeRequirementCompletion`)。
|
|
18
|
+
*/
|
|
19
|
+
export const REQUIREMENT_STATUSES = Object.freeze(["draft", "open", "done", "closed"]);
|
|
20
|
+
/** 需求终态:已完成 / 已关闭(都不再产生新任务;`done` 需关联任务先收口)。 */
|
|
21
|
+
export const REQUIREMENT_DONE_STATUSES = Object.freeze(["done", "closed"]);
|
|
22
|
+
/** 需求条目来源:手工 / 规则解析(fallback)/ AI 拆解(首选)/ 资料引入。 */
|
|
23
|
+
export const REQUIREMENT_SOURCES = Object.freeze(["manual", "elaborated-rule", "elaborated-ai", "intake"]);
|
|
24
|
+
/** 可行性结论取值(追加字段)。 */
|
|
25
|
+
export const FEASIBILITY_VERDICTS = Object.freeze(["feasible", "infeasible"]);
|
|
26
|
+
|
|
27
|
+
export function isRequirementStatus(v) {
|
|
28
|
+
return REQUIREMENT_STATUSES.includes(v);
|
|
29
|
+
}
|
|
30
|
+
export function assertRequirementStatus(v, field = "status") {
|
|
31
|
+
if (!isRequirementStatus(v)) {
|
|
32
|
+
throw invalidField(field, `${field} 必须是 ${REQUIREMENT_STATUSES.join(" / ")} 之一,收到:${JSON.stringify(v)}`);
|
|
33
|
+
}
|
|
34
|
+
return v;
|
|
35
|
+
}
|
|
36
|
+
export function assertRequirementSource(v, field = "source") {
|
|
37
|
+
if (!REQUIREMENT_SOURCES.includes(v)) {
|
|
38
|
+
throw invalidField(field, `${field} 必须是 ${REQUIREMENT_SOURCES.join(" / ")} 之一,收到:${JSON.stringify(v)}`);
|
|
39
|
+
}
|
|
40
|
+
return v;
|
|
41
|
+
}
|
|
42
|
+
export function assertFeasibilityVerdict(v, field = "verdict") {
|
|
43
|
+
if (!FEASIBILITY_VERDICTS.includes(v)) {
|
|
44
|
+
throw invalidField(field, `${field} 必须是 ${FEASIBILITY_VERDICTS.join(" / ")} 之一,收到:${JSON.stringify(v)}`);
|
|
45
|
+
}
|
|
46
|
+
return v;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** 需求条目可读编号:`<项目id>-R<序号>`(与任务 `<项目id>-<序号>` 区分)。 */
|
|
50
|
+
export function formatRequirementIdentifier(projectId, sequence) {
|
|
51
|
+
if (!Number.isInteger(sequence) || sequence < 1) {
|
|
52
|
+
throw invalidField("sequence", `序号必须是 ≥1 的整数,收到:${JSON.stringify(sequence)}`);
|
|
53
|
+
}
|
|
54
|
+
return `${projectId}-R${sequence}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** 解析 `p-R12` → { prefix: "p", sequence: 12 };不匹配返回 null。 */
|
|
58
|
+
export function parseRequirementIdentifier(value) {
|
|
59
|
+
const m = /^([a-z][a-z0-9-]*)-R(\d+)$/.exec(String(value ?? ""));
|
|
60
|
+
if (!m) return null;
|
|
61
|
+
const sequence = Number(m[2]);
|
|
62
|
+
if (!Number.isSafeInteger(sequence) || sequence < 1) return null;
|
|
63
|
+
return { prefix: m[1], sequence };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** 标题归一化(去首尾空白、压缩内部空白)。 */
|
|
67
|
+
export function normalizeTitle(value) {
|
|
68
|
+
return String(value ?? "").trim().replace(/\s+/g, " ");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** 去重键:标题小写 + 去 markdown 强调符。 */
|
|
72
|
+
export function titleKey(value) {
|
|
73
|
+
return normalizeTitle(value)
|
|
74
|
+
.toLowerCase()
|
|
75
|
+
.replace(/[*_`#]/g, "")
|
|
76
|
+
.trim();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** 抽取需求文档正文里的候选条目(规则解析,非 AI)。 */
|
|
80
|
+
export function elaborateDocument(body) {
|
|
81
|
+
if (typeof body !== "string") throw invalidField("body", "需求文档正文必须是字符串");
|
|
82
|
+
const candidates = [];
|
|
83
|
+
const seen = new Set();
|
|
84
|
+
const push = (rawTitle, priority = "none") => {
|
|
85
|
+
const title = normalizeTitle(rawTitle).replace(/[*_`]/g, "").replace(/[::]\s*$/, "").trim();
|
|
86
|
+
if (title === "") return;
|
|
87
|
+
const key = titleKey(title);
|
|
88
|
+
if (key === "" || seen.has(key)) return;
|
|
89
|
+
seen.add(key);
|
|
90
|
+
candidates.push({ title, description: "", acceptance: "", priority });
|
|
91
|
+
};
|
|
92
|
+
for (const line of body.split(/\r?\n/)) {
|
|
93
|
+
let m;
|
|
94
|
+
if ((m = /^(#{1,6})\s+(.+?)\s*$/.exec(line))) { push(m[2]); continue; }
|
|
95
|
+
if ((m = /^\s*(?:[-*+]|\d+[.)])\s+(.+?)\s*$/.exec(line))) { push(m[1]); continue; }
|
|
96
|
+
}
|
|
97
|
+
return candidates;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** 校验分拆产出的任务数组(FR-38)。 */
|
|
101
|
+
/** 分拆任务的 kind 取值(2026-10-28 补:此前**收到就丢**,界面承诺了却落不了库)。 */
|
|
102
|
+
export const SPLIT_KINDS = Object.freeze(["work", "review"]);
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* kind 归一:空 → null;已知值 → 原值;**未知值直接报错**。
|
|
106
|
+
*
|
|
107
|
+
* 为什么"未知值报错"而不是静默丢成 null:2026-10-28 真机排查发现旧实现把 `kind` 整个丢弃
|
|
108
|
+
* (`assertSplitTasks` 只保留 6 个字段),用户在界面填 `review` **看起来生效、实际什么都没有** ——
|
|
109
|
+
* 这正是"界面承诺 ≠ 实现"的典型。宁可当场报错,也不许再出现"填了等于没填"。
|
|
110
|
+
*/
|
|
111
|
+
export function normalizeSplitKind(value) {
|
|
112
|
+
const text = String(value ?? "").trim().toLowerCase();
|
|
113
|
+
if (text === "") return null;
|
|
114
|
+
if (!SPLIT_KINDS.includes(text)) throw invalidField("tasks[].kind", `kind 只能是 ${SPLIT_KINDS.join(" / ")},收到:${value}`);
|
|
115
|
+
return text;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function assertSplitTasks(tasks) {
|
|
119
|
+
if (!Array.isArray(tasks)) throw invalidField("tasks", "分拆产出必须是任务数组");
|
|
120
|
+
const out = [];
|
|
121
|
+
for (const t of tasks) {
|
|
122
|
+
if (!t || typeof t !== "object") throw invalidField("tasks", "任务项必须是对象");
|
|
123
|
+
const title = normalizeTitle(t.title);
|
|
124
|
+
if (title === "") throw invalidField("tasks[].title", "任务标题不能为空");
|
|
125
|
+
const dependsOn = Array.isArray(t.dependsOn) ? t.dependsOn.slice() : [];
|
|
126
|
+
out.push({
|
|
127
|
+
title,
|
|
128
|
+
description: t.description === undefined || t.description === null ? "" : String(t.description),
|
|
129
|
+
owner: t.owner === undefined || t.owner === null ? null : String(t.owner),
|
|
130
|
+
// 2026-10-28:kind 必须**穿过**校验层(旧实现丢字段 ⇒ 界面填了等于没填)
|
|
131
|
+
kind: normalizeSplitKind(t.kind),
|
|
132
|
+
priority: t.priority ?? "none",
|
|
133
|
+
labels: normalizeLabels(t.labels ?? []),
|
|
134
|
+
dependsOn,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ------------------------------------------------------------------ AI 条目化(FR-36,首选路径;规则解析为 fallback)
|
|
141
|
+
|
|
142
|
+
/** 构造 AI 条目化的系统提示(要求严格 JSON 输出)。 */
|
|
143
|
+
export function buildElaborationSystem() {
|
|
144
|
+
return [
|
|
145
|
+
"你是需求分析助手。把给定的需求文档拆解成需求条目。",
|
|
146
|
+
'只输出一个 JSON 数组,每个元素形如 {"title":string,"description":string,"acceptance":string,"priority":"none|low|medium|high|urgent"}。',
|
|
147
|
+
"不要输出 JSON 以外的任何文字、不要用代码块包裹。标题必填;无法确定时 acceptance/description 用空串。",
|
|
148
|
+
].join("\n");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** 构造 AI 条目化的消息(含文档正文)。 */
|
|
152
|
+
export function buildElaborationMessages(body) {
|
|
153
|
+
return {
|
|
154
|
+
system: buildElaborationSystem(),
|
|
155
|
+
messages: [{ role: "user", content: `需求文档正文:\n\n${String(body ?? "")}` }],
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 解析 AI 产出为候选条目;格式非法即抛错(AI 产出格式非法 → 走降级/失败处理)。
|
|
161
|
+
* 容忍代码块包裹与首尾噪声。
|
|
162
|
+
*/
|
|
163
|
+
export function parseElaborationOutput(text) {
|
|
164
|
+
if (typeof text !== "string" || text.trim() === "") {
|
|
165
|
+
throw new TbError("AI_OUTPUT_INVALID", "AI 产出为空或无法解析");
|
|
166
|
+
}
|
|
167
|
+
let raw = text.trim();
|
|
168
|
+
const fence = /^```(?:json)?\s*([\s\S]*?)```$/m.exec(raw);
|
|
169
|
+
if (fence) raw = fence[1].trim();
|
|
170
|
+
const start = raw.indexOf("[");
|
|
171
|
+
const end = raw.lastIndexOf("]");
|
|
172
|
+
if (start === -1 || end === -1 || end < start) throw new TbError("AI_OUTPUT_INVALID", "AI 产出不是 JSON 数组");
|
|
173
|
+
let parsed;
|
|
174
|
+
try {
|
|
175
|
+
parsed = JSON.parse(raw.slice(start, end + 1));
|
|
176
|
+
} catch (error) {
|
|
177
|
+
throw new TbError("AI_OUTPUT_INVALID", `AI 产出 JSON 解析失败:${error.message}`);
|
|
178
|
+
}
|
|
179
|
+
if (!Array.isArray(parsed)) throw new TbError("AI_OUTPUT_INVALID", "AI 产出不是数组");
|
|
180
|
+
const out = [];
|
|
181
|
+
for (const c of parsed) {
|
|
182
|
+
if (!c || typeof c !== "object") continue;
|
|
183
|
+
const title = normalizeTitle(c.title);
|
|
184
|
+
if (title === "") continue;
|
|
185
|
+
const priority = ["none", "low", "medium", "high", "urgent"].includes(c.priority) ? c.priority : "none";
|
|
186
|
+
out.push({
|
|
187
|
+
title,
|
|
188
|
+
description: c.description == null ? "" : String(c.description),
|
|
189
|
+
acceptance: c.acceptance == null ? "" : String(c.acceptance),
|
|
190
|
+
priority,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (out.length === 0) throw new TbError("AI_OUTPUT_INVALID", "AI 产出未包含任何有效条目");
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** 归一化外部(AI/规则)给出的候选条目列表。 */
|
|
198
|
+
export function normalizeCandidates(input) {
|
|
199
|
+
if (!Array.isArray(input)) throw invalidField("candidates", "候选条目必须是数组");
|
|
200
|
+
const out = [];
|
|
201
|
+
const seen = new Set();
|
|
202
|
+
for (const c of input) {
|
|
203
|
+
if (!c || typeof c !== "object") continue;
|
|
204
|
+
const title = normalizeTitle(c.title);
|
|
205
|
+
if (title === "") continue;
|
|
206
|
+
const key = titleKey(title);
|
|
207
|
+
if (key === "" || seen.has(key)) continue;
|
|
208
|
+
seen.add(key);
|
|
209
|
+
out.push({
|
|
210
|
+
title,
|
|
211
|
+
description: c.description == null ? "" : String(c.description),
|
|
212
|
+
acceptance: c.acceptance == null ? "" : String(c.acceptance),
|
|
213
|
+
priority: c.priority ?? "none",
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return out;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* 需求完成度(FR-91,纯函数):把**关联任务**的状态汇总成一句可核验的结论,供「自动/人工评审需求是否完成」。
|
|
221
|
+
*
|
|
222
|
+
* 需求详情里必须能看到「这条需求关联的任务做完了没有」,否则需求层与任务层对不上账,人只能凭印象点完成。
|
|
223
|
+
* 本函数只做口径汇总、**不查库不改状态**;给出的是**建议**(`ready`),终态仍由人确认。
|
|
224
|
+
*
|
|
225
|
+
* 判据(优先级从高到低):
|
|
226
|
+
* - 无关联任务 → `no-tasks`(先「生成任务」,不然无从评审);
|
|
227
|
+
* - 关联任务全部收口(done/canceled)→ `all-closed`,`ready=true`;
|
|
228
|
+
* - 有受阻任务 → `blocked`;有待验收任务 → `in-review`;其余 → `in-progress`(都 `ready=false`)。
|
|
229
|
+
*/
|
|
230
|
+
export function summarizeRequirementCompletion(tasks = []) {
|
|
231
|
+
const list = (Array.isArray(tasks) ? tasks : []).map((t) => ({
|
|
232
|
+
identifier: t?.identifier ?? null,
|
|
233
|
+
title: t?.title ?? "",
|
|
234
|
+
status: t?.status ?? null,
|
|
235
|
+
reviewState: t?.reviewState ?? null,
|
|
236
|
+
}));
|
|
237
|
+
const counts = { backlog: 0, todo: 0, in_progress: 0, in_review: 0, blocked: 0, done: 0, canceled: 0 };
|
|
238
|
+
for (const t of list) if (t.status in counts) counts[t.status] += 1;
|
|
239
|
+
const total = list.length;
|
|
240
|
+
const closed = counts.done + counts.canceled;
|
|
241
|
+
const active = total - closed;
|
|
242
|
+
|
|
243
|
+
let verdict; let text; let ready = false;
|
|
244
|
+
if (total === 0) {
|
|
245
|
+
verdict = "no-tasks";
|
|
246
|
+
text = "尚无关联任务:请先「生成任务」再评审本条需求是否完成。";
|
|
247
|
+
} else if (active === 0) {
|
|
248
|
+
verdict = "all-closed";
|
|
249
|
+
ready = true;
|
|
250
|
+
text = `关联任务 ${total} 个已全部收口(完成 ${counts.done}${counts.canceled ? ` · 已取消 ${counts.canceled}` : ""}):可判定本条需求完成。`;
|
|
251
|
+
} else if (counts.blocked > 0) {
|
|
252
|
+
verdict = "blocked";
|
|
253
|
+
text = `还有 ${active} 个关联任务未收口,其中 ${counts.blocked} 个受阻:先解阻塞再评审需求完成。`;
|
|
254
|
+
} else if (counts.in_review > 0) {
|
|
255
|
+
verdict = "in-review";
|
|
256
|
+
text = `还有 ${active} 个关联任务未收口,其中 ${counts.in_review} 个待验收:先在任务上完成评审(通过不等于完成,仍需人工点 done)。`;
|
|
257
|
+
} else {
|
|
258
|
+
verdict = "in-progress";
|
|
259
|
+
text = `还有 ${active} 个关联任务未收口(待办 ${counts.backlog + counts.todo} · 进行中 ${counts.in_progress}):需求尚未完成。`;
|
|
260
|
+
}
|
|
261
|
+
return { total, closed, active, counts, verdict, ready, text, tasks: list };
|
|
262
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* review.mjs —— 评审流程与评审死锁诊断(FR-83)。
|
|
3
|
+
*
|
|
4
|
+
* 对齐 hermes `request_changes` + `_rule_review_dependency_deadlock`(见 设计/hermes-kanban评估-2026-10-16.md §6.7):
|
|
5
|
+
* · 评审是**一等流程**:请求评审(指派评审者)→ 请求返工(退回**来源列**)/ 评审通过
|
|
6
|
+
* · 返工**退回来源列**,不得退成"实现"以外的错列(来源列在请求评审时记下)
|
|
7
|
+
* · "评审者自身被阻塞 / 评审链成环 / 无人评审"必须被**显式诊断**出来,并给恢复动作
|
|
8
|
+
* · 红线不动:**评审通过也不自动置"完成"**(完成只能人确认)
|
|
9
|
+
*
|
|
10
|
+
* 本模块只做纯函数 + 只读遍历;写库在 store(`requestReview` / `requestChanges` / `approveReview`)。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** 评审态(tasks.review_state)。 */
|
|
14
|
+
export const REVIEW_STATES = Object.freeze(["pending", "approved", "changes_requested"]);
|
|
15
|
+
/** 默认"无人评审"多久算停摆。 */
|
|
16
|
+
export const REVIEW_IDLE_MS = 30 * 60 * 1000;
|
|
17
|
+
/** 返工允许退回的"实现列"(其余一律回落到 in_progress,**不得退到 backlog/done 这类错列**)。 */
|
|
18
|
+
export const REVIEW_SOURCE_STATUSES = Object.freeze(["in_progress", "todo"]);
|
|
19
|
+
|
|
20
|
+
/** 返工应退回哪一列:请求评审时记下的来源列;非法/缺失 → 回落到"进行中"(实现列)。 */
|
|
21
|
+
export function reviewReturnStatus(reviewSourceStatus) {
|
|
22
|
+
const src = String(reviewSourceStatus ?? "");
|
|
23
|
+
return REVIEW_SOURCE_STATUSES.includes(src) ? src : "in_progress";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** 评审链是否成环(沿 reviewDependsOn 走;names 便于人读)。 */
|
|
27
|
+
export function reviewChain(store, task, { maxHops = 20 } = {}) {
|
|
28
|
+
const names = [task.identifier];
|
|
29
|
+
const ids = new Set([task.id]);
|
|
30
|
+
let cursor = task;
|
|
31
|
+
for (let hop = 0; hop < maxHops; hop += 1) {
|
|
32
|
+
const nextId = cursor?.reviewDependsOn ? String(cursor.reviewDependsOn) : "";
|
|
33
|
+
if (!nextId) break;
|
|
34
|
+
if (ids.has(nextId)) return { names, cycle: true, cycleTo: nextId, nodes: [] };
|
|
35
|
+
const next = (() => { try { return store.getTaskById(nextId); } catch { return null; } })();
|
|
36
|
+
if (!next) return { names, cycle: false, missing: nextId, nodes: [] };
|
|
37
|
+
ids.add(next.id);
|
|
38
|
+
names.push(next.identifier);
|
|
39
|
+
cursor = next;
|
|
40
|
+
}
|
|
41
|
+
return { names, cycle: false, nodes: [] };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 评审死锁判定(只读遍历)。返回 null(正常)或 {deadlocked, kind, reason, chain}。
|
|
46
|
+
* 四种死锁:
|
|
47
|
+
* · cycle 评审链成环(A 等 B 评审、B 等 A 评审)
|
|
48
|
+
* · reviewer-blocked 评审者自身被阻断("评审者被阻塞")
|
|
49
|
+
* · reviewer-missing 依赖的评审任务已不存在
|
|
50
|
+
* · unassigned 未指派评审者且已停摆超阈值
|
|
51
|
+
*/
|
|
52
|
+
export function detectReviewDeadlock(store, task, { now = Date.now(), idleMs = REVIEW_IDLE_MS } = {}) {
|
|
53
|
+
if (!task || task.status !== "in_review") return null;
|
|
54
|
+
const state = task.reviewState ?? "pending";
|
|
55
|
+
if (state === "approved") return null; // 已通过,只差人确认完成
|
|
56
|
+
const chain = reviewChain(store, task);
|
|
57
|
+
if (chain.cycle) return { deadlocked: true, kind: "cycle", reason: `评审链成环:${chain.names.join(" → ")} →(回到起点)`, chain: chain.names };
|
|
58
|
+
if (chain.missing) return { deadlocked: true, kind: "reviewer-missing", reason: `评审依赖的任务已不存在(${chain.missing})`, chain: chain.names };
|
|
59
|
+
let cursor = task;
|
|
60
|
+
const seen = new Set([task.id]);
|
|
61
|
+
for (let hop = 0; hop < 20; hop += 1) {
|
|
62
|
+
const nextId = cursor?.reviewDependsOn ? String(cursor.reviewDependsOn) : "";
|
|
63
|
+
if (!nextId) break;
|
|
64
|
+
if (seen.has(nextId)) break;
|
|
65
|
+
seen.add(nextId);
|
|
66
|
+
const next = (() => { try { return store.getTaskById(nextId); } catch { return null; } })();
|
|
67
|
+
if (!next) break;
|
|
68
|
+
if (next.status === "blocked") {
|
|
69
|
+
return { deadlocked: true, kind: "reviewer-blocked", reason: `评审者自身受阻:${next.identifier}(${next.blockKind ?? "未分类"})`, chain: chain.names };
|
|
70
|
+
}
|
|
71
|
+
cursor = next;
|
|
72
|
+
}
|
|
73
|
+
if (!task.reviewer) {
|
|
74
|
+
const since = task.reviewRequestedAt ?? task.updatedAt;
|
|
75
|
+
const minutes = since ? Math.max(0, Math.round((now - new Date(since).getTime()) / 60000)) : 0;
|
|
76
|
+
if (minutes * 60000 >= idleMs) {
|
|
77
|
+
return { deadlocked: true, kind: "unassigned", reason: `未指派评审者,已 ${minutes} 分钟无人评审`, chain: chain.names, minutes };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 会话命名口径(2026-10-23 用户新增约束)。
|
|
3
|
+
*
|
|
4
|
+
* 用户口径(原话):
|
|
5
|
+
* 1. 由任务看板下发的会话,统一「**【任务】+ 任务标题 + 时间**」;
|
|
6
|
+
* 2. 项目主会话统一「**【项目】+ 项目名称**」;**重载 / 重绑**的,名称后跟备注;
|
|
7
|
+
* 3. 其他会话(专属文档 / 修复 / 评审 …)在任务会话约束**基础上额外备注**。
|
|
8
|
+
*
|
|
9
|
+
* 为什么做成纯函数:命名是**可判定的口径**,不该在调用点各拼一次字符串 —— 单测直接钉住字符串形状,
|
|
10
|
+
* 调用点只负责提供「标题 / 项目名 / 备注」。
|
|
11
|
+
*
|
|
12
|
+
* ⚠️ 宿主约束(实测契约):DSH 的 `sessionController.create()` **不接受 title**
|
|
13
|
+
* (`SessionCreateRequest` 只有 `workspaceId / cwd / sessionId / agentPreset`),只有
|
|
14
|
+
* `rename({ sessionId, title })`。故一律**建完再改名**(见 `index.js` 的宿主端口),
|
|
15
|
+
* 且改名失败要**如实回原因**,不谎报成功。
|
|
16
|
+
*/
|
|
17
|
+
export const TASK_PREFIX = "【任务】";
|
|
18
|
+
export const PROJECT_PREFIX = "【项目】";
|
|
19
|
+
|
|
20
|
+
/** 其他会话的备注词表(口径 3)。**未收录的 kind 一律回 `null`** —— 不臆造备注。 */
|
|
21
|
+
export const NOTE_KINDS = Object.freeze({
|
|
22
|
+
doc: "专属文档",
|
|
23
|
+
fix: "修复",
|
|
24
|
+
review: "评审",
|
|
25
|
+
test: "测试",
|
|
26
|
+
design: "设计",
|
|
27
|
+
rebuild: "重建",
|
|
28
|
+
rebind: "重绑",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export function noteForKind(kind) {
|
|
32
|
+
if (typeof kind !== "string") return null;
|
|
33
|
+
const key = kind.trim().toLowerCase();
|
|
34
|
+
return Object.prototype.hasOwnProperty.call(NOTE_KINDS, key) ? NOTE_KINDS[key] : null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** 把多行 / 多余空白压成单行并限长(会话名是一行,别把整段描述灌进去)。 */
|
|
38
|
+
export function cleanLabel(text, { max = 80 } = {}) {
|
|
39
|
+
const s = String(text ?? "").replace(/[\r\n\t]+/g, " ").replace(/\s{2,}/g, " ").trim();
|
|
40
|
+
if (max > 0 && s.length > max) return `${s.slice(0, max - 1)}…`;
|
|
41
|
+
return s;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** 时间戳(本地时区,分钟精度):`2026-10-23 12:40`。取不到有效时间回空串(调用方不拼半个时间)。 */
|
|
45
|
+
export function formatStamp(at = new Date()) {
|
|
46
|
+
const d = at instanceof Date ? at : new Date(at);
|
|
47
|
+
if (Number.isNaN(d.getTime())) return "";
|
|
48
|
+
const p = (n) => String(n).padStart(2, "0");
|
|
49
|
+
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** 口径 1 / 3:`【任务】<标题> · <时间>`,带备注时 `…(<备注>)`。 */
|
|
53
|
+
export function taskSessionTitle(title, { at = new Date(), note = null } = {}) {
|
|
54
|
+
const head = `${TASK_PREFIX}${cleanLabel(title) || "(无标题)"}`;
|
|
55
|
+
const stamp = formatStamp(at);
|
|
56
|
+
const tail = note ? `(${cleanLabel(note, { max: 30 })})` : "";
|
|
57
|
+
return stamp ? `${head} · ${stamp}${tail}` : `${head}${tail}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** 口径 2:`【项目】<项目名称>`;重载 / 重绑时 `…(<备注>)`。 */
|
|
61
|
+
export function projectMainSessionTitle(name, { note = null } = {}) {
|
|
62
|
+
const head = `${PROJECT_PREFIX}${cleanLabel(name) || "(未命名项目)"}`;
|
|
63
|
+
return note ? `${head}(${cleanLabel(note, { max: 30 })})` : head;
|
|
64
|
+
}
|