scene-capability-engine 3.6.45 → 3.6.47

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +1 -0
  3. package/README.zh.md +1 -0
  4. package/docs/agent-runtime/symbol-evidence.schema.json +1 -1
  5. package/docs/command-reference.md +8 -0
  6. package/docs/interactive-customization/dialogue-governance-policy-baseline.json +4 -1
  7. package/docs/interactive-customization/embedded-assistant-authorization-dialogue-rules.md +5 -0
  8. package/docs/releases/README.md +2 -0
  9. package/docs/releases/v3.6.46.md +23 -0
  10. package/docs/releases/v3.6.47.md +23 -0
  11. package/docs/sce-business-mode-map.md +2 -1
  12. package/docs/sce-capability-matrix-e2e-example.md +2 -1
  13. package/docs/security-governance-default-baseline.md +2 -0
  14. package/docs/starter-kit/README.md +3 -0
  15. package/docs/zh/releases/README.md +2 -0
  16. package/docs/zh/releases/v3.6.46.md +23 -0
  17. package/docs/zh/releases/v3.6.47.md +23 -0
  18. package/lib/workspace/takeover-baseline.js +293 -1
  19. package/package.json +6 -2
  20. package/scripts/auto-strategy-router.js +231 -0
  21. package/scripts/capability-mapping-report.js +339 -0
  22. package/scripts/check-branding-consistency.js +140 -0
  23. package/scripts/check-sce-tracking.js +54 -0
  24. package/scripts/check-skip-allowlist.js +94 -0
  25. package/scripts/clarification-first-audit.js +322 -0
  26. package/scripts/errorbook-registry-health-gate.js +172 -0
  27. package/scripts/errorbook-release-gate.js +132 -0
  28. package/scripts/failure-attribution-repair.js +317 -0
  29. package/scripts/git-managed-gate.js +464 -0
  30. package/scripts/interactive-approval-event-projection.js +400 -0
  31. package/scripts/interactive-approval-workflow.js +829 -0
  32. package/scripts/interactive-authorization-tier-evaluate.js +413 -0
  33. package/scripts/interactive-change-plan-gate.js +225 -0
  34. package/scripts/interactive-context-bridge.js +617 -0
  35. package/scripts/interactive-customization-loop.js +1690 -0
  36. package/scripts/interactive-dialogue-governance.js +873 -0
  37. package/scripts/interactive-feedback-log.js +253 -0
  38. package/scripts/interactive-flow-smoke.js +238 -0
  39. package/scripts/interactive-flow.js +1059 -0
  40. package/scripts/interactive-governance-report.js +1112 -0
  41. package/scripts/interactive-intent-build.js +707 -0
  42. package/scripts/interactive-loop-smoke.js +215 -0
  43. package/scripts/interactive-moqui-adapter.js +304 -0
  44. package/scripts/interactive-plan-build.js +426 -0
  45. package/scripts/interactive-runtime-policy-evaluate.js +495 -0
  46. package/scripts/interactive-work-order-build.js +552 -0
  47. package/scripts/matrix-regression-gate.js +167 -0
  48. package/scripts/moqui-core-regression-suite.js +397 -0
  49. package/scripts/moqui-lexicon-audit.js +651 -0
  50. package/scripts/moqui-matrix-remediation-phased-runner.js +865 -0
  51. package/scripts/moqui-matrix-remediation-queue.js +852 -0
  52. package/scripts/moqui-metadata-extract.js +1340 -0
  53. package/scripts/moqui-rebuild-gate.js +167 -0
  54. package/scripts/moqui-release-summary.js +729 -0
  55. package/scripts/moqui-standard-rebuild.js +1370 -0
  56. package/scripts/moqui-template-baseline-report.js +682 -0
  57. package/scripts/npm-package-runtime-asset-check.js +221 -0
  58. package/scripts/problem-closure-gate.js +441 -0
  59. package/scripts/release-asset-integrity-check.js +216 -0
  60. package/scripts/release-asset-nonempty-normalize.js +166 -0
  61. package/scripts/release-drift-evaluate.js +223 -0
  62. package/scripts/release-drift-signals.js +255 -0
  63. package/scripts/release-governance-snapshot-export.js +132 -0
  64. package/scripts/release-ops-weekly-summary.js +934 -0
  65. package/scripts/release-risk-remediation-bundle.js +315 -0
  66. package/scripts/release-weekly-ops-gate.js +423 -0
  67. package/scripts/state-migration-reconciliation-gate.js +110 -0
  68. package/scripts/state-storage-tiering-audit.js +337 -0
  69. package/scripts/steering-content-audit.js +393 -0
  70. package/scripts/symbol-evidence-locate.js +370 -0
  71. package/template/.sce/README.md +1 -0
  72. package/template/.sce/steering/CORE_PRINCIPLES.md +25 -0
