@boyingliu01/xp-gate 0.38.5 → 0.38.6
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/build-integrity/gate-10.ts +45 -27
- package/hooks/gate-entries/gate-10-entry.sh +7 -0
- package/hooks/gate-entries/gate-11-entry.sh +7 -0
- package/hooks/gate-entries/gate-12-entry.sh +7 -0
- package/hooks/gate-entries/gate-12b-entry.sh +7 -0
- package/hooks/gate-entries/gate-12c-entry.sh +7 -0
- package/hooks/gate-entries/gate-13-entry.sh +7 -0
- package/hooks/gate-entries/gate-5-entry.sh +48 -2
- package/hooks/gate-entries/gate-6-entry.sh +93 -2
- package/hooks/gate-entries/gate-7-entry.sh +7 -0
- package/hooks/gate-entries/gate-8-entry.sh +7 -0
- package/hooks/gate-entries/gate-9-entry.sh +7 -0
- package/lib/mattpocock-license-verdict.json +1 -1
- package/mock-policy/AGENTS.md +1 -1
- package/mutation/AGENTS.md +1 -1
- package/package.json +1 -1
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
- package/principles/AGENTS.md +1 -1
- package/scripts/generate-mirrors.cjs +85 -28
- package/scripts/sync-package-content.js +5 -0
- package/skills/delphi-review/AGENTS.md +1 -1
- package/skills/sprint-flow/AGENTS.md +1 -1
- package/skills/test-specification-alignment/AGENTS.md +1 -1
- package/build-integrity/__tests__/ccn-refactor-gate10.test.ts +0 -133
- package/build-integrity/__tests__/gate-10.test.ts +0 -340
- package/build-integrity/__tests__/import-resolver.test.ts +0 -747
- package/build-integrity/__tests__/orchestrator.test.ts +0 -302
- package/build-integrity/__tests__/quote-masker.test.ts +0 -177
- package/skills/sprint-flow/__tests__/sprint-flow.test.cjs +0 -457
- package/skills/sprint-flow/__tests__/verify-sprint-state.test.bats +0 -70
|
@@ -1,457 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @test REQ-SF-001 Sprint Flow Trigger Accuracy
|
|
3
|
-
* @intent Verify that sprint-flow SKILL.md trigger detection correctly distinguishes
|
|
4
|
-
* between valid sprint-flow requests and unrelated queries
|
|
5
|
-
* @covers AC-SF-001-01, AC-SF-001-02, AC-SF-001-03
|
|
6
|
-
*/
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
const path = require('path');
|
|
9
|
-
|
|
10
|
-
const SKILL_MD_PATH = path.join(__dirname, '..', 'SKILL.md');
|
|
11
|
-
const REFERENCES_DIR = path.join(__dirname, '..', 'references');
|
|
12
|
-
const PHASE_OVERVIEW_PATH = path.join(REFERENCES_DIR, 'phase-overview.md');
|
|
13
|
-
const PHASE_2_BUILD_PATH = path.join(REFERENCES_DIR, 'phase-3-build.md');
|
|
14
|
-
const ORCHESTRATION_RULES_PATH = path.join(REFERENCES_DIR, 'orchestration-rules.md');
|
|
15
|
-
|
|
16
|
-
let skillContent = '';
|
|
17
|
-
let phaseOverviewContent = '';
|
|
18
|
-
|
|
19
|
-
function loadSkillMd() {
|
|
20
|
-
skillContent = fs.readFileSync(SKILL_MD_PATH, 'utf-8');
|
|
21
|
-
if (fs.existsSync(PHASE_OVERVIEW_PATH)) {
|
|
22
|
-
phaseOverviewContent = fs.readFileSync(PHASE_OVERVIEW_PATH, 'utf-8');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Search across SKILL.md AND references/phase-overview.md (progressive disclosure: sections
|
|
27
|
-
// like "Unique Value Proposition" and "Phase Flow Consistency" moved to reference file).
|
|
28
|
-
function contentIncludes(str) {
|
|
29
|
-
return skillContent.includes(str) || phaseOverviewContent.includes(str);
|
|
30
|
-
}
|
|
31
|
-
function contentSplit(str) {
|
|
32
|
-
// Return the part after str from whichever file contains it.
|
|
33
|
-
// Throws descriptive error instead of returning undefined so callers
|
|
34
|
-
// get a clear assertion message rather than a TypeError crash.
|
|
35
|
-
if (skillContent.includes(str)) return skillContent.split(str)[1];
|
|
36
|
-
if (phaseOverviewContent.includes(str)) return phaseOverviewContent.split(str)[1];
|
|
37
|
-
throw new Error(`Section "${str}" not found in SKILL.md or references/phase-overview.md`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function parseFrontmatter(content) {
|
|
41
|
-
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
42
|
-
if (!match) return {};
|
|
43
|
-
const yaml = match[1];
|
|
44
|
-
const result = {};
|
|
45
|
-
// Parse simple YAML key-value pairs and lists
|
|
46
|
-
const lines = yaml.split('\n');
|
|
47
|
-
let currentKey = null;
|
|
48
|
-
for (const line of lines) {
|
|
49
|
-
const trimmed = line.trim();
|
|
50
|
-
if (trimmed === '' || trimmed.startsWith('#')) continue;
|
|
51
|
-
const kvMatch = trimmed.match(/^(\w[\w_]*):\s*(.*)/);
|
|
52
|
-
if (kvMatch) {
|
|
53
|
-
currentKey = kvMatch[1];
|
|
54
|
-
const val = kvMatch[2].trim();
|
|
55
|
-
if (val === '') {
|
|
56
|
-
result[currentKey] = [];
|
|
57
|
-
} else if (val.startsWith('"') || val.startsWith("'")) {
|
|
58
|
-
result[currentKey] = val.slice(1, -1);
|
|
59
|
-
} else {
|
|
60
|
-
result[currentKey] = val;
|
|
61
|
-
}
|
|
62
|
-
} else if (trimmed.startsWith('- ') && currentKey) {
|
|
63
|
-
const item = trimmed.slice(2).trim().replace(/^["'](.*)["'].*$/, '$1');
|
|
64
|
-
if (!Array.isArray(result[currentKey])) result[currentKey] = [];
|
|
65
|
-
result[currentKey].push(item);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// === Trigger Accuracy Tests ===
|
|
72
|
-
|
|
73
|
-
function testPositiveTriggersArePresent() {
|
|
74
|
-
const frontmatter = parseFrontmatter(skillContent);
|
|
75
|
-
const triggers = frontmatter.triggers || [];
|
|
76
|
-
const required = ['/sprint-flow', 'start sprint', '开发新功能', '一键开发'];
|
|
77
|
-
const missing = required.filter(r => !triggers.some(t => t.includes(r)));
|
|
78
|
-
if (missing.length > 0) {
|
|
79
|
-
throw new Error(`Missing positive triggers: ${missing.join(', ')}`);
|
|
80
|
-
}
|
|
81
|
-
console.log(' ✓ Positive triggers are present');
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function testNegativeTriggersArePresent() {
|
|
85
|
-
const frontmatter = parseFrontmatter(skillContent);
|
|
86
|
-
const negTriggers = frontmatter.triggers_negative_examples || [];
|
|
87
|
-
if (negTriggers.length < 8) {
|
|
88
|
-
throw new Error(`triggers_negative_examples must have at least 8 entries, got ${negTriggers.length}`);
|
|
89
|
-
}
|
|
90
|
-
console.log(` ✓ Negative triggers have ${negTriggers.length} entries (>= 8 required)`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function testNegativeTriggerPhrases() {
|
|
94
|
-
// These phrases must NOT trigger sprint-flow
|
|
95
|
-
const shouldNotTrigger = [
|
|
96
|
-
'实现排序算法',
|
|
97
|
-
'实现一下',
|
|
98
|
-
'帮我实现这个函数',
|
|
99
|
-
'怎么实现登录功能',
|
|
100
|
-
'start spring boot',
|
|
101
|
-
'开发环境配置',
|
|
102
|
-
'一键部署',
|
|
103
|
-
'新功能建议',
|
|
104
|
-
'implement a sort function',
|
|
105
|
-
'how to implement auth',
|
|
106
|
-
];
|
|
107
|
-
for (const phrase of shouldNotTrigger) {
|
|
108
|
-
// Verify phrase is in triggers_negative_examples
|
|
109
|
-
const frontmatter = parseFrontmatter(skillContent);
|
|
110
|
-
const negTriggers = frontmatter.triggers_negative_examples || [];
|
|
111
|
-
const found = negTriggers.some(n => n.includes(phrase) || phrase.includes(n));
|
|
112
|
-
if (!found) {
|
|
113
|
-
throw new Error(`Negative trigger phrase "${phrase}" not found in triggers_negative_examples`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
console.log(` ✓ All ${shouldNotTrigger.length} negative trigger phrases verified`);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function testPositiveTriggerPhrases() {
|
|
120
|
-
const shouldTrigger = [
|
|
121
|
-
'开发用户认证模块',
|
|
122
|
-
'/sprint-flow',
|
|
123
|
-
'一键开发 REST API',
|
|
124
|
-
];
|
|
125
|
-
for (const phrase of shouldTrigger) {
|
|
126
|
-
const frontmatter = parseFrontmatter(skillContent);
|
|
127
|
-
const triggers = frontmatter.triggers || [];
|
|
128
|
-
// Match against frontmatter triggers OR check body trigger table for broader patterns
|
|
129
|
-
const matched = triggers.some(t =>
|
|
130
|
-
phrase.includes(t) || t.includes(phrase) || phrase.includes('/sprint-flow')
|
|
131
|
-
) || skillContent.includes(phrase);
|
|
132
|
-
if (!matched) {
|
|
133
|
-
throw new Error(`Positive trigger phrase "${phrase}" should match at least one trigger`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
console.log(` ✓ All ${shouldTrigger.length} positive trigger phrases verified`);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function testNegativeTestCasesExist() {
|
|
140
|
-
// Count test case entries by matching "input:" lines in triggers_negative_test_cases YAML block
|
|
141
|
-
const fmMatch = skillContent.match(/^---\n([\s\S]*?)\n---/);
|
|
142
|
-
if (!fmMatch) throw new Error('Frontmatter not found');
|
|
143
|
-
const yaml = fmMatch[1];
|
|
144
|
-
|
|
145
|
-
// Find triggers_negative_test_cases block and count "- input:" lines within it
|
|
146
|
-
const testCasesSection = yaml.split('triggers_negative_test_cases:')[1];
|
|
147
|
-
if (!testCasesSection) throw new Error('triggers_negative_test_cases not found in frontmatter');
|
|
148
|
-
|
|
149
|
-
const count = (testCasesSection.match(/^\s+- input:/gm) || []).length;
|
|
150
|
-
if (count < 11) {
|
|
151
|
-
throw new Error(`triggers_negative_test_cases must have at least 11 entries, got ${count}`);
|
|
152
|
-
}
|
|
153
|
-
console.log(` ✓ Negative test cases have ${count} entries (>= 11 required)`);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// === Phase Transition Tests ===
|
|
157
|
-
|
|
158
|
-
function testWorkflowStepsOrder() {
|
|
159
|
-
const frontmatter = parseFrontmatter(skillContent);
|
|
160
|
-
const steps = frontmatter.workflow_steps || [];
|
|
161
|
-
if (steps.length !== 6) {
|
|
162
|
-
throw new Error(`workflow_steps must have exactly 6 entries, got ${steps.length}`);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const expectedOrder = [
|
|
166
|
-
'PREP', 'DESIGN', 'BUILD', 'VERIFY', 'SHIP', 'CLOSE',
|
|
167
|
-
];
|
|
168
|
-
|
|
169
|
-
for (let i = 0; i < expectedOrder.length; i++) {
|
|
170
|
-
if (!steps[i].includes(expectedOrder[i])) {
|
|
171
|
-
throw new Error(
|
|
172
|
-
`workflow_steps[${i}] should contain "${expectedOrder[i]}", got "${steps[i]}"`
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
console.log(' ✓ workflow_steps order matches canonical 6-phase sequence');
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function testPhaseFlowDiagramOrder() {
|
|
180
|
-
// The Phase Flow diagram in the body must show: PREP → ... → SHIP → CLOSE
|
|
181
|
-
const flowMatch = skillContent.match(/PREP →.*CLOSE/);
|
|
182
|
-
if (!flowMatch) {
|
|
183
|
-
throw new Error('Phase Flow diagram not found in SKILL.md body');
|
|
184
|
-
}
|
|
185
|
-
const flow = flowMatch[0];
|
|
186
|
-
|
|
187
|
-
// Verify VERIFY comes before SHIP
|
|
188
|
-
const verifyPos = flow.indexOf('VERIFY');
|
|
189
|
-
const shipPos = flow.indexOf('SHIP');
|
|
190
|
-
const closePos = flow.indexOf('CLOSE');
|
|
191
|
-
if (verifyPos === -1 || shipPos === -1 || closePos === -1) {
|
|
192
|
-
throw new Error('Phase Flow diagram missing required phases');
|
|
193
|
-
}
|
|
194
|
-
if (verifyPos > shipPos) {
|
|
195
|
-
throw new Error('VERIFY must come before SHIP in phase flow diagram');
|
|
196
|
-
}
|
|
197
|
-
if (shipPos > closePos) {
|
|
198
|
-
throw new Error('SHIP must come before CLOSE in phase flow diagram');
|
|
199
|
-
}
|
|
200
|
-
console.log(' ✓ Phase Flow diagram has correct ordering');
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function testPhaseFlowConsistencySectionExists() {
|
|
204
|
-
if (!contentIncludes('Phase Flow Consistency')) {
|
|
205
|
-
throw new Error('SKILL.md or references/phase-overview.md must contain "Phase Flow Consistency" section');
|
|
206
|
-
}
|
|
207
|
-
console.log(' ✓ Phase Flow Consistency section exists');
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function testCanonicalPhaseOrderTableExists() {
|
|
211
|
-
if (!contentIncludes('Canonical Phase Order')) {
|
|
212
|
-
throw new Error('SKILL.md or references/phase-overview.md must contain "Canonical Phase Order" table');
|
|
213
|
-
}
|
|
214
|
-
console.log(' ✓ Canonical Phase Order table exists');
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function testAll11PhasesInPhaseFlowConsistency() {
|
|
218
|
-
const section = contentSplit('Phase Flow Consistency');
|
|
219
|
-
const requiredPhases = [
|
|
220
|
-
'PREP', 'DESIGN', 'BUILD', 'VERIFY', 'SHIP', 'CLOSE',
|
|
221
|
-
];
|
|
222
|
-
for (const phase of requiredPhases) {
|
|
223
|
-
if (!section.includes(phase)) {
|
|
224
|
-
throw new Error(`Phase Flow Consistency section missing phase: ${phase}`);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
console.log(' ✓ All 6 phases referenced in Phase Flow Consistency section');
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// === Force Levels Tests ===
|
|
231
|
-
|
|
232
|
-
function testForceLevelsDocumentExists() {
|
|
233
|
-
const forceLevelsPath = path.join(REFERENCES_DIR, 'force-levels.md');
|
|
234
|
-
if (!fs.existsSync(forceLevelsPath)) {
|
|
235
|
-
throw new Error('references/force-levels.md must exist');
|
|
236
|
-
}
|
|
237
|
-
const content = fs.readFileSync(forceLevelsPath, 'utf-8');
|
|
238
|
-
if (!content.includes('轻量') || !content.includes('标准') || !content.includes('复杂')) {
|
|
239
|
-
throw new Error('force-levels.md must document lightweight/standard/complex levels');
|
|
240
|
-
}
|
|
241
|
-
console.log(' ✓ force-levels.md exists and documents three levels');
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function testForceLevelsRequiresDelphi() {
|
|
245
|
-
const forceLevelsContent = fs.readFileSync(
|
|
246
|
-
path.join(REFERENCES_DIR, 'force-levels.md'), 'utf-8'
|
|
247
|
-
);
|
|
248
|
-
if (!forceLevelsContent.includes('Delphi') && !forceLevelsContent.includes('delphi')) {
|
|
249
|
-
throw new Error('force-levels.md must reference Delphi review requirement');
|
|
250
|
-
}
|
|
251
|
-
console.log(' ✓ force-levels.md requires Delphi review for all levels');
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// === Value Proposition Tests ===
|
|
255
|
-
|
|
256
|
-
function testUniqueValuePropositionExists() {
|
|
257
|
-
if (!contentIncludes('Unique Value Proposition')) {
|
|
258
|
-
throw new Error('SKILL.md or references/phase-overview.md must contain "Unique Value Proposition" section');
|
|
259
|
-
}
|
|
260
|
-
console.log(' ✓ Unique Value Proposition section exists');
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function testUvpMentionsTokenSavings() {
|
|
264
|
-
const section = contentSplit('Unique Value Proposition');
|
|
265
|
-
if (!section.includes('40') || !section.includes('67') || !section.includes('token')) {
|
|
266
|
-
throw new Error('Unique Value Proposition must mention 40-67% token savings');
|
|
267
|
-
}
|
|
268
|
-
console.log(' ✓ UVP mentions 40-67% token savings');
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function testUvpMentionsHardGate() {
|
|
272
|
-
const section = contentSplit('Unique Value Proposition');
|
|
273
|
-
if (!section.includes('HARD-GATE')) {
|
|
274
|
-
throw new Error('Unique Value Proposition must mention HARD-GATE discipline');
|
|
275
|
-
}
|
|
276
|
-
console.log(' ✓ UVP mentions HARD-GATE discipline');
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function testUvpMentionsEmergentRequirements() {
|
|
280
|
-
const section = contentSplit('Unique Value Proposition');
|
|
281
|
-
if (!section.toLowerCase().includes('emergent')) {
|
|
282
|
-
throw new Error('Unique Value Proposition must mention emergent requirements');
|
|
283
|
-
}
|
|
284
|
-
console.log(' ✓ UVP mentions emergent requirements');
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// === Phase Timing Tests ===
|
|
288
|
-
|
|
289
|
-
function testTimingSectionExists() {
|
|
290
|
-
const phase2BuildContent = fs.readFileSync(PHASE_2_BUILD_PATH, 'utf-8');
|
|
291
|
-
if (!phase2BuildContent.includes('Timing & Stability')) {
|
|
292
|
-
throw new Error('phase-3-build.md must contain "Timing & Stability" section');
|
|
293
|
-
}
|
|
294
|
-
console.log(' ✓ Timing & Stability section exists in phase-3-build.md');
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function testTimeoutRecommendationsExist() {
|
|
298
|
-
const phase2BuildContent = fs.readFileSync(PHASE_2_BUILD_PATH, 'utf-8');
|
|
299
|
-
const timeoutSection = phase2BuildContent.split('Timing & Stability')[1];
|
|
300
|
-
if (!timeoutSection || !timeoutSection.includes('Timeout')) {
|
|
301
|
-
throw new Error('Timing & Stability section must include timeout recommendations');
|
|
302
|
-
}
|
|
303
|
-
console.log(' ✓ Timeout recommendations exist');
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
function testExecutionTimeEstimatesExist() {
|
|
307
|
-
const phase2BuildContent = fs.readFileSync(PHASE_2_BUILD_PATH, 'utf-8');
|
|
308
|
-
if (!phase2BuildContent.includes('Expected Time')) {
|
|
309
|
-
throw new Error('phase-3-build.md must include expected execution time estimates');
|
|
310
|
-
}
|
|
311
|
-
console.log(' ✓ Expected execution time estimates exist');
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// === Orchestration Rules Tests ===
|
|
315
|
-
|
|
316
|
-
function testOrchestrationRulesExists() {
|
|
317
|
-
if (!fs.existsSync(ORCHESTRATION_RULES_PATH)) {
|
|
318
|
-
throw new Error('references/orchestration-rules.md must exist');
|
|
319
|
-
}
|
|
320
|
-
console.log(' ✓ orchestration-rules.md exists');
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function testPhaseSubagentMatrixOrder() {
|
|
324
|
-
const orchContent = fs.readFileSync(ORCHESTRATION_RULES_PATH, 'utf-8');
|
|
325
|
-
// The matrix order reflects file names, but phases should all be present
|
|
326
|
-
for (const phase of ['PREP', 'DESIGN', 'BUILD', 'VERIFY', 'SHIP', 'CLOSE']) {
|
|
327
|
-
if (!orchContent.includes(phase)) {
|
|
328
|
-
throw new Error(`orchestration-rules.md missing phase: ${phase}`);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
console.log(' ✓ Orchestration rules covers all key phases');
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// === Run All Tests ===
|
|
335
|
-
|
|
336
|
-
function runTests(opts = {}) {
|
|
337
|
-
const { exitOnFail = false } = opts;
|
|
338
|
-
let passed = 0;
|
|
339
|
-
let failed = 0;
|
|
340
|
-
const errors = [];
|
|
341
|
-
|
|
342
|
-
const tests = [
|
|
343
|
-
{ name: 'Positive triggers are present', fn: testPositiveTriggersArePresent },
|
|
344
|
-
{ name: 'Negative triggers have >= 8 entries', fn: testNegativeTriggersArePresent },
|
|
345
|
-
{ name: 'Negative trigger phrases verified', fn: testNegativeTriggerPhrases },
|
|
346
|
-
{ name: 'Positive trigger phrases verified', fn: testPositiveTriggerPhrases },
|
|
347
|
-
{ name: 'Negative test cases exist (>= 11)', fn: testNegativeTestCasesExist },
|
|
348
|
-
{ name: 'workflow_steps order matches canonical', fn: testWorkflowStepsOrder },
|
|
349
|
-
{ name: 'Phase Flow diagram has correct ordering', fn: testPhaseFlowDiagramOrder },
|
|
350
|
-
{ name: 'Phase Flow Consistency section exists', fn: testPhaseFlowConsistencySectionExists },
|
|
351
|
-
{ name: 'Canonical Phase Order table exists', fn: testCanonicalPhaseOrderTableExists },
|
|
352
|
-
{ name: 'All 6 phases in consistency section', fn: testAll11PhasesInPhaseFlowConsistency },
|
|
353
|
-
{ name: 'force-levels.md exists with three levels', fn: testForceLevelsDocumentExists },
|
|
354
|
-
{ name: 'force-levels.md requires Delphi review', fn: testForceLevelsRequiresDelphi },
|
|
355
|
-
{ name: 'Unique Value Proposition exists', fn: testUniqueValuePropositionExists },
|
|
356
|
-
{ name: 'UVP mentions 40-67% token savings', fn: testUvpMentionsTokenSavings },
|
|
357
|
-
{ name: 'UVP mentions HARD-GATE', fn: testUvpMentionsHardGate },
|
|
358
|
-
{ name: 'UVP mentions emergent requirements', fn: testUvpMentionsEmergentRequirements },
|
|
359
|
-
{ name: 'Timing & Stability section exists', fn: testTimingSectionExists },
|
|
360
|
-
{ name: 'Timeout recommendations exist', fn: testTimeoutRecommendationsExist },
|
|
361
|
-
{ name: 'Execution time estimates exist', fn: testExecutionTimeEstimatesExist },
|
|
362
|
-
{ name: 'orchestration-rules.md exists', fn: testOrchestrationRulesExists },
|
|
363
|
-
{ name: 'Orchestration covers all key phases', fn: testPhaseSubagentMatrixOrder },
|
|
364
|
-
{ name: 'Uncommitted Changes Gate section exists', fn: testUncommittedGateExists },
|
|
365
|
-
{ name: 'Uncommitted gate has escape valve', fn: testUncommittedGateEscapeValve },
|
|
366
|
-
{ name: 'Uncommitted gate has log path', fn: testUncommittedGateLogPath },
|
|
367
|
-
];
|
|
368
|
-
|
|
369
|
-
loadSkillMd();
|
|
370
|
-
|
|
371
|
-
for (const { name, fn } of tests) {
|
|
372
|
-
try {
|
|
373
|
-
fn();
|
|
374
|
-
passed++;
|
|
375
|
-
} catch (e) {
|
|
376
|
-
failed++;
|
|
377
|
-
errors.push(`FAIL: ${name}: ${e.message}`);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
console.log(`\n=== Results: ${passed} passed, ${failed} failed ===\n`);
|
|
382
|
-
for (const e of errors) console.log(e);
|
|
383
|
-
|
|
384
|
-
if (exitOnFail && failed > 0) {
|
|
385
|
-
process.exit(1);
|
|
386
|
-
}
|
|
387
|
-
return failed > 0 ? 1 : 0;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
// Uncommitted Changes Gate tests (must run after the section is added)
|
|
391
|
-
function testUncommittedGateExists() {
|
|
392
|
-
const phase2BuildContent = fs.readFileSync(PHASE_2_BUILD_PATH, 'utf-8');
|
|
393
|
-
if (!phase2BuildContent.includes('Uncommitted Changes Gate')) {
|
|
394
|
-
throw new Error('phase-3-build.md must contain "Uncommitted Changes Gate" section');
|
|
395
|
-
}
|
|
396
|
-
console.log(' ✓ Uncommitted Changes Gate section exists');
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
function testUncommittedGateEscapeValve() {
|
|
400
|
-
const phase2BuildContent = fs.readFileSync(PHASE_2_BUILD_PATH, 'utf-8');
|
|
401
|
-
if (!phase2BuildContent.includes('SKIP_UNCOMMITTED_GATE')) {
|
|
402
|
-
throw new Error('Uncommitted Changes Gate must provide SKIP_UNCOMMITTED_GATE escape valve');
|
|
403
|
-
}
|
|
404
|
-
console.log(' ✓ Uncommitted gate has SKIP_UNCOMMITTED_GATE escape valve');
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
function testUncommittedGateLogPath() {
|
|
408
|
-
const phase2BuildContent = fs.readFileSync(PHASE_2_BUILD_PATH, 'utf-8');
|
|
409
|
-
if (!phase2BuildContent.includes('.sprint-state/uncommitted-gate-log.json')) {
|
|
410
|
-
throw new Error('Uncommitted Changes Gate must log to .sprint-state/uncommitted-gate-log.json');
|
|
411
|
-
}
|
|
412
|
-
console.log(' ✓ Uncommitted gate logs to .sprint-state/uncommitted-gate-log.json');
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
// When run directly (node script.js), call with exitOnFail for CLI behavior.
|
|
416
|
-
if (require.main === module) {
|
|
417
|
-
const exitCode = runTests({ exitOnFail: true });
|
|
418
|
-
process.exit(exitCode);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
// Vitest discovery — wrap each test function as a vitest it() block
|
|
422
|
-
describe('sprint-flow SKILL.md', () => {
|
|
423
|
-
beforeAll(() => { loadSkillMd(); });
|
|
424
|
-
|
|
425
|
-
const tests = [
|
|
426
|
-
{ name: 'Positive triggers are present', fn: testPositiveTriggersArePresent },
|
|
427
|
-
{ name: 'Negative triggers have >= 8 entries', fn: testNegativeTriggersArePresent },
|
|
428
|
-
{ name: 'Negative trigger phrases verified', fn: testNegativeTriggerPhrases },
|
|
429
|
-
{ name: 'Positive trigger phrases verified', fn: testPositiveTriggerPhrases },
|
|
430
|
-
{ name: 'Negative test cases exist (>= 11)', fn: testNegativeTestCasesExist },
|
|
431
|
-
{ name: 'workflow_steps order matches canonical', fn: testWorkflowStepsOrder },
|
|
432
|
-
{ name: 'Phase Flow diagram has correct ordering', fn: testPhaseFlowDiagramOrder },
|
|
433
|
-
{ name: 'Phase Flow Consistency section exists', fn: testPhaseFlowConsistencySectionExists },
|
|
434
|
-
{ name: 'Canonical Phase Order table exists', fn: testCanonicalPhaseOrderTableExists },
|
|
435
|
-
{ name: 'All 6 phases in consistency section', fn: testAll11PhasesInPhaseFlowConsistency },
|
|
436
|
-
{ name: 'force-levels.md exists with three levels', fn: testForceLevelsDocumentExists },
|
|
437
|
-
{ name: 'force-levels.md requires Delphi review', fn: testForceLevelsRequiresDelphi },
|
|
438
|
-
{ name: 'Unique Value Proposition exists', fn: testUniqueValuePropositionExists },
|
|
439
|
-
{ name: 'UVP mentions 40-67% token savings', fn: testUvpMentionsTokenSavings },
|
|
440
|
-
{ name: 'UVP mentions HARD-GATE', fn: testUvpMentionsHardGate },
|
|
441
|
-
{ name: 'UVP mentions emergent requirements', fn: testUvpMentionsEmergentRequirements },
|
|
442
|
-
{ name: 'Timing & Stability section exists', fn: testTimingSectionExists },
|
|
443
|
-
{ name: 'Timeout recommendations exist', fn: testTimeoutRecommendationsExist },
|
|
444
|
-
{ name: 'Execution time estimates exist', fn: testExecutionTimeEstimatesExist },
|
|
445
|
-
{ name: 'orchestration-rules.md exists', fn: testOrchestrationRulesExists },
|
|
446
|
-
{ name: 'Orchestration covers all key phases', fn: testPhaseSubagentMatrixOrder },
|
|
447
|
-
{ name: 'Uncommitted Changes Gate section exists', fn: testUncommittedGateExists },
|
|
448
|
-
{ name: 'Uncommitted gate has escape valve', fn: testUncommittedGateEscapeValve },
|
|
449
|
-
{ name: 'Uncommitted gate has log path', fn: testUncommittedGateLogPath },
|
|
450
|
-
];
|
|
451
|
-
|
|
452
|
-
for (const { name, fn } of tests) {
|
|
453
|
-
it(name, () => { fn(); });
|
|
454
|
-
}
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
module.exports = { runTests };
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bats
|
|
2
|
-
# @test REQ-688
|
|
3
|
-
# @intent 验证 sprint-flow 的校验脚本能接受 `xp-gate sprint-init` 自己写出的状态文件
|
|
4
|
-
# ——脚本曾要求 sprint_id/current_phase/phases 这套从未被写入过的键,
|
|
5
|
-
# 对 CLI 刚创建的 sprint 恒判失败(#679)
|
|
6
|
-
# @covers AC-688-01, AC-688-02
|
|
7
|
-
#
|
|
8
|
-
# 为什么用真 sprint-init 而不是手写一个 fixture:缺陷的本质是「校验方与生产方对
|
|
9
|
-
# schema 的认知不一致」。手写 fixture 会把「我认为 CLI 写什么」固化下来,双方一起
|
|
10
|
-
# 错就一起绿。只有让生产方真的产出、校验方真的读,才能发现这类偏差。
|
|
11
|
-
|
|
12
|
-
setup() {
|
|
13
|
-
# #814: this used to be a hard-coded `../../..`, which resolves to the repo
|
|
14
|
-
# root only for THIS copy (skills/sprint-flow/__tests__). The same file also
|
|
15
|
-
# ships under plugins/<p>/skills/ and src/npm-package/**/skills/, three and four
|
|
16
|
-
# levels deep, where the fixed depth points at plugins/claude-code or
|
|
17
|
-
# src/npm-package -- so 6 of the 7 copies failed under Gate 5 and, once this
|
|
18
|
-
# repo's own hooks are installed, made every commit impossible.
|
|
19
|
-
#
|
|
20
|
-
# Walk up until the markers of the repo are both present instead of counting
|
|
21
|
-
# `..`. Depth-counting is what broke: it encodes "where this file lives" into a
|
|
22
|
-
# constant, and every new mirror location re-breaks it.
|
|
23
|
-
REPO_ROOT="$(cd "$BATS_TEST_DIRNAME" && pwd)"
|
|
24
|
-
while [ "$REPO_ROOT" != "/" ] && [ -n "$REPO_ROOT" ]; do
|
|
25
|
-
if [ -f "$REPO_ROOT/VERSION" ] && [ -f "$REPO_ROOT/src/npm-package/bin/xp-gate.js" ]; then
|
|
26
|
-
break
|
|
27
|
-
fi
|
|
28
|
-
REPO_ROOT="$(dirname "$REPO_ROOT")"
|
|
29
|
-
done
|
|
30
|
-
VERIFY="$REPO_ROOT/skills/sprint-flow/scripts/verify-sprint-state.sh"
|
|
31
|
-
CLI="$REPO_ROOT/src/npm-package/bin/xp-gate.js"
|
|
32
|
-
WORK="$(mktemp -d)"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
teardown() {
|
|
36
|
-
rm -rf "$WORK"
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@test "AC-688-01: accepts state written by xp-gate sprint-init" {
|
|
40
|
-
cd "$WORK"
|
|
41
|
-
git init -q .
|
|
42
|
-
# The developer machine sets a GLOBAL core.hooksPath at the installed hooks, so
|
|
43
|
-
# a bare `git commit` in the fixture would run the whole gate suite instead of
|
|
44
|
-
# creating the fixture commit. Pin it to an empty dir: this suite tests the
|
|
45
|
-
# verify script, not the hook chain.
|
|
46
|
-
mkdir -p "$WORK/empty-hooks"
|
|
47
|
-
git config core.hooksPath "$WORK/empty-hooks"
|
|
48
|
-
echo '{}' > package.json
|
|
49
|
-
git add -A
|
|
50
|
-
git -c user.email=t@t -c user.name=t commit -q -m init
|
|
51
|
-
|
|
52
|
-
run node "$CLI" sprint-init "probe task"
|
|
53
|
-
[ -f ".sprint-state/sprint-state.json" ]
|
|
54
|
-
|
|
55
|
-
run bash "$VERIFY"
|
|
56
|
-
[ "$status" -eq 0 ]
|
|
57
|
-
[[ "$output" == *"OK:"* ]]
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@test "AC-688-02: still rejects a state file missing real keys" {
|
|
61
|
-
# The fix must not become "accept anything": a file that lost its task or its
|
|
62
|
-
# phase is genuinely broken and the verifier should say so.
|
|
63
|
-
mkdir -p "$WORK/.sprint-state"
|
|
64
|
-
printf '{"id":"s-1","phase":"BUILD"}\n' > "$WORK/.sprint-state/sprint-state.json"
|
|
65
|
-
|
|
66
|
-
cd "$WORK"
|
|
67
|
-
run bash "$VERIFY"
|
|
68
|
-
[ "$status" -eq 1 ]
|
|
69
|
-
[[ "$output" == *"task_description"* ]]
|
|
70
|
-
}
|