taskboard-workbench 0.0.0-stage → 0.3.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 +403 -0
- package/LICENSE +21 -0
- package/README.md +210 -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 +96 -4
- package/scripts/tb-flow.mjs +86 -0
- package/skills/taskboard-flow/SKILL.md +89 -0
- package/skills/taskboard-flow/references/errors.md +61 -0
- package/skills/taskboard-flow/references/injection.md +70 -0
- package/skills/taskboard-flow/references/steps/S0.md +31 -0
- package/skills/taskboard-flow/references/steps/S1.md +28 -0
- package/skills/taskboard-flow/references/steps/S2.md +31 -0
- package/skills/taskboard-flow/references/steps/S3.md +22 -0
- package/skills/taskboard-flow/references/steps/S4.md +25 -0
- package/skills/taskboard-flow/references/steps/S5.md +36 -0
- package/skills/taskboard-flow/references/steps/S6.md +30 -0
- package/skills/taskboard-flow/references/steps/S7.md +23 -0
- package/spec/norms/acceptance.md +36 -0
- package/spec/norms/card-update.md +39 -0
- package/spec/norms/doc-editing.md +30 -0
- package/spec/norms/flow.md +45 -0
- package/spec/norms/manifest.json +41 -0
- package/spec/norms/project-defaults.md +33 -0
- package/spec//345/233/242/351/230/237agent.md +171 -0
- package/src/core/acceptance.mjs +62 -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/contract.mjs +287 -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 +142 -0
- package/src/core/evidence.mjs +86 -0
- package/src/core/executor.mjs +645 -0
- package/src/core/human-review.mjs +773 -0
- package/src/core/intake.mjs +179 -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 +292 -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 +3442 -0
- package/src/core/team.mjs +170 -0
- package/src/core/ticket-stage.mjs +150 -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/mcp/flow-block.mjs +173 -0
- package/src/mcp/server.mjs +156 -0
- package/src/mcp/tools.mjs +764 -0
- package/src/server/api.mjs +2050 -0
- package/src/server/events.mjs +32 -0
- package/src/server/kickoff.mjs +46 -0
- package/src/server/server.mjs +214 -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 +5337 -0
- package/web/index.html +15 -0
- package/web/tokens.css +1151 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* intake.mjs —— 项目资料引入(本地项目文件夹 → 工作台)。
|
|
3
|
+
*
|
|
4
|
+
* 背景:工作台此前只有"手工建条目/任务",本地项目文件夹里的 md/doc 资料
|
|
5
|
+
* **没有被引入**,导致"需求文档为空、团队/需求像摆设"。本模块把项目文件夹扫一遍,
|
|
6
|
+
* 汇总成"资料索引"写入需求文档,并可按文档生成需求条目(可判定的初始资料引入)。
|
|
7
|
+
*/
|
|
8
|
+
import { readdir, readFile, stat, realpath, readlink } from "node:fs/promises";
|
|
9
|
+
import { join, relative, extname, basename, sep } from "node:path";
|
|
10
|
+
|
|
11
|
+
/** 默认可引入的文档后缀(文本类可读,二进制类只登记)。 */
|
|
12
|
+
export const DEFAULT_DOC_EXTS = [".md", ".markdown", ".txt", ".rst", ".doc", ".docx", ".pdf"];
|
|
13
|
+
const TEXT_EXTS = new Set([".md", ".markdown", ".txt", ".rst"]);
|
|
14
|
+
/** 遍历时跳过的重目录(避免把依赖/产物当资料)。 */
|
|
15
|
+
const SKIP_DIRS = new Set(["node_modules", ".git", ".data", ".archify", ".cache", "dist", "build", "coverage", ".next", ".turbo"]);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 递归扫描项目文件夹中的文档。
|
|
19
|
+
*
|
|
20
|
+
* **符号链接(2026-10-29 · 卡 `-175`)**:此前的判据是 `entry.isFile()` / `entry.isDirectory()`,
|
|
21
|
+
* 而 `Dirent.isFile()` 对**符号链接恒为 false** ⇒ 软链文档被**静默跳过**(无告警、无计数)。
|
|
22
|
+
* 本仓 `docs/团队agent.md → ../spec/团队agent.md` 因此一直没进索引(`docsTotal` 少 1)。
|
|
23
|
+
* 现在按软链处理:`stat` 跟随判类型 → 环路保护(`realpath` 去重)→ 越界判定(`realpath` 必须仍在 root 内),
|
|
24
|
+
* 跳过的每一条都进 `symlinks.skipped`(带 reason),**不再静默**。
|
|
25
|
+
*
|
|
26
|
+
* @returns {{ root:string, files:Array, count:number, truncated:boolean,
|
|
27
|
+
* symlinks:{ followed:number, skipped:Array<{relPath:string,target:string|null,reason:string}> } }}
|
|
28
|
+
*/
|
|
29
|
+
export async function scanProjectMaterials(rootDir, { maxFiles = 500, maxDepth = 8, exts = DEFAULT_DOC_EXTS, include = null, exclude = null } = {}) {
|
|
30
|
+
const allowed = new Set(exts.map((e) => e.toLowerCase()));
|
|
31
|
+
const norm = (s) => String(s).replace(/^\/+/, "").replace(/\/+$/, "");
|
|
32
|
+
const inc = include && include.length ? include.map(norm) : null;
|
|
33
|
+
const exc = (exclude ?? []).map(norm);
|
|
34
|
+
const under = (rel, prefixes) => prefixes.some((p) => rel === p || rel.startsWith(`${p}/`));
|
|
35
|
+
const files = [];
|
|
36
|
+
let truncated = false;
|
|
37
|
+
const symlinks = { followed: 0, skipped: [] };
|
|
38
|
+
let rootReal = rootDir;
|
|
39
|
+
try { rootReal = await realpath(rootDir); } catch { /* root 不可解析时退回字面路径 */ }
|
|
40
|
+
const insideRoot = (real) => real === rootReal || real.startsWith(rootReal + sep);
|
|
41
|
+
/**
|
|
42
|
+
* 环路保护用**祖先链**,不用全局 seen 集合。
|
|
43
|
+
* 全局去重会让「同一真目录被两条路径引用」时后者凭空消失(example:`alias/ → real/sub`,两个 relPath 只留一个),
|
|
44
|
+
* 那不是防环,那是悄悄丢文件。祖先链只挡「指回自己祖先/自身」,两个别名各走各的。
|
|
45
|
+
*/
|
|
46
|
+
const chain = [];
|
|
47
|
+
const skipLink = (relPath, target, reason) => symlinks.skipped.push({ relPath, target, reason });
|
|
48
|
+
async function walk(dir, depth) {
|
|
49
|
+
if (files.length >= maxFiles) { truncated = true; return; }
|
|
50
|
+
if (depth > maxDepth) return;
|
|
51
|
+
let dirReal = dir;
|
|
52
|
+
try { dirReal = await realpath(dir); } catch { /* 保持字面路径 */ }
|
|
53
|
+
if (chain.includes(dirReal)) {
|
|
54
|
+
// 指回祖先(软链最常见的自环形态):记账后返回,不递归
|
|
55
|
+
if (depth > 0) skipLink(relative(rootDir, dir) || ".", dirReal, "loop");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
chain.push(dirReal);
|
|
59
|
+
// push/pop 必须由 walk 自己配对(try/finally)。此前由调用方 `chain.pop()`:
|
|
60
|
+
// 一旦被调方在 push 之前早退(maxDepth / maxFiles / 指回祖先),调用方就会把**自家**条目弹掉,
|
|
61
|
+
// 祖先链随之损坏 ⇒ 后面的兄弟软链不再被识别为环,同一批文件被重复收进索引。测试 ⑦ 是这条的反证。
|
|
62
|
+
try {
|
|
63
|
+
let entries;
|
|
64
|
+
try { entries = await readdir(dir, { withFileTypes: true }); } catch { return; }
|
|
65
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
if (files.length >= maxFiles) { truncated = true; return; }
|
|
68
|
+
if (entry.name.startsWith(".")) continue; // 跳过隐藏文件/目录
|
|
69
|
+
const absPath = join(dir, entry.name);
|
|
70
|
+
const relPath = relative(rootDir, absPath);
|
|
71
|
+
if (entry.isSymbolicLink()) {
|
|
72
|
+
let info;
|
|
73
|
+
try { info = await stat(absPath); } catch {
|
|
74
|
+
let target = null;
|
|
75
|
+
try { target = await readlink(absPath); } catch { /* 读不到目标 */ }
|
|
76
|
+
skipLink(relPath, target, "broken");
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
let real;
|
|
80
|
+
try { real = await realpath(absPath); } catch { skipLink(relPath, null, "unreadable"); continue; }
|
|
81
|
+
if (!insideRoot(real)) { skipLink(relPath, real, "outside-root"); continue; }
|
|
82
|
+
if (info.isDirectory()) {
|
|
83
|
+
if (SKIP_DIRS.has(entry.name)) { skipLink(relPath, real, "skip-dir"); continue; }
|
|
84
|
+
if (under(relPath, exc)) { skipLink(relPath, real, "excluded"); continue; }
|
|
85
|
+
symlinks.followed += 1;
|
|
86
|
+
await walk(absPath, depth + 1);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (!info.isFile()) { skipLink(relPath, real, "not-a-file"); continue; }
|
|
90
|
+
const ext = extname(entry.name).toLowerCase();
|
|
91
|
+
if (!allowed.has(ext)) { skipLink(relPath, real, "ext-not-allowed"); continue; }
|
|
92
|
+
if (inc && !under(relPath, inc)) { skipLink(relPath, real, "not-included"); continue; }
|
|
93
|
+
if (under(relPath, exc)) { skipLink(relPath, real, "excluded"); continue; }
|
|
94
|
+
let bytes = 0;
|
|
95
|
+
try { bytes = (await stat(absPath)).size; } catch { /* ignore */ }
|
|
96
|
+
files.push({ absPath, relPath, ext, name: entry.name, bytes, readable: TEXT_EXTS.has(ext), symlink: true });
|
|
97
|
+
symlinks.followed += 1;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (entry.isDirectory()) {
|
|
101
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
102
|
+
if (under(relPath, exc)) continue;
|
|
103
|
+
await walk(absPath, depth + 1);
|
|
104
|
+
} else if (entry.isFile()) {
|
|
105
|
+
const ext = extname(entry.name).toLowerCase();
|
|
106
|
+
if (!allowed.has(ext)) continue;
|
|
107
|
+
if (inc && !under(relPath, inc)) continue;
|
|
108
|
+
if (under(relPath, exc)) continue;
|
|
109
|
+
let bytes = 0;
|
|
110
|
+
try { bytes = (await stat(absPath)).size; } catch { /* ignore */ }
|
|
111
|
+
files.push({ absPath, relPath, ext, name: entry.name, bytes, readable: TEXT_EXTS.has(ext) });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
} finally {
|
|
115
|
+
chain.pop();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
await walk(rootDir, 0);
|
|
119
|
+
return { root: rootDir, files, count: files.length, truncated, symlinks };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 收集"工作区外的显式文件"(按引用纳入,不拷贝)。
|
|
124
|
+
* 用于 survey 这类位于项目根之外、但属 SSOT 的技术细节文档。
|
|
125
|
+
*/
|
|
126
|
+
export async function collectExternalFiles(paths = []) {
|
|
127
|
+
const out = [];
|
|
128
|
+
for (const p of paths) {
|
|
129
|
+
if (!p) continue;
|
|
130
|
+
try {
|
|
131
|
+
const info = await stat(p);
|
|
132
|
+
if (!info.isFile()) continue;
|
|
133
|
+
const ext = extname(p).toLowerCase();
|
|
134
|
+
out.push({ absPath: p, relPath: `«外部» ${p}`, ext, name: basename(p), bytes: info.size, readable: TEXT_EXTS.has(ext), external: true });
|
|
135
|
+
} catch { /* 路径不存在则跳过 */ }
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** 从内容或文件名推断标题(优先首个一级标题)。 */
|
|
141
|
+
export function titleOf(file, content) {
|
|
142
|
+
if (content) {
|
|
143
|
+
const m = content.match(/^\s*#\s+(.+)$/m);
|
|
144
|
+
if (m) return m[1].trim().slice(0, 120);
|
|
145
|
+
}
|
|
146
|
+
return basename(file.name, file.ext).replace(/[-_]+/g, " ").trim().slice(0, 120) || file.name;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 生成"资料索引"(写入需求文档)+ 可读文档内容(用于生成条目)。
|
|
151
|
+
* @returns {{ index:string, docs:Array<{relPath,title,content}> }}
|
|
152
|
+
*/
|
|
153
|
+
export async function buildMaterialIndex(scan, { maxBytesPerFile = 8000, includeContent = true } = {}) {
|
|
154
|
+
const lines = [
|
|
155
|
+
`# 项目资料引入`,
|
|
156
|
+
"",
|
|
157
|
+
`- 目录:\`${scan.root}\``,
|
|
158
|
+
`- 扫描到文档:**${scan.count}** 个${scan.truncated ? "(已按上限截断)" : ""}`,
|
|
159
|
+
`- 引入时间:${new Date().toISOString()}`,
|
|
160
|
+
"",
|
|
161
|
+
"## 资料清单",
|
|
162
|
+
"",
|
|
163
|
+
];
|
|
164
|
+
for (const f of scan.files) lines.push(`- \`${f.relPath}\` — ${f.bytes} B${f.readable ? "" : "(二进制/需人工)"}`);
|
|
165
|
+
lines.push("");
|
|
166
|
+
const docs = [];
|
|
167
|
+
if (includeContent) {
|
|
168
|
+
lines.push("## 文档内容(文本类)", "");
|
|
169
|
+
for (const f of scan.files) {
|
|
170
|
+
if (!f.readable) continue;
|
|
171
|
+
let content = "";
|
|
172
|
+
try { content = await readFile(f.absPath, "utf8"); } catch { continue; }
|
|
173
|
+
const trimmed = content.length > maxBytesPerFile ? `${content.slice(0, maxBytesPerFile)}\n\n…(已截断,全文见源文件)` : content;
|
|
174
|
+
docs.push({ relPath: f.relPath, title: titleOf(f, content), content });
|
|
175
|
+
lines.push(`### ${f.relPath}`, "", trimmed, "");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return { index: lines.join("\n"), docs };
|
|
179
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FR-92「项目开局对齐」—— 标准步骤程序(**纯函数**,不碰文件系统/数据库,可单测)。
|
|
3
|
+
*
|
|
4
|
+
* 来源:用户 2026-10-22 指定引入鱼皮《Vibe Coding 团队协作技巧》
|
|
5
|
+
* (https://github.com/liyupi/ai-guide/blob/main/Vibe%20Coding%20零基础教程/30%20经验技巧/11%20Vibe%20Coding%20团队协作技巧.md),
|
|
6
|
+
* 要求「作为项目任务看板工作台的项目开局对齐事项,建立相关团队&配置约束」,并
|
|
7
|
+
* 「把该对齐作为标准化流程引入,作为任务工作台标准步骤程序执行」。
|
|
8
|
+
*
|
|
9
|
+
* 该文七条要点(统一代码规范 / 文档驱动 / Git 协作流程 / 代码审查 / AI 团队功能 / 协作机制 / 明确分工)
|
|
10
|
+
* 在这里被压成 **6 个可自检的开局步骤**:每一步都有**可核验的判据**(工作区里存在哪些文件、
|
|
11
|
+
* 项目设置里哪些约束已填),而不是"读一读就好"的口号 —— 这样工作台能自己回答"这个项目对齐了没有"。
|
|
12
|
+
*
|
|
13
|
+
* 红线(与 FR-85 同口径):**自检只给结论,不改任何数据**;缺什么由人(或用既有入口)去补。
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** 出处(写进报告,便于追溯;引用不复制原文)。 */
|
|
17
|
+
export const KICKOFF_SOURCE = Object.freeze({
|
|
18
|
+
title: "Vibe Coding 团队协作技巧(鱼皮 / ai-guide)",
|
|
19
|
+
url: "https://github.com/liyupi/ai-guide/blob/main/Vibe%20Coding%20%E9%9B%B6%E5%9F%BA%E7%A1%80%E6%95%99%E7%A8%8B/30%20%E7%BB%8F%E9%AA%8C%E6%8A%80%E5%B7%A7/11%20Vibe%20Coding%20%E5%9B%A2%E9%98%9F%E5%8D%8F%E4%BD%9C%E6%8A%80%E5%B7%A7.md",
|
|
20
|
+
note: "本仓只落**可执行的检查单与约束**,不搬运原文;需要原文请点链接。",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 六个标准步骤。`checks` 每条:`paths`(工作区相对路径,任一存在即通过)或 `setting`
|
|
25
|
+
* (项目设置里的点路径,非空即通过)或 `custom`(由调用方注入的布尔)。
|
|
26
|
+
*/
|
|
27
|
+
export const KICKOFF_ALIGNMENT_STEPS = Object.freeze([
|
|
28
|
+
{
|
|
29
|
+
id: "code-style",
|
|
30
|
+
title: "① 统一代码规范",
|
|
31
|
+
why: "各人用 AI 生成的风格不一致(React/Vue、camelCase/snake_case 混用)会让项目无法维护。",
|
|
32
|
+
spec: "落一份规范文档 + 用 Linter/Formatter 强制执行 + 一份 AI 规则文件(AGENTS.md / CLAUDE.md / .cursorrules)。",
|
|
33
|
+
checks: [
|
|
34
|
+
{ id: "style-doc", label: "规范文档(CODE_STYLE.md / AGENTS.md / CLAUDE.md / .cursorrules 任一)", paths: ["CODE_STYLE.md", "AGENTS.md", "CLAUDE.md", ".cursorrules", ".cursor/rules"] },
|
|
35
|
+
{ id: "linter", label: "Linter 配置", paths: [".eslintrc", ".eslintrc.json", ".eslintrc.cjs", ".eslintrc.js", "eslint.config.js", "eslint.config.mjs", "eslint.config.cjs"] },
|
|
36
|
+
{ id: "formatter", label: "Formatter 配置", paths: [".prettierrc", ".prettierrc.json", ".prettierrc.cjs", ".prettierrc.js", "prettier.config.js", "prettier.config.cjs"] },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "docs-first",
|
|
41
|
+
title: "② 文档驱动开发",
|
|
42
|
+
why: "文档是协作基础:新人靠它上手,跨人交接靠它对齐。",
|
|
43
|
+
spec: "README(简介/快速开始/技术栈/目录结构)+ 参与指南 + 变更记录。",
|
|
44
|
+
checks: [
|
|
45
|
+
{ id: "readme", label: "README.md", paths: ["README.md", "readme.md"] },
|
|
46
|
+
{ id: "contributing", label: "参与指南(CONTRIBUTING.md 或 docs/规范/)", paths: ["CONTRIBUTING.md", "docs/规范", "docs/规范/README.md"] },
|
|
47
|
+
{ id: "changelog", label: "变更记录(CHANGELOG.md 或 docs/进度/)", paths: ["CHANGELOG.md", "docs/进度", "docs/进度/README.md"] },
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "git-flow",
|
|
52
|
+
title: "③ Git 协作流程",
|
|
53
|
+
why: "分支与提交不规范 ⇒ 冲突频发、历史不可追溯。",
|
|
54
|
+
spec: "分支策略(main/develop/feature/bugfix)+ Conventional Commits + PR 模板与评审。",
|
|
55
|
+
checks: [
|
|
56
|
+
{ id: "pr-template", label: "PR 模板(.github/PULL_REQUEST_TEMPLATE.md)", paths: [".github/PULL_REQUEST_TEMPLATE.md", ".github/pull_request_template.md"] },
|
|
57
|
+
{ id: "git-convention", label: "项目设置里写明 Git/提交约定(envConfig.gitFlow)", setting: "envConfig.gitFlow" },
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "review-gate",
|
|
62
|
+
title: "④ 代码审查门",
|
|
63
|
+
why: "审查是质量关键:上线前拦 Bug、统一风格,也是团队学习机会。",
|
|
64
|
+
spec: "至少一人审查 + AI 初审 + 多 AI 交叉验证;审查未过不得合并/解锁下游。",
|
|
65
|
+
checks: [
|
|
66
|
+
{ id: "reviewer-role", label: "团队模板里有 reviewer(审计)角色", custom: "reviewerRole" },
|
|
67
|
+
{ id: "review-gate", label: "项目设置里定义质量门(envConfig.qualityGates 或 teamTemplate.qualityGates)", setting: ["envConfig.qualityGates", "teamTemplate.qualityGates"] },
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: "collaboration",
|
|
72
|
+
title: "⑤ 协作机制与知识沉淀",
|
|
73
|
+
why: "定期同步、知识分享、共享资源能避免重复踩坑。",
|
|
74
|
+
spec: "站会/周会节奏 + 知识库 + 提示词与代码片段等共享资源。",
|
|
75
|
+
checks: [
|
|
76
|
+
{ id: "cadence", label: "项目设置里写明同步节奏(envConfig.cadence)", setting: "envConfig.cadence" },
|
|
77
|
+
{ id: "knowledge", label: "知识沉淀目录(docs/规范/ 或 个人笔记/踩坑经验/)", paths: ["docs/规范", "docs/规范/README.md", "个人笔记/踩坑经验"] },
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: "roles",
|
|
82
|
+
title: "⑥ 明确分工",
|
|
83
|
+
why: "谁负责什么要说清,避免重复工作或遗漏;同时别养成 AI 依赖症。",
|
|
84
|
+
spec: "团队模板定义 lead/planner/engineer/tester/reviewer/archivist 的职责与模型。",
|
|
85
|
+
checks: [
|
|
86
|
+
{ id: "roles-defined", label: "团队模板包含角色编制(teamTemplate.roles)", setting: "teamTemplate.roles" },
|
|
87
|
+
{ id: "executor", label: "工程师角色的执行器与验证命令已约定(teamTemplate.roles[engineer].executor / teamTemplate.engineer.verifyCommand)", custom: "engineerExecutor" },
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
/** 点路径取值(`a.b.c`);空串/空数组/空对象都算"没填"。 */
|
|
93
|
+
export function pickSetting(settings, dotted) {
|
|
94
|
+
let cur = settings;
|
|
95
|
+
for (const key of String(dotted ?? "").split(".")) {
|
|
96
|
+
if (cur == null || typeof cur !== "object") return undefined;
|
|
97
|
+
cur = cur[key];
|
|
98
|
+
}
|
|
99
|
+
return cur;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** "有没有填"的判定:undefined/null/""/[]/{} 都算没填。 */
|
|
103
|
+
export function isFilled(value) {
|
|
104
|
+
if (value === undefined || value === null) return false;
|
|
105
|
+
if (typeof value === "string") return value.trim() !== "";
|
|
106
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
107
|
+
if (typeof value === "object") return Object.keys(value).length > 0;
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 自检:`files` 是「工作区相对路径 → 是否存在」的映射(由 `../server/kickoff.mjs` 采集),
|
|
113
|
+
* `settings` 是项目设置,`custom` 放调用方算好的布尔(如"团队模板里有 reviewer")。
|
|
114
|
+
*/
|
|
115
|
+
export function evaluateKickoff({ files = {}, settings = {}, custom = {} } = {}) {
|
|
116
|
+
const hasFile = (p) => files[p] === true;
|
|
117
|
+
const steps = KICKOFF_ALIGNMENT_STEPS.map((step) => {
|
|
118
|
+
const checks = step.checks.map((c) => {
|
|
119
|
+
let ok;
|
|
120
|
+
if (c.paths) ok = c.paths.some(hasFile);
|
|
121
|
+
// `setting` 允许给一组候选点路径(各仓把同一件事放在不同位置,如 qualityGates 在
|
|
122
|
+
// envConfig 或 teamTemplate 下都有先例)——任一已填即算通过。
|
|
123
|
+
else if (c.setting) ok = (Array.isArray(c.setting) ? c.setting : [c.setting]).some((k) => isFilled(pickSetting(settings, k)));
|
|
124
|
+
else if (c.custom) ok = custom[c.custom] === true;
|
|
125
|
+
else ok = false;
|
|
126
|
+
const settingHit = c.setting ? (Array.isArray(c.setting) ? c.setting : [c.setting]).find((k) => isFilled(pickSetting(settings, k))) : null;
|
|
127
|
+
return { id: c.id, label: c.label, ok, evidence: c.paths ? c.paths.filter(hasFile).join(" / ") || null : settingHit ?? c.custom ?? null };
|
|
128
|
+
});
|
|
129
|
+
const done = checks.filter((c) => c.ok).length;
|
|
130
|
+
const status = done === checks.length ? "done" : done === 0 ? "missing" : "partial";
|
|
131
|
+
return { id: step.id, title: step.title, why: step.why, spec: step.spec, status, done, total: checks.length, checks };
|
|
132
|
+
});
|
|
133
|
+
const doneCount = steps.filter((s) => s.status === "done").length;
|
|
134
|
+
const missing = steps.filter((s) => s.status !== "done");
|
|
135
|
+
return {
|
|
136
|
+
source: KICKOFF_SOURCE,
|
|
137
|
+
steps,
|
|
138
|
+
total: steps.length,
|
|
139
|
+
doneCount,
|
|
140
|
+
// 只有六步全 done 才算"对齐完成";未对齐不阻断(不替用户做决定),但**必须显式提示**。
|
|
141
|
+
ready: doneCount === steps.length,
|
|
142
|
+
missing: missing.map((s) => ({ id: s.id, title: s.title, status: s.status, todo: s.checks.filter((c) => !c.ok).map((c) => c.label) })),
|
|
143
|
+
verdict: doneCount === steps.length
|
|
144
|
+
? "开局对齐已完成(6/6):可以进入拆解与派发。"
|
|
145
|
+
: `开局对齐未完成(${doneCount}/${steps.length}):未对齐项 ${missing.map((s) => s.title).join("、")};建议先补齐再派发执行。`,
|
|
146
|
+
};
|
|
147
|
+
}
|