flow-comet 1.6.4 → 1.6.5
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/SKILL.md +21 -3
- package/.flow-comet/skills/flow-comet/reference/artifact-template-overlay.md +154 -0
- package/.flow-comet/skills/flow-comet/reference/artifact-templates.json +387 -0
- package/.flow-comet/skills/flow-comet/reference/entry-detail.md +8 -2
- package/.flow-comet/skills/flow-comet/reference/workflow-protocol.json +22 -0
- package/.flow-comet/skills/flow-comet/scripts/evolve.mjs +174 -0
- package/.flow-comet/skills/flow-comet/scripts/guard-self-test.mjs +3 -1
- package/.flow-comet/skills/flow-comet/scripts/health.mjs +28 -4
- package/.flow-comet/skills/flow-comet/scripts/items/a.mjs +41 -18
- package/.flow-comet/skills/flow-comet/scripts/items/b.mjs +16 -16
- package/.flow-comet/skills/flow-comet/scripts/items/c.mjs +6 -6
- package/.flow-comet/skills/flow-comet/scripts/items/h.mjs +9 -7
- package/.flow-comet/skills/flow-comet/scripts/items/l.mjs +2 -2
- package/.flow-comet/skills/flow-comet/scripts/items/m.mjs +17 -13
- package/.flow-comet/skills/flow-comet/scripts/items/n.mjs +154 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-artifact-skeleton.mjs +406 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-evidence-gates.mjs +206 -3
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-gates.mjs +458 -60
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-routing.mjs +38 -58
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-template-fidelity.mjs +642 -230
- package/.flow-comet/skills/flow-comet/scripts/lib/guard-uidesign.mjs +85 -14
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-admin.mjs +43 -5
- package/.flow-comet/skills/flow-comet/scripts/lib/state-commands-flow.mjs +15 -1
- package/.flow-comet/skills/flow-comet/scripts/lib/state-explain.mjs +18 -1
- package/.flow-comet/skills/flow-comet/scripts/lib/state-skillmarkers.mjs +60 -0
- package/.flow-comet/skills/flow-comet/scripts/lib/system-fixtures.mjs +73 -9
- package/.flow-comet/skills/flow-comet/scripts/lib/test-fixtures.mjs +21 -1
- package/.flow-comet/skills/flow-comet/scripts/lib/text-anchor-checks.mjs +9 -0
- package/.flow-comet/skills/flow-comet/scripts/protocol-utils.mjs +212 -0
- package/.flow-comet/skills/flow-comet/scripts/scenarios/a.mjs +15 -5
- package/.flow-comet/skills/flow-comet/scripts/scenarios/c.mjs +4 -4
- package/.flow-comet/skills/flow-comet/scripts/scenarios/e.mjs +20 -10
- package/.flow-comet/skills/flow-comet/scripts/scenarios/g.mjs +4 -1
- package/.flow-comet/skills/flow-comet/scripts/scenarios/j.mjs +6 -6
- package/.flow-comet/skills/flow-comet/scripts/scenarios/l.mjs +13 -5
- package/.flow-comet/skills/flow-comet/scripts/scenarios/n.mjs +2125 -0
- package/.flow-comet/skills/flow-comet/scripts/system-test.mjs +6 -5
- package/.flow-comet/skills/flow-comet/scripts/workflow-guard.mjs +74 -2
- package/.flow-comet/skills/flow-comet-archive/SKILL.md +6 -2
- package/.flow-comet/skills/flow-comet-change/SKILL.md +6 -2
- package/.flow-comet/skills/flow-comet-design/GUIDANCE.md +13 -3
- package/.flow-comet/skills/flow-comet-design/SKILL.md +15 -8
- package/.flow-comet/skills/flow-comet-dev/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-evolve/SKILL.md +1 -0
- package/.flow-comet/skills/flow-comet-execute/SKILL.md +13 -10
- package/.flow-comet/skills/flow-comet-health/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-integration/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-open/GUIDANCE.md +14 -4
- package/.flow-comet/skills/flow-comet-open/SKILL.md +11 -9
- package/.flow-comet/skills/flow-comet-plan/GUIDANCE.md +13 -3
- package/.flow-comet/skills/flow-comet-plan/SKILL.md +11 -7
- package/.flow-comet/skills/flow-comet-requirement/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-review/SKILL.md +15 -9
- package/.flow-comet/skills/flow-comet-subagent-execute/GUIDANCE.md +13 -3
- package/.flow-comet/skills/flow-comet-subagent-execute/SKILL.md +11 -8
- package/.flow-comet/skills/flow-comet-task/SKILL.md +1 -1
- package/.flow-comet/skills/flow-comet-test/SKILL.md +6 -2
- package/.flow-comet/skills/flow-comet-ui-design/SKILL.md +2 -2
- package/.flow-comet/skills/flow-comet-verify/SKILL.md +12 -8
- package/README.md +3 -3
- package/package.json +1 -1
- package/scripts/dsh-bridge.mjs +2 -2
- package/scripts/lib/installer-flowkit.mjs +43 -3
|
@@ -10,13 +10,18 @@
|
|
|
10
10
|
// 按 `<nodeId>.<skill>` 键控,工件门与出口自动补写共用 applicabilityGatedBinding 查询。
|
|
11
11
|
//
|
|
12
12
|
// 判据必须结构性可判:CHANGE.md 的「视觉调性」段在场且段内不含**结构形态**的「不适用」标记 ⇒
|
|
13
|
-
//
|
|
14
|
-
//
|
|
13
|
+
// 前端;段内以结构形态标注 ⇒ 非前端。段**缺席**只在旧 change 上沿用「判非前端」的兼容口径——
|
|
14
|
+
// 新 change 由 open 出口按模板条件段拦(标题必须在场),此处缺席即拦,不再默认判非前端
|
|
15
|
+
// (否则「漏写段」会被静默翻译成一个更弱的门)。
|
|
16
|
+
//
|
|
17
|
+
// UI-DESIGN.md 在场时,其模板结构(frontmatter 8 键 / H2 骨架 / 结构型 H3)由产出物模板结构门禁
|
|
18
|
+
// 统一校验(与七类产出物同一实现,不在这里另写一份段名校验)。
|
|
15
19
|
|
|
16
20
|
import { promises as fs } from 'fs';
|
|
17
21
|
import path from 'path';
|
|
18
22
|
import { runRoot, fileExists } from './guard-state-io.mjs';
|
|
19
23
|
import { isNewChange, templateSectionPatterns, TEMPLATE_FALLBACK_SECTION_PATTERNS } from './guard-routing.mjs';
|
|
24
|
+
import { assessArtifact, evaluateArtifact, reportArtifactStructure } from './guard-template-fidelity.mjs';
|
|
20
25
|
|
|
21
26
|
export const UI_DESIGN_SKILL = 'flow-comet-ui-design';
|
|
22
27
|
const APPLICABILITY_GATED_BINDINGS = new Set(['design.' + UI_DESIGN_SKILL]);
|
|
@@ -40,17 +45,26 @@ const TONE_MARKER_FIELD_VALUE = new RegExp(String.raw`(?:^|[\s|])(?:\*\*)?(?:`
|
|
|
40
45
|
+ TONE_MARKER_FIELD_LABELS + String.raw`)(?:\*\*)?\s*[::]\s*(?:\*\*)?`
|
|
41
46
|
+ VISUAL_TONE_NOT_APPLICABLE + String.raw`(?:\*\*)?` + TONE_MARKER_TAIL);
|
|
42
47
|
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
// 「视觉调性」段读取四态(区分「CHANGE.md 不存在」「模板整份缺失」「段缺席」「段在场」——四者判据
|
|
49
|
+
// 不同:文件不存在时本门没有输入,交给其余门禁处理;模板整份缺失时段名无从派生(no-basis,按
|
|
50
|
+
// 「未校验」显式跳过);段缺席才按 newChange 分级,C10)。
|
|
51
|
+
async function visualToneSectionState(changeName) {
|
|
52
|
+
if (!changeName) return { state: 'file-missing', body: null };
|
|
46
53
|
let text;
|
|
47
54
|
try {
|
|
48
55
|
text = await fs.readFile(path.join(runRoot, '.specs', changeName, 'CHANGE.md'), 'utf8');
|
|
49
56
|
} catch {
|
|
50
|
-
return null;
|
|
57
|
+
return { state: 'file-missing', body: null };
|
|
51
58
|
}
|
|
52
59
|
const headingPattern = (await templateSectionPatterns())
|
|
53
60
|
.pick('change', ['视觉调性'], TEMPLATE_FALLBACK_SECTION_PATTERNS.changeVisualTone);
|
|
61
|
+
// 整份模板缺席时 pick 返回可判别的跳过判据(TEMPLATE_SECTION_SKIP:skip 标记 + `.test` 恒真)。
|
|
62
|
+
// 不能拿它扫描:`.test` 恒真会让 CHANGE.md 的**首个小节**被当成「视觉调性」段(错的输入 = 错的
|
|
63
|
+
// 判据)。此时段名无从派生,显式报 no-basis 由调用方按「未校验(模板缺失)」处理;模板在场时
|
|
64
|
+
// pick 返回正则或 fallback,行为不变。
|
|
65
|
+
if (headingPattern !== null && typeof headingPattern === 'object' && headingPattern.skip === true) {
|
|
66
|
+
return { state: 'no-basis', body: null };
|
|
67
|
+
}
|
|
54
68
|
let body = null;
|
|
55
69
|
for (const line of String(text).replace(/\uFEFF/g, '').split(/\r?\n/)) {
|
|
56
70
|
if (/^##\s+/.test(line)) {
|
|
@@ -60,7 +74,7 @@ async function visualToneSectionBody(changeName) {
|
|
|
60
74
|
}
|
|
61
75
|
if (body !== null) body += line + '\n';
|
|
62
76
|
}
|
|
63
|
-
return body;
|
|
77
|
+
return body === null ? { state: 'section-missing', body: null } : { state: 'present', body };
|
|
64
78
|
}
|
|
65
79
|
|
|
66
80
|
// 段内负向标记命中(逐行判定——判据限段内):命中 → 返回命中行片段(去空白 + 超长截断),未命中
|
|
@@ -90,15 +104,36 @@ export function applicabilityGatedBinding(node, skill) {
|
|
|
90
104
|
return (node.requiredSkillCalls ?? []).find((call) => call.skill === skill && call.enforcement === 'guarded') ?? null;
|
|
91
105
|
}
|
|
92
106
|
|
|
93
|
-
// 前端判据:{ applicable, reason }——applicable=true 表示本 change
|
|
107
|
+
// 前端判据:{ applicable, reason, toneState }——applicable=true 表示本 change 判为前端项目。
|
|
108
|
+
// toneState 让调用方区分「段缺席」「模板整份缺失(no-basis,判据无依据)」与「段内标注不适用」:
|
|
109
|
+
// 段缺席在新 change 上必须拦(不能静默降级成非前端),最后一种是执行者显式声明,直接放行;
|
|
110
|
+
// no-basis 按「未校验」显式跳过,由调用方决定如何发声。
|
|
94
111
|
export async function frontendCriterion(changeName) {
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
|
|
112
|
+
const tone = await visualToneSectionState(changeName);
|
|
113
|
+
if (tone.state === 'file-missing') {
|
|
114
|
+
return { applicable: false, reason: 'CHANGE.md 不存在(本门无输入)', toneState: tone.state };
|
|
115
|
+
}
|
|
116
|
+
if (tone.state === 'no-basis') {
|
|
117
|
+
// 模板整份缺失 ⇒ 段名无从派生,本判据没有输入依据。不猜(不用首个小节冒充「视觉调性」段),
|
|
118
|
+
// 也不判前端:交给调用方按「未校验(模板缺失)」显式跳过(未验证 ≠ 通过,C9)。
|
|
119
|
+
return {
|
|
120
|
+
applicable: false,
|
|
121
|
+
reason: '「视觉调性」段判据无可依据(模板整份缺失,段名无从派生)',
|
|
122
|
+
toneState: tone.state,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (tone.state === 'section-missing') {
|
|
126
|
+
return { applicable: false, reason: '「视觉调性」段缺席', toneState: tone.state };
|
|
127
|
+
}
|
|
128
|
+
const hit = visualToneNotApplicableHit(tone.body);
|
|
98
129
|
if (hit !== null) {
|
|
99
|
-
return {
|
|
130
|
+
return {
|
|
131
|
+
applicable: false,
|
|
132
|
+
reason: '「视觉调性」段标注「不适用」(判非前端;命中片段: ' + hit + ')',
|
|
133
|
+
toneState: tone.state,
|
|
134
|
+
};
|
|
100
135
|
}
|
|
101
|
-
return { applicable: true, reason: '「视觉调性」段在场且未标注「不适用」(判前端;无结构形态标记)' };
|
|
136
|
+
return { applicable: true, reason: '「视觉调性」段在场且未标注「不适用」(判前端;无结构形态标记)', toneState: tone.state };
|
|
102
137
|
}
|
|
103
138
|
|
|
104
139
|
// design 出口 ui-design 工件门(按协议绑定键控:登记 ∧ 等级 = guarded ∧ 判据成立)——判据成立 ⇒
|
|
@@ -115,12 +150,48 @@ export async function checkUiDesignArtifact(node, state) {
|
|
|
115
150
|
return;
|
|
116
151
|
}
|
|
117
152
|
const frontend = await frontendCriterion(state.activeChange);
|
|
153
|
+
if (frontend.toneState === 'no-basis') {
|
|
154
|
+
// 模板整份缺失:适用性门控的输入判据不存在,按「未校验」显式跳过(不静默通过,也不误报非前端)。
|
|
155
|
+
console.error('UI-DESIGN 未校验(模板缺失)——flow-kit/templates/CHANGE.md 不在项目根,'
|
|
156
|
+
+ '「视觉调性」段名无从派生,适用性门控跳过');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (frontend.toneState === 'section-missing') {
|
|
160
|
+
// 段缺席不再默认判非前端:新 change 由 open 出口的条件段门禁拦,此处兜底同口径拦下,
|
|
161
|
+
// 要求执行者显式写「不适用」(缺席与声明不适用是两件事,只有后者是决策)。
|
|
162
|
+
const toneRecovery = '在 .specs/' + state.activeChange + '/CHANGE.md 的「视觉调性」段填写选定调性,'
|
|
163
|
+
+ '或以结构形态标注「不适用」(非前端项目),然后重试 exit design';
|
|
164
|
+
if (isNewChange(state)) {
|
|
165
|
+
console.error('BLOCKED: CHANGE.md 的「视觉调性」段缺席——新 change 须显式标注「不适用」或填写调性(段缺席不再默认判非前端)');
|
|
166
|
+
console.error('恢复: ' + toneRecovery);
|
|
167
|
+
process.exit(1);
|
|
168
|
+
}
|
|
169
|
+
console.error('UI-DESIGN: skipped(旧 change 兼容)——「视觉调性」段缺席,沿用旧口径判非前端');
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
118
172
|
if (!frontend.applicable) {
|
|
119
173
|
console.error('UI-DESIGN: skipped(非前端)——' + frontend.reason + ',不要求 UI-DESIGN.md');
|
|
120
174
|
return;
|
|
121
175
|
}
|
|
122
176
|
const artifact = path.join(runRoot, '.specs', state.activeChange, 'UI-DESIGN.md');
|
|
123
|
-
if (await fileExists(artifact))
|
|
177
|
+
if (await fileExists(artifact)) {
|
|
178
|
+
// 工件在场 → 按模板结构校验(frontmatter 8 键 / H2 骨架 / 结构型 H3);模板缺席只输出未校验行。
|
|
179
|
+
let text;
|
|
180
|
+
try {
|
|
181
|
+
text = await fs.readFile(artifact, 'utf8');
|
|
182
|
+
} catch {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
// 标题形态与 frontmatter 键都属于「模板结构」面:模板缺席时整体判「未校验(模板缺失)」,
|
|
186
|
+
// 不拿登记表形态去替模板做缺席判定(C9/AC-21 的统一口径)。
|
|
187
|
+
const { skeleton, derived, issues } = await evaluateArtifact('UI-DESIGN', text, { underivedPolicy: 'skip' });
|
|
188
|
+
await reportArtifactStructure({
|
|
189
|
+
changeDir: path.join(runRoot, '.specs', state.activeChange),
|
|
190
|
+
state,
|
|
191
|
+
assessments: [assessArtifact({ fileLabel: 'UI-DESIGN.md', skeleton, derived, issues })],
|
|
192
|
+
});
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
124
195
|
const recovery = '补 .specs/' + state.activeChange + '/UI-DESIGN.md(加载 ' + UI_DESIGN_SKILL + ' 并按其协议产出 design token / 反 AI-slop 自检),'
|
|
125
196
|
+ '或在 .specs/' + state.activeChange + '/CHANGE.md 的「视觉调性」段以结构形态标注「不适用」(非前端项目)后重试 exit design';
|
|
126
197
|
if (isNewChange(state)) {
|
|
@@ -4,6 +4,13 @@ import path from 'path';
|
|
|
4
4
|
import { isValidTimestamp } from '../time-utils.mjs';
|
|
5
5
|
import { verifyFailuresFor, setVerifyFailuresFor, writeJsonAtomic } from '../state-schema.mjs';
|
|
6
6
|
import { findActiveChange, readState, writeState, specsDir } from './state-io.mjs';
|
|
7
|
+
import {
|
|
8
|
+
describeTemplateList,
|
|
9
|
+
findTemplatesArg,
|
|
10
|
+
nodeTemplateDeclaration,
|
|
11
|
+
templateDeclarationProblems,
|
|
12
|
+
templateDeclareCommand,
|
|
13
|
+
} from '../protocol-utils.mjs';
|
|
7
14
|
import { findPromptArg, protocolUnderFlowKitPrompts } from './state-skillmarkers.mjs';
|
|
8
15
|
|
|
9
16
|
// config set <key> <value>——branchMode 只读(init 自动判定),enablePrReview 手动
|
|
@@ -75,16 +82,17 @@ export async function runExecutionMode(argv) {
|
|
|
75
82
|
return;
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
// skill-load <node> <skill> [--prompt <path>]——写声明标记
|
|
79
|
-
// .specs/<change-id>/.skill-loads/<node>-<skill>.json
|
|
80
|
-
// record 校验 completedChecks 的 required-skill
|
|
85
|
+
// skill-load <node> <skill> [--prompt <path>] [--templates <a.md,b.md>]——写声明标记
|
|
86
|
+
// .specs/<change-id>/.skill-loads/<node>-<skill>.json
|
|
87
|
+
// ({ node, skill, protocol, templates, at });record 校验 completedChecks 的 required-skill 条目
|
|
88
|
+
// 与节点模板声明以此为准。
|
|
81
89
|
// 诚实边界:标记是"声明"而非物理证明——运行时没有 Skill 调用观察点,脚本无法确认执行者
|
|
82
90
|
// 真实加载过该 skill;标记仅记录"执行者主动声明已加载",由流程纪律兜底。
|
|
83
91
|
export async function runSkillLoad(protocol, argv) {
|
|
84
92
|
const nodeId = argv[3];
|
|
85
93
|
const skillName = argv[4];
|
|
86
94
|
if (!nodeId || !skillName) {
|
|
87
|
-
throw new Error('skill-load requires <node> <skill>. 用法: workflow-state.mjs skill-load <node> <skill> [--prompt <path>]');
|
|
95
|
+
throw new Error('skill-load requires <node> <skill>. 用法: workflow-state.mjs skill-load <node> <skill> [--prompt <path>] [--templates <a.md,b.md>]');
|
|
88
96
|
}
|
|
89
97
|
// 参数校验:node 为当前协议节点集合之一(动态读取协议 nodes[].id——内置 +
|
|
90
98
|
// 自定义,compose 自定义协议节点可声明);协议外节点名依然非法(fail-closed)。
|
|
@@ -103,6 +111,36 @@ export async function runSkillLoad(protocol, argv) {
|
|
|
103
111
|
if (promptArg !== null && !protocolUnderFlowKitPrompts(promptArg)) {
|
|
104
112
|
throw new Error('skill-load --prompt 路径必须位于 flow-kit/prompts/ 下(flow-kit 为 vendored 上游,协议提示只读引用): ' + promptArg);
|
|
105
113
|
}
|
|
114
|
+
// 产出物模板声明(C4 / C11):置入既有标记 JSON 的 templates 数组(节点级一份)。
|
|
115
|
+
// 内置节点:声明集合必须与 C3 映射一致(required ⊆ declared ⊆ required ∪ optional)——新 change
|
|
116
|
+
// 缺失 / 多写 / 漏写 / 错名一律 BLOCK(fail-closed),旧 change 只在「显式传了不一致的清单」时
|
|
117
|
+
// WARN(渐进兼容:旧项目不可能一夜补齐声明,缺失由 record 侧统一给提示,不在声明处重复报)。
|
|
118
|
+
// 自定义协议节点:不比对集合(ADR-002 特化层,C12:协议声明什么就记什么)。
|
|
119
|
+
const templateArg = findTemplatesArg(argv.slice(3));
|
|
120
|
+
const templateDeclaration = nodeTemplateDeclaration((protocol.nodes ?? []).find((item) => item.id === nodeId));
|
|
121
|
+
if (templateDeclaration.source === 'builtin') {
|
|
122
|
+
const isNewChange = (await readState()).newChange === true;
|
|
123
|
+
const requiredNames = describeTemplateList(templateDeclaration.required);
|
|
124
|
+
const declareCommand = templateDeclareCommand(templateDeclaration, { nodeId, skillName });
|
|
125
|
+
const reportUnsoundDeclaration = (reason) => {
|
|
126
|
+
if (isNewChange) {
|
|
127
|
+
console.error('BLOCKED: ' + reason + '——重跑 ' + declareCommand + ' 重新声明后重试');
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
console.error('WARN: ' + reason + '——重跑 ' + declareCommand + ' 重新声明(旧 change 渐进不阻断)');
|
|
131
|
+
};
|
|
132
|
+
const problems = templateDeclarationProblems(templateDeclaration, templateArg.values);
|
|
133
|
+
if (!templateArg.provided && templateDeclaration.required.length > 0 && isNewChange) {
|
|
134
|
+
reportUnsoundDeclaration('节点 ' + nodeId + ' 的模板声明缺失(C3 映射: ' + requiredNames + ')');
|
|
135
|
+
}
|
|
136
|
+
if (templateArg.provided && (problems.missing.length > 0 || problems.extra.length > 0)) {
|
|
137
|
+
const detail = [];
|
|
138
|
+
if (problems.missing.length > 0) detail.push('漏写: ' + problems.missing.join('、'));
|
|
139
|
+
if (problems.extra.length > 0) detail.push('多写/错名: ' + problems.extra.join('、'));
|
|
140
|
+
reportUnsoundDeclaration('节点 ' + nodeId + ' 的模板声明与节点映射不一致(' + detail.join(';')
|
|
141
|
+
+ ';映射要求: ' + requiredNames + ')');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
106
144
|
// 声明标记写入:.skill-loads/ 目录不存在时创建(writeJsonAtomic 自带 mkdir recursive);
|
|
107
145
|
// 同 node-skill 重复调用覆盖(记录最新声明)
|
|
108
146
|
const changeName = await findActiveChange();
|
|
@@ -115,7 +153,7 @@ export async function runSkillLoad(protocol, argv) {
|
|
|
115
153
|
// 校验的节点协议映射表 basename 精确比对同值(真实链路 skill-load → exit 一致);未传 --prompt →
|
|
116
154
|
// null(无协议声明,exit 校验 fail-closed)。若写 resolveProtocol 解析后的完整绝对路径,与
|
|
117
155
|
// 节点协议映射表的 basename 比对必然失败(真实链路必 BLOCKED——机制实际不可用)。
|
|
118
|
-
const marker = { node: nodeId, skill: skillName, protocol: promptArg === null ? null : path.basename(promptArg), at: new Date().toISOString() };
|
|
156
|
+
const marker = { node: nodeId, skill: skillName, protocol: promptArg === null ? null : path.basename(promptArg), templates: templateArg.values, at: new Date().toISOString() };
|
|
119
157
|
// specsDir 已含 .specs/,相对路径为 <change-id>/.skill-loads/<node>-<skill>.json
|
|
120
158
|
const markerRel = path.posix.join(changeName, '.skill-loads', nodeId + '-' + skillName + '.json');
|
|
121
159
|
await writeJsonAtomic(path.join(specsDir(), markerRel), marker);
|
|
@@ -12,7 +12,7 @@ import { looksLikeObjectLiteral, toPersistedProtocolPath, writeJsonAtomic } from
|
|
|
12
12
|
import { nowTimestamp } from '../time-utils.mjs';
|
|
13
13
|
import { probeProject, classify, printDetection, validateContext, printGenerationGuide } from '../context-init.mjs';
|
|
14
14
|
import { fileExists, findActiveChange, readState, writeState, specsDir, runRootDir, hasExactSpecsEntry } from './state-io.mjs';
|
|
15
|
-
import { hasNodeSkillDeclaration, verifySkillLoadMarkers, findSkillLoadsDir } from './state-skillmarkers.mjs';
|
|
15
|
+
import { hasNodeSkillDeclaration, verifySkillLoadMarkers, findSkillLoadsDir, verifyTemplateDeclaration } from './state-skillmarkers.mjs';
|
|
16
16
|
import { determineNode, normalAdvanceExempt } from './state-determine.mjs';
|
|
17
17
|
import { isInsideWorkTree, gitBranchName, branchExists, printBranchLine } from './state-branch.mjs';
|
|
18
18
|
import { printEvolveDueHint } from './state-evolve-hint.mjs';
|
|
@@ -601,6 +601,20 @@ export async function runRecord(protocol, argv) {
|
|
|
601
601
|
}
|
|
602
602
|
console.error('WARN: 节点 ' + nodeId + ' 缺少技能加载声明标记(.skill-loads/' + nodeId + '-*.json)——' + loadGuide + '(旧 change 渐进不阻断,记录继续)');
|
|
603
603
|
}
|
|
604
|
+
// 模板声明核对(C11)——声明标记里必须有与该节点映射一致的 templates 集合:新 change
|
|
605
|
+
// 缺失 / 多写 / 漏写 / 错名 BLOCK(fail-closed,不让人「声明了但说得不对」),旧 change WARN。
|
|
606
|
+
// 自定义协议节点不比对(C12);无活动 change / 声明机制未激活时不在这里报(见该函数的边界注释)。
|
|
607
|
+
const templateCheck = await verifyTemplateDeclaration({
|
|
608
|
+
protocol,
|
|
609
|
+
nodeId,
|
|
610
|
+
changeName: markerChange,
|
|
611
|
+
newChange: state.newChange === true,
|
|
612
|
+
});
|
|
613
|
+
if (templateCheck.warn) console.error('WARN: ' + templateCheck.warn);
|
|
614
|
+
if (!templateCheck.ok) {
|
|
615
|
+
console.error('BLOCKED: ' + templateCheck.reason);
|
|
616
|
+
process.exit(1);
|
|
617
|
+
}
|
|
604
618
|
}
|
|
605
619
|
// 声明自动化——record 时按协议 requiredSkillCalls 自动补写缺失的声明标记
|
|
606
620
|
// (执行者无需手动 skill-load;标记如实记录"节点完成即视为其实现/协议技能已加载",
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// 读写(不写 state、不改路由、不绕门禁,与 bridge-check 同为纯读通道)。节点 id 非法 →
|
|
5
5
|
// fail-closed 并列出协议内全部合法节点。
|
|
6
6
|
import path from 'path';
|
|
7
|
+
import { nodeTemplateDeclaration, templatePointerLines } from '../protocol-utils.mjs';
|
|
7
8
|
import { runRootDir } from './state-io.mjs';
|
|
8
9
|
|
|
9
10
|
// 命令路径形态(平台化):权威源保持设计形态 .claude/skills/(与册子命令形态一致,安装时由
|
|
@@ -21,7 +22,22 @@ function platformScriptsDir(scriptsDir) {
|
|
|
21
22
|
return relative;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
// ①
|
|
25
|
+
// ① 产出物模板现问(加载链的第三环):与 entry 的 READ TEMPLATE 行同源同实现(protocol-utils
|
|
26
|
+
// 的 templatePointerLines),只换标签——两处措辞一处维护。零模板节点不打印。
|
|
27
|
+
// 条件模板行在本通道无条件列出(本通道不读状态、不判前端),并显式标注「仅前端 change」:是否
|
|
28
|
+
// 真的适用由 CHANGE.md 的视觉调性段决定,design 的入口会按 frontendCriterion 追出。
|
|
29
|
+
function printNodeTemplates(node) {
|
|
30
|
+
const declaration = nodeTemplateDeclaration(node);
|
|
31
|
+
if (declaration.required.length === 0 && declaration.optional.length === 0) return;
|
|
32
|
+
for (const line of templatePointerLines(declaration, {
|
|
33
|
+
label: 'TEMPLATE',
|
|
34
|
+
conditional: declaration.optional.length > 0,
|
|
35
|
+
})) {
|
|
36
|
+
console.log(line);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ② 该节点的 outputSchema 名与产物路径(含 evidence id)。产物根语义与状态机 / guard 的节点完成
|
|
25
41
|
// 判定一致:'specs-root' → .specs/;'project' / 缺省 → 项目根。悬空 schema 引用如实标注、不编造
|
|
26
42
|
// 产物(自定义协议允许悬空引用,route-node 的产物推导同样容忍)。
|
|
27
43
|
function printNodeArtifacts(protocol, node) {
|
|
@@ -98,6 +114,7 @@ export function runExplain(protocol, argv, scriptsDir) {
|
|
|
98
114
|
if (explainNode.label) console.log('LABEL: ' + explainNode.label);
|
|
99
115
|
if (explainNode.kind) console.log('KIND: ' + explainNode.kind);
|
|
100
116
|
if (explainNode.disabled === true) console.log('DISABLED: true(该节点在当前协议中被停用)');
|
|
117
|
+
printNodeTemplates(explainNode);
|
|
101
118
|
printNodeArtifacts(protocol, explainNode);
|
|
102
119
|
printNodeGuardrails(explainNode);
|
|
103
120
|
printNodeSkillCalls(explainNode);
|
|
@@ -6,6 +6,14 @@
|
|
|
6
6
|
// 由 handoff result 的 commitHash/greenEvidence 审计性兜底。
|
|
7
7
|
import { promises as fs } from 'fs';
|
|
8
8
|
import path from 'path';
|
|
9
|
+
import {
|
|
10
|
+
describeTemplateList,
|
|
11
|
+
nodeTemplateDeclaration,
|
|
12
|
+
normalizeTemplateName,
|
|
13
|
+
templateDeclarationProblems,
|
|
14
|
+
templateDeclareCommand,
|
|
15
|
+
templateKeyOf,
|
|
16
|
+
} from '../protocol-utils.mjs';
|
|
9
17
|
import { fileExists, readJson, specsDir } from './state-io.mjs';
|
|
10
18
|
|
|
11
19
|
// --prompt 原始参数提取(skill-load 专用参数):--protocol 由 resolveProtocol 全局解析
|
|
@@ -97,6 +105,58 @@ export async function hasNodeSkillDeclaration(nodeId, changeName) {
|
|
|
97
105
|
return false;
|
|
98
106
|
}
|
|
99
107
|
|
|
108
|
+
// 模板声明核对(C11):节点的产出物模板声明落在 .skill-loads/<node>-*.json 的 templates 数组里,
|
|
109
|
+
// 集合必须与 C3 映射一致(required ⊆ declared ⊆ required ∪ optional)。同一节点可有多个 skill 标记
|
|
110
|
+
// (open 有 change / requirement),取并集——节点级一份声明被任一标记满足即可(skill-load 每次
|
|
111
|
+
// 都写全清单)。新 change 缺失 / 多写 / 漏写 / 错名 → BLOCK;旧 change → WARN(渐进兼容,C10)。
|
|
112
|
+
// 不比对的三种情形:非内置节点(C12:自定义协议按自己的声明走)、无活动 change、声明机制未激活
|
|
113
|
+
//(无 .skill-loads/ 或本节点无标记)——后者由「缺少技能加载声明标记」门负责,不重复报
|
|
114
|
+
//(与 exit 侧协议声明校验的「未激活不追溯」同一口径)。
|
|
115
|
+
// 零模板的内置节点(verify / archive)省略 --templates 即视为空集,通过。
|
|
116
|
+
export async function verifyTemplateDeclaration({ protocol, nodeId, changeName, newChange }) {
|
|
117
|
+
const declaration = nodeTemplateDeclaration((protocol?.nodes ?? []).find((node) => node.id === nodeId));
|
|
118
|
+
if (declaration.source !== 'builtin' || !changeName) return { ok: true };
|
|
119
|
+
const loadsDir = await findSkillLoadsDir(changeName);
|
|
120
|
+
if (loadsDir === null) return { ok: true };
|
|
121
|
+
const prefix = nodeId + '-';
|
|
122
|
+
const markers = (await fs.readdir(loadsDir.dir).catch(() => []))
|
|
123
|
+
.filter((name) => name.startsWith(prefix) && name.endsWith('.json'));
|
|
124
|
+
if (markers.length === 0) return { ok: true };
|
|
125
|
+
const declared = [];
|
|
126
|
+
let explicitMarkers = 0;
|
|
127
|
+
for (const markerName of markers) {
|
|
128
|
+
let marker;
|
|
129
|
+
try {
|
|
130
|
+
marker = await readJson(path.join(loadsDir.dir, markerName));
|
|
131
|
+
} catch {
|
|
132
|
+
continue; // 损坏标记由既有声明校验报(本判据不抢报)
|
|
133
|
+
}
|
|
134
|
+
// record 自动补写的标记(auto)是引擎写的,不是执行者的声明——它不承担模板声明义务
|
|
135
|
+
// (exit 侧已有「建议手动 skill-load」提示),不拿它算缺失
|
|
136
|
+
if (marker?.auto === true) continue;
|
|
137
|
+
explicitMarkers += 1;
|
|
138
|
+
if (!Array.isArray(marker?.templates)) continue; // 旧标记无该字段 = 未声明
|
|
139
|
+
for (const name of marker.templates) {
|
|
140
|
+
if (typeof name !== 'string' || name.trim() === '') continue;
|
|
141
|
+
if (!declared.some((existing) => templateKeyOf(existing) === templateKeyOf(name))) {
|
|
142
|
+
declared.push(normalizeTemplateName(name));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// 只有自动标记(无执行者声明)→ 不在这里要求模板集(旧 change 的声明机制本就未激活)
|
|
147
|
+
if (explicitMarkers === 0) return { ok: true };
|
|
148
|
+
const problems = templateDeclarationProblems(declaration, declared);
|
|
149
|
+
if (problems.missing.length === 0 && problems.extra.length === 0) return { ok: true };
|
|
150
|
+
const detail = [];
|
|
151
|
+
if (problems.missing.length > 0) detail.push('漏写: ' + problems.missing.join('、'));
|
|
152
|
+
if (problems.extra.length > 0) detail.push('多写/错名: ' + problems.extra.join('、'));
|
|
153
|
+
const declareCommand = templateDeclareCommand(declaration, { nodeId });
|
|
154
|
+
const reason = '节点 ' + nodeId + ' 的模板声明与节点映射不一致(' + detail.join(';')
|
|
155
|
+
+ ';映射要求: ' + describeTemplateList(declaration.required) + ')——重跑 ' + declareCommand + ' 重新声明';
|
|
156
|
+
if (newChange === true) return { ok: false, reason };
|
|
157
|
+
return { ok: true, warn: reason };
|
|
158
|
+
}
|
|
159
|
+
|
|
100
160
|
// completedChecks 真实性校验。解析 completedChecks 的 required-skill:<node>.<skill>
|
|
101
161
|
// 条目 → 对应声明标记 .specs/<change-id>/.skill-loads/<node>-<skill>.json 必须存在(缺失 →
|
|
102
162
|
// BLOCKED + 指引先加载 skill 并运行 skill-load);标记 at 必须 ≤ 本次记录时间(交叉自洽:
|
|
@@ -21,6 +21,7 @@ import os from 'os';
|
|
|
21
21
|
import { execFileSync, spawnSync } from 'child_process';
|
|
22
22
|
import { fileURLToPath } from 'url';
|
|
23
23
|
import { assertExit, assertOut, copyTreePortable, runGuard, runState, writeFile, writeState } from './test-helpers.mjs';
|
|
24
|
+
import { NODE_ARTIFACT_TEMPLATES } from '../protocol-utils.mjs';
|
|
24
25
|
|
|
25
26
|
// 路径推导基准:技能包 scripts/ 目录(与套件入口同基准)
|
|
26
27
|
export const SCRIPTS_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
@@ -48,9 +49,16 @@ export function gitBranch(root) {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
|
|
51
|
-
// open 阶段工件(CHANGE 含 Why;REQUIREMENT 含 用户故事 +
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
// open 阶段工件(CHANGE 含 Why;REQUIREMENT 含 用户故事 + 验收准则——通过出口校验的完整形态)。
|
|
53
|
+
// 「视觉调性」是 CHANGE 模板的条件段且新 change 要求在场:夹具按其结构形态标注「不适用」
|
|
54
|
+
//(独立行 + 理由),使前端判据稳定地判为非前端——不写这段会让 ui-design 门对新 change 报「段缺席」。
|
|
55
|
+
// visualTone 覆盖该段正文:需要判为「前端」的夹具(或需要构造段内自然句子负例的夹具)**改这一段**,
|
|
56
|
+
// 不要另追加第二个「视觉调性」段——同名段重复时判据取首段,追加对首段没有影响。
|
|
57
|
+
export const DEFAULT_VISUAL_TONE = '不适用(夹具:后端任务,无用户可见界面)。';
|
|
58
|
+
|
|
59
|
+
export function writeIntakeArtifacts(root, changeId = CHANGE_ID, { visualTone = DEFAULT_VISUAL_TONE } = {}) {
|
|
60
|
+
writeFile(root, '.specs/' + changeId + '/CHANGE.md', '# CHANGE\n\n- **Change ID**: ' + changeId
|
|
61
|
+
+ '\n\n## Why(为什么做)\n\n变更目标。\n\n## 视觉调性\n\n' + visualTone + '\n');
|
|
54
62
|
writeFile(root, '.specs/' + changeId + '/REQUIREMENT.md', '# REQUIREMENT\n\n- **Change ID**: ' + changeId + '\n\n## 用户故事(User Story)\n\n用户需求。\n\n## 验收准则(AC)\n\n- 通过标准\n');
|
|
55
63
|
}
|
|
56
64
|
|
|
@@ -72,6 +80,20 @@ export function fullContract(commitHash, taskId) {
|
|
|
72
80
|
// 仓库本地验证工具执行(仅主仓存在、不随克隆分发;副本上文件缺失自动跳过):
|
|
73
81
|
// 返回 { status, output }(spawnSync 原始结果 output 是数组,统一拼接成字符串供断言)
|
|
74
82
|
|
|
83
|
+
// archive 记录的证据 JSON:含归档提名三要素(扫描份数 / 提名编号 / 无提名理由)。新 change 的 archive
|
|
84
|
+
// 出口会核对 evidence.lessonsNomination——夹具只写 summary 会被提名门拦下,掩盖各条目真正被测的
|
|
85
|
+
// 归档/路由判据。summaryIds = 该夹具已写入的 `*-SUMMARY.md` 任务号(扫描份数按此对账,不另抄数字)。
|
|
86
|
+
export function archiveRecordJson(summary, summaryIds = []) {
|
|
87
|
+
return JSON.stringify({
|
|
88
|
+
summary,
|
|
89
|
+
lessonsNomination: {
|
|
90
|
+
scanned: summaryIds.length,
|
|
91
|
+
nominated: [],
|
|
92
|
+
reasonIfNone: '夹具:本 change 无沉淀候选入库',
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
75
97
|
// 多趟链路 SUMMARY 夹具(SUMMARY 模板保真全量满足:标题首行 # SUMMARY: + 首部 4 字段 +
|
|
76
98
|
// 段序 做了什么→改动文件→verify 输出→6 维自查→越界检查→自检方法;6 维声明 brooks-review)
|
|
77
99
|
export function execSummaryFixture(taskId) {
|
|
@@ -117,6 +139,10 @@ export function execSummaryFixture(taskId) {
|
|
|
117
139
|
'',
|
|
118
140
|
'brooks-review',
|
|
119
141
|
'',
|
|
142
|
+
'## LESSONS 扫描',
|
|
143
|
+
'',
|
|
144
|
+
'无 active 条目命中(夹具:本任务 write_files 与 .specs/LESSONS.md 关键词行无交集)。',
|
|
145
|
+
'',
|
|
120
146
|
].join('\n');
|
|
121
147
|
}
|
|
122
148
|
|
|
@@ -219,7 +245,7 @@ export function writeFixBatchFixture(dir, { kind, fixStatus, newChange = true, p
|
|
|
219
245
|
export function completeFixTaskAndRecord(dir, env) {
|
|
220
246
|
writeFile(dir, '.specs/' + CHANGE_ID + '/TASK.md', fixBatchTaskText('done'));
|
|
221
247
|
writeFile(dir, '.specs/' + CHANGE_ID + '/T-FIX-01-SUMMARY.md', execSummaryFixture('T-FIX-01'));
|
|
222
|
-
assertExit(runState(['skill-load', 'execute', 'flow-comet-execute', '--prompt', 'flow-kit/prompts/4-dev.md'], dir, env), 0);
|
|
248
|
+
assertExit(runState(['skill-load', 'execute', 'flow-comet-execute', '--prompt', 'flow-kit/prompts/4-dev.md', '--templates', 'SUMMARY.md'], dir, env), 0);
|
|
223
249
|
const rec = runState(['record', 'execute', '{"summary":"fix batch executed","parallelTakeoverApproved":true}'], dir, env);
|
|
224
250
|
assertExit(rec, 0);
|
|
225
251
|
assertOut(rec, 'EVIDENCE: execute');
|
|
@@ -285,7 +311,7 @@ function parseExplainSkillLine(value) {
|
|
|
285
311
|
function parseExplainOutput(output) {
|
|
286
312
|
const parsed = {
|
|
287
313
|
attributes: {}, schemas: [], artifacts: [], evidence: [], guardrails: [], guardrailsNone: false,
|
|
288
|
-
skills: [], skillsNone: false, commands: [],
|
|
314
|
+
skills: [], skillsNone: false, templates: [], commands: [],
|
|
289
315
|
};
|
|
290
316
|
let schemaIndex = -1;
|
|
291
317
|
for (const rawLine of String(output).split(/\r?\n/)) {
|
|
@@ -313,6 +339,8 @@ function parseExplainOutput(output) {
|
|
|
313
339
|
} else if (line.startsWith('REQUIRED-SKILL: ')) {
|
|
314
340
|
if (value === '(none)') parsed.skillsNone = true;
|
|
315
341
|
else parsed.skills.push(parseExplainSkillLine(value));
|
|
342
|
+
} else if (/^TEMPLATE(?:(条件模板))?: /.test(line)) {
|
|
343
|
+
parsed.templates.push(line);
|
|
316
344
|
} else if (line.startsWith('COMMAND ')) parsed.commands.push(line);
|
|
317
345
|
else throw new Error('explain 输出含未识别的行形态: ' + line);
|
|
318
346
|
}
|
|
@@ -390,7 +418,22 @@ function explainGuardrailAndSkillProblems(node, parsed) {
|
|
|
390
418
|
return problems;
|
|
391
419
|
}
|
|
392
420
|
|
|
393
|
-
// ⑤
|
|
421
|
+
// ⑤ 模板指针行:内置节点取引擎 C3 映射、自定义协议节点取 node.templates,零模板节点不打印。
|
|
422
|
+
// 期望值在这里**独立构造**(不调 explain 侧的格式化函数):措辞、路径根或 .md 后缀的漂移
|
|
423
|
+
// 才能被这条锥抓到。
|
|
424
|
+
function explainTemplateProblems(node, parsed) {
|
|
425
|
+
const builtin = NODE_ARTIFACT_TEMPLATES[node.id];
|
|
426
|
+
const required = builtin ? builtin.required : (node.templates ?? []);
|
|
427
|
+
const optional = builtin ? (builtin.optional ?? []) : [];
|
|
428
|
+
const expected = [];
|
|
429
|
+
for (const name of required) expected.push('TEMPLATE: flow-kit/templates/' + name + '.md');
|
|
430
|
+
for (const name of optional) expected.push('TEMPLATE(条件模板): flow-kit/templates/' + name + '.md(仅前端 change)');
|
|
431
|
+
if (JSON.stringify(parsed.templates) === JSON.stringify(expected)) return [];
|
|
432
|
+
return ['节点 ' + node.id + ' 的 TEMPLATE 行与节点模板声明不一致: 输出 '
|
|
433
|
+
+ JSON.stringify(parsed.templates) + ' / 期望 ' + JSON.stringify(expected)];
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// ⑥ 三条命令:节点 id 与 --apply 形态 + 脚本根形态(三条同根、指向技能包 scripts 目录)+ 脚本
|
|
394
437
|
// 路径整体带双引号(含空格的安装根下不被 shell 分词——引号是契约形态的一部分,缺引号即红)。
|
|
395
438
|
function explainCommandProblems(node, parsed) {
|
|
396
439
|
const commandPatterns = [
|
|
@@ -427,7 +470,7 @@ function explainCommandProblems(node, parsed) {
|
|
|
427
470
|
return problems;
|
|
428
471
|
}
|
|
429
472
|
|
|
430
|
-
//
|
|
473
|
+
// 逐字段对账(单一实现:真实判据与反向构造探针共用):五类字段 + 三条命令。
|
|
431
474
|
export function explainContractProblems(protocol, explainOutputs) {
|
|
432
475
|
const problems = [];
|
|
433
476
|
const schemaById = new Map((protocol.outputSchemas ?? []).map((schema) => [schema.id, schema]));
|
|
@@ -451,6 +494,7 @@ export function explainContractProblems(protocol, explainOutputs) {
|
|
|
451
494
|
node.disabled === true ? 'true(该节点在当前协议中被停用)' : null, 'DISABLED');
|
|
452
495
|
problems.push(...explainSchemaProblems(node, parsed, schemaById));
|
|
453
496
|
problems.push(...explainGuardrailAndSkillProblems(node, parsed));
|
|
497
|
+
problems.push(...explainTemplateProblems(node, parsed));
|
|
454
498
|
problems.push(...explainCommandProblems(node, parsed));
|
|
455
499
|
}
|
|
456
500
|
return problems;
|
|
@@ -544,6 +588,26 @@ export function explainReverseConstructionProblems(dir, protocolDecl, explainOut
|
|
|
544
588
|
}
|
|
545
589
|
}
|
|
546
590
|
}
|
|
591
|
+
// ⑤ 模板指针行的另一面(不需重跑):真实输出去掉首条 TEMPLATE 行 ⇒ 逐节点必报 TEMPLATE 不一致。
|
|
592
|
+
// 没有这一侧,把模板行从实现里拿掉也能全绿(对账恒真空过)。
|
|
593
|
+
const strippedTemplates = new Map();
|
|
594
|
+
for (const [nodeId, output] of explainOutputs) {
|
|
595
|
+
const lines = String(output).split(/\r?\n/);
|
|
596
|
+
const index = lines.findIndex((line) => line.startsWith('TEMPLATE: '));
|
|
597
|
+
if (index < 0) continue;
|
|
598
|
+
strippedTemplates.set(nodeId, [...lines.slice(0, index), ...lines.slice(index + 1)].join('\n'));
|
|
599
|
+
}
|
|
600
|
+
if (strippedTemplates.size === 0) {
|
|
601
|
+
problems.push('反向构造前提不成立:没有任何节点的 explain 输出含 TEMPLATE: 行(模板指针判据无从判别)');
|
|
602
|
+
} else {
|
|
603
|
+
const templateProblems = explainContractProblems(protocolDecl, new Map([...explainOutputs, ...strippedTemplates]));
|
|
604
|
+
for (const nodeId of strippedTemplates.keys()) {
|
|
605
|
+
if (!templateProblems.some((problem) => problem.includes('节点 ' + nodeId + ' 的')
|
|
606
|
+
&& problem.includes('TEMPLATE 行'))) {
|
|
607
|
+
problems.push('反向构造判别力缺失(去掉节点 ' + nodeId + ' 的 TEMPLATE 行未被判不一致)');
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
547
611
|
return problems;
|
|
548
612
|
}
|
|
549
613
|
|
|
@@ -570,12 +634,12 @@ export function multiWaveTaskContent(statusMap) {
|
|
|
570
634
|
// 新 change 两层加载模型下逐节点 skill-load → record → entry → exit --apply 全程驱动。
|
|
571
635
|
export function driveThroughDesign(dir) {
|
|
572
636
|
assertExit(runState(['init', CHANGE_ID], dir), 0);
|
|
573
|
-
assertExit(runState(['skill-load', 'open', 'flow-comet-change', '--prompt', 'flow-kit/prompts/0-change.md'], dir), 0);
|
|
637
|
+
assertExit(runState(['skill-load', 'open', 'flow-comet-change', '--prompt', 'flow-kit/prompts/0-change.md', '--templates', 'CHANGE.md,REQUIREMENT.md'], dir), 0);
|
|
574
638
|
writeIntakeArtifacts(dir);
|
|
575
639
|
assertExit(runState(['record', 'open', '{"summary":"intake complete"}'], dir), 0);
|
|
576
640
|
assertExit(runGuard(['entry', 'open'], dir), 0);
|
|
577
641
|
assertExit(runGuard(['exit', 'open', '--apply'], dir), 0);
|
|
578
|
-
assertExit(runState(['skill-load', 'design', 'flow-comet-design', '--prompt', 'flow-kit/prompts/2-design.md'], dir), 0);
|
|
642
|
+
assertExit(runState(['skill-load', 'design', 'flow-comet-design', '--prompt', 'flow-kit/prompts/2-design.md', '--templates', 'DESIGN.md'], dir), 0);
|
|
579
643
|
writeFile(dir, '.specs/' + CHANGE_ID + '/DESIGN.md',
|
|
580
644
|
'# DESIGN\n\n- **Change ID**: ' + CHANGE_ID + '\n\n## 0. 技术栈选定\n\nNode.js(ESM)\n\n## 决策清单\n\n- [ ] 循环路由\n');
|
|
581
645
|
assertExit(runState(['record', 'design', '{"summary":"design done"}'], dir), 0);
|
|
@@ -405,10 +405,12 @@ export function composeState(overrides = {}) {
|
|
|
405
405
|
|
|
406
406
|
// 完整 SUMMARY:六段齐全(## verify 输出 / ## 6 维自查 / ## 越界检查 / ## 做了什么 / ## 改动文件 / ## 自检方法)
|
|
407
407
|
// 6 维自查默认含实质内容且声明 brooks-review;method='' 表示去掉 ## 自检方法 段(旧格式场景)
|
|
408
|
+
// 结构子段与增量段按模板骨架补齐(`### 已知接受 + 理由` / `### 已知小问题` / `## LESSONS 扫描`):
|
|
409
|
+
// 这些 H3/增量段已成为新 change 的必填结构,夹具缺它们会被结构门当成工件缺陷而不是被测行为。
|
|
408
410
|
export function summaryContent(options = {}) {
|
|
409
411
|
const sixDim = options.sixDim !== undefined
|
|
410
412
|
? options.sixDim
|
|
411
|
-
: '## 6 维自查\n\n- 功能: 通过(brooks-review 已跑)\n- 性能: 无影响\n- 安全: 无影响\n- 兼容: 通过\n- 可观测: 通过\n- 可维护:
|
|
413
|
+
: '## 6 维自查\n\n- 功能: 通过(brooks-review 已跑)\n- 性能: 无影响\n- 安全: 无影响\n- 兼容: 通过\n- 可观测: 通过\n- 可维护: 通过\n\n### 已知接受 + 理由\n\n- 无(夹具)。\n\n### 已知小问题\n\n- 无(夹具)。';
|
|
412
414
|
const method = options.method !== undefined ? options.method : '## 自检方法\n\nbrooks-review';
|
|
413
415
|
return [
|
|
414
416
|
'# T01-SUMMARY',
|
|
@@ -435,12 +437,18 @@ export function summaryContent(options = {}) {
|
|
|
435
437
|
'',
|
|
436
438
|
method,
|
|
437
439
|
'',
|
|
440
|
+
'## LESSONS 扫描',
|
|
441
|
+
'',
|
|
442
|
+
'无 active 条目命中(夹具)。',
|
|
443
|
+
'',
|
|
438
444
|
].join('\n');
|
|
439
445
|
}
|
|
440
446
|
|
|
441
447
|
// 新 change 模板保真 SUMMARY(M1 严格形态:# SUMMARY: 标题 + 首部 4 字段 + 段序保真——
|
|
442
448
|
// directOverride 授权约束场景(213~216)用:新 change 出口强制模板保真,旧 summaryContent
|
|
443
449
|
// 无 # SUMMARY: 标题会被 M1 BLOCKED,不能用于正例/恢复场景)
|
|
450
|
+
// 结构子段(### 已知接受 + 理由 / ### 已知小问题)与增量段(## 自检方法 / ## LESSONS 扫描)按模板
|
|
451
|
+
// 骨架补齐——新 change 缺它们属工件缺陷,不应让夹具自身触发结构门。
|
|
444
452
|
export function strictSummary(taskId) {
|
|
445
453
|
return [
|
|
446
454
|
'# SUMMARY: ' + taskId + ' - 实现 ' + taskId,
|
|
@@ -477,6 +485,14 @@ export function strictSummary(taskId) {
|
|
|
477
485
|
'- 可观测: 通过',
|
|
478
486
|
'- 可维护: 通过',
|
|
479
487
|
'',
|
|
488
|
+
'### 已知接受 + 理由',
|
|
489
|
+
'',
|
|
490
|
+
'- 无(夹具)。',
|
|
491
|
+
'',
|
|
492
|
+
'### 已知小问题',
|
|
493
|
+
'',
|
|
494
|
+
'- 无(夹具)。',
|
|
495
|
+
'',
|
|
480
496
|
'## 数据库迁移',
|
|
481
497
|
'',
|
|
482
498
|
'N/A:本任务无 schema 变更(条件段按模板占位)。',
|
|
@@ -505,6 +521,10 @@ export function strictSummary(taskId) {
|
|
|
505
521
|
'',
|
|
506
522
|
'brooks-review',
|
|
507
523
|
'',
|
|
524
|
+
'## LESSONS 扫描',
|
|
525
|
+
'',
|
|
526
|
+
'无 active 条目命中(夹具)。',
|
|
527
|
+
'',
|
|
508
528
|
].join('\n');
|
|
509
529
|
}
|
|
510
530
|
|
|
@@ -2016,6 +2016,11 @@ export const BARE_ISO_ENGINE_WHITELIST = [
|
|
|
2016
2016
|
count: 2,
|
|
2017
2017
|
reason: '受控重入 / 重校授权的机器时刻(authorizedAt):随 state 事件流时间形态一并迁移;轮次推导已由综合判定派生,本条只剩落盘时刻',
|
|
2018
2018
|
},
|
|
2019
|
+
{
|
|
2020
|
+
file: 'lib/guard-template-fidelity.mjs',
|
|
2021
|
+
count: 1,
|
|
2022
|
+
reason: '两阶段提示的时间戳(.template-hints.json 的 failedAt)为引擎运行时值,非拼接的公开文案:它是引擎自写的机器字段(Z 形随提示文件持久化),迁移须与历史提示文件的读取同批处理,留专门窗口',
|
|
2023
|
+
},
|
|
2019
2024
|
{
|
|
2020
2025
|
file: 'workflow-handoff.mjs',
|
|
2021
2026
|
count: 4,
|
|
@@ -2270,6 +2275,10 @@ export function writeDesignExitFixture(dir, {
|
|
|
2270
2275
|
newChange, visualTone, uiDesign, declareUiDesign, changeName = CHANGE_ID, changeTail = '', declareDesign = true,
|
|
2271
2276
|
}) {
|
|
2272
2277
|
writeFile(dir, 'flow-kit/templates/DESIGN.md', '# DESIGN 模板\n\n## 0. 技术栈选型\n## 1. 技术决策清单\n');
|
|
2278
|
+
// CHANGE 模板同样在场:design 出口的前端判据用 `pick('change', ['视觉调性'])` 在**模板派生**的段名表里
|
|
2279
|
+
// 定位该段——整份模板缺席时命名段判据按 C9 跳过(不回落),夹具缺 CHANGE 模板会让这条判据失去输入面
|
|
2280
|
+
// (模板缺席下的跳过另由 TA-21 覆盖)。
|
|
2281
|
+
writeFile(dir, 'flow-kit/templates/CHANGE.md', '# CHANGE 模板\n\n## Why(为什么做)\n\n## 视觉调性(前端项目必填)\n');
|
|
2273
2282
|
const state = baseState('design');
|
|
2274
2283
|
state.newChange = newChange === true;
|
|
2275
2284
|
state.enteredNodes = ['design'];
|