@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,391 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* context-triggered-audit.mjs
|
|
5
|
-
*
|
|
6
|
-
* Determines whether strict security/performance audits should run based on
|
|
7
|
-
* workflow context, changed scope size, and explicit user override.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
11
|
-
import { execFileSync } from 'node:child_process';
|
|
12
|
-
import { dirname, resolve } from 'node:path';
|
|
13
|
-
import { fileURLToPath } from 'node:url';
|
|
14
|
-
|
|
15
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
-
const __dirname = dirname(__filename);
|
|
17
|
-
const REPOSITORY_ROOT = resolve(__dirname, '..');
|
|
18
|
-
|
|
19
|
-
const PR_CHECKLIST_PATH = '.agent-context/review-checklists/pr-checklist.md';
|
|
20
|
-
const ARCHITECTURE_CHECKLIST_PATH = '.agent-context/review-checklists/architecture-review.md';
|
|
21
|
-
const DEFAULT_WORKFLOW = 'auto';
|
|
22
|
-
const SMALL_EDIT_MAX_FILES = 3;
|
|
23
|
-
const MAJOR_FEATURE_MIN_SIGNIFICANT_FILES = 4;
|
|
24
|
-
|
|
25
|
-
const STRICT_WORKFLOWS = new Set([
|
|
26
|
-
'review-request',
|
|
27
|
-
'pr-intent',
|
|
28
|
-
'pr-preparation',
|
|
29
|
-
'major-feature-completion',
|
|
30
|
-
]);
|
|
31
|
-
|
|
32
|
-
const SUPPORTED_WORKFLOWS = new Set([
|
|
33
|
-
DEFAULT_WORKFLOW,
|
|
34
|
-
...STRICT_WORKFLOWS,
|
|
35
|
-
'small-edit',
|
|
36
|
-
'standard',
|
|
37
|
-
]);
|
|
38
|
-
|
|
39
|
-
const REQUIRED_PR_CHECKLIST_SNIPPETS = [
|
|
40
|
-
'### 9.1 Context-Triggered Audit Mode',
|
|
41
|
-
'Strict audit mode activates automatically on review and PR-intent workflows',
|
|
42
|
-
'Small edits avoid heavy checks by default unless strict mode is explicitly requested',
|
|
43
|
-
'User can always force strict audit mode manually',
|
|
44
|
-
];
|
|
45
|
-
|
|
46
|
-
const REQUIRED_ARCHITECTURE_CHECKLIST_SNIPPETS = [];
|
|
47
|
-
|
|
48
|
-
function pushResult(results, isPassed, checkName, details) {
|
|
49
|
-
results.push({
|
|
50
|
-
checkName,
|
|
51
|
-
passed: isPassed,
|
|
52
|
-
details,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function normalizeFilePath(filePath) {
|
|
57
|
-
return filePath.replace(/\\/g, '/').replace(/^\.\//, '');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function parseGitFileList(rawOutput) {
|
|
61
|
-
if (typeof rawOutput !== 'string' || rawOutput.trim().length === 0) {
|
|
62
|
-
return [];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return rawOutput
|
|
66
|
-
.split(/\r?\n/)
|
|
67
|
-
.map((filePath) => filePath.trim())
|
|
68
|
-
.filter((filePath) => filePath.length > 0)
|
|
69
|
-
.map(normalizeFilePath);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function runGitFileQuery(commandArguments) {
|
|
73
|
-
try {
|
|
74
|
-
const rawOutput = execFileSync('git', commandArguments, {
|
|
75
|
-
cwd: REPOSITORY_ROOT,
|
|
76
|
-
encoding: 'utf8',
|
|
77
|
-
maxBuffer: 1024 * 1024,
|
|
78
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
return parseGitFileList(rawOutput);
|
|
82
|
-
} catch {
|
|
83
|
-
return [];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function uniqueSorted(filePaths) {
|
|
88
|
-
return Array.from(new Set(filePaths)).sort((leftPath, rightPath) => leftPath.localeCompare(rightPath));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function collectChangedFiles() {
|
|
92
|
-
const workingTreeFiles = runGitFileQuery(['diff', '--name-only']);
|
|
93
|
-
const stagedFiles = runGitFileQuery(['diff', '--name-only', '--cached']);
|
|
94
|
-
const workingScopeFiles = uniqueSorted([...workingTreeFiles, ...stagedFiles]);
|
|
95
|
-
|
|
96
|
-
if (workingScopeFiles.length > 0) {
|
|
97
|
-
return {
|
|
98
|
-
source: 'working-tree-and-index',
|
|
99
|
-
files: workingScopeFiles,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const latestCommitRangeFiles = runGitFileQuery(['diff', '--name-only', 'HEAD~1..HEAD']);
|
|
104
|
-
if (latestCommitRangeFiles.length > 0) {
|
|
105
|
-
return {
|
|
106
|
-
source: 'latest-commit-range',
|
|
107
|
-
files: uniqueSorted(latestCommitRangeFiles),
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const headCommitFiles = runGitFileQuery(['show', '--pretty=format:', '--name-only', 'HEAD']);
|
|
112
|
-
if (headCommitFiles.length > 0) {
|
|
113
|
-
return {
|
|
114
|
-
source: 'head-commit',
|
|
115
|
-
files: uniqueSorted(headCommitFiles),
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
source: 'none',
|
|
121
|
-
files: [],
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function parseCliArguments(argumentList) {
|
|
126
|
-
let workflow = DEFAULT_WORKFLOW;
|
|
127
|
-
let strict = false;
|
|
128
|
-
|
|
129
|
-
for (let argumentIndex = 0; argumentIndex < argumentList.length; argumentIndex += 1) {
|
|
130
|
-
const argumentValue = argumentList[argumentIndex];
|
|
131
|
-
|
|
132
|
-
if (argumentValue === '--strict') {
|
|
133
|
-
strict = true;
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (argumentValue === '--workflow') {
|
|
138
|
-
const nextArgumentValue = argumentList[argumentIndex + 1];
|
|
139
|
-
if (nextArgumentValue && !nextArgumentValue.startsWith('--')) {
|
|
140
|
-
workflow = nextArgumentValue;
|
|
141
|
-
argumentIndex += 1;
|
|
142
|
-
}
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (argumentValue.startsWith('--workflow=')) {
|
|
147
|
-
workflow = argumentValue.slice('--workflow='.length);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const normalizedWorkflow = String(workflow).trim().toLowerCase() || DEFAULT_WORKFLOW;
|
|
152
|
-
|
|
153
|
-
return {
|
|
154
|
-
workflow: SUPPORTED_WORKFLOWS.has(normalizedWorkflow) ? normalizedWorkflow : DEFAULT_WORKFLOW,
|
|
155
|
-
strict,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function isLightweightFilePath(filePath) {
|
|
160
|
-
return filePath.endsWith('.md')
|
|
161
|
-
|| filePath.startsWith('docs/')
|
|
162
|
-
|| filePath.startsWith('.agent-context/review-checklists/')
|
|
163
|
-
|| filePath.startsWith('.agent-context/rules/')
|
|
164
|
-
|| filePath.startsWith('.agent-context/prompts/')
|
|
165
|
-
|| filePath === 'CHANGELOG.md'
|
|
166
|
-
|| filePath === 'README.md';
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function countSignificantChangedFiles(changedFiles) {
|
|
170
|
-
return changedFiles.filter((filePath) => (
|
|
171
|
-
filePath.startsWith('bin/')
|
|
172
|
-
|| filePath.startsWith('lib/')
|
|
173
|
-
|| filePath.startsWith('scripts/')
|
|
174
|
-
|| filePath.startsWith('tests/')
|
|
175
|
-
)).length;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function detectSmallEdit(changedFiles) {
|
|
179
|
-
const nonLightweightChangedFiles = changedFiles.filter((filePath) => !isLightweightFilePath(filePath));
|
|
180
|
-
return nonLightweightChangedFiles.length <= 1 && changedFiles.length <= SMALL_EDIT_MAX_FILES;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function detectMajorFeatureCompletion(changedFiles) {
|
|
184
|
-
const significantChangedFileCount = countSignificantChangedFiles(changedFiles);
|
|
185
|
-
return significantChangedFileCount >= MAJOR_FEATURE_MIN_SIGNIFICANT_FILES;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function detectReviewIntentFromEnvironment() {
|
|
189
|
-
const githubEventName = String(process.env.GITHUB_EVENT_NAME || '').toLowerCase();
|
|
190
|
-
const githubEventAction = String(process.env.GITHUB_EVENT_ACTION || '').toLowerCase();
|
|
191
|
-
const gitlabMergeRequestId = String(process.env.CI_MERGE_REQUEST_IID || '').trim();
|
|
192
|
-
const ciPullRequestMarker = String(process.env.CI_PULL_REQUEST || '').toLowerCase();
|
|
193
|
-
const auditWorkflowHint = String(process.env.AUDIT_WORKFLOW || '').toLowerCase();
|
|
194
|
-
|
|
195
|
-
if (githubEventName.includes('pull_request') || githubEventAction.includes('pull_request')) {
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (gitlabMergeRequestId.length > 0) {
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (ciPullRequestMarker === 'true' || ciPullRequestMarker === '1') {
|
|
204
|
-
return true;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return auditWorkflowHint.includes('review') || auditWorkflowHint.includes('pr');
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function resolveAuditMode(options) {
|
|
211
|
-
const {
|
|
212
|
-
workflow,
|
|
213
|
-
manualForceStrict,
|
|
214
|
-
changedFiles,
|
|
215
|
-
} = options;
|
|
216
|
-
|
|
217
|
-
const smallEditDetected = detectSmallEdit(changedFiles);
|
|
218
|
-
const majorFeatureDetected = detectMajorFeatureCompletion(changedFiles);
|
|
219
|
-
|
|
220
|
-
if (manualForceStrict) {
|
|
221
|
-
return {
|
|
222
|
-
strictAuditMode: true,
|
|
223
|
-
triggerReason: 'manual-force-strict',
|
|
224
|
-
smallEditDetected,
|
|
225
|
-
majorFeatureDetected,
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (STRICT_WORKFLOWS.has(workflow)) {
|
|
230
|
-
return {
|
|
231
|
-
strictAuditMode: true,
|
|
232
|
-
triggerReason: `workflow-${workflow}`,
|
|
233
|
-
smallEditDetected,
|
|
234
|
-
majorFeatureDetected,
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
if (workflow === 'small-edit') {
|
|
239
|
-
return {
|
|
240
|
-
strictAuditMode: false,
|
|
241
|
-
triggerReason: 'workflow-small-edit-lightweight',
|
|
242
|
-
smallEditDetected: true,
|
|
243
|
-
majorFeatureDetected,
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (workflow === 'standard') {
|
|
248
|
-
return {
|
|
249
|
-
strictAuditMode: false,
|
|
250
|
-
triggerReason: 'workflow-standard-lightweight',
|
|
251
|
-
smallEditDetected,
|
|
252
|
-
majorFeatureDetected,
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (detectReviewIntentFromEnvironment()) {
|
|
257
|
-
return {
|
|
258
|
-
strictAuditMode: true,
|
|
259
|
-
triggerReason: 'auto-review-or-pr-intent',
|
|
260
|
-
smallEditDetected,
|
|
261
|
-
majorFeatureDetected,
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (majorFeatureDetected) {
|
|
266
|
-
return {
|
|
267
|
-
strictAuditMode: true,
|
|
268
|
-
triggerReason: 'auto-major-feature-completion',
|
|
269
|
-
smallEditDetected,
|
|
270
|
-
majorFeatureDetected,
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (smallEditDetected) {
|
|
275
|
-
return {
|
|
276
|
-
strictAuditMode: false,
|
|
277
|
-
triggerReason: 'auto-small-edit-lightweight',
|
|
278
|
-
smallEditDetected,
|
|
279
|
-
majorFeatureDetected,
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
return {
|
|
284
|
-
strictAuditMode: false,
|
|
285
|
-
triggerReason: 'auto-standard-lightweight',
|
|
286
|
-
smallEditDetected,
|
|
287
|
-
majorFeatureDetected,
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function assertChecklist(checklistLabel, checklistPath, requiredSnippets, failures, results) {
|
|
292
|
-
const absoluteChecklistPath = resolve(REPOSITORY_ROOT, checklistPath);
|
|
293
|
-
|
|
294
|
-
if (!existsSync(absoluteChecklistPath)) {
|
|
295
|
-
failures.push(`Missing ${checklistLabel} checklist: ${checklistPath}`);
|
|
296
|
-
pushResult(results, false, `${checklistLabel}-checklist-exists`, `Missing ${checklistPath}`);
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
pushResult(results, true, `${checklistLabel}-checklist-exists`, `${checklistPath} is present`);
|
|
301
|
-
|
|
302
|
-
const checklistContent = readFileSync(absoluteChecklistPath, 'utf8');
|
|
303
|
-
const missingChecklistSnippets = requiredSnippets.filter(
|
|
304
|
-
(requiredSnippet) => !checklistContent.includes(requiredSnippet)
|
|
305
|
-
);
|
|
306
|
-
|
|
307
|
-
if (missingChecklistSnippets.length > 0) {
|
|
308
|
-
failures.push(`Missing ${checklistLabel} checklist snippets: ${missingChecklistSnippets.join(', ')}`);
|
|
309
|
-
pushResult(
|
|
310
|
-
results,
|
|
311
|
-
false,
|
|
312
|
-
`${checklistLabel}-checklist-coverage`,
|
|
313
|
-
`Missing snippets in ${checklistPath}: ${missingChecklistSnippets.join(', ')}`
|
|
314
|
-
);
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
pushResult(results, true, `${checklistLabel}-checklist-coverage`, `${checklistLabel} checklist snippets are complete`);
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function runAudit() {
|
|
322
|
-
const parsedArguments = parseCliArguments(process.argv.slice(2));
|
|
323
|
-
const changedScope = collectChangedFiles();
|
|
324
|
-
const changedFiles = changedScope.files;
|
|
325
|
-
|
|
326
|
-
const auditMode = resolveAuditMode({
|
|
327
|
-
workflow: parsedArguments.workflow,
|
|
328
|
-
manualForceStrict: parsedArguments.strict,
|
|
329
|
-
changedFiles,
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
const results = [];
|
|
333
|
-
const failures = [];
|
|
334
|
-
|
|
335
|
-
pushResult(results, true, 'context-workflow', `workflow=${parsedArguments.workflow}`);
|
|
336
|
-
pushResult(
|
|
337
|
-
results,
|
|
338
|
-
true,
|
|
339
|
-
'manual-force-strict-flag',
|
|
340
|
-
parsedArguments.strict ? 'Manual strict mode requested' : 'Manual strict mode not requested'
|
|
341
|
-
);
|
|
342
|
-
|
|
343
|
-
if (auditMode.strictAuditMode) {
|
|
344
|
-
pushResult(results, true, 'strict-audit-activation', `Strict audit mode activated (${auditMode.triggerReason})`);
|
|
345
|
-
|
|
346
|
-
assertChecklist(
|
|
347
|
-
'pr',
|
|
348
|
-
PR_CHECKLIST_PATH,
|
|
349
|
-
REQUIRED_PR_CHECKLIST_SNIPPETS,
|
|
350
|
-
failures,
|
|
351
|
-
results
|
|
352
|
-
);
|
|
353
|
-
assertChecklist(
|
|
354
|
-
'architecture',
|
|
355
|
-
ARCHITECTURE_CHECKLIST_PATH,
|
|
356
|
-
REQUIRED_ARCHITECTURE_CHECKLIST_SNIPPETS,
|
|
357
|
-
failures,
|
|
358
|
-
results
|
|
359
|
-
);
|
|
360
|
-
} else {
|
|
361
|
-
pushResult(
|
|
362
|
-
results,
|
|
363
|
-
true,
|
|
364
|
-
'strict-audit-lightweight-mode',
|
|
365
|
-
`Strict audits skipped to avoid heavy mode (${auditMode.triggerReason})`
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
const reportPayload = {
|
|
370
|
-
generatedAt: new Date().toISOString(),
|
|
371
|
-
auditName: 'context-triggered-audit',
|
|
372
|
-
workflow: parsedArguments.workflow,
|
|
373
|
-
source: changedScope.source,
|
|
374
|
-
changedFileCount: changedFiles.length,
|
|
375
|
-
changedFiles,
|
|
376
|
-
userForcedStrictMode: parsedArguments.strict,
|
|
377
|
-
strictAuditMode: auditMode.strictAuditMode,
|
|
378
|
-
triggerReason: auditMode.triggerReason,
|
|
379
|
-
smallEditDetected: auditMode.smallEditDetected,
|
|
380
|
-
majorFeatureDetected: auditMode.majorFeatureDetected,
|
|
381
|
-
passed: failures.length === 0,
|
|
382
|
-
failureCount: failures.length,
|
|
383
|
-
failures,
|
|
384
|
-
results,
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
console.log(JSON.stringify(reportPayload, null, 2));
|
|
388
|
-
process.exit(reportPayload.passed ? 0 : 1);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
runAudit();
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* detection-benchmark.mjs
|
|
5
|
-
*
|
|
6
|
-
* Lightweight benchmark for stack detection heuristics used by the CLI.
|
|
7
|
-
* Publishes top-1 accuracy and manual-correction-rate proxy.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const AMBIGUITY_THRESHOLD = 0.08;
|
|
11
|
-
|
|
12
|
-
const BENCHMARK_FIXTURES = [
|
|
13
|
-
{ fixtureName: 'typescript-basic', markers: ['package.json', 'tsconfig.json'], expectedStack: 'typescript.md' },
|
|
14
|
-
{ fixtureName: 'typescript-next', markers: ['package.json', 'tsconfig.json', 'next.config.js'], expectedStack: 'typescript.md' },
|
|
15
|
-
{ fixtureName: 'python-poetry', markers: ['pyproject.toml'], expectedStack: 'python.md' },
|
|
16
|
-
{ fixtureName: 'python-requirements', markers: ['requirements.txt'], expectedStack: 'python.md' },
|
|
17
|
-
{ fixtureName: 'java-maven', markers: ['pom.xml'], expectedStack: 'java.md' },
|
|
18
|
-
{ fixtureName: 'java-gradle', markers: ['build.gradle'], expectedStack: 'java.md' },
|
|
19
|
-
{ fixtureName: 'php-composer', markers: ['composer.json'], expectedStack: 'php.md' },
|
|
20
|
-
{ fixtureName: 'go-module', markers: ['go.mod'], expectedStack: 'go.md' },
|
|
21
|
-
{ fixtureName: 'dotnet-solution', markers: ['app.sln'], expectedStack: 'csharp.md' },
|
|
22
|
-
{ fixtureName: 'rust-cargo', markers: ['Cargo.toml'], expectedStack: 'rust.md' },
|
|
23
|
-
{ fixtureName: 'ruby-gemfile', markers: ['Gemfile'], expectedStack: 'ruby.md' },
|
|
24
|
-
{ fixtureName: 'mixed-ts-python', markers: ['package.json', 'tsconfig.json', 'pyproject.toml'], expectedStack: 'typescript.md' },
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
function detectProjectFromMarkers(markers) {
|
|
28
|
-
const markerNames = new Set(markers);
|
|
29
|
-
const candidates = [];
|
|
30
|
-
|
|
31
|
-
if (markerNames.has('package.json') || markerNames.has('tsconfig.json') || markerNames.has('next.config.js') || markerNames.has('next.config.mjs')) {
|
|
32
|
-
let confidenceScore = 0.7;
|
|
33
|
-
if (markerNames.has('package.json')) confidenceScore += 0.12;
|
|
34
|
-
if (markerNames.has('tsconfig.json')) confidenceScore += 0.12;
|
|
35
|
-
if (markerNames.has('next.config.js') || markerNames.has('next.config.mjs')) confidenceScore += 0.05;
|
|
36
|
-
candidates.push({ stackFileName: 'typescript.md', confidenceScore: Math.min(confidenceScore, 0.97) });
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (markerNames.has('pyproject.toml') || markerNames.has('requirements.txt')) {
|
|
40
|
-
candidates.push({
|
|
41
|
-
stackFileName: 'python.md',
|
|
42
|
-
confidenceScore: markerNames.has('pyproject.toml') ? 0.96 : 0.78,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (markerNames.has('pom.xml') || markerNames.has('build.gradle') || markerNames.has('build.gradle.kts')) {
|
|
47
|
-
candidates.push({
|
|
48
|
-
stackFileName: 'java.md',
|
|
49
|
-
confidenceScore: markerNames.has('pom.xml') ? 0.95 : 0.84,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (markerNames.has('composer.json')) candidates.push({ stackFileName: 'php.md', confidenceScore: 0.95 });
|
|
54
|
-
if (markerNames.has('go.mod')) candidates.push({ stackFileName: 'go.md', confidenceScore: 0.96 });
|
|
55
|
-
if (markerNames.has('Cargo.toml')) candidates.push({ stackFileName: 'rust.md', confidenceScore: 0.96 });
|
|
56
|
-
if (markerNames.has('Gemfile')) candidates.push({ stackFileName: 'ruby.md', confidenceScore: 0.95 });
|
|
57
|
-
|
|
58
|
-
const hasDotNetMarker = Array.from(markerNames).some((markerName) => markerName.endsWith('.sln') || markerName.endsWith('.csproj'));
|
|
59
|
-
if (hasDotNetMarker) {
|
|
60
|
-
candidates.push({ stackFileName: 'csharp.md', confidenceScore: 0.95 });
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (candidates.length === 0) {
|
|
64
|
-
return {
|
|
65
|
-
detectedStack: null,
|
|
66
|
-
confidenceScore: 0,
|
|
67
|
-
confidenceGap: 0,
|
|
68
|
-
needsManualCorrection: true,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
candidates.sort((leftCandidate, rightCandidate) => rightCandidate.confidenceScore - leftCandidate.confidenceScore);
|
|
73
|
-
const strongestCandidate = candidates[0];
|
|
74
|
-
const secondStrongestCandidate = candidates[1];
|
|
75
|
-
const confidenceGap = secondStrongestCandidate
|
|
76
|
-
? Number((strongestCandidate.confidenceScore - secondStrongestCandidate.confidenceScore).toFixed(2))
|
|
77
|
-
: Number(strongestCandidate.confidenceScore.toFixed(2));
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
detectedStack: strongestCandidate.stackFileName,
|
|
81
|
-
confidenceScore: strongestCandidate.confidenceScore,
|
|
82
|
-
confidenceGap,
|
|
83
|
-
needsManualCorrection: confidenceGap < AMBIGUITY_THRESHOLD,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function runBenchmark() {
|
|
88
|
-
let passingFixtureCount = 0;
|
|
89
|
-
let manualCorrectionCount = 0;
|
|
90
|
-
|
|
91
|
-
const fixtureResults = BENCHMARK_FIXTURES.map((benchmarkFixture) => {
|
|
92
|
-
const detectionResult = detectProjectFromMarkers(benchmarkFixture.markers);
|
|
93
|
-
const isCorrect = detectionResult.detectedStack === benchmarkFixture.expectedStack;
|
|
94
|
-
|
|
95
|
-
if (isCorrect) {
|
|
96
|
-
passingFixtureCount += 1;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (detectionResult.needsManualCorrection) {
|
|
100
|
-
manualCorrectionCount += 1;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
fixtureName: benchmarkFixture.fixtureName,
|
|
105
|
-
expectedStack: benchmarkFixture.expectedStack,
|
|
106
|
-
detectedStack: detectionResult.detectedStack,
|
|
107
|
-
confidenceGap: detectionResult.confidenceGap,
|
|
108
|
-
needsManualCorrection: detectionResult.needsManualCorrection,
|
|
109
|
-
isCorrect,
|
|
110
|
-
};
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const totalFixtureCount = BENCHMARK_FIXTURES.length;
|
|
114
|
-
const top1Accuracy = Number((passingFixtureCount / totalFixtureCount).toFixed(4));
|
|
115
|
-
const manualCorrectionRate = Number((manualCorrectionCount / totalFixtureCount).toFixed(4));
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
generatedAt: new Date().toISOString(),
|
|
119
|
-
fixtureCount: totalFixtureCount,
|
|
120
|
-
top1Accuracy,
|
|
121
|
-
manualCorrectionRate,
|
|
122
|
-
fixtures: fixtureResults,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const benchmarkResult = runBenchmark();
|
|
127
|
-
console.log(JSON.stringify(benchmarkResult, null, 2));
|