@ryuenn3123/agentic-senior-core 2.0.5 → 2.0.7

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 (121) hide show
  1. package/.agent-context/blueprints/mobile-app.md +91 -21
  2. package/.agent-context/profiles/platform.md +13 -13
  3. package/.agent-context/profiles/regulated.md +13 -13
  4. package/.agent-context/profiles/startup.md +13 -13
  5. package/.agent-context/review-checklists/frontend-skill-parity.md +28 -28
  6. package/.agent-context/review-checklists/frontend-usability.md +33 -33
  7. package/.agent-context/review-checklists/release-operations.md +29 -29
  8. package/.agent-context/skills/README.md +62 -62
  9. package/.agent-context/skills/backend/README.md +67 -67
  10. package/.agent-context/skills/backend/architecture.md +360 -360
  11. package/.agent-context/skills/backend/compatibility-manifest.json +8 -8
  12. package/.agent-context/skills/backend/data-access.md +230 -230
  13. package/.agent-context/skills/backend/errors.md +137 -137
  14. package/.agent-context/skills/backend/validation.md +116 -116
  15. package/.agent-context/skills/backend.md +28 -28
  16. package/.agent-context/skills/cli/README.md +55 -49
  17. package/.agent-context/skills/cli/compatibility-manifest.json +8 -8
  18. package/.agent-context/skills/cli/init.md +37 -37
  19. package/.agent-context/skills/cli/output.md +35 -35
  20. package/.agent-context/skills/cli/safety-telemetry.md +39 -0
  21. package/.agent-context/skills/cli/upgrade.md +37 -37
  22. package/.agent-context/skills/cli.md +31 -28
  23. package/.agent-context/skills/distribution/.evidence/compatibility-manifest.json +9 -0
  24. package/.agent-context/skills/distribution/.evidence/sbom-excerpt.json +6 -0
  25. package/.agent-context/skills/distribution/.evidence/test-report.json +8 -0
  26. package/.agent-context/skills/distribution/CHANGELOG.md +7 -0
  27. package/.agent-context/skills/distribution/README.md +27 -19
  28. package/.agent-context/skills/distribution/compatibility-manifest.json +8 -8
  29. package/.agent-context/skills/distribution/compatibility.md +31 -31
  30. package/.agent-context/skills/distribution/package.json +5 -0
  31. package/.agent-context/skills/distribution/provenance-attestation.md +47 -0
  32. package/.agent-context/skills/distribution/publish.md +36 -36
  33. package/.agent-context/skills/distribution/rollback.md +31 -31
  34. package/.agent-context/skills/distribution/tests/.gitkeep +1 -0
  35. package/.agent-context/skills/distribution.md +31 -28
  36. package/.agent-context/skills/frontend/.evidence/compatibility-manifest.json +9 -0
  37. package/.agent-context/skills/frontend/.evidence/sbom-excerpt.json +6 -0
  38. package/.agent-context/skills/frontend/.evidence/test-report.json +8 -0
  39. package/.agent-context/skills/frontend/CHANGELOG.md +7 -0
  40. package/.agent-context/skills/frontend/README.md +49 -36
  41. package/.agent-context/skills/frontend/accessibility.md +107 -107
  42. package/.agent-context/skills/frontend/compatibility-manifest.json +8 -8
  43. package/.agent-context/skills/frontend/conversion-clarity.md +51 -0
  44. package/.agent-context/skills/frontend/motion.md +66 -66
  45. package/.agent-context/skills/frontend/package.json +5 -0
  46. package/.agent-context/skills/frontend/performance.md +62 -62
  47. package/.agent-context/skills/frontend/responsive-delivery.md +41 -0
  48. package/.agent-context/skills/frontend/tests/.gitkeep +1 -0
  49. package/.agent-context/skills/frontend/ui-architecture.md +128 -128
  50. package/.agent-context/skills/frontend.md +35 -29
  51. package/.agent-context/skills/fullstack/.evidence/compatibility-manifest.json +9 -0
  52. package/.agent-context/skills/fullstack/.evidence/sbom-excerpt.json +6 -0
  53. package/.agent-context/skills/fullstack/.evidence/test-report.json +8 -0
  54. package/.agent-context/skills/fullstack/CHANGELOG.md +7 -0
  55. package/.agent-context/skills/fullstack/README.md +27 -19
  56. package/.agent-context/skills/fullstack/compatibility-manifest.json +8 -8
  57. package/.agent-context/skills/fullstack/contracts.md +52 -52
  58. package/.agent-context/skills/fullstack/end-to-end.md +41 -41
  59. package/.agent-context/skills/fullstack/feature-slicing.md +64 -64
  60. package/.agent-context/skills/fullstack/package.json +5 -0
  61. package/.agent-context/skills/fullstack/release-coordination.md +51 -0
  62. package/.agent-context/skills/fullstack/tests/.gitkeep +1 -0
  63. package/.agent-context/skills/fullstack.md +29 -26
  64. package/.agent-context/skills/index.json +107 -107
  65. package/.agent-context/skills/review-quality/.evidence/compatibility-manifest.json +9 -0
  66. package/.agent-context/skills/review-quality/.evidence/sbom-excerpt.json +6 -0
  67. package/.agent-context/skills/review-quality/.evidence/test-report.json +8 -0
  68. package/.agent-context/skills/review-quality/CHANGELOG.md +7 -0
  69. package/.agent-context/skills/review-quality/README.md +27 -19
  70. package/.agent-context/skills/review-quality/benchmark.md +29 -29
  71. package/.agent-context/skills/review-quality/compatibility-manifest.json +8 -8
  72. package/.agent-context/skills/review-quality/package.json +5 -0
  73. package/.agent-context/skills/review-quality/planning.md +37 -37
  74. package/.agent-context/skills/review-quality/release-decision.md +49 -0
  75. package/.agent-context/skills/review-quality/security.md +33 -33
  76. package/.agent-context/skills/review-quality/tests/.gitkeep +1 -0
  77. package/.agent-context/skills/review-quality.md +30 -27
  78. package/.agent-context/stacks/flutter.md +16 -16
  79. package/.agent-context/stacks/react-native.md +16 -16
  80. package/.agent-context/state/architecture-map.md +25 -25
  81. package/.agent-context/state/benchmark-analysis.json +431 -431
  82. package/.agent-context/state/benchmark-thresholds.json +10 -10
  83. package/.agent-context/state/benchmark-watchlist.json +19 -19
  84. package/.agent-context/state/dependency-map.md +32 -32
  85. package/.agent-context/state/quality-trend-report.json +16 -6
  86. package/.agent-context/state/skill-platform.json +38 -38
  87. package/.agent-context/state/weekly-governance-report.json +126 -0
  88. package/.agent-override.md +36 -36
  89. package/.cursorrules +1 -1
  90. package/.gemini/instructions.md +20 -20
  91. package/.github/ISSUE_TEMPLATE/v1.7-frontend-work-item.yml +54 -54
  92. package/.github/copilot-instructions.md +20 -20
  93. package/.github/workflows/benchmark-detection.yml +38 -38
  94. package/.github/workflows/benchmark-intelligence.yml +50 -50
  95. package/.github/workflows/frontend-usability-gate.yml +36 -36
  96. package/.github/workflows/governance-weekly-report.yml +43 -0
  97. package/.github/workflows/release-gate.yml +32 -32
  98. package/.github/workflows/sbom-compliance.yml +32 -32
  99. package/.windsurfrules +1 -1
  100. package/AGENTS.md +27 -27
  101. package/README.md +383 -368
  102. package/lib/cli/commands/optimize.mjs +171 -171
  103. package/lib/cli/compatibility.mjs +124 -124
  104. package/lib/cli/constants.mjs +35 -0
  105. package/lib/cli/token-optimization.mjs +275 -275
  106. package/lib/cli/utils.mjs +4 -1
  107. package/mcp.json +92 -92
  108. package/package.json +2 -1
  109. package/scripts/benchmark-gate.mjs +121 -121
  110. package/scripts/benchmark-intelligence.mjs +140 -140
  111. package/scripts/detection-benchmark.mjs +138 -138
  112. package/scripts/frontend-usability-audit.mjs +87 -87
  113. package/scripts/generate-sbom.mjs +61 -61
  114. package/scripts/governance-weekly-report.mjs +293 -0
  115. package/scripts/init-project.ps1 +104 -104
  116. package/scripts/llm-judge.mjs +664 -664
  117. package/scripts/quality-trend-report.mjs +288 -288
  118. package/scripts/release-gate.mjs +261 -259
  119. package/scripts/skill-tier-policy.mjs +75 -75
  120. package/scripts/token-optimization-benchmark.mjs +252 -252
  121. package/scripts/validate.mjs +874 -865
