@ryuenn3123/agentic-senior-core 1.9.0 → 1.9.2

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 (86) hide show
  1. package/.agent-context/blueprints/mobile-app.md +21 -21
  2. package/.agent-context/policies/llm-judge-threshold.json +29 -20
  3. package/.agent-context/profiles/platform.md +13 -13
  4. package/.agent-context/profiles/regulated.md +13 -13
  5. package/.agent-context/profiles/startup.md +13 -13
  6. package/.agent-context/review-checklists/frontend-skill-parity.md +28 -28
  7. package/.agent-context/review-checklists/frontend-usability.md +33 -33
  8. package/.agent-context/review-checklists/release-operations.md +29 -29
  9. package/.agent-context/rules/security.md +92 -0
  10. package/.agent-context/skills/README.md +62 -62
  11. package/.agent-context/skills/backend/README.md +67 -67
  12. package/.agent-context/skills/backend/architecture.md +360 -360
  13. package/.agent-context/skills/backend/data-access.md +230 -230
  14. package/.agent-context/skills/backend/errors.md +137 -137
  15. package/.agent-context/skills/backend/validation.md +116 -116
  16. package/.agent-context/skills/backend.md +28 -28
  17. package/.agent-context/skills/cli/README.md +49 -49
  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/upgrade.md +37 -37
  21. package/.agent-context/skills/cli.md +28 -28
  22. package/.agent-context/skills/distribution/README.md +18 -18
  23. package/.agent-context/skills/distribution/compatibility.md +31 -31
  24. package/.agent-context/skills/distribution/publish.md +36 -36
  25. package/.agent-context/skills/distribution/rollback.md +31 -31
  26. package/.agent-context/skills/distribution.md +28 -28
  27. package/.agent-context/skills/frontend/README.md +35 -35
  28. package/.agent-context/skills/frontend/accessibility.md +107 -107
  29. package/.agent-context/skills/frontend/motion.md +66 -66
  30. package/.agent-context/skills/frontend/performance.md +62 -62
  31. package/.agent-context/skills/frontend/ui-architecture.md +128 -128
  32. package/.agent-context/skills/frontend.md +29 -29
  33. package/.agent-context/skills/fullstack/README.md +18 -18
  34. package/.agent-context/skills/fullstack/contracts.md +52 -52
  35. package/.agent-context/skills/fullstack/end-to-end.md +41 -41
  36. package/.agent-context/skills/fullstack/feature-slicing.md +64 -64
  37. package/.agent-context/skills/fullstack.md +26 -26
  38. package/.agent-context/skills/index.json +107 -107
  39. package/.agent-context/skills/review-quality/README.md +18 -18
  40. package/.agent-context/skills/review-quality/benchmark.md +29 -29
  41. package/.agent-context/skills/review-quality/planning.md +37 -37
  42. package/.agent-context/skills/review-quality/security.md +33 -33
  43. package/.agent-context/skills/review-quality.md +27 -27
  44. package/.agent-context/stacks/flutter.md +16 -16
  45. package/.agent-context/stacks/react-native.md +16 -16
  46. package/.agent-context/state/architecture-map.md +25 -25
  47. package/.agent-context/state/benchmark-analysis.json +431 -431
  48. package/.agent-context/state/benchmark-thresholds.json +10 -10
  49. package/.agent-context/state/benchmark-watchlist.json +19 -19
  50. package/.agent-context/state/dependency-map.md +32 -32
  51. package/.agent-context/state/onboarding-report.json +39 -0
  52. package/.agent-context/state/skill-platform.json +38 -38
  53. package/.agent-override.md +36 -36
  54. package/.cursorrules +3718 -140
  55. package/.github/ISSUE_TEMPLATE/v1.7-frontend-work-item.yml +54 -54
  56. package/.github/workflows/benchmark-detection.yml +38 -38
  57. package/.github/workflows/benchmark-intelligence.yml +50 -50
  58. package/.github/workflows/frontend-usability-gate.yml +36 -36
  59. package/.github/workflows/publish.yml +32 -0
  60. package/.github/workflows/release-gate.yml +32 -32
  61. package/.github/workflows/sbom-compliance.yml +32 -32
  62. package/.windsurfrules +3718 -106
  63. package/AGENTS.md +181 -181
  64. package/README.md +318 -318
  65. package/bin/agentic-senior-core.js +61 -1556
  66. package/lib/cli/commands/init.mjs +339 -0
  67. package/lib/cli/commands/launch.mjs +81 -0
  68. package/lib/cli/commands/upgrade.mjs +165 -0
  69. package/lib/cli/compiler.mjs +204 -0
  70. package/lib/cli/constants.mjs +136 -0
  71. package/lib/cli/detector.mjs +211 -0
  72. package/lib/cli/profile-packs.mjs +94 -0
  73. package/lib/cli/skill-selector.mjs +210 -0
  74. package/lib/cli/utils.mjs +227 -0
  75. package/mcp.json +92 -92
  76. package/package.json +3 -1
  77. package/scripts/benchmark-gate.mjs +121 -121
  78. package/scripts/benchmark-intelligence.mjs +140 -140
  79. package/scripts/detection-benchmark.mjs +138 -138
  80. package/scripts/frontend-usability-audit.mjs +87 -87
  81. package/scripts/generate-sbom.mjs +61 -61
  82. package/scripts/init-project.ps1 +104 -104
  83. package/scripts/llm-judge.mjs +664 -664
  84. package/scripts/release-gate.mjs +116 -116
  85. package/scripts/skill-tier-policy.mjs +75 -75
  86. package/scripts/validate.mjs +636 -636
