@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,449 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* single-source-lazy-loading-audit.mjs
|
|
5
|
-
*
|
|
6
|
-
* Enforces V3.0-010 policy:
|
|
7
|
-
* - One canonical rule source is explicitly defined and enforced.
|
|
8
|
-
* - Global domain governance loads lazily by touched scope.
|
|
9
|
-
* - Conflicting duplicate instruction paths are prevented.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
13
|
-
import { execFileSync } from 'node:child_process';
|
|
14
|
-
import { dirname, resolve } from 'node:path';
|
|
15
|
-
import { fileURLToPath } from 'node:url';
|
|
16
|
-
|
|
17
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
-
const __dirname = dirname(__filename);
|
|
19
|
-
const REPOSITORY_ROOT = resolve(__dirname, '..');
|
|
20
|
-
|
|
21
|
-
const CANONICAL_SOURCE_PATH = 'AGENTS.md';
|
|
22
|
-
const ADAPTER_PATHS = [
|
|
23
|
-
'CLAUDE.md',
|
|
24
|
-
'GEMINI.md',
|
|
25
|
-
];
|
|
26
|
-
const COMPILER_PATH = 'lib/cli/compiler.mjs';
|
|
27
|
-
const ONBOARDING_REPORT_PATH = '.agent-context/state/onboarding-report.json';
|
|
28
|
-
const ARCHITECTURE_RULE_PATH = '.agent-context/rules/architecture.md';
|
|
29
|
-
const PR_CHECKLIST_PATH = '.agent-context/review-checklists/pr-checklist.md';
|
|
30
|
-
const REVIEW_PROMPT_PATH = '.agent-context/prompts/review-code.md';
|
|
31
|
-
|
|
32
|
-
const DEFAULT_WORKFLOW = 'standard';
|
|
33
|
-
const SUPPORTED_WORKFLOWS = new Set([
|
|
34
|
-
DEFAULT_WORKFLOW,
|
|
35
|
-
'pr-preparation',
|
|
36
|
-
'review-request',
|
|
37
|
-
'session-handoff',
|
|
38
|
-
'init',
|
|
39
|
-
'upgrade',
|
|
40
|
-
]);
|
|
41
|
-
|
|
42
|
-
const STACK_CATALOG_FILE_NAMES = [
|
|
43
|
-
'typescript.md',
|
|
44
|
-
'python.md',
|
|
45
|
-
'java.md',
|
|
46
|
-
'php.md',
|
|
47
|
-
'go.md',
|
|
48
|
-
'csharp.md',
|
|
49
|
-
'rust.md',
|
|
50
|
-
'ruby.md',
|
|
51
|
-
'flutter.md',
|
|
52
|
-
'react-native.md',
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
const MAX_EAGER_STACK_MENTIONS = 4;
|
|
56
|
-
|
|
57
|
-
const REQUIRED_ARCHITECTURE_RULE_SNIPPETS = [
|
|
58
|
-
'## ARCH-007: Single Source of Truth and Lazy Rule Loading',
|
|
59
|
-
'Canonical rule source is AGENTS.md.',
|
|
60
|
-
'Load global domain rules lazily based on touched scope.',
|
|
61
|
-
'Do not create or load stack-specific governance adapters as the baseline.',
|
|
62
|
-
];
|
|
63
|
-
|
|
64
|
-
const REQUIRED_PR_CHECKLIST_SNIPPETS = [
|
|
65
|
-
'Canonical rule source is explicitly defined and enforced',
|
|
66
|
-
'Global domain governance is loaded lazily based on touched scope',
|
|
67
|
-
'No conflicting duplicate rule instructions during normal flow',
|
|
68
|
-
];
|
|
69
|
-
|
|
70
|
-
const REQUIRED_REVIEW_PROMPT_SNIPPETS = [
|
|
71
|
-
'Enforce single-source and lazy-loading policy: canonical rule source must be explicitly enforced, global domain governance must load lazily based on touched scope, and conflicting duplicate rule instructions must not appear during normal flow.',
|
|
72
|
-
];
|
|
73
|
-
|
|
74
|
-
const REQUIRED_COMPILER_SNIPPETS = [
|
|
75
|
-
'## LAYER 2 POLICY: LAZY RULE LOADING',
|
|
76
|
-
'Load global domain rules only when task scope touches that domain.',
|
|
77
|
-
'Avoid eager loading unrelated runtime or domain guidance to prevent instruction conflicts.',
|
|
78
|
-
"stackLoadingMode: 'lazy'",
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
function pushResult(results, isPassed, checkName, details) {
|
|
82
|
-
results.push({
|
|
83
|
-
checkName,
|
|
84
|
-
passed: isPassed,
|
|
85
|
-
details,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function normalizeLineEndings(content) {
|
|
90
|
-
return String(content || '').replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function readText(relativeFilePath) {
|
|
94
|
-
const absolutePath = resolve(REPOSITORY_ROOT, relativeFilePath);
|
|
95
|
-
if (!existsSync(absolutePath)) {
|
|
96
|
-
return '';
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return readFileSync(absolutePath, 'utf8');
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function normalizeFilePath(filePath) {
|
|
103
|
-
return filePath.replace(/\\/g, '/').replace(/^\.\//, '');
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function parseGitFileList(rawOutput) {
|
|
107
|
-
if (typeof rawOutput !== 'string' || rawOutput.trim().length === 0) {
|
|
108
|
-
return [];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return rawOutput
|
|
112
|
-
.split(/\r?\n/)
|
|
113
|
-
.map((filePath) => filePath.trim())
|
|
114
|
-
.filter((filePath) => filePath.length > 0)
|
|
115
|
-
.map(normalizeFilePath);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function runGitFileQuery(commandArguments) {
|
|
119
|
-
try {
|
|
120
|
-
const rawOutput = execFileSync('git', commandArguments, {
|
|
121
|
-
cwd: REPOSITORY_ROOT,
|
|
122
|
-
encoding: 'utf8',
|
|
123
|
-
maxBuffer: 1024 * 1024,
|
|
124
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
return parseGitFileList(rawOutput);
|
|
128
|
-
} catch {
|
|
129
|
-
return [];
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function uniqueSorted(filePaths) {
|
|
134
|
-
return Array.from(new Set(filePaths)).sort((leftPath, rightPath) => leftPath.localeCompare(rightPath));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function collectChangedFiles() {
|
|
138
|
-
const workingTreeFiles = runGitFileQuery(['diff', '--name-only']);
|
|
139
|
-
const stagedFiles = runGitFileQuery(['diff', '--name-only', '--cached']);
|
|
140
|
-
const workingScopeFiles = uniqueSorted([...workingTreeFiles, ...stagedFiles]);
|
|
141
|
-
|
|
142
|
-
if (workingScopeFiles.length > 0) {
|
|
143
|
-
return {
|
|
144
|
-
source: 'working-tree-and-index',
|
|
145
|
-
files: workingScopeFiles,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const latestCommitRangeFiles = runGitFileQuery(['diff', '--name-only', 'HEAD~1..HEAD']);
|
|
150
|
-
if (latestCommitRangeFiles.length > 0) {
|
|
151
|
-
return {
|
|
152
|
-
source: 'latest-commit-range',
|
|
153
|
-
files: uniqueSorted(latestCommitRangeFiles),
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const headCommitFiles = runGitFileQuery(['show', '--pretty=format:', '--name-only', 'HEAD']);
|
|
158
|
-
if (headCommitFiles.length > 0) {
|
|
159
|
-
return {
|
|
160
|
-
source: 'head-commit',
|
|
161
|
-
files: uniqueSorted(headCommitFiles),
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return {
|
|
166
|
-
source: 'none',
|
|
167
|
-
files: [],
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function parseCliArguments(argumentList) {
|
|
172
|
-
let workflow = DEFAULT_WORKFLOW;
|
|
173
|
-
|
|
174
|
-
for (let argumentIndex = 0; argumentIndex < argumentList.length; argumentIndex += 1) {
|
|
175
|
-
const argumentValue = argumentList[argumentIndex];
|
|
176
|
-
|
|
177
|
-
if (argumentValue === '--workflow') {
|
|
178
|
-
const nextArgumentValue = argumentList[argumentIndex + 1];
|
|
179
|
-
if (nextArgumentValue && !nextArgumentValue.startsWith('--')) {
|
|
180
|
-
workflow = nextArgumentValue;
|
|
181
|
-
argumentIndex += 1;
|
|
182
|
-
}
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (argumentValue.startsWith('--workflow=')) {
|
|
187
|
-
workflow = argumentValue.slice('--workflow='.length);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const normalizedWorkflow = String(workflow).trim().toLowerCase() || DEFAULT_WORKFLOW;
|
|
192
|
-
|
|
193
|
-
return {
|
|
194
|
-
workflow: SUPPORTED_WORKFLOWS.has(normalizedWorkflow) ? normalizedWorkflow : DEFAULT_WORKFLOW,
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function assertSnippetCoverage(sourceLabel, sourcePath, requiredSnippets, failures, results) {
|
|
199
|
-
const sourceContent = readText(sourcePath);
|
|
200
|
-
|
|
201
|
-
if (!sourceContent) {
|
|
202
|
-
failures.push(`Missing ${sourceLabel} source: ${sourcePath}`);
|
|
203
|
-
pushResult(results, false, `${sourceLabel}-source-exists`, `Missing ${sourcePath}`);
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
pushResult(results, true, `${sourceLabel}-source-exists`, `${sourcePath} is present`);
|
|
208
|
-
|
|
209
|
-
const missingSnippets = requiredSnippets.filter((requiredSnippet) => !sourceContent.includes(requiredSnippet));
|
|
210
|
-
|
|
211
|
-
if (missingSnippets.length > 0) {
|
|
212
|
-
failures.push(`Missing ${sourceLabel} snippets: ${missingSnippets.join(', ')}`);
|
|
213
|
-
pushResult(
|
|
214
|
-
results,
|
|
215
|
-
false,
|
|
216
|
-
`${sourceLabel}-source-coverage`,
|
|
217
|
-
`Missing snippets in ${sourcePath}: ${missingSnippets.join(', ')}`
|
|
218
|
-
);
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
pushResult(results, true, `${sourceLabel}-source-coverage`, `${sourceLabel} snippets are complete`);
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function parseJsonSafely(rawText) {
|
|
227
|
-
if (typeof rawText !== 'string' || rawText.trim().length === 0) {
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
try {
|
|
232
|
-
return JSON.parse(rawText);
|
|
233
|
-
} catch {
|
|
234
|
-
return null;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function countStackMentions(textContent) {
|
|
239
|
-
return STACK_CATALOG_FILE_NAMES.reduce((mentionCount, stackFileName) => (
|
|
240
|
-
mentionCount + (textContent.includes(stackFileName) ? 1 : 0)
|
|
241
|
-
), 0);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function runAudit() {
|
|
245
|
-
const parsedArguments = parseCliArguments(process.argv.slice(2));
|
|
246
|
-
const changedScope = collectChangedFiles();
|
|
247
|
-
const changedFiles = changedScope.files;
|
|
248
|
-
const results = [];
|
|
249
|
-
const failures = [];
|
|
250
|
-
const warnings = [];
|
|
251
|
-
|
|
252
|
-
pushResult(results, true, 'context-workflow', `workflow=${parsedArguments.workflow}`);
|
|
253
|
-
|
|
254
|
-
const canonicalSourceContent = readText(CANONICAL_SOURCE_PATH);
|
|
255
|
-
const canonicalSourceExists = canonicalSourceContent.length > 0;
|
|
256
|
-
|
|
257
|
-
if (!canonicalSourceExists) {
|
|
258
|
-
failures.push(`Missing canonical source: ${CANONICAL_SOURCE_PATH}`);
|
|
259
|
-
pushResult(results, false, 'canonical-source-exists', `Missing ${CANONICAL_SOURCE_PATH}`);
|
|
260
|
-
} else {
|
|
261
|
-
pushResult(results, true, 'canonical-source-exists', `${CANONICAL_SOURCE_PATH} is present`);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const canonicalHash = canonicalSourceExists ? 'native-import-bridges' : '';
|
|
265
|
-
let adapterImportPassCount = 0;
|
|
266
|
-
const adapterChecks = [];
|
|
267
|
-
|
|
268
|
-
for (const adapterPath of ADAPTER_PATHS) {
|
|
269
|
-
const adapterContent = readText(adapterPath);
|
|
270
|
-
|
|
271
|
-
if (!adapterContent) {
|
|
272
|
-
failures.push(`Missing adapter file: ${adapterPath}`);
|
|
273
|
-
pushResult(results, false, 'adapter-file-exists', `Missing ${adapterPath}`);
|
|
274
|
-
adapterChecks.push({
|
|
275
|
-
path: adapterPath,
|
|
276
|
-
exists: false,
|
|
277
|
-
importsCanonical: false,
|
|
278
|
-
});
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
pushResult(results, true, 'adapter-file-exists', `${adapterPath} is present`);
|
|
283
|
-
|
|
284
|
-
const importsCanonical = normalizeLineEndings(adapterContent).trim() === '@AGENTS.md';
|
|
285
|
-
|
|
286
|
-
if (!importsCanonical) {
|
|
287
|
-
failures.push(`${adapterPath} must import canonical AGENTS.md`);
|
|
288
|
-
pushResult(results, false, 'adapter-canonical-import', `${adapterPath} is not @AGENTS.md`);
|
|
289
|
-
} else {
|
|
290
|
-
adapterImportPassCount += 1;
|
|
291
|
-
pushResult(results, true, 'adapter-canonical-import', `${adapterPath} imports AGENTS.md`);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
adapterChecks.push({
|
|
295
|
-
path: adapterPath,
|
|
296
|
-
exists: true,
|
|
297
|
-
importsCanonical,
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
const architectureCoverageComplete = assertSnippetCoverage(
|
|
302
|
-
'single-source-lazy-loading-architecture-rule',
|
|
303
|
-
ARCHITECTURE_RULE_PATH,
|
|
304
|
-
REQUIRED_ARCHITECTURE_RULE_SNIPPETS,
|
|
305
|
-
failures,
|
|
306
|
-
results
|
|
307
|
-
);
|
|
308
|
-
|
|
309
|
-
const checklistCoverageComplete = assertSnippetCoverage(
|
|
310
|
-
'single-source-lazy-loading-pr-checklist',
|
|
311
|
-
PR_CHECKLIST_PATH,
|
|
312
|
-
REQUIRED_PR_CHECKLIST_SNIPPETS,
|
|
313
|
-
failures,
|
|
314
|
-
results
|
|
315
|
-
);
|
|
316
|
-
|
|
317
|
-
const reviewPromptCoverageComplete = assertSnippetCoverage(
|
|
318
|
-
'single-source-lazy-loading-review-prompt',
|
|
319
|
-
REVIEW_PROMPT_PATH,
|
|
320
|
-
REQUIRED_REVIEW_PROMPT_SNIPPETS,
|
|
321
|
-
failures,
|
|
322
|
-
results
|
|
323
|
-
);
|
|
324
|
-
|
|
325
|
-
const compilerCoverageComplete = assertSnippetCoverage(
|
|
326
|
-
'single-source-lazy-loading-compiler-policy',
|
|
327
|
-
COMPILER_PATH,
|
|
328
|
-
REQUIRED_COMPILER_SNIPPETS,
|
|
329
|
-
failures,
|
|
330
|
-
results
|
|
331
|
-
);
|
|
332
|
-
|
|
333
|
-
const onboardingReportContent = readText(ONBOARDING_REPORT_PATH);
|
|
334
|
-
const onboardingReport = parseJsonSafely(onboardingReportContent);
|
|
335
|
-
|
|
336
|
-
let onboardingLazyPolicyMode = 'missing';
|
|
337
|
-
let onboardingLazyPolicyValidated = false;
|
|
338
|
-
|
|
339
|
-
if (!onboardingReportContent) {
|
|
340
|
-
warnings.push(`Missing ${ONBOARDING_REPORT_PATH}; fallback lazy policy inference used`);
|
|
341
|
-
pushResult(results, false, 'lazy-loading-onboarding-state', `Missing ${ONBOARDING_REPORT_PATH}`);
|
|
342
|
-
} else if (!onboardingReport) {
|
|
343
|
-
failures.push(`Invalid JSON in ${ONBOARDING_REPORT_PATH}`);
|
|
344
|
-
pushResult(results, false, 'lazy-loading-onboarding-state', `Cannot parse ${ONBOARDING_REPORT_PATH}`);
|
|
345
|
-
} else {
|
|
346
|
-
const lazyPolicy = onboardingReport.ruleLoadingPolicy;
|
|
347
|
-
|
|
348
|
-
if (lazyPolicy
|
|
349
|
-
&& lazyPolicy.canonicalSource === CANONICAL_SOURCE_PATH
|
|
350
|
-
&& lazyPolicy.stackLoadingMode === 'lazy'
|
|
351
|
-
&& (lazyPolicy.domainRuleLoadingMode === 'lazy' || typeof lazyPolicy.domainRuleLoadingMode === 'undefined')
|
|
352
|
-
&& lazyPolicy.loadedOnDemand === true) {
|
|
353
|
-
onboardingLazyPolicyMode = 'explicit-lazy-policy';
|
|
354
|
-
onboardingLazyPolicyValidated = true;
|
|
355
|
-
pushResult(results, true, 'lazy-loading-onboarding-state', `${ONBOARDING_REPORT_PATH} exposes explicit lazy loading policy`);
|
|
356
|
-
} else if (typeof onboardingReport.selectedStack === 'string' && onboardingReport.selectedStack.trim().length > 0) {
|
|
357
|
-
onboardingLazyPolicyMode = 'selected-stack-fallback';
|
|
358
|
-
onboardingLazyPolicyValidated = true;
|
|
359
|
-
warnings.push('Onboarding report does not include explicit ruleLoadingPolicy; using selectedStack fallback inference');
|
|
360
|
-
pushResult(
|
|
361
|
-
results,
|
|
362
|
-
true,
|
|
363
|
-
'lazy-loading-onboarding-state',
|
|
364
|
-
`${ONBOARDING_REPORT_PATH} includes selectedStack fallback for lazy loading policy`
|
|
365
|
-
);
|
|
366
|
-
} else {
|
|
367
|
-
onboardingLazyPolicyMode = 'invalid';
|
|
368
|
-
failures.push(`${ONBOARDING_REPORT_PATH} must include selectedStack or explicit ruleLoadingPolicy`);
|
|
369
|
-
pushResult(results, false, 'lazy-loading-onboarding-state', `${ONBOARDING_REPORT_PATH} missing lazy loading policy signals`);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
let eagerLoadingDetected = false;
|
|
374
|
-
const compiledRuleChecks = [];
|
|
375
|
-
|
|
376
|
-
const canonicalSourceEnforced = canonicalSourceExists
|
|
377
|
-
&& adapterImportPassCount === ADAPTER_PATHS.length
|
|
378
|
-
&& architectureCoverageComplete
|
|
379
|
-
&& checklistCoverageComplete
|
|
380
|
-
&& reviewPromptCoverageComplete;
|
|
381
|
-
|
|
382
|
-
if (canonicalSourceEnforced) {
|
|
383
|
-
pushResult(results, true, 'canonical-source-hard-rule', 'Canonical rule source is explicitly defined and enforced');
|
|
384
|
-
} else {
|
|
385
|
-
failures.push('Canonical rule source hard-rule is not fully enforced');
|
|
386
|
-
pushResult(results, false, 'canonical-source-hard-rule', 'Canonical source enforcement failed');
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const lazyRuleLoadingEnforced = compilerCoverageComplete
|
|
390
|
-
&& onboardingLazyPolicyValidated
|
|
391
|
-
&& !eagerLoadingDetected;
|
|
392
|
-
|
|
393
|
-
if (lazyRuleLoadingEnforced) {
|
|
394
|
-
pushResult(results, true, 'lazy-rule-loading-hard-rule', 'Global domain governance is loaded lazily by touched scope');
|
|
395
|
-
} else {
|
|
396
|
-
failures.push('Lazy rule loading hard-rule is not fully enforced');
|
|
397
|
-
pushResult(results, false, 'lazy-rule-loading-hard-rule', 'Lazy loading enforcement failed');
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
const noConflictingDuplicates = canonicalSourceEnforced && !eagerLoadingDetected;
|
|
401
|
-
|
|
402
|
-
if (noConflictingDuplicates) {
|
|
403
|
-
pushResult(results, true, 'no-conflicting-duplicate-rule-instructions', 'No conflicting duplicate rule instructions detected in normal flow');
|
|
404
|
-
} else {
|
|
405
|
-
failures.push('Conflicting duplicate rule instructions detected in normal flow');
|
|
406
|
-
pushResult(results, false, 'no-conflicting-duplicate-rule-instructions', 'Duplicate/conflicting instruction risk detected');
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
const reportPayload = {
|
|
410
|
-
generatedAt: new Date().toISOString(),
|
|
411
|
-
auditName: 'single-source-lazy-loading-audit',
|
|
412
|
-
workflow: parsedArguments.workflow,
|
|
413
|
-
source: changedScope.source,
|
|
414
|
-
changedFileCount: changedFiles.length,
|
|
415
|
-
changedFiles,
|
|
416
|
-
canonicalSource: {
|
|
417
|
-
path: CANONICAL_SOURCE_PATH,
|
|
418
|
-
hash: canonicalHash,
|
|
419
|
-
enforced: canonicalSourceEnforced,
|
|
420
|
-
adapterChecks,
|
|
421
|
-
compiledRuleChecks,
|
|
422
|
-
},
|
|
423
|
-
lazyRuleLoading: {
|
|
424
|
-
enforced: lazyRuleLoadingEnforced,
|
|
425
|
-
compilerPolicySnippetsComplete: compilerCoverageComplete,
|
|
426
|
-
onboardingPolicyMode: onboardingLazyPolicyMode,
|
|
427
|
-
onboardingPolicyValidated: onboardingLazyPolicyValidated,
|
|
428
|
-
eagerLoadingDetected,
|
|
429
|
-
maxAllowedStackMentions: MAX_EAGER_STACK_MENTIONS,
|
|
430
|
-
globalDomainGovernance: true,
|
|
431
|
-
},
|
|
432
|
-
duplicationPolicy: {
|
|
433
|
-
noConflictingDuplicates,
|
|
434
|
-
conflictingDuplicateSignals: noConflictingDuplicates
|
|
435
|
-
? []
|
|
436
|
-
: ['canonical-source-enforcement-or-lazy-loading-density-failed'],
|
|
437
|
-
},
|
|
438
|
-
passed: failures.length === 0,
|
|
439
|
-
failureCount: failures.length,
|
|
440
|
-
failures,
|
|
441
|
-
warnings,
|
|
442
|
-
results,
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
console.log(JSON.stringify(reportPayload, null, 2));
|
|
446
|
-
process.exit(reportPayload.passed ? 0 : 1);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
runAudit();
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* sync-thin-adapters.mjs
|
|
5
|
-
*
|
|
6
|
-
* Regenerates minimal native-tool import bridges from canonical AGENTS.md.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* - node scripts/sync-thin-adapters.mjs
|
|
10
|
-
* - node scripts/sync-thin-adapters.mjs --check
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { readFile, writeFile } from 'node:fs/promises';
|
|
14
|
-
import { join, resolve, dirname } from 'node:path';
|
|
15
|
-
import { fileURLToPath } from 'node:url';
|
|
16
|
-
|
|
17
|
-
const SCRIPT_FILE_PATH = fileURLToPath(import.meta.url);
|
|
18
|
-
const ROOT_DIR = resolve(dirname(SCRIPT_FILE_PATH), '..');
|
|
19
|
-
const IS_CHECK_MODE = process.argv.includes('--check');
|
|
20
|
-
|
|
21
|
-
const ADAPTERS = [
|
|
22
|
-
{
|
|
23
|
-
relativePath: 'CLAUDE.md',
|
|
24
|
-
content: '@AGENTS.md\n',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
relativePath: 'GEMINI.md',
|
|
28
|
-
content: '@AGENTS.md\n',
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
function normalizeLineEndings(content) {
|
|
33
|
-
return content.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async function main() {
|
|
37
|
-
await readFile(join(ROOT_DIR, 'AGENTS.md'), 'utf8');
|
|
38
|
-
|
|
39
|
-
let hasDrift = false;
|
|
40
|
-
|
|
41
|
-
for (const adapter of ADAPTERS) {
|
|
42
|
-
const adapterAbsolutePath = join(ROOT_DIR, adapter.relativePath);
|
|
43
|
-
|
|
44
|
-
if (IS_CHECK_MODE) {
|
|
45
|
-
const existingContent = normalizeLineEndings(await readFile(adapterAbsolutePath, 'utf8'));
|
|
46
|
-
if (existingContent !== adapter.content) {
|
|
47
|
-
hasDrift = true;
|
|
48
|
-
console.error(`[DRIFT] ${adapter.relativePath} does not match canonical adapter output.`);
|
|
49
|
-
} else {
|
|
50
|
-
console.log(`[OK] ${adapter.relativePath} is synchronized.`);
|
|
51
|
-
}
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
await writeFile(adapterAbsolutePath, adapter.content, 'utf8');
|
|
56
|
-
console.log(`[SYNC] ${adapter.relativePath}`);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (IS_CHECK_MODE) {
|
|
60
|
-
if (hasDrift) {
|
|
61
|
-
process.exitCode = 1;
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
console.log('[OK] All native import bridges match canonical source output.');
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
main().catch((error) => {
|
|
70
|
-
console.error(`[FATAL] Failed to synchronize thin adapters: ${error.message}`);
|
|
71
|
-
process.exitCode = 1;
|
|
72
|
-
});
|