@ryuenn3123/agentic-senior-core 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent-context/blueprints/api-nextjs.md +184 -0
- package/.agent-context/blueprints/aspnet-api.md +247 -0
- package/.agent-context/blueprints/ci-github-actions.md +226 -0
- package/.agent-context/blueprints/ci-gitlab.md +200 -0
- package/.agent-context/blueprints/fastapi-service.md +210 -0
- package/.agent-context/blueprints/go-service.md +217 -0
- package/.agent-context/blueprints/graphql-grpc-api.md +51 -0
- package/.agent-context/blueprints/infrastructure-as-code.md +62 -0
- package/.agent-context/blueprints/kubernetes-manifests.md +76 -0
- package/.agent-context/blueprints/laravel-api.md +223 -0
- package/.agent-context/blueprints/nestjs-logic.md +247 -0
- package/.agent-context/blueprints/observability.md +227 -0
- package/.agent-context/blueprints/spring-boot-api.md +218 -0
- package/.agent-context/policies/llm-judge-threshold.json +20 -0
- package/.agent-context/profiles/platform.md +13 -0
- package/.agent-context/profiles/regulated.md +13 -0
- package/.agent-context/profiles/startup.md +13 -0
- package/.agent-context/prompts/init-project.md +86 -0
- package/.agent-context/prompts/refactor.md +45 -0
- package/.agent-context/prompts/review-code.md +47 -0
- package/.agent-context/review-checklists/architecture-review.md +70 -0
- package/.agent-context/review-checklists/frontend-usability.md +33 -0
- package/.agent-context/review-checklists/performance-audit.md +65 -0
- package/.agent-context/review-checklists/pr-checklist.md +97 -0
- package/.agent-context/review-checklists/release-operations.md +29 -0
- package/.agent-context/review-checklists/security-audit.md +113 -0
- package/.agent-context/rules/api-docs.md +186 -0
- package/.agent-context/rules/architecture.md +198 -0
- package/.agent-context/rules/database-design.md +202 -0
- package/.agent-context/rules/efficiency-vs-hype.md +143 -0
- package/.agent-context/rules/error-handling.md +234 -0
- package/.agent-context/rules/event-driven.md +226 -0
- package/.agent-context/rules/frontend-architecture.md +66 -0
- package/.agent-context/rules/git-workflow.md +200 -0
- package/.agent-context/rules/microservices.md +174 -0
- package/.agent-context/rules/naming-conv.md +141 -0
- package/.agent-context/rules/performance.md +168 -0
- package/.agent-context/rules/realtime.md +47 -0
- package/.agent-context/rules/security.md +195 -0
- package/.agent-context/rules/testing.md +178 -0
- package/.agent-context/stacks/csharp.md +149 -0
- package/.agent-context/stacks/go.md +181 -0
- package/.agent-context/stacks/java.md +135 -0
- package/.agent-context/stacks/php.md +178 -0
- package/.agent-context/stacks/python.md +153 -0
- package/.agent-context/stacks/ruby.md +80 -0
- package/.agent-context/stacks/rust.md +86 -0
- package/.agent-context/stacks/typescript.md +317 -0
- package/.agent-context/state/architecture-map.md +25 -0
- package/.agent-context/state/dependency-map.md +32 -0
- package/.agent-override.md +36 -0
- package/.agents/workflows/init-project.md +29 -0
- package/.agents/workflows/refactor.md +29 -0
- package/.agents/workflows/review-code.md +29 -0
- package/.cursorrules +140 -0
- package/.gemini/instructions.md +97 -0
- package/.github/ISSUE_TEMPLATE/v1.7-frontend-work-item.yml +54 -0
- package/.github/copilot-instructions.md +104 -0
- package/.github/workflows/benchmark-detection.yml +38 -0
- package/.github/workflows/frontend-usability-gate.yml +36 -0
- package/.github/workflows/release-gate.yml +32 -0
- package/.github/workflows/sbom-compliance.yml +32 -0
- package/.windsurfrules +106 -0
- package/AGENTS.md +131 -0
- package/CONTRIBUTING.md +136 -0
- package/LICENSE +21 -0
- package/README.md +239 -0
- package/bin/agentic-senior-core.js +1147 -0
- package/mcp.json +29 -0
- package/package.json +50 -0
- package/scripts/detection-benchmark.mjs +138 -0
- package/scripts/frontend-usability-audit.mjs +87 -0
- package/scripts/generate-sbom.mjs +61 -0
- package/scripts/init-project.ps1 +105 -0
- package/scripts/init-project.sh +131 -0
- package/scripts/llm-judge.mjs +664 -0
- package/scripts/release-gate.mjs +116 -0
- package/scripts/validate.mjs +554 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* release-gate.mjs
|
|
5
|
+
*
|
|
6
|
+
* Enterprise release gate for V1.8.
|
|
7
|
+
* Produces machine-readable output for CI and fails fast on missing release evidence.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
11
|
+
import { resolve, dirname } from 'node:path';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = dirname(__filename);
|
|
16
|
+
const REPOSITORY_ROOT = resolve(__dirname, '..');
|
|
17
|
+
|
|
18
|
+
const VERSION_PATTERN = /^\d+\.\d+\.\d+$/;
|
|
19
|
+
|
|
20
|
+
function readText(relativeFilePath) {
|
|
21
|
+
const absolutePath = resolve(REPOSITORY_ROOT, relativeFilePath);
|
|
22
|
+
if (!existsSync(absolutePath)) {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return readFileSync(absolutePath, 'utf8');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function pushResult(results, isPassed, checkName, details) {
|
|
30
|
+
results.push({
|
|
31
|
+
checkName,
|
|
32
|
+
passed: isPassed,
|
|
33
|
+
details,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function runReleaseGate() {
|
|
38
|
+
const results = [];
|
|
39
|
+
const packageJsonPath = 'package.json';
|
|
40
|
+
const changelogPath = 'CHANGELOG.md';
|
|
41
|
+
const roadmapPath = 'docs/roadmap.md';
|
|
42
|
+
|
|
43
|
+
const packageJsonContent = readText(packageJsonPath);
|
|
44
|
+
if (!packageJsonContent) {
|
|
45
|
+
pushResult(results, false, 'package-json-exists', `Missing ${packageJsonPath}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let packageManifest = null;
|
|
49
|
+
if (packageJsonContent) {
|
|
50
|
+
try {
|
|
51
|
+
packageManifest = JSON.parse(packageJsonContent);
|
|
52
|
+
pushResult(results, true, 'package-json-parse', 'package.json is valid JSON');
|
|
53
|
+
} catch (packageParseError) {
|
|
54
|
+
const parseMessage = packageParseError instanceof Error ? packageParseError.message : 'Unknown parse error';
|
|
55
|
+
pushResult(results, false, 'package-json-parse', `Cannot parse package.json: ${parseMessage}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const releaseVersion = packageManifest?.version;
|
|
60
|
+
if (!releaseVersion || !VERSION_PATTERN.test(releaseVersion)) {
|
|
61
|
+
pushResult(results, false, 'version-semver', `Invalid package version: ${String(releaseVersion)}`);
|
|
62
|
+
} else {
|
|
63
|
+
pushResult(results, true, 'version-semver', `Version ${releaseVersion} matches x.y.z format`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const changelogContent = readText(changelogPath);
|
|
67
|
+
if (!changelogContent) {
|
|
68
|
+
pushResult(results, false, 'changelog-exists', `Missing ${changelogPath}`);
|
|
69
|
+
} else if (!releaseVersion) {
|
|
70
|
+
pushResult(results, false, 'changelog-version-entry', 'Cannot check changelog because version is invalid');
|
|
71
|
+
} else if (!changelogContent.includes(`## ${releaseVersion} - `)) {
|
|
72
|
+
pushResult(results, false, 'changelog-version-entry', `Missing release header for ${releaseVersion} in CHANGELOG.md`);
|
|
73
|
+
} else {
|
|
74
|
+
pushResult(results, true, 'changelog-version-entry', `Found release header for ${releaseVersion}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const roadmapContent = readText(roadmapPath);
|
|
78
|
+
if (!roadmapContent) {
|
|
79
|
+
pushResult(results, false, 'roadmap-exists', `Missing ${roadmapPath}`);
|
|
80
|
+
} else if (!roadmapContent.includes('V1.8')) {
|
|
81
|
+
pushResult(results, false, 'roadmap-v18', 'Roadmap does not mention V1.8 release track');
|
|
82
|
+
} else {
|
|
83
|
+
pushResult(results, true, 'roadmap-v18', 'Roadmap includes V1.8 release track');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const requiredEnterpriseFiles = [
|
|
87
|
+
'.agent-context/review-checklists/release-operations.md',
|
|
88
|
+
'docs/v1.8-operations-playbook.md',
|
|
89
|
+
'.github/workflows/release-gate.yml',
|
|
90
|
+
'.github/workflows/sbom-compliance.yml',
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
for (const requiredEnterpriseFile of requiredEnterpriseFiles) {
|
|
94
|
+
const absoluteRequiredPath = resolve(REPOSITORY_ROOT, requiredEnterpriseFile);
|
|
95
|
+
if (!existsSync(absoluteRequiredPath)) {
|
|
96
|
+
pushResult(results, false, 'required-enterprise-file', `Missing ${requiredEnterpriseFile}`);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
pushResult(results, true, 'required-enterprise-file', `${requiredEnterpriseFile} is present`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const failureCount = results.filter((checkResult) => !checkResult.passed).length;
|
|
104
|
+
const releaseGateReport = {
|
|
105
|
+
generatedAt: new Date().toISOString(),
|
|
106
|
+
gateName: 'release-gate',
|
|
107
|
+
passed: failureCount === 0,
|
|
108
|
+
failureCount,
|
|
109
|
+
results,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
console.log(JSON.stringify(releaseGateReport, null, 2));
|
|
113
|
+
process.exit(releaseGateReport.passed ? 0 : 1);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
runReleaseGate();
|
|
@@ -0,0 +1,554 @@
|
|
|
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
|
+
|
|
20
|
+
const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
|
|
21
|
+
const ROOT_DIR = resolve(dirname(SCRIPT_FILE_PATH), '..');
|
|
22
|
+
const AGENT_CONTEXT_DIR = join(ROOT_DIR, '.agent-context');
|
|
23
|
+
const PACKAGE_JSON_PATH = join(ROOT_DIR, 'package.json');
|
|
24
|
+
const CHANGELOG_PATH = join(ROOT_DIR, 'CHANGELOG.md');
|
|
25
|
+
const README_PATH = join(ROOT_DIR, 'README.md');
|
|
26
|
+
const POLICY_FILE_PATH = join(ROOT_DIR, '.agent-context', 'policies', 'llm-judge-threshold.json');
|
|
27
|
+
const OVERRIDE_FILE_PATH = join(ROOT_DIR, '.agent-override.md');
|
|
28
|
+
const GENERATED_RULE_FILES = ['.cursorrules', '.windsurfrules'];
|
|
29
|
+
const ALLOWED_SEVERITIES = new Set(['critical', 'high', 'medium', 'low']);
|
|
30
|
+
const OVERRIDE_WARNING_WINDOW_DAYS = 30;
|
|
31
|
+
|
|
32
|
+
const validationResult = {
|
|
33
|
+
passed: 0,
|
|
34
|
+
failed: 0,
|
|
35
|
+
errors: [],
|
|
36
|
+
warnings: [],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
async function fileExists(filePath) {
|
|
40
|
+
try {
|
|
41
|
+
await stat(filePath);
|
|
42
|
+
return true;
|
|
43
|
+
} catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function readTextFile(filePath) {
|
|
49
|
+
return readFile(filePath, 'utf8');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function collectFiles(directoryPath, fileExtensionMatcher) {
|
|
53
|
+
const matchingFilePaths = [];
|
|
54
|
+
|
|
55
|
+
async function walk(currentDirectoryPath) {
|
|
56
|
+
const directoryEntries = await readdir(currentDirectoryPath, { withFileTypes: true });
|
|
57
|
+
|
|
58
|
+
for (const directoryEntry of directoryEntries) {
|
|
59
|
+
if (directoryEntry.name === '.git' || directoryEntry.name === 'node_modules') {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const entryPath = join(currentDirectoryPath, directoryEntry.name);
|
|
64
|
+
|
|
65
|
+
if (directoryEntry.isDirectory()) {
|
|
66
|
+
await walk(entryPath);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (fileExtensionMatcher(directoryEntry.name)) {
|
|
71
|
+
matchingFilePaths.push(entryPath);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
await walk(directoryPath);
|
|
77
|
+
return matchingFilePaths;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function pass(message) {
|
|
81
|
+
validationResult.passed += 1;
|
|
82
|
+
console.log(` PASS ${message}`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function fail(message) {
|
|
86
|
+
validationResult.failed += 1;
|
|
87
|
+
validationResult.errors.push(message);
|
|
88
|
+
console.log(` FAIL ${message}`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function warn(message) {
|
|
92
|
+
validationResult.warnings.push(message);
|
|
93
|
+
console.log(` WARN ${message}`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function validateRequiredFiles() {
|
|
97
|
+
console.log('\nChecking required files...');
|
|
98
|
+
|
|
99
|
+
const requiredFiles = [
|
|
100
|
+
'bin/agentic-senior-core.js',
|
|
101
|
+
'scripts/validate.mjs',
|
|
102
|
+
'scripts/llm-judge.mjs',
|
|
103
|
+
'scripts/detection-benchmark.mjs',
|
|
104
|
+
'scripts/frontend-usability-audit.mjs',
|
|
105
|
+
'scripts/release-gate.mjs',
|
|
106
|
+
'scripts/generate-sbom.mjs',
|
|
107
|
+
'scripts/init-project.sh',
|
|
108
|
+
'scripts/init-project.ps1',
|
|
109
|
+
'.cursorrules',
|
|
110
|
+
'.windsurfrules',
|
|
111
|
+
'.agent-override.md',
|
|
112
|
+
'.agent-context/policies/llm-judge-threshold.json',
|
|
113
|
+
'mcp.json',
|
|
114
|
+
'AGENTS.md',
|
|
115
|
+
'.github/copilot-instructions.md',
|
|
116
|
+
'.gemini/instructions.md',
|
|
117
|
+
'README.md',
|
|
118
|
+
'CHANGELOG.md',
|
|
119
|
+
'docs/faq.md',
|
|
120
|
+
'docs/deep-dive.md',
|
|
121
|
+
'docs/v1.7-execution-playbook.md',
|
|
122
|
+
'docs/v1.7-issue-breakdown.md',
|
|
123
|
+
'docs/v1.8-operations-playbook.md',
|
|
124
|
+
'.github/workflows/release-gate.yml',
|
|
125
|
+
'.github/workflows/sbom-compliance.yml',
|
|
126
|
+
'tests/cli-smoke.test.mjs',
|
|
127
|
+
'tests/llm-judge.test.mjs',
|
|
128
|
+
'tests/enterprise-ops.test.mjs',
|
|
129
|
+
'LICENSE',
|
|
130
|
+
'.gitignore',
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
for (const requiredFilePath of requiredFiles) {
|
|
134
|
+
const absoluteRequiredFilePath = join(ROOT_DIR, requiredFilePath);
|
|
135
|
+
|
|
136
|
+
if (await fileExists(absoluteRequiredFilePath)) {
|
|
137
|
+
pass(requiredFilePath);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
fail(`Missing required file: ${requiredFilePath}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function validateMarkdownFiles() {
|
|
146
|
+
console.log('\nChecking markdown content...');
|
|
147
|
+
|
|
148
|
+
const markdownFilePaths = await collectFiles(ROOT_DIR, (fileName) => fileName.endsWith('.md'));
|
|
149
|
+
|
|
150
|
+
for (const markdownFilePath of markdownFilePaths) {
|
|
151
|
+
const markdownContent = await readTextFile(markdownFilePath);
|
|
152
|
+
const relativeMarkdownPath = relative(ROOT_DIR, markdownFilePath);
|
|
153
|
+
|
|
154
|
+
if (markdownContent.trim().length === 0) {
|
|
155
|
+
fail(`Empty markdown file: ${relativeMarkdownPath}`);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
pass(`${relativeMarkdownPath} (${markdownContent.length} chars)`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async function validateRuleFiles() {
|
|
164
|
+
console.log('\nChecking rule, stack, blueprint, checklist, and state files...');
|
|
165
|
+
|
|
166
|
+
const expectedPaths = [
|
|
167
|
+
'rules/naming-conv.md',
|
|
168
|
+
'rules/architecture.md',
|
|
169
|
+
'rules/security.md',
|
|
170
|
+
'rules/performance.md',
|
|
171
|
+
'rules/error-handling.md',
|
|
172
|
+
'rules/testing.md',
|
|
173
|
+
'rules/git-workflow.md',
|
|
174
|
+
'rules/efficiency-vs-hype.md',
|
|
175
|
+
'rules/api-docs.md',
|
|
176
|
+
'rules/microservices.md',
|
|
177
|
+
'rules/event-driven.md',
|
|
178
|
+
'rules/database-design.md',
|
|
179
|
+
'rules/realtime.md',
|
|
180
|
+
'rules/frontend-architecture.md',
|
|
181
|
+
'stacks/typescript.md',
|
|
182
|
+
'stacks/python.md',
|
|
183
|
+
'stacks/java.md',
|
|
184
|
+
'stacks/php.md',
|
|
185
|
+
'stacks/go.md',
|
|
186
|
+
'stacks/csharp.md',
|
|
187
|
+
'stacks/rust.md',
|
|
188
|
+
'stacks/ruby.md',
|
|
189
|
+
'blueprints/api-nextjs.md',
|
|
190
|
+
'blueprints/nestjs-logic.md',
|
|
191
|
+
'blueprints/fastapi-service.md',
|
|
192
|
+
'blueprints/laravel-api.md',
|
|
193
|
+
'blueprints/spring-boot-api.md',
|
|
194
|
+
'blueprints/go-service.md',
|
|
195
|
+
'blueprints/aspnet-api.md',
|
|
196
|
+
'blueprints/ci-github-actions.md',
|
|
197
|
+
'blueprints/ci-gitlab.md',
|
|
198
|
+
'blueprints/observability.md',
|
|
199
|
+
'blueprints/graphql-grpc-api.md',
|
|
200
|
+
'blueprints/infrastructure-as-code.md',
|
|
201
|
+
'blueprints/kubernetes-manifests.md',
|
|
202
|
+
'profiles/startup.md',
|
|
203
|
+
'profiles/regulated.md',
|
|
204
|
+
'profiles/platform.md',
|
|
205
|
+
'review-checklists/pr-checklist.md',
|
|
206
|
+
'review-checklists/frontend-usability.md',
|
|
207
|
+
'review-checklists/release-operations.md',
|
|
208
|
+
'review-checklists/security-audit.md',
|
|
209
|
+
'review-checklists/performance-audit.md',
|
|
210
|
+
'review-checklists/architecture-review.md',
|
|
211
|
+
'state/architecture-map.md',
|
|
212
|
+
'state/dependency-map.md',
|
|
213
|
+
];
|
|
214
|
+
|
|
215
|
+
for (const expectedPath of expectedPaths) {
|
|
216
|
+
const absoluteExpectedPath = join(AGENT_CONTEXT_DIR, expectedPath);
|
|
217
|
+
|
|
218
|
+
if (!(await fileExists(absoluteExpectedPath))) {
|
|
219
|
+
fail(`Missing agent context file: .agent-context/${expectedPath}`);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const fileContent = await readTextFile(absoluteExpectedPath);
|
|
224
|
+
if (fileContent.trim().length < 100) {
|
|
225
|
+
fail(`Agent context file is suspiciously short: .agent-context/${expectedPath}`);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
pass(`.agent-context/${expectedPath}`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function stripMarkdownCodeBlocks(markdownText) {
|
|
234
|
+
return markdownText.replace(/```[\s\S]*?```/g, '');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function parseOverrideExpiryDate(rawExpiryValue) {
|
|
238
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(rawExpiryValue)) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const parsedDate = new Date(`${rawExpiryValue}T00:00:00.000Z`);
|
|
243
|
+
return Number.isNaN(parsedDate.getTime()) ? null : parsedDate;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
async function validateOverrideGovernance() {
|
|
247
|
+
console.log('\nChecking override governance...');
|
|
248
|
+
|
|
249
|
+
const overrideContent = await readTextFile(OVERRIDE_FILE_PATH);
|
|
250
|
+
const overrideContentWithoutCodeBlocks = stripMarkdownCodeBlocks(overrideContent);
|
|
251
|
+
const overrideEntryPattern = /\[Rule:\s*([^\]]+)\]([\s\S]*?)(?=\n\[Rule:|$)/g;
|
|
252
|
+
const overrideEntries = [];
|
|
253
|
+
let overrideEntryMatch = overrideEntryPattern.exec(overrideContentWithoutCodeBlocks);
|
|
254
|
+
|
|
255
|
+
while (overrideEntryMatch) {
|
|
256
|
+
const ruleName = overrideEntryMatch[1].trim();
|
|
257
|
+
const entryBody = overrideEntryMatch[2];
|
|
258
|
+
const ownerMatch = entryBody.match(/(?:^|\n)Owner:\s*(.+)/);
|
|
259
|
+
const expiryMatch = entryBody.match(/(?:^|\n)Expiry:\s*(.+)/);
|
|
260
|
+
|
|
261
|
+
overrideEntries.push({
|
|
262
|
+
ruleName,
|
|
263
|
+
owner: ownerMatch ? ownerMatch[1].trim() : '',
|
|
264
|
+
expiry: expiryMatch ? expiryMatch[1].trim() : '',
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
overrideEntryMatch = overrideEntryPattern.exec(overrideContentWithoutCodeBlocks);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (overrideEntries.length === 0) {
|
|
271
|
+
pass('No active override entries found; governance baseline remains strict');
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const currentDate = new Date();
|
|
276
|
+
|
|
277
|
+
for (const overrideEntry of overrideEntries) {
|
|
278
|
+
const overrideContextLabel = `[Rule: ${overrideEntry.ruleName}]`;
|
|
279
|
+
|
|
280
|
+
if (!overrideEntry.owner) {
|
|
281
|
+
fail(`${overrideContextLabel} is missing Owner metadata`);
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
pass(`${overrideContextLabel} owner is defined`);
|
|
286
|
+
|
|
287
|
+
if (!overrideEntry.expiry) {
|
|
288
|
+
fail(`${overrideContextLabel} is missing Expiry metadata`);
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const expiryDate = parseOverrideExpiryDate(overrideEntry.expiry);
|
|
293
|
+
if (!expiryDate) {
|
|
294
|
+
fail(`${overrideContextLabel} has invalid Expiry format (expected YYYY-MM-DD)`);
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const remainingMilliseconds = expiryDate.getTime() - currentDate.getTime();
|
|
299
|
+
const remainingDays = Math.floor(remainingMilliseconds / (1000 * 60 * 60 * 24));
|
|
300
|
+
|
|
301
|
+
if (remainingMilliseconds < 0) {
|
|
302
|
+
fail(`${overrideContextLabel} is expired (${overrideEntry.expiry})`);
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
pass(`${overrideContextLabel} expiry is valid (${overrideEntry.expiry})`);
|
|
307
|
+
|
|
308
|
+
if (remainingDays <= OVERRIDE_WARNING_WINDOW_DAYS) {
|
|
309
|
+
warn(`${overrideContextLabel} expires in ${remainingDays} day(s); renew or remove soon`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
async function validateCrossReferences() {
|
|
315
|
+
console.log('\nChecking internal links...');
|
|
316
|
+
|
|
317
|
+
const markdownFilePaths = await collectFiles(ROOT_DIR, (fileName) => fileName.endsWith('.md'));
|
|
318
|
+
const linkPattern = /\[([^\]]*)\]\((?!https?:\/\/|#)([^)]+)\)/g;
|
|
319
|
+
let checkedLinkCount = 0;
|
|
320
|
+
|
|
321
|
+
for (const markdownFilePath of markdownFilePaths) {
|
|
322
|
+
const markdownContent = await readTextFile(markdownFilePath);
|
|
323
|
+
const currentFileDirectory = dirname(markdownFilePath);
|
|
324
|
+
const relativeMarkdownPath = relative(ROOT_DIR, markdownFilePath);
|
|
325
|
+
let linkMatch = linkPattern.exec(markdownContent);
|
|
326
|
+
|
|
327
|
+
while (linkMatch) {
|
|
328
|
+
const rawLinkTarget = linkMatch[2].split('#')[0];
|
|
329
|
+
if (rawLinkTarget) {
|
|
330
|
+
checkedLinkCount += 1;
|
|
331
|
+
const resolvedLinkPath = resolve(currentFileDirectory, rawLinkTarget);
|
|
332
|
+
|
|
333
|
+
if (await fileExists(resolvedLinkPath)) {
|
|
334
|
+
pass(`${relativeMarkdownPath} → ${linkMatch[2]}`);
|
|
335
|
+
} else {
|
|
336
|
+
fail(`Broken link in ${relativeMarkdownPath}: ${linkMatch[2]}`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
linkMatch = linkPattern.exec(markdownContent);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (checkedLinkCount === 0) {
|
|
345
|
+
warn('No internal links were found in markdown files');
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
async function validateAgentsManifest() {
|
|
350
|
+
console.log('\nChecking AGENTS.md manifest links...');
|
|
351
|
+
|
|
352
|
+
const agentsContent = await readTextFile(join(ROOT_DIR, 'AGENTS.md'));
|
|
353
|
+
const fileReferencePattern = /\[`?([^`\]]+)`?\]\(([^)]+)\)/g;
|
|
354
|
+
let manifestLinkCount = 0;
|
|
355
|
+
let fileReferenceMatch = fileReferencePattern.exec(agentsContent);
|
|
356
|
+
|
|
357
|
+
while (fileReferenceMatch) {
|
|
358
|
+
const manifestLinkTarget = fileReferenceMatch[2];
|
|
359
|
+
|
|
360
|
+
if (!manifestLinkTarget.startsWith('http')) {
|
|
361
|
+
manifestLinkCount += 1;
|
|
362
|
+
const resolvedManifestLinkPath = resolve(ROOT_DIR, manifestLinkTarget);
|
|
363
|
+
|
|
364
|
+
if (await fileExists(resolvedManifestLinkPath)) {
|
|
365
|
+
pass(`AGENTS.md → ${manifestLinkTarget}`);
|
|
366
|
+
} else {
|
|
367
|
+
fail(`AGENTS.md references missing file: ${manifestLinkTarget}`);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
fileReferenceMatch = fileReferencePattern.exec(agentsContent);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (manifestLinkCount === 0) {
|
|
375
|
+
warn('AGENTS.md does not contain any local manifest links');
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
async function validatePackageMetadata() {
|
|
380
|
+
console.log('\nChecking package metadata...');
|
|
381
|
+
|
|
382
|
+
const packageJson = JSON.parse(await readTextFile(PACKAGE_JSON_PATH));
|
|
383
|
+
const versionPattern = /^\d+\.\d+\.\d+$/;
|
|
384
|
+
|
|
385
|
+
if (typeof packageJson.version !== 'string' || !versionPattern.test(packageJson.version)) {
|
|
386
|
+
fail('package.json version must be a semantic version string');
|
|
387
|
+
} else {
|
|
388
|
+
pass(`package.json version ${packageJson.version}`);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (packageJson.scripts?.validate === 'node ./scripts/validate.mjs') {
|
|
392
|
+
pass('package.json validate script is Node-first');
|
|
393
|
+
} else {
|
|
394
|
+
fail('package.json validate script must use node ./scripts/validate.mjs');
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if (packageJson.scripts?.test) {
|
|
398
|
+
pass('package.json test script exists');
|
|
399
|
+
} else {
|
|
400
|
+
fail('package.json test script is missing');
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (packageJson.devDependencies && Object.keys(packageJson.devDependencies).length > 0) {
|
|
404
|
+
warn('package.json still has devDependencies; review whether they are necessary');
|
|
405
|
+
} else {
|
|
406
|
+
pass('package.json has no unnecessary devDependencies');
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
async function validatePolicyFile() {
|
|
411
|
+
console.log('\nChecking LLM Judge policy...');
|
|
412
|
+
|
|
413
|
+
const policyContent = await readTextFile(POLICY_FILE_PATH);
|
|
414
|
+
const parsedPolicy = JSON.parse(policyContent);
|
|
415
|
+
const selectedProfileName = parsedPolicy.selectedProfile;
|
|
416
|
+
const profileThresholds = parsedPolicy.profileThresholds;
|
|
417
|
+
|
|
418
|
+
if (typeof selectedProfileName !== 'string') {
|
|
419
|
+
fail('Policy file must define selectedProfile as a string');
|
|
420
|
+
} else {
|
|
421
|
+
pass(`LLM Judge selected profile: ${selectedProfileName}`);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if (!profileThresholds || typeof profileThresholds !== 'object') {
|
|
425
|
+
fail('Policy file must define profileThresholds');
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
for (const [profileName, profileSettings] of Object.entries(profileThresholds)) {
|
|
430
|
+
if (!Array.isArray(profileSettings.blockingSeverities)) {
|
|
431
|
+
fail(`Policy profile ${profileName} must define blockingSeverities`);
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const invalidSeverity = profileSettings.blockingSeverities.find((severity) => !ALLOWED_SEVERITIES.has(severity));
|
|
436
|
+
if (invalidSeverity) {
|
|
437
|
+
fail(`Policy profile ${profileName} uses unsupported severity: ${invalidSeverity}`);
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
pass(`Policy profile ${profileName} blocking severities are valid`);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
if (typeof profileThresholds[selectedProfileName] === 'object') {
|
|
445
|
+
pass('Policy selectedProfile points to a valid profile');
|
|
446
|
+
} else {
|
|
447
|
+
fail('Policy selectedProfile must match one of the configured profileThresholds');
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
async function validateVersionConsistency() {
|
|
452
|
+
console.log('\nChecking release version consistency...');
|
|
453
|
+
|
|
454
|
+
const packageJson = JSON.parse(await readTextFile(PACKAGE_JSON_PATH));
|
|
455
|
+
const packageVersion = packageJson.version;
|
|
456
|
+
const changelogContent = await readTextFile(CHANGELOG_PATH);
|
|
457
|
+
|
|
458
|
+
if (changelogContent.includes(`## ${packageVersion}`)) {
|
|
459
|
+
pass(`CHANGELOG.md contains release entry for ${packageVersion}`);
|
|
460
|
+
} else {
|
|
461
|
+
fail(`CHANGELOG.md is missing a ## ${packageVersion} heading`);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
for (const generatedRuleFileName of GENERATED_RULE_FILES) {
|
|
465
|
+
const generatedRuleContent = await readTextFile(join(ROOT_DIR, generatedRuleFileName));
|
|
466
|
+
|
|
467
|
+
if (generatedRuleContent.includes(`Generated by Agentic-Senior-Core CLI v${packageVersion}`)) {
|
|
468
|
+
pass(`${generatedRuleFileName} matches package version ${packageVersion}`);
|
|
469
|
+
} else {
|
|
470
|
+
fail(`${generatedRuleFileName} does not match package version ${packageVersion}`);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
async function validateDocumentationFlow() {
|
|
476
|
+
console.log('\nChecking documentation flow...');
|
|
477
|
+
|
|
478
|
+
const readmeContent = await readTextFile(README_PATH);
|
|
479
|
+
const requiredReadmeSnippets = [
|
|
480
|
+
'GitHub Template',
|
|
481
|
+
'scripts/init-project.ps1',
|
|
482
|
+
'scripts/init-project.sh',
|
|
483
|
+
'npx @fatidaprilian/agentic-senior-core init',
|
|
484
|
+
'npm run validate',
|
|
485
|
+
'docs/faq.md',
|
|
486
|
+
'docs/deep-dive.md',
|
|
487
|
+
];
|
|
488
|
+
|
|
489
|
+
for (const requiredReadmeSnippet of requiredReadmeSnippets) {
|
|
490
|
+
if (readmeContent.includes(requiredReadmeSnippet)) {
|
|
491
|
+
pass(`README.md mentions ${requiredReadmeSnippet}`);
|
|
492
|
+
} else {
|
|
493
|
+
fail(`README.md must mention ${requiredReadmeSnippet}`);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
async function validateMcpConfiguration() {
|
|
499
|
+
console.log('\nChecking MCP configuration...');
|
|
500
|
+
|
|
501
|
+
const mcpConfiguration = JSON.parse(await readTextFile(join(ROOT_DIR, 'mcp.json')));
|
|
502
|
+
const lintServerCommand = mcpConfiguration.servers?.lint?.command;
|
|
503
|
+
const testServerCommand = mcpConfiguration.servers?.test?.command;
|
|
504
|
+
|
|
505
|
+
if (lintServerCommand === 'node') {
|
|
506
|
+
pass('MCP lint server uses Node');
|
|
507
|
+
} else {
|
|
508
|
+
fail('MCP lint server must use Node');
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if (testServerCommand === 'node') {
|
|
512
|
+
pass('MCP test server uses Node');
|
|
513
|
+
} else {
|
|
514
|
+
fail('MCP test server must use Node');
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
async function main() {
|
|
519
|
+
console.log('===============================================');
|
|
520
|
+
console.log(' Agentic-Senior-Core Repository Validator');
|
|
521
|
+
console.log('===============================================');
|
|
522
|
+
|
|
523
|
+
await validateRequiredFiles();
|
|
524
|
+
await validateMarkdownFiles();
|
|
525
|
+
await validateRuleFiles();
|
|
526
|
+
await validateOverrideGovernance();
|
|
527
|
+
await validateAgentsManifest();
|
|
528
|
+
await validateCrossReferences();
|
|
529
|
+
await validatePackageMetadata();
|
|
530
|
+
await validatePolicyFile();
|
|
531
|
+
await validateVersionConsistency();
|
|
532
|
+
await validateDocumentationFlow();
|
|
533
|
+
await validateMcpConfiguration();
|
|
534
|
+
|
|
535
|
+
console.log('\n===============================================');
|
|
536
|
+
console.log(' RESULTS');
|
|
537
|
+
console.log('===============================================');
|
|
538
|
+
console.log(` Passed: ${validationResult.passed}`);
|
|
539
|
+
console.log(` Failed: ${validationResult.failed}`);
|
|
540
|
+
console.log(` Warnings: ${validationResult.warnings.length}`);
|
|
541
|
+
console.log('===============================================');
|
|
542
|
+
|
|
543
|
+
if (validationResult.failed > 0) {
|
|
544
|
+
console.log('\nVALIDATION FAILED\n');
|
|
545
|
+
process.exit(1);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
console.log('\nALL CHECKS PASSED\n');
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
main().catch((error) => {
|
|
552
|
+
console.error('Validator crashed:', error);
|
|
553
|
+
process.exit(1);
|
|
554
|
+
});
|