@ryuenn3123/agentic-senior-core 2.5.14 → 2.5.16
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/prompts/review-code.md +2 -0
- package/.agent-context/review-checklists/frontend-excellence-rubric.md +12 -2
- package/.agent-context/review-checklists/frontend-usability.md +1 -0
- package/.agent-context/review-checklists/pr-checklist.md +10 -0
- package/.agent-context/rules/architecture.md +17 -0
- package/.agent-context/rules/frontend-architecture.md +7 -0
- package/.agent-context/state/memory-continuity-benchmark.json +1 -1
- package/.agent-context/state/onboarding-report.json +11 -2
- package/.cursorrules +2 -2
- package/.windsurfrules +2 -2
- package/lib/cli/compiler.mjs +20 -1
- package/package.json +3 -1
- package/scripts/explain-on-demand-audit.mjs +426 -0
- package/scripts/frontend-usability-audit.mjs +5 -0
- package/scripts/release-gate.mjs +164 -0
- package/scripts/single-source-lazy-loading-audit.mjs +535 -0
- package/scripts/validate.mjs +2 -0
|
@@ -18,6 +18,8 @@ Use these checklists:
|
|
|
18
18
|
5. Enforce documentation hard blockers on changed boundaries: public surface changes, API contract changes, and database structure changes must include synchronized documentation updates.
|
|
19
19
|
6. Enforce context-triggered strict audits: review requests, PR-intent workflows, and major feature completion must run strict security and performance audits; small edits stay lightweight unless strict mode is explicitly forced.
|
|
20
20
|
7. Enforce cross-session consistency guardian: session handoff must include active architecture contract summary, drift detection must warn before direction changes, and direction changes require explicit user confirmation.
|
|
21
|
+
8. Enforce explain-on-demand state visibility: default responses must avoid unnecessary state-file internals, state internals are exposed only on explicit request, and diagnostic mode must explain relevant state decisions when needed.
|
|
22
|
+
9. Enforce single-source and lazy-loading policy: canonical rule source must be explicitly enforced, language-specific guidance must load lazily based on detected scope, and conflicting duplicate rule instructions must not appear during normal flow.
|
|
21
23
|
|
|
22
24
|
For EVERY violation found:
|
|
23
25
|
- State the exact file and line
|
|
@@ -38,12 +38,22 @@ Release recommendation:
|
|
|
38
38
|
- [ ] Breakpoint transitions preserve hierarchy, spacing rhythm, and action clarity.
|
|
39
39
|
- [ ] Navigation and key CTA remain explicit across viewport sizes.
|
|
40
40
|
|
|
41
|
-
## 6.
|
|
41
|
+
## 6. Language and Content Consistency
|
|
42
|
+
- [ ] Content language is consistent across headline, body, CTA, and system messages for the same screen flow.
|
|
43
|
+
- [ ] Mixed-language output appears only when requested by user or product requirement.
|
|
44
|
+
- [ ] Terminology stays stable for repeated actions and labels.
|
|
45
|
+
|
|
46
|
+
## 7. Text Contrast and Collision Safety
|
|
47
|
+
- [ ] Text-to-background contrast is checked for every semantic token pair used in UI.
|
|
48
|
+
- [ ] No text color clashes with gradients, images, or accent surfaces.
|
|
49
|
+
- [ ] Primary and secondary text remain readable in all supported breakpoints.
|
|
50
|
+
|
|
51
|
+
## 8. UX Narrative and Conversion Clarity
|
|
42
52
|
- [ ] First viewport communicates value proposition and primary action immediately.
|
|
43
53
|
- [ ] Error, empty, and loading states provide clear next actions.
|
|
44
54
|
- [ ] User journey avoids dead ends and hidden critical actions.
|
|
45
55
|
|
|
46
|
-
##
|
|
56
|
+
## 9. Template Diversity and Originality
|
|
47
57
|
- [ ] Output is not a copy of a generic starter template or repeated AI layout pattern.
|
|
48
58
|
- [ ] Layout composition shows intentional variation in structure and hierarchy.
|
|
49
59
|
- [ ] Visual intent, interaction quality, and conversion clarity are all explicitly reviewed together.
|
|
@@ -6,6 +6,7 @@ Run this checklist before claiming frontend work is production-ready.
|
|
|
6
6
|
- [ ] Typography scale is consistent and tokenized.
|
|
7
7
|
- [ ] Color usage follows design tokens and avoids ad-hoc values.
|
|
8
8
|
- [ ] Spacing and layout rhythm is coherent across pages.
|
|
9
|
+
- [ ] Language and terminology stay consistent across headline, body, and CTA for the same flow.
|
|
9
10
|
|
|
10
11
|
## 2. Responsiveness
|
|
11
12
|
- [ ] Core pages are usable at mobile, tablet, and desktop breakpoints.
|
|
@@ -119,3 +119,13 @@ VERDICT: PASS / FAIL (X/Y items passed)
|
|
|
119
119
|
- [ ] Session handoff includes active architecture contract summary
|
|
120
120
|
- [ ] Drift detection warns before direction changes
|
|
121
121
|
- [ ] Direction changes require explicit user confirmation
|
|
122
|
+
|
|
123
|
+
### 13. Invisible State Management (Explain-on-Demand)
|
|
124
|
+
- [ ] Default responses avoid unnecessary state-file internals
|
|
125
|
+
- [ ] State internals are exposed only on explicit request
|
|
126
|
+
- [ ] Diagnostic mode can explain relevant state decisions when needed
|
|
127
|
+
|
|
128
|
+
### 14. Single Source and Lazy Rule Loading
|
|
129
|
+
- [ ] Canonical rule source is explicitly defined and enforced
|
|
130
|
+
- [ ] Language-specific guidance is loaded lazily based on detected scope
|
|
131
|
+
- [ ] No conflicting duplicate rule instructions during normal flow
|
|
@@ -23,6 +23,23 @@ These guardrails are mandatory to preserve architecture direction across session
|
|
|
23
23
|
- Direction changes require explicit user confirmation before applying changes.
|
|
24
24
|
- When confirmation is provided, record the rationale in session notes or PR context.
|
|
25
25
|
|
|
26
|
+
## Invisible State Management with Explain-on-Demand
|
|
27
|
+
|
|
28
|
+
State internals must stay invisible by default.
|
|
29
|
+
|
|
30
|
+
- Default responses must avoid unnecessary state-file internals.
|
|
31
|
+
- State internals are exposed only on explicit user request.
|
|
32
|
+
- Diagnostic mode explains relevant state decisions when needed.
|
|
33
|
+
- Keep default explanations concise and outcome-first; show raw state details only in diagnostic mode.
|
|
34
|
+
|
|
35
|
+
## Single Source of Truth and Lazy Rule Loading
|
|
36
|
+
|
|
37
|
+
- Canonical rule source is .instructions.md.
|
|
38
|
+
- Adapter entry files stay thin and must point to the canonical source.
|
|
39
|
+
- Load language-specific stack guidance lazily based on detected scope.
|
|
40
|
+
- Do not preload unrelated stack profiles during normal flow.
|
|
41
|
+
- Keep rule-loading output deterministic for init and release validation.
|
|
42
|
+
|
|
26
43
|
## The Core Principle
|
|
27
44
|
|
|
28
45
|
**Every layer has ONE job. Layer leaks are bugs — not "pragmatic shortcuts."**
|
|
@@ -16,6 +16,13 @@ Mandatory behavior when triggered:
|
|
|
16
16
|
- score and review generated UI work against visual intent, interaction quality, and conversion clarity
|
|
17
17
|
- reject template-only repetitive outputs and force a distinct layout direction
|
|
18
18
|
|
|
19
|
+
## UI Consistency Guardrails (Mandatory)
|
|
20
|
+
|
|
21
|
+
- Content language must stay consistent per screen and flow unless user requests multilingual output.
|
|
22
|
+
- Text color must remain contrast-safe against its background; no color collisions.
|
|
23
|
+
- Layout must avoid overlap, clipped text, and misaligned key actions across breakpoints.
|
|
24
|
+
- Keep spacing and positioning token-driven so repeated outputs stay stable.
|
|
25
|
+
|
|
19
26
|
## 1. File Structure (Feature-Driven Design)
|
|
20
27
|
Organize your application by feature domain, not by file type.
|
|
21
28
|
- **BANNED:** Monolithic directories like `/components` (with 500 files), `/hooks`, `/api`.
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"cliVersion": "2.
|
|
3
|
-
"generatedAt": "2026-04-
|
|
2
|
+
"cliVersion": "2.5.16",
|
|
3
|
+
"generatedAt": "2026-04-18T00:00:00.000Z",
|
|
4
4
|
"operationMode": "upgrade",
|
|
5
5
|
"selectedProfile": "beginner",
|
|
6
6
|
"selectedProfilePack": null,
|
|
7
7
|
"selectedStack": "typescript.md",
|
|
8
|
+
"selectedAdditionalStacks": [],
|
|
8
9
|
"selectedBlueprint": "api-nextjs.md",
|
|
10
|
+
"selectedAdditionalBlueprints": [],
|
|
11
|
+
"ruleLoadingPolicy": {
|
|
12
|
+
"canonicalSource": ".instructions.md",
|
|
13
|
+
"stackLoadingMode": "lazy",
|
|
14
|
+
"loadedOnDemand": true,
|
|
15
|
+
"primaryStack": "typescript.md",
|
|
16
|
+
"additionalStacks": []
|
|
17
|
+
},
|
|
9
18
|
"ciGuardrailsEnabled": true,
|
|
10
19
|
"setupDurationMs": 106,
|
|
11
20
|
"selectedSkillDomains": [],
|
package/.cursorrules
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# AGENTIC-SENIOR-CORE DYNAMIC GOVERNANCE RULESET
|
|
2
2
|
|
|
3
|
-
Generated by Agentic-Senior-Core CLI v2.5.
|
|
4
|
-
Timestamp: 2026-04-
|
|
3
|
+
Generated by Agentic-Senior-Core CLI v2.5.16
|
|
4
|
+
Timestamp: 2026-04-18T00:00:00.000Z
|
|
5
5
|
Selected profile: beginner
|
|
6
6
|
Selected policy file: .agent-context/policies/llm-judge-threshold.json
|
|
7
7
|
|
package/.windsurfrules
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# AGENTIC-SENIOR-CORE DYNAMIC GOVERNANCE RULESET
|
|
2
2
|
|
|
3
|
-
Generated by Agentic-Senior-Core CLI v2.5.
|
|
4
|
-
Timestamp: 2026-04-
|
|
3
|
+
Generated by Agentic-Senior-Core CLI v2.5.16
|
|
4
|
+
Timestamp: 2026-04-18T00:00:00.000Z
|
|
5
5
|
Selected profile: beginner
|
|
6
6
|
Selected policy file: .agent-context/policies/llm-judge-threshold.json
|
|
7
7
|
|
package/lib/cli/compiler.mjs
CHANGED
|
@@ -80,6 +80,13 @@ export async function writeOnboardingReport({
|
|
|
80
80
|
selectedAdditionalStacks: selectedAdditionalStackFileNames,
|
|
81
81
|
selectedBlueprint: selectedBlueprintFileName,
|
|
82
82
|
selectedAdditionalBlueprints: selectedAdditionalBlueprintFileNames,
|
|
83
|
+
ruleLoadingPolicy: {
|
|
84
|
+
canonicalSource: '.instructions.md',
|
|
85
|
+
stackLoadingMode: 'lazy',
|
|
86
|
+
loadedOnDemand: true,
|
|
87
|
+
primaryStack: selectedStackFileName,
|
|
88
|
+
additionalStacks: selectedAdditionalStackFileNames,
|
|
89
|
+
},
|
|
83
90
|
ciGuardrailsEnabled: includeCiGuardrails,
|
|
84
91
|
setupDurationMs,
|
|
85
92
|
selectedSkillDomains,
|
|
@@ -174,7 +181,7 @@ export async function buildCompiledRulesContent({
|
|
|
174
181
|
'## BOOTSTRAP CHAIN (MANDATORY)',
|
|
175
182
|
'Load every layer before responding. Do not skip steps:',
|
|
176
183
|
'1. .agent-context/rules/',
|
|
177
|
-
'2. .agent-context/stacks/',
|
|
184
|
+
'2. .agent-context/stacks/ (lazy by task scope)',
|
|
178
185
|
'3. .agent-context/blueprints/',
|
|
179
186
|
'4. .agent-context/skills/',
|
|
180
187
|
'5. .agent-context/prompts/',
|
|
@@ -220,6 +227,18 @@ export async function buildCompiledRulesContent({
|
|
|
220
227
|
);
|
|
221
228
|
}
|
|
222
229
|
|
|
230
|
+
contextBlocks.push(
|
|
231
|
+
[
|
|
232
|
+
'## LAYER 2 POLICY: LAZY RULE LOADING',
|
|
233
|
+
`Primary stack profile is always loaded for this project: .agent-context/stacks/${selectedStackFileName}`,
|
|
234
|
+
normalizedAdditionalStackFileNames.length > 0
|
|
235
|
+
? `Additional stack profiles load on demand: ${normalizedAdditionalStackFileNames.map((stackFileName) => `.agent-context/stacks/${stackFileName}`).join(', ')}`
|
|
236
|
+
: 'Additional stack profiles load only when explicitly selected or detected.',
|
|
237
|
+
'Load stack guidance only when task scope touches that stack.',
|
|
238
|
+
'Avoid eager loading unrelated stack profiles to prevent instruction conflicts.',
|
|
239
|
+
].join('\n')
|
|
240
|
+
);
|
|
241
|
+
|
|
223
242
|
const blueprintFilePath = path.join(selectedBlueprintsDirectoryPath, selectedBlueprintFileName);
|
|
224
243
|
const blueprintContent = await fs.readFile(blueprintFilePath, 'utf8');
|
|
225
244
|
const blueprintSummary = firstMarkdownHeading(blueprintContent, selectedBlueprintFileName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryuenn3123/agentic-senior-core",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Force your AI Agent to code like a Staff Engineer, not a Junior.",
|
|
6
6
|
"bin": {
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
"audit:documentation-boundary": "node ./scripts/documentation-boundary-audit.mjs",
|
|
47
47
|
"audit:context-triggered": "node ./scripts/context-triggered-audit.mjs",
|
|
48
48
|
"audit:rules-guardian": "node ./scripts/rules-guardian-audit.mjs",
|
|
49
|
+
"audit:explain-on-demand": "node ./scripts/explain-on-demand-audit.mjs",
|
|
50
|
+
"audit:single-source-lazy-loading": "node ./scripts/single-source-lazy-loading-audit.mjs",
|
|
49
51
|
"gate:release": "node ./scripts/release-gate.mjs && node ./scripts/forbidden-content-check.mjs",
|
|
50
52
|
"prepublishOnly": "npm run gate:release",
|
|
51
53
|
"sbom:generate": "node ./scripts/generate-sbom.mjs",
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* explain-on-demand-audit.mjs
|
|
5
|
+
*
|
|
6
|
+
* Enforces invisible state management defaults and explicit diagnostic
|
|
7
|
+
* visibility rules for state internals.
|
|
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 ONBOARDING_REPORT_PATH = '.agent-context/state/onboarding-report.json';
|
|
20
|
+
const ARCHITECTURE_RULE_PATH = '.agent-context/rules/architecture.md';
|
|
21
|
+
const PR_CHECKLIST_PATH = '.agent-context/review-checklists/pr-checklist.md';
|
|
22
|
+
const REVIEW_PROMPT_PATH = '.agent-context/prompts/review-code.md';
|
|
23
|
+
|
|
24
|
+
const DEFAULT_MODE = 'default';
|
|
25
|
+
const SUPPORTED_MODES = new Set([DEFAULT_MODE, 'diagnostic']);
|
|
26
|
+
const DEFAULT_WORKFLOW = 'standard';
|
|
27
|
+
|
|
28
|
+
const REQUIRED_ARCHITECTURE_RULE_SNIPPETS = [
|
|
29
|
+
'## Invisible State Management with Explain-on-Demand',
|
|
30
|
+
'Default responses must avoid unnecessary state-file internals.',
|
|
31
|
+
'State internals are exposed only on explicit user request.',
|
|
32
|
+
'Diagnostic mode explains relevant state decisions when needed.',
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const REQUIRED_PR_CHECKLIST_SNIPPETS = [
|
|
36
|
+
'Default responses avoid unnecessary state-file internals',
|
|
37
|
+
'State internals are exposed only on explicit request',
|
|
38
|
+
'Diagnostic mode can explain relevant state decisions when needed',
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const REQUIRED_REVIEW_PROMPT_SNIPPETS = [
|
|
42
|
+
'Enforce explain-on-demand state visibility: default responses must avoid unnecessary state-file internals, state internals are exposed only on explicit request, and diagnostic mode must explain relevant state decisions when needed.',
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const INTERNAL_STATE_SIGNAL_PATTERNS = [
|
|
46
|
+
/\.agent-context\/state\//i,
|
|
47
|
+
/\bautoDetection\b/i,
|
|
48
|
+
/\brankedCandidates\b/i,
|
|
49
|
+
/\bconfidenceGap\b/i,
|
|
50
|
+
/\bschemaVersion\b/i,
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
function pushResult(results, isPassed, checkName, details) {
|
|
54
|
+
results.push({
|
|
55
|
+
checkName,
|
|
56
|
+
passed: isPassed,
|
|
57
|
+
details,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function normalizeFilePath(filePath) {
|
|
62
|
+
return filePath.replace(/\\/g, '/').replace(/^\.\//, '');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function parseGitFileList(rawOutput) {
|
|
66
|
+
if (typeof rawOutput !== 'string' || rawOutput.trim().length === 0) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return rawOutput
|
|
71
|
+
.split(/\r?\n/)
|
|
72
|
+
.map((filePath) => filePath.trim())
|
|
73
|
+
.filter((filePath) => filePath.length > 0)
|
|
74
|
+
.map(normalizeFilePath);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function runGitFileQuery(commandArguments) {
|
|
78
|
+
try {
|
|
79
|
+
const rawOutput = execFileSync('git', commandArguments, {
|
|
80
|
+
cwd: REPOSITORY_ROOT,
|
|
81
|
+
encoding: 'utf8',
|
|
82
|
+
maxBuffer: 1024 * 1024,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return parseGitFileList(rawOutput);
|
|
86
|
+
} catch {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function uniqueSorted(filePaths) {
|
|
92
|
+
return Array.from(new Set(filePaths)).sort((leftPath, rightPath) => leftPath.localeCompare(rightPath));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function collectChangedFiles() {
|
|
96
|
+
const workingTreeFiles = runGitFileQuery(['diff', '--name-only']);
|
|
97
|
+
const stagedFiles = runGitFileQuery(['diff', '--name-only', '--cached']);
|
|
98
|
+
const workingScopeFiles = uniqueSorted([...workingTreeFiles, ...stagedFiles]);
|
|
99
|
+
|
|
100
|
+
if (workingScopeFiles.length > 0) {
|
|
101
|
+
return {
|
|
102
|
+
source: 'working-tree-and-index',
|
|
103
|
+
files: workingScopeFiles,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const latestCommitRangeFiles = runGitFileQuery(['diff', '--name-only', 'HEAD~1..HEAD']);
|
|
108
|
+
if (latestCommitRangeFiles.length > 0) {
|
|
109
|
+
return {
|
|
110
|
+
source: 'latest-commit-range',
|
|
111
|
+
files: uniqueSorted(latestCommitRangeFiles),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const headCommitFiles = runGitFileQuery(['show', '--pretty=format:', '--name-only', 'HEAD']);
|
|
116
|
+
if (headCommitFiles.length > 0) {
|
|
117
|
+
return {
|
|
118
|
+
source: 'head-commit',
|
|
119
|
+
files: uniqueSorted(headCommitFiles),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
source: 'none',
|
|
125
|
+
files: [],
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function readText(relativeFilePath) {
|
|
130
|
+
const absolutePath = resolve(REPOSITORY_ROOT, relativeFilePath);
|
|
131
|
+
if (!existsSync(absolutePath)) {
|
|
132
|
+
return '';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return readFileSync(absolutePath, 'utf8');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function parseOnboardingReport(onboardingReportContent) {
|
|
139
|
+
if (typeof onboardingReportContent !== 'string' || onboardingReportContent.trim().length === 0) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
return JSON.parse(onboardingReportContent);
|
|
145
|
+
} catch {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function parseCliArguments(argumentList) {
|
|
151
|
+
let mode = DEFAULT_MODE;
|
|
152
|
+
let workflow = DEFAULT_WORKFLOW;
|
|
153
|
+
let explicitStateRequest = false;
|
|
154
|
+
|
|
155
|
+
for (let argumentIndex = 0; argumentIndex < argumentList.length; argumentIndex += 1) {
|
|
156
|
+
const argumentValue = argumentList[argumentIndex];
|
|
157
|
+
|
|
158
|
+
if (argumentValue === '--state-debug') {
|
|
159
|
+
explicitStateRequest = true;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (argumentValue === '--mode') {
|
|
164
|
+
const nextArgumentValue = argumentList[argumentIndex + 1];
|
|
165
|
+
if (nextArgumentValue && !nextArgumentValue.startsWith('--')) {
|
|
166
|
+
mode = nextArgumentValue;
|
|
167
|
+
argumentIndex += 1;
|
|
168
|
+
}
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (argumentValue.startsWith('--mode=')) {
|
|
173
|
+
mode = argumentValue.slice('--mode='.length);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
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 normalizedMode = String(mode || '').trim().toLowerCase();
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
mode: SUPPORTED_MODES.has(normalizedMode) ? normalizedMode : DEFAULT_MODE,
|
|
195
|
+
workflow: String(workflow || '').trim().toLowerCase() || DEFAULT_WORKFLOW,
|
|
196
|
+
explicitStateRequest,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function assertSnippetCoverage(sourceLabel, sourcePath, requiredSnippets, failures, results) {
|
|
201
|
+
const sourceContent = readText(sourcePath);
|
|
202
|
+
|
|
203
|
+
if (!sourceContent) {
|
|
204
|
+
failures.push(`Missing ${sourceLabel} source: ${sourcePath}`);
|
|
205
|
+
pushResult(results, false, `${sourceLabel}-source-exists`, `Missing ${sourcePath}`);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
pushResult(results, true, `${sourceLabel}-source-exists`, `${sourcePath} is present`);
|
|
210
|
+
|
|
211
|
+
const missingSnippets = requiredSnippets.filter((requiredSnippet) => !sourceContent.includes(requiredSnippet));
|
|
212
|
+
|
|
213
|
+
if (missingSnippets.length > 0) {
|
|
214
|
+
failures.push(`Missing ${sourceLabel} snippets: ${missingSnippets.join(', ')}`);
|
|
215
|
+
pushResult(
|
|
216
|
+
results,
|
|
217
|
+
false,
|
|
218
|
+
`${sourceLabel}-source-coverage`,
|
|
219
|
+
`Missing snippets in ${sourcePath}: ${missingSnippets.join(', ')}`
|
|
220
|
+
);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
pushResult(results, true, `${sourceLabel}-source-coverage`, `${sourceLabel} snippets are complete`);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function buildDefaultResponseSummary(onboardingReport) {
|
|
228
|
+
const selectedStack = String(onboardingReport?.selectedStack || 'unknown-stack').trim() || 'unknown-stack';
|
|
229
|
+
const selectedBlueprint = String(onboardingReport?.selectedBlueprint || 'unknown-blueprint').trim() || 'unknown-blueprint';
|
|
230
|
+
const selectedProfile = String(onboardingReport?.selectedProfile || 'unknown-profile').trim() || 'unknown-profile';
|
|
231
|
+
|
|
232
|
+
return `Active setup summary: stack=${selectedStack}, blueprint=${selectedBlueprint}, profile=${selectedProfile}.`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function detectInternalSignals(textValue) {
|
|
236
|
+
const normalizedText = String(textValue || '');
|
|
237
|
+
return INTERNAL_STATE_SIGNAL_PATTERNS.some((signalPattern) => signalPattern.test(normalizedText));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function buildDiagnosticDecisionSummaries(onboardingReport) {
|
|
241
|
+
const explanations = [];
|
|
242
|
+
|
|
243
|
+
const selectedStack = String(onboardingReport?.selectedStack || '').trim();
|
|
244
|
+
if (selectedStack) {
|
|
245
|
+
explanations.push(`Stack decision: selectedStack=${selectedStack}.`);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const selectedBlueprint = String(onboardingReport?.selectedBlueprint || '').trim();
|
|
249
|
+
if (selectedBlueprint) {
|
|
250
|
+
explanations.push(`Blueprint decision: selectedBlueprint=${selectedBlueprint}.`);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const selectedProfile = String(onboardingReport?.selectedProfile || '').trim();
|
|
254
|
+
if (selectedProfile) {
|
|
255
|
+
explanations.push(`Profile decision: selectedProfile=${selectedProfile}.`);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const detectionReasoning = String(onboardingReport?.autoDetection?.detectionReasoning || '').trim();
|
|
259
|
+
if (detectionReasoning) {
|
|
260
|
+
explanations.push(`Detection reasoning: ${detectionReasoning}`);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (typeof onboardingReport?.ciGuardrailsEnabled === 'boolean') {
|
|
264
|
+
explanations.push(`CI guardrails decision: ciGuardrailsEnabled=${String(onboardingReport.ciGuardrailsEnabled)}.`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return explanations;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function runAudit() {
|
|
271
|
+
const parsedArguments = parseCliArguments(process.argv.slice(2));
|
|
272
|
+
const changedScope = collectChangedFiles();
|
|
273
|
+
const changedFiles = changedScope.files;
|
|
274
|
+
const results = [];
|
|
275
|
+
const failures = [];
|
|
276
|
+
const warnings = [];
|
|
277
|
+
|
|
278
|
+
pushResult(results, true, 'context-workflow', `workflow=${parsedArguments.workflow}`);
|
|
279
|
+
pushResult(results, true, 'explain-mode', `mode=${parsedArguments.mode}`);
|
|
280
|
+
pushResult(
|
|
281
|
+
results,
|
|
282
|
+
true,
|
|
283
|
+
'state-debug-explicit-request',
|
|
284
|
+
parsedArguments.explicitStateRequest
|
|
285
|
+
? 'Explicit state diagnostic request received'
|
|
286
|
+
: 'No explicit state diagnostic request provided'
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
assertSnippetCoverage(
|
|
290
|
+
'explain-on-demand-architecture-rule',
|
|
291
|
+
ARCHITECTURE_RULE_PATH,
|
|
292
|
+
REQUIRED_ARCHITECTURE_RULE_SNIPPETS,
|
|
293
|
+
failures,
|
|
294
|
+
results
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
assertSnippetCoverage(
|
|
298
|
+
'explain-on-demand-pr-checklist',
|
|
299
|
+
PR_CHECKLIST_PATH,
|
|
300
|
+
REQUIRED_PR_CHECKLIST_SNIPPETS,
|
|
301
|
+
failures,
|
|
302
|
+
results
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
assertSnippetCoverage(
|
|
306
|
+
'explain-on-demand-review-prompt',
|
|
307
|
+
REVIEW_PROMPT_PATH,
|
|
308
|
+
REQUIRED_REVIEW_PROMPT_SNIPPETS,
|
|
309
|
+
failures,
|
|
310
|
+
results
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
const onboardingReportContent = readText(ONBOARDING_REPORT_PATH);
|
|
314
|
+
const onboardingReport = parseOnboardingReport(onboardingReportContent);
|
|
315
|
+
|
|
316
|
+
if (!onboardingReportContent) {
|
|
317
|
+
failures.push(`Missing state source: ${ONBOARDING_REPORT_PATH}`);
|
|
318
|
+
pushResult(results, false, 'state-source', `Missing ${ONBOARDING_REPORT_PATH}`);
|
|
319
|
+
} else if (!onboardingReport) {
|
|
320
|
+
failures.push(`Invalid state source JSON: ${ONBOARDING_REPORT_PATH}`);
|
|
321
|
+
pushResult(results, false, 'state-source', `Cannot parse ${ONBOARDING_REPORT_PATH}`);
|
|
322
|
+
} else {
|
|
323
|
+
pushResult(results, true, 'state-source', `${ONBOARDING_REPORT_PATH} is present and valid`);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const defaultResponseSummary = buildDefaultResponseSummary(onboardingReport);
|
|
327
|
+
const defaultModeExposesStateInternals = detectInternalSignals(defaultResponseSummary);
|
|
328
|
+
|
|
329
|
+
if (defaultModeExposesStateInternals) {
|
|
330
|
+
failures.push('Default response exposes state internals');
|
|
331
|
+
pushResult(
|
|
332
|
+
results,
|
|
333
|
+
false,
|
|
334
|
+
'default-response-invisible-state',
|
|
335
|
+
'Default response leaks internal state details'
|
|
336
|
+
);
|
|
337
|
+
} else {
|
|
338
|
+
pushResult(
|
|
339
|
+
results,
|
|
340
|
+
true,
|
|
341
|
+
'default-response-invisible-state',
|
|
342
|
+
'Default response avoids unnecessary state-file internals'
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const diagnosticDecisionSummaries = buildDiagnosticDecisionSummaries(onboardingReport);
|
|
347
|
+
const canExplainStateDecisions = diagnosticDecisionSummaries.length > 0;
|
|
348
|
+
|
|
349
|
+
if (parsedArguments.mode === 'diagnostic' && !parsedArguments.explicitStateRequest) {
|
|
350
|
+
failures.push('Diagnostic mode requested without explicit state request');
|
|
351
|
+
pushResult(
|
|
352
|
+
results,
|
|
353
|
+
false,
|
|
354
|
+
'diagnostic-explicit-request-gate',
|
|
355
|
+
'Diagnostic mode requires explicit request. Re-run with --state-debug when user asks for state-level details.'
|
|
356
|
+
);
|
|
357
|
+
} else {
|
|
358
|
+
pushResult(
|
|
359
|
+
results,
|
|
360
|
+
true,
|
|
361
|
+
'diagnostic-explicit-request-gate',
|
|
362
|
+
parsedArguments.mode === 'diagnostic'
|
|
363
|
+
? 'Diagnostic mode is explicitly requested and permitted'
|
|
364
|
+
: 'Diagnostic mode not requested; default hidden-state behavior applies'
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (!canExplainStateDecisions) {
|
|
369
|
+
failures.push('Diagnostic mode cannot explain relevant state decisions');
|
|
370
|
+
pushResult(
|
|
371
|
+
results,
|
|
372
|
+
false,
|
|
373
|
+
'diagnostic-explain-state-decisions',
|
|
374
|
+
'No state decision explanations available'
|
|
375
|
+
);
|
|
376
|
+
} else {
|
|
377
|
+
pushResult(
|
|
378
|
+
results,
|
|
379
|
+
true,
|
|
380
|
+
'diagnostic-explain-state-decisions',
|
|
381
|
+
`Diagnostic mode can explain ${diagnosticDecisionSummaries.length} state decision points`
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (parsedArguments.mode === 'default' && parsedArguments.explicitStateRequest) {
|
|
386
|
+
warnings.push('Explicit state request was provided in default mode; internal state details remain hidden unless diagnostic mode is selected.');
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const reportPayload = {
|
|
390
|
+
generatedAt: new Date().toISOString(),
|
|
391
|
+
auditName: 'explain-on-demand-audit',
|
|
392
|
+
workflow: parsedArguments.workflow,
|
|
393
|
+
mode: parsedArguments.mode,
|
|
394
|
+
source: changedScope.source,
|
|
395
|
+
changedFileCount: changedFiles.length,
|
|
396
|
+
changedFiles,
|
|
397
|
+
responsePolicy: {
|
|
398
|
+
defaultModeExposesStateInternals,
|
|
399
|
+
diagnosticRequiresExplicitRequest: true,
|
|
400
|
+
explicitStateRequestReceived: parsedArguments.explicitStateRequest,
|
|
401
|
+
},
|
|
402
|
+
defaultResponse: {
|
|
403
|
+
summary: defaultResponseSummary,
|
|
404
|
+
containsStateInternals: defaultModeExposesStateInternals,
|
|
405
|
+
},
|
|
406
|
+
diagnosticMode: {
|
|
407
|
+
requested: parsedArguments.mode === 'diagnostic',
|
|
408
|
+
allowed: parsedArguments.mode !== 'diagnostic' || parsedArguments.explicitStateRequest,
|
|
409
|
+
canExplainStateDecisions,
|
|
410
|
+
stateDecisionExplanations: parsedArguments.mode === 'diagnostic' && parsedArguments.explicitStateRequest
|
|
411
|
+
? diagnosticDecisionSummaries
|
|
412
|
+
: [],
|
|
413
|
+
availableDecisionCount: diagnosticDecisionSummaries.length,
|
|
414
|
+
},
|
|
415
|
+
passed: failures.length === 0,
|
|
416
|
+
failureCount: failures.length,
|
|
417
|
+
failures,
|
|
418
|
+
warnings,
|
|
419
|
+
results,
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
console.log(JSON.stringify(reportPayload, null, 2));
|
|
423
|
+
process.exit(reportPayload.passed ? 0 : 1);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
runAudit();
|
|
@@ -44,6 +44,8 @@ const REQUIRED_EXCELLENCE_RUBRIC_SNIPPETS = [
|
|
|
44
44
|
'Typography Quality',
|
|
45
45
|
'Color System Diversity and Contrast',
|
|
46
46
|
'Interaction Choreography',
|
|
47
|
+
'Language and Content Consistency',
|
|
48
|
+
'Text Contrast and Collision Safety',
|
|
47
49
|
'UX Narrative and Conversion Clarity',
|
|
48
50
|
'Template Diversity and Originality',
|
|
49
51
|
'Low-Diversity Template Output Policy',
|
|
@@ -55,6 +57,9 @@ const REQUIRED_FRONTEND_RULE_SNIPPETS = [
|
|
|
55
57
|
'UI scope trigger signals',
|
|
56
58
|
'visual intent, interaction quality, and conversion clarity',
|
|
57
59
|
'template-only repetitive outputs',
|
|
60
|
+
'UI Consistency Guardrails (Mandatory)',
|
|
61
|
+
'Content language must stay consistent per screen and flow unless user requests multilingual output.',
|
|
62
|
+
'Text color must remain contrast-safe against its background; no color collisions.',
|
|
58
63
|
];
|
|
59
64
|
|
|
60
65
|
function assertFileExists(relativeFilePath, failures) {
|