@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
package/cli/help.js CHANGED
@@ -23,13 +23,16 @@ export const printHelp = () => {
23
23
  ` Computes Molecular Health Index (MHI: 0-100) and letter grades (A+ to F).`,
24
24
  ` Defaults to interactive zero-scroll Gum terminal dashboard.`,
25
25
  '',
26
- ` ${CYAN}generate${RESET} <m-name> ${DIM}(aliases: capsule, add)${RESET}`,
27
- ` Scaffold an isolated crystalline molecule capsule directory:`,
28
- ` ${DIM}- ${RESET}<m-name>/<m-name>.tsx ${DIM}(declarative component < 50 lines of code)${RESET}`,
29
- ` ${DIM}- ${RESET}<m-name>/types.d.ts ${DIM}(props and emits interfaces)${RESET}`,
30
- ` ${DIM}- ${RESET}<m-name>/index.ts ${DIM}(clean public barrel export)${RESET}`,
31
- ` Free evaluation mode supported with non-blocking license reminder.`,
32
- ` Example: ${CYAN}npx chemx generate m-user-avatar${RESET}`,
26
+ ` ${CYAN}generate${RESET} [name] ${DIM}(aliases: capsule, add)${RESET}`,
27
+ ` Launch the interactive Molecular Capsule Generator wizard.`,
28
+ ` Scaffolds a compliant, crystalline capsule directory with:`,
29
+ ` ${DIM}- ${RESET}<name>.<ext> ${DIM}(React .tsx, Vue .vue, or Svelte .svelte < 100 lines)${RESET}`,
30
+ ` ${DIM}- ${RESET}<name>.controller.ts ${DIM}(pure reactive state & 2-stage booleans)${RESET}`,
31
+ ` ${DIM}- ${RESET}_<name>.scss ${DIM}(mixin-only glass styling with zero inline styles)${RESET}`,
32
+ ` ${DIM}- ${RESET}types.d.ts ${DIM}(discriminated union states and props interfaces)${RESET}`,
33
+ ` ${DIM}- ${RESET}index.ts ${DIM}(clean public barrel export)${RESET}`,
34
+ ` Flags: ${CYAN}--tier=m|a|o|t${RESET}, ${CYAN}--framework=react|vue|svelte${RESET}, ${CYAN}--dir=<path>${RESET}, ${CYAN}-y${RESET}`,
35
+ ` Example: ${CYAN}npx chemx generate${RESET} or ${CYAN}npx chemx generate m-user-avatar -y${RESET}`,
33
36
  '',
34
37
  ` ${CYAN}init${RESET} [directory]`,
35
38
  ` ${YELLOW}[PAID]${RESET} Drop full Chemical X blueprints, core hooks (toResult,`,
@@ -49,6 +52,13 @@ export const printHelp = () => {
49
52
  ` minimum grade/score thresholds with automatic AI prompt clipboard copying.`,
50
53
  ` Example: ${CYAN}npx chemx install-hooks${RESET}`,
51
54
  '',
55
+ ` ${CYAN}badge${RESET} [options] ${DIM}(aliases: badges)${RESET}`,
56
+ ` ${GREEN}[FREE]${RESET} Generate and copy verified Chemical X footer badges for your site.`,
57
+ ` Outputs Vue 3 SFC, React 19 TSX, Svelte 5, HTML/CSS, Markdown, or SVG.`,
58
+ ` Automatically reads latest audit grade from .chemx/history.json or baseline.`,
59
+ ` Flags: ${CYAN}--format=vue|react|html|markdown|svg|all${RESET}, ${CYAN}--grade=A+${RESET}, ${CYAN}--label="..."${RESET}, ${CYAN}--copy${RESET}`,
60
+ ` Example: ${CYAN}npx chemx badge${RESET} or ${CYAN}npx chemx badge --format=html --copy${RESET}`,
61
+ '',
52
62
  ` ${CYAN}help${RESET}, ${CYAN}--help${RESET}, ${CYAN}-h${RESET}`,
53
63
  ` Display this comprehensive CLI documentation and options guide.`,
54
64
  '',
package/cli/index.js CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  runScaffold,
16
16
  runInit,
17
17
  runGenerateCapsule,
18
+ runGenerateWizard,
18
19
  printHelp
19
20
  } from './scaffold.js';
20
21
  import {
@@ -23,18 +24,20 @@ import {
23
24
  handleShareToDiscussions
24
25
  } from './navigator.js';
25
26
  import { runInstallWizard } from './installer.js';
27
+ import { runBadgeCommand } from './badge.js';
26
28
 
27
29
  const rawArgs = process.argv.slice(2);
28
30
  const invokedBin = path.basename(process.argv[1] || '');
29
31
 
30
32
  const loadProjectConfig = () => {
33
+ const cfgPath = path.resolve(process.cwd(), '.chemx', 'config.json');
34
+ if (!fs.existsSync(cfgPath)) return {};
31
35
  try {
32
- const cfgPath = path.resolve(process.cwd(), '.chemx', 'config.json');
33
- if (fs.existsSync(cfgPath)) {
34
- return JSON.parse(fs.readFileSync(cfgPath, 'utf-8'));
35
- }
36
- } catch {}
37
- return {};
36
+ return JSON.parse(fs.readFileSync(cfgPath, 'utf-8'));
37
+ } catch (err) {
38
+ const error = err instanceof Error ? err : new Error(String(err));
39
+ return {};
40
+ }
38
41
  };
39
42
  const isCreateInvoked =
40
43
  invokedBin.includes('create-chemx') || (rawArgs[0] && rawArgs[0] === 'create');
@@ -109,7 +112,16 @@ export const runAudit = async (customDir = null, isCli = false) => {
109
112
  const isInteractive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
110
113
 
111
114
  if (isInteractive && !isUnroll) {
112
- await runInteractiveAuditNavigator(report, () => runScaffold(undefined, rawArgs, runAudit));
115
+ const handleReAudit = () => {
116
+ const refreshed = executeAstAudit(targetDir, { outputFile, model, costPerMillion });
117
+ saveAuditSnapshot(refreshed);
118
+ return refreshed;
119
+ };
120
+ await runInteractiveAuditNavigator(
121
+ report,
122
+ () => runScaffold(undefined, rawArgs, runAudit),
123
+ handleReAudit
124
+ );
113
125
  } else {
114
126
  process.stdout.write(formatTerminalReport(report));
115
127
  if (isInteractive && isUnroll) {
@@ -163,13 +175,11 @@ const main = async () => {
163
175
  case 'generate':
164
176
  case 'capsule':
165
177
  case 'add':
166
- if (!rawArgs[1]) {
167
- process.stderr.write(
168
- 'Usage: npx chemx generate <capsule-name>\nExample: npx chemx generate m-user-avatar\n'
169
- );
170
- process.exit(1);
171
- }
172
- await runGenerateCapsule(rawArgs[1]);
178
+ await runGenerateWizard(rawArgs.slice(1));
179
+ break;
180
+ case 'badge':
181
+ case 'badges':
182
+ await runBadgeCommand(rawArgs.slice(1));
173
183
  break;
174
184
  case 'help':
175
185
  case '--help':
@@ -177,8 +187,8 @@ const main = async () => {
177
187
  printHelp();
178
188
  break;
179
189
  default:
180
- if (firstArg && firstArg.startsWith('m-')) {
181
- await runGenerateCapsule(firstArg);
190
+ if (firstArg && (firstArg.startsWith('m-') || firstArg.startsWith('a-') || firstArg.startsWith('o-') || firstArg.startsWith('t-'))) {
191
+ await runGenerateWizard(rawArgs);
182
192
  } else if (firstArg && !firstArg.startsWith('-')) {
183
193
  await runScaffold(firstArg, rawArgs, runAudit);
184
194
  } else {
@@ -12,6 +12,7 @@ export interface ProjectConfig {
12
12
  maxMoleculeLineCount: number;
13
13
  }
14
14
 
15
+ export declare function resolveGitHooksDir(targetDir?: string): string | null;
15
16
  export declare function buildPreCommitHookScript(minGrade?: string, minScore?: number): string;
16
17
  export declare function buildGitHubWorkflowScript(minGrade?: string, minScore?: number): string;
17
18
  export declare function installPreCommitHook(targetDir?: string, options?: InstallOptions): boolean;
@@ -19,3 +20,4 @@ export declare function installGitHubWorkflow(targetDir?: string, options?: Inst
19
20
  export declare function saveProjectConfig(targetDir?: string, config?: Partial<ProjectConfig>): void;
20
21
  export declare function areGuardrailsInstalled(targetDir?: string): boolean;
21
22
  export declare function runInstallWizard(targetDir?: string): Promise<void>;
23
+
package/cli/installer.js CHANGED
@@ -5,12 +5,50 @@ import { buildPreCommitHookScript, buildGitHubWorkflowScript } from './installer
5
5
 
6
6
  export { buildPreCommitHookScript, buildGitHubWorkflowScript } from './installer-templates.js';
7
7
 
8
+ export const resolveGitHooksDir = (targetDir = '.') => {
9
+ const resolvedTarget = path.resolve(targetDir);
10
+ const gitPath = path.join(resolvedTarget, '.git');
11
+ if (!fs.existsSync(gitPath)) return null;
12
+
13
+ try {
14
+ const stat = fs.statSync(gitPath);
15
+ if (stat.isDirectory()) {
16
+ return path.join(gitPath, 'hooks');
17
+ }
18
+ if (stat.isFile()) {
19
+ const gitContent = fs.readFileSync(gitPath, 'utf-8');
20
+ const match = gitContent.match(/gitdir:\s*(.+)/);
21
+ if (!match) return null;
22
+
23
+ const gitDir = path.resolve(resolvedTarget, match[1].trim());
24
+ const commonDirFile = path.join(gitDir, 'commondir');
25
+ const actualGitDir = fs.existsSync(commonDirFile)
26
+ ? path.resolve(gitDir, fs.readFileSync(commonDirFile, 'utf-8').trim())
27
+ : gitDir;
28
+
29
+ return path.join(actualGitDir, 'hooks');
30
+ }
31
+ } catch {
32
+ return null;
33
+ }
34
+ return null;
35
+ };
36
+
8
37
  export const installPreCommitHook = (targetDir = '.', options = {}) => {
9
- const gitHooksDir = path.resolve(targetDir, '.git', 'hooks');
10
- if (!fs.existsSync(gitHooksDir)) fs.mkdirSync(gitHooksDir, { recursive: true });
38
+ const gitHooksDir = resolveGitHooksDir(targetDir);
39
+ if (!gitHooksDir) {
40
+ process.stdout.write(' \x1b[33m⚠\x1b[0m Skipped .git/hooks (current directory is not a git repository root or submodule).\n');
41
+ return false;
42
+ }
43
+
44
+ if (!fs.existsSync(gitHooksDir)) {
45
+ fs.mkdirSync(gitHooksDir, { recursive: true });
46
+ }
47
+
11
48
  const hookPath = path.join(gitHooksDir, 'pre-commit');
12
49
  fs.writeFileSync(hookPath, buildPreCommitHookScript(options.minGrade, options.minScore), { mode: 0o755 });
13
- process.stdout.write(` \x1b[32m✔\x1b[0m Installed git pre-commit hook: .git/hooks/pre-commit (chmod +x)\n`);
50
+ const relativeHook = path.relative(path.resolve(targetDir), hookPath);
51
+ process.stdout.write(` \x1b[32m✔\x1b[0m Installed git pre-commit hook: ${relativeHook} (chmod +x)\n`);
14
52
  return true;
15
53
  };
16
54
 
@@ -35,43 +73,19 @@ export const areGuardrailsInstalled = (targetDir = '.') => {
35
73
  const wfPath = path.join(resolvedTarget, '.github', 'workflows', 'chemx-audit.yml');
36
74
  const hasWf = fs.existsSync(wfPath);
37
75
 
38
- const gitPath = path.join(resolvedTarget, '.git');
39
- let hasGit = false;
40
- let hooksDir = null;
41
-
42
- if (fs.existsSync(gitPath)) {
43
- try {
44
- const stat = fs.statSync(gitPath);
45
- if (stat.isDirectory()) {
46
- hasGit = true;
47
- hooksDir = path.join(gitPath, 'hooks');
48
- } else if (stat.isFile()) {
49
- hasGit = true;
50
- const gitContent = fs.readFileSync(gitPath, 'utf-8');
51
- const match = gitContent.match(/gitdir:\s*(.+)/);
52
- if (match) {
53
- hooksDir = path.resolve(resolvedTarget, match[1].trim(), 'hooks');
54
- }
55
- }
56
- } catch {
57
- hasGit = false;
58
- }
59
- }
60
-
61
- if (!hasGit) {
76
+ const hooksDir = resolveGitHooksDir(resolvedTarget);
77
+ if (!hooksDir) {
62
78
  return hasWf;
63
79
  }
64
80
 
81
+ const hookPath = path.join(hooksDir, 'pre-commit');
65
82
  let hasHook = false;
66
- if (hooksDir) {
67
- const hookPath = path.join(hooksDir, 'pre-commit');
68
- if (fs.existsSync(hookPath)) {
69
- try {
70
- const hookContent = fs.readFileSync(hookPath, 'utf-8');
71
- hasHook = hookContent.includes('Chemical X') || hookContent.includes('chemx');
72
- } catch {
73
- hasHook = false;
74
- }
83
+ if (fs.existsSync(hookPath)) {
84
+ try {
85
+ const hookContent = fs.readFileSync(hookPath, 'utf-8');
86
+ hasHook = hookContent.includes('Chemical X') || hookContent.includes('chemx');
87
+ } catch {
88
+ hasHook = false;
75
89
  }
76
90
  }
77
91
 
@@ -79,7 +93,7 @@ export const areGuardrailsInstalled = (targetDir = '.') => {
79
93
  };
80
94
 
81
95
  export const runInstallWizard = async (targetDir = '.') => {
82
- const isGit = fs.existsSync(path.resolve(targetDir, '.git'));
96
+ const isGit = Boolean(resolveGitHooksDir(targetDir));
83
97
  process.stdout.write('\n\x1b[1m\x1b[38;2;98;201;255mChemical X: Architecture Guardrail Installer\x1b[0m\n\n');
84
98
  const targetChoice = hasGum()
85
99
  ? gumChoose(['1. Install All Guardrails (Git Pre-Commit Hook + GitHub CI Workflow)', '2. Git Pre-Commit Hook only (.git/hooks/pre-commit)', '3. GitHub Actions CI Workflow only (.github/workflows/chemx-audit.yml)', '4. Cancel'])
@@ -96,7 +110,7 @@ export const runInstallWizard = async (targetDir = '.') => {
96
110
 
97
111
  if (shouldHook) {
98
112
  if (isGit) installPreCommitHook(targetDir, opts);
99
- else process.stdout.write(' \x1b[33m⚠\x1b[0m Skipped .git/hooks (current directory is not a git repository root).\n');
113
+ else process.stdout.write(' \x1b[33m⚠\x1b[0m Skipped .git/hooks (current directory is not a git repository root or submodule).\n');
100
114
  }
101
115
  if (shouldWf) installGitHubWorkflow(targetDir, opts);
102
116
  saveProjectConfig(targetDir, { minGrade: opts.minGrade, minScore: opts.minScore, maxLineCount: 500, maxMoleculeLineCount: 100 });
package/cli/license.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import os from 'node:os';
4
+ import { spawnSync } from 'node:child_process';
4
5
  import {
5
6
  hasGum,
6
7
  gumChoose,
@@ -22,7 +23,10 @@ export const URL_MASTER = 'https://mycompassconsulting.com/buy/chemical-x/master
22
23
  if (!fs.existsSync(CONFIG_DIR)) {
23
24
  try {
24
25
  fs.mkdirSync(CONFIG_DIR, { recursive: true });
25
- } catch {}
26
+ } catch (err) {
27
+ const error = err instanceof Error ? err : new Error(String(err));
28
+ process.stderr.write(`Failed to create config directory: ${error.message}\n`);
29
+ }
26
30
  }
27
31
 
28
32
  export const getOrCreateDeviceId = () => {
@@ -30,12 +34,18 @@ export const getOrCreateDeviceId = () => {
30
34
  try {
31
35
  const id = fs.readFileSync(DEVICE_FILE, 'utf-8').trim();
32
36
  if (id) return id;
33
- } catch {}
37
+ } catch (err) {
38
+ const error = err instanceof Error ? err : new Error(String(err));
39
+ process.stderr.write(`Failed to read device id: ${error.message}\n`);
40
+ }
34
41
  }
35
42
  const newId = `cli_${Math.random().toString(36).substring(2, 12)}_${Date.now()}`;
36
43
  try {
37
44
  fs.writeFileSync(DEVICE_FILE, newId, 'utf-8');
38
- } catch {}
45
+ } catch (err) {
46
+ const error = err instanceof Error ? err : new Error(String(err));
47
+ process.stderr.write(`Failed to write device id: ${error.message}\n`);
48
+ }
39
49
  return newId;
40
50
  };
41
51
 
@@ -58,7 +68,10 @@ export const saveLicenseKey = (licenseKey) => {
58
68
  JSON.stringify({ licenseKey, updatedAt: new Date().toISOString() }, null, 2),
59
69
  'utf-8'
60
70
  );
61
- } catch {}
71
+ } catch (err) {
72
+ const error = err instanceof Error ? err : new Error(String(err));
73
+ process.stderr.write(`Failed to cache license key: ${error.message}\n`);
74
+ }
62
75
  };
63
76
 
64
77
  const resolveFlagLicense = (args) => {
@@ -15,6 +15,8 @@ import {
15
15
  formatGradeCSection,
16
16
  formatGradeBSection,
17
17
  formatGradeASection,
18
+ formatAiSlopSection,
19
+ formatHotspotsSection,
18
20
  getAuditHistory,
19
21
  getAuditBaseline,
20
22
  createSnapshotFromReport,
@@ -24,6 +26,8 @@ import {
24
26
  buildGradeDPrompt,
25
27
  buildGradeCPrompt,
26
28
  buildGradeBPrompt,
29
+ buildAiSlopPrompt,
30
+ buildHotspotsPrompt,
27
31
  buildMasterPrompt,
28
32
  copyToClipboard
29
33
  } from "./audit.js";
@@ -33,6 +37,7 @@ import { showConversionMenu } from "./navigator-conversion.js";
33
37
  import { handleShareToDiscussions } from "./navigator-share.js";
34
38
  import { runInstallWizard } from "./installer.js";
35
39
  import { formatButtonTag } from "./navigator-menu.js";
40
+ import { runBadgeCommand } from "./badge.js";
36
41
 
37
42
  const isExtremeMonolith = (h) => h.lineCount >= 2000;
38
43
  const isSevereMonolith = (h) => h.lineCount >= 1000 && h.lineCount < 2000;
@@ -71,6 +76,10 @@ export const buildActiveGrades = (report) => {
71
76
  const handleGradeFAction = async () => {
72
77
  await showPagedContent(formatGradeFSection(report), buildGradeFPrompt(report));
73
78
  };
79
+ const slopViolations = (violations || []).filter((v) => v.isAiSlop);
80
+ const handleSlopAction = async () => {
81
+ await showPagedContent(formatAiSlopSection(report), buildAiSlopPrompt(report));
82
+ };
74
83
 
75
84
  const gradeTiers = [
76
85
  {
@@ -80,6 +89,13 @@ export const buildActiveGrades = (report) => {
80
89
  description: "Compliant Checks & Passing Pillars",
81
90
  action: handleGradeAAction
82
91
  },
92
+ {
93
+ grade: report.aiSlop?.grade || (slopViolations.length > 0 ? "D" : "A"),
94
+ count: slopViolations.length,
95
+ icon: "🤖",
96
+ description: `AI Slop & Authenticity (${report.aiSlop?.score ?? 100}/100 - ${report.aiSlop?.label ?? "Pure Artisanal"})`,
97
+ action: handleSlopAction
98
+ },
83
99
  {
84
100
  grade: "B",
85
101
  count: gradeBCount,
@@ -121,7 +137,7 @@ export const buildActiveGrades = (report) => {
121
137
  return gradeTiers.filter(hasGradeItems).map(createActiveGradeItem);
122
138
  };
123
139
 
124
- export const buildDashboardActionGroups = ({ report, onScaffold = null }) => {
140
+ export const buildDashboardActionGroups = ({ report, onScaffold = null, onRerun = null }) => {
125
141
  const handleInstallAction = async () => {
126
142
  await runInstallWizard(process.cwd());
127
143
  if (hasGum()) {
@@ -137,6 +153,12 @@ export const buildDashboardActionGroups = ({ report, onScaffold = null }) => {
137
153
  await showPagedContent(formatTerminalReport(report), buildMasterPrompt(report));
138
154
  };
139
155
 
156
+ const handleRerunAction = async () => {
157
+ if (onRerun) {
158
+ await onRerun();
159
+ }
160
+ };
161
+
140
162
  const handleShareAction = async () => {
141
163
  await handleShareToDiscussions(report);
142
164
  };
@@ -173,6 +195,16 @@ export const buildDashboardActionGroups = ({ report, onScaffold = null }) => {
173
195
  }
174
196
  };
175
197
 
198
+ const handleBadgeAction = async () => {
199
+ const grade = report?.health?.grade || 'A+';
200
+ await runBadgeCommand([`--grade=${grade}`]);
201
+ if (hasGum()) {
202
+ gumChoose(["<-- Back to Audit Dashboard"]);
203
+ } else {
204
+ await promptQuestion("Press Enter to return to menu...");
205
+ }
206
+ };
207
+
176
208
  const handleCopyPromptAction = async () => {
177
209
  const masterPrompt = buildMasterPrompt(report);
178
210
  if (!masterPrompt) {
@@ -196,8 +228,20 @@ export const buildDashboardActionGroups = ({ report, onScaffold = null }) => {
196
228
  }
197
229
  };
198
230
 
231
+ const handleHotspotsAction = async () => {
232
+ await showPagedContent(formatHotspotsSection(report), buildHotspotsPrompt(report));
233
+ };
234
+
199
235
  const handleExitAction = async () => {};
200
236
 
237
+ const monolithHotspots = (report?.hotspots || []).filter((h) => h.isMonolith || h.lineCount > 500);
238
+ const hotspotsAction = {
239
+ key: "hotspots",
240
+ tag: formatButtonTag("Hotspots", "\x1b[38;5;208m"),
241
+ label: `🔥 Top Refactoring Hotspots & Monoliths (${monolithHotspots.length} files)`,
242
+ action: handleHotspotsAction
243
+ };
244
+
201
245
  const installAction = {
202
246
  key: "install",
203
247
  tag: formatButtonTag("Install", "\x1b[32m"),
@@ -219,6 +263,13 @@ export const buildDashboardActionGroups = ({ report, onScaffold = null }) => {
219
263
  action: handleReportAction
220
264
  };
221
265
 
266
+ const rerunAction = {
267
+ key: "rerun",
268
+ tag: formatButtonTag("Re-Run", "\x1b[32m"),
269
+ label: "🔄 Re-Run Architecture Audit & Refresh Scorecard",
270
+ action: handleRerunAction
271
+ };
272
+
222
273
  const shareAction = {
223
274
  key: "share",
224
275
  tag: formatButtonTag("Share", "\x1b[35m"),
@@ -240,6 +291,13 @@ export const buildDashboardActionGroups = ({ report, onScaffold = null }) => {
240
291
  action: handleExportAction
241
292
  };
242
293
 
294
+ const badgeAction = {
295
+ key: "badge",
296
+ tag: formatButtonTag("Badge", "\x1b[38;2;98;201;255m"),
297
+ label: "🏷️ Get Chemical X Footer Badge (Vue, React, HTML)",
298
+ action: handleBadgeAction
299
+ };
300
+
243
301
  const copyPromptAction = {
244
302
  key: "prompt",
245
303
  tag: formatButtonTag("Prompt", "\x1b[38;2;98;201;255m"),
@@ -264,9 +322,13 @@ export const buildDashboardActionGroups = ({ report, onScaffold = null }) => {
264
322
  installAction,
265
323
  upgradeAction,
266
324
  reportAction,
325
+ rerunAction,
267
326
  shareAction,
268
327
  progressAction,
269
328
  exportAction,
329
+ badgeAction,
330
+ hotspotsAction,
331
+ hasHotspots: monolithHotspots.length > 0,
270
332
  copyPromptAction,
271
333
  exitAction,
272
334
  shouldShowPromptAction
@@ -15,10 +15,16 @@ const visualWidth = (s) => {
15
15
  };
16
16
 
17
17
  const resolveProjectName = () => {
18
- try {
19
- const pkgPath = path.resolve(process.cwd(), "package.json");
20
- if (fs.existsSync(pkgPath)) return JSON.parse(fs.readFileSync(pkgPath, "utf-8")).name || path.basename(process.cwd());
21
- } catch {}
18
+ const pkgPath = path.resolve(process.cwd(), "package.json");
19
+ if (fs.existsSync(pkgPath)) {
20
+ try {
21
+ const parsed = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
22
+ return parsed.name || path.basename(process.cwd());
23
+ } catch (err) {
24
+ const error = err instanceof Error ? err : new Error(String(err));
25
+ return path.basename(process.cwd()) || "Project";
26
+ }
27
+ }
22
28
  return path.basename(process.cwd()) || "Project";
23
29
  };
24
30
 
@@ -31,7 +37,8 @@ export const renderDashboardBanner = (
31
37
  critical,
32
38
  highMediumCount,
33
39
  low,
34
- contextAnalysis = null
40
+ contextAnalysis = null,
41
+ aiSlop = null
35
42
  ) => {
36
43
  if (process.stdout.isTTY) console.clear();
37
44
  process.stdout.write(getChemicalXAsciiBanner(health.grade));
@@ -44,7 +51,11 @@ export const renderDashboardBanner = (
44
51
  const hearts = resolveHealthHearts(health.grade, health.score);
45
52
  const scoreBadge = `${health.score}/100 [Grade: ${health.grade}]`;
46
53
  const labelStr = health.label ? ` (${health.label})` : "";
47
- const healthStr = `${hearts} ${gColor}${scoreBadge}\x1b[0m${gColor}${labelStr}\x1b[0m`;
54
+ const slopScore = aiSlop?.score ?? 100;
55
+ const slopGrade = aiSlop?.grade ?? "A+";
56
+ const slopColor = resolveGradeColor(slopGrade);
57
+ const slopStr = aiSlop ? ` | ASI: ${slopColor}${slopScore}/100 [${slopGrade}]\x1b[0m` : "";
58
+ const healthStr = `${hearts} ${gColor}${scoreBadge}\x1b[0m${gColor}${labelStr}\x1b[0m${slopStr}`;
48
59
 
49
60
  const filesStr = `${metrics.scannedFiles} Files`;
50
61
  const locStr = `${(metrics.totalLoc || 0).toLocaleString()}`;
@@ -85,3 +85,12 @@ export const resolveContextGrade = (riskTier) => {
85
85
  if (riskTier === 'HIGH') return 'D';
86
86
  return 'F';
87
87
  };
88
+
89
+ export const resolveAiSlopGrade = (score = 100) => {
90
+ if (score >= 95) return 'A+';
91
+ if (score >= 90) return 'A';
92
+ if (score >= 80) return 'B';
93
+ if (score >= 70) return 'C';
94
+ if (score >= 60) return 'D';
95
+ return 'F';
96
+ };
@@ -51,6 +51,21 @@ const isChoiceMatchingItem = (cleanChoice) => (item) => {
51
51
  ) {
52
52
  return true;
53
53
  }
54
+ if (
55
+ item.key === "rerun" &&
56
+ (cleanChoice.includes("Re-Run") ||
57
+ cleanChoice.includes("Rerun") ||
58
+ cleanChoice.includes("Re-run") ||
59
+ cleanChoice.includes("Re-Audit"))
60
+ ) {
61
+ return true;
62
+ }
63
+ if (
64
+ item.key === "hotspots" &&
65
+ (cleanChoice.includes("Hotspots") || cleanChoice.includes("Monoliths"))
66
+ ) {
67
+ return true;
68
+ }
54
69
  if (item.key === "progress" && cleanChoice.includes("Progress")) return true;
55
70
  if (
56
71
  item.key === "share" &&
@@ -61,6 +76,12 @@ const isChoiceMatchingItem = (cleanChoice) => (item) => {
61
76
  return true;
62
77
  }
63
78
  if (item.key === "export" && cleanChoice.includes("Export")) return true;
79
+ if (
80
+ item.key === "badge" &&
81
+ (cleanChoice.includes("Badge") || cleanChoice.includes("Footer Badge"))
82
+ ) {
83
+ return true;
84
+ }
64
85
  if (
65
86
  item.key === "install" &&
66
87
  (cleanChoice.includes("Install") ||
@@ -113,7 +134,22 @@ const isEffectiveMatchingItem = (effective, exitIndex) => (item) => {
113
134
  ) {
114
135
  return true;
115
136
  }
137
+ if (
138
+ item.key === "rerun" &&
139
+ (effective === "rerun" ||
140
+ effective === "re-run" ||
141
+ effective === "r" ||
142
+ effective === "reaudit")
143
+ ) {
144
+ return true;
145
+ }
116
146
  if (item.key === "share" && (effective === "share" || effective === "post")) return true;
147
+ if (
148
+ item.key === "hotspots" &&
149
+ (effective === "hotspots" || effective === "hotspot" || effective === "h" || effective === "monoliths")
150
+ ) {
151
+ return true;
152
+ }
117
153
  if (item.key === effective) return true;
118
154
  if (item.grade && (effective === item.grade || effective === `grade ${item.grade}`)) {
119
155
  return true;
@@ -57,13 +57,16 @@ export const handleShareToDiscussions = async (report) => {
57
57
  }
58
58
 
59
59
  let detectedSite = '';
60
- try {
61
- const pkgPath = path.resolve(process.cwd(), 'package.json');
62
- if (fs.existsSync(pkgPath)) {
60
+ const pkgPath = path.resolve(process.cwd(), 'package.json');
61
+ if (fs.existsSync(pkgPath)) {
62
+ try {
63
63
  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
64
64
  detectedSite = pkg.homepage || pkg.website || '';
65
+ } catch (err) {
66
+ const error = err instanceof Error ? err : new Error(String(err));
67
+ detectedSite = '';
65
68
  }
66
- } catch {}
69
+ }
67
70
 
68
71
  const stored = getStoredDiscussion();
69
72
  if (!detectedSite && stored?.website) {
@@ -40,4 +40,8 @@ export declare function renderDashboardBanner(
40
40
  low: readonly unknown[],
41
41
  contextAnalysis?: AuditReport['contextAnalysis'] | null
42
42
  ): void;
43
- export declare function runInteractiveAuditNavigator(report: AuditReport, onScaffold?: (() => Promise<void>) | null): Promise<void>;
43
+ export declare function runInteractiveAuditNavigator(
44
+ report: AuditReport,
45
+ onScaffold?: (() => Promise<void>) | null,
46
+ onReAudit?: (() => Promise<AuditReport> | AuditReport) | null
47
+ ): Promise<void>;