@@ -1,865 +1,874 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * validate.mjs — Repository Integrity Validator
5
- *
6
- * Validates the Agentic-Senior-Core repository:
7
- * - Required files exist
8
- * - Markdown and JSON documents are readable
9
- * - Cross-references resolve from the correct source directory
10
- * - Version references stay consistent for release builds
11
- * - LLM Judge policy configuration is valid
12
- *
13
- * Usage: node scripts/validate.mjs
14
- */
15
-
16
- import { readdir, readFile, stat } from 'node:fs/promises';
17
- import { dirname, join, relative, resolve } from 'node:path';
18
- import { fileURLToPath } from 'node:url';
19
- import { createHash } from 'node:crypto';
20
- import { validateSkillTopicContent } from './skill-tier-policy.mjs';
21
- import { calculateTrustScore } from './trust-scorer.mjs';
22
-
23
- const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
24
- const ROOT_DIR = resolve(dirname(SCRIPT_FILE_PATH), '..');
25
- const AGENT_CONTEXT_DIR = join(ROOT_DIR, '.agent-context');
26
- const CANONICAL_INSTRUCTION_PATH = join(ROOT_DIR, '.instructions.md');
27
- const PACKAGE_JSON_PATH = join(ROOT_DIR, 'package.json');
28
- const CHANGELOG_PATH = join(ROOT_DIR, 'CHANGELOG.md');
29
- const README_PATH = join(ROOT_DIR, 'README.md');
30
- const POLICY_FILE_PATH = join(ROOT_DIR, '.agent-context', 'policies', 'llm-judge-threshold.json');
31
- const OVERRIDE_FILE_PATH = join(ROOT_DIR, '.agent-override.md');
32
- const SKILLS_DIR = join(AGENT_CONTEXT_DIR, 'skills');
33
- const GENERATED_RULE_FILES = ['.cursorrules', '.windsurfrules'];
34
- const ALLOWED_SEVERITIES = new Set(['critical', 'high', 'medium', 'low']);
35
- const OVERRIDE_WARNING_WINDOW_DAYS = 30;
36
- const SUPPORTED_COMPATIBILITY_PLATFORMS = new Set(['windows', 'linux', 'macos']);
37
- const THIN_ADAPTER_PATHS = [
38
- 'AGENTS.md',
39
- '.github/copilot-instructions.md',
40
- '.gemini/instructions.md',
41
- ];
42
-
43
- const validationResult = {
44
- passed: 0,
45
- failed: 0,
46
- errors: [],
47
- warnings: [],
48
- };
49
-
50
- async function fileExists(filePath) {
51
- try {
52
- await stat(filePath);
53
- return true;
54
- } catch {
55
- return false;
56
- }
57
- }
58
-
59
- async function readTextFile(filePath) {
60
- return readFile(filePath, 'utf8');
61
- }
62
-
63
- async function collectFiles(directoryPath, fileExtensionMatcher) {
64
- const matchingFilePaths = [];
65
-
66
- async function walk(currentDirectoryPath) {
67
- const directoryEntries = await readdir(currentDirectoryPath, { withFileTypes: true });
68
-
69
- for (const directoryEntry of directoryEntries) {
70
- if (
71
- directoryEntry.name === '.git'
72
- || directoryEntry.name === 'node_modules'
73
- || directoryEntry.name === '.agentic-backup'
74
- || directoryEntry.name === '.benchmarks'
75
- ) {
76
- continue;
77
- }
78
-
79
- const entryPath = join(currentDirectoryPath, directoryEntry.name);
80
-
81
- if (directoryEntry.isDirectory()) {
82
- await walk(entryPath);
83
- continue;
84
- }
85
-
86
- if (fileExtensionMatcher(directoryEntry.name)) {
87
- matchingFilePaths.push(entryPath);
88
- }
89
- }
90
- }
91
-
92
- await walk(directoryPath);
93
- return matchingFilePaths;
94
- }
95
-
96
- function pass(message) {
97
- validationResult.passed += 1;
98
- console.log(` PASS ${message}`);
99
- }
100
-
101
- function fail(message) {
102
- validationResult.failed += 1;
103
- validationResult.errors.push(message);
104
- console.log(` FAIL ${message}`);
105
- }
106
-
107
- function warn(message) {
108
- validationResult.warnings.push(message);
109
- console.log(` WARN ${message}`);
110
- }
111
-
112
- async function validateRequiredFiles() {
113
- console.log('\nChecking required files...');
114
-
115
- const requiredFiles = [
116
- 'bin/agentic-senior-core.js',
117
- 'scripts/validate.mjs',
118
- 'scripts/llm-judge.mjs',
119
- 'scripts/detection-benchmark.mjs',
120
- 'scripts/benchmark-gate.mjs',
121
- 'scripts/benchmark-intelligence.mjs',
122
- 'scripts/frontend-usability-audit.mjs',
123
- 'scripts/release-gate.mjs',
124
- 'scripts/generate-sbom.mjs',
125
- 'scripts/init-project.sh',
126
- 'scripts/init-project.ps1',
127
- '.cursorrules',
128
- '.windsurfrules',
129
- '.agent-override.md',
130
- '.agent-context/policies/llm-judge-threshold.json',
131
- 'mcp.json',
132
- 'AGENTS.md',
133
- '.github/copilot-instructions.md',
134
- '.gemini/instructions.md',
135
- 'README.md',
136
- 'CHANGELOG.md',
137
- 'docs/faq.md',
138
- 'docs/deep-dive.md',
139
- 'docs/v1.7-execution-playbook.md',
140
- 'docs/v1.7-issue-breakdown.md',
141
- 'docs/v1.8-operations-playbook.md',
142
- 'docs/v2-upgrade-playbook.md',
143
- '.agent-context/state/benchmark-watchlist.json',
144
- '.agent-context/state/skill-platform.json',
145
- '.agent-context/skills/index.json',
146
- '.github/workflows/release-gate.yml',
147
- '.github/workflows/sbom-compliance.yml',
148
- '.github/workflows/benchmark-intelligence.yml',
149
- 'tests/cli-smoke.test.mjs',
150
- 'tests/llm-judge.test.mjs',
151
- 'tests/enterprise-ops.test.mjs',
152
- 'LICENSE',
153
- '.gitignore',
154
- '.agent-context/marketplace/trust-tiers.json',
155
- ];
156
-
157
- for (const requiredFilePath of requiredFiles) {
158
- const absoluteRequiredFilePath = join(ROOT_DIR, requiredFilePath);
159
-
160
- if (await fileExists(absoluteRequiredFilePath)) {
161
- pass(requiredFilePath);
162
- continue;
163
- }
164
-
165
- fail(`Missing required file: ${requiredFilePath}`);
166
- }
167
- }
168
-
169
- async function validateMarkdownFiles() {
170
- console.log('\nChecking markdown content...');
171
-
172
- const markdownFilePaths = await collectFiles(ROOT_DIR, (fileName) => fileName.endsWith('.md'));
173
-
174
- for (const markdownFilePath of markdownFilePaths) {
175
- const markdownContent = await readTextFile(markdownFilePath);
176
- const relativeMarkdownPath = relative(ROOT_DIR, markdownFilePath);
177
-
178
- if (markdownContent.trim().length === 0) {
179
- fail(`Empty markdown file: ${relativeMarkdownPath}`);
180
- continue;
181
- }
182
-
183
- pass(`${relativeMarkdownPath} (${markdownContent.length} chars)`);
184
- }
185
- }
186
-
187
- async function validateRuleFiles() {
188
- console.log('\nChecking rule, stack, blueprint, checklist, and state files...');
189
-
190
- const expectedPaths = [
191
- 'rules/naming-conv.md',
192
- 'rules/architecture.md',
193
- 'rules/security.md',
194
- 'rules/performance.md',
195
- 'rules/error-handling.md',
196
- 'rules/testing.md',
197
- 'rules/git-workflow.md',
198
- 'rules/efficiency-vs-hype.md',
199
- 'rules/api-docs.md',
200
- 'rules/microservices.md',
201
- 'rules/event-driven.md',
202
- 'rules/database-design.md',
203
- 'rules/realtime.md',
204
- 'rules/frontend-architecture.md',
205
- 'stacks/typescript.md',
206
- 'stacks/python.md',
207
- 'stacks/java.md',
208
- 'stacks/php.md',
209
- 'stacks/go.md',
210
- 'stacks/csharp.md',
211
- 'stacks/rust.md',
212
- 'stacks/ruby.md',
213
- 'blueprints/api-nextjs.md',
214
- 'blueprints/nestjs-logic.md',
215
- 'blueprints/fastapi-service.md',
216
- 'blueprints/laravel-api.md',
217
- 'blueprints/spring-boot-api.md',
218
- 'blueprints/go-service.md',
219
- 'blueprints/aspnet-api.md',
220
- 'blueprints/ci-github-actions.md',
221
- 'blueprints/ci-gitlab.md',
222
- 'blueprints/observability.md',
223
- 'blueprints/graphql-grpc-api.md',
224
- 'blueprints/infrastructure-as-code.md',
225
- 'blueprints/kubernetes-manifests.md',
226
- 'profiles/startup.md',
227
- 'profiles/regulated.md',
228
- 'profiles/platform.md',
229
- 'review-checklists/pr-checklist.md',
230
- 'review-checklists/frontend-usability.md',
231
- 'review-checklists/frontend-skill-parity.md',
232
- 'review-checklists/release-operations.md',
233
- 'review-checklists/security-audit.md',
234
- 'review-checklists/performance-audit.md',
235
- 'review-checklists/architecture-review.md',
236
- 'review-checklists/marketplace-acceptance.md',
237
- 'skills/README.md',
238
- 'skills/frontend/README.md',
239
- 'skills/backend/README.md',
240
- 'skills/fullstack/README.md',
241
- 'skills/cli/README.md',
242
- 'skills/distribution/README.md',
243
- 'skills/review-quality/README.md',
244
- 'skills/frontend.md',
245
- 'skills/backend.md',
246
- 'skills/fullstack.md',
247
- 'skills/cli.md',
248
- 'skills/distribution.md',
249
- 'skills/review-quality.md',
250
- 'state/architecture-map.md',
251
- 'state/dependency-map.md',
252
- ];
253
-
254
- for (const expectedPath of expectedPaths) {
255
- const absoluteExpectedPath = join(AGENT_CONTEXT_DIR, expectedPath);
256
-
257
- if (!(await fileExists(absoluteExpectedPath))) {
258
- fail(`Missing agent context file: .agent-context/${expectedPath}`);
259
- continue;
260
- }
261
-
262
- const fileContent = await readTextFile(absoluteExpectedPath);
263
- if (fileContent.trim().length < 100) {
264
- fail(`Agent context file is suspiciously short: .agent-context/${expectedPath}`);
265
- continue;
266
- }
267
-
268
- pass(`.agent-context/${expectedPath}`);
269
- }
270
- }
271
-
272
- async function validateSkillTierQuality() {
273
- console.log('\nChecking skill tier quality...');
274
-
275
- const skillMarkdownFiles = await collectFiles(SKILLS_DIR, (fileName) => fileName.endsWith('.md'));
276
- const scopedSkillTopicFiles = skillMarkdownFiles.filter((skillFilePath) => {
277
- if (skillFilePath.endsWith('README.md') || skillFilePath.endsWith('CHANGELOG.md')) {
278
- return false;
279
- }
280
-
281
- const relativeSkillPath = relative(SKILLS_DIR, skillFilePath);
282
- return /[\\/]/.test(relativeSkillPath);
283
- });
284
-
285
- for (const skillTopicPath of scopedSkillTopicFiles) {
286
- const skillTopicContent = await readTextFile(skillTopicPath);
287
- const relativeSkillTopicPath = relative(ROOT_DIR, skillTopicPath);
288
- const validationResult = validateSkillTopicContent(skillTopicContent);
289
-
290
- if (!validationResult.isValid) {
291
- if (validationResult.reason === 'missing-tier') {
292
- fail(`${relativeSkillTopicPath} is missing explicit Tier metadata`);
293
- continue;
294
- }
295
-
296
- if (validationResult.reason === 'unsupported-tier') {
297
- fail(`${relativeSkillTopicPath} has unsupported tier: ${validationResult.detectedTier}`);
298
- continue;
299
- }
300
-
301
- if (validationResult.reason === 'word-count') {
302
- fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minWords} words (found ${validationResult.wordCount})`);
303
- continue;
304
- }
305
-
306
- if (validationResult.reason === 'heading-count') {
307
- fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minHeadings} section headings (found ${validationResult.headingCount})`);
308
- continue;
309
- }
310
-
311
- if (validationResult.reason === 'checklist-count') {
312
- fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minChecklistItems} checklist item(s) (found ${validationResult.checklistCount})`);
313
- continue;
314
- }
315
-
316
- if (validationResult.reason === 'code-block-count') {
317
- fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minCodeBlocks} code block(s) (found ${validationResult.codeBlockCount})`);
318
- continue;
319
- }
320
-
321
- fail(`${relativeSkillTopicPath} failed tier validation`);
322
- continue;
323
- }
324
-
325
- pass(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} quality gate passed`);
326
- }
327
- }
328
-
329
- async function validateSkillCompatibilityManifests() {
330
- console.log('\nChecking skill compatibility manifests...');
331
-
332
- const skillDomainEntries = await readdir(SKILLS_DIR, { withFileTypes: true });
333
- const skillDomainDirectoryNames = skillDomainEntries
334
- .filter((entry) => entry.isDirectory())
335
- .map((entry) => entry.name)
336
- .sort((leftName, rightName) => leftName.localeCompare(rightName));
337
-
338
- let validManifestCount = 0;
339
-
340
- for (const skillDomainDirectoryName of skillDomainDirectoryNames) {
341
- const compatibilityManifestPath = join(
342
- SKILLS_DIR,
343
- skillDomainDirectoryName,
344
- 'compatibility-manifest.json'
345
- );
346
-
347
- if (!(await fileExists(compatibilityManifestPath))) {
348
- fail(`Missing compatibility manifest: .agent-context/skills/${skillDomainDirectoryName}/compatibility-manifest.json`);
349
- continue;
350
- }
351
-
352
- let parsedCompatibilityManifest;
353
- try {
354
- parsedCompatibilityManifest = JSON.parse(await readTextFile(compatibilityManifestPath));
355
- } catch (error) {
356
- fail(`Invalid JSON compatibility manifest for ${skillDomainDirectoryName}: ${error.message}`);
357
- continue;
358
- }
359
-
360
- if (!Array.isArray(parsedCompatibilityManifest.ides) || parsedCompatibilityManifest.ides.length === 0) {
361
- fail(`Compatibility manifest for ${skillDomainDirectoryName} must include non-empty "ides" array`);
362
- continue;
363
- }
364
-
365
- if (!Array.isArray(parsedCompatibilityManifest.platforms) || parsedCompatibilityManifest.platforms.length === 0) {
366
- fail(`Compatibility manifest for ${skillDomainDirectoryName} must include non-empty "platforms" array`);
367
- continue;
368
- }
369
-
370
- const unsupportedPlatform = parsedCompatibilityManifest.platforms.find(
371
- (platformName) => !SUPPORTED_COMPATIBILITY_PLATFORMS.has(platformName)
372
- );
373
-
374
- if (unsupportedPlatform) {
375
- fail(`Compatibility manifest for ${skillDomainDirectoryName} has unsupported platform: ${unsupportedPlatform}`);
376
- continue;
377
- }
378
-
379
- if (
380
- typeof parsedCompatibilityManifest.nodeMin !== 'string'
381
- || !/^\d+(\.\d+)?$/.test(parsedCompatibilityManifest.nodeMin)
382
- ) {
383
- fail(`Compatibility manifest for ${skillDomainDirectoryName} must include string nodeMin (for example "18" or "18.0")`);
384
- continue;
385
- }
386
-
387
- validManifestCount += 1;
388
- pass(`Compatibility manifest validated: .agent-context/skills/${skillDomainDirectoryName}/compatibility-manifest.json`);
389
- }
390
-
391
- if (validManifestCount >= 6) {
392
- pass(`Compatibility manifest coverage is valid (${validManifestCount} skill domains)`);
393
- } else {
394
- fail(`Compatibility manifest coverage is insufficient (${validManifestCount}/6 skill domains)`);
395
- }
396
- }
397
-
398
- function stripMarkdownCodeBlocks(markdownText) {
399
- return markdownText.replace(/```[\s\S]*?```/g, '');
400
- }
401
-
402
- function parseOverrideExpiryDate(rawExpiryValue) {
403
- if (!/^\d{4}-\d{2}-\d{2}$/.test(rawExpiryValue)) {
404
- return null;
405
- }
406
-
407
- const parsedDate = new Date(`${rawExpiryValue}T00:00:00.000Z`);
408
- return Number.isNaN(parsedDate.getTime()) ? null : parsedDate;
409
- }
410
-
411
- async function validateOverrideGovernance() {
412
- console.log('\nChecking override governance...');
413
-
414
- const overrideContent = await readTextFile(OVERRIDE_FILE_PATH);
415
- const overrideContentWithoutCodeBlocks = stripMarkdownCodeBlocks(overrideContent);
416
- const overrideEntryPattern = /\[Rule:\s*([^\]]+)\]([\s\S]*?)(?=\n\[Rule:|$)/g;
417
- const overrideEntries = [];
418
- let overrideEntryMatch = overrideEntryPattern.exec(overrideContentWithoutCodeBlocks);
419
-
420
- while (overrideEntryMatch) {
421
- const ruleName = overrideEntryMatch[1].trim();
422
- const entryBody = overrideEntryMatch[2];
423
- const ownerMatch = entryBody.match(/(?:^|\n)Owner:\s*(.+)/);
424
- const expiryMatch = entryBody.match(/(?:^|\n)Expiry:\s*(.+)/);
425
-
426
- overrideEntries.push({
427
- ruleName,
428
- owner: ownerMatch ? ownerMatch[1].trim() : '',
429
- expiry: expiryMatch ? expiryMatch[1].trim() : '',
430
- });
431
-
432
- overrideEntryMatch = overrideEntryPattern.exec(overrideContentWithoutCodeBlocks);
433
- }
434
-
435
- if (overrideEntries.length === 0) {
436
- pass('No active override entries found; governance baseline remains strict');
437
- return;
438
- }
439
-
440
- const currentDate = new Date();
441
-
442
- for (const overrideEntry of overrideEntries) {
443
- const overrideContextLabel = `[Rule: ${overrideEntry.ruleName}]`;
444
-
445
- if (!overrideEntry.owner) {
446
- fail(`${overrideContextLabel} is missing Owner metadata`);
447
- continue;
448
- }
449
-
450
- pass(`${overrideContextLabel} owner is defined`);
451
-
452
- if (!overrideEntry.expiry) {
453
- fail(`${overrideContextLabel} is missing Expiry metadata`);
454
- continue;
455
- }
456
-
457
- const expiryDate = parseOverrideExpiryDate(overrideEntry.expiry);
458
- if (!expiryDate) {
459
- fail(`${overrideContextLabel} has invalid Expiry format (expected YYYY-MM-DD)`);
460
- continue;
461
- }
462
-
463
- const remainingMilliseconds = expiryDate.getTime() - currentDate.getTime();
464
- const remainingDays = Math.floor(remainingMilliseconds / (1000 * 60 * 60 * 24));
465
-
466
- if (remainingMilliseconds < 0) {
467
- fail(`${overrideContextLabel} is expired (${overrideEntry.expiry})`);
468
- continue;
469
- }
470
-
471
- pass(`${overrideContextLabel} expiry is valid (${overrideEntry.expiry})`);
472
-
473
- if (remainingDays <= OVERRIDE_WARNING_WINDOW_DAYS) {
474
- warn(`${overrideContextLabel} expires in ${remainingDays} day(s); renew or remove soon`);
475
- }
476
- }
477
- }
478
-
479
- async function validateCrossReferences() {
480
- console.log('\nChecking internal links...');
481
-
482
- const markdownFilePaths = await collectFiles(ROOT_DIR, (fileName) => fileName.endsWith('.md'));
483
- const linkPattern = /\[([^\]]*)\]\((?!https?:\/\/|#)([^)]+)\)/g;
484
- let checkedLinkCount = 0;
485
-
486
- for (const markdownFilePath of markdownFilePaths) {
487
- const markdownContent = await readTextFile(markdownFilePath);
488
- const currentFileDirectory = dirname(markdownFilePath);
489
- const relativeMarkdownPath = relative(ROOT_DIR, markdownFilePath);
490
- let linkMatch = linkPattern.exec(markdownContent);
491
-
492
- while (linkMatch) {
493
- const rawLinkTarget = linkMatch[2].split('#')[0];
494
- if (rawLinkTarget) {
495
- checkedLinkCount += 1;
496
- const resolvedLinkPath = resolve(currentFileDirectory, rawLinkTarget);
497
-
498
- if (await fileExists(resolvedLinkPath)) {
499
- pass(`${relativeMarkdownPath} ${linkMatch[2]}`);
500
- } else {
501
- fail(`Broken link in ${relativeMarkdownPath}: ${linkMatch[2]}`);
502
- }
503
- }
504
-
505
- linkMatch = linkPattern.exec(markdownContent);
506
- }
507
- }
508
-
509
- if (checkedLinkCount === 0) {
510
- warn('No internal links were found in markdown files');
511
- }
512
- }
513
-
514
- async function validateAgentsManifest() {
515
- console.log('\nChecking AGENTS.md manifest links...');
516
-
517
- const agentsContent = await readTextFile(join(ROOT_DIR, 'AGENTS.md'));
518
- const fileReferencePattern = /\[`?([^`\]]+)`?\]\(([^)]+)\)/g;
519
- let manifestLinkCount = 0;
520
- let fileReferenceMatch = fileReferencePattern.exec(agentsContent);
521
-
522
- while (fileReferenceMatch) {
523
- const manifestLinkTarget = fileReferenceMatch[2];
524
-
525
- if (!manifestLinkTarget.startsWith('http')) {
526
- manifestLinkCount += 1;
527
- const resolvedManifestLinkPath = resolve(ROOT_DIR, manifestLinkTarget);
528
-
529
- if (await fileExists(resolvedManifestLinkPath)) {
530
- pass(`AGENTS.md → ${manifestLinkTarget}`);
531
- } else {
532
- fail(`AGENTS.md references missing file: ${manifestLinkTarget}`);
533
- }
534
- }
535
-
536
- fileReferenceMatch = fileReferencePattern.exec(agentsContent);
537
- }
538
-
539
- if (manifestLinkCount === 0) {
540
- warn('AGENTS.md does not contain any local manifest links');
541
- }
542
- }
543
-
544
- async function validatePackageMetadata() {
545
- console.log('\nChecking package metadata...');
546
-
547
- const packageJson = JSON.parse(await readTextFile(PACKAGE_JSON_PATH));
548
- const versionPattern = /^\d+\.\d+\.\d+$/;
549
-
550
- if (typeof packageJson.version !== 'string' || !versionPattern.test(packageJson.version)) {
551
- fail('package.json version must be a semantic version string');
552
- } else {
553
- pass(`package.json version ${packageJson.version}`);
554
- }
555
-
556
- if (packageJson.scripts?.validate === 'node ./scripts/validate.mjs') {
557
- pass('package.json validate script is Node-first');
558
- } else {
559
- fail('package.json validate script must use node ./scripts/validate.mjs');
560
- }
561
-
562
- if (packageJson.scripts?.test) {
563
- pass('package.json test script exists');
564
- } else {
565
- fail('package.json test script is missing');
566
- }
567
-
568
- if (packageJson.devDependencies && Object.keys(packageJson.devDependencies).length > 0) {
569
- warn('package.json still has devDependencies; review whether they are necessary');
570
- } else {
571
- pass('package.json has no unnecessary devDependencies');
572
- }
573
- }
574
-
575
- async function validatePolicyFile() {
576
- console.log('\nChecking LLM Judge policy...');
577
-
578
- const policyContent = await readTextFile(POLICY_FILE_PATH);
579
- const parsedPolicy = JSON.parse(policyContent);
580
- const selectedProfileName = parsedPolicy.selectedProfile;
581
- const profileThresholds = parsedPolicy.profileThresholds;
582
-
583
- if (typeof selectedProfileName !== 'string') {
584
- fail('Policy file must define selectedProfile as a string');
585
- } else {
586
- pass(`LLM Judge selected profile: ${selectedProfileName}`);
587
- }
588
-
589
- if (!profileThresholds || typeof profileThresholds !== 'object') {
590
- fail('Policy file must define profileThresholds');
591
- return;
592
- }
593
-
594
- for (const [profileName, profileSettings] of Object.entries(profileThresholds)) {
595
- if (!Array.isArray(profileSettings.blockingSeverities)) {
596
- fail(`Policy profile ${profileName} must define blockingSeverities`);
597
- continue;
598
- }
599
-
600
- const invalidSeverity = profileSettings.blockingSeverities.find((severity) => !ALLOWED_SEVERITIES.has(severity));
601
- if (invalidSeverity) {
602
- fail(`Policy profile ${profileName} uses unsupported severity: ${invalidSeverity}`);
603
- continue;
604
- }
605
-
606
- pass(`Policy profile ${profileName} blocking severities are valid`);
607
- }
608
-
609
- if (typeof profileThresholds[selectedProfileName] === 'object') {
610
- pass('Policy selectedProfile points to a valid profile');
611
- } else {
612
- fail('Policy selectedProfile must match one of the configured profileThresholds');
613
- }
614
- }
615
-
616
- async function validateVersionConsistency() {
617
- console.log('\nChecking release version consistency...');
618
-
619
- const packageJson = JSON.parse(await readTextFile(PACKAGE_JSON_PATH));
620
- const packageVersion = packageJson.version;
621
- const changelogContent = await readTextFile(CHANGELOG_PATH);
622
-
623
- if (changelogContent.includes(`## ${packageVersion}`)) {
624
- pass(`CHANGELOG.md contains release entry for ${packageVersion}`);
625
- } else {
626
- fail(`CHANGELOG.md is missing a ## ${packageVersion} heading`);
627
- }
628
-
629
- for (const generatedRuleFileName of GENERATED_RULE_FILES) {
630
- const generatedRuleContent = await readTextFile(join(ROOT_DIR, generatedRuleFileName));
631
-
632
- if (generatedRuleContent.includes(`Generated by Agentic-Senior-Core CLI v${packageVersion}`)) {
633
- pass(`${generatedRuleFileName} matches package version ${packageVersion}`);
634
- } else {
635
- fail(`${generatedRuleFileName} does not match package version ${packageVersion}`);
636
- }
637
- }
638
- }
639
-
640
- async function validateDocumentationFlow() {
641
- console.log('\nChecking documentation flow...');
642
-
643
- const readmeContent = await readTextFile(README_PATH);
644
- const requiredReadmeSnippets = [
645
- 'GitHub Template',
646
- 'scripts/init-project.ps1',
647
- 'scripts/init-project.sh',
648
- 'npx @ryuenn3123/agentic-senior-core init',
649
- 'npm run validate',
650
- 'docs/faq.md',
651
- 'docs/deep-dive.md',
652
- 'docs/v2-upgrade-playbook.md',
653
- ];
654
-
655
- for (const requiredReadmeSnippet of requiredReadmeSnippets) {
656
- if (readmeContent.includes(requiredReadmeSnippet)) {
657
- pass(`README.md mentions ${requiredReadmeSnippet}`);
658
- } else {
659
- fail(`README.md must mention ${requiredReadmeSnippet}`);
660
- }
661
- }
662
- }
663
-
664
- async function validateMcpConfiguration() {
665
- console.log('\nChecking MCP configuration...');
666
-
667
- const mcpConfiguration = JSON.parse(await readTextFile(join(ROOT_DIR, 'mcp.json')));
668
- const lintServerCommand = mcpConfiguration.servers?.lint?.command;
669
- const testServerCommand = mcpConfiguration.servers?.test?.command;
670
-
671
- if (lintServerCommand === 'node') {
672
- pass('MCP lint server uses Node');
673
- } else {
674
- fail('MCP lint server must use Node');
675
- }
676
-
677
- if (testServerCommand === 'node') {
678
- pass('MCP test server uses Node');
679
- } else {
680
- fail('MCP test server must use Node');
681
- }
682
- }
683
-
684
- async function validateInstructionAdapters() {
685
- console.log('\nChecking instruction adapter consolidation...');
686
-
687
- const canonicalInstructionContent = await readTextFile(CANONICAL_INSTRUCTION_PATH);
688
- const canonicalSnapshotHash = createHash('sha256').update(canonicalInstructionContent).digest('hex');
689
-
690
- for (const thinAdapterPath of THIN_ADAPTER_PATHS) {
691
- const absoluteAdapterPath = join(ROOT_DIR, thinAdapterPath);
692
-
693
- if (!(await fileExists(absoluteAdapterPath))) {
694
- fail(`Missing thin adapter file: ${thinAdapterPath}`);
695
- continue;
696
- }
697
-
698
- const thinAdapterContent = await readTextFile(absoluteAdapterPath);
699
-
700
- if (
701
- thinAdapterContent.includes('Adapter Mode: thin')
702
- && thinAdapterContent.includes('Adapter Source: .instructions.md')
703
- ) {
704
- pass(`${thinAdapterPath} declares thin adapter metadata`);
705
- } else {
706
- fail(`${thinAdapterPath} must declare Adapter Mode: thin and Adapter Source: .instructions.md`);
707
- }
708
-
709
- const hashMatch = thinAdapterContent.match(/Canonical Snapshot SHA256:\s*([a-f0-9]{64})/);
710
- if (!hashMatch) {
711
- fail(`${thinAdapterPath} must declare Canonical Snapshot SHA256`);
712
- continue;
713
- }
714
-
715
- if (hashMatch[1] === canonicalSnapshotHash) {
716
- pass(`${thinAdapterPath} canonical hash matches .instructions.md`);
717
- } else {
718
- fail(`${thinAdapterPath} canonical hash drift detected (expected ${canonicalSnapshotHash})`);
719
- }
720
-
721
- const thinAdapterLineCount = thinAdapterContent.split(/\r?\n/u).length;
722
- if (thinAdapterLineCount <= 80) {
723
- pass(`${thinAdapterPath} remains thin (${thinAdapterLineCount} lines)`);
724
- } else {
725
- fail(`${thinAdapterPath} is too large for thin-adapter mode (${thinAdapterLineCount} lines)`);
726
- }
727
- }
728
- }
729
-
730
- async function validateTrustTierSchema() {
731
- console.log('\nChecking marketplace trust tier schema...');
732
-
733
- const trustTierPath = join(AGENT_CONTEXT_DIR, 'marketplace', 'trust-tiers.json');
734
- const trustTierContent = await readTextFile(trustTierPath);
735
- const trustTierSchema = JSON.parse(trustTierContent);
736
-
737
- const expectedTierNames = ['verified', 'community', 'experimental'];
738
- for (const expectedTierName of expectedTierNames) {
739
- if (trustTierSchema.tiers?.[expectedTierName]) {
740
- pass(`Trust tier "${expectedTierName}" is defined`);
741
- } else {
742
- fail(`Trust tier "${expectedTierName}" is missing from trust-tiers.json`);
743
- }
744
- }
745
-
746
- const scorecardDimensions = trustTierSchema.scorecard?.dimensions;
747
- if (!scorecardDimensions || typeof scorecardDimensions !== 'object') {
748
- fail('Trust tier scorecard must define dimensions');
749
- return;
750
- }
751
-
752
- const dimensionNames = Object.keys(scorecardDimensions);
753
- let totalWeight = 0;
754
-
755
- for (const dimensionName of dimensionNames) {
756
- const dimensionWeight = scorecardDimensions[dimensionName].weight;
757
- if (typeof dimensionWeight !== 'number' || dimensionWeight <= 0) {
758
- fail(`Scorecard dimension "${dimensionName}" must have a positive weight`);
759
- continue;
760
- }
761
- totalWeight += dimensionWeight;
762
- pass(`Scorecard dimension "${dimensionName}" weight: ${dimensionWeight}`);
763
- }
764
-
765
- if (totalWeight === 100) {
766
- pass(`Scorecard weights sum to 100`);
767
- } else {
768
- fail(`Scorecard weights must sum to 100 (got ${totalWeight})`);
769
- }
770
-
771
- for (const dimensionName of dimensionNames) {
772
- const gates = scorecardDimensions[dimensionName].gates;
773
- if (!Array.isArray(gates) || gates.length === 0) {
774
- fail(`Scorecard dimension "${dimensionName}" must define at least one gate`);
775
- continue;
776
- }
777
- pass(`Scorecard dimension "${dimensionName}" has ${gates.length} gates`);
778
- }
779
-
780
- for (const [tierName, tierDefinition] of Object.entries(trustTierSchema.tiers)) {
781
- if (typeof tierDefinition.minimumScore !== 'number') {
782
- fail(`Tier "${tierName}" must define a numeric minimumScore`);
783
- continue;
784
- }
785
- pass(`Tier "${tierName}" minimumScore: ${tierDefinition.minimumScore}`);
786
- }
787
- }
788
-
789
- async function validateEvidenceBundles() {
790
- console.log('\nChecking skill evidence bundles and trust scores...');
791
-
792
- const skillsDir = join(AGENT_CONTEXT_DIR, 'skills');
793
- const skillDirs = (await readdir(skillsDir, { withFileTypes: true }))
794
- .filter(dirent => dirent.isDirectory())
795
- .map(dirent => dirent.name);
796
-
797
- // We only DEMAND evidence from official skills if they want to be considered "Verified".
798
- // Let's at least enforce they don't throw errors when scored.
799
- // And specifically, 'cli' has a mocked evidence bundle, so it should score Verified.
800
- for (const skillName of skillDirs) {
801
- if (skillName === 'cli') {
802
- try {
803
- const result = await calculateTrustScore(join(skillsDir, skillName));
804
- if (result.tier === 'verified') {
805
- pass(`Skill "${skillName}" achieved Verified trust tier (Score: ${result.score})`);
806
- } else {
807
- fail(`Skill "${skillName}" failed to reach Verified tier. Got ${result.tier} (Score: ${result.score})`);
808
- console.log(result.dimensions);
809
- }
810
- } catch (err) {
811
- fail(`Skill "${skillName}" scorer crashed: ${err.message}`);
812
- }
813
- } else {
814
- try {
815
- const result = await calculateTrustScore(join(skillsDir, skillName));
816
- pass(`Skill "${skillName}" parses successfully as ${result.tier} tier`);
817
- } catch (err) {
818
- fail(`Skill "${skillName}" scorer crashed: ${err.message}`);
819
- }
820
- }
821
- }
822
- }
823
-
824
- async function main() {
825
- console.log('===============================================');
826
- console.log(' Agentic-Senior-Core Repository Validator');
827
- console.log('===============================================');
828
-
829
- await validateRequiredFiles();
830
- await validateMarkdownFiles();
831
- await validateRuleFiles();
832
- await validateSkillTierQuality();
833
- await validateSkillCompatibilityManifests();
834
- await validateOverrideGovernance();
835
- await validateAgentsManifest();
836
- await validateCrossReferences();
837
- await validatePackageMetadata();
838
- await validatePolicyFile();
839
- await validateVersionConsistency();
840
- await validateDocumentationFlow();
841
- await validateMcpConfiguration();
842
- await validateInstructionAdapters();
843
- await validateTrustTierSchema();
844
- await validateEvidenceBundles();
845
-
846
- console.log('\n===============================================');
847
- console.log(' RESULTS');
848
- console.log('===============================================');
849
- console.log(` Passed: ${validationResult.passed}`);
850
- console.log(` Failed: ${validationResult.failed}`);
851
- console.log(` Warnings: ${validationResult.warnings.length}`);
852
- console.log('===============================================');
853
-
854
- if (validationResult.failed > 0) {
855
- console.log('\nVALIDATION FAILED\n');
856
- process.exit(1);
857
- }
858
-
859
- console.log('\nALL CHECKS PASSED\n');
860
- }
861
-
862
- main().catch((error) => {
863
- console.error('Validator crashed:', error);
864
- process.exit(1);
865
- });
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * validate.mjs — Repository Integrity Validator
5
+ *
6
+ * Validates the Agentic-Senior-Core repository:
7
+ * - Required files exist
8
+ * - Markdown and JSON documents are readable
9
+ * - Cross-references resolve from the correct source directory
10
+ * - Version references stay consistent for release builds
11
+ * - LLM Judge policy configuration is valid
12
+ *
13
+ * Usage: node scripts/validate.mjs
14
+ */
15
+
16
+ import { readdir, readFile, stat } from 'node:fs/promises';
17
+ import { dirname, join, relative, resolve } from 'node:path';
18
+ import { fileURLToPath } from 'node:url';
19
+ import { createHash } from 'node:crypto';
20
+ import { validateSkillTopicContent } from './skill-tier-policy.mjs';
21
+ import { calculateTrustScore } from './trust-scorer.mjs';
22
+
23
+ const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
24
+ const ROOT_DIR = resolve(dirname(SCRIPT_FILE_PATH), '..');
25
+ const AGENT_CONTEXT_DIR = join(ROOT_DIR, '.agent-context');
26
+ const CANONICAL_INSTRUCTION_PATH = join(ROOT_DIR, '.instructions.md');
27
+ const PACKAGE_JSON_PATH = join(ROOT_DIR, 'package.json');
28
+ const CHANGELOG_PATH = join(ROOT_DIR, 'CHANGELOG.md');
29
+ const README_PATH = join(ROOT_DIR, 'README.md');
30
+ const POLICY_FILE_PATH = join(ROOT_DIR, '.agent-context', 'policies', 'llm-judge-threshold.json');
31
+ const OVERRIDE_FILE_PATH = join(ROOT_DIR, '.agent-override.md');
32
+ const SKILLS_DIR = join(AGENT_CONTEXT_DIR, 'skills');
33
+ const GENERATED_RULE_FILES = ['.cursorrules', '.windsurfrules'];
34
+ const ALLOWED_SEVERITIES = new Set(['critical', 'high', 'medium', 'low']);
35
+ const OVERRIDE_WARNING_WINDOW_DAYS = 30;
36
+ const SUPPORTED_COMPATIBILITY_PLATFORMS = new Set(['windows', 'linux', 'macos']);
37
+ const THIN_ADAPTER_PATHS = [
38
+ 'AGENTS.md',
39
+ '.github/copilot-instructions.md',
40
+ '.gemini/instructions.md',
41
+ ];
42
+
43
+ const validationResult = {
44
+ passed: 0,
45
+ failed: 0,
46
+ errors: [],
47
+ warnings: [],
48
+ };
49
+
50
+ async function fileExists(filePath) {
51
+ try {
52
+ await stat(filePath);
53
+ return true;
54
+ } catch {
55
+ return false;
56
+ }
57
+ }
58
+
59
+ async function readTextFile(filePath) {
60
+ return readFile(filePath, 'utf8');
61
+ }
62
+
63
+ async function collectFiles(directoryPath, fileExtensionMatcher) {
64
+ const matchingFilePaths = [];
65
+
66
+ async function walk(currentDirectoryPath) {
67
+ const directoryEntries = await readdir(currentDirectoryPath, { withFileTypes: true });
68
+
69
+ for (const directoryEntry of directoryEntries) {
70
+ if (
71
+ directoryEntry.name === '.git'
72
+ || directoryEntry.name === 'node_modules'
73
+ || directoryEntry.name === '.agentic-backup'
74
+ || directoryEntry.name === '.benchmarks'
75
+ ) {
76
+ continue;
77
+ }
78
+
79
+ const entryPath = join(currentDirectoryPath, directoryEntry.name);
80
+
81
+ if (directoryEntry.isDirectory()) {
82
+ await walk(entryPath);
83
+ continue;
84
+ }
85
+
86
+ if (fileExtensionMatcher(directoryEntry.name)) {
87
+ matchingFilePaths.push(entryPath);
88
+ }
89
+ }
90
+ }
91
+
92
+ await walk(directoryPath);
93
+ return matchingFilePaths;
94
+ }
95
+
96
+ function pass(message) {
97
+ validationResult.passed += 1;
98
+ console.log(` PASS ${message}`);
99
+ }
100
+
101
+ function fail(message) {
102
+ validationResult.failed += 1;
103
+ validationResult.errors.push(message);
104
+ console.log(` FAIL ${message}`);
105
+ }
106
+
107
+ function warn(message) {
108
+ validationResult.warnings.push(message);
109
+ console.log(` WARN ${message}`);
110
+ }
111
+
112
+ function normalizeLineEndings(content) {
113
+ return content.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
114
+ }
115
+
116
+ async function validateRequiredFiles() {
117
+ console.log('\nChecking required files...');
118
+
119
+ const requiredFiles = [
120
+ 'bin/agentic-senior-core.js',
121
+ 'scripts/validate.mjs',
122
+ 'scripts/llm-judge.mjs',
123
+ 'scripts/detection-benchmark.mjs',
124
+ 'scripts/benchmark-gate.mjs',
125
+ 'scripts/benchmark-intelligence.mjs',
126
+ 'scripts/governance-weekly-report.mjs',
127
+ 'scripts/frontend-usability-audit.mjs',
128
+ 'scripts/release-gate.mjs',
129
+ 'scripts/generate-sbom.mjs',
130
+ 'scripts/init-project.sh',
131
+ 'scripts/init-project.ps1',
132
+ '.cursorrules',
133
+ '.windsurfrules',
134
+ '.agent-override.md',
135
+ '.agent-context/policies/llm-judge-threshold.json',
136
+ 'mcp.json',
137
+ 'AGENTS.md',
138
+ '.github/copilot-instructions.md',
139
+ '.gemini/instructions.md',
140
+ 'README.md',
141
+ 'CHANGELOG.md',
142
+ 'docs/faq.md',
143
+ 'docs/deep-dive.md',
144
+ 'docs/v1.7-execution-playbook.md',
145
+ 'docs/v1.7-issue-breakdown.md',
146
+ 'docs/v1.8-operations-playbook.md',
147
+ 'docs/v2-upgrade-playbook.md',
148
+ '.agent-context/state/benchmark-watchlist.json',
149
+ '.agent-context/state/skill-platform.json',
150
+ '.agent-context/skills/index.json',
151
+ '.github/workflows/release-gate.yml',
152
+ '.github/workflows/sbom-compliance.yml',
153
+ '.github/workflows/benchmark-intelligence.yml',
154
+ '.github/workflows/governance-weekly-report.yml',
155
+ 'tests/cli-smoke.test.mjs',
156
+ 'tests/llm-judge.test.mjs',
157
+ 'tests/enterprise-ops.test.mjs',
158
+ 'LICENSE',
159
+ '.gitignore',
160
+ '.agent-context/marketplace/trust-tiers.json',
161
+ ];
162
+
163
+ for (const requiredFilePath of requiredFiles) {
164
+ const absoluteRequiredFilePath = join(ROOT_DIR, requiredFilePath);
165
+
166
+ if (await fileExists(absoluteRequiredFilePath)) {
167
+ pass(requiredFilePath);
168
+ continue;
169
+ }
170
+
171
+ fail(`Missing required file: ${requiredFilePath}`);
172
+ }
173
+ }
174
+
175
+ async function validateMarkdownFiles() {
176
+ console.log('\nChecking markdown content...');
177
+
178
+ const markdownFilePaths = await collectFiles(ROOT_DIR, (fileName) => fileName.endsWith('.md'));
179
+
180
+ for (const markdownFilePath of markdownFilePaths) {
181
+ const markdownContent = await readTextFile(markdownFilePath);
182
+ const relativeMarkdownPath = relative(ROOT_DIR, markdownFilePath);
183
+
184
+ if (markdownContent.trim().length === 0) {
185
+ fail(`Empty markdown file: ${relativeMarkdownPath}`);
186
+ continue;
187
+ }
188
+
189
+ pass(`${relativeMarkdownPath} (${markdownContent.length} chars)`);
190
+ }
191
+ }
192
+
193
+ async function validateRuleFiles() {
194
+ console.log('\nChecking rule, stack, blueprint, checklist, and state files...');
195
+
196
+ const expectedPaths = [
197
+ 'rules/naming-conv.md',
198
+ 'rules/architecture.md',
199
+ 'rules/security.md',
200
+ 'rules/performance.md',
201
+ 'rules/error-handling.md',
202
+ 'rules/testing.md',
203
+ 'rules/git-workflow.md',
204
+ 'rules/efficiency-vs-hype.md',
205
+ 'rules/api-docs.md',
206
+ 'rules/microservices.md',
207
+ 'rules/event-driven.md',
208
+ 'rules/database-design.md',
209
+ 'rules/realtime.md',
210
+ 'rules/frontend-architecture.md',
211
+ 'stacks/typescript.md',
212
+ 'stacks/python.md',
213
+ 'stacks/java.md',
214
+ 'stacks/php.md',
215
+ 'stacks/go.md',
216
+ 'stacks/csharp.md',
217
+ 'stacks/rust.md',
218
+ 'stacks/ruby.md',
219
+ 'blueprints/api-nextjs.md',
220
+ 'blueprints/nestjs-logic.md',
221
+ 'blueprints/fastapi-service.md',
222
+ 'blueprints/laravel-api.md',
223
+ 'blueprints/spring-boot-api.md',
224
+ 'blueprints/go-service.md',
225
+ 'blueprints/aspnet-api.md',
226
+ 'blueprints/ci-github-actions.md',
227
+ 'blueprints/ci-gitlab.md',
228
+ 'blueprints/observability.md',
229
+ 'blueprints/graphql-grpc-api.md',
230
+ 'blueprints/infrastructure-as-code.md',
231
+ 'blueprints/kubernetes-manifests.md',
232
+ 'profiles/startup.md',
233
+ 'profiles/regulated.md',
234
+ 'profiles/platform.md',
235
+ 'review-checklists/pr-checklist.md',
236
+ 'review-checklists/frontend-usability.md',
237
+ 'review-checklists/frontend-skill-parity.md',
238
+ 'review-checklists/release-operations.md',
239
+ 'review-checklists/security-audit.md',
240
+ 'review-checklists/performance-audit.md',
241
+ 'review-checklists/architecture-review.md',
242
+ 'review-checklists/marketplace-acceptance.md',
243
+ 'skills/README.md',
244
+ 'skills/frontend/README.md',
245
+ 'skills/backend/README.md',
246
+ 'skills/fullstack/README.md',
247
+ 'skills/cli/README.md',
248
+ 'skills/distribution/README.md',
249
+ 'skills/review-quality/README.md',
250
+ 'skills/frontend.md',
251
+ 'skills/backend.md',
252
+ 'skills/fullstack.md',
253
+ 'skills/cli.md',
254
+ 'skills/distribution.md',
255
+ 'skills/review-quality.md',
256
+ 'state/architecture-map.md',
257
+ 'state/dependency-map.md',
258
+ ];
259
+
260
+ for (const expectedPath of expectedPaths) {
261
+ const absoluteExpectedPath = join(AGENT_CONTEXT_DIR, expectedPath);
262
+
263
+ if (!(await fileExists(absoluteExpectedPath))) {
264
+ fail(`Missing agent context file: .agent-context/${expectedPath}`);
265
+ continue;
266
+ }
267
+
268
+ const fileContent = await readTextFile(absoluteExpectedPath);
269
+ if (fileContent.trim().length < 100) {
270
+ fail(`Agent context file is suspiciously short: .agent-context/${expectedPath}`);
271
+ continue;
272
+ }
273
+
274
+ pass(`.agent-context/${expectedPath}`);
275
+ }
276
+ }
277
+
278
+ async function validateSkillTierQuality() {
279
+ console.log('\nChecking skill tier quality...');
280
+
281
+ const skillMarkdownFiles = await collectFiles(SKILLS_DIR, (fileName) => fileName.endsWith('.md'));
282
+ const scopedSkillTopicFiles = skillMarkdownFiles.filter((skillFilePath) => {
283
+ if (skillFilePath.endsWith('README.md') || skillFilePath.endsWith('CHANGELOG.md')) {
284
+ return false;
285
+ }
286
+
287
+ const relativeSkillPath = relative(SKILLS_DIR, skillFilePath);
288
+ return /[\\/]/.test(relativeSkillPath);
289
+ });
290
+
291
+ for (const skillTopicPath of scopedSkillTopicFiles) {
292
+ const skillTopicContent = await readTextFile(skillTopicPath);
293
+ const relativeSkillTopicPath = relative(ROOT_DIR, skillTopicPath);
294
+ const validationResult = validateSkillTopicContent(skillTopicContent);
295
+
296
+ if (!validationResult.isValid) {
297
+ if (validationResult.reason === 'missing-tier') {
298
+ fail(`${relativeSkillTopicPath} is missing explicit Tier metadata`);
299
+ continue;
300
+ }
301
+
302
+ if (validationResult.reason === 'unsupported-tier') {
303
+ fail(`${relativeSkillTopicPath} has unsupported tier: ${validationResult.detectedTier}`);
304
+ continue;
305
+ }
306
+
307
+ if (validationResult.reason === 'word-count') {
308
+ fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minWords} words (found ${validationResult.wordCount})`);
309
+ continue;
310
+ }
311
+
312
+ if (validationResult.reason === 'heading-count') {
313
+ fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minHeadings} section headings (found ${validationResult.headingCount})`);
314
+ continue;
315
+ }
316
+
317
+ if (validationResult.reason === 'checklist-count') {
318
+ fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minChecklistItems} checklist item(s) (found ${validationResult.checklistCount})`);
319
+ continue;
320
+ }
321
+
322
+ if (validationResult.reason === 'code-block-count') {
323
+ fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minCodeBlocks} code block(s) (found ${validationResult.codeBlockCount})`);
324
+ continue;
325
+ }
326
+
327
+ fail(`${relativeSkillTopicPath} failed tier validation`);
328
+ continue;
329
+ }
330
+
331
+ pass(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} quality gate passed`);
332
+ }
333
+ }
334
+
335
+ async function validateSkillCompatibilityManifests() {
336
+ console.log('\nChecking skill compatibility manifests...');
337
+
338
+ const skillDomainEntries = await readdir(SKILLS_DIR, { withFileTypes: true });
339
+ const skillDomainDirectoryNames = skillDomainEntries
340
+ .filter((entry) => entry.isDirectory())
341
+ .map((entry) => entry.name)
342
+ .sort((leftName, rightName) => leftName.localeCompare(rightName));
343
+
344
+ let validManifestCount = 0;
345
+
346
+ for (const skillDomainDirectoryName of skillDomainDirectoryNames) {
347
+ const compatibilityManifestPath = join(
348
+ SKILLS_DIR,
349
+ skillDomainDirectoryName,
350
+ 'compatibility-manifest.json'
351
+ );
352
+
353
+ if (!(await fileExists(compatibilityManifestPath))) {
354
+ fail(`Missing compatibility manifest: .agent-context/skills/${skillDomainDirectoryName}/compatibility-manifest.json`);
355
+ continue;
356
+ }
357
+
358
+ let parsedCompatibilityManifest;
359
+ try {
360
+ parsedCompatibilityManifest = JSON.parse(await readTextFile(compatibilityManifestPath));
361
+ } catch (error) {
362
+ fail(`Invalid JSON compatibility manifest for ${skillDomainDirectoryName}: ${error.message}`);
363
+ continue;
364
+ }
365
+
366
+ if (!Array.isArray(parsedCompatibilityManifest.ides) || parsedCompatibilityManifest.ides.length === 0) {
367
+ fail(`Compatibility manifest for ${skillDomainDirectoryName} must include non-empty "ides" array`);
368
+ continue;
369
+ }
370
+
371
+ if (!Array.isArray(parsedCompatibilityManifest.platforms) || parsedCompatibilityManifest.platforms.length === 0) {
372
+ fail(`Compatibility manifest for ${skillDomainDirectoryName} must include non-empty "platforms" array`);
373
+ continue;
374
+ }
375
+
376
+ const unsupportedPlatform = parsedCompatibilityManifest.platforms.find(
377
+ (platformName) => !SUPPORTED_COMPATIBILITY_PLATFORMS.has(platformName)
378
+ );
379
+
380
+ if (unsupportedPlatform) {
381
+ fail(`Compatibility manifest for ${skillDomainDirectoryName} has unsupported platform: ${unsupportedPlatform}`);
382
+ continue;
383
+ }
384
+
385
+ if (
386
+ typeof parsedCompatibilityManifest.nodeMin !== 'string'
387
+ || !/^\d+(\.\d+)?$/.test(parsedCompatibilityManifest.nodeMin)
388
+ ) {
389
+ fail(`Compatibility manifest for ${skillDomainDirectoryName} must include string nodeMin (for example "18" or "18.0")`);
390
+ continue;
391
+ }
392
+
393
+ validManifestCount += 1;
394
+ pass(`Compatibility manifest validated: .agent-context/skills/${skillDomainDirectoryName}/compatibility-manifest.json`);
395
+ }
396
+
397
+ if (validManifestCount >= 6) {
398
+ pass(`Compatibility manifest coverage is valid (${validManifestCount} skill domains)`);
399
+ } else {
400
+ fail(`Compatibility manifest coverage is insufficient (${validManifestCount}/6 skill domains)`);
401
+ }
402
+ }
403
+
404
+ function stripMarkdownCodeBlocks(markdownText) {
405
+ return markdownText.replace(/```[\s\S]*?```/g, '');
406
+ }
407
+
408
+ function parseOverrideExpiryDate(rawExpiryValue) {
409
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(rawExpiryValue)) {
410
+ return null;
411
+ }
412
+
413
+ const parsedDate = new Date(`${rawExpiryValue}T00:00:00.000Z`);
414
+ return Number.isNaN(parsedDate.getTime()) ? null : parsedDate;
415
+ }
416
+
417
+ async function validateOverrideGovernance() {
418
+ console.log('\nChecking override governance...');
419
+
420
+ const overrideContent = await readTextFile(OVERRIDE_FILE_PATH);
421
+ const overrideContentWithoutCodeBlocks = stripMarkdownCodeBlocks(overrideContent);
422
+ const overrideEntryPattern = /\[Rule:\s*([^\]]+)\]([\s\S]*?)(?=\n\[Rule:|$)/g;
423
+ const overrideEntries = [];
424
+ let overrideEntryMatch = overrideEntryPattern.exec(overrideContentWithoutCodeBlocks);
425
+
426
+ while (overrideEntryMatch) {
427
+ const ruleName = overrideEntryMatch[1].trim();
428
+ const entryBody = overrideEntryMatch[2];
429
+ const ownerMatch = entryBody.match(/(?:^|\n)Owner:\s*(.+)/);
430
+ const expiryMatch = entryBody.match(/(?:^|\n)Expiry:\s*(.+)/);
431
+
432
+ overrideEntries.push({
433
+ ruleName,
434
+ owner: ownerMatch ? ownerMatch[1].trim() : '',
435
+ expiry: expiryMatch ? expiryMatch[1].trim() : '',
436
+ });
437
+
438
+ overrideEntryMatch = overrideEntryPattern.exec(overrideContentWithoutCodeBlocks);
439
+ }
440
+
441
+ if (overrideEntries.length === 0) {
442
+ pass('No active override entries found; governance baseline remains strict');
443
+ return;
444
+ }
445
+
446
+ const currentDate = new Date();
447
+
448
+ for (const overrideEntry of overrideEntries) {
449
+ const overrideContextLabel = `[Rule: ${overrideEntry.ruleName}]`;
450
+
451
+ if (!overrideEntry.owner) {
452
+ fail(`${overrideContextLabel} is missing Owner metadata`);
453
+ continue;
454
+ }
455
+
456
+ pass(`${overrideContextLabel} owner is defined`);
457
+
458
+ if (!overrideEntry.expiry) {
459
+ fail(`${overrideContextLabel} is missing Expiry metadata`);
460
+ continue;
461
+ }
462
+
463
+ const expiryDate = parseOverrideExpiryDate(overrideEntry.expiry);
464
+ if (!expiryDate) {
465
+ fail(`${overrideContextLabel} has invalid Expiry format (expected YYYY-MM-DD)`);
466
+ continue;
467
+ }
468
+
469
+ const remainingMilliseconds = expiryDate.getTime() - currentDate.getTime();
470
+ const remainingDays = Math.floor(remainingMilliseconds / (1000 * 60 * 60 * 24));
471
+
472
+ if (remainingMilliseconds < 0) {
473
+ fail(`${overrideContextLabel} is expired (${overrideEntry.expiry})`);
474
+ continue;
475
+ }
476
+
477
+ pass(`${overrideContextLabel} expiry is valid (${overrideEntry.expiry})`);
478
+
479
+ if (remainingDays <= OVERRIDE_WARNING_WINDOW_DAYS) {
480
+ warn(`${overrideContextLabel} expires in ${remainingDays} day(s); renew or remove soon`);
481
+ }
482
+ }
483
+ }
484
+
485
+ async function validateCrossReferences() {
486
+ console.log('\nChecking internal links...');
487
+
488
+ const markdownFilePaths = await collectFiles(ROOT_DIR, (fileName) => fileName.endsWith('.md'));
489
+ const linkPattern = /\[([^\]]*)\]\((?!https?:\/\/|#)([^)]+)\)/g;
490
+ let checkedLinkCount = 0;
491
+
492
+ for (const markdownFilePath of markdownFilePaths) {
493
+ const markdownContent = await readTextFile(markdownFilePath);
494
+ const currentFileDirectory = dirname(markdownFilePath);
495
+ const relativeMarkdownPath = relative(ROOT_DIR, markdownFilePath);
496
+ let linkMatch = linkPattern.exec(markdownContent);
497
+
498
+ while (linkMatch) {
499
+ const rawLinkTarget = linkMatch[2].split('#')[0];
500
+ if (rawLinkTarget) {
501
+ checkedLinkCount += 1;
502
+ const resolvedLinkPath = resolve(currentFileDirectory, rawLinkTarget);
503
+
504
+ if (await fileExists(resolvedLinkPath)) {
505
+ pass(`${relativeMarkdownPath} ${linkMatch[2]}`);
506
+ } else {
507
+ fail(`Broken link in ${relativeMarkdownPath}: ${linkMatch[2]}`);
508
+ }
509
+ }
510
+
511
+ linkMatch = linkPattern.exec(markdownContent);
512
+ }
513
+ }
514
+
515
+ if (checkedLinkCount === 0) {
516
+ warn('No internal links were found in markdown files');
517
+ }
518
+ }
519
+
520
+ async function validateAgentsManifest() {
521
+ console.log('\nChecking AGENTS.md manifest links...');
522
+
523
+ const agentsContent = await readTextFile(join(ROOT_DIR, 'AGENTS.md'));
524
+ const fileReferencePattern = /\[`?([^`\]]+)`?\]\(([^)]+)\)/g;
525
+ let manifestLinkCount = 0;
526
+ let fileReferenceMatch = fileReferencePattern.exec(agentsContent);
527
+
528
+ while (fileReferenceMatch) {
529
+ const manifestLinkTarget = fileReferenceMatch[2];
530
+
531
+ if (!manifestLinkTarget.startsWith('http')) {
532
+ manifestLinkCount += 1;
533
+ const resolvedManifestLinkPath = resolve(ROOT_DIR, manifestLinkTarget);
534
+
535
+ if (await fileExists(resolvedManifestLinkPath)) {
536
+ pass(`AGENTS.md ${manifestLinkTarget}`);
537
+ } else {
538
+ fail(`AGENTS.md references missing file: ${manifestLinkTarget}`);
539
+ }
540
+ }
541
+
542
+ fileReferenceMatch = fileReferencePattern.exec(agentsContent);
543
+ }
544
+
545
+ if (manifestLinkCount === 0) {
546
+ warn('AGENTS.md does not contain any local manifest links');
547
+ }
548
+ }
549
+
550
+ async function validatePackageMetadata() {
551
+ console.log('\nChecking package metadata...');
552
+
553
+ const packageJson = JSON.parse(await readTextFile(PACKAGE_JSON_PATH));
554
+ const versionPattern = /^\d+\.\d+\.\d+$/;
555
+
556
+ if (typeof packageJson.version !== 'string' || !versionPattern.test(packageJson.version)) {
557
+ fail('package.json version must be a semantic version string');
558
+ } else {
559
+ pass(`package.json version ${packageJson.version}`);
560
+ }
561
+
562
+ if (packageJson.scripts?.validate === 'node ./scripts/validate.mjs') {
563
+ pass('package.json validate script is Node-first');
564
+ } else {
565
+ fail('package.json validate script must use node ./scripts/validate.mjs');
566
+ }
567
+
568
+ if (packageJson.scripts?.test) {
569
+ pass('package.json test script exists');
570
+ } else {
571
+ fail('package.json test script is missing');
572
+ }
573
+
574
+ if (packageJson.devDependencies && Object.keys(packageJson.devDependencies).length > 0) {
575
+ warn('package.json still has devDependencies; review whether they are necessary');
576
+ } else {
577
+ pass('package.json has no unnecessary devDependencies');
578
+ }
579
+ }
580
+
581
+ async function validatePolicyFile() {
582
+ console.log('\nChecking LLM Judge policy...');
583
+
584
+ const policyContent = await readTextFile(POLICY_FILE_PATH);
585
+ const parsedPolicy = JSON.parse(policyContent);
586
+ const selectedProfileName = parsedPolicy.selectedProfile;
587
+ const profileThresholds = parsedPolicy.profileThresholds;
588
+
589
+ if (typeof selectedProfileName !== 'string') {
590
+ fail('Policy file must define selectedProfile as a string');
591
+ } else {
592
+ pass(`LLM Judge selected profile: ${selectedProfileName}`);
593
+ }
594
+
595
+ if (!profileThresholds || typeof profileThresholds !== 'object') {
596
+ fail('Policy file must define profileThresholds');
597
+ return;
598
+ }
599
+
600
+ for (const [profileName, profileSettings] of Object.entries(profileThresholds)) {
601
+ if (!Array.isArray(profileSettings.blockingSeverities)) {
602
+ fail(`Policy profile ${profileName} must define blockingSeverities`);
603
+ continue;
604
+ }
605
+
606
+ const invalidSeverity = profileSettings.blockingSeverities.find((severity) => !ALLOWED_SEVERITIES.has(severity));
607
+ if (invalidSeverity) {
608
+ fail(`Policy profile ${profileName} uses unsupported severity: ${invalidSeverity}`);
609
+ continue;
610
+ }
611
+
612
+ pass(`Policy profile ${profileName} blocking severities are valid`);
613
+ }
614
+
615
+ if (typeof profileThresholds[selectedProfileName] === 'object') {
616
+ pass('Policy selectedProfile points to a valid profile');
617
+ } else {
618
+ fail('Policy selectedProfile must match one of the configured profileThresholds');
619
+ }
620
+ }
621
+
622
+ async function validateVersionConsistency() {
623
+ console.log('\nChecking release version consistency...');
624
+
625
+ const packageJson = JSON.parse(await readTextFile(PACKAGE_JSON_PATH));
626
+ const packageVersion = packageJson.version;
627
+ const changelogContent = await readTextFile(CHANGELOG_PATH);
628
+
629
+ if (changelogContent.includes(`## ${packageVersion}`)) {
630
+ pass(`CHANGELOG.md contains release entry for ${packageVersion}`);
631
+ } else {
632
+ fail(`CHANGELOG.md is missing a ## ${packageVersion} heading`);
633
+ }
634
+
635
+ for (const generatedRuleFileName of GENERATED_RULE_FILES) {
636
+ const generatedRuleContent = await readTextFile(join(ROOT_DIR, generatedRuleFileName));
637
+
638
+ if (generatedRuleContent.includes(`Generated by Agentic-Senior-Core CLI v${packageVersion}`)) {
639
+ pass(`${generatedRuleFileName} matches package version ${packageVersion}`);
640
+ } else {
641
+ fail(`${generatedRuleFileName} does not match package version ${packageVersion}`);
642
+ }
643
+ }
644
+ }
645
+
646
+ async function validateDocumentationFlow() {
647
+ console.log('\nChecking documentation flow...');
648
+
649
+ const readmeContent = await readTextFile(README_PATH);
650
+ const requiredReadmeSnippets = [
651
+ 'GitHub Template',
652
+ 'scripts/init-project.ps1',
653
+ 'scripts/init-project.sh',
654
+ 'npx @ryuenn3123/agentic-senior-core init',
655
+ 'npm run validate',
656
+ 'docs/faq.md',
657
+ 'docs/deep-dive.md',
658
+ 'docs/v2-upgrade-playbook.md',
659
+ ];
660
+
661
+ for (const requiredReadmeSnippet of requiredReadmeSnippets) {
662
+ if (readmeContent.includes(requiredReadmeSnippet)) {
663
+ pass(`README.md mentions ${requiredReadmeSnippet}`);
664
+ } else {
665
+ fail(`README.md must mention ${requiredReadmeSnippet}`);
666
+ }
667
+ }
668
+ }
669
+
670
+ async function validateMcpConfiguration() {
671
+ console.log('\nChecking MCP configuration...');
672
+
673
+ const mcpConfiguration = JSON.parse(await readTextFile(join(ROOT_DIR, 'mcp.json')));
674
+ const lintServerCommand = mcpConfiguration.servers?.lint?.command;
675
+ const testServerCommand = mcpConfiguration.servers?.test?.command;
676
+
677
+ if (lintServerCommand === 'node') {
678
+ pass('MCP lint server uses Node');
679
+ } else {
680
+ fail('MCP lint server must use Node');
681
+ }
682
+
683
+ if (testServerCommand === 'node') {
684
+ pass('MCP test server uses Node');
685
+ } else {
686
+ fail('MCP test server must use Node');
687
+ }
688
+ }
689
+
690
+ async function validateInstructionAdapters() {
691
+ console.log('\nChecking instruction adapter consolidation...');
692
+
693
+ const canonicalInstructionContent = normalizeLineEndings(await readTextFile(CANONICAL_INSTRUCTION_PATH));
694
+ const canonicalSnapshotHash = createHash('sha256').update(canonicalInstructionContent).digest('hex');
695
+
696
+ for (const thinAdapterPath of THIN_ADAPTER_PATHS) {
697
+ const absoluteAdapterPath = join(ROOT_DIR, thinAdapterPath);
698
+
699
+ if (!(await fileExists(absoluteAdapterPath))) {
700
+ fail(`Missing thin adapter file: ${thinAdapterPath}`);
701
+ continue;
702
+ }
703
+
704
+ const thinAdapterContent = await readTextFile(absoluteAdapterPath);
705
+
706
+ if (
707
+ thinAdapterContent.includes('Adapter Mode: thin')
708
+ && thinAdapterContent.includes('Adapter Source: .instructions.md')
709
+ ) {
710
+ pass(`${thinAdapterPath} declares thin adapter metadata`);
711
+ } else {
712
+ fail(`${thinAdapterPath} must declare Adapter Mode: thin and Adapter Source: .instructions.md`);
713
+ }
714
+
715
+ const hashMatch = thinAdapterContent.match(/Canonical Snapshot SHA256:\s*([a-f0-9]{64})/);
716
+ if (!hashMatch) {
717
+ fail(`${thinAdapterPath} must declare Canonical Snapshot SHA256`);
718
+ continue;
719
+ }
720
+
721
+ if (hashMatch[1] === canonicalSnapshotHash) {
722
+ pass(`${thinAdapterPath} canonical hash matches .instructions.md`);
723
+ } else {
724
+ fail(`${thinAdapterPath} canonical hash drift detected (expected ${canonicalSnapshotHash})`);
725
+ }
726
+
727
+ const thinAdapterLineCount = thinAdapterContent.split(/\r?\n/u).length;
728
+ if (thinAdapterLineCount <= 80) {
729
+ pass(`${thinAdapterPath} remains thin (${thinAdapterLineCount} lines)`);
730
+ } else {
731
+ fail(`${thinAdapterPath} is too large for thin-adapter mode (${thinAdapterLineCount} lines)`);
732
+ }
733
+ }
734
+ }
735
+
736
+ async function validateTrustTierSchema() {
737
+ console.log('\nChecking marketplace trust tier schema...');
738
+
739
+ const trustTierPath = join(AGENT_CONTEXT_DIR, 'marketplace', 'trust-tiers.json');
740
+ const trustTierContent = await readTextFile(trustTierPath);
741
+ const trustTierSchema = JSON.parse(trustTierContent);
742
+
743
+ const expectedTierNames = ['verified', 'community', 'experimental'];
744
+ for (const expectedTierName of expectedTierNames) {
745
+ if (trustTierSchema.tiers?.[expectedTierName]) {
746
+ pass(`Trust tier "${expectedTierName}" is defined`);
747
+ } else {
748
+ fail(`Trust tier "${expectedTierName}" is missing from trust-tiers.json`);
749
+ }
750
+ }
751
+
752
+ const scorecardDimensions = trustTierSchema.scorecard?.dimensions;
753
+ if (!scorecardDimensions || typeof scorecardDimensions !== 'object') {
754
+ fail('Trust tier scorecard must define dimensions');
755
+ return;
756
+ }
757
+
758
+ const dimensionNames = Object.keys(scorecardDimensions);
759
+ let totalWeight = 0;
760
+
761
+ for (const dimensionName of dimensionNames) {
762
+ const dimensionWeight = scorecardDimensions[dimensionName].weight;
763
+ if (typeof dimensionWeight !== 'number' || dimensionWeight <= 0) {
764
+ fail(`Scorecard dimension "${dimensionName}" must have a positive weight`);
765
+ continue;
766
+ }
767
+ totalWeight += dimensionWeight;
768
+ pass(`Scorecard dimension "${dimensionName}" weight: ${dimensionWeight}`);
769
+ }
770
+
771
+ if (totalWeight === 100) {
772
+ pass(`Scorecard weights sum to 100`);
773
+ } else {
774
+ fail(`Scorecard weights must sum to 100 (got ${totalWeight})`);
775
+ }
776
+
777
+ for (const dimensionName of dimensionNames) {
778
+ const gates = scorecardDimensions[dimensionName].gates;
779
+ if (!Array.isArray(gates) || gates.length === 0) {
780
+ fail(`Scorecard dimension "${dimensionName}" must define at least one gate`);
781
+ continue;
782
+ }
783
+ pass(`Scorecard dimension "${dimensionName}" has ${gates.length} gates`);
784
+ }
785
+
786
+ for (const [tierName, tierDefinition] of Object.entries(trustTierSchema.tiers)) {
787
+ if (typeof tierDefinition.minimumScore !== 'number') {
788
+ fail(`Tier "${tierName}" must define a numeric minimumScore`);
789
+ continue;
790
+ }
791
+ pass(`Tier "${tierName}" minimumScore: ${tierDefinition.minimumScore}`);
792
+ }
793
+ }
794
+
795
+ async function validateEvidenceBundles() {
796
+ console.log('\nChecking skill evidence bundles and trust scores...');
797
+
798
+ const skillsDir = join(AGENT_CONTEXT_DIR, 'skills');
799
+ const skillDirs = (await readdir(skillsDir, { withFileTypes: true }))
800
+ .filter(dirent => dirent.isDirectory())
801
+ .map(dirent => dirent.name);
802
+
803
+ const requiredVerifiedSkillNames = new Set([
804
+ 'cli',
805
+ 'frontend',
806
+ 'fullstack',
807
+ 'distribution',
808
+ 'review-quality',
809
+ ]);
810
+
811
+ for (const skillName of skillDirs) {
812
+ try {
813
+ const result = await calculateTrustScore(join(skillsDir, skillName));
814
+
815
+ if (requiredVerifiedSkillNames.has(skillName)) {
816
+ if (result.tier === 'verified') {
817
+ pass(`Skill "${skillName}" achieved Verified trust tier (Score: ${result.score})`);
818
+ } else {
819
+ fail(`Skill "${skillName}" failed to reach Verified tier. Got ${result.tier} (Score: ${result.score})`);
820
+ continue;
821
+ }
822
+
823
+ continue;
824
+ }
825
+
826
+ pass(`Skill "${skillName}" parses successfully as ${result.tier} tier`);
827
+ } catch (err) {
828
+ fail(`Skill "${skillName}" scorer crashed: ${err.message}`);
829
+ }
830
+ }
831
+ }
832
+
833
+ async function main() {
834
+ console.log('===============================================');
835
+ console.log(' Agentic-Senior-Core Repository Validator');
836
+ console.log('===============================================');
837
+
838
+ await validateRequiredFiles();
839
+ await validateMarkdownFiles();
840
+ await validateRuleFiles();
841
+ await validateSkillTierQuality();
842
+ await validateSkillCompatibilityManifests();
843
+ await validateOverrideGovernance();
844
+ await validateAgentsManifest();
845
+ await validateCrossReferences();
846
+ await validatePackageMetadata();
847
+ await validatePolicyFile();
848
+ await validateVersionConsistency();
849
+ await validateDocumentationFlow();
850
+ await validateMcpConfiguration();
851
+ await validateInstructionAdapters();
852
+ await validateTrustTierSchema();
853
+ await validateEvidenceBundles();
854
+
855
+ console.log('\n===============================================');
856
+ console.log(' RESULTS');
857
+ console.log('===============================================');
858
+ console.log(` Passed: ${validationResult.passed}`);
859
+ console.log(` Failed: ${validationResult.failed}`);
860
+ console.log(` Warnings: ${validationResult.warnings.length}`);
861
+ console.log('===============================================');
862
+
863
+ if (validationResult.failed > 0) {
864
+ console.log('\nVALIDATION FAILED\n');
865
+ process.exit(1);
866
+ }
867
+
868
+ console.log('\nALL CHECKS PASSED\n');
869
+ }
870
+
871
+ main().catch((error) => {
872
+ console.error('Validator crashed:', error);
873
+ process.exit(1);
874
+ });