@@ -1,636 +1,636 @@
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 { validateSkillTopicContent } from './skill-tier-policy.mjs';
20
-
21
- const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
22
- const ROOT_DIR = resolve(dirname(SCRIPT_FILE_PATH), '..');
23
- const AGENT_CONTEXT_DIR = join(ROOT_DIR, '.agent-context');
24
- const PACKAGE_JSON_PATH = join(ROOT_DIR, 'package.json');
25
- const CHANGELOG_PATH = join(ROOT_DIR, 'CHANGELOG.md');
26
- const README_PATH = join(ROOT_DIR, 'README.md');
27
- const POLICY_FILE_PATH = join(ROOT_DIR, '.agent-context', 'policies', 'llm-judge-threshold.json');
28
- const OVERRIDE_FILE_PATH = join(ROOT_DIR, '.agent-override.md');
29
- const SKILLS_DIR = join(AGENT_CONTEXT_DIR, 'skills');
30
- const GENERATED_RULE_FILES = ['.cursorrules', '.windsurfrules'];
31
- const ALLOWED_SEVERITIES = new Set(['critical', 'high', 'medium', 'low']);
32
- const OVERRIDE_WARNING_WINDOW_DAYS = 30;
33
-
34
- const validationResult = {
35
- passed: 0,
36
- failed: 0,
37
- errors: [],
38
- warnings: [],
39
- };
40
-
41
- async function fileExists(filePath) {
42
- try {
43
- await stat(filePath);
44
- return true;
45
- } catch {
46
- return false;
47
- }
48
- }
49
-
50
- async function readTextFile(filePath) {
51
- return readFile(filePath, 'utf8');
52
- }
53
-
54
- async function collectFiles(directoryPath, fileExtensionMatcher) {
55
- const matchingFilePaths = [];
56
-
57
- async function walk(currentDirectoryPath) {
58
- const directoryEntries = await readdir(currentDirectoryPath, { withFileTypes: true });
59
-
60
- for (const directoryEntry of directoryEntries) {
61
- if (directoryEntry.name === '.git' || directoryEntry.name === 'node_modules') {
62
- continue;
63
- }
64
-
65
- const entryPath = join(currentDirectoryPath, directoryEntry.name);
66
-
67
- if (directoryEntry.isDirectory()) {
68
- await walk(entryPath);
69
- continue;
70
- }
71
-
72
- if (fileExtensionMatcher(directoryEntry.name)) {
73
- matchingFilePaths.push(entryPath);
74
- }
75
- }
76
- }
77
-
78
- await walk(directoryPath);
79
- return matchingFilePaths;
80
- }
81
-
82
- function pass(message) {
83
- validationResult.passed += 1;
84
- console.log(` PASS ${message}`);
85
- }
86
-
87
- function fail(message) {
88
- validationResult.failed += 1;
89
- validationResult.errors.push(message);
90
- console.log(` FAIL ${message}`);
91
- }
92
-
93
- function warn(message) {
94
- validationResult.warnings.push(message);
95
- console.log(` WARN ${message}`);
96
- }
97
-
98
- async function validateRequiredFiles() {
99
- console.log('\nChecking required files...');
100
-
101
- const requiredFiles = [
102
- 'bin/agentic-senior-core.js',
103
- 'scripts/validate.mjs',
104
- 'scripts/llm-judge.mjs',
105
- 'scripts/detection-benchmark.mjs',
106
- 'scripts/benchmark-gate.mjs',
107
- 'scripts/benchmark-intelligence.mjs',
108
- 'scripts/frontend-usability-audit.mjs',
109
- 'scripts/release-gate.mjs',
110
- 'scripts/generate-sbom.mjs',
111
- 'scripts/init-project.sh',
112
- 'scripts/init-project.ps1',
113
- '.cursorrules',
114
- '.windsurfrules',
115
- '.agent-override.md',
116
- '.agent-context/policies/llm-judge-threshold.json',
117
- 'mcp.json',
118
- 'AGENTS.md',
119
- '.github/copilot-instructions.md',
120
- '.gemini/instructions.md',
121
- 'README.md',
122
- 'CHANGELOG.md',
123
- 'docs/faq.md',
124
- 'docs/deep-dive.md',
125
- 'docs/v1.7-execution-playbook.md',
126
- 'docs/v1.7-issue-breakdown.md',
127
- 'docs/v1.8-operations-playbook.md',
128
- 'docs/v2-upgrade-playbook.md',
129
- '.agent-context/state/benchmark-watchlist.json',
130
- '.agent-context/state/skill-platform.json',
131
- '.agent-context/skills/index.json',
132
- '.github/workflows/release-gate.yml',
133
- '.github/workflows/sbom-compliance.yml',
134
- '.github/workflows/benchmark-intelligence.yml',
135
- 'tests/cli-smoke.test.mjs',
136
- 'tests/llm-judge.test.mjs',
137
- 'tests/enterprise-ops.test.mjs',
138
- 'LICENSE',
139
- '.gitignore',
140
- ];
141
-
142
- for (const requiredFilePath of requiredFiles) {
143
- const absoluteRequiredFilePath = join(ROOT_DIR, requiredFilePath);
144
-
145
- if (await fileExists(absoluteRequiredFilePath)) {
146
- pass(requiredFilePath);
147
- continue;
148
- }
149
-
150
- fail(`Missing required file: ${requiredFilePath}`);
151
- }
152
- }
153
-
154
- async function validateMarkdownFiles() {
155
- console.log('\nChecking markdown content...');
156
-
157
- const markdownFilePaths = await collectFiles(ROOT_DIR, (fileName) => fileName.endsWith('.md'));
158
-
159
- for (const markdownFilePath of markdownFilePaths) {
160
- const markdownContent = await readTextFile(markdownFilePath);
161
- const relativeMarkdownPath = relative(ROOT_DIR, markdownFilePath);
162
-
163
- if (markdownContent.trim().length === 0) {
164
- fail(`Empty markdown file: ${relativeMarkdownPath}`);
165
- continue;
166
- }
167
-
168
- pass(`${relativeMarkdownPath} (${markdownContent.length} chars)`);
169
- }
170
- }
171
-
172
- async function validateRuleFiles() {
173
- console.log('\nChecking rule, stack, blueprint, checklist, and state files...');
174
-
175
- const expectedPaths = [
176
- 'rules/naming-conv.md',
177
- 'rules/architecture.md',
178
- 'rules/security.md',
179
- 'rules/performance.md',
180
- 'rules/error-handling.md',
181
- 'rules/testing.md',
182
- 'rules/git-workflow.md',
183
- 'rules/efficiency-vs-hype.md',
184
- 'rules/api-docs.md',
185
- 'rules/microservices.md',
186
- 'rules/event-driven.md',
187
- 'rules/database-design.md',
188
- 'rules/realtime.md',
189
- 'rules/frontend-architecture.md',
190
- 'stacks/typescript.md',
191
- 'stacks/python.md',
192
- 'stacks/java.md',
193
- 'stacks/php.md',
194
- 'stacks/go.md',
195
- 'stacks/csharp.md',
196
- 'stacks/rust.md',
197
- 'stacks/ruby.md',
198
- 'blueprints/api-nextjs.md',
199
- 'blueprints/nestjs-logic.md',
200
- 'blueprints/fastapi-service.md',
201
- 'blueprints/laravel-api.md',
202
- 'blueprints/spring-boot-api.md',
203
- 'blueprints/go-service.md',
204
- 'blueprints/aspnet-api.md',
205
- 'blueprints/ci-github-actions.md',
206
- 'blueprints/ci-gitlab.md',
207
- 'blueprints/observability.md',
208
- 'blueprints/graphql-grpc-api.md',
209
- 'blueprints/infrastructure-as-code.md',
210
- 'blueprints/kubernetes-manifests.md',
211
- 'profiles/startup.md',
212
- 'profiles/regulated.md',
213
- 'profiles/platform.md',
214
- 'review-checklists/pr-checklist.md',
215
- 'review-checklists/frontend-usability.md',
216
- 'review-checklists/frontend-skill-parity.md',
217
- 'review-checklists/release-operations.md',
218
- 'review-checklists/security-audit.md',
219
- 'review-checklists/performance-audit.md',
220
- 'review-checklists/architecture-review.md',
221
- 'skills/README.md',
222
- 'skills/frontend/README.md',
223
- 'skills/backend/README.md',
224
- 'skills/fullstack/README.md',
225
- 'skills/cli/README.md',
226
- 'skills/distribution/README.md',
227
- 'skills/review-quality/README.md',
228
- 'skills/frontend.md',
229
- 'skills/backend.md',
230
- 'skills/fullstack.md',
231
- 'skills/cli.md',
232
- 'skills/distribution.md',
233
- 'skills/review-quality.md',
234
- 'state/architecture-map.md',
235
- 'state/dependency-map.md',
236
- ];
237
-
238
- for (const expectedPath of expectedPaths) {
239
- const absoluteExpectedPath = join(AGENT_CONTEXT_DIR, expectedPath);
240
-
241
- if (!(await fileExists(absoluteExpectedPath))) {
242
- fail(`Missing agent context file: .agent-context/${expectedPath}`);
243
- continue;
244
- }
245
-
246
- const fileContent = await readTextFile(absoluteExpectedPath);
247
- if (fileContent.trim().length < 100) {
248
- fail(`Agent context file is suspiciously short: .agent-context/${expectedPath}`);
249
- continue;
250
- }
251
-
252
- pass(`.agent-context/${expectedPath}`);
253
- }
254
- }
255
-
256
- async function validateSkillTierQuality() {
257
- console.log('\nChecking skill tier quality...');
258
-
259
- const skillMarkdownFiles = await collectFiles(SKILLS_DIR, (fileName) => fileName.endsWith('.md'));
260
- const scopedSkillTopicFiles = skillMarkdownFiles.filter((skillFilePath) => {
261
- if (skillFilePath.endsWith('README.md')) {
262
- return false;
263
- }
264
-
265
- const relativeSkillPath = relative(SKILLS_DIR, skillFilePath);
266
- return /[\\/]/.test(relativeSkillPath);
267
- });
268
-
269
- for (const skillTopicPath of scopedSkillTopicFiles) {
270
- const skillTopicContent = await readTextFile(skillTopicPath);
271
- const relativeSkillTopicPath = relative(ROOT_DIR, skillTopicPath);
272
- const validationResult = validateSkillTopicContent(skillTopicContent);
273
-
274
- if (!validationResult.isValid) {
275
- if (validationResult.reason === 'missing-tier') {
276
- fail(`${relativeSkillTopicPath} is missing explicit Tier metadata`);
277
- continue;
278
- }
279
-
280
- if (validationResult.reason === 'unsupported-tier') {
281
- fail(`${relativeSkillTopicPath} has unsupported tier: ${validationResult.detectedTier}`);
282
- continue;
283
- }
284
-
285
- if (validationResult.reason === 'word-count') {
286
- fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minWords} words (found ${validationResult.wordCount})`);
287
- continue;
288
- }
289
-
290
- if (validationResult.reason === 'heading-count') {
291
- fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minHeadings} section headings (found ${validationResult.headingCount})`);
292
- continue;
293
- }
294
-
295
- if (validationResult.reason === 'checklist-count') {
296
- fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minChecklistItems} checklist item(s) (found ${validationResult.checklistCount})`);
297
- continue;
298
- }
299
-
300
- if (validationResult.reason === 'code-block-count') {
301
- fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minCodeBlocks} code block(s) (found ${validationResult.codeBlockCount})`);
302
- continue;
303
- }
304
-
305
- fail(`${relativeSkillTopicPath} failed tier validation`);
306
- continue;
307
- }
308
-
309
- pass(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} quality gate passed`);
310
- }
311
- }
312
-
313
- function stripMarkdownCodeBlocks(markdownText) {
314
- return markdownText.replace(/```[\s\S]*?```/g, '');
315
- }
316
-
317
- function parseOverrideExpiryDate(rawExpiryValue) {
318
- if (!/^\d{4}-\d{2}-\d{2}$/.test(rawExpiryValue)) {
319
- return null;
320
- }
321
-
322
- const parsedDate = new Date(`${rawExpiryValue}T00:00:00.000Z`);
323
- return Number.isNaN(parsedDate.getTime()) ? null : parsedDate;
324
- }
325
-
326
- async function validateOverrideGovernance() {
327
- console.log('\nChecking override governance...');
328
-
329
- const overrideContent = await readTextFile(OVERRIDE_FILE_PATH);
330
- const overrideContentWithoutCodeBlocks = stripMarkdownCodeBlocks(overrideContent);
331
- const overrideEntryPattern = /\[Rule:\s*([^\]]+)\]([\s\S]*?)(?=\n\[Rule:|$)/g;
332
- const overrideEntries = [];
333
- let overrideEntryMatch = overrideEntryPattern.exec(overrideContentWithoutCodeBlocks);
334
-
335
- while (overrideEntryMatch) {
336
- const ruleName = overrideEntryMatch[1].trim();
337
- const entryBody = overrideEntryMatch[2];
338
- const ownerMatch = entryBody.match(/(?:^|\n)Owner:\s*(.+)/);
339
- const expiryMatch = entryBody.match(/(?:^|\n)Expiry:\s*(.+)/);
340
-
341
- overrideEntries.push({
342
- ruleName,
343
- owner: ownerMatch ? ownerMatch[1].trim() : '',
344
- expiry: expiryMatch ? expiryMatch[1].trim() : '',
345
- });
346
-
347
- overrideEntryMatch = overrideEntryPattern.exec(overrideContentWithoutCodeBlocks);
348
- }
349
-
350
- if (overrideEntries.length === 0) {
351
- pass('No active override entries found; governance baseline remains strict');
352
- return;
353
- }
354
-
355
- const currentDate = new Date();
356
-
357
- for (const overrideEntry of overrideEntries) {
358
- const overrideContextLabel = `[Rule: ${overrideEntry.ruleName}]`;
359
-
360
- if (!overrideEntry.owner) {
361
- fail(`${overrideContextLabel} is missing Owner metadata`);
362
- continue;
363
- }
364
-
365
- pass(`${overrideContextLabel} owner is defined`);
366
-
367
- if (!overrideEntry.expiry) {
368
- fail(`${overrideContextLabel} is missing Expiry metadata`);
369
- continue;
370
- }
371
-
372
- const expiryDate = parseOverrideExpiryDate(overrideEntry.expiry);
373
- if (!expiryDate) {
374
- fail(`${overrideContextLabel} has invalid Expiry format (expected YYYY-MM-DD)`);
375
- continue;
376
- }
377
-
378
- const remainingMilliseconds = expiryDate.getTime() - currentDate.getTime();
379
- const remainingDays = Math.floor(remainingMilliseconds / (1000 * 60 * 60 * 24));
380
-
381
- if (remainingMilliseconds < 0) {
382
- fail(`${overrideContextLabel} is expired (${overrideEntry.expiry})`);
383
- continue;
384
- }
385
-
386
- pass(`${overrideContextLabel} expiry is valid (${overrideEntry.expiry})`);
387
-
388
- if (remainingDays <= OVERRIDE_WARNING_WINDOW_DAYS) {
389
- warn(`${overrideContextLabel} expires in ${remainingDays} day(s); renew or remove soon`);
390
- }
391
- }
392
- }
393
-
394
- async function validateCrossReferences() {
395
- console.log('\nChecking internal links...');
396
-
397
- const markdownFilePaths = await collectFiles(ROOT_DIR, (fileName) => fileName.endsWith('.md'));
398
- const linkPattern = /\[([^\]]*)\]\((?!https?:\/\/|#)([^)]+)\)/g;
399
- let checkedLinkCount = 0;
400
-
401
- for (const markdownFilePath of markdownFilePaths) {
402
- const markdownContent = await readTextFile(markdownFilePath);
403
- const currentFileDirectory = dirname(markdownFilePath);
404
- const relativeMarkdownPath = relative(ROOT_DIR, markdownFilePath);
405
- let linkMatch = linkPattern.exec(markdownContent);
406
-
407
- while (linkMatch) {
408
- const rawLinkTarget = linkMatch[2].split('#')[0];
409
- if (rawLinkTarget) {
410
- checkedLinkCount += 1;
411
- const resolvedLinkPath = resolve(currentFileDirectory, rawLinkTarget);
412
-
413
- if (await fileExists(resolvedLinkPath)) {
414
- pass(`${relativeMarkdownPath} → ${linkMatch[2]}`);
415
- } else {
416
- fail(`Broken link in ${relativeMarkdownPath}: ${linkMatch[2]}`);
417
- }
418
- }
419
-
420
- linkMatch = linkPattern.exec(markdownContent);
421
- }
422
- }
423
-
424
- if (checkedLinkCount === 0) {
425
- warn('No internal links were found in markdown files');
426
- }
427
- }
428
-
429
- async function validateAgentsManifest() {
430
- console.log('\nChecking AGENTS.md manifest links...');
431
-
432
- const agentsContent = await readTextFile(join(ROOT_DIR, 'AGENTS.md'));
433
- const fileReferencePattern = /\[`?([^`\]]+)`?\]\(([^)]+)\)/g;
434
- let manifestLinkCount = 0;
435
- let fileReferenceMatch = fileReferencePattern.exec(agentsContent);
436
-
437
- while (fileReferenceMatch) {
438
- const manifestLinkTarget = fileReferenceMatch[2];
439
-
440
- if (!manifestLinkTarget.startsWith('http')) {
441
- manifestLinkCount += 1;
442
- const resolvedManifestLinkPath = resolve(ROOT_DIR, manifestLinkTarget);
443
-
444
- if (await fileExists(resolvedManifestLinkPath)) {
445
- pass(`AGENTS.md → ${manifestLinkTarget}`);
446
- } else {
447
- fail(`AGENTS.md references missing file: ${manifestLinkTarget}`);
448
- }
449
- }
450
-
451
- fileReferenceMatch = fileReferencePattern.exec(agentsContent);
452
- }
453
-
454
- if (manifestLinkCount === 0) {
455
- warn('AGENTS.md does not contain any local manifest links');
456
- }
457
- }
458
-
459
- async function validatePackageMetadata() {
460
- console.log('\nChecking package metadata...');
461
-
462
- const packageJson = JSON.parse(await readTextFile(PACKAGE_JSON_PATH));
463
- const versionPattern = /^\d+\.\d+\.\d+$/;
464
-
465
- if (typeof packageJson.version !== 'string' || !versionPattern.test(packageJson.version)) {
466
- fail('package.json version must be a semantic version string');
467
- } else {
468
- pass(`package.json version ${packageJson.version}`);
469
- }
470
-
471
- if (packageJson.scripts?.validate === 'node ./scripts/validate.mjs') {
472
- pass('package.json validate script is Node-first');
473
- } else {
474
- fail('package.json validate script must use node ./scripts/validate.mjs');
475
- }
476
-
477
- if (packageJson.scripts?.test) {
478
- pass('package.json test script exists');
479
- } else {
480
- fail('package.json test script is missing');
481
- }
482
-
483
- if (packageJson.devDependencies && Object.keys(packageJson.devDependencies).length > 0) {
484
- warn('package.json still has devDependencies; review whether they are necessary');
485
- } else {
486
- pass('package.json has no unnecessary devDependencies');
487
- }
488
- }
489
-
490
- async function validatePolicyFile() {
491
- console.log('\nChecking LLM Judge policy...');
492
-
493
- const policyContent = await readTextFile(POLICY_FILE_PATH);
494
- const parsedPolicy = JSON.parse(policyContent);
495
- const selectedProfileName = parsedPolicy.selectedProfile;
496
- const profileThresholds = parsedPolicy.profileThresholds;
497
-
498
- if (typeof selectedProfileName !== 'string') {
499
- fail('Policy file must define selectedProfile as a string');
500
- } else {
501
- pass(`LLM Judge selected profile: ${selectedProfileName}`);
502
- }
503
-
504
- if (!profileThresholds || typeof profileThresholds !== 'object') {
505
- fail('Policy file must define profileThresholds');
506
- return;
507
- }
508
-
509
- for (const [profileName, profileSettings] of Object.entries(profileThresholds)) {
510
- if (!Array.isArray(profileSettings.blockingSeverities)) {
511
- fail(`Policy profile ${profileName} must define blockingSeverities`);
512
- continue;
513
- }
514
-
515
- const invalidSeverity = profileSettings.blockingSeverities.find((severity) => !ALLOWED_SEVERITIES.has(severity));
516
- if (invalidSeverity) {
517
- fail(`Policy profile ${profileName} uses unsupported severity: ${invalidSeverity}`);
518
- continue;
519
- }
520
-
521
- pass(`Policy profile ${profileName} blocking severities are valid`);
522
- }
523
-
524
- if (typeof profileThresholds[selectedProfileName] === 'object') {
525
- pass('Policy selectedProfile points to a valid profile');
526
- } else {
527
- fail('Policy selectedProfile must match one of the configured profileThresholds');
528
- }
529
- }
530
-
531
- async function validateVersionConsistency() {
532
- console.log('\nChecking release version consistency...');
533
-
534
- const packageJson = JSON.parse(await readTextFile(PACKAGE_JSON_PATH));
535
- const packageVersion = packageJson.version;
536
- const changelogContent = await readTextFile(CHANGELOG_PATH);
537
-
538
- if (changelogContent.includes(`## ${packageVersion}`)) {
539
- pass(`CHANGELOG.md contains release entry for ${packageVersion}`);
540
- } else {
541
- fail(`CHANGELOG.md is missing a ## ${packageVersion} heading`);
542
- }
543
-
544
- for (const generatedRuleFileName of GENERATED_RULE_FILES) {
545
- const generatedRuleContent = await readTextFile(join(ROOT_DIR, generatedRuleFileName));
546
-
547
- if (generatedRuleContent.includes(`Generated by Agentic-Senior-Core CLI v${packageVersion}`)) {
548
- pass(`${generatedRuleFileName} matches package version ${packageVersion}`);
549
- } else {
550
- fail(`${generatedRuleFileName} does not match package version ${packageVersion}`);
551
- }
552
- }
553
- }
554
-
555
- async function validateDocumentationFlow() {
556
- console.log('\nChecking documentation flow...');
557
-
558
- const readmeContent = await readTextFile(README_PATH);
559
- const requiredReadmeSnippets = [
560
- 'GitHub Template',
561
- 'scripts/init-project.ps1',
562
- 'scripts/init-project.sh',
563
- 'npx @ryuenn3123/agentic-senior-core init',
564
- 'npm run validate',
565
- 'docs/faq.md',
566
- 'docs/deep-dive.md',
567
- 'docs/v2-upgrade-playbook.md',
568
- ];
569
-
570
- for (const requiredReadmeSnippet of requiredReadmeSnippets) {
571
- if (readmeContent.includes(requiredReadmeSnippet)) {
572
- pass(`README.md mentions ${requiredReadmeSnippet}`);
573
- } else {
574
- fail(`README.md must mention ${requiredReadmeSnippet}`);
575
- }
576
- }
577
- }
578
-
579
- async function validateMcpConfiguration() {
580
- console.log('\nChecking MCP configuration...');
581
-
582
- const mcpConfiguration = JSON.parse(await readTextFile(join(ROOT_DIR, 'mcp.json')));
583
- const lintServerCommand = mcpConfiguration.servers?.lint?.command;
584
- const testServerCommand = mcpConfiguration.servers?.test?.command;
585
-
586
- if (lintServerCommand === 'node') {
587
- pass('MCP lint server uses Node');
588
- } else {
589
- fail('MCP lint server must use Node');
590
- }
591
-
592
- if (testServerCommand === 'node') {
593
- pass('MCP test server uses Node');
594
- } else {
595
- fail('MCP test server must use Node');
596
- }
597
- }
598
-
599
- async function main() {
600
- console.log('===============================================');
601
- console.log(' Agentic-Senior-Core Repository Validator');
602
- console.log('===============================================');
603
-
604
- await validateRequiredFiles();
605
- await validateMarkdownFiles();
606
- await validateRuleFiles();
607
- await validateSkillTierQuality();
608
- await validateOverrideGovernance();
609
- await validateAgentsManifest();
610
- await validateCrossReferences();
611
- await validatePackageMetadata();
612
- await validatePolicyFile();
613
- await validateVersionConsistency();
614
- await validateDocumentationFlow();
615
- await validateMcpConfiguration();
616
-
617
- console.log('\n===============================================');
618
- console.log(' RESULTS');
619
- console.log('===============================================');
620
- console.log(` Passed: ${validationResult.passed}`);
621
- console.log(` Failed: ${validationResult.failed}`);
622
- console.log(` Warnings: ${validationResult.warnings.length}`);
623
- console.log('===============================================');
624
-
625
- if (validationResult.failed > 0) {
626
- console.log('\nVALIDATION FAILED\n');
627
- process.exit(1);
628
- }
629
-
630
- console.log('\nALL CHECKS PASSED\n');
631
- }
632
-
633
- main().catch((error) => {
634
- console.error('Validator crashed:', error);
635
- process.exit(1);
636
- });
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 { validateSkillTopicContent } from './skill-tier-policy.mjs';
20
+
21
+ const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
22
+ const ROOT_DIR = resolve(dirname(SCRIPT_FILE_PATH), '..');
23
+ const AGENT_CONTEXT_DIR = join(ROOT_DIR, '.agent-context');
24
+ const PACKAGE_JSON_PATH = join(ROOT_DIR, 'package.json');
25
+ const CHANGELOG_PATH = join(ROOT_DIR, 'CHANGELOG.md');
26
+ const README_PATH = join(ROOT_DIR, 'README.md');
27
+ const POLICY_FILE_PATH = join(ROOT_DIR, '.agent-context', 'policies', 'llm-judge-threshold.json');
28
+ const OVERRIDE_FILE_PATH = join(ROOT_DIR, '.agent-override.md');
29
+ const SKILLS_DIR = join(AGENT_CONTEXT_DIR, 'skills');
30
+ const GENERATED_RULE_FILES = ['.cursorrules', '.windsurfrules'];
31
+ const ALLOWED_SEVERITIES = new Set(['critical', 'high', 'medium', 'low']);
32
+ const OVERRIDE_WARNING_WINDOW_DAYS = 30;
33
+
34
+ const validationResult = {
35
+ passed: 0,
36
+ failed: 0,
37
+ errors: [],
38
+ warnings: [],
39
+ };
40
+
41
+ async function fileExists(filePath) {
42
+ try {
43
+ await stat(filePath);
44
+ return true;
45
+ } catch {
46
+ return false;
47
+ }
48
+ }
49
+
50
+ async function readTextFile(filePath) {
51
+ return readFile(filePath, 'utf8');
52
+ }
53
+
54
+ async function collectFiles(directoryPath, fileExtensionMatcher) {
55
+ const matchingFilePaths = [];
56
+
57
+ async function walk(currentDirectoryPath) {
58
+ const directoryEntries = await readdir(currentDirectoryPath, { withFileTypes: true });
59
+
60
+ for (const directoryEntry of directoryEntries) {
61
+ if (directoryEntry.name === '.git' || directoryEntry.name === 'node_modules') {
62
+ continue;
63
+ }
64
+
65
+ const entryPath = join(currentDirectoryPath, directoryEntry.name);
66
+
67
+ if (directoryEntry.isDirectory()) {
68
+ await walk(entryPath);
69
+ continue;
70
+ }
71
+
72
+ if (fileExtensionMatcher(directoryEntry.name)) {
73
+ matchingFilePaths.push(entryPath);
74
+ }
75
+ }
76
+ }
77
+
78
+ await walk(directoryPath);
79
+ return matchingFilePaths;
80
+ }
81
+
82
+ function pass(message) {
83
+ validationResult.passed += 1;
84
+ console.log(` PASS ${message}`);
85
+ }
86
+
87
+ function fail(message) {
88
+ validationResult.failed += 1;
89
+ validationResult.errors.push(message);
90
+ console.log(` FAIL ${message}`);
91
+ }
92
+
93
+ function warn(message) {
94
+ validationResult.warnings.push(message);
95
+ console.log(` WARN ${message}`);
96
+ }
97
+
98
+ async function validateRequiredFiles() {
99
+ console.log('\nChecking required files...');
100
+
101
+ const requiredFiles = [
102
+ 'bin/agentic-senior-core.js',
103
+ 'scripts/validate.mjs',
104
+ 'scripts/llm-judge.mjs',
105
+ 'scripts/detection-benchmark.mjs',
106
+ 'scripts/benchmark-gate.mjs',
107
+ 'scripts/benchmark-intelligence.mjs',
108
+ 'scripts/frontend-usability-audit.mjs',
109
+ 'scripts/release-gate.mjs',
110
+ 'scripts/generate-sbom.mjs',
111
+ 'scripts/init-project.sh',
112
+ 'scripts/init-project.ps1',
113
+ '.cursorrules',
114
+ '.windsurfrules',
115
+ '.agent-override.md',
116
+ '.agent-context/policies/llm-judge-threshold.json',
117
+ 'mcp.json',
118
+ 'AGENTS.md',
119
+ '.github/copilot-instructions.md',
120
+ '.gemini/instructions.md',
121
+ 'README.md',
122
+ 'CHANGELOG.md',
123
+ 'docs/faq.md',
124
+ 'docs/deep-dive.md',
125
+ 'docs/v1.7-execution-playbook.md',
126
+ 'docs/v1.7-issue-breakdown.md',
127
+ 'docs/v1.8-operations-playbook.md',
128
+ 'docs/v2-upgrade-playbook.md',
129
+ '.agent-context/state/benchmark-watchlist.json',
130
+ '.agent-context/state/skill-platform.json',
131
+ '.agent-context/skills/index.json',
132
+ '.github/workflows/release-gate.yml',
133
+ '.github/workflows/sbom-compliance.yml',
134
+ '.github/workflows/benchmark-intelligence.yml',
135
+ 'tests/cli-smoke.test.mjs',
136
+ 'tests/llm-judge.test.mjs',
137
+ 'tests/enterprise-ops.test.mjs',
138
+ 'LICENSE',
139
+ '.gitignore',
140
+ ];
141
+
142
+ for (const requiredFilePath of requiredFiles) {
143
+ const absoluteRequiredFilePath = join(ROOT_DIR, requiredFilePath);
144
+
145
+ if (await fileExists(absoluteRequiredFilePath)) {
146
+ pass(requiredFilePath);
147
+ continue;
148
+ }
149
+
150
+ fail(`Missing required file: ${requiredFilePath}`);
151
+ }
152
+ }
153
+
154
+ async function validateMarkdownFiles() {
155
+ console.log('\nChecking markdown content...');
156
+
157
+ const markdownFilePaths = await collectFiles(ROOT_DIR, (fileName) => fileName.endsWith('.md'));
158
+
159
+ for (const markdownFilePath of markdownFilePaths) {
160
+ const markdownContent = await readTextFile(markdownFilePath);
161
+ const relativeMarkdownPath = relative(ROOT_DIR, markdownFilePath);
162
+
163
+ if (markdownContent.trim().length === 0) {
164
+ fail(`Empty markdown file: ${relativeMarkdownPath}`);
165
+ continue;
166
+ }
167
+
168
+ pass(`${relativeMarkdownPath} (${markdownContent.length} chars)`);
169
+ }
170
+ }
171
+
172
+ async function validateRuleFiles() {
173
+ console.log('\nChecking rule, stack, blueprint, checklist, and state files...');
174
+
175
+ const expectedPaths = [
176
+ 'rules/naming-conv.md',
177
+ 'rules/architecture.md',
178
+ 'rules/security.md',
179
+ 'rules/performance.md',
180
+ 'rules/error-handling.md',
181
+ 'rules/testing.md',
182
+ 'rules/git-workflow.md',
183
+ 'rules/efficiency-vs-hype.md',
184
+ 'rules/api-docs.md',
185
+ 'rules/microservices.md',
186
+ 'rules/event-driven.md',
187
+ 'rules/database-design.md',
188
+ 'rules/realtime.md',
189
+ 'rules/frontend-architecture.md',
190
+ 'stacks/typescript.md',
191
+ 'stacks/python.md',
192
+ 'stacks/java.md',
193
+ 'stacks/php.md',
194
+ 'stacks/go.md',
195
+ 'stacks/csharp.md',
196
+ 'stacks/rust.md',
197
+ 'stacks/ruby.md',
198
+ 'blueprints/api-nextjs.md',
199
+ 'blueprints/nestjs-logic.md',
200
+ 'blueprints/fastapi-service.md',
201
+ 'blueprints/laravel-api.md',
202
+ 'blueprints/spring-boot-api.md',
203
+ 'blueprints/go-service.md',
204
+ 'blueprints/aspnet-api.md',
205
+ 'blueprints/ci-github-actions.md',
206
+ 'blueprints/ci-gitlab.md',
207
+ 'blueprints/observability.md',
208
+ 'blueprints/graphql-grpc-api.md',
209
+ 'blueprints/infrastructure-as-code.md',
210
+ 'blueprints/kubernetes-manifests.md',
211
+ 'profiles/startup.md',
212
+ 'profiles/regulated.md',
213
+ 'profiles/platform.md',
214
+ 'review-checklists/pr-checklist.md',
215
+ 'review-checklists/frontend-usability.md',
216
+ 'review-checklists/frontend-skill-parity.md',
217
+ 'review-checklists/release-operations.md',
218
+ 'review-checklists/security-audit.md',
219
+ 'review-checklists/performance-audit.md',
220
+ 'review-checklists/architecture-review.md',
221
+ 'skills/README.md',
222
+ 'skills/frontend/README.md',
223
+ 'skills/backend/README.md',
224
+ 'skills/fullstack/README.md',
225
+ 'skills/cli/README.md',
226
+ 'skills/distribution/README.md',
227
+ 'skills/review-quality/README.md',
228
+ 'skills/frontend.md',
229
+ 'skills/backend.md',
230
+ 'skills/fullstack.md',
231
+ 'skills/cli.md',
232
+ 'skills/distribution.md',
233
+ 'skills/review-quality.md',
234
+ 'state/architecture-map.md',
235
+ 'state/dependency-map.md',
236
+ ];
237
+
238
+ for (const expectedPath of expectedPaths) {
239
+ const absoluteExpectedPath = join(AGENT_CONTEXT_DIR, expectedPath);
240
+
241
+ if (!(await fileExists(absoluteExpectedPath))) {
242
+ fail(`Missing agent context file: .agent-context/${expectedPath}`);
243
+ continue;
244
+ }
245
+
246
+ const fileContent = await readTextFile(absoluteExpectedPath);
247
+ if (fileContent.trim().length < 100) {
248
+ fail(`Agent context file is suspiciously short: .agent-context/${expectedPath}`);
249
+ continue;
250
+ }
251
+
252
+ pass(`.agent-context/${expectedPath}`);
253
+ }
254
+ }
255
+
256
+ async function validateSkillTierQuality() {
257
+ console.log('\nChecking skill tier quality...');
258
+
259
+ const skillMarkdownFiles = await collectFiles(SKILLS_DIR, (fileName) => fileName.endsWith('.md'));
260
+ const scopedSkillTopicFiles = skillMarkdownFiles.filter((skillFilePath) => {
261
+ if (skillFilePath.endsWith('README.md')) {
262
+ return false;
263
+ }
264
+
265
+ const relativeSkillPath = relative(SKILLS_DIR, skillFilePath);
266
+ return /[\\/]/.test(relativeSkillPath);
267
+ });
268
+
269
+ for (const skillTopicPath of scopedSkillTopicFiles) {
270
+ const skillTopicContent = await readTextFile(skillTopicPath);
271
+ const relativeSkillTopicPath = relative(ROOT_DIR, skillTopicPath);
272
+ const validationResult = validateSkillTopicContent(skillTopicContent);
273
+
274
+ if (!validationResult.isValid) {
275
+ if (validationResult.reason === 'missing-tier') {
276
+ fail(`${relativeSkillTopicPath} is missing explicit Tier metadata`);
277
+ continue;
278
+ }
279
+
280
+ if (validationResult.reason === 'unsupported-tier') {
281
+ fail(`${relativeSkillTopicPath} has unsupported tier: ${validationResult.detectedTier}`);
282
+ continue;
283
+ }
284
+
285
+ if (validationResult.reason === 'word-count') {
286
+ fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minWords} words (found ${validationResult.wordCount})`);
287
+ continue;
288
+ }
289
+
290
+ if (validationResult.reason === 'heading-count') {
291
+ fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minHeadings} section headings (found ${validationResult.headingCount})`);
292
+ continue;
293
+ }
294
+
295
+ if (validationResult.reason === 'checklist-count') {
296
+ fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minChecklistItems} checklist item(s) (found ${validationResult.checklistCount})`);
297
+ continue;
298
+ }
299
+
300
+ if (validationResult.reason === 'code-block-count') {
301
+ fail(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} must include at least ${validationResult.minimumRules.minCodeBlocks} code block(s) (found ${validationResult.codeBlockCount})`);
302
+ continue;
303
+ }
304
+
305
+ fail(`${relativeSkillTopicPath} failed tier validation`);
306
+ continue;
307
+ }
308
+
309
+ pass(`${relativeSkillTopicPath} tier ${validationResult.detectedTier} quality gate passed`);
310
+ }
311
+ }
312
+
313
+ function stripMarkdownCodeBlocks(markdownText) {
314
+ return markdownText.replace(/```[\s\S]*?```/g, '');
315
+ }
316
+
317
+ function parseOverrideExpiryDate(rawExpiryValue) {
318
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(rawExpiryValue)) {
319
+ return null;
320
+ }
321
+
322
+ const parsedDate = new Date(`${rawExpiryValue}T00:00:00.000Z`);
323
+ return Number.isNaN(parsedDate.getTime()) ? null : parsedDate;
324
+ }
325
+
326
+ async function validateOverrideGovernance() {
327
+ console.log('\nChecking override governance...');
328
+
329
+ const overrideContent = await readTextFile(OVERRIDE_FILE_PATH);
330
+ const overrideContentWithoutCodeBlocks = stripMarkdownCodeBlocks(overrideContent);
331
+ const overrideEntryPattern = /\[Rule:\s*([^\]]+)\]([\s\S]*?)(?=\n\[Rule:|$)/g;
332
+ const overrideEntries = [];
333
+ let overrideEntryMatch = overrideEntryPattern.exec(overrideContentWithoutCodeBlocks);
334
+
335
+ while (overrideEntryMatch) {
336
+ const ruleName = overrideEntryMatch[1].trim();
337
+ const entryBody = overrideEntryMatch[2];
338
+ const ownerMatch = entryBody.match(/(?:^|\n)Owner:\s*(.+)/);
339
+ const expiryMatch = entryBody.match(/(?:^|\n)Expiry:\s*(.+)/);
340
+
341
+ overrideEntries.push({
342
+ ruleName,
343
+ owner: ownerMatch ? ownerMatch[1].trim() : '',
344
+ expiry: expiryMatch ? expiryMatch[1].trim() : '',
345
+ });
346
+
347
+ overrideEntryMatch = overrideEntryPattern.exec(overrideContentWithoutCodeBlocks);
348
+ }
349
+
350
+ if (overrideEntries.length === 0) {
351
+ pass('No active override entries found; governance baseline remains strict');
352
+ return;
353
+ }
354
+
355
+ const currentDate = new Date();
356
+
357
+ for (const overrideEntry of overrideEntries) {
358
+ const overrideContextLabel = `[Rule: ${overrideEntry.ruleName}]`;
359
+
360
+ if (!overrideEntry.owner) {
361
+ fail(`${overrideContextLabel} is missing Owner metadata`);
362
+ continue;
363
+ }
364
+
365
+ pass(`${overrideContextLabel} owner is defined`);
366
+
367
+ if (!overrideEntry.expiry) {
368
+ fail(`${overrideContextLabel} is missing Expiry metadata`);
369
+ continue;
370
+ }
371
+
372
+ const expiryDate = parseOverrideExpiryDate(overrideEntry.expiry);
373
+ if (!expiryDate) {
374
+ fail(`${overrideContextLabel} has invalid Expiry format (expected YYYY-MM-DD)`);
375
+ continue;
376
+ }
377
+
378
+ const remainingMilliseconds = expiryDate.getTime() - currentDate.getTime();
379
+ const remainingDays = Math.floor(remainingMilliseconds / (1000 * 60 * 60 * 24));
380
+
381
+ if (remainingMilliseconds < 0) {
382
+ fail(`${overrideContextLabel} is expired (${overrideEntry.expiry})`);
383
+ continue;
384
+ }
385
+
386
+ pass(`${overrideContextLabel} expiry is valid (${overrideEntry.expiry})`);
387
+
388
+ if (remainingDays <= OVERRIDE_WARNING_WINDOW_DAYS) {
389
+ warn(`${overrideContextLabel} expires in ${remainingDays} day(s); renew or remove soon`);
390
+ }
391
+ }
392
+ }
393
+
394
+ async function validateCrossReferences() {
395
+ console.log('\nChecking internal links...');
396
+
397
+ const markdownFilePaths = await collectFiles(ROOT_DIR, (fileName) => fileName.endsWith('.md'));
398
+ const linkPattern = /\[([^\]]*)\]\((?!https?:\/\/|#)([^)]+)\)/g;
399
+ let checkedLinkCount = 0;
400
+
401
+ for (const markdownFilePath of markdownFilePaths) {
402
+ const markdownContent = await readTextFile(markdownFilePath);
403
+ const currentFileDirectory = dirname(markdownFilePath);
404
+ const relativeMarkdownPath = relative(ROOT_DIR, markdownFilePath);
405
+ let linkMatch = linkPattern.exec(markdownContent);
406
+
407
+ while (linkMatch) {
408
+ const rawLinkTarget = linkMatch[2].split('#')[0];
409
+ if (rawLinkTarget) {
410
+ checkedLinkCount += 1;
411
+ const resolvedLinkPath = resolve(currentFileDirectory, rawLinkTarget);
412
+
413
+ if (await fileExists(resolvedLinkPath)) {
414
+ pass(`${relativeMarkdownPath} → ${linkMatch[2]}`);
415
+ } else {
416
+ fail(`Broken link in ${relativeMarkdownPath}: ${linkMatch[2]}`);
417
+ }
418
+ }
419
+
420
+ linkMatch = linkPattern.exec(markdownContent);
421
+ }
422
+ }
423
+
424
+ if (checkedLinkCount === 0) {
425
+ warn('No internal links were found in markdown files');
426
+ }
427
+ }
428
+
429
+ async function validateAgentsManifest() {
430
+ console.log('\nChecking AGENTS.md manifest links...');
431
+
432
+ const agentsContent = await readTextFile(join(ROOT_DIR, 'AGENTS.md'));
433
+ const fileReferencePattern = /\[`?([^`\]]+)`?\]\(([^)]+)\)/g;
434
+ let manifestLinkCount = 0;
435
+ let fileReferenceMatch = fileReferencePattern.exec(agentsContent);
436
+
437
+ while (fileReferenceMatch) {
438
+ const manifestLinkTarget = fileReferenceMatch[2];
439
+
440
+ if (!manifestLinkTarget.startsWith('http')) {
441
+ manifestLinkCount += 1;
442
+ const resolvedManifestLinkPath = resolve(ROOT_DIR, manifestLinkTarget);
443
+
444
+ if (await fileExists(resolvedManifestLinkPath)) {
445
+ pass(`AGENTS.md → ${manifestLinkTarget}`);
446
+ } else {
447
+ fail(`AGENTS.md references missing file: ${manifestLinkTarget}`);
448
+ }
449
+ }
450
+
451
+ fileReferenceMatch = fileReferencePattern.exec(agentsContent);
452
+ }
453
+
454
+ if (manifestLinkCount === 0) {
455
+ warn('AGENTS.md does not contain any local manifest links');
456
+ }
457
+ }
458
+
459
+ async function validatePackageMetadata() {
460
+ console.log('\nChecking package metadata...');
461
+
462
+ const packageJson = JSON.parse(await readTextFile(PACKAGE_JSON_PATH));
463
+ const versionPattern = /^\d+\.\d+\.\d+$/;
464
+
465
+ if (typeof packageJson.version !== 'string' || !versionPattern.test(packageJson.version)) {
466
+ fail('package.json version must be a semantic version string');
467
+ } else {
468
+ pass(`package.json version ${packageJson.version}`);
469
+ }
470
+
471
+ if (packageJson.scripts?.validate === 'node ./scripts/validate.mjs') {
472
+ pass('package.json validate script is Node-first');
473
+ } else {
474
+ fail('package.json validate script must use node ./scripts/validate.mjs');
475
+ }
476
+
477
+ if (packageJson.scripts?.test) {
478
+ pass('package.json test script exists');
479
+ } else {
480
+ fail('package.json test script is missing');
481
+ }
482
+
483
+ if (packageJson.devDependencies && Object.keys(packageJson.devDependencies).length > 0) {
484
+ warn('package.json still has devDependencies; review whether they are necessary');
485
+ } else {
486
+ pass('package.json has no unnecessary devDependencies');
487
+ }
488
+ }
489
+
490
+ async function validatePolicyFile() {
491
+ console.log('\nChecking LLM Judge policy...');
492
+
493
+ const policyContent = await readTextFile(POLICY_FILE_PATH);
494
+ const parsedPolicy = JSON.parse(policyContent);
495
+ const selectedProfileName = parsedPolicy.selectedProfile;
496
+ const profileThresholds = parsedPolicy.profileThresholds;
497
+
498
+ if (typeof selectedProfileName !== 'string') {
499
+ fail('Policy file must define selectedProfile as a string');
500
+ } else {
501
+ pass(`LLM Judge selected profile: ${selectedProfileName}`);
502
+ }
503
+
504
+ if (!profileThresholds || typeof profileThresholds !== 'object') {
505
+ fail('Policy file must define profileThresholds');
506
+ return;
507
+ }
508
+
509
+ for (const [profileName, profileSettings] of Object.entries(profileThresholds)) {
510
+ if (!Array.isArray(profileSettings.blockingSeverities)) {
511
+ fail(`Policy profile ${profileName} must define blockingSeverities`);
512
+ continue;
513
+ }
514
+
515
+ const invalidSeverity = profileSettings.blockingSeverities.find((severity) => !ALLOWED_SEVERITIES.has(severity));
516
+ if (invalidSeverity) {
517
+ fail(`Policy profile ${profileName} uses unsupported severity: ${invalidSeverity}`);
518
+ continue;
519
+ }
520
+
521
+ pass(`Policy profile ${profileName} blocking severities are valid`);
522
+ }
523
+
524
+ if (typeof profileThresholds[selectedProfileName] === 'object') {
525
+ pass('Policy selectedProfile points to a valid profile');
526
+ } else {
527
+ fail('Policy selectedProfile must match one of the configured profileThresholds');
528
+ }
529
+ }
530
+
531
+ async function validateVersionConsistency() {
532
+ console.log('\nChecking release version consistency...');
533
+
534
+ const packageJson = JSON.parse(await readTextFile(PACKAGE_JSON_PATH));
535
+ const packageVersion = packageJson.version;
536
+ const changelogContent = await readTextFile(CHANGELOG_PATH);
537
+
538
+ if (changelogContent.includes(`## ${packageVersion}`)) {
539
+ pass(`CHANGELOG.md contains release entry for ${packageVersion}`);
540
+ } else {
541
+ fail(`CHANGELOG.md is missing a ## ${packageVersion} heading`);
542
+ }
543
+
544
+ for (const generatedRuleFileName of GENERATED_RULE_FILES) {
545
+ const generatedRuleContent = await readTextFile(join(ROOT_DIR, generatedRuleFileName));
546
+
547
+ if (generatedRuleContent.includes(`Generated by Agentic-Senior-Core CLI v${packageVersion}`)) {
548
+ pass(`${generatedRuleFileName} matches package version ${packageVersion}`);
549
+ } else {
550
+ fail(`${generatedRuleFileName} does not match package version ${packageVersion}`);
551
+ }
552
+ }
553
+ }
554
+
555
+ async function validateDocumentationFlow() {
556
+ console.log('\nChecking documentation flow...');
557
+
558
+ const readmeContent = await readTextFile(README_PATH);
559
+ const requiredReadmeSnippets = [
560
+ 'GitHub Template',
561
+ 'scripts/init-project.ps1',
562
+ 'scripts/init-project.sh',
563
+ 'npx @ryuenn3123/agentic-senior-core init',
564
+ 'npm run validate',
565
+ 'docs/faq.md',
566
+ 'docs/deep-dive.md',
567
+ 'docs/v2-upgrade-playbook.md',
568
+ ];
569
+
570
+ for (const requiredReadmeSnippet of requiredReadmeSnippets) {
571
+ if (readmeContent.includes(requiredReadmeSnippet)) {
572
+ pass(`README.md mentions ${requiredReadmeSnippet}`);
573
+ } else {
574
+ fail(`README.md must mention ${requiredReadmeSnippet}`);
575
+ }
576
+ }
577
+ }
578
+
579
+ async function validateMcpConfiguration() {
580
+ console.log('\nChecking MCP configuration...');
581
+
582
+ const mcpConfiguration = JSON.parse(await readTextFile(join(ROOT_DIR, 'mcp.json')));
583
+ const lintServerCommand = mcpConfiguration.servers?.lint?.command;
584
+ const testServerCommand = mcpConfiguration.servers?.test?.command;
585
+
586
+ if (lintServerCommand === 'node') {
587
+ pass('MCP lint server uses Node');
588
+ } else {
589
+ fail('MCP lint server must use Node');
590
+ }
591
+
592
+ if (testServerCommand === 'node') {
593
+ pass('MCP test server uses Node');
594
+ } else {
595
+ fail('MCP test server must use Node');
596
+ }
597
+ }
598
+
599
+ async function main() {
600
+ console.log('===============================================');
601
+ console.log(' Agentic-Senior-Core Repository Validator');
602
+ console.log('===============================================');
603
+
604
+ await validateRequiredFiles();
605
+ await validateMarkdownFiles();
606
+ await validateRuleFiles();
607
+ await validateSkillTierQuality();
608
+ await validateOverrideGovernance();
609
+ await validateAgentsManifest();
610
+ await validateCrossReferences();
611
+ await validatePackageMetadata();
612
+ await validatePolicyFile();
613
+ await validateVersionConsistency();
614
+ await validateDocumentationFlow();
615
+ await validateMcpConfiguration();
616
+
617
+ console.log('\n===============================================');
618
+ console.log(' RESULTS');
619
+ console.log('===============================================');
620
+ console.log(` Passed: ${validationResult.passed}`);
621
+ console.log(` Failed: ${validationResult.failed}`);
622
+ console.log(` Warnings: ${validationResult.warnings.length}`);
623
+ console.log('===============================================');
624
+
625
+ if (validationResult.failed > 0) {
626
+ console.log('\nVALIDATION FAILED\n');
627
+ process.exit(1);
628
+ }
629
+
630
+ console.log('\nALL CHECKS PASSED\n');
631
+ }
632
+
633
+ main().catch((error) => {
634
+ console.error('Validator crashed:', error);
635
+ process.exit(1);
636
+ });