@chemx/starter-kit 26.9.11-481 → 26.9.12-107

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.
Files changed (46) hide show
  1. package/cli/audit/ai-slop-detector.js +262 -0
  2. package/cli/audit/extended-visitors.js +359 -0
  3. package/cli/audit/history.js +19 -2
  4. package/cli/audit/metrics.js +69 -0
  5. package/cli/audit/prompts.js +175 -48
  6. package/cli/audit/reporter-banner.d.ts +3 -0
  7. package/cli/audit/reporter-banner.js +74 -0
  8. package/cli/audit/reporter-grades.js +11 -26
  9. package/cli/audit/reporter-grouping-markdown.js +83 -0
  10. package/cli/audit/reporter-grouping.d.ts +42 -0
  11. package/cli/audit/reporter-grouping.js +243 -0
  12. package/cli/audit/reporter-markdown.js +34 -22
  13. package/cli/audit/reporter-sections.d.ts +10 -0
  14. package/cli/audit/reporter-sections.js +259 -0
  15. package/cli/audit/reporter-summary.d.ts +4 -0
  16. package/cli/audit/reporter-summary.js +142 -0
  17. package/cli/audit/reporter-utils.js +13 -1
  18. package/cli/audit/reporter.d.ts +16 -0
  19. package/cli/audit/reporter.js +47 -420
  20. package/cli/audit/rules-helpers.js +16 -0
  21. package/cli/audit/rules-registry.js +88 -1
  22. package/cli/audit/rules.js +32 -1
  23. package/cli/audit/social-git.js +133 -131
  24. package/cli/audit/social.js +15 -2
  25. package/cli/audit/types.d.ts +28 -27
  26. package/cli/audit.js +56 -3
  27. package/cli/badge.js +262 -0
  28. package/cli/generator-templates.js +264 -0
  29. package/cli/generator.d.ts +10 -0
  30. package/cli/generator.js +151 -0
  31. package/cli/help.js +17 -7
  32. package/cli/index.js +26 -16
  33. package/cli/installer.d.ts +2 -0
  34. package/cli/installer.js +52 -38
  35. package/cli/license.js +17 -4
  36. package/cli/navigator-actions.js +63 -1
  37. package/cli/navigator-banner.js +17 -6
  38. package/cli/navigator-grades.js +9 -0
  39. package/cli/navigator-menu.js +36 -0
  40. package/cli/navigator-share.js +7 -4
  41. package/cli/navigator.d.ts +5 -1
  42. package/cli/navigator.js +49 -12
  43. package/cli/scaffold.js +3 -54
  44. package/cli/terminal.js +4 -1
  45. package/docs/CHANGELOG.md +50 -0
  46. package/package.json +1 -1
@@ -1,24 +1,25 @@
1
- import { PILLARS } from './rules.js';
2
1
  import {
3
2
  buildMasterPrompt,
4
3
  formatPromptBox
5
4
  } from './prompts.js';
6
5
  import {
7
- CYAN,
8
- GREEN,
9
- YELLOW,
10
- RED,
11
- ORANGE,
12
- DIM,
13
6
  BOLD,
7
+ DIM,
14
8
  RESET,
15
- groupViolationsBySeverity,
16
- getStatusBadge,
17
- resolveGradeColor,
18
- resolveHealthHearts,
19
- resolveRiskColor,
20
- resolveHotspotBadge
9
+ resolveTopSectionColor
21
10
  } from './reporter-utils.js';
11
+ import { getChemicalXAsciiBanner } from './reporter-banner.js';
12
+ import { formatDirectoryDistributionSection } from './reporter-grouping.js';
13
+ import {
14
+ formatScorecardSection,
15
+ formatCriticalSection,
16
+ formatHighMediumSection,
17
+ formatLowSection,
18
+ formatPillarsSection,
19
+ formatHotspotsSection,
20
+ formatContextAnalysisSection,
21
+ formatAiSlopSection
22
+ } from './reporter-sections.js';
22
23
 
