@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/navigator.js CHANGED
@@ -1,3 +1,4 @@
1
+ import fs from "node:fs";
1
2
  import {
2
3
  hasGum,
3
4
  gumChoose,
@@ -5,7 +6,7 @@ import {
5
6
  stripAnsi,
6
7
  confirmAction
7
8
  } from "./terminal.js";
8
- import { saveAuditSnapshot, groupViolationsBySeverity } from "./audit.js";
9
+ import { runAudit, saveAuditSnapshot, groupViolationsBySeverity } from "./audit.js";
9
10
  import { areGuardrailsInstalled } from "./installer.js";
10
11
  import { renderDashboardBanner } from "./navigator-banner.js";
11
12
  import {
@@ -29,7 +30,8 @@ export {
29
30
  resolveLowGrade,
30
31
  resolvePillarGrade,
31
32
  resolveHotspotGrade,
32
- resolveContextGrade
33
+ resolveContextGrade,
34
+ resolveAiSlopGrade
33
35
  } from "./navigator-grades.js";
34
36
  export { extractPromptFromContent, showPagedContent } from "./navigator-paged.js";
35
37
  export { showConversionMenu } from "./navigator-conversion.js";
@@ -37,16 +39,47 @@ export { handleShareToDiscussions } from "./navigator-share.js";
37
39
  export { formatButtonTag, buildNavigatorMenu } from "./navigator-menu.js";
38
40
  export { renderDashboardBanner } from "./navigator-banner.js";
39
41
 
40
- export const runInteractiveAuditNavigator = async (report, onScaffold = null) => {
42
+ export const runInteractiveAuditNavigator = async (initialReport, onScaffold = null, onReAudit = null) => {
43
+ let report = initialReport;
41
44
  saveAuditSnapshot(report);
42
- const { metrics, health, violations, contextAnalysis } = report;
43
- const { critical, high, medium, low } = groupViolationsBySeverity(violations);
44
- const highMediumCount = high.length + medium.length;
45
+ let { metrics, health, violations, contextAnalysis, aiSlop } = report;
46
+ let { critical, high, medium, low } = groupViolationsBySeverity(violations);
47
+ let highMediumCount = high.length + medium.length;
48
+
49
+ const handleRerun = async () => {
50
+ process.stdout.write("\n\x1b[36m⟳ Re-running architectural audit...\x1b[0m\n");
51
+ if (onReAudit) {
52
+ report = await onReAudit();
53
+ } else {
54
+ const targetDir = report?.targetDir || (fs.existsSync("src") ? "src" : ".");
55
+ const options = report?.options || {};
56
+ report = runAudit(targetDir, options);
57
+ }
58
+ saveAuditSnapshot(report);
59
+
60
+ metrics = report.metrics;
61
+ health = report.health;
62
+ violations = report.violations;
63
+ contextAnalysis = report.contextAnalysis;
64
+ aiSlop = report.aiSlop;
65
+
66
+ const grouped = groupViolationsBySeverity(violations);
67
+ critical = grouped.critical;
68
+ high = grouped.high;
69
+ medium = grouped.medium;
70
+ low = grouped.low;
71
+ highMediumCount = high.length + medium.length;
45
72
 
46
- const activeGrades = buildActiveGrades(report);
47
- const actions = buildDashboardActionGroups({ report, onScaffold });
73
+ activeGrades = buildActiveGrades(report);
74
+ actions = buildDashboardActionGroups({ report, onScaffold, onRerun: handleRerun });
48
75
 
49
- renderDashboardBanner(health, metrics, violations, critical, highMediumCount, low, contextAnalysis);
76
+ process.stdout.write(`\x1b[32m✔ Audit refreshed: ${health.score}/100 [Grade: ${health.grade}]\x1b[0m\n\n`);
77
+ };
78
+
79
+ let activeGrades = buildActiveGrades(report);
80
+ let actions = buildDashboardActionGroups({ report, onScaffold, onRerun: handleRerun });
81
+
82
+ renderDashboardBanner(health, metrics, violations, critical, highMediumCount, low, contextAnalysis, aiSlop);
50
83
 
51
84
  const shouldPublish = await confirmAction(
52
85
  "Publish audit report and promote your project to our GitHub Discussions Audits Forum?",
@@ -60,16 +93,20 @@ export const runInteractiveAuditNavigator = async (report, onScaffold = null) =>
60
93
  }
61
94
 
62
95
  while (true) {
63
- renderDashboardBanner(health, metrics, violations, critical, highMediumCount, low, contextAnalysis);
96
+ renderDashboardBanner(health, metrics, violations, critical, highMediumCount, low, contextAnalysis, aiSlop);
64
97
 
65
98
  const guardrailsInstalled = areGuardrailsInstalled(process.cwd());
66
99
  const topActions = [];
67
100
  if (!guardrailsInstalled) {
68
101
  topActions.push(actions.installAction);
69
102
  }
70
- topActions.push(actions.upgradeAction, actions.reportAction);
103
+ topActions.push(actions.upgradeAction, actions.reportAction, actions.rerunAction);
71
104
 
72
- const midActions = [actions.shareAction, actions.progressAction, actions.exportAction];
105
+ const midActions = [];
106
+ if (actions.hasHotspots) {
107
+ midActions.push(actions.hotspotsAction);
108
+ }
109
+ midActions.push(actions.shareAction, actions.progressAction, actions.exportAction, actions.badgeAction);
73
110
  const bottomActions = [];
74
111
  if (actions.shouldShowPromptAction) {
75
112
  bottomActions.push(actions.copyPromptAction);
package/cli/scaffold.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { hasGum, gumInput, promptQuestion, renderBanner } from './terminal.js';
4
- import { obtainLicenseKey, fetchStarterKitFiles, checkOrPromptEvaluation } from './license.js';
4
+ import { obtainLicenseKey, fetchStarterKitFiles } from './license.js';
5
5
 
6
6
  export const runScaffold = async (projectName, rawArgs = [], onRunAudit = null) => {
7
7
  renderBanner('Chemical X: Molecular Architecture Scaffolder (npm create chemx)');
@@ -92,57 +92,6 @@ export const runInit = async (targetSubDir = 'src/chemical-x', rawArgs = [], onR
92
92
  );
93
93
  };
94
94
 
95
- export const runGenerateCapsule = async (capsuleName) => {
96
- await checkOrPromptEvaluation('generate capsule');
97
-
98
- const normalizedName = capsuleName.startsWith('m-') ? capsuleName : `m-${capsuleName}`;
99
- const targetDir = path.resolve(process.cwd(), normalizedName);
100
-
101
- if (fs.existsSync(targetDir)) {
102
- process.stderr.write(`\x1b[31m✕ Error: Directory ${normalizedName} already exists.\x1b[0m\n`);
103
- process.exit(1);
104
- }
105
-
106
- fs.mkdirSync(targetDir, { recursive: true });
107
-
108
- const pascalName = normalizedName
109
- .split('-')
110
- .map((p) => p.charAt(0).toUpperCase() + p.slice(1))
111
- .join('');
112
-
113
- const componentCode = `import React from 'react';
114
- import type { ${pascalName}Props } from './types';
115
-
116
- export const ${pascalName}: React.FC<${pascalName}Props> = ({ label }) => {
117
- return (
118
- <div className="${normalizedName}">
119
- <span>{label}</span>
120
- </div>
121
- );
122
- };
123
-
124
- export default ${pascalName};
125
- `;
126
-
127
- const typesCode = `export interface ${pascalName}Props {
128
- readonly label: string;
129
- }
130
- `;
131
-
132
- const indexCode = `export { ${pascalName} } from './${normalizedName}';
133
- export type { ${pascalName}Props } from './types';
134
- `;
135
-
136
- fs.writeFileSync(path.join(targetDir, `${normalizedName}.tsx`), componentCode, 'utf-8');
137
- fs.writeFileSync(path.join(targetDir, 'types.d.ts'), typesCode, 'utf-8');
138
- fs.writeFileSync(path.join(targetDir, 'index.ts'), indexCode, 'utf-8');
139
-
140
- process.stdout.write(
141
- `\x1b[32m✔ Successfully generated crystalline capsule:\x1b[0m ${normalizedName}/\n`
142
- );
143
- process.stdout.write(` - ${normalizedName}/${normalizedName}.tsx (< 50 lines)\n`);
144
- process.stdout.write(` - ${normalizedName}/types.d.ts\n`);
145
- process.stdout.write(` - ${normalizedName}/index.ts\n\n`);
146
- };
147
-
95
+ export { runGenerateCapsule, runGenerateWizard } from './generator.js';
148
96
  export { printHelp } from './help.js';
97
+
package/cli/terminal.js CHANGED
@@ -11,7 +11,10 @@ export const openBrowser = (url) => {
11
11
  } else {
12
12
  spawnSync("xdg-open", [url], { stdio: "ignore" });
13
13
  }
14
- } catch {}
14
+ } catch (err) {
15
+ const error = err instanceof Error ? err : new Error(String(err));
16
+ process.stderr.write(`Failed to open browser: ${error.message}\n`);
17
+ }
15
18
  };
16
19
 
17
20
  export const hasGum = () => {
package/docs/CHANGELOG.md CHANGED
@@ -18,12 +18,62 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
18
18
 
19
19
  ## [2026-09-11]
20
20
 
21
+ ### Added
22
+ - Expanded AST static analysis engine with Pillars 8 to 11 (`cli/audit/extended-visitors.js`): added automated rules and visitors for Accessibility & Semantic Integrity (`A11Y_CLICKABLE_NON_SEMANTIC`, `A11Y_IMAGE_MISSING_ALT`), Security & Content Safety (`SECURITY_RAW_HTML_INJECTION`, `SECURITY_HARDCODED_SECRET`), Testing Discipline (`TEST_FAKE_GREEN`, `TEST_MISSING_COLOCATED`), and Naming Conventions (`NAMING_BARE_BOOLEAN`, `NAMING_HANDLER_PREFIX`).
23
+ - Implemented nested bullet tree path-chain formatter (`formatGroupedPromptViolations` in `cli/audit/prompts.js`), clustering violations by rule and rendering folder hierarchy steps as indented bullet chains (`* app/` -> `* components/` -> `* molecules/` -> leaf files with line hits) to eliminate boilerplate repetitions and slash AI prompt token consumption by up to 85%.
24
+ - Consolidated monolith refactoring action directives across `buildHotspotsPrompt`, `buildGradeFPrompt`, `buildGradeDPrompt`, and `buildGradeCPrompt`, stating action requirements once per section.
25
+ - Added `{ excludeAiSlop }` filter options to grade prompt builders to prevent duplicate slop violation listings in `buildMasterPrompt`.
26
+ - Added `{ includePrompt: false }` flag to `formatHotspotsSection` and `formatAiSlopSection` when rendered within full terminal report (`cli/audit/reporter.js`), preventing mid-report prompt box duplication before the master prompt.
27
+ - Added AI Agent refactoring prompt generator for AI Slop & Authenticity (`buildAiSlopPrompt` in `cli/audit/prompts.js`), generating surgical instructions to eliminate conversational residue, lazy placeholders, echo comments, shallow catch blocks, and reinvented utilities.
28
+ - Added AI Agent refactoring prompt generator for Top Refactoring Hotspots (`buildHotspotsPrompt` in `cli/audit/prompts.js`), providing phased decomposition plans for files exceeding line budgets.
29
+ - Integrated AI Slop and Hotspots prompt boxes into report sections (`formatAiSlopSection`, `formatHotspotsSection` in `cli/audit/reporter-sections.js`), composite master prompt (`buildMasterPrompt`), and interactive navigator inspection views (`cli/navigator-actions.js`, `cli/navigator.js`, `cli/navigator-menu.js`).
30
+ - Appended Section 8 (Accessibility & Semantic Integrity), Section 9 (Security & Content Safety), Section 10 (Testing Discipline), and Section 11 (Naming Conventions) to Chemical X Molecular Architecture Directives (`AGENTS.md`).
31
+ - Interactive `[ Re-Run ]` dashboard action positioned directly below `[Full Report]` in the Audit Navigator (`cli/navigator.js`, `cli/navigator-actions.js`, `cli/navigator-menu.js`), enabling developers to rescan their codebase and dynamically refresh the Gamer HUD scorecard and grade drill-downs without restarting the CLI.
32
+ - Compact directory and rule-based problem grouping engine (`cli/audit/reporter-grouping.js`, `cli/audit/reporter-grouping-markdown.js`, `cli/audit/reporter-grouping.d.ts`), clustering violations by directory and rule type to eliminate repetitive multi-line output bloat in audit reports.
33
+ - `HAZARD DISTRIBUTION BY DIRECTORY` terminal scorecard (`formatDirectoryDistributionSection`) and Markdown directory rollup table (`formatDirectoryRollupMarkdown`) displaying total hazard density and severity breakdown per directory.
34
+ - Compact location formatter (`formatCompactLocations`) clustering affected files and line numbers under folder badges.
35
+ - Pure deterministic AI Slop Index (ASI) and code authenticity engine (`cli/audit/ai-slop-detector.js`) detecting LLM conversational preambles, leaked markdown fences, lazy truncation placeholders, shallow catch paranoia wrappers, redundant passthrough assignments, inline utility reinventions, and trivial echo comments.
36
+ - Registered AI slop rules (`AI_SLOP_CONVERSATIONAL_ARTIFACT`, `AI_SLOP_LAZY_PLACEHOLDER`, `AI_SLOP_SHALLOW_CATCH`, `AI_SLOP_UTILITY_REINVENTION`, `AI_SLOP_ECHO_COMMENT`, `AI_SLOP_LAZY_ANY`, `AI_SLOP_REDUNDANT_PASSTHROUGH`) in `RULE_REGISTRY` (`cli/audit/rules-registry.js`).
37
+ - Added `calculateAiSlopScore` to compute dedicated 0 to 100 authenticity score and letter grades (`A+` to `F`), isolating slop penalties from architectural Molecular Health Index (`cli/audit/metrics.js`).
38
+ - Integrated AI Slop Index (ASI) metrics and dedicated audit section into full terminal report (`formatAiSlopSection` in `cli/audit/reporter.js`) and Markdown audit report (`cli/audit/reporter-markdown.js`).
39
+ - Added Shields.io AI Slop badge and Before vs. After delta progression rows to GitHub Discussions shared social cards (`cli/audit/social.js`).
40
+ - Added AI Slop score indicator to Gamer HUD banner (`cli/navigator-banner.js`), active grade navigator actions (`cli/navigator-actions.js`), and grade resolution helpers (`cli/navigator-grades.js`, `cli/navigator.js`).
41
+ - Interactive Molecular Capsule Generator wizard for `npx chemx generate` (and aliases `capsule`, `add`), supporting Gum and ANSI fallbacks (`cli/generator.js`, `cli/generator.d.ts`).
42
+ - Multi-framework scaffolding support for React 19 (`.tsx`), Vue 3.4+ (`.vue`), and Svelte 5 (`.svelte`) with scoped SCSS, controllers, and discriminated union types (`cli/generator-templates.js`).
43
+ - CLI flags for non-interactive and fast capsule generation (`--tier`, `--framework`, `--dir`, `--lean`, `-y` / `--yes`).
44
+ - Verified Chemical X Footer Badge command and generator (`npx chemx badge` / `cli/badge.js`), providing copyable snippets for Vue 3 SFC, React 19 TSX, Svelte 5, HTML/CSS, Markdown Shields, and SVG asset export.
45
+ - Integrated `[ Badge ]` action into the interactive Audit Navigator dashboard (`cli/navigator-actions.js`, `cli/navigator.js`, `cli/navigator-menu.js`).
46
+ - Added `m-chemx-badge` blueprint capsule with Vue 3, React 19, SCSS, and TypeScript declarations (`blueprints/molecule-capsule/m-chemx-badge/`).
47
+
48
+ - Added co-located unit test suite for `m-chemx-badge` capsule (`blueprints/molecule-capsule/m-chemx-badge/m-chemx-badge.spec.ts`) covering grade classification tiers and component markup attributes.
49
+ - Added co-located unit test suite for `m-sample-card` capsule (`blueprints/molecule-capsule/m-sample-card.spec.ts`) covering badge descriptor resolution, formatting, and interactive action handling.
50
+
21
51
  ### Changed
52
+ - Exported `resolveGradeClass` from `m-chemx-badge` entrypoints for isolated testing and external consumption.
53
+ - Exported `resolveBadgeDescriptor` and co-located `SampleCardBadgeDescriptor` type declaration in `blueprints/molecule-capsule/` capsule.
54
+ - Decomposed warning monolith `cli/audit/reporter.js` (513 lines to 125 lines) to eliminate Grade C medium severity technical debt, extracting single-purpose modules `cli/audit/reporter-banner.js` (75 lines), `cli/audit/reporter-sections.js` (238 lines), and `cli/audit/reporter-summary.js` (143 lines).
55
+ - Co-located granular TypeScript declaration capsules (`cli/audit/reporter.d.ts`, `cli/audit/reporter-banner.d.ts`, `cli/audit/reporter-sections.d.ts`, `cli/audit/reporter-summary.d.ts`) all under 20 lines, updating `cli/audit/types.d.ts` to re-export domain capsules.
56
+ - Extracted anonymous inline callbacks into named predicates and iterator handlers across terminal section formatters.
57
+ - Preserved 100% backward-compatible re-exports in `cli/audit/reporter.js` for seamless consumption across CLI actions and tools.
58
+ - Streamlined terminal reports (`formatTerminalReport`, `formatCriticalSection`, `formatHighMediumSection`, `formatLowSection`, `formatFailuresSection` in `cli/audit/reporter.js`) and grade drill-down views (`formatGradeFSection`, `formatGradeDSection`, `formatGradeCSection`, `formatGradeBSection` in `cli/audit/reporter-grades.js`) to display deduplicated rule descriptions and directives once with grouped directory location paths.
59
+ - Streamlined Markdown audit report (`cli/audit/reporter-markdown.js`) Section 4 to group problems by directory and rule with concise location links, eliminating hundreds of repetitive table rows.
22
60
  - Conditioned `[ Prompt ] 📋 Copy AI Prompt Fix to Clipboard` dashboard action to hide when the codebase earns a pristine Grade A+ with no pending refactoring prompt (`cli/navigator.js`, `cli/navigator-actions.js`).
23
61
  - Added early-return guard clause to `handleCopyPromptAction` preventing empty clipboard copy operations on pristine Grade A+ audits (`cli/navigator-actions.js`).
24
62
 
25
63
  ### Fixed
64
+ - Remediated 22 AI Slop hazards across `cli/` and `cli/audit/` to restore AI Slop Index (ASI) from 31/100 (Grade F) to 100/100 (Grade A+):
65
+ - Fixed self-matching regex detection patterns in `cli/audit/ai-slop-detector.js` (`AI_SLOP_CONVERSATIONAL_ARTIFACT`) by assembling detection patterns from string token arrays.
66
+ - Replaced 10 shallow catch blocks in `cli/audit/social-git.js` with functional Result Tuple helpers (`safeSpawnSync` and `safeReadJson`) per Chemical X Section 2.C.
67
+ - Eliminated 10 shallow catch paranoia wrappers with normalized error diagnostics and explicit fallback returns across `cli/audit/history.js`, `cli/index.js`, `cli/license.js`, `cli/navigator-banner.js`, `cli/navigator-share.js`, and `cli/terminal.js`.
68
+ - Fixed pre-commit hook installer failure (`ENOTDIR`) in git submodules and worktrees where `.git` is a pointer file rather than a directory by introducing `resolveGitHooksDir` to resolve `gitdir:` targets (`cli/installer.js`, `cli/installer.d.ts`).
69
+ - Fixed missing `spawnSync` import from `node:child_process` in evaluation check prompt causing runtime reference error (`cli/license.js`).
26
70
  - Fixed typographical artifact (`and p`) in the interactive audit publication confirmation prompt across navigator and terminal handlers (`cli/navigator.js`, `cli/terminal.js`).
71
+ - Eliminated trivial echo comments (`AI_SLOP_ECHO_COMMENT`) in `cli/audit/social-git.js` that redundantly repeated self-documenting git commands.
72
+ - Eliminated self-matching AI truncation placeholder hazard in `cli/audit/prompts.js` (`AI_SLOP_LAZY_PLACEHOLDER`) to prevent self-audit false positive.
73
+ - Eliminated self-matching `A11Y_IMAGE_MISSING_ALT` hazard on `cli/audit/extended-visitors.js` by assembling tokenized template regexes and scoping template tag checks to template files.
74
+ - Replaced shallow catch paranoia wrapper (`AI_SLOP_SHALLOW_CATCH`) in `cli/audit/extended-visitors.js` with `toResultSync` Result Tuple pattern and 2-stage atomic boolean composition per Chemical X Section 2.C and 3.A.
75
+ - Exported shared `toResultSync` synchronous Result Tuple helper from `cli/audit/rules-helpers.js`.
76
+
27
77
 
28
78
  ## [2026-09-10]
29
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chemx/starter-kit",
3
- "version": "26.9.11-481",
3
+ "version": "26.9.12-107",
4
4
  "description": "Chemical X Protocol: Private drop-in architecture starter kit and capsule generator",
5
5
  "type": "module",
6
6
  "bin": {