flow-comet 1.6.3 → 1.6.4
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/.flow-comet/skills/flow-comet/INSTALLED_VERSION +1 -1
- package/.flow-comet/skills/flow-comet/scripts/comet-hook-guard.mjs +11 -13
- package/.flow-comet/skills/flow-comet/scripts/context-init.mjs +2 -2
- package/.flow-comet/skills/flow-comet/scripts/evolve.mjs +6 -6
- package/.flow-comet/skills/flow-comet/scripts/guard-self-test.mjs +67 -18878
- package/.flow-comet/skills/flow-comet/scripts/health.mjs +1 -1
- package/.flow-comet/skills/flow-comet/scripts/items/a.mjs +1030 -0
- package/.flow-comet/skills/flow-comet/scripts/items/b.mjs +830 -0
- package/.flow-comet/skills/flow-comet/scripts/items/c.mjs +781 -0
- package/.flow-comet/skills/flow-comet/scripts/items/d.mjs +99 -0
- package/.flow-comet/skills/flow-comet/scripts/items/e.mjs +185 -0
- package/.flow-comet/skills/flow-comet/scripts/items/f.mjs +90 -0
- package/.flow-comet/skills/flow-comet/scripts/items/g.mjs +59 -0
- package/.flow-comet/skills/flow-comet/scripts/items/h.mjs +815 -0
- package/.flow-comet/skills/flow-comet/scripts/items/i.mjs +77 -0
- package/.flow-comet/skills/flow-comet/scripts/items/j.mjs +75 -0
- package/.flow-comet/skills/flow-comet/scripts/items/k.mjs +1427 -0
- package/.flow-comet/skills/flow-comet/scripts/items/l.mjs +275 -0
- package/.flow-comet/skills/flow-comet/scripts/items/m.mjs +614 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/count-derivation.mjs +97 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/fix-loop-node.mjs +196 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-evidence-gates.mjs +553 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-gates.mjs +837 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-routing.mjs +404 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-state-io.mjs +404 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-template-fidelity.mjs +302 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-uidesign.mjs +133 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/reentry-node.mjs +237 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/replan-node.mjs +209 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-branch.mjs +49 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-bridgecheck.mjs +201 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-admin.mjs +141 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-flow.mjs +700 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-recovery.mjs +578 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-determine.mjs +52 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-evolve-hint.mjs +55 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-explain.mjs +106 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-intelscan.mjs +58 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-io.mjs +147 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/state-skillmarkers.mjs +189 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/system-fixtures.mjs +1441 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/task-graph.mjs +471 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/test-assertions.mjs +509 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/test-fixtures.mjs +1228 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/test-helpers.mjs +237 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/text-anchor-checks.mjs +2484 -0
- package/.flow-comet/skills/flow-comet/scripts/protocol-utils.mjs +2 -2
- package/.flow-comet/skills/flow-comet/scripts/route-node.mjs +72 -1123
- package/.flow-comet/skills/flow-comet/scripts/scenarios/a.mjs +966 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/b.mjs +1233 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/c.mjs +1382 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/d.mjs +483 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/e.mjs +1388 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/f.mjs +1466 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/g.mjs +1364 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/h.mjs +1287 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/i.mjs +1436 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/j.mjs +1384 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/k.mjs +1338 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/l.mjs +1484 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/m.mjs +971 -0
- package/.flow-comet/skills/flow-comet/scripts/state-schema.mjs +1 -1
- package/.flow-comet/skills/flow-comet/scripts/system-test.mjs +58 -7559
- package/.flow-comet/skills/flow-comet/scripts/time-utils.mjs +4 -4
- package/.flow-comet/skills/flow-comet/scripts/workflow-guard.mjs +151 -2476
- package/.flow-comet/skills/flow-comet/scripts/workflow-handoff.mjs +5 -5
- package/.flow-comet/skills/flow-comet/scripts/workflow-state.mjs +27 -2190
- package/.flow-comet/skills/flow-comet-plan/GUIDANCE.md +1 -1
- package/README.md +52 -69
- package/package.json +3 -2
- package/scripts/dsh-bridge.mjs +2 -2
- package/scripts/lib/installer-cleanup.mjs +152 -0
- package/scripts/lib/installer-flowkit.mjs +119 -0
- package/scripts/lib/installer-hooks.mjs +363 -0
- package/scripts/lib/installer-loader.mjs +220 -0
- package/scripts/lib/installer-migrate.mjs +236 -0
- package/scripts/lib/installer-platforms.mjs +314 -0
- package/scripts/prepare-env.mjs +21 -1313
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// items/d.mjs — D 组条目(hook 写白名单)
|
|
2
|
+
//
|
|
3
|
+
// 组文件约定:`export const ENTRIES = [...]`(元素含 name 与 run;计数派生按此聚合,见 lib/count-derivation.mjs)。
|
|
4
|
+
// 跨组共用夹具在 lib/system-fixtures.mjs(组文件只承载 ENTRIES 数据与组内私有夹具,组文件之间零 import)。
|
|
5
|
+
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { assertExit, assertOut, baseState, runHook, runState, writeState } from '../lib/test-helpers.mjs';
|
|
8
|
+
import { CHANGE_ID, readStateFile } from '../lib/system-fixtures.mjs';
|
|
9
|
+
|
|
10
|
+
export const ENTRIES = [
|
|
11
|
+
// ---------- D. hook 写白名单 ----------
|
|
12
|
+
|
|
13
|
+
{
|
|
14
|
+
name: 'D1 hook:open 阶段工件放行与源码拦截',
|
|
15
|
+
run: (dir) => {
|
|
16
|
+
assertExit(runState(['init', CHANGE_ID], dir), 0);
|
|
17
|
+
// 工件放行
|
|
18
|
+
const ok = runHook(['before_tool'], dir,
|
|
19
|
+
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, '.specs', CHANGE_ID, 'CHANGE.md') } });
|
|
20
|
+
assertExit(ok, 0);
|
|
21
|
+
assertOut(ok, 'workflow-hook-guard-ok');
|
|
22
|
+
assertOut(ok, 'NODE: open');
|
|
23
|
+
// 源码拦截(exit 2)
|
|
24
|
+
const blocked = runHook(['before_tool'], dir,
|
|
25
|
+
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, 'src', 'evil.py') } });
|
|
26
|
+
assertExit(blocked, 2);
|
|
27
|
+
assertOut(blocked, 'BLOCKED: phase "open" 不允许写入');
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
{
|
|
32
|
+
name: 'D2 hook:execute 按执行模式收窄(direct 放宽)',
|
|
33
|
+
run: (dir) => {
|
|
34
|
+
// subagent 模式:execute 协调者只写 .specs/ → 写源码拦截
|
|
35
|
+
const st = baseState('execute');
|
|
36
|
+
st.status = 'running';
|
|
37
|
+
writeState(dir, st);
|
|
38
|
+
const blocked = runHook(['before_tool'], dir,
|
|
39
|
+
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, 'src', 'evil.py') } });
|
|
40
|
+
assertExit(blocked, 2);
|
|
41
|
+
assertOut(blocked, 'BLOCKED: phase "execute" 不允许写入');
|
|
42
|
+
// subagent 模式:写工件放行
|
|
43
|
+
const ok = runHook(['before_tool'], dir,
|
|
44
|
+
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, '.specs', CHANGE_ID, 'T01-SUMMARY.md') } });
|
|
45
|
+
assertExit(ok, 0);
|
|
46
|
+
assertOut(ok, 'NODE: execute');
|
|
47
|
+
// direct 模式(逃生口):主代理直写源码放行
|
|
48
|
+
const stDirect = readStateFile(dir);
|
|
49
|
+
stDirect.executionMode = 'direct';
|
|
50
|
+
stDirect.directOverride = true;
|
|
51
|
+
writeState(dir, stDirect);
|
|
52
|
+
const direct = runHook(['before_tool'], dir,
|
|
53
|
+
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, 'src', 'evil.py') } });
|
|
54
|
+
assertExit(direct, 0);
|
|
55
|
+
assertOut(direct, 'workflow-hook-guard-ok');
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
{
|
|
60
|
+
name: 'D3 hook:归档阶段白名单与完成态放行',
|
|
61
|
+
run: (dir) => {
|
|
62
|
+
const st = baseState('archive');
|
|
63
|
+
st.status = 'running';
|
|
64
|
+
writeState(dir, st);
|
|
65
|
+
// 归档路径放行
|
|
66
|
+
const ok = runHook(['before_tool'], dir,
|
|
67
|
+
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, '.specs', 'archive', '2026-08-11-' + CHANGE_ID, 'CHANGE.md') } });
|
|
68
|
+
assertExit(ok, 0);
|
|
69
|
+
assertOut(ok, 'NODE: archive');
|
|
70
|
+
// 归档流程写 change 目录工件(遗留清单 KNOWN-ISSUES.md 先写后移)放行——
|
|
71
|
+
// 修复前白名单仅 .specs/archive/ 导致按文档流程被 BLOCK(此处应 RED)
|
|
72
|
+
const okChange = runHook(['before_tool'], dir,
|
|
73
|
+
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, '.specs', CHANGE_ID, 'KNOWN-ISSUES.md') } });
|
|
74
|
+
assertExit(okChange, 0);
|
|
75
|
+
assertOut(okChange, 'NODE: archive');
|
|
76
|
+
// 白名单收窄:归档阶段仅遗留清单可写——change 目录其他工件(如 TASK.md)应 BLOCK
|
|
77
|
+
// (放宽到整个 change 目录会让归档阶段可改任意工件且无校验——防线变宽)
|
|
78
|
+
const blockedArtifact = runHook(['before_tool'], dir,
|
|
79
|
+
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, '.specs', CHANGE_ID, 'TASK.md') } });
|
|
80
|
+
assertExit(blockedArtifact, 2);
|
|
81
|
+
assertOut(blockedArtifact, 'BLOCKED');
|
|
82
|
+
// 归档阶段写源码拦截
|
|
83
|
+
const blocked = runHook(['before_tool'], dir,
|
|
84
|
+
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, 'src', 'evil.py') } });
|
|
85
|
+
assertExit(blocked, 2);
|
|
86
|
+
// 完成态(归档后,活跃项目已清空)→ 无活跃工作流放行
|
|
87
|
+
const done = readStateFile(dir);
|
|
88
|
+
done.status = 'completed';
|
|
89
|
+
done.activeChange = null;
|
|
90
|
+
done.currentNode = null;
|
|
91
|
+
writeState(dir, done);
|
|
92
|
+
const after = runHook(['before_tool'], dir,
|
|
93
|
+
{ tool_name: 'Write', tool_input: { file_path: path.join(dir, 'anything.md') } });
|
|
94
|
+
assertExit(after, 0);
|
|
95
|
+
assertOut(after, 'no active workflow');
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
];
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// items/e.mjs — E 组条目(自定义协议)
|
|
2
|
+
//
|
|
3
|
+
// 组文件约定:`export const ENTRIES = [...]`(元素含 name 与 run;计数派生按此聚合,见 lib/count-derivation.mjs)。
|
|
4
|
+
// 跨组共用夹具在 lib/system-fixtures.mjs(组文件只承载 ENTRIES 数据与组内私有夹具,组文件之间零 import)。
|
|
5
|
+
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { assertExit, assertNotOut, assertOut, runGuard, runState, writeFile } from '../lib/test-helpers.mjs';
|
|
9
|
+
import { readStateFile } from '../lib/system-fixtures.mjs';
|
|
10
|
+
|
|
11
|
+
// 自定义协议(compose-demo):3 节点 brainstorm/tdd/codereview(避开内置 8 节点 id)——
|
|
12
|
+
// 协议数据化路由 + 通用层防线对自定义节点生效;无 writeWhitelist(hook 回退内置缺省表)
|
|
13
|
+
function customProtocol() {
|
|
14
|
+
return {
|
|
15
|
+
schemaVersion: 1,
|
|
16
|
+
kind: 'workflow-kernel',
|
|
17
|
+
name: 'compose-demo',
|
|
18
|
+
goal: '系统测试自定义协议:数据化路由 + 声明机制 + 通用层防线。',
|
|
19
|
+
nodes: [
|
|
20
|
+
{
|
|
21
|
+
id: 'brainstorm',
|
|
22
|
+
label: 'Brainstorm',
|
|
23
|
+
kind: 'control',
|
|
24
|
+
responsibility: '产出 notes.md。',
|
|
25
|
+
outputSchemas: ['compose.notes.v1'],
|
|
26
|
+
requiredSkillCalls: [],
|
|
27
|
+
augmentations: [],
|
|
28
|
+
disabled: false,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'tdd',
|
|
32
|
+
label: 'TDD',
|
|
33
|
+
kind: 'control',
|
|
34
|
+
responsibility: '产出 *-SUMMARY.md。',
|
|
35
|
+
outputSchemas: ['compose.tdd.v1'],
|
|
36
|
+
requiredSkillCalls: [],
|
|
37
|
+
augmentations: [],
|
|
38
|
+
disabled: false,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'codereview',
|
|
42
|
+
label: 'Code Review',
|
|
43
|
+
kind: 'control',
|
|
44
|
+
responsibility: '产出 verdict.md。',
|
|
45
|
+
outputSchemas: ['compose.verdict.v1'],
|
|
46
|
+
requiredSkillCalls: [],
|
|
47
|
+
augmentations: [],
|
|
48
|
+
disabled: false,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
outputSchemas: [
|
|
52
|
+
{
|
|
53
|
+
id: 'compose.notes.v1',
|
|
54
|
+
description: 'notes.md',
|
|
55
|
+
artifacts: [
|
|
56
|
+
{
|
|
57
|
+
id: 'notes',
|
|
58
|
+
kind: 'file',
|
|
59
|
+
required: true,
|
|
60
|
+
paths: ['<change-id>/notes.md'],
|
|
61
|
+
pathBase: 'specs-root',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
evidence: [{ id: 'notes-summary', required: true }],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 'compose.tdd.v1',
|
|
68
|
+
description: '*-SUMMARY.md',
|
|
69
|
+
artifacts: [
|
|
70
|
+
{
|
|
71
|
+
id: 'summaries',
|
|
72
|
+
kind: 'file',
|
|
73
|
+
required: true,
|
|
74
|
+
paths: ['<change-id>/*-SUMMARY.md'],
|
|
75
|
+
pathBase: 'specs-root',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
evidence: [{ id: 'tdd-summary', required: true }],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'compose.verdict.v1',
|
|
82
|
+
description: 'verdict.md',
|
|
83
|
+
artifacts: [
|
|
84
|
+
{
|
|
85
|
+
id: 'verdict',
|
|
86
|
+
kind: 'file',
|
|
87
|
+
required: true,
|
|
88
|
+
paths: ['<change-id>/verdict.md'],
|
|
89
|
+
pathBase: 'specs-root',
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
evidence: [{ id: 'verdict-summary', required: true }],
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
state: {
|
|
96
|
+
kind: 'workflow-run',
|
|
97
|
+
statePath: '.flow-comet/flow-comet-state.json',
|
|
98
|
+
currentNodeField: 'currentNode',
|
|
99
|
+
completedNodesField: 'completedNodes',
|
|
100
|
+
evidenceField: 'evidence',
|
|
101
|
+
},
|
|
102
|
+
edges: [],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// 含 requiredSkillCalls 的变体:brainstorm 带 main scope 绑定(协调者加载 → 需 skill-load 声明标记)
|
|
107
|
+
function customProtocolWithSkillCall() {
|
|
108
|
+
const p = customProtocol();
|
|
109
|
+
p.nodes[0].requiredSkillCalls = [{ skill: 'flow-comet-brainstorm', scope: 'main' }];
|
|
110
|
+
return p;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 写入自定义协议文件,返回绝对路径
|
|
114
|
+
function writeCustomProtocol(dir, withSkillCall = false) {
|
|
115
|
+
const proto = withSkillCall ? customProtocolWithSkillCall() : customProtocol();
|
|
116
|
+
const file = path.join(dir, withSkillCall ? 'custom-protocol-skill.json' : 'custom-protocol.json');
|
|
117
|
+
fs.writeFileSync(file, JSON.stringify(proto, null, 2) + '\n', 'utf8');
|
|
118
|
+
return file;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export const ENTRIES = [
|
|
122
|
+
// ---------- E. 自定义协议 ----------
|
|
123
|
+
|
|
124
|
+
{
|
|
125
|
+
name: 'E1 自定义协议:加载路由与节点推导',
|
|
126
|
+
run: (dir) => {
|
|
127
|
+
const custom = writeCustomProtocol(dir);
|
|
128
|
+
// init 按协议首节点
|
|
129
|
+
const init = runState(['init', 'cp-demo', '--protocol', custom], dir);
|
|
130
|
+
assertExit(init, 0);
|
|
131
|
+
assertOut(init, 'NODE: brainstorm');
|
|
132
|
+
const st = readStateFile(dir);
|
|
133
|
+
if (st.currentNode !== 'brainstorm') throw new Error('init currentNode 应为协议首节点 brainstorm');
|
|
134
|
+
// 无产物 → 首节点;仅 notes.md → 第二节点;产物齐全 → 最后节点
|
|
135
|
+
const s1 = runState(['status', '--protocol', custom], dir);
|
|
136
|
+
assertExit(s1, 0);
|
|
137
|
+
assertOut(s1, '"currentNode": "brainstorm"');
|
|
138
|
+
writeFile(dir, '.specs/cp-demo/notes.md', '# notes\n');
|
|
139
|
+
const s2 = runState(['status', '--protocol', custom], dir);
|
|
140
|
+
assertExit(s2, 0);
|
|
141
|
+
assertOut(s2, '"currentNode": "tdd"');
|
|
142
|
+
writeFile(dir, '.specs/cp-demo/T01-SUMMARY.md', '# T01-SUMMARY\n');
|
|
143
|
+
writeFile(dir, '.specs/cp-demo/verdict.md', '# verdict\n');
|
|
144
|
+
const s3 = runState(['status', '--protocol', custom], dir);
|
|
145
|
+
assertExit(s3, 0);
|
|
146
|
+
assertOut(s3, '"currentNode": "codereview"');
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
{
|
|
151
|
+
name: 'E2 自定义协议:声明机制与出口全链路(含技能绑定)',
|
|
152
|
+
run: (dir) => {
|
|
153
|
+
const custom = writeCustomProtocol(dir, true);
|
|
154
|
+
assertExit(runState(['init', 'cp-skill', '--protocol', custom], dir), 0);
|
|
155
|
+
const env = { FLOW_COMET_PROTOCOL: custom };
|
|
156
|
+
// 自定义节点 skill-load 声明(协议节点集合动态校验)
|
|
157
|
+
const sl = runState(['skill-load', 'brainstorm', 'flow-comet-brainstorm'], dir, env);
|
|
158
|
+
assertExit(sl, 0);
|
|
159
|
+
assertOut(sl, 'SKILL-LOAD: brainstorm flow-comet-brainstorm');
|
|
160
|
+
// 自定义节点 record(main scope 绑定 + 声明标记 → 通过)
|
|
161
|
+
const rec = runState(['record', 'brainstorm', JSON.stringify({ summary: 'brainstorm done', completedChecks: ['required-skill:brainstorm.flow-comet-brainstorm'] })], dir, env);
|
|
162
|
+
assertExit(rec, 0);
|
|
163
|
+
assertOut(rec, 'EVIDENCE: brainstorm');
|
|
164
|
+
// 出口:产物齐 + 诱饵内置工件缺段 → 通过且不误触发内置特化校验
|
|
165
|
+
writeFile(dir, '.specs/cp-skill/notes.md', '# notes\n');
|
|
166
|
+
writeFile(dir, '.specs/cp-skill/CHANGE.md', '# CHANGE\n\n## 变更目标\n\n## 方案\n');
|
|
167
|
+
writeFile(dir, '.specs/cp-skill/REQUIREMENT.md', '# REQUIREMENT\n\n## 用户故事\n\n## 需求分析\n');
|
|
168
|
+
assertExit(runGuard(['entry', 'brainstorm'], dir, env), 0);
|
|
169
|
+
const exitRes = runGuard(['exit', 'brainstorm', '--apply'], dir, env);
|
|
170
|
+
assertExit(exitRes, 0);
|
|
171
|
+
assertOut(exitRes, 'ALL CHECKS PASSED');
|
|
172
|
+
assertNotOut(exitRes, '缺必填段');
|
|
173
|
+
assertNotOut(exitRes, '缺少验收标准');
|
|
174
|
+
const st = readStateFile(dir);
|
|
175
|
+
if (!st.completedNodes.includes('brainstorm') || st.currentNode !== 'tdd') {
|
|
176
|
+
throw new Error('apply 后应完成 brainstorm 并推进到 tdd: ' + JSON.stringify({ completedNodes: st.completedNodes, currentNode: st.currentNode }));
|
|
177
|
+
}
|
|
178
|
+
// 协议 env 加载(无 --protocol CLI)同样生效
|
|
179
|
+
const envLoad = runGuard(['exit', 'bogus'], dir, env);
|
|
180
|
+
assertExit(envLoad, 1);
|
|
181
|
+
assertOut(envLoad, 'Unknown workflow Node');
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
];
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// items/f.mjs — F 组条目(自动初始化)
|
|
2
|
+
//
|
|
3
|
+
// 组文件约定:`export const ENTRIES = [...]`(元素含 name 与 run;计数派生按此聚合,见 lib/count-derivation.mjs)。
|
|
4
|
+
// 跨组共用夹具在 lib/system-fixtures.mjs(组文件只承载 ENTRIES 数据与组内私有夹具,组文件之间零 import)。
|
|
5
|
+
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { assertExit, assertNotOut, assertOut, baseState, runState, writeFile, writeState } from '../lib/test-helpers.mjs';
|
|
9
|
+
import { CHANGE_ID, readStateFile } from '../lib/system-fixtures.mjs';
|
|
10
|
+
|
|
11
|
+
// CONTEXT 7 段完整模板(通过校验的形态)
|
|
12
|
+
const CONTEXT_FULL =
|
|
13
|
+
'# CONTEXT\n## 项目概要\nx\n## 技术栈\nx\n## 域语言\n| 术语 | 定义 |\n|---|---|\n| 例 | 定义 |\n' +
|
|
14
|
+
'## 已锁决策\n- [2026-08-01] 决策一\n## 默认偏好\nx\n## 既有抽象索引\nx\n' +
|
|
15
|
+
'## intel-scan 元数据\n- **last_intel_scan**: x\n- **scanner**: x\n- **下次重扫建议**: x\n';
|
|
16
|
+
|
|
17
|
+
export const ENTRIES = [
|
|
18
|
+
// ---------- F. 自动初始化 ----------
|
|
19
|
+
|
|
20
|
+
{
|
|
21
|
+
name: 'F1 初始化检测:上下文缺失提示且不自动生成',
|
|
22
|
+
run: (dir) => {
|
|
23
|
+
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
24
|
+
const res = runState(['init', CHANGE_ID], dir);
|
|
25
|
+
assertExit(res, 0);
|
|
26
|
+
assertOut(res, 'INIT-NEEDED');
|
|
27
|
+
if (fs.existsSync(path.join(dir, '.specs', 'CONTEXT.md'))) {
|
|
28
|
+
throw new Error('CONTEXT 不应由脚本自动生成(生成职责在 agent)');
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
{
|
|
34
|
+
name: 'F2 初始化检测:跳过记忆',
|
|
35
|
+
run: (dir) => {
|
|
36
|
+
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
37
|
+
const first = runState(['init', CHANGE_ID, '--init-skip'], dir);
|
|
38
|
+
assertExit(first, 0);
|
|
39
|
+
assertOut(first, 'INIT-SKIPPED');
|
|
40
|
+
const st1 = readStateFile(dir);
|
|
41
|
+
if (st1.ai_context_doc !== 'none') throw new Error('跳过后 ai_context_doc 应为 none');
|
|
42
|
+
// 下次 init(新 id)尊重既有决策 → 静默
|
|
43
|
+
const second = runState(['init', CHANGE_ID + '-2'], dir);
|
|
44
|
+
assertExit(second, 0);
|
|
45
|
+
assertNotOut(second, 'INIT-NEEDED');
|
|
46
|
+
assertNotOut(second, 'INIT-HINT');
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
{
|
|
51
|
+
name: 'F3 初始化检测:新鲜上下文静默',
|
|
52
|
+
run: (dir) => {
|
|
53
|
+
writeState(dir, { ...baseState('open'), last_intel_scan: new Date(Date.now() - 10 * 864e5).toISOString() });
|
|
54
|
+
writeFile(dir, '.specs/CONTEXT.md', '# CONTEXT\n## 项目概要\nx\n');
|
|
55
|
+
const res = runState(['init', CHANGE_ID], dir);
|
|
56
|
+
assertExit(res, 0);
|
|
57
|
+
assertNotOut(res, 'INIT-NEEDED');
|
|
58
|
+
assertNotOut(res, 'INIT-HINT');
|
|
59
|
+
assertOut(res, 'Initialized: ' + CHANGE_ID);
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
{
|
|
64
|
+
name: 'F4 初始化检测:生成协作全链路',
|
|
65
|
+
run: (dir) => {
|
|
66
|
+
writeFile(dir, 'package.json', '{"name":"x"}');
|
|
67
|
+
// ① 缺失 + 授权 → 生成指引,不生成不写扫描时间
|
|
68
|
+
const gen = runState(['init', CHANGE_ID, '--init-context'], dir);
|
|
69
|
+
assertExit(gen, 0);
|
|
70
|
+
assertOut(gen, 'INIT-GENERATE');
|
|
71
|
+
if (fs.existsSync(path.join(dir, '.specs', 'CONTEXT.md'))) throw new Error('CONTEXT 不应由脚本生成');
|
|
72
|
+
let st = readStateFile(dir);
|
|
73
|
+
if (st.last_intel_scan) throw new Error('校验通过前不应写扫描时间');
|
|
74
|
+
// ② agent 生成 7 段模板后重跑 → 校验通过 + 记录扫描时间
|
|
75
|
+
writeFile(dir, '.specs/CONTEXT.md', CONTEXT_FULL);
|
|
76
|
+
const done = runState(['init', CHANGE_ID, '--init-context'], dir);
|
|
77
|
+
assertExit(done, 0);
|
|
78
|
+
assertOut(done, 'INIT-DONE');
|
|
79
|
+
st = readStateFile(dir);
|
|
80
|
+
if (!st.last_intel_scan) throw new Error('校验通过后应写扫描时间');
|
|
81
|
+
// ③ 已存在但缺段 → 重写指引,不记录新扫描时间(保持既有)
|
|
82
|
+
writeFile(dir, '.specs/CONTEXT.md', '# CONTEXT\n## 项目概要\nx\n');
|
|
83
|
+
const failed = runState(['init', CHANGE_ID, '--init-context'], dir);
|
|
84
|
+
assertExit(failed, 0);
|
|
85
|
+
assertOut(failed, 'INIT-VALIDATE-FAILED');
|
|
86
|
+
assertOut(failed, '重写');
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// items/g.mjs — G 组条目(分支模式)
|
|
2
|
+
//
|
|
3
|
+
// 组文件约定:`export const ENTRIES = [...]`(元素含 name 与 run;计数派生按此聚合,见 lib/count-derivation.mjs)。
|
|
4
|
+
// 跨组共用夹具在 lib/system-fixtures.mjs(组文件只承载 ENTRIES 数据与组内私有夹具,组文件之间零 import)。
|
|
5
|
+
|
|
6
|
+
import { execFileSync, spawnSync } from 'child_process';
|
|
7
|
+
import { assertExit, assertOut, baseState, runGuard, runState, writeFile, writeState } from '../lib/test-helpers.mjs';
|
|
8
|
+
import { CHANGE_ID, gitBranch, gitInit } from '../lib/system-fixtures.mjs';
|
|
9
|
+
|
|
10
|
+
export const ENTRIES = [
|
|
11
|
+
// ---------- G. 分支模式 ----------
|
|
12
|
+
|
|
13
|
+
{
|
|
14
|
+
name: 'G1 分支模式:init 建分支与一致性',
|
|
15
|
+
run: (dir) => {
|
|
16
|
+
gitInit(dir);
|
|
17
|
+
assertExit(runState(['init', 'g1-br'], dir), 0);
|
|
18
|
+
if (gitBranch(dir) !== 'change/g1-br') throw new Error('期望分支 change/g1-br,实际 ' + gitBranch(dir));
|
|
19
|
+
const status = runState(['status'], dir);
|
|
20
|
+
assertExit(status, 0);
|
|
21
|
+
assertOut(status, 'BRANCH: change/g1-br | 一致性: ok');
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
{
|
|
26
|
+
name: 'G2 分支模式:归档入口分支校验',
|
|
27
|
+
run: (dir) => {
|
|
28
|
+
gitInit(dir);
|
|
29
|
+
const st = baseState('archive');
|
|
30
|
+
st.branchMode = true;
|
|
31
|
+
writeState(dir, st);
|
|
32
|
+
// 非 change/<id> 分支 → 拦截
|
|
33
|
+
const blocked = runGuard(['entry', 'archive'], dir);
|
|
34
|
+
assertExit(blocked, 1);
|
|
35
|
+
assertOut(blocked, 'BLOCKED');
|
|
36
|
+
assertOut(blocked, '归档必须在 change/' + CHANGE_ID + ' 分支上进行');
|
|
37
|
+
// 切到正确分支 → 通过
|
|
38
|
+
execFileSync('git', ['checkout', '-b', 'change/' + CHANGE_ID], { cwd: dir, stdio: 'ignore' });
|
|
39
|
+
const ok = runGuard(['entry', 'archive'], dir);
|
|
40
|
+
assertExit(ok, 0);
|
|
41
|
+
assertOut(ok, 'ENTRY OK: archive');
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
{
|
|
46
|
+
name: 'G3 分支模式:一致性失配警告',
|
|
47
|
+
run: (dir) => {
|
|
48
|
+
gitInit(dir);
|
|
49
|
+
execFileSync('git', ['checkout', '-b', 'topic-x'], { cwd: dir, stdio: 'ignore' });
|
|
50
|
+
writeState(dir, { ...baseState('open'), branchPrefix: 'change/' });
|
|
51
|
+
writeFile(dir, '.specs/' + CHANGE_ID + '/CHANGE.md', '# CHANGE\n## Why\nx\n');
|
|
52
|
+
const status = runState(['status'], dir);
|
|
53
|
+
assertExit(status, 0);
|
|
54
|
+
assertOut(status, '一致性: mismatch');
|
|
55
|
+
assertOut(status, 'WARN: 分支与 activeChange 不一致');
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
];
|