@@ -0,0 +1,339 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('fs-extra');
5
+ const path = require('path');
6
+
7
+ function parseArgs(argv = []) {
8
+ const options = {
9
+ input: '',
10
+ inputFile: '',
11
+ changesFile: '',
12
+ templatesFile: '',
13
+ ontologyFile: '',
14
+ out: '',
15
+ json: false
16
+ };
17
+
18
+ for (let index = 0; index < argv.length; index += 1) {
19
+ const token = argv[index];
20
+ const next = argv[index + 1];
21
+ if (token === '--input' && next) {
22
+ options.input = next;
23
+ index += 1;
24
+ continue;
25
+ }
26
+ if (token === '--input-file' && next) {
27
+ options.inputFile = next;
28
+ index += 1;
29
+ continue;
30
+ }
31
+ if (token === '--changes-file' && next) {
32
+ options.changesFile = next;
33
+ index += 1;
34
+ continue;
35
+ }
36
+ if (token === '--templates-file' && next) {
37
+ options.templatesFile = next;
38
+ index += 1;
39
+ continue;
40
+ }
41
+ if (token === '--ontology-file' && next) {
42
+ options.ontologyFile = next;
43
+ index += 1;
44
+ continue;
45
+ }
46
+ if (token === '--out' && next) {
47
+ options.out = next;
48
+ index += 1;
49
+ continue;
50
+ }
51
+ if (token === '--json') {
52
+ options.json = true;
53
+ continue;
54
+ }
55
+ if (token === '--help' || token === '-h') {
56
+ printHelpAndExit(0);
57
+ }
58
+ }
59
+
60
+ return options;
61
+ }
62
+
63
+ function printHelpAndExit(code) {
64
+ const lines = [
65
+ 'Usage: node scripts/capability-mapping-report.js [options]',
66
+ '',
67
+ 'Options:',
68
+ ' --input <json> Inline input payload (changes/templates/ontology)',
69
+ ' --input-file <path> Input JSON file (changes/templates/ontology)',
70
+ ' --changes-file <path> Changes JSON file (array)',
71
+ ' --templates-file <path> Template catalog JSON file (array)',
72
+ ' --ontology-file <path> Ontology model JSON file',
73
+ ' --out <path> Output report path',
74
+ ' --json Print JSON payload',
75
+ ' -h, --help Show this help'
76
+ ];
77
+ console.log(lines.join('\n'));
78
+ process.exit(code);
79
+ }
80
+
81
+ async function readJsonIfExists(filePath) {
82
+ if (!filePath) {
83
+ return null;
84
+ }
85
+ const resolved = path.resolve(process.cwd(), filePath);
86
+ if (!(await fs.pathExists(resolved))) {
87
+ throw new Error(`file not found: ${filePath}`);
88
+ }
89
+ return fs.readJson(resolved);
90
+ }
91
+
92
+ function normalizeChanges(changes) {
93
+ const array = Array.isArray(changes) ? changes : [];
94
+ return array
95
+ .filter((item) => item && typeof item === 'object')
96
+ .map((item) => {
97
+ const type = `${item.type || item.node_type || ''}`.trim().toLowerCase();
98
+ const name = `${item.name || item.ref || item.id || ''}`.trim();
99
+ const changeId = `${item.change_id || item.id || (type && name ? `${type}:${name}` : name || type || 'unknown')}`;
100
+ return {
101
+ change_id: changeId,
102
+ type: type || 'unknown',
103
+ name: name || changeId,
104
+ operation: `${item.operation || item.action || 'update'}`.trim().toLowerCase()
105
+ };
106
+ });
107
+ }
108
+
109
+ function normalizeTemplates(templates) {
110
+ const array = Array.isArray(templates) ? templates : [];
111
+ return array
112
+ .filter((item) => item && typeof item === 'object')
113
+ .map((item) => ({
114
+ id: `${item.id || item.template_id || item.name || 'unknown-template'}`.trim(),
115
+ capabilities: Array.isArray(item.capabilities)
116
+ ? item.capabilities.map((capability) => `${capability}`.trim().toLowerCase()).filter(Boolean)
117
+ : []
118
+ }));
119
+ }
120
+
121
+ function normalizeOntology(ontology = {}) {
122
+ const pickNames = (values) => {
123
+ if (!Array.isArray(values)) {
124
+ return new Set();
125
+ }
126
+ return new Set(
127
+ values
128
+ .map((value) => {
129
+ if (typeof value === 'string') {
130
+ return value.trim().toLowerCase();
131
+ }
132
+ if (value && typeof value === 'object') {
133
+ return `${value.name || value.ref || value.id || ''}`.trim().toLowerCase();
134
+ }
135
+ return '';
136
+ })
137
+ .filter(Boolean)
138
+ );
139
+ };
140
+
141
+ return {
142
+ entities: pickNames(ontology.entities),
143
+ business_rules: pickNames(ontology.business_rules),
144
+ decision_strategies: pickNames(ontology.decision_strategies),
145
+ relations: Array.isArray(ontology.relations) ? ontology.relations : []
146
+ };
147
+ }
148
+
149
+ function normalizeCapability(type, name) {
150
+ const loweredName = `${name || ''}`.trim().toLowerCase();
151
+ if (!loweredName) {
152
+ return 'unknown:unknown';
153
+ }
154
+ if (type === 'entity') {
155
+ return `entity:${loweredName}`;
156
+ }
157
+ if (type === 'business_rule' || type === 'rule') {
158
+ return `rule:${loweredName}`;
159
+ }
160
+ if (type === 'decision_strategy' || type === 'decision') {
161
+ return `decision:${loweredName}`;
162
+ }
163
+ if (type === 'service') {
164
+ return `service:${loweredName}`;
165
+ }
166
+ if (type === 'scene') {
167
+ return `scene:${loweredName}`;
168
+ }
169
+ return `${type || 'unknown'}:${loweredName}`;
170
+ }
171
+
172
+ function capabilityMatches(capability, templateCapability) {
173
+ if (!capability || !templateCapability) {
174
+ return false;
175
+ }
176
+ if (templateCapability === capability) {
177
+ return true;
178
+ }
179
+ if (templateCapability.endsWith('*')) {
180
+ const prefix = templateCapability.slice(0, -1);
181
+ return capability.startsWith(prefix);
182
+ }
183
+ return false;
184
+ }
185
+
186
+ function findMappedTemplates(capability, templates) {
187
+ const mapped = [];
188
+ for (const template of templates) {
189
+ if (template.capabilities.some((item) => capabilityMatches(capability, item))) {
190
+ mapped.push(template.id);
191
+ }
192
+ }
193
+ return mapped;
194
+ }
195
+
196
+ function checkOntologyCoverage(type, name, ontology) {
197
+ const loweredName = `${name || ''}`.trim().toLowerCase();
198
+ if (!loweredName) {
199
+ return false;
200
+ }
201
+ if (type === 'entity') {
202
+ return ontology.entities.has(loweredName);
203
+ }
204
+ if (type === 'business_rule' || type === 'rule') {
205
+ return ontology.business_rules.has(loweredName);
206
+ }
207
+ if (type === 'decision_strategy' || type === 'decision') {
208
+ return ontology.decision_strategies.has(loweredName);
209
+ }
210
+ return true;
211
+ }
212
+
213
+ function buildMappingReport({ changes, templates, ontology }) {
214
+ const mappingReport = [];
215
+ const missingCapabilities = [];
216
+ const recommendedTemplates = new Set();
217
+ const ontologyGaps = [];
218
+
219
+ for (const change of changes) {
220
+ const capability = normalizeCapability(change.type, change.name);
221
+ const mappedTemplates = findMappedTemplates(capability, templates);
222
+ const ontologyCovered = checkOntologyCoverage(change.type, change.name, ontology);
223
+
224
+ for (const templateId of mappedTemplates) {
225
+ recommendedTemplates.add(templateId);
226
+ }
227
+
228
+ if (mappedTemplates.length === 0) {
229
+ missingCapabilities.push(capability);
230
+ }
231
+ if (!ontologyCovered) {
232
+ ontologyGaps.push({
233
+ change_id: change.change_id,
234
+ type: change.type,
235
+ name: change.name,
236
+ capability
237
+ });
238
+ }
239
+
240
+ const status = mappedTemplates.length > 0
241
+ ? 'mapped'
242
+ : (ontologyCovered ? 'missing_template' : 'missing_template_and_ontology_gap');
243
+
244
+ mappingReport.push({
245
+ change_id: change.change_id,
246
+ capability,
247
+ mapped_templates: mappedTemplates,
248
+ ontology_status: ontologyCovered ? 'covered' : 'gap',
249
+ status
250
+ });
251
+ }
252
+
253
+ const totalChanges = mappingReport.length;
254
+ const mappedChanges = mappingReport.filter((item) => item.mapped_templates.length > 0).length;
255
+ const coveragePercent = totalChanges === 0
256
+ ? 100
257
+ : Number(((mappedChanges / totalChanges) * 100).toFixed(2));
258
+
259
+ return {
260
+ mode: 'capability-mapping-report',
261
+ generated_at: new Date().toISOString(),
262
+ mapping_report: mappingReport,
263
+ missing_capabilities: [...new Set(missingCapabilities)],
264
+ recommended_templates: [...recommendedTemplates],
265
+ ontology_gaps: ontologyGaps,
266
+ summary: {
267
+ total_changes: totalChanges,
268
+ mapped_changes: mappedChanges,
269
+ missing_capabilities: [...new Set(missingCapabilities)].length,
270
+ ontology_gaps: ontologyGaps.length,
271
+ coverage_percent: coveragePercent
272
+ }
273
+ };
274
+ }
275
+
276
+ async function loadInput(options) {
277
+ const inline = options.input ? JSON.parse(options.input) : null;
278
+ const inputFilePayload = options.inputFile ? await readJsonIfExists(options.inputFile) : null;
279
+ const changesPayload = options.changesFile ? await readJsonIfExists(options.changesFile) : null;
280
+ const templatesPayload = options.templatesFile ? await readJsonIfExists(options.templatesFile) : null;
281
+ const ontologyPayload = options.ontologyFile ? await readJsonIfExists(options.ontologyFile) : null;
282
+
283
+ const source = inline || inputFilePayload || {};
284
+ const changes = normalizeChanges(
285
+ changesPayload || source.changes || source.change_set || source.mapping_input
286
+ );
287
+ const templates = normalizeTemplates(
288
+ templatesPayload || source.templates || source.template_catalog || source.scene_templates
289
+ );
290
+ const ontology = normalizeOntology(
291
+ ontologyPayload || source.ontology || source.ontology_model || {}
292
+ );
293
+
294
+ return {
295
+ changes,
296
+ templates,
297
+ ontology
298
+ };
299
+ }
300
+
301
+ async function main() {
302
+ const options = parseArgs(process.argv.slice(2));
303
+ const input = await loadInput(options);
304
+ const payload = buildMappingReport(input);
305
+
306
+ if (options.out) {
307
+ const outPath = path.resolve(process.cwd(), options.out);
308
+ await fs.ensureDir(path.dirname(outPath));
309
+ await fs.writeJson(outPath, payload, { spaces: 2 });
310
+ }
311
+
312
+ if (options.json) {
313
+ process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
314
+ } else {
315
+ process.stdout.write(`capability mapping coverage=${payload.summary.coverage_percent}%\n`);
316
+ process.stdout.write(`missing_capabilities=${payload.summary.missing_capabilities}\n`);
317
+ process.stdout.write(`ontology_gaps=${payload.summary.ontology_gaps}\n`);
318
+ }
319
+ }
320
+
321
+ if (require.main === module) {
322
+ main().catch((error) => {
323
+ console.error(`capability-mapping-report failed: ${error.message}`);
324
+ process.exit(1);
325
+ });
326
+ }
327
+
328
+ module.exports = {
329
+ parseArgs,
330
+ normalizeChanges,
331
+ normalizeTemplates,
332
+ normalizeOntology,
333
+ normalizeCapability,
334
+ capabilityMatches,
335
+ findMappedTemplates,
336
+ checkOntologyCoverage,
337
+ buildMappingReport,
338
+ loadInput
339
+ };
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execSync } = require('child_process');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+
7
+ const LEGACY_PATTERNS = [
8
+ {
9
+ label: 'legacy CLI alias',
10
+ regex: /\bkse\b/gi
11
+ },
12
+ {
13
+ label: 'legacy social handle',
14
+ regex: /@kse_dev/gi
15
+ },
16
+ {
17
+ label: 'legacy GitHub repository URL',
18
+ regex: /https:\/\/github\.com\/heguangyong\/kiro-spec-engine/gi
19
+ },
20
+ {
21
+ label: 'legacy template repository name',
22
+ regex: /\bkse-spec-templates\b/gi
23
+ },
24
+ {
25
+ label: 'legacy product naming',
26
+ regex: /\bKiro Spec Engine\b|\bScene Capability Orchestrator\b|场景能力编排引擎/g
27
+ },
28
+ {
29
+ label: 'legacy Kiro IDE wording',
30
+ regex: /\bKiro IDE\b/gi
31
+ },
32
+ {
33
+ label: 'legacy npm package name',
34
+ regex: /\bsco-engine\b/gi
35
+ }
36
+ ];
37
+
38
+ const EXCLUDE_PREFIXES = [
39
+ '.sce/',
40
+ 'tests/fixtures/',
41
+ 'node_modules/'
42
+ ];
43
+
44
+ const EXCLUDE_FILES = new Set([
45
+ 'scripts/check-branding-consistency.js'
46
+ ]);
47
+
48
+ const HISTORY_ALLOW_PREFIXES = [
49
+ 'docs/releases/',
50
+ 'docs/zh/releases/'
51
+ ];
52
+
53
+ const HISTORY_ALLOW_FILES = new Set([
54
+ 'CHANGELOG.md'
55
+ ]);
56
+
57
+ const TEXT_EXTENSIONS = new Set([
58
+ '.js', '.json', '.md', '.txt', '.yml', '.yaml'
59
+ ]);
60
+
61
+ function getTrackedFiles() {
62
+ const output = execSync('git ls-files', { encoding: 'utf8' });
63
+ return output
64
+ .split(/\r?\n/)
65
+ .map((line) => line.trim())
66
+ .filter(Boolean);
67
+ }
68
+
69
+ function shouldScan(filePath) {
70
+ if (EXCLUDE_FILES.has(filePath)) {
71
+ return false;
72
+ }
73
+
74
+ if (EXCLUDE_PREFIXES.some((prefix) => filePath.startsWith(prefix))) {
75
+ return false;
76
+ }
77
+
78
+ const ext = path.extname(filePath).toLowerCase();
79
+ return TEXT_EXTENSIONS.has(ext);
80
+ }
81
+
82
+ function isHistoryDocument(filePath) {
83
+ return HISTORY_ALLOW_FILES.has(filePath)
84
+ || HISTORY_ALLOW_PREFIXES.some((prefix) => filePath.startsWith(prefix));
85
+ }
86
+
87
+ function scanFile(filePath) {
88
+ let content = '';
89
+ try {
90
+ content = fs.readFileSync(filePath, 'utf8');
91
+ } catch (_error) {
92
+ return [];
93
+ }
94
+
95
+ const hits = [];
96
+
97
+ for (const pattern of LEGACY_PATTERNS) {
98
+ const matches = content.match(pattern.regex);
99
+ if (matches && matches.length > 0) {
100
+ if (isHistoryDocument(filePath)) {
101
+ continue;
102
+ }
103
+ hits.push({
104
+ label: pattern.label,
105
+ count: matches.length
106
+ });
107
+ }
108
+ }
109
+
110
+ return hits;
111
+ }
112
+
113
+ function main() {
114
+ const files = getTrackedFiles().filter(shouldScan);
115
+ const violations = [];
116
+
117
+ for (const filePath of files) {
118
+ const hits = scanFile(filePath);
119
+ if (hits.length > 0) {
120
+ violations.push({ filePath, hits });
121
+ }
122
+ }
123
+
124
+ if (violations.length === 0) {
125
+ console.log('Branding consistency check passed: no legacy naming references found.');
126
+ return;
127
+ }
128
+
129
+ console.error('Branding consistency check failed. Found legacy naming references:');
130
+ for (const violation of violations) {
131
+ const summary = violation.hits
132
+ .map((hit) => `${hit.label} x${hit.count}`)
133
+ .join(', ');
134
+ console.error(`- ${violation.filePath}: ${summary}`);
135
+ }
136
+
137
+ process.exit(1);
138
+ }
139
+
140
+ main();
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { auditSceTracking } = require('../lib/workspace/sce-tracking-audit');
4
+
5
+ function printTextReport(report) {
6
+ if (report.passed) {
7
+ console.log('SCE tracking audit passed.');
8
+ console.log(`Fixture tracked specs: ${report.summary.fixture_spec_files}`);
9
+ console.log(`Fixture tracked templates: ${report.summary.fixture_template_files}`);
10
+ return;
11
+ }
12
+
13
+ console.error('SCE tracking audit failed.');
14
+ if (report.missing_required_files.length > 0) {
15
+ console.error('Missing required tracked files:');
16
+ for (const filePath of report.missing_required_files) {
17
+ console.error(` - ${filePath}`);
18
+ }
19
+ }
20
+ if (report.summary.fixture_spec_files === 0) {
21
+ console.error('No tracked fixture spec files were found under tests/fixtures/.../.sce/specs.');
22
+ }
23
+ if (report.summary.fixture_template_files === 0) {
24
+ console.error('No tracked fixture template files were found under tests/fixtures/.../.sce/templates.');
25
+ }
26
+ if (report.fixture.disallowed_tracked_files.length > 0) {
27
+ console.error('Disallowed tracked fixture runtime files found:');
28
+ for (const filePath of report.fixture.disallowed_tracked_files) {
29
+ console.error(` - ${filePath}`);
30
+ }
31
+ }
32
+ }
33
+
34
+ function main() {
35
+ const json = process.argv.includes('--json');
36
+ const report = auditSceTracking(process.cwd());
37
+
38
+ if (json) {
39
+ console.log(JSON.stringify(report, null, 2));
40
+ } else {
41
+ printTextReport(report);
42
+ }
43
+
44
+ if (!report.passed) {
45
+ process.exit(1);
46
+ }
47
+ }
48
+
49
+ try {
50
+ main();
51
+ } catch (error) {
52
+ console.error(`SCE tracking audit error: ${error.message}`);
53
+ process.exit(1);
54
+ }
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const repoRoot = path.resolve(__dirname, '..');
7
+ const testsRoot = path.join(repoRoot, 'tests');
8
+ const allowlistPath = path.join(repoRoot, 'tests', 'skip-allowlist.txt');
9
+
10
+ function walkFiles(dirPath) {
11
+ const entries = fs.readdirSync(dirPath, { withFileTypes: true });
12
+ const files = [];
13
+
14
+ for (const entry of entries) {
15
+ const absolutePath = path.join(dirPath, entry.name);
16
+ if (entry.isDirectory()) {
17
+ files.push(...walkFiles(absolutePath));
18
+ continue;
19
+ }
20
+
21
+ if (entry.isFile() && (entry.name.endsWith('.test.js') || entry.name.endsWith('.spec.js'))) {
22
+ files.push(absolutePath);
23
+ }
24
+ }
25
+
26
+ return files;
27
+ }
28
+
29
+ function loadAllowlist(filePath) {
30
+ if (!fs.existsSync(filePath)) {
31
+ throw new Error(`Allowlist file not found: ${filePath}`);
32
+ }
33
+
34
+ return fs.readFileSync(filePath, 'utf8')
35
+ .split(/\r?\n/)
36
+ .map(line => line.trim())
37
+ .filter(line => line.length > 0 && !line.startsWith('#'));
38
+ }
39
+
40
+ function collectSkippedTests() {
41
+ const testFiles = walkFiles(testsRoot);
42
+ const skipPattern = /\b(?:test|it|describe)\.skip\(\s*(['"`])([^'"`]+)\1/g;
43
+ const skipped = [];
44
+
45
+ for (const filePath of testFiles) {
46
+ const content = fs.readFileSync(filePath, 'utf8');
47
+ const relativePath = path.relative(repoRoot, filePath).replace(/\\/g, '/');
48
+ let match = skipPattern.exec(content);
49
+
50
+ while (match) {
51
+ skipped.push(`${relativePath}::${match[2]}`);
52
+ match = skipPattern.exec(content);
53
+ }
54
+ }
55
+
56
+ return skipped.sort();
57
+ }
58
+
59
+ function main() {
60
+ const allowlist = loadAllowlist(allowlistPath);
61
+ const skipped = collectSkippedTests();
62
+
63
+ const allowSet = new Set(allowlist);
64
+ const skippedSet = new Set(skipped);
65
+
66
+ const unexpected = skipped.filter(item => !allowSet.has(item));
67
+ const stale = allowlist.filter(item => !skippedSet.has(item));
68
+
69
+ console.log(`Skip audit: ${skipped.length} skipped tests, ${allowlist.length} allowlisted entries`);
70
+
71
+ if (stale.length > 0) {
72
+ console.log('Stale allowlist entries (safe to remove):');
73
+ for (const item of stale) {
74
+ console.log(` - ${item}`);
75
+ }
76
+ }
77
+
78
+ if (unexpected.length > 0) {
79
+ console.error('Unexpected skipped tests found:');
80
+ for (const item of unexpected) {
81
+ console.error(` - ${item}`);
82
+ }
83
+ process.exit(1);
84
+ }
85
+
86
+ console.log('Skip audit passed.');
87
+ }
88
+
89
+ try {
90
+ main();
91
+ } catch (error) {
92
+ console.error(`Skip audit failed: ${error.message}`);
93
+ process.exit(1);
94
+ }