23
24
  export {
24
25
  groupViolationsBySeverity,
@@ -28,6 +29,7 @@ export {
28
29
  resolveHealthHearts,
29
30
  resolveRiskColor,
30
31
  resolveHotspotBadge,
32
+ resolveTopSectionColor,
31
33
  resolveMarkdownStatusIcon,
32
34
  resolveMarkdownMonolithText,
33
35
  PILLAR_EMOJIS,
@@ -43,6 +45,20 @@ export {
43
45
  RESET
44
46
  } from './reporter-utils.js';
45
47
 
48
+ export {
49
+ resolveDirectory,
50
+ groupViolationsByDirectory,
51
+ groupViolationsByRule,
52
+ formatCompactLocations,
53
+ renderGroupedViolationsTerminal,
54
+ formatDirectoryDistributionSection
55
+ } from './reporter-grouping.js';
56
+
57
+ export {
58
+ formatDirectoryRollupMarkdown,
59
+ renderGroupedViolationsMarkdown
60
+ } from './reporter-grouping-markdown.js';
61
+
46
62
  export { generateMarkdownReport } from './reporter-markdown.js';
47
63
 
48
64
  export {
@@ -60,281 +76,23 @@ export {
60
76
  REPORT_CARD_ASCII
61
77
  } from './reporter-ascii.js';
62
78
 
63
- import { getAsciiGradeLines, getReportCardAsciiLines } from './reporter-ascii.js';
64
-
65
- export const resolveTopSectionColor = (report) => {
66
- const hasNoViolations = (report?.violations?.length ?? 0) === 0;
67
- const hasNoHotspots = (report?.hotspots?.length ?? 0) === 0;
68
- const areAllPillarsPassed = Object.values(report?.pillars ?? {}).every((p) => p.status === 'PASSED');
69
- const isAllPassed = hasNoViolations && hasNoHotspots && areAllPillarsPassed;
70
- return isAllPassed ? GREEN : CYAN;
71
- };
72
-
73
- export const formatScorecardSection = (report, themeColor = null) => {
74
- const { metrics, health } = report;
75
- const sectionColor = themeColor || resolveTopSectionColor(report);
76
- const gradeColor = resolveGradeColor(health?.score ?? health?.grade ?? 'A');
77
- const lines = [];
78
-
79
- lines.push('');
80
- for (const rcLine of getReportCardAsciiLines(sectionColor)) {
81
- lines.push(` ${rcLine}`);
82
- }
83
- lines.push(`${sectionColor}======================================================================${RESET}`);
84
- lines.push(`${BOLD}${sectionColor} MOLECULAR HEALTH INDEX & CODEBASE OVERVIEW${RESET}`);
85
- lines.push(`${sectionColor}======================================================================${RESET}`);
86
-
87
- const asciiGradeLines = getAsciiGradeLines(health?.grade || 'A', gradeColor);
88
- if (asciiGradeLines.length > 0) {
89
- lines.push('');
90
- for (const asciiLine of asciiGradeLines) {
91
- lines.push(` ${asciiLine}`);
92
- }
93
- lines.push('');
94
- lines.push(`${sectionColor}----------------------------------------------------------------------${RESET}`);
95
- }
96
-
97
- const hearts = resolveHealthHearts(health?.grade, health?.score);
98
- lines.push(` Life / Health Meter: ${hearts} ${gradeColor}${BOLD}${health.score} / 100${RESET} (Grade: ${gradeColor}${BOLD}${health.grade}${RESET} - ${health.label})`);
99
- lines.push(` Files Scanned: ${BOLD}${metrics.scannedFiles}${RESET} source files`);
100
- lines.push(` Total Lines of Code: ${BOLD}${metrics.totalLoc}${RESET} lines of code (avg: ${metrics.avgLoc} lines/file)`);
101
- lines.push(` Largest File: ${BOLD}${metrics.largestFile.filePath || 'None'}${RESET} (${metrics.largestFile.lineCount} lines)`);
102
- lines.push(` Molecule Capsules: ${metrics.moleculeCount} found (${metrics.moleculeCompliantPct}% compliant < 100 lines of code)`);
103
- lines.push(` Custom Hooks: ${metrics.hookCount} detected`);
104
- lines.push(`${sectionColor}======================================================================${RESET}\n`);
105
-
106
- return lines.join('\n');
107
- };
108
-
109
- export const formatCriticalSection = (report) => {
110
- const { violations } = report;
111
- const { critical } = groupViolationsBySeverity(violations);
112
- const lines = [];
113
-
114
- lines.push('');
115
- lines.push(`${RED}======================================================================${RESET}`);
116
- lines.push(`${BOLD}${RED} CRITICAL HAZARDS (${critical.length} TOTAL) : IMMEDIATE ACTION REQUIRED${RESET}`);
117
- lines.push(`${DIM} Violations that break Molecular line budgets or introduce severe AST bugs${RESET}`);
118
- lines.push(`${RED}======================================================================${RESET}`);
119
-
120
- if (critical.length === 0) {
121
- lines.push(` ${GREEN}✔ Zero critical hazards detected. No monoliths or breaking AST patterns.${RESET}`);
122
- } else {
123
- critical.forEach((v, idx) => {
124
- lines.push(` ${RED}[#${idx + 1} CRITICAL]${RESET} [${v.rule}] ${YELLOW}${v.filePath}:${v.line}:${v.column}${RESET}`);
125
- lines.push(` Hazard: ${v.hazard}`);
126
- lines.push(` Directive: ${CYAN}${v.directive}${RESET}\n`);
127
- });
128
- }
129
- lines.push(`${RED}======================================================================${RESET}\n`);
130
-
131
- return lines.join('\n');
132
- };
133
-
134
- export const formatHighMediumSection = (report) => {
135
- const { violations } = report;
136
- const { high, medium } = groupViolationsBySeverity(violations);
137
- const totalCount = high.length + medium.length;
138
- const lines = [];
139
-
140
- lines.push('');
141
- lines.push(`${ORANGE}======================================================================${RESET}`);
142
- lines.push(`${BOLD}${ORANGE} HIGH & MEDIUM HAZARDS (${totalCount} TOTAL) : ARCHITECTURE DEBTS${RESET}`);
143
- lines.push(`${DIM} Saturation, complex control flow booleans, and raw inline styles${RESET}`);
144
- lines.push(`${ORANGE}======================================================================${RESET}`);
145
-
146
- if (totalCount === 0) {
147
- lines.push(` ${GREEN}✔ Zero high or medium architecture hazards detected.${RESET}`);
148
- } else {
149
- if (high.length > 0) {
150
- lines.push(`\n ${BOLD}--- High Severity (${high.length} items) ---${RESET}`);
151
- high.forEach((v, idx) => {
152
- lines.push(` ${ORANGE}[#${idx + 1} HIGH]${RESET} [${v.rule}] ${YELLOW}${v.filePath}:${v.line}:${v.column}${RESET}`);
153
- lines.push(` Hazard: ${v.hazard}`);
154
- lines.push(` Directive: ${CYAN}${v.directive}${RESET}\n`);
155
- });
156
- }
157
-
158
- if (medium.length > 0) {
159
- lines.push(`\n ${BOLD}--- Medium Severity (${medium.length} items) ---${RESET}`);
160
- medium.forEach((v, idx) => {
161
- lines.push(` ${ORANGE}[#${idx + 1} MED]${RESET} [${v.rule}] ${YELLOW}${v.filePath}:${v.line}:${v.column}${RESET}`);
162
- lines.push(` Hazard: ${v.hazard}`);
163
- lines.push(` Directive: ${CYAN}${v.directive}${RESET}\n`);
164
- });
165
- }
166
- }
167
- lines.push(`${ORANGE}======================================================================${RESET}\n`);
168
-
169
- return lines.join('\n');
170
- };
171
-
172
- export const formatLowSection = (report) => {
173
- const { violations } = report;
174
- const { low } = groupViolationsBySeverity(violations);
175
- const lines = [];
176
-
177
- lines.push('');
178
- lines.push(`${YELLOW}======================================================================${RESET}`);
179
- lines.push(`${BOLD}${YELLOW} LOW & HYGIENE ISSUES (${low.length} TOTAL) : TYPOGRAPHY & LOGGING${RESET}`);
180
- lines.push(`${DIM} Em dash typography violations and unguarded console statements${RESET}`);
181
- lines.push(`${YELLOW}======================================================================${RESET}`);
182
-
183
- if (low.length === 0) {
184
- lines.push(` ${GREEN}✔ Zero typography or logging hygiene issues detected.${RESET}`);
185
- } else {
186
- low.forEach((v, idx) => {
187
- lines.push(` ${YELLOW}[#${idx + 1} LOW]${RESET} [${v.rule}] ${YELLOW}${v.filePath}:${v.line}:${v.column}${RESET}`);
188
- lines.push(` Hazard: ${v.hazard}`);
189
- lines.push(` Directive: ${CYAN}${v.directive}${RESET}\n`);
190
- });
191
- }
192
- lines.push(`${YELLOW}======================================================================${RESET}\n`);
193
-
194
- return lines.join('\n');
195
- };
196
-
197
- export const formatPillarsSection = (report, themeColor = null) => {
198
- const { pillars } = report;
199
- const sectionColor = themeColor || resolveTopSectionColor(report);
200
- const lines = [];
201
-
202
- lines.push('');
203
- lines.push(`${sectionColor}======================================================================${RESET}`);
204
- lines.push(`${BOLD}${sectionColor} 7-PILLAR ARCHITECTURAL COMPLIANCE MATRIX${RESET}`);
205
- lines.push(`${sectionColor}======================================================================${RESET}`);
206
- lines.push(` ${DIM}Pillar Name Status Violations${RESET}`);
207
- lines.push(` ${DIM}------------------------------------------------------------------${RESET}`);
208
- for (const [pillarName, data] of Object.entries(pillars)) {
209
- const padName = pillarName.padEnd(45, ' ');
210
- const badge = getStatusBadge(data.status).padEnd(16, ' ');
211
- const countStr = data.violations === 0 ? `${GREEN}0${RESET}` : `${RED}${data.violations}${RESET}`;
212
- lines.push(` ${padName} ${badge} ${countStr}`);
213
- }
214
- lines.push(`${sectionColor}======================================================================${RESET}\n`);
215
-
216
- return lines.join('\n');
217
- };
218
-
219
- export const formatHotspotsSection = (report, themeColor = null) => {
220
- const { hotspots } = report;
221
- const sectionColor = themeColor || resolveTopSectionColor(report);
222
- const lines = [];
223
-
224
- lines.push('');
225
- lines.push(`${sectionColor}======================================================================${RESET}`);
226
- lines.push(`${BOLD}${sectionColor} TOP REFACTORING HOTSPOTS (PRIORITY RANKING)${RESET}`);
227
- lines.push(`${sectionColor}======================================================================${RESET}`);
228
-
229
- if (hotspots.length === 0) {
230
- lines.push(` ${GREEN}✔ Zero hotspot files. All files stay within architectural budgets.${RESET}`);
231
- } else {
232
- hotspots.forEach((h, idx) => {
233
- const monolithBadge = resolveHotspotBadge(h.lineCount);
234
- lines.push(` [#${idx + 1}] ${YELLOW}${h.filePath}${RESET} (${h.lineCount} lines, ${h.violationCount} hazards)${monolithBadge}`);
235
- });
236
- }
237
- lines.push(`${sectionColor}======================================================================${RESET}\n`);
238
-
239
- return lines.join('\n');
240
- };
241
-
242
- export const formatContextAnalysisSection = (report, themeColor = null) => {
243
- const { contextAnalysis } = report;
244
- const sectionColor = themeColor || resolveTopSectionColor(report);
245
- const riskColor = resolveRiskColor(contextAnalysis.riskLevel);
246
- const lines = [];
247
-
248
- lines.push('');
249
- lines.push(`${sectionColor}======================================================================${RESET}`);
250
- lines.push(`${BOLD}${sectionColor} CONTEXT ROT & TOKEN BURN ANALYTICS${RESET}`);
251
- lines.push(`${sectionColor}======================================================================${RESET}`);
252
- lines.push(` Estimated Codebase Tokens: ~${contextAnalysis.estimatedTokens.toLocaleString()} tokens`);
253
- lines.push(` Estimated Monolith Bloat: ~${contextAnalysis.estimatedExcessTokens.toLocaleString()} tokens`);
254
- lines.push(` Target Architecture Cut: ${BOLD}${contextAnalysis.potentialSavingsPct}%${RESET} token reduction potential`);
255
- lines.push(` Agent Hallucination Risk: ${riskColor}${BOLD}${contextAnalysis.riskLevel}${RESET}`);
256
- if (contextAnalysis.excessCostPerPass !== undefined) {
257
- const costPass = contextAnalysis.excessCostPerPass.toFixed(3);
258
- const costMonth = contextAnalysis.monthlyWastePerDev.toFixed(2);
259
- const costWeek = contextAnalysis.weeklyWastePerDev.toFixed(2);
260
- lines.push(` Pricing Model Baseline: ${contextAnalysis.pricingModel}`);
261
- lines.push(` Monolith Bloat per AI Turn: \x1b[38;5;208;1m$${costPass}\x1b[0m / prompt turn`);
262
- lines.push(` Projected Dev Context Tax: \x1b[31;1m$${costMonth}/mo\x1b[0m per engineer ($${costWeek}/wk)`);
263
- }
264
- lines.push(`${sectionColor}======================================================================${RESET}\n`);
265
-
266
- return lines.join('\n');
267
- };
268
-
269
- export const getChemicalXAsciiBanner = (gradeOrReport = null) => {
270
- const grade = typeof gradeOrReport === 'object' && gradeOrReport !== null
271
- ? gradeOrReport.health?.grade
272
- : gradeOrReport;
273
-
274
- const art = [
275
- ' ██████╗██╗ ██╗███████╗███╗ ███╗██╗ ██████╗ █████╗ ██╗ ██╗ ██╗',
276
- '██╔════╝██║ ██║██╔════╝████╗ ████║██║██╔════╝██╔══██╗██║ ╚██╗██╔╝',
277
- '██║ ███████║█████╗ ██╔████╔██║██║██║ ███████║██║ ╚███╔╝ ',
278
- '██║ ██╔══██║██╔══╝ ██║╚██╔╝██║██║██║ ██╔══██║██║ ██╔██╗ ',
279
- '╚██████╗██║ ██║███████╗██║ ╚═╝ ██║██║╚██████╗██║ ██║███████╗ ██╔╝ ██╗',
280
- ' ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝'
281
- ];
79
+ export { getChemicalXAsciiBanner } from './reporter-banner.js';
282
80
 
283
- const maxLen = 74;
284
- const lines = [];
285
-
286
- lines.push(' \x1b[1m\x1b[37mThe Secret Sauce to \x1b[38;2;98;201;255mVibe Coding\x1b[0m');
287
-
288
- const gColor = grade ? resolveGradeColor(grade) : '';
289
- const gradeLines = grade ? getAsciiGradeLines(grade, gColor, true) : [];
290
- const termWidth = process.stdout.columns || 0;
291
- const isSideBySide = Boolean(!termWidth || termWidth >= 105);
292
-
293
- for (let lineIdx = 0; lineIdx < art.length; lineIdx++) {
294
- const line = art[lineIdx];
295
- let out = '';
296
- for (let i = 0; i < line.length; i++) {
297
- const ch = line[i];
298
- if (ch === ' ') {
299
- out += ' ';
300
- continue;
301
- }
302
- const t = i / (maxLen - 1);
303
- let r, g, b;
304
- if (t < 0.5) {
305
- const factor = t * 2;
306
- r = Math.round(244 * (1 - factor) + 192 * factor);
307
- g = Math.round(114 * (1 - factor) + 132 * factor);
308
- b = Math.round(182 * (1 - factor) + 252 * factor);
309
- } else {
310
- const factor = (t - 0.5) * 2;
311
- r = Math.round(192 * (1 - factor) + 129 * factor);
312
- g = Math.round(132 * (1 - factor) + 140 * factor);
313
- b = Math.round(252 * (1 - factor) + 248 * factor);
314
- }
315
- out += `\x1b[38;2;${r};${g};${b}m\x1b[1m${ch}\x1b[0m`;
316
- }
317
-
318
- if (isSideBySide && gradeLines.length > lineIdx) {
319
- out += ` ${gradeLines[lineIdx]}`;
320
- }
321
-
322
- lines.push(out);
323
- }
324
-
325
- const subtitle = 'Architectural guardrails to eliminate token burn and AI hallucinations.';
326
- const pad = ' '.repeat(Math.max(0, Math.floor((maxLen - subtitle.length) / 2)));
327
- lines.push(`${pad}\x1b[2m${subtitle}\x1b[0m\n`);
328
-
329
- if (!isSideBySide && gradeLines.length > 0) {
330
- for (const gl of gradeLines) {
331
- lines.push(` ${gl}`);
332
- }
333
- lines.push('');
334
- }
81
+ export {
82
+ formatScorecardSection,
83
+ formatCriticalSection,
84
+ formatHighMediumSection,
85
+ formatLowSection,
86
+ formatPillarsSection,
87
+ formatHotspotsSection,
88
+ formatContextAnalysisSection,
89
+ formatAiSlopSection
90
+ } from './reporter-sections.js';
335
91
 
336
- return lines.join('\n');
337
- };
92
+ export {
93
+ formatFailuresSection,
94
+ formatPassesSection
95
+ } from './reporter-summary.js';
338
96
 
339
97
  export const formatTerminalReport = (report) => {
340
98
  const lines = [];
@@ -350,7 +108,9 @@ export const formatTerminalReport = (report) => {
350
108
  lines.push(formatScorecardSection(report, topColor));
351
109
  lines.push(formatContextAnalysisSection(report, topColor));
352
110
  lines.push(formatPillarsSection(report, topColor));
353
- lines.push(formatHotspotsSection(report, topColor));
111
+ lines.push(formatHotspotsSection(report, topColor, { includePrompt: false }));
112
+ lines.push(formatDirectoryDistributionSection(report, topColor));
113
+ lines.push(formatAiSlopSection(report, topColor, { includePrompt: false }));
354
114
  lines.push(formatCriticalSection(report));
355
115
  lines.push(formatHighMediumSection(report));
356
116
  lines.push(formatLowSection(report));
@@ -362,136 +122,3 @@ export const formatTerminalReport = (report) => {
362
122
 
363
123
  return lines.join('\n');
364
124
  };
365
-
366
- export const formatFailuresSection = (report) => {
367
- const { violations, pillars, hotspots } = report;
368
- const { critical, high, medium, low } = groupViolationsBySeverity(violations);
369
- const lines = [];
370
-
371
- lines.push('');
372
- lines.push(`${RED}======================================================================${RESET}`);
373
- lines.push(`${BOLD}${RED} FAILED & DEGRADED CHECKS : HAZARDS, DEBTS & HOTSPOTS${RESET}`);
374
- lines.push(`${DIM} Consolidated breakdown of all failed architectural checks${RESET}`);
375
- lines.push(`${RED}======================================================================${RESET}`);
376
-
377
- if (violations.length === 0 && hotspots.length === 0) {
378
- lines.push(`\n ${GREEN}${BOLD}✔ ZERO FAILURES DETECTED!${RESET}`);
379
- lines.push(' All 7 Chemical X Molecular Architecture Pillars are 100% Compliant.\n');
380
- lines.push(`${RED}======================================================================${RESET}\n`);
381
- return lines.join('\n');
382
- }
383
-
384
- lines.push(` Total Hazards Flagged: ${BOLD}${RED}${violations.length}${RESET}`);
385
- const critDesc = critical.length > 0 ? `${RED}${BOLD}${critical.length} (Immediate Action Required)${RESET}` : `${GREEN}0${RESET}`;
386
- lines.push(` Critical Hazards: ${critDesc}`);
387
- const debtsTotal = high.length + medium.length;
388
- const debtsDesc = debtsTotal > 0 ? `${ORANGE}${BOLD}${debtsTotal}${RESET}` : `${GREEN}0${RESET}`;
389
- lines.push(` High/Med Debts: ${debtsDesc}`);
390
- const lowDesc = low.length > 0 ? `${YELLOW}${low.length}${RESET}` : `${GREEN}0${RESET}`;
391
- lines.push(` Low Hygiene Issues: ${lowDesc}`);
392
- const hotspotsDesc = hotspots.length > 0 ? `${YELLOW}${hotspots.length}${RESET}` : `${GREEN}0${RESET}`;
393
- lines.push(` Hotspot Files: ${hotspotsDesc}`);
394
- lines.push(`${RED}----------------------------------------------------------------------${RESET}`);
395
-
396
- if (critical.length > 0) {
397
- lines.push(`\n ${BOLD}${RED}🚨 CRITICAL HAZARDS (${critical.length}) : IMMEDIATE ACTION REQUIRED${RESET}`);
398
- critical.forEach((v, idx) => {
399
- lines.push(` ${RED}[#${idx + 1} CRITICAL]${RESET} [${v.rule}] ${YELLOW}${v.filePath}:${v.line}:${v.column}${RESET}`);
400
- lines.push(` Hazard: ${v.hazard}`);
401
- lines.push(` Directive: ${CYAN}${v.directive}${RESET}\n`);
402
- });
403
- }
404
-
405
- if (debtsTotal > 0) {
406
- lines.push(` ${BOLD}${ORANGE}⚠️ HIGH & MEDIUM HAZARDS (${debtsTotal}) : ARCHITECTURE DEBTS${RESET}`);
407
- [...high, ...medium].forEach((v, idx) => {
408
- const isHigh = v.severity === 'HIGH';
409
- const badge = isHigh ? `${ORANGE}[#${idx + 1} HIGH]${RESET}` : `${ORANGE}[#${idx + 1} MED]${RESET}`;
410
- lines.push(` ${badge} [${v.rule}] ${YELLOW}${v.filePath}:${v.line}:${v.column}${RESET}`);
411
- lines.push(` Hazard: ${v.hazard}`);
412
- lines.push(` Directive: ${CYAN}${v.directive}${RESET}\n`);
413
- });
414
- }
415
-
416
- if (low.length > 0) {
417
- lines.push(` ${BOLD}${YELLOW}🧹 LOW & HYGIENE ISSUES (${low.length})${RESET}`);
418
- low.forEach((v, idx) => {
419
- lines.push(` ${YELLOW}[#${idx + 1} LOW]${RESET} [${v.rule}] ${YELLOW}${v.filePath}:${v.line}:${v.column}${RESET}`);
420
- lines.push(` Hazard: ${v.hazard}`);
421
- lines.push(` Directive: ${CYAN}${v.directive}${RESET}\n`);
422
- });
423
- }
424
-
425
- const failedPillars = Object.entries(pillars).filter(([_, p]) => p.status !== 'PASSED');
426
- if (failedPillars.length > 0) {
427
- lines.push(` ${BOLD}${RED}🏛️ FAILED / DEGRADED PILLARS (${failedPillars.length})${RESET}`);
428
- for (const [name, p] of failedPillars) {
429
- lines.push(` ✕ ${YELLOW}${name}${RESET}: ${p.violations} violations (${p.critical} Critical, ${p.high} High, ${p.medium} Med)`);
430
- }
431
- lines.push('');
432
- }
433
-
434
- if (hotspots.length > 0) {
435
- lines.push(` ${BOLD}${YELLOW}🔥 REFACTORING HOTSPOTS (${hotspots.length})${RESET}`);
436
- hotspots.forEach((h, idx) => {
437
- const monolithBadge = resolveHotspotBadge(h.lineCount);
438
- lines.push(` [#${idx + 1}] ${YELLOW}${h.filePath}${RESET} (${h.lineCount} lines, ${h.violationCount} hazards)${monolithBadge}`);
439
- });
440
- lines.push('');
441
- }
442
-
443
- const prompt = buildMasterPrompt(report);
444
- if (prompt) {
445
- lines.push(formatPromptBox('🤖 AI AGENT REFACTORING PROMPT (ALL FAILED CHECKS)', prompt));
446
- }
447
-
448
- lines.push(`${RED}======================================================================${RESET}\n`);
449
- return lines.join('\n');
450
- };
451
-
452
- export const formatPassesSection = (report) => {
453
- const { metrics, health, pillars, hotspots, contextAnalysis } = report;
454
- const passedPillars = Object.entries(pillars).filter(([_, p]) => p.status === 'PASSED');
455
- const lines = [];
456
-
457
- lines.push('');
458
- lines.push(`${GREEN}======================================================================${RESET}`);
459
- lines.push(`${BOLD}${GREEN} PASSED & COMPLIANT CHECKS : CLEAN ARCHITECTURE STANDARDS${RESET}`);
460
- lines.push(`${DIM} Consolidated breakdown of verified compliant areas${RESET}`);
461
- lines.push(`${GREEN}======================================================================${RESET}`);
462
-
463
- lines.push(` Molecular Health Score: ${BOLD}${GREEN}${health.score}/100${RESET} [Grade: ${BOLD}${GREEN}${health.grade}${RESET}]`);
464
- lines.push(` Passing Pillars: ${BOLD}${GREEN}${passedPillars.length} / 7 Pillars PASSED${RESET}`);
465
- lines.push(` Capsule Compliance: ${BOLD}${GREEN}${metrics.moleculeCompliantPct}%${RESET} molecules compliant (< 100 lines of code)`);
466
- lines.push(` Total Files Scanned: ${metrics.scannedFiles} source files (${metrics.totalLoc} total lines of code)`);
467
- lines.push(`${GREEN}----------------------------------------------------------------------${RESET}`);
468
-
469
- lines.push(`\n ${BOLD}${GREEN}✔ COMPLIANT ARCHITECTURAL PILLARS:${RESET}`);
470
- if (passedPillars.length === 0) {
471
- lines.push(` ${YELLOW}No pillars are completely hazard-free.${RESET}\n`);
472
- } else {
473
- for (const [name] of passedPillars) {
474
- lines.push(` ${GREEN}✔${RESET} ${name} ${DIM}(0 violations)${RESET}`);
475
- }
476
- lines.push('');
477
- }
478
-
479
- lines.push(` ${BOLD}${CYAN}STANDARDS MET & CLEAN AREAS:${RESET}`);
480
- if (metrics.moleculeCompliantPct === 100) {
481
- lines.push(` ${GREEN}✔${RESET} 100% Molecule Capsule Limit (< 100 lines per molecule)`);
482
- }
483
- const hasExtremeMonolith = hotspots.some((h) => h.lineCount >= 2000);
484
- if (!hasExtremeMonolith) {
485
- lines.push(` ${GREEN}✔${RESET} Zero Extreme Monoliths (0 files >= 2,000 lines of code)`);
486
- }
487
- const hasSevereMonolith = hotspots.some((h) => h.lineCount >= 1000);
488
- if (!hasSevereMonolith) {
489
- lines.push(` ${GREEN}✔${RESET} Zero Severe Monoliths (0 files >= 1,000 lines of code)`);
490
- }
491
- if (contextAnalysis.riskLevel === 'LOW') {
492
- lines.push(` ${GREEN}✔${RESET} Low Context Hazard & Token Burn Risk`);
493
- }
494
-
495
- lines.push(`\n${GREEN}======================================================================${RESET}\n`);
496
- return lines.join('\n');
497
- };
@@ -107,3 +107,19 @@ export const resolveMoleculeTier = (lineCount) => {
107
107
  directive: 'Split molecule into focused sub-molecules or extract state to hook'
108
108
  };
109
109
  };
110
+
111
+ /**
112
+ * Executes a synchronous operation returning a Go/Rust-style [data, error] tuple.
113
+ * @template T
114
+ * @param {() => T} operation
115
+ * @returns {[T, null] | [null, Error]}
116
+ */
117
+ export const toResultSync = (operation) => {
118
+ try {
119
+ const value = operation();
120
+ return [value, null];
121
+ } catch (err) {
122
+ const normalizedError = err instanceof Error ? err : new Error(String(err));
123
+ return [null, normalizedError];
124
+ }
125
+ };
@@ -5,10 +5,62 @@ export const PILLARS = {
5
5
  PILLAR_4: 'Type Architecture & Data Integrity',
6
6
  PILLAR_5: 'Design System & Styling Hygiene',
7
7
  PILLAR_6: 'Timers & Macro-Task Discipline',
8
- PILLAR_7: 'Global Hygiene & Typography'
8
+ PILLAR_7: 'Global Hygiene & Typography',
9
+ PILLAR_8: 'Accessibility & Semantic Integrity',
10
+ PILLAR_9: 'Security & Content Safety',
11
+ PILLAR_10: 'Testing Discipline',
12
+ PILLAR_11: 'Naming Conventions'
9
13
  };
10
14
 
11
15
  export const RULE_REGISTRY = {
16
+ // Pillar 8: Accessibility & Semantic Integrity
17
+ A11Y_CLICKABLE_NON_SEMANTIC: {
18
+ pillar: PILLARS.PILLAR_8,
19
+ severity: 'MEDIUM',
20
+ directive: 'Replace clickable generic container with native interactive element (<button> or <a>)'
21
+ },
22
+ A11Y_IMAGE_MISSING_ALT: {
23
+ pillar: PILLARS.PILLAR_8,
24
+ severity: 'MEDIUM',
25
+ directive: 'Provide meaningful alt text or alt="" for decorative images'
26
+ },
27
+
28
+ // Pillar 9: Security & Content Safety
29
+ SECURITY_RAW_HTML_INJECTION: {
30
+ pillar: PILLARS.PILLAR_9,
31
+ severity: 'CRITICAL',
32
+ directive: 'Sanitize dynamic HTML via DOMPurify before injecting into v-html or dangerouslySetInnerHTML'
33
+ },
34
+ SECURITY_HARDCODED_SECRET: {
35
+ pillar: PILLARS.PILLAR_9,
36
+ severity: 'CRITICAL',
37
+ directive: 'Extract hardcoded API keys and secrets into environment variables or secrets manager'
38
+ },
39
+
40
+ // Pillar 10: Testing Discipline
41
+ TEST_FAKE_GREEN: {
42
+ pillar: PILLARS.PILLAR_10,
43
+ severity: 'HIGH',
44
+ directive: 'Replace trivial truthy assertions with genuine assertions testing real logic'
45
+ },
46
+ TEST_MISSING_COLOCATED: {
47
+ pillar: PILLARS.PILLAR_10,
48
+ severity: 'MEDIUM',
49
+ directive: 'Co-locate *.spec.ts or *.test.ts alongside the molecule capsule'
50
+ },
51
+
52
+ // Pillar 11: Naming Conventions
53
+ NAMING_BARE_BOOLEAN: {
54
+ pillar: PILLARS.PILLAR_11,
55
+ severity: 'MEDIUM',
56
+ directive: 'Prefix boolean variables with is, has, can, or should'
57
+ },
58
+ NAMING_HANDLER_PREFIX: {
59
+ pillar: PILLARS.PILLAR_11,
60
+ severity: 'LOW',
61
+ directive: 'Prefix action handler functions with handle (e.g. handleCheckout)'
62
+ },
63
+
12
64
  LINE_BUDGET_FILE: {
13
65
  pillar: PILLARS.PILLAR_1,
14
66
  severity: 'MEDIUM',
@@ -93,5 +145,40 @@ export const RULE_REGISTRY = {
93
145
  pillar: PILLARS.PILLAR_1,
94
146
  severity: 'CRITICAL',
95
147
  directive: 'Fix syntax errors before static analysis'
148
+ },
149
+ AI_SLOP_CONVERSATIONAL_ARTIFACT: {
150
+ pillar: 'AI Slop & Code Authenticity',
151
+ severity: 'CRITICAL',
152
+ directive: 'Remove LLM assistant conversational residue and markdown leaks from comments and code'
153
+ },
154
+ AI_SLOP_LAZY_PLACEHOLDER: {
155
+ pillar: 'AI Slop & Code Authenticity',
156
+ severity: 'CRITICAL',
157
+ directive: 'Replace lazy AI truncation placeholders with complete, verifiable implementations'
158
+ },
159
+ AI_SLOP_SHALLOW_CATCH: {
160
+ pillar: 'AI Slop & Code Authenticity',
161
+ severity: 'HIGH',
162
+ directive: 'Replace shallow catch paranoia wrappers with intentional error propagation or ResultTuple'
163
+ },
164
+ AI_SLOP_UTILITY_REINVENTION: {
165
+ pillar: 'AI Slop & Code Authenticity',
166
+ severity: 'HIGH',
167
+ directive: 'Import shared domain utilities instead of reinventing boilerplate helpers inline'
168
+ },
169
+ AI_SLOP_ECHO_COMMENT: {
170
+ pillar: 'AI Slop & Code Authenticity',
171
+ severity: 'MEDIUM',
172
+ directive: 'Eliminate trivial parroting comments that merely restate self-documenting code'
173
+ },
174
+ AI_SLOP_LAZY_ANY: {
175
+ pillar: 'AI Slop & Code Authenticity',
176
+ severity: 'MEDIUM',
177
+ directive: 'Replace lazy any widening with strict domain types or unknown guards'
178
+ },
179
+ AI_SLOP_REDUNDANT_PASSTHROUGH: {
180
+ pillar: 'AI Slop & Code Authenticity',
181
+ severity: 'LOW',
182
+ directive: 'Inline redundant single-use passthrough assignments directly into return expressions'
96
183
  }
97
184
  };
@@ -10,6 +10,14 @@ import {
10
10
  resolveMoleculeTier
11
11
  } from './rules-helpers.js';
12
12
  import { createAstVisitors } from './ast-visitors.js';
13
+ import {
14
+ checkSlopTextPatterns,
15
+ createAiSlopVisitors
16
+ } from './ai-slop-detector.js';
17
+ import {
18
+ checkExtendedTextPatterns,
19
+ createExtendedVisitors
20
+ } from './extended-visitors.js';
13
21
 
14
22
  export { PILLARS, RULE_REGISTRY };
15
23
 
@@ -87,6 +95,12 @@ export const auditCode = (content, filePath, relativePath) => {
87
95
  checkTypographyEmDash(content, lines, relativePath, violations);
88
96
  checkMockDataPatterns(content, lines, relativePath, violations);
89
97
 
98
+ // AI Slop Fast Checks (conversational residue, code fences, echo comments)
99
+ checkSlopTextPatterns(content, lines, relativePath, violations);
100
+
101
+ // Pillars 8-11: Extended Fast Checks (A11y, Security secrets, Fake tests, Co-located specs)
102
+ checkExtendedTextPatterns(content, lines, relativePath, filePath, violations);
103
+
90
104
  const codeToParse = extractParseableCode(content, ext);
91
105
  if (!codeToParse.trim()) {
92
106
  return violations;
@@ -116,8 +130,25 @@ export const auditCode = (content, filePath, relativePath) => {
116
130
 
117
131
  const traverseFn = traverse.default || traverse;
118
132
  const visitors = createAstVisitors({ relativePath, violations });
133
+ const slopVisitors = createAiSlopVisitors({ relativePath, violations });
134
+ const extendedVisitors = createExtendedVisitors({ relativePath, violations });
135
+
136
+ const mergedVisitors = { ...visitors };
137
+ for (const visitorSet of [slopVisitors, extendedVisitors]) {
138
+ for (const [key, fn] of Object.entries(visitorSet)) {
139
+ if (mergedVisitors[key]) {
140
+ const orig = mergedVisitors[key];
141
+ mergedVisitors[key] = (p, s) => {
142
+ orig(p, s);
143
+ fn(p, s);
144
+ };
145
+ } else {
146
+ mergedVisitors[key] = fn;
147
+ }
148
+ }
149
+ }
119
150
 
120
- traverseFn(ast, visitors);
151
+ traverseFn(ast, mergedVisitors);
121
152
 
122
153
  return violations;
123
154
  };