@ryuenn3123/agentic-senior-core 4.4.0 → 5.2.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/.agents/plugins/agentic-senior-core/plugin.json +3 -0
- package/.agents/plugins/agentic-senior-core/rules/agentic-senior-core.md +131 -0
- package/.agents/plugins/agentic-senior-core/skills/asc/SKILL.md +16 -0
- package/.agents/plugins/agentic-senior-core/skills/asc-audit/SKILL.md +28 -0
- package/.agents/plugins/agentic-senior-core/skills/asc-refactor/SKILL.md +35 -0
- package/.agents/plugins/agentic-senior-core/skills/asc-review/SKILL.md +54 -0
- package/.agents/rules/agentic-senior-core.md +131 -0
- package/.claude-plugin/marketplace.json +17 -0
- package/.claude-plugin/plugin.json +17 -0
- package/.clinerules/agentic-senior-core.md +94 -0
- package/.codex-plugin/plugin.json +24 -0
- package/.cursor/rules/agentic-senior-core.mdc +99 -0
- package/.devin-plugin/plugin.json +13 -0
- package/.github/copilot-instructions.md +94 -0
- package/.github/plugin/marketplace.json +20 -0
- package/.github/plugin/plugin.json +16 -0
- package/.kiro/steering/agentic-senior-core.md +94 -0
- package/.openclaw/skills/asc/SKILL.md +23 -0
- package/.openclaw/skills/asc-audit/SKILL.md +28 -0
- package/.openclaw/skills/asc-review/SKILL.md +54 -0
- package/.opencode/plugins/agentic-senior-core.mjs +31 -0
- package/.windsurf/rules/agentic-senior-core.md +94 -0
- package/AGENTS.md +126 -127
- package/CONTRIBUTING.md +93 -63
- package/README.md +190 -110
- package/__init__.py +61 -0
- package/bin/agentic-senior-core.js +42 -41
- package/commands/asc-audit.md +1 -0
- package/commands/asc-audit.toml +2 -0
- package/commands/asc-help.md +9 -0
- package/commands/asc-help.toml +2 -0
- package/commands/asc-refactor.md +1 -0
- package/commands/asc-refactor.toml +2 -0
- package/commands/asc-review.md +1 -0
- package/commands/asc-review.toml +2 -0
- package/gemini-extension.json +10 -0
- package/hooks/copilot-hooks.json +21 -0
- package/hooks/hooks.json +31 -0
- package/hooks/session-start.js +36 -0
- package/hooks/subagent-start.js +38 -0
- package/lib/cli/commands/adapter.mjs +109 -0
- package/lib/cli/commands/clean.mjs +63 -0
- package/lib/cli/commands/status.mjs +94 -0
- package/package.json +43 -60
- package/plugin.yaml +16 -0
- package/scripts/uninstall.js +38 -0
- package/skills/asc/SKILL.md +16 -0
- package/skills/asc-audit/SKILL.md +28 -0
- package/skills/asc-refactor/SKILL.md +35 -0
- package/skills/asc-review/SKILL.md +54 -0
- package/.agent-context/policies/llm-judge-threshold.json +0 -29
- package/.agent-context/prompts/bootstrap-design.md +0 -63
- package/.agent-context/prompts/compact-natural-mode.md +0 -100
- package/.agent-context/prompts/init-project.md +0 -60
- package/.agent-context/prompts/refactor.md +0 -38
- package/.agent-context/prompts/review-code.md +0 -31
- package/.agent-context/review-checklists/architecture-review.md +0 -57
- package/.agent-context/review-checklists/pr-checklist.md +0 -134
- package/.agent-context/rules/api-docs.md +0 -24
- package/.agent-context/rules/api-versioning.md +0 -16
- package/.agent-context/rules/architecture.md +0 -38
- package/.agent-context/rules/background-jobs.md +0 -17
- package/.agent-context/rules/config-and-flags.md +0 -16
- package/.agent-context/rules/database-design.md +0 -18
- package/.agent-context/rules/docker-runtime.md +0 -17
- package/.agent-context/rules/error-handling.md +0 -16
- package/.agent-context/rules/event-driven.md +0 -16
- package/.agent-context/rules/frontend-architecture.md +0 -54
- package/.agent-context/rules/microservices.md +0 -16
- package/.agent-context/rules/migrations.md +0 -16
- package/.agent-context/rules/observability.md +0 -16
- package/.agent-context/rules/performance.md +0 -16
- package/.agent-context/rules/realtime.md +0 -16
- package/.agent-context/rules/resilience.md +0 -18
- package/.agent-context/rules/security.md +0 -18
- package/.agent-context/rules/testing.md +0 -16
- package/.agent-context/state/README.md +0 -25
- package/.agent-context/state/architecture-map.md +0 -40
- package/.agent-context/state/benchmark-comparison-schema.json +0 -181
- package/.agent-context/state/benchmark-reproducibility.json +0 -87
- package/.agent-context/state/benchmark-thresholds.json +0 -10
- package/.agent-context/state/benchmark-writer-judge-config.json +0 -58
- package/.agent-context/state/dependency-map.md +0 -41
- package/.agent-context/state/memory-adapter-contract.json +0 -52
- package/.agent-context/state/memory-schema-v1.json +0 -88
- package/GEMINI.md +0 -1
- package/benchmarks/README.md +0 -60
- package/benchmarks/compact-natural-mode/fixtures.mjs +0 -359
- package/benchmarks/compact-natural-mode/scorer.mjs +0 -331
- package/benchmarks/runtime-token-saver/fixtures.mjs +0 -836
- package/lib/cli/adaptive-context/catalog.mjs +0 -394
- package/lib/cli/adaptive-context/file-signals.mjs +0 -100
- package/lib/cli/adaptive-context/implications.mjs +0 -44
- package/lib/cli/adaptive-context.mjs +0 -151
- package/lib/cli/audits/typography-palette-anti-repeat/color-utils.mjs +0 -156
- package/lib/cli/audits/typography-palette-anti-repeat/file-scanner.mjs +0 -103
- package/lib/cli/audits/typography-palette-anti-repeat/typography-utils.mjs +0 -70
- package/lib/cli/backup.mjs +0 -210
- package/lib/cli/commands/context.mjs +0 -140
- package/lib/cli/commands/init/project-context.mjs +0 -60
- package/lib/cli/commands/init/runtime-environment.mjs +0 -59
- package/lib/cli/commands/init/setup-decisions.mjs +0 -83
- package/lib/cli/commands/init.mjs +0 -654
- package/lib/cli/commands/launch.mjs +0 -76
- package/lib/cli/commands/optimize.mjs +0 -284
- package/lib/cli/commands/rollback.mjs +0 -64
- package/lib/cli/commands/upgrade/token-optimization-state.mjs +0 -51
- package/lib/cli/commands/upgrade.mjs +0 -451
- package/lib/cli/compiler.mjs +0 -187
- package/lib/cli/constants.mjs +0 -136
- package/lib/cli/detector/constants.mjs +0 -135
- package/lib/cli/detector/design-evidence/collector.mjs +0 -256
- package/lib/cli/detector/design-evidence/constants.mjs +0 -39
- package/lib/cli/detector/design-evidence/file-traversal.mjs +0 -83
- package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +0 -117
- package/lib/cli/detector/design-evidence/summary.mjs +0 -109
- package/lib/cli/detector/design-evidence/utility-helpers.mjs +0 -122
- package/lib/cli/detector/design-evidence.mjs +0 -25
- package/lib/cli/detector/stack-detection.mjs +0 -243
- package/lib/cli/detector/ui-signals.mjs +0 -150
- package/lib/cli/detector/workspace-scan.mjs +0 -177
- package/lib/cli/detector.mjs +0 -23
- package/lib/cli/init-detection-flow.mjs +0 -48
- package/lib/cli/init-options.mjs +0 -237
- package/lib/cli/init-selection.mjs +0 -29
- package/lib/cli/memory-continuity.mjs +0 -537
- package/lib/cli/preflight.mjs +0 -76
- package/lib/cli/project-scaffolder/constants.mjs +0 -69
- package/lib/cli/project-scaffolder/discovery.mjs +0 -272
- package/lib/cli/project-scaffolder/prompt-builders.mjs +0 -171
- package/lib/cli/project-scaffolder/storage.mjs +0 -144
- package/lib/cli/project-scaffolder/ui-scope-detection.mjs +0 -36
- package/lib/cli/project-scaffolder.mjs +0 -29
- package/lib/cli/rollback.mjs +0 -66
- package/lib/cli/token-optimization.mjs +0 -401
- package/lib/cli/utils/filesystem.mjs +0 -81
- package/lib/cli/utils/managed-surface.mjs +0 -280
- package/lib/cli/utils/prompting.mjs +0 -44
- package/lib/cli/utils.mjs +0 -479
- package/mcp.json +0 -134
- package/scripts/adaptive-context/fixtures.mjs +0 -183
- package/scripts/adaptive-context-benchmark.mjs +0 -9
- package/scripts/ascx-runtime-token-saver-benchmark.mjs +0 -9
- package/scripts/benchmark-evidence-bundle.mjs +0 -645
- package/scripts/benchmark-gate.mjs +0 -121
- package/scripts/benchmark-intelligence.mjs +0 -33
- package/scripts/benchmark-writer-judge-matrix.mjs +0 -379
- package/scripts/build-release-benchmark-bundle.mjs +0 -202
- package/scripts/bump-version.mjs +0 -103
- package/scripts/clean-local-artifacts.mjs +0 -78
- package/scripts/compact-natural-mode-benchmark.mjs +0 -9
- package/scripts/context-triggered-audit.mjs +0 -391
- package/scripts/detection-benchmark.mjs +0 -127
- package/scripts/docs-quality-drift-report.mjs +0 -358
- package/scripts/documentation-boundary-audit.mjs +0 -305
- package/scripts/explain-on-demand-audit.mjs +0 -427
- package/scripts/forbidden-content-check.mjs +0 -123
- package/scripts/frontend-usability-audit.mjs +0 -243
- package/scripts/generate-sbom.mjs +0 -61
- package/scripts/governance-weekly-report.mjs +0 -466
- package/scripts/llm-judge/checklist-loader.mjs +0 -45
- package/scripts/llm-judge/constants.mjs +0 -66
- package/scripts/llm-judge/diff-collection.mjs +0 -74
- package/scripts/llm-judge/prompting.mjs +0 -78
- package/scripts/llm-judge/providers.mjs +0 -111
- package/scripts/llm-judge/verdict.mjs +0 -134
- package/scripts/llm-judge.mjs +0 -200
- package/scripts/memory-continuity-benchmark.mjs +0 -322
- package/scripts/quality-trend-report.mjs +0 -289
- package/scripts/release-gate/audit-checks.mjs +0 -441
- package/scripts/release-gate/constants.mjs +0 -53
- package/scripts/release-gate/runtime.mjs +0 -63
- package/scripts/release-gate/static-checks.mjs +0 -182
- package/scripts/release-gate.mjs +0 -42
- package/scripts/rules-guardian-audit.mjs +0 -580
- package/scripts/single-source-lazy-loading-audit.mjs +0 -449
- package/scripts/sync-thin-adapters.mjs +0 -72
- package/scripts/token-optimization-benchmark.mjs +0 -252
- package/scripts/ui-design-judge/constants.mjs +0 -13
- package/scripts/ui-design-judge/design-execution-summary.mjs +0 -81
- package/scripts/ui-design-judge/git-input.mjs +0 -134
- package/scripts/ui-design-judge/prompting.mjs +0 -52
- package/scripts/ui-design-judge/providers.mjs +0 -102
- package/scripts/ui-design-judge/reporting.mjs +0 -183
- package/scripts/ui-design-judge/rubric-calibration.mjs +0 -214
- package/scripts/ui-design-judge/rubric-goldset.json +0 -188
- package/scripts/ui-design-judge.mjs +0 -319
- package/scripts/ui-rubric-calibration.mjs +0 -35
- package/scripts/validate/audits/cache-layer-contract.mjs +0 -230
- package/scripts/validate/audits/caching-scope-hygiene.mjs +0 -235
- package/scripts/validate/audits/file-size.mjs +0 -158
- package/scripts/validate/audits/reflection-citations.mjs +0 -130
- package/scripts/validate/audits/release-bundle.mjs +0 -135
- package/scripts/validate/audits/rule-id-uniqueness.mjs +0 -278
- package/scripts/validate/config.mjs +0 -501
- package/scripts/validate/coverage-checks.mjs +0 -446
- package/scripts/validate/file-structure.mjs +0 -158
- package/scripts/validate/markdown-content.mjs +0 -109
- package/scripts/validate/project-metadata.mjs +0 -166
- package/scripts/validate/utils.mjs +0 -52
- package/scripts/validate.mjs +0 -267
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// @ts-check
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* audit-rule-id-uniqueness.mjs
|
|
6
|
-
*
|
|
7
|
-
* Phase 1 GATE B citability gate. Checks every migrated rule file under
|
|
8
|
-
* `.agent-context/rules/` for:
|
|
9
|
-
*
|
|
10
|
-
* 1. YAML frontmatter parses and contains required keys (id_prefix, domain,
|
|
11
|
-
* priority, scope, applies_to, keywords).
|
|
12
|
-
* 2. Section IDs match the file's locked id_prefix and are unique within
|
|
13
|
-
* the file.
|
|
14
|
-
* 3. Every `[REF:<PREFIX>-NNN]` mention across the rules pack, prompts/,
|
|
15
|
-
* and review-checklists/ resolves to a real section ID.
|
|
16
|
-
* 4. Every `related:` entry in any rule's frontmatter resolves to a real
|
|
17
|
-
* section ID.
|
|
18
|
-
* 5. No ambiguous prose references (`see above`, `as noted earlier`,
|
|
19
|
-
* `the next section`, etc.) survive in any rule body.
|
|
20
|
-
*
|
|
21
|
-
* Files that have not been migrated yet (no YAML frontmatter) are skipped
|
|
22
|
-
* with a notice. The audit only enforces shape on migrated files.
|
|
23
|
-
*
|
|
24
|
-
* Usage:
|
|
25
|
-
* node scripts/audit-rule-id-uniqueness.mjs (human + report line)
|
|
26
|
-
* node scripts/audit-rule-id-uniqueness.mjs --json (JSON only)
|
|
27
|
-
*
|
|
28
|
-
* Exit codes:
|
|
29
|
-
* 0 — clean
|
|
30
|
-
* 1 — at least one violation
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
import { readdirSync, readFileSync, existsSync } from 'node:fs';
|
|
34
|
-
import { dirname, join, resolve } from 'node:path';
|
|
35
|
-
import { fileURLToPath } from 'node:url';
|
|
36
|
-
import { parse as parseYaml } from 'yaml';
|
|
37
|
-
|
|
38
|
-
const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
|
|
39
|
-
const REPOSITORY_ROOT = resolve(dirname(SCRIPT_FILE_PATH), '../../..');
|
|
40
|
-
const RULES_DIRECTORY = join(REPOSITORY_ROOT, '.agent-context', 'rules');
|
|
41
|
-
const PROMPTS_DIRECTORY = join(REPOSITORY_ROOT, '.agent-context', 'prompts');
|
|
42
|
-
const REVIEW_CHECKLISTS_DIRECTORY = join(REPOSITORY_ROOT, '.agent-context', 'review-checklists');
|
|
43
|
-
|
|
44
|
-
const ARGS = new Set(process.argv.slice(2));
|
|
45
|
-
const JSON_ONLY = ARGS.has('--json');
|
|
46
|
-
|
|
47
|
-
const RULE_ID_PATTERN = /\b([A-Z]+)-(\d{3,4})(?:-([A-Z]))?\b/;
|
|
48
|
-
const REF_PATTERN = /\[REF:([A-Z]+-\d{3,4}(?:-[A-Z])?)\]/g;
|
|
49
|
-
const SECTION_HEADING_PATTERN = /^##\s+([A-Z]+-\d{3,4}(?:-[A-Z])?):\s+(.+)$/;
|
|
50
|
-
const REQUIRED_FRONTMATTER_KEYS = ['id_prefix', 'domain', 'priority', 'scope', 'applies_to', 'keywords'];
|
|
51
|
-
const FRONTMATTER_PATTERN = /^---\n([\s\S]*?)\n---\n/;
|
|
52
|
-
|
|
53
|
-
const AMBIGUOUS_PROSE_REFERENCE_PATTERNS = [
|
|
54
|
-
/\bsee above\b/i,
|
|
55
|
-
/\bsee below\b/i,
|
|
56
|
-
/\bas noted earlier\b/i,
|
|
57
|
-
/\bas noted above\b/i,
|
|
58
|
-
/\bas mentioned earlier\b/i,
|
|
59
|
-
/\bas mentioned above\b/i,
|
|
60
|
-
/\bin the previous section\b/i,
|
|
61
|
-
/\bin the next section\b/i,
|
|
62
|
-
/\bthe next section\b/i,
|
|
63
|
-
/\bthe previous section\b/i,
|
|
64
|
-
/\bsee earlier\b/i,
|
|
65
|
-
/\bsee later\b/i,
|
|
66
|
-
];
|
|
67
|
-
|
|
68
|
-
function listRuleFiles() {
|
|
69
|
-
return readdirSync(RULES_DIRECTORY)
|
|
70
|
-
.filter((filename) => filename.endsWith('.md') && !filename.endsWith('.candidate.md'))
|
|
71
|
-
.sort()
|
|
72
|
-
.map((filename) => ({ filename, absolutePath: join(RULES_DIRECTORY, filename) }));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function parseFrontmatter(sourceText) {
|
|
76
|
-
const match = sourceText.match(FRONTMATTER_PATTERN);
|
|
77
|
-
if (!match) return null;
|
|
78
|
-
try {
|
|
79
|
-
return parseYaml(match[1]);
|
|
80
|
-
} catch {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function extractSectionIds(sourceText) {
|
|
86
|
-
const sectionIds = [];
|
|
87
|
-
for (const line of sourceText.split(/\r?\n/)) {
|
|
88
|
-
const match = line.match(SECTION_HEADING_PATTERN);
|
|
89
|
-
if (match) {
|
|
90
|
-
sectionIds.push({ id: match[1], title: match[2].trim() });
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return sectionIds;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function findAmbiguousProseReferences(sourceText) {
|
|
97
|
-
const findings = [];
|
|
98
|
-
const lines = sourceText.split(/\r?\n/);
|
|
99
|
-
for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {
|
|
100
|
-
for (const pattern of AMBIGUOUS_PROSE_REFERENCE_PATTERNS) {
|
|
101
|
-
if (pattern.test(lines[lineIndex])) {
|
|
102
|
-
findings.push({ lineNumber: lineIndex + 1, snippet: lines[lineIndex].trim() });
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return findings;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function listMarkdownFilesIn(absoluteDirectoryPath) {
|
|
111
|
-
if (!existsSync(absoluteDirectoryPath)) return [];
|
|
112
|
-
return readdirSync(absoluteDirectoryPath)
|
|
113
|
-
.filter((filename) => filename.endsWith('.md'))
|
|
114
|
-
.map((filename) => join(absoluteDirectoryPath, filename));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function collectAllRefMentions() {
|
|
118
|
-
const mentions = [];
|
|
119
|
-
const candidatePaths = [
|
|
120
|
-
...listRuleFiles().map((entry) => entry.absolutePath),
|
|
121
|
-
...listMarkdownFilesIn(PROMPTS_DIRECTORY),
|
|
122
|
-
...listMarkdownFilesIn(REVIEW_CHECKLISTS_DIRECTORY),
|
|
123
|
-
];
|
|
124
|
-
for (const filePath of candidatePaths) {
|
|
125
|
-
const sourceText = readFileSync(filePath, 'utf8');
|
|
126
|
-
for (const match of sourceText.matchAll(REF_PATTERN)) {
|
|
127
|
-
mentions.push({ filePath, refId: match[1] });
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return mentions;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export function runRuleIdUniquenessAudit() {
|
|
134
|
-
const violations = [];
|
|
135
|
-
const ruleFiles = listRuleFiles();
|
|
136
|
-
const allKnownSectionIds = new Set();
|
|
137
|
-
const migratedFileCount = { migrated: 0, skipped: 0 };
|
|
138
|
-
const perFile = [];
|
|
139
|
-
|
|
140
|
-
for (const { filename, absolutePath } of ruleFiles) {
|
|
141
|
-
const sourceText = readFileSync(absolutePath, 'utf8');
|
|
142
|
-
const frontmatter = parseFrontmatter(sourceText);
|
|
143
|
-
if (!frontmatter) {
|
|
144
|
-
migratedFileCount.skipped += 1;
|
|
145
|
-
perFile.push({ filename, status: 'skipped', reason: 'no-yaml-frontmatter' });
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
migratedFileCount.migrated += 1;
|
|
150
|
-
|
|
151
|
-
for (const requiredKey of REQUIRED_FRONTMATTER_KEYS) {
|
|
152
|
-
if (!(requiredKey in frontmatter)) {
|
|
153
|
-
violations.push({
|
|
154
|
-
file: filename,
|
|
155
|
-
kind: 'frontmatter.missing-key',
|
|
156
|
-
detail: `frontmatter is missing required key: ${requiredKey}`,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const idPrefix = frontmatter.id_prefix;
|
|
162
|
-
if (typeof idPrefix !== 'string' || idPrefix.length === 0) {
|
|
163
|
-
violations.push({ file: filename, kind: 'frontmatter.invalid-id-prefix', detail: 'id_prefix must be a non-empty string' });
|
|
164
|
-
perFile.push({ filename, status: 'failed', reason: 'invalid-id-prefix' });
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const sections = extractSectionIds(sourceText);
|
|
169
|
-
const seenIdsInFile = new Set();
|
|
170
|
-
for (const section of sections) {
|
|
171
|
-
const idMatch = section.id.match(RULE_ID_PATTERN);
|
|
172
|
-
if (!idMatch || idMatch[1] !== idPrefix) {
|
|
173
|
-
violations.push({
|
|
174
|
-
file: filename,
|
|
175
|
-
kind: 'id.prefix-mismatch',
|
|
176
|
-
detail: `section id '${section.id}' does not match the file's id_prefix '${idPrefix}'`,
|
|
177
|
-
});
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
if (seenIdsInFile.has(section.id)) {
|
|
181
|
-
violations.push({
|
|
182
|
-
file: filename,
|
|
183
|
-
kind: 'id.duplicate',
|
|
184
|
-
detail: `section id '${section.id}' is reused within the same file`,
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
seenIdsInFile.add(section.id);
|
|
188
|
-
allKnownSectionIds.add(section.id);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const ambiguousProse = findAmbiguousProseReferences(sourceText);
|
|
192
|
-
for (const finding of ambiguousProse) {
|
|
193
|
-
violations.push({
|
|
194
|
-
file: filename,
|
|
195
|
-
kind: 'prose.ambiguous-reference',
|
|
196
|
-
detail: `line ${finding.lineNumber}: ${finding.snippet}`,
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
perFile.push({
|
|
201
|
-
filename,
|
|
202
|
-
status: 'audited',
|
|
203
|
-
idPrefix,
|
|
204
|
-
sectionCount: sections.length,
|
|
205
|
-
ambiguousProseCount: ambiguousProse.length,
|
|
206
|
-
knownSectionIdsInFile: sections.map((section) => section.id),
|
|
207
|
-
relatedRefs: (frontmatter.related && typeof frontmatter.related === 'object' && !Array.isArray(frontmatter.related))
|
|
208
|
-
? frontmatter.related
|
|
209
|
-
: null,
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
for (const fileEntry of perFile) {
|
|
214
|
-
if (fileEntry.status !== 'audited') continue;
|
|
215
|
-
if (!fileEntry.relatedRefs) continue;
|
|
216
|
-
for (const [parentId, relatedList] of Object.entries(fileEntry.relatedRefs)) {
|
|
217
|
-
if (!fileEntry.knownSectionIdsInFile.includes(parentId)) {
|
|
218
|
-
violations.push({
|
|
219
|
-
file: fileEntry.filename,
|
|
220
|
-
kind: 'related.parent-missing',
|
|
221
|
-
detail: `related map key '${parentId}' is not a section in this file`,
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
if (!Array.isArray(relatedList)) {
|
|
225
|
-
violations.push({
|
|
226
|
-
file: fileEntry.filename,
|
|
227
|
-
kind: 'related.malformed',
|
|
228
|
-
detail: `related[${parentId}] must be an array of <PREFIX>-NNN ids`,
|
|
229
|
-
});
|
|
230
|
-
continue;
|
|
231
|
-
}
|
|
232
|
-
for (const relatedId of relatedList) {
|
|
233
|
-
if (typeof relatedId !== 'string' || !RULE_ID_PATTERN.test(relatedId)) {
|
|
234
|
-
violations.push({
|
|
235
|
-
file: fileEntry.filename,
|
|
236
|
-
kind: 'related.malformed',
|
|
237
|
-
detail: `related[${parentId}] entry '${relatedId}' is not a valid <PREFIX>-NNN id`,
|
|
238
|
-
});
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
if (!allKnownSectionIds.has(relatedId)) {
|
|
242
|
-
violations.push({
|
|
243
|
-
file: fileEntry.filename,
|
|
244
|
-
kind: 'related.unresolved',
|
|
245
|
-
detail: `related[${parentId}] entry '${relatedId}' does not resolve to any section in the rules pack`,
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const refMentions = collectAllRefMentions();
|
|
253
|
-
for (const mention of refMentions) {
|
|
254
|
-
if (!allKnownSectionIds.has(mention.refId)) {
|
|
255
|
-
violations.push({
|
|
256
|
-
file: mention.filePath.replace(REPOSITORY_ROOT, '').replace(/^[\\/]+/, ''),
|
|
257
|
-
kind: 'ref.unresolved',
|
|
258
|
-
detail: `[REF:${mention.refId}] does not resolve to any section in the rules pack`,
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
return {
|
|
264
|
-
auditName: 'audit-rule-id-uniqueness',
|
|
265
|
-
reportVersion: '1.0.0',
|
|
266
|
-
generatedAt: new Date().toISOString(),
|
|
267
|
-
migratedFileCount: migratedFileCount.migrated,
|
|
268
|
-
skippedFileCount: migratedFileCount.skipped,
|
|
269
|
-
knownSectionIdCount: allKnownSectionIds.size,
|
|
270
|
-
refMentionCount: refMentions.length,
|
|
271
|
-
perFile,
|
|
272
|
-
violationCount: violations.length,
|
|
273
|
-
violations,
|
|
274
|
-
passed: violations.length === 0,
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
|