@house365/comate 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -4
- package/bin/init-run.mjs +45 -6
- package/bin/init.mjs +43 -1
- package/bin/postinstall.mjs +36 -0
- package/docs/COMATE_MANUAL.md +48 -2
- package/package.json +2 -1
- package/skills/comate/SKILL.md +8 -1
- package/skills/comate/scripts/comate-lib.sh +94 -0
- package/skills/comate/scripts/comate.sh +204 -0
- package/skills/comate/tests/comate.bats +197 -0
- package/skills/comate-grill/SKILL.md +185 -0
- package/skills/comate-intake/SKILL.md +222 -0
- package/skills/comate-intake/scaffold/docs/README.md +36 -0
- package/skills/comate-intake/scaffold/docs/architecture/README.md +31 -0
- package/skills/comate-intake/scaffold/docs/knowledge-base/README.md +48 -0
- package/skills/comate-intake/scaffold/docs/knowledge-base/integrations/_TEMPLATE/README.md +49 -0
- package/skills/comate-intake/scaffold/docs/knowledge-base/integrations/_TEMPLATE/api-snapshot.md +47 -0
- package/skills/comate-intake/scaffold/docs/knowledge-base/requirements/_templates/PRD.md +97 -0
- package/skills/comate-open/SKILL.md +19 -0
package/README.md
CHANGED
|
@@ -7,13 +7,14 @@ comate 把 **OpenSpec**(WHAT:提案、规约生命周期、归档)和 **Superpow
|
|
|
7
7
|
## 五阶段
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
/comate
|
|
11
|
-
|
|
12
|
-
open → design → build → verify → archive
|
|
10
|
+
[原始 PRD] ─→ /comate-intake ─┐ (阶段 0:门禁+拆分)
|
|
11
|
+
▼
|
|
12
|
+
/comate ──自动探测阶段──────→ open → design → build → verify → archive
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
| 阶段 | skill | 职责 |
|
|
16
16
|
|------|-------|------|
|
|
17
|
+
| intake | `/comate-intake` | (阶段 0,可选)对原始 PRD 做质量门禁 + 拆分成 N 个 change |
|
|
17
18
|
| open | `/comate-open` | 探索想法,创建 change 结构并初始化 `.comate.yaml` |
|
|
18
19
|
| design | `/comate-design` | 技术设计与方案 brainstorming |
|
|
19
20
|
| build | `/comate-build` | 按任务实现并提交 |
|
|
@@ -22,6 +23,10 @@ open → design → build → verify → archive
|
|
|
22
23
|
|
|
23
24
|
预设路径:`/comate-hotfix`(热修)、`/comate-tweak`(文案/配置小调整)。
|
|
24
25
|
|
|
26
|
+
工具 skill:`/comate-grill`(决策点穷追式澄清)——对计划/设计/PRD 的模糊点逐个深挖,每问附推荐答案、一次一问,直到歧义清零。comate-intake 在阻断问题多、有依赖链时会自动提供「深度澄清」选项调用它;也可单独 `/comate-grill <话题>` 挑战自己的计划草稿。
|
|
27
|
+
|
|
28
|
+
**阶段 0(PRD 门禁与拆分)**:需求若来自一份**原始 PRD**,先过 `/comate-intake`——它审阅 PRD 质量、百分制评分、建阻断台账,门禁通过前禁止建任何 change;通过后按依赖/独立性判定把 PRD 拆成 1 或 N 个 change(粒度由用户定),逐个交给 `/comate-open`。门禁状态钉在 PRD 同级 `<PRD>.gate.yaml`,PRD 通过后被改会自动失效需重跑。需求来自对话时无需此阶段,直接从 open 起步。
|
|
29
|
+
|
|
25
30
|
## 安装
|
|
26
31
|
|
|
27
32
|
```bash
|
|
@@ -35,7 +40,7 @@ cd your-project
|
|
|
35
40
|
comate init
|
|
36
41
|
```
|
|
37
42
|
|
|
38
|
-
`init` 会装好 comate 及其依赖(OpenSpec CLI、Superpowers
|
|
43
|
+
`init` 会装好 comate 及其依赖(OpenSpec CLI、Superpowers),创建 `openspec/` 项目结构,并铺出 `docs/` 知识库骨架(`docs/knowledge-base/requirements/` 放 PRD + PRD 模板、`docs/architecture/` 架构规范占位、integrations 对接模板)——`/comate-intake` 从这里读 PRD。支持 Claude Code、Codex、Cursor 等 70+ agent。可重复执行,已装的自动跳过,已有的 docs 文件不覆盖。
|
|
39
44
|
|
|
40
45
|
skills 装到用户级(`~/.agents/skills`),装一次所有项目共用;`openspec/` 是项目自己的规约,建在当前目录,所以 `init` 需要在项目目录下运行。
|
|
41
46
|
|
|
@@ -63,7 +68,9 @@ skills/
|
|
|
63
68
|
reference/ 决策点、脏工作树协议、前置条件
|
|
64
69
|
tests/ bats 测试
|
|
65
70
|
comate-open/ design/ build/ verify/ archive/ 各阶段 skill
|
|
71
|
+
comate-intake/ 阶段 0:PRD 门禁与拆分
|
|
66
72
|
comate-hotfix/ tweak/ 预设路径 skill
|
|
73
|
+
comate-grill/ 决策点穷追式澄清工具
|
|
67
74
|
docs/
|
|
68
75
|
COMATE_MANUAL.md 完整操作手册
|
|
69
76
|
```
|
package/bin/init-run.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
4
|
import { join, resolve } from 'node:path';
|
|
5
|
+
import { createInterface } from 'node:readline';
|
|
5
6
|
|
|
6
7
|
import { findBash } from './doctor.mjs';
|
|
7
8
|
import {
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
npmInvocation,
|
|
12
13
|
openSpecState,
|
|
13
14
|
run,
|
|
15
|
+
scaffoldDocs,
|
|
14
16
|
skillsInvocation,
|
|
15
17
|
superpowersInstalled,
|
|
16
18
|
} from './init.mjs';
|
|
@@ -49,12 +51,19 @@ export async function init(pkgRoot) {
|
|
|
49
51
|
|
|
50
52
|
const target = inspectTarget(cwd, home);
|
|
51
53
|
if (target.kind !== 'project') {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
// Home directory is always refused
|
|
55
|
+
if (target.kind === 'home') {
|
|
56
|
+
console.error('\n这是主目录,请在项目目录下运行 comate init。');
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Bare directory: ask user if they want to create a project here
|
|
61
|
+
console.log('\n当前目录不像项目(无 .git / package.json 等)。');
|
|
62
|
+
const confirmed = await askConfirm('要在这里初始化新项目吗?');
|
|
63
|
+
if (!confirmed) {
|
|
64
|
+
console.log('已取消。');
|
|
65
|
+
return 1;
|
|
66
|
+
}
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
// comate's skills are bash scripts needing associative arrays (bash 4+), and
|
|
@@ -147,10 +156,40 @@ export async function init(pkgRoot) {
|
|
|
147
156
|
results.push(['openspec/', r2.ok ? 'installed' : 'failed', r2.ok ? '' : r2.reason, r2.output]);
|
|
148
157
|
}
|
|
149
158
|
|
|
159
|
+
// 5. docs/ knowledge-base scaffold. /comate-intake reads PRDs from
|
|
160
|
+
// docs/knowledge-base/requirements/ (comate_kb_root is hardcoded there), so a
|
|
161
|
+
// fresh project has nowhere to put a PRD. Idempotent — existing files are left
|
|
162
|
+
// alone, only missing pieces are filled in, so re-running never clobbers a
|
|
163
|
+
// project's real docs. A failure here is non-fatal to the rest of the install.
|
|
164
|
+
const sc = scaffoldDocs(pkgRoot);
|
|
165
|
+
if (!sc.ok) {
|
|
166
|
+
results.push(['docs/', 'failed', sc.reason]);
|
|
167
|
+
} else if (sc.created === 0) {
|
|
168
|
+
results.push(['docs/', 'skipped', '已存在']);
|
|
169
|
+
} else {
|
|
170
|
+
const note = sc.skipped > 0 ? `新建 ${sc.created} 个文件,保留 ${sc.skipped} 个已有` : '';
|
|
171
|
+
results.push(['docs/', 'installed', note]);
|
|
172
|
+
}
|
|
173
|
+
|
|
150
174
|
stopSpinner();
|
|
151
175
|
return report(results);
|
|
152
176
|
}
|
|
153
177
|
|
|
178
|
+
// A yes/no prompt. Defaults to "no" so a piped/non-interactive run (CI, an
|
|
179
|
+
// unattended npx) never silently scaffolds a project into whatever directory it
|
|
180
|
+
// happened to land in — those callers should point at a real project instead.
|
|
181
|
+
// [y/N]: empty input, EOF (Ctrl-D / closed stdin), or anything but y/yes = no.
|
|
182
|
+
export function askConfirm(question, { input = process.stdin, output = process.stdout } = {}) {
|
|
183
|
+
if (!input.isTTY) return Promise.resolve(false);
|
|
184
|
+
const rl = createInterface({ input, output });
|
|
185
|
+
return new Promise((done) => {
|
|
186
|
+
rl.question(`${question} [y/N] `, (answer) => {
|
|
187
|
+
rl.close();
|
|
188
|
+
done(/^\s*y(es)?\s*$/i.test(answer));
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
154
193
|
// The spinner runs in its own process because every step above is a synchronous
|
|
155
194
|
// spawnSync — an interval on this thread would never fire. In a pipe \r does not
|
|
156
195
|
// overwrite, so animating there would leave every frame on screen; print one
|
package/bin/init.mjs
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// ponytail: no SKILLS_AGENT_MAP here. The skills CLI detects the running agent
|
|
10
10
|
// on its own, so translating platform ids to agent names would be dead code.
|
|
11
11
|
import { spawnSync } from 'node:child_process';
|
|
12
|
-
import { existsSync } from 'node:fs';
|
|
12
|
+
import { existsSync, mkdirSync, readdirSync, copyFileSync, statSync } from 'node:fs';
|
|
13
13
|
import { createRequire } from 'node:module';
|
|
14
14
|
import { dirname, join } from 'node:path';
|
|
15
15
|
|
|
@@ -172,6 +172,45 @@ function superpowersInstalled(scope) {
|
|
|
172
172
|
return roots.some((root) => SUPERPOWERS_MARKERS.some((m) => existsSync(join(root, ...m))));
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
// The docs scaffold ships inside the comate skill, so it is present both in dev
|
|
176
|
+
// (repo checkout) and after `skills add` copies the skill to ~/.agents/skills.
|
|
177
|
+
// Locating it relative to pkgRoot means init reads the same tree it packed.
|
|
178
|
+
function scaffoldSourceDir(pkgRoot) {
|
|
179
|
+
return join(pkgRoot, 'skills', 'comate-intake', 'scaffold', 'docs');
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// copyTreeSkipExisting — recursively copy src→dst, never overwriting a file that
|
|
183
|
+
// already exists. Returns { created, skipped } counts so init can report whether
|
|
184
|
+
// it actually laid anything down (matching the openspec/ step's idempotence:
|
|
185
|
+
// an existing docs/ is left alone, only missing pieces are filled in).
|
|
186
|
+
function copyTreeSkipExisting(src, dst, acc = { created: 0, skipped: 0 }) {
|
|
187
|
+
mkdirSync(dst, { recursive: true });
|
|
188
|
+
for (const entry of readdirSync(src)) {
|
|
189
|
+
const s = join(src, entry);
|
|
190
|
+
const d = join(dst, entry);
|
|
191
|
+
if (statSync(s).isDirectory()) {
|
|
192
|
+
copyTreeSkipExisting(s, d, acc);
|
|
193
|
+
} else if (existsSync(d)) {
|
|
194
|
+
acc.skipped++;
|
|
195
|
+
} else {
|
|
196
|
+
copyFileSync(s, d);
|
|
197
|
+
acc.created++;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return acc;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// scaffoldDocs — lay down docs/ (knowledge-base + architecture placeholder + PRD
|
|
204
|
+
// template) so /comate-intake has somewhere to read PRDs from. comate_kb_root in
|
|
205
|
+
// comate-lib.sh is hardcoded to docs/knowledge-base, so this path is not
|
|
206
|
+
// configurable — it must match. Idempotent: existing files are never clobbered.
|
|
207
|
+
function scaffoldDocs(pkgRoot, cwd = process.cwd()) {
|
|
208
|
+
const src = scaffoldSourceDir(pkgRoot);
|
|
209
|
+
if (!existsSync(src)) return { ok: false, reason: `scaffold source missing: ${src}` };
|
|
210
|
+
const { created, skipped } = copyTreeSkipExisting(src, join(cwd, 'docs'));
|
|
211
|
+
return { ok: true, created, skipped };
|
|
212
|
+
}
|
|
213
|
+
|
|
175
214
|
export {
|
|
176
215
|
MIN_OPENSPEC,
|
|
177
216
|
NPM_TIMEOUT_MS,
|
|
@@ -186,4 +225,7 @@ export {
|
|
|
186
225
|
atLeast,
|
|
187
226
|
openSpecState,
|
|
188
227
|
superpowersInstalled,
|
|
228
|
+
scaffoldSourceDir,
|
|
229
|
+
copyTreeSkipExisting,
|
|
230
|
+
scaffoldDocs,
|
|
189
231
|
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Postinstall hook: show the wordmark and next steps after npm install finishes.
|
|
3
|
+
// Skipped in CI (where the logo wouldn't render anyway) and local dev installs
|
|
4
|
+
// (where the developer already knows what they installed).
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { dirname, resolve } from 'node:path';
|
|
7
|
+
|
|
8
|
+
const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
9
|
+
|
|
10
|
+
// Skip in CI, or when installing the package's own dependencies during dev.
|
|
11
|
+
if (isCI() || isDevInstall()) {
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { banner, pkgVersion } = await import('./init-run.mjs');
|
|
16
|
+
|
|
17
|
+
console.log(banner(pkgVersion(pkgRoot)));
|
|
18
|
+
console.log(` 🎉 Congratulations! comate 已成功安装。\n`);
|
|
19
|
+
console.log(' 下一步:');
|
|
20
|
+
console.log(' 在你的项目目录下运行 comate init 开始使用');
|
|
21
|
+
console.log(' 或运行 comate doctor 健康检查');
|
|
22
|
+
console.log(' 更多帮助 comate --help\n');
|
|
23
|
+
|
|
24
|
+
function isCI() {
|
|
25
|
+
return Boolean(process.env.CI || process.env.GITHUB_ACTIONS);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// When npm installs a package's own dependencies (npm i in the repo itself),
|
|
29
|
+
// INIT_CWD points to the package root. A user installing comate globally or as
|
|
30
|
+
// a dependency has INIT_CWD pointing elsewhere.
|
|
31
|
+
function isDevInstall() {
|
|
32
|
+
const initCwd = process.env.INIT_CWD;
|
|
33
|
+
if (!initCwd) return false;
|
|
34
|
+
const normalise = (p) => resolve(p).replace(/[\\/]+$/, '').toLowerCase();
|
|
35
|
+
return normalise(initCwd) === normalise(pkgRoot);
|
|
36
|
+
}
|
package/docs/COMATE_MANUAL.md
CHANGED
|
@@ -33,13 +33,17 @@ comate 是一个规约驱动、AI 辅助的开发编排器。它将 **OpenSpec**
|
|
|
33
33
|
### 1.2 五阶段流程
|
|
34
34
|
|
|
35
35
|
```
|
|
36
|
+
[原始 PRD] -> /comate-intake -┐ (阶段 0:门禁 + 拆分)
|
|
37
|
+
v
|
|
36
38
|
/comate
|
|
37
39
|
auto-detect
|
|
38
40
|
/comate-open -> /comate-design -> /comate-build -> /comate-verify -> /comate-archive
|
|
39
41
|
(OpenSpec) (Superpowers) (Superpowers) (两者) (OpenSpec)
|
|
40
42
|
```
|
|
41
43
|
|
|
42
|
-
流程链:open -> design -> build -> verify -> archive
|
|
44
|
+
流程链:(intake ->) open -> design -> build -> verify -> archive
|
|
45
|
+
|
|
46
|
+
**阶段 0(可选,PRD 门禁与拆分)**:需求来自一份**原始 PRD**时,先过 `/comate-intake`:审阅 PRD 质量、百分制评分、建阻断台账,门禁通过前禁止建任何 change;通过后按依赖/整体性/独立性/规模把 PRD 拆成 1 或 N 个 change(粒度由用户定),逐个交给 `/comate-open`。门禁状态钉在 PRD 同级 `<PRD>.gate.yaml`(机器真相源),评审报告为 `PRD-REVIEW-<PRD名>.md`(人类可读)。PRD 通过门禁后被改会因哈希漂移自动失效(stale),需重跑 intake。需求来自对话时无需此阶段。
|
|
43
47
|
|
|
44
48
|
单次 `/comate` 调用从检测到的阶段开始,当退出条件满足时推进到下一阶段。智能体会自动推进后续阶段,但必须在决策阻塞点暂停,直到收到用户确认。
|
|
45
49
|
|
|
@@ -48,10 +52,15 @@ comate 是一个规约驱动、AI 辅助的开发编排器。它将 **OpenSpec**
|
|
|
48
52
|
- **hotfix**:Bug 修复 / 热修复 —— 跳过头脑风暴,直接走 open -> build -> verify -> archive
|
|
49
53
|
- **tweak**:非 Bug 的微调(文本、配置、文档、提示词)—— 跳过头脑风暴和完整计划,走 open -> 轻量 build -> 轻量 verify -> archive
|
|
50
54
|
|
|
55
|
+
### 1.3.1 工具 skill
|
|
56
|
+
|
|
57
|
+
- **grill**(`/comate-grill`):决策点穷追式澄清。对计划/设计/PRD 的模糊点做深度优先遍历,逐个决策点给推荐答案并等用户确认,直到歧义清零。不是阶段,是跨阶段可复用的工具。comate-intake 在阻断问题 > 3 或有依赖链时会提供「深度澄清」选项自动调用它;用户也可 `/comate-grill <话题>` 直接挑战自己的计划草稿。算法内化自社区 grill-me pattern,避免外部依赖漂移。
|
|
58
|
+
|
|
51
59
|
### 1.4 命令快速参考
|
|
52
60
|
|
|
53
61
|
| 命令 | 阶段 | 归属 | 产出物 |
|
|
54
62
|
|---------|-------|-------|-----------|
|
|
63
|
+
| `/comate-intake` | 0. PRD 门禁与拆分 | Claude | `<PRD>.gate.yaml`, 评审报告, N 个 change |
|
|
55
64
|
| `/comate-open` | 1. 启动 | OpenSpec | proposal.md, design.md, tasks.md |
|
|
56
65
|
| `/comate-design` | 2. 深度设计 | Superpowers | 设计文档, delta spec |
|
|
57
66
|
| `/comate-build` | 3. 规划与构建 | Superpowers | 实现计划, 代码提交 |
|
|
@@ -59,6 +68,7 @@ comate 是一个规约驱动、AI 辅助的开发编排器。它将 **OpenSpec**
|
|
|
59
68
|
| `/comate-archive` | 5. 归档 | OpenSpec | delta->main spec 同步, 设计文档标注, 归档 |
|
|
60
69
|
| `/comate-hotfix` | 预设 | 两者 | 快速修复(跳过头脑风暴) |
|
|
61
70
|
| `/comate-tweak` | 预设 | 两者 | 微调(跳过头脑风暴 + 完整计划) |
|
|
71
|
+
| `/comate-grill` | 工具 | Claude | 决策台账(逐决策点澄清,附推荐 + 用户答案) |
|
|
62
72
|
|
|
63
73
|
---
|
|
64
74
|
|
|
@@ -69,7 +79,7 @@ npm install -g @house365/comate
|
|
|
69
79
|
cd your-project && comate init
|
|
70
80
|
```
|
|
71
81
|
|
|
72
|
-
`init` 会装好下面 2.2–2.4
|
|
82
|
+
`init` 会装好下面 2.2–2.4 的全部内容,并铺出 `docs/` 知识库骨架(2.5)。本节余下部分用于排查:init 报某项失败时,对照确认要装什么、怎么自查。
|
|
73
83
|
|
|
74
84
|
### 2.1 运行环境
|
|
75
85
|
|
|
@@ -113,6 +123,27 @@ comate 使用以下 OpenSpec 能力(以技能形式调用):`openspec-explo
|
|
|
113
123
|
|
|
114
124
|
comate 以 npm 包分发(`npm install -g @house365/comate`),`comate init` 通过 skills CLI 装到用户级 `~/.agents/skills`,一次装完所有项目共用,支持 Claude Code、Codex、Cursor 等 70+ agent。
|
|
115
125
|
|
|
126
|
+
### 2.5 docs/ 知识库骨架(阶段 0 用)
|
|
127
|
+
|
|
128
|
+
`comate init` 会在项目里铺出 `docs/` 骨架,供 `/comate-intake` 读写 PRD:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
docs/
|
|
132
|
+
├── README.md # docs 目录说明
|
|
133
|
+
├── architecture/README.md # 架构规范占位(契约事实源,需项目自建)
|
|
134
|
+
└── knowledge-base/
|
|
135
|
+
├── README.md # PRD → comate 流程说明 + 命名约定
|
|
136
|
+
├── requirements/_templates/PRD.md # PRD 模板(comate 版,无 MRD/FRD 层)
|
|
137
|
+
└── integrations/_TEMPLATE/ # 第三方对接档案模板(README + api-snapshot)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
- 路径与 `comate-lib.sh` 硬编码的 `comate_kb_root=docs/knowledge-base` 对齐,PRD 放 `requirements/<YYYYMMDD-功能名>/` 下。
|
|
141
|
+
- **幂等且不覆盖**:逐文件跳过已存在的,重跑 `comate init` 不动你已改过的 docs。
|
|
142
|
+
- `architecture/` 只给占位 README(架构内容项目专属),是 PRD 门禁「契约对齐」的事实源,需按项目实际补齐。
|
|
143
|
+
- 不含 MRD/FRD 模板——comate 只保留 PRD 层,FRD 内容消解进 change 的 proposal/design/tasks。
|
|
144
|
+
|
|
145
|
+
### 2.6 comate 本身的技能布局
|
|
146
|
+
|
|
116
147
|
采用扁平布局——每个 phase 是顶层技能目录,而非 `comate/<phase>/` 嵌套。部分 agent(含 Claude Code)只发现顶层目录,扁平是共同可用的最小公倍数:
|
|
117
148
|
|
|
118
149
|
```
|
|
@@ -511,6 +542,21 @@ bash `""` doctor
|
|
|
511
542
|
|
|
512
543
|
清单文件位于 `openspec/changes/<name>/.comate/sources.manifest`,随 change 进版本库、随归档保留。design 与 build 阶段 guard 会复算知识库文件哈希、与清单比对,漂移则阻塞。
|
|
513
544
|
|
|
545
|
+
### gate - PRD 门禁(阶段 0)
|
|
546
|
+
|
|
547
|
+
对**原始 PRD** 做质量门禁,通过前禁止从该 PRD 建 change。状态钉在 PRD 同级 `<PRD>.gate.yaml`(独立于 change 的 `.comate.yaml`),评审报告为 `PRD-REVIEW-<PRD名>.md`。由 `/comate-intake` 驱动。
|
|
548
|
+
|
|
549
|
+
| 命令 | 描述 |
|
|
550
|
+
|---------|-------------|
|
|
551
|
+
| `gate <prd> review` | 建/刷新 gate.yaml,钉当前 PRD sha256,回显评审报告路径。PRD 变了则状态重置为 `reviewing` |
|
|
552
|
+
| `gate <prd> set <field> <value>` | 写字段:`score` / `blocking_open` / `gate_status` 等 |
|
|
553
|
+
| `gate <prd> pass [--tbd]` | 置 `passed`(`--tbd` 置 `passed-with-tbd`)。硬校验 `blocking_open=0` 且评审报告非空,并重钉哈希 |
|
|
554
|
+
| `gate <prd> spawned <change>` | 记录据此 PRD 扇出的 change(逗号拼接) |
|
|
555
|
+
| `gate <prd> status [--json]` | 查状态;哈希漂移时自动判 `stale`(不改文件) |
|
|
556
|
+
| `gate <prd> check` | comate-open 建 change 前的前置守卫。PASS 要求 gate 存在、状态 ∈ {passed, passed-with-tbd}、哈希未漂移;否则退出码 1 阻塞 |
|
|
557
|
+
|
|
558
|
+
`gate_status` 取值:`reviewing`(审阅中)/ `blocked`(有未关闭阻断项)/ `passed`(阻断清零,可扇出)/ `passed-with-tbd`(用户授权带 TBD,change 需标 ⚠)/ `stale`(PRD 通过后被改,须重过门禁)。退出码契约同 guard:0 通过 / 1 阻塞 / 2 用法 / 3 环境 / 4 状态损坏。
|
|
559
|
+
|
|
514
560
|
### archive - 归档
|
|
515
561
|
|
|
516
562
|
| 命令 | 描述 |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@house365/comate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "comate —— OpenSpec + Superpowers 规约驱动的 AI 开发编排器(Agent Skills)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"skills": "^1.5.21"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
+
"postinstall": "node bin/postinstall.mjs",
|
|
47
48
|
"test": "node bin/init.test.mjs && bash skills/comate/tests/run.sh",
|
|
48
49
|
"doctor": "cd skills && bash comate/scripts/comate.sh doctor",
|
|
49
50
|
"prepublish-check": "node scripts/prepublish-check.mjs",
|
package/skills/comate/SKILL.md
CHANGED
|
@@ -24,10 +24,12 @@ agent 做决策只需读本节,其余参见末尾「参考附录」。决策
|
|
|
24
24
|
**预设探测优先级最高**:
|
|
25
25
|
- 用户明确描述 bug 修复/热修 + 满足 hotfix 条件 → 直接调用 `/comate-hotfix`
|
|
26
26
|
- 用户明确描述文案/配置/文档/prompt 小调整 + 满足 tweak 条件 → 直接调用 `/comate-tweak`
|
|
27
|
+
- **用户输入指向一份原始 PRD**(给了 PRD 路径/编号,或明确说「这是 PRD / 从这份需求文档开始」,典型路径 `docs/knowledge-base/**/PRD-*.md`)**且无对应活跃 change** → 直接调用 `/comate-intake`(阶段 0:先过门禁,再拆分建 change)。不要直接调 `/comate-open`——PRD 必须先过质量门禁。
|
|
27
28
|
- 无预设命中 → 按下表处理
|
|
28
29
|
|
|
29
30
|
| 活跃 change | 用户输入 | 行为 |
|
|
30
31
|
|-------------|----------|------|
|
|
32
|
+
| 无 | 指向原始 PRD | → 调用 `/comate-intake` |
|
|
31
33
|
| 无 | 非预设输入 | → 调用 `/comate-open` |
|
|
32
34
|
| 恰好 1 个 | `/comate <描述>` | → **询问**:继续该 change 还是新建 |
|
|
33
35
|
| 多个 | `/comate <描述>` | → **询问**:继续已有还是新建;继续则列出供选择 |
|
|
@@ -99,6 +101,7 @@ agent 做决策只需读本节,其余参见末尾「参考附录」。决策
|
|
|
99
101
|
|
|
100
102
|
| 命令 | 阶段 | Owner | 产物 |
|
|
101
103
|
|------|------|-------|------|
|
|
104
|
+
| `/comate-intake` | 0. PRD 门禁与拆分 | Claude | `<PRD>.gate.yaml`, 评审报告, N 个 change |
|
|
102
105
|
| `/comate-open` | 1. 开题 | OpenSpec | proposal.md, design.md, tasks.md |
|
|
103
106
|
| `/comate-design` | 2. 深度设计 | Superpowers | Design Doc, delta spec |
|
|
104
107
|
| `/comate-build` | 3. 计划与构建 | Superpowers | 实施计划, 代码提交 |
|
|
@@ -108,12 +111,16 @@ agent 做决策只需读本节,其余参见末尾「参考附录」。决策
|
|
|
108
111
|
| `/comate-tweak` | 预设 | 双方 | 小调整(跳过 brainstorming + 完整 plan) |
|
|
109
112
|
|
|
110
113
|
```
|
|
111
|
-
/comate
|
|
114
|
+
[原始 PRD] ──→ /comate-intake ──┐ (门禁+拆分,扇出 N 个 change)
|
|
115
|
+
(Claude) │
|
|
116
|
+
/comate ▼
|
|
112
117
|
↓ 自动探测
|
|
113
118
|
/comate-open ──→ /comate-design ──→ /comate-build ──→ /comate-verify ──→ /comate-archive
|
|
114
119
|
(OpenSpec) (Superpowers) (Superpowers) (双方) (OpenSpec)
|
|
115
120
|
```
|
|
116
121
|
|
|
122
|
+
需求来自对话时从 `/comate-open` 起步;来自原始 PRD 时先过 `/comate-intake` 门禁再拆分。
|
|
123
|
+
|
|
117
124
|
---
|
|
118
125
|
|
|
119
126
|
## 参考附录
|
|
@@ -428,3 +428,97 @@ sources_drift() {
|
|
|
428
428
|
|
|
429
429
|
# json_escape <string> — escape backslash and double-quote for JSON values.
|
|
430
430
|
json_escape() { printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'; }
|
|
431
|
+
|
|
432
|
+
# --- PRD gate (phase 0: quality gate + split) ---
|
|
433
|
+
#
|
|
434
|
+
# gate.yaml lives NEXT TO the PRD (<prd>.gate.yaml), not under openspec/changes,
|
|
435
|
+
# so it has its own flat schema kept separate from the change .comate.yaml
|
|
436
|
+
# FIELD_ORDER (mixing them would pollute every change state file with gate keys).
|
|
437
|
+
# It is the machine truth for "may a change be spawned from this PRD"; the
|
|
438
|
+
# markdown review report is the human-readable derivative.
|
|
439
|
+
|
|
440
|
+
readonly GATE_SCHEMA_VERSION=1
|
|
441
|
+
|
|
442
|
+
# Canonical field order for gate.yaml (same full-rewrite discipline as yaml_set).
|
|
443
|
+
GATE_FIELD_ORDER=(
|
|
444
|
+
schema_version
|
|
445
|
+
prd_path
|
|
446
|
+
prd_hash
|
|
447
|
+
gate_status
|
|
448
|
+
score
|
|
449
|
+
blocking_open
|
|
450
|
+
review_report
|
|
451
|
+
spawned_changes
|
|
452
|
+
gated_at
|
|
453
|
+
created_at
|
|
454
|
+
)
|
|
455
|
+
|
|
456
|
+
# gate_status is the only enum. `stale` is computed (hash mismatch) but also
|
|
457
|
+
# storable so a detected-stale gate persists across runs.
|
|
458
|
+
declare -A GATE_ENUMS=(
|
|
459
|
+
[schema_version]="1"
|
|
460
|
+
[gate_status]="reviewing blocked passed passed-with-tbd stale"
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
# gate_path_for <prd> — echo the gate.yaml path adjacent to the PRD.
|
|
464
|
+
# Strips a trailing .md/.markdown and appends .gate.yaml.
|
|
465
|
+
gate_path_for() {
|
|
466
|
+
local prd="$1" base
|
|
467
|
+
base="${prd%.markdown}"
|
|
468
|
+
base="${base%.md}"
|
|
469
|
+
echo "${base}.gate.yaml"
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
# gate_report_for <prd> — echo the review report path (PRD same dir).
|
|
473
|
+
gate_report_for() {
|
|
474
|
+
local prd="$1" dir base
|
|
475
|
+
dir=$(dirname "$prd")
|
|
476
|
+
base=$(basename "$prd")
|
|
477
|
+
base="${base%.markdown}"
|
|
478
|
+
base="${base%.md}"
|
|
479
|
+
echo "${dir}/PRD-REVIEW-${base}.md"
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
# gate_yaml_set <file> <key> <value> — gate-file analogue of yaml_set: validate
|
|
483
|
+
# enum, read the whole file, set one key, rewrite every GATE_FIELD_ORDER field,
|
|
484
|
+
# atomic mv, write-back verify.
|
|
485
|
+
gate_yaml_set() {
|
|
486
|
+
local file="$1" key="$2" value="$3"
|
|
487
|
+
[ -f "$file" ] || die "$COMATE_CORRUPT" "ERROR: gate file not found: $file"
|
|
488
|
+
|
|
489
|
+
local known=0 k
|
|
490
|
+
for k in "${GATE_FIELD_ORDER[@]}"; do
|
|
491
|
+
[ "$k" = "$key" ] && { known=1; break; }
|
|
492
|
+
done
|
|
493
|
+
[ "$known" -eq 1 ] || die "$COMATE_USAGE" "ERROR: unknown gate field '$key'"
|
|
494
|
+
|
|
495
|
+
local legal="${GATE_ENUMS[$key]:-}"
|
|
496
|
+
if [ -n "$legal" ] && [ -n "$value" ] && [ "$value" != "null" ]; then
|
|
497
|
+
local ok=0 v
|
|
498
|
+
for v in $legal; do [ "$value" = "$v" ] && { ok=1; break; }; done
|
|
499
|
+
[ "$ok" -eq 1 ] || die "$COMATE_USAGE" "ERROR: invalid value '$value' for '$key' (expected: $legal)"
|
|
500
|
+
fi
|
|
501
|
+
|
|
502
|
+
declare -A _g
|
|
503
|
+
for k in "${GATE_FIELD_ORDER[@]}"; do
|
|
504
|
+
local cv; cv=$(yaml_get "$file" "$k")
|
|
505
|
+
[ -z "$cv" ] && cv="null"
|
|
506
|
+
_g[$k]="$cv"
|
|
507
|
+
done
|
|
508
|
+
_g[$key]="$value"
|
|
509
|
+
|
|
510
|
+
local tmp
|
|
511
|
+
tmp=$(mktemp "${TMPDIR:-/tmp}/comate-gate.XXXXXX") || die "$COMATE_ENV" "ERROR: mktemp failed"
|
|
512
|
+
{
|
|
513
|
+
printf '# comate PRD gate — flat key:value only, no nesting\n'
|
|
514
|
+
for k in "${GATE_FIELD_ORDER[@]}"; do
|
|
515
|
+
printf '%s: %s\n' "$k" "${_g[$k]:-null}"
|
|
516
|
+
done
|
|
517
|
+
} > "$tmp"
|
|
518
|
+
mv "$tmp" "$file" || { rm -f "$tmp"; die "$COMATE_ENV" "ERROR: failed to replace $file"; }
|
|
519
|
+
|
|
520
|
+
local readback; readback=$(yaml_get "$file" "$key")
|
|
521
|
+
if [ "$readback" != "$value" ]; then
|
|
522
|
+
die "$COMATE_CORRUPT" "ERROR: gate write-back mismatch for '$key': wrote '$value', read '$readback'"
|
|
523
|
+
fi
|
|
524
|
+
}
|