@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.
- package/cli/audit/ai-slop-detector.js +262 -0
- package/cli/audit/extended-visitors.js +359 -0
- package/cli/audit/history.js +19 -2
- package/cli/audit/metrics.js +69 -0
- package/cli/audit/prompts.js +175 -48
- package/cli/audit/reporter-banner.d.ts +3 -0
- package/cli/audit/reporter-banner.js +74 -0
- package/cli/audit/reporter-grades.js +11 -26
- package/cli/audit/reporter-grouping-markdown.js +83 -0
- package/cli/audit/reporter-grouping.d.ts +42 -0
- package/cli/audit/reporter-grouping.js +243 -0
- package/cli/audit/reporter-markdown.js +34 -22
- package/cli/audit/reporter-sections.d.ts +10 -0
- package/cli/audit/reporter-sections.js +259 -0
- package/cli/audit/reporter-summary.d.ts +4 -0
- package/cli/audit/reporter-summary.js +142 -0
- package/cli/audit/reporter-utils.js +13 -1
- package/cli/audit/reporter.d.ts +16 -0
- package/cli/audit/reporter.js +47 -420
- package/cli/audit/rules-helpers.js +16 -0
- package/cli/audit/rules-registry.js +88 -1
- package/cli/audit/rules.js +32 -1
- package/cli/audit/social-git.js +133 -131
- package/cli/audit/social.js +15 -2
- package/cli/audit/types.d.ts +28 -27
- package/cli/audit.js +56 -3
- package/cli/badge.js +262 -0
- package/cli/generator-templates.js +264 -0
- package/cli/generator.d.ts +10 -0
- package/cli/generator.js +151 -0
- package/cli/help.js +17 -7
- package/cli/index.js +26 -16
- package/cli/installer.d.ts +2 -0
- package/cli/installer.js +52 -38
- package/cli/license.js +17 -4
- package/cli/navigator-actions.js +63 -1
- package/cli/navigator-banner.js +17 -6
- package/cli/navigator-grades.js +9 -0
- package/cli/navigator-menu.js +36 -0
- package/cli/navigator-share.js +7 -4
- package/cli/navigator.d.ts +5 -1
- package/cli/navigator.js +49 -12
- package/cli/scaffold.js +3 -54
- package/cli/terminal.js +4 -1
- package/docs/CHANGELOG.md +50 -0
- package/package.json +1 -1
package/cli/audit/social-git.js
CHANGED
|
@@ -2,6 +2,32 @@ import fs from 'node:fs';
|
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
|
|
5
|
+
const safeSpawnSync = (command, args, options) => {
|
|
6
|
+
try {
|
|
7
|
+
const res = spawnSync(command, args, options);
|
|
8
|
+
if (res.error) {
|
|
9
|
+
return [null, res.error];
|
|
10
|
+
}
|
|
11
|
+
return [res, null];
|
|
12
|
+
} catch (err) {
|
|
13
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
14
|
+
return [null, error];
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const safeReadJson = (filePath) => {
|
|
19
|
+
try {
|
|
20
|
+
if (!fs.existsSync(filePath)) {
|
|
21
|
+
return [null, new Error(`File not found: ${filePath}`)];
|
|
22
|
+
}
|
|
23
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
24
|
+
return [JSON.parse(raw), null];
|
|
25
|
+
} catch (err) {
|
|
26
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
27
|
+
return [null, error];
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
5
31
|
export const parseGitRemoteUrl = (url) => {
|
|
6
32
|
if (!url || typeof url !== 'string') return null;
|
|
7
33
|
const clean = url.trim().replace(/^git\+/, '').replace(/\.git$/, '');
|
|
@@ -36,105 +62,90 @@ export const parseGitRemoteUrl = (url) => {
|
|
|
36
62
|
};
|
|
37
63
|
|
|
38
64
|
export const detectGitRepoInfo = (cwd = process.cwd()) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
if (parsed) return parsed;
|
|
49
|
-
}
|
|
50
|
-
} catch {}
|
|
65
|
+
const [res1] = safeSpawnSync('git', ['remote', 'get-url', 'origin'], {
|
|
66
|
+
cwd,
|
|
67
|
+
encoding: 'utf-8',
|
|
68
|
+
stdio: ['ignore', 'pipe', 'ignore']
|
|
69
|
+
});
|
|
70
|
+
if (res1?.status === 0 && res1.stdout) {
|
|
71
|
+
const parsed = parseGitRemoteUrl(res1.stdout);
|
|
72
|
+
if (parsed) return parsed;
|
|
73
|
+
}
|
|
51
74
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
if (parsed) return parsed;
|
|
62
|
-
}
|
|
63
|
-
} catch {}
|
|
75
|
+
const [res2] = safeSpawnSync('git', ['config', '--get', 'remote.origin.url'], {
|
|
76
|
+
cwd,
|
|
77
|
+
encoding: 'utf-8',
|
|
78
|
+
stdio: ['ignore', 'pipe', 'ignore']
|
|
79
|
+
});
|
|
80
|
+
if (res2?.status === 0 && res2.stdout) {
|
|
81
|
+
const parsed = parseGitRemoteUrl(res2.stdout);
|
|
82
|
+
if (parsed) return parsed;
|
|
83
|
+
}
|
|
64
84
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (
|
|
81
|
-
const parsed = parseGitRemoteUrl(urlRes.stdout);
|
|
82
|
-
if (parsed) return parsed;
|
|
83
|
-
}
|
|
85
|
+
const [remotesRes] = safeSpawnSync('git', ['remote'], {
|
|
86
|
+
cwd,
|
|
87
|
+
encoding: 'utf-8',
|
|
88
|
+
stdio: ['ignore', 'pipe', 'ignore']
|
|
89
|
+
});
|
|
90
|
+
if (remotesRes?.status === 0 && remotesRes.stdout) {
|
|
91
|
+
const firstRemote = (remotesRes.stdout.trim().split(/\s+/)[0] || '').trim();
|
|
92
|
+
if (firstRemote) {
|
|
93
|
+
const [urlRes] = safeSpawnSync('git', ['remote', 'get-url', firstRemote], {
|
|
94
|
+
cwd,
|
|
95
|
+
encoding: 'utf-8',
|
|
96
|
+
stdio: ['ignore', 'pipe', 'ignore']
|
|
97
|
+
});
|
|
98
|
+
if (urlRes?.status === 0 && urlRes.stdout) {
|
|
99
|
+
const parsed = parseGitRemoteUrl(urlRes.stdout);
|
|
100
|
+
if (parsed) return parsed;
|
|
84
101
|
}
|
|
85
102
|
}
|
|
86
|
-
}
|
|
103
|
+
}
|
|
87
104
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (pkg.name.startsWith('@') && pkg.name.includes('/')) {
|
|
100
|
-
const [scope, pkgRepo] = pkg.name.slice(1).split('/');
|
|
101
|
-
return {
|
|
102
|
-
owner: scope,
|
|
103
|
-
repo: pkgRepo,
|
|
104
|
-
nameWithOwner: `${scope}/${pkgRepo}`,
|
|
105
|
-
url: `https://github.com/${scope}/${pkgRepo}`
|
|
106
|
-
};
|
|
107
|
-
}
|
|
105
|
+
const pkgPath = path.resolve(cwd, 'package.json');
|
|
106
|
+
const [pkg] = safeReadJson(pkgPath);
|
|
107
|
+
if (pkg) {
|
|
108
|
+
const repoUrl = typeof pkg.repository === 'string' ? pkg.repository : pkg.repository?.url;
|
|
109
|
+
if (repoUrl) {
|
|
110
|
+
const parsed = parseGitRemoteUrl(repoUrl);
|
|
111
|
+
if (parsed) return parsed;
|
|
112
|
+
}
|
|
113
|
+
if (pkg.name) {
|
|
114
|
+
if (pkg.name.startsWith('@') && pkg.name.includes('/')) {
|
|
115
|
+
const [scope, pkgRepo] = pkg.name.slice(1).split('/');
|
|
108
116
|
return {
|
|
109
|
-
owner:
|
|
110
|
-
repo:
|
|
111
|
-
nameWithOwner:
|
|
112
|
-
url:
|
|
117
|
+
owner: scope,
|
|
118
|
+
repo: pkgRepo,
|
|
119
|
+
nameWithOwner: `${scope}/${pkgRepo}`,
|
|
120
|
+
url: `https://github.com/${scope}/${pkgRepo}`
|
|
113
121
|
};
|
|
114
122
|
}
|
|
123
|
+
return {
|
|
124
|
+
owner: '',
|
|
125
|
+
repo: pkg.name,
|
|
126
|
+
nameWithOwner: pkg.name,
|
|
127
|
+
url: ''
|
|
128
|
+
};
|
|
115
129
|
}
|
|
116
|
-
}
|
|
130
|
+
}
|
|
117
131
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
url: ''
|
|
134
|
-
};
|
|
135
|
-
}
|
|
132
|
+
const [topRes] = safeSpawnSync('git', ['rev-parse', '--show-toplevel'], {
|
|
133
|
+
cwd,
|
|
134
|
+
encoding: 'utf-8',
|
|
135
|
+
stdio: ['ignore', 'pipe', 'ignore']
|
|
136
|
+
});
|
|
137
|
+
if (topRes?.status === 0 && topRes.stdout) {
|
|
138
|
+
const topDir = topRes.stdout.trim();
|
|
139
|
+
const repoName = path.basename(topDir);
|
|
140
|
+
if (repoName) {
|
|
141
|
+
return {
|
|
142
|
+
owner: '',
|
|
143
|
+
repo: repoName,
|
|
144
|
+
nameWithOwner: repoName,
|
|
145
|
+
url: ''
|
|
146
|
+
};
|
|
136
147
|
}
|
|
137
|
-
}
|
|
148
|
+
}
|
|
138
149
|
|
|
139
150
|
const fallback = path.basename(cwd) || 'Codebase';
|
|
140
151
|
return {
|
|
@@ -151,64 +162,55 @@ export const detectGitHubUser = (preferredUser) => {
|
|
|
151
162
|
if (trimmed && trimmed !== 'Architect') return trimmed;
|
|
152
163
|
}
|
|
153
164
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
if (user && /^[a-zA-Z0-9_\-]+$/.test(user)) return user;
|
|
160
|
-
}
|
|
161
|
-
} catch {}
|
|
165
|
+
const [res] = safeSpawnSync('gh', ['api', 'user', '-q', '.login'], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
166
|
+
if (res?.status === 0) {
|
|
167
|
+
const user = (res.stdout || '').trim();
|
|
168
|
+
if (user && /^[a-zA-Z0-9_\-]+$/.test(user)) return user;
|
|
169
|
+
}
|
|
162
170
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const statusRes = spawnSync('gh', ['auth', 'status'], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'pipe'] });
|
|
171
|
+
const [statusRes] = safeSpawnSync('gh', ['auth', 'status'], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'pipe'] });
|
|
172
|
+
if (statusRes) {
|
|
166
173
|
const output = `${statusRes.stdout || ''} ${statusRes.stderr || ''}`.trim();
|
|
167
174
|
const match = output.match(/account\s+([a-zA-Z0-9_\-]+)/i) || output.match(/Logged in to [^\s]+ account ([a-zA-Z0-9_\-]+)/i);
|
|
168
175
|
if (match && match[1]) {
|
|
169
176
|
const user = match[1].trim();
|
|
170
177
|
if (user && user !== 'default') return user;
|
|
171
178
|
}
|
|
172
|
-
}
|
|
179
|
+
}
|
|
173
180
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
const u = (ghUser.stdout || '').trim();
|
|
181
|
+
const [ghUser] = safeSpawnSync('git', ['config', 'github.user'], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
182
|
+
if (ghUser?.stdout) {
|
|
183
|
+
const u = ghUser.stdout.trim();
|
|
178
184
|
if (u && /^[a-zA-Z0-9_\-]+$/.test(u)) return u;
|
|
179
|
-
}
|
|
185
|
+
}
|
|
180
186
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
const name = (gitRes.stdout || '').trim();
|
|
187
|
+
const [gitRes] = safeSpawnSync('git', ['config', 'user.name'], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
188
|
+
if (gitRes?.stdout) {
|
|
189
|
+
const name = gitRes.stdout.trim();
|
|
185
190
|
if (name && /^[a-zA-Z0-9_\-]+$/.test(name)) return name;
|
|
186
|
-
}
|
|
191
|
+
}
|
|
187
192
|
|
|
188
193
|
return 'Architect';
|
|
189
194
|
};
|
|
190
195
|
|
|
191
196
|
export const copyToClipboard = (text) => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
if (
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
if (
|
|
209
|
-
|
|
210
|
-
if (res.status === 0) return true;
|
|
211
|
-
}
|
|
212
|
-
} catch {}
|
|
197
|
+
if (process.platform === 'darwin') {
|
|
198
|
+
const [res] = safeSpawnSync('pbcopy', [], { input: text, stdio: ['pipe', 'ignore', 'ignore'] });
|
|
199
|
+
return res?.status === 0;
|
|
200
|
+
}
|
|
201
|
+
if (process.platform === 'win32') {
|
|
202
|
+
const [res] = safeSpawnSync('clip', [], { input: text, stdio: ['pipe', 'ignore', 'ignore'] });
|
|
203
|
+
return res?.status === 0;
|
|
204
|
+
}
|
|
205
|
+
const [wlWhich] = safeSpawnSync('which', ['wl-copy'], { stdio: 'ignore' });
|
|
206
|
+
if (wlWhich?.status === 0) {
|
|
207
|
+
const [res] = safeSpawnSync('wl-copy', [], { input: text, stdio: ['pipe', 'ignore', 'ignore'] });
|
|
208
|
+
if (res?.status === 0) return true;
|
|
209
|
+
}
|
|
210
|
+
const [xcWhich] = safeSpawnSync('which', ['xclip'], { stdio: 'ignore' });
|
|
211
|
+
if (xcWhich?.status === 0) {
|
|
212
|
+
const [res] = safeSpawnSync('xclip', ['-selection', 'clipboard'], { input: text, stdio: ['pipe', 'ignore', 'ignore'] });
|
|
213
|
+
if (res?.status === 0) return true;
|
|
214
|
+
}
|
|
213
215
|
return false;
|
|
214
216
|
};
|
package/cli/audit/social.js
CHANGED
|
@@ -82,11 +82,17 @@ export const resolveWeeklyWastePerDev = (tokensObj, fallbackCostPerMillion = 3.0
|
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
export const generateDiscussionContent = (report, username, projectName = 'Codebase', repoUrl = '', liveUrl = '') => {
|
|
85
|
-
const { health, metrics, pillars, hotspots, contextAnalysis, violations } = report;
|
|
85
|
+
const { health, metrics, pillars, hotspots, contextAnalysis, violations, aiSlop } = report;
|
|
86
86
|
const isHighScoring = health.score >= 80;
|
|
87
87
|
const badgeColor = resolveBadgeColor(health.score);
|
|
88
88
|
const encodedGrade = encodeURIComponent(`${health.score}/100 (${health.grade})`);
|
|
89
89
|
|
|
90
|
+
const slopScore = aiSlop?.score ?? 100;
|
|
91
|
+
const slopGrade = aiSlop?.grade ?? 'A+';
|
|
92
|
+
const slopLabel = aiSlop?.label ?? 'Pure Artisanal';
|
|
93
|
+
const slopBadgeColor = resolveBadgeColor(slopScore);
|
|
94
|
+
const encodedSlop = encodeURIComponent(`${slopScore}/100 (${slopGrade})`);
|
|
95
|
+
|
|
90
96
|
const category = DISCUSSION_CATEGORY;
|
|
91
97
|
const categorySlug = DISCUSSION_CATEGORY_SLUG;
|
|
92
98
|
const prefix = isHighScoring ? '[Showcase]' : '[Teardown]';
|
|
@@ -95,7 +101,7 @@ export const generateDiscussionContent = (report, username, projectName = 'Codeb
|
|
|
95
101
|
const lines = [];
|
|
96
102
|
lines.push(`# ${isHighScoring ? 'Crystalline' : 'Architecture'} Audit Report: ${projectName}`);
|
|
97
103
|
lines.push('');
|
|
98
|
-
lines.push(`[](https://chemicalx.xophz.com)`);
|
|
104
|
+
lines.push(`[](https://chemicalx.xophz.com) [](https://chemicalx.xophz.com)`);
|
|
99
105
|
lines.push('');
|
|
100
106
|
lines.push(`* **Audited by**: @${username}`);
|
|
101
107
|
const resolvedRepoUrl = repoUrl || (/^[\w\-.]+\/[\w\-.]+$/.test(projectName) ? `https://github.com/${projectName}` : '');
|
|
@@ -109,6 +115,7 @@ export const generateDiscussionContent = (report, username, projectName = 'Codeb
|
|
|
109
115
|
}
|
|
110
116
|
}
|
|
111
117
|
lines.push(`* **Molecular Health Index**: **${health.score} / 100** (Grade: **${health.grade}** - ${health.label})`);
|
|
118
|
+
lines.push(`* **AI Slop Index**: **${slopScore} / 100** (Grade: **${slopGrade}** - ${slopLabel})`);
|
|
112
119
|
lines.push(`* **Source Files Analyzed**: ${metrics.scannedFiles} files (${metrics.totalLoc} total lines of code)`);
|
|
113
120
|
lines.push(`* **Token Reduction Potential**: **${contextAnalysis.potentialSavingsPct}%** (Estimated ${contextAnalysis.estimatedTokens.toLocaleString()} tokens)`);
|
|
114
121
|
const costPass = resolveExcessCostPerPass(contextAnalysis);
|
|
@@ -259,6 +266,12 @@ export const generateTransformationDiscussionContent = (
|
|
|
259
266
|
lines.push('| Metric | Before (Baseline) | After (Refactored) | Delta |');
|
|
260
267
|
lines.push('| :--- | :---: | :---: | :---: |');
|
|
261
268
|
lines.push(`| **Molecular Health (MHI)** | ${scoreBefore} / 100 (${beforeSnapshot.health.grade}) | ${scoreAfter} / 100 (${afterSnapshot.health.grade}) | ${formatDelta(scoreDelta)} |`);
|
|
269
|
+
const slopBefore = beforeSnapshot.aiSlop?.score ?? 100;
|
|
270
|
+
const slopBeforeGrade = beforeSnapshot.aiSlop?.grade ?? 'A+';
|
|
271
|
+
const slopAfter = afterSnapshot.aiSlop?.score ?? 100;
|
|
272
|
+
const slopAfterGrade = afterSnapshot.aiSlop?.grade ?? 'A+';
|
|
273
|
+
const slopDelta = slopAfter - slopBefore;
|
|
274
|
+
lines.push(`| **AI Slop Index (ASI)** | ${slopBefore} / 100 (${slopBeforeGrade}) | ${slopAfter} / 100 (${slopAfterGrade}) | ${formatDelta(slopDelta)} |`);
|
|
262
275
|
lines.push(`| **Critical Hazards** | ${beforeSnapshot.violations.critical} | ${afterSnapshot.violations.critical} | ${formatDelta(critDelta, true)} |`);
|
|
263
276
|
lines.push(`| **Total Violations** | ${beforeSnapshot.violations.total} | ${afterSnapshot.violations.total} | ${formatDelta(totalDelta, true)} |`);
|
|
264
277
|
lines.push(`| **Monolith Files (> 500 lines of code)** | ${beforeSnapshot.monoliths.total} | ${afterSnapshot.monoliths.total} | ${formatDelta(monoDelta, true)} |`);
|
package/cli/audit/types.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface HazardViolation {
|
|
|
11
11
|
readonly severity: SeverityLevel;
|
|
12
12
|
readonly pillar: string;
|
|
13
13
|
readonly directive: string;
|
|
14
|
+
readonly isAiSlop?: boolean;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export interface FileStat {
|
|
@@ -73,11 +74,25 @@ export interface HotspotFile {
|
|
|
73
74
|
readonly monolithTier?: 'CRITICAL' | 'SEVERE' | 'WARNING' | null;
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
export interface AiSlopScore {
|
|
78
|
+
readonly score: number;
|
|
79
|
+
readonly grade: string;
|
|
80
|
+
readonly label: string;
|
|
81
|
+
readonly violationsCount: number;
|
|
82
|
+
readonly breakdown: {
|
|
83
|
+
readonly critical: number;
|
|
84
|
+
readonly high: number;
|
|
85
|
+
readonly medium: number;
|
|
86
|
+
readonly low: number;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
76
90
|
export interface AuditReport {
|
|
77
91
|
readonly scannedFiles: number;
|
|
78
92
|
readonly totalViolations: number;
|
|
79
93
|
readonly metrics: CodebaseMetrics;
|
|
80
94
|
readonly health: MolecularHealthScore;
|
|
95
|
+
readonly aiSlop?: AiSlopScore;
|
|
81
96
|
readonly pillars: Record<string, PillarData>;
|
|
82
97
|
readonly contextAnalysis: ContextTokenAnalysis;
|
|
83
98
|
readonly hotspots: readonly HotspotFile[];
|
|
@@ -104,35 +119,21 @@ export declare function auditCode(content: string, filePath: string, relativePat
|
|
|
104
119
|
export declare function auditFile(filePath: string, relativePath: string): HazardViolation[];
|
|
105
120
|
export declare function scanDirectory(targetDir: string, baseDir: string): HazardViolation[];
|
|
106
121
|
export declare function runAudit(targetDir?: string, options?: AuditOptions): AuditReport;
|
|
107
|
-
export declare function
|
|
108
|
-
export
|
|
109
|
-
export declare function resolveTopSectionColor(report: AuditReport): string;
|
|
110
|
-
export declare function formatScorecardSection(report: AuditReport, themeColor?: string | null): string;
|
|
111
|
-
export declare function formatCriticalSection(report: AuditReport): string;
|
|
112
|
-
export declare function formatHighMediumSection(report: AuditReport): string;
|
|
113
|
-
export declare function formatLowSection(report: AuditReport): string;
|
|
114
|
-
export declare function formatPillarsSection(report: AuditReport, themeColor?: string | null): string;
|
|
115
|
-
export declare function formatHotspotsSection(report: AuditReport, themeColor?: string | null): string;
|
|
116
|
-
export declare function formatContextAnalysisSection(report: AuditReport, themeColor?: string | null): string;
|
|
117
|
-
export declare function formatFailuresSection(report: AuditReport): string;
|
|
118
|
-
export declare function formatPassesSection(report: AuditReport): string;
|
|
119
|
-
export declare function formatGradeFSection(report: AuditReport): string;
|
|
120
|
-
export declare function formatGradeDSection(report: AuditReport): string;
|
|
121
|
-
export declare function formatGradeCSection(report: AuditReport): string;
|
|
122
|
-
export declare function formatGradeBSection(report: AuditReport): string;
|
|
123
|
-
export declare function formatGradeASection(report: AuditReport): string;
|
|
124
|
-
export declare function getChemicalXAsciiBanner(gradeOrReport?: string | AuditReport | null): string;
|
|
125
|
-
export declare function getAsciiGradeLines(grade?: string, color?: string, withEquals?: boolean): readonly string[];
|
|
126
|
-
export declare function formatAsciiGrade(grade?: string, color?: string, indent?: string, withEquals?: boolean): string;
|
|
127
|
-
export declare const REPORT_CARD_ASCII: readonly string[];
|
|
128
|
-
export declare function getReportCardAsciiLines(color?: string): readonly string[];
|
|
129
|
-
|
|
122
|
+
export declare function calculateAiSlopScore(violations: readonly HazardViolation[], totalFiles: number): AiSlopScore;
|
|
123
|
+
export * from './reporter';
|
|
130
124
|
export * from './social';
|
|
131
125
|
|
|
132
|
-
export
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
126
|
+
export interface PromptOptions {
|
|
127
|
+
readonly excludeAiSlop?: boolean;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export declare function formatGroupedPromptViolations(violations?: readonly HazardViolation[]): string[];
|
|
131
|
+
export declare function buildGradeFPrompt(report: AuditReport, options?: PromptOptions): string;
|
|
132
|
+
export declare function buildGradeDPrompt(report: AuditReport, options?: PromptOptions): string;
|
|
133
|
+
export declare function buildGradeCPrompt(report: AuditReport, options?: PromptOptions): string;
|
|
134
|
+
export declare function buildGradeBPrompt(report: AuditReport, options?: PromptOptions): string;
|
|
135
|
+
export declare function buildAiSlopPrompt(report: AuditReport): string;
|
|
136
|
+
export declare function buildHotspotsPrompt(report: AuditReport): string;
|
|
136
137
|
export declare function buildMasterPrompt(report: AuditReport): string;
|
|
137
138
|
export declare function formatPromptBox(title: string, promptText: string): string;
|
|
138
139
|
|
package/cli/audit.js
CHANGED
|
@@ -6,14 +6,21 @@ import {
|
|
|
6
6
|
calculateQuantumHealthScore,
|
|
7
7
|
calculatePillarBreakdown,
|
|
8
8
|
calculateTokenBurnAnalytics,
|
|
9
|
-
calculateHotspots
|
|
9
|
+
calculateHotspots,
|
|
10
|
+
calculateAiSlopScore
|
|
10
11
|
} from './audit/metrics.js';
|
|
11
12
|
import {
|
|
12
13
|
formatTerminalReport,
|
|
13
14
|
generateMarkdownReport,
|
|
14
15
|
groupViolationsBySeverity,
|
|
16
|
+
groupViolationsByDirectory,
|
|
17
|
+
groupViolationsByRule,
|
|
18
|
+
formatDirectoryDistributionSection,
|
|
19
|
+
formatDirectoryRollupMarkdown,
|
|
20
|
+
renderGroupedViolationsMarkdown,
|
|
15
21
|
resolveTopSectionColor,
|
|
16
22
|
formatScorecardSection,
|
|
23
|
+
formatAiSlopSection,
|
|
17
24
|
formatCriticalSection,
|
|
18
25
|
formatHighMediumSection,
|
|
19
26
|
formatLowSection,
|
|
@@ -33,6 +40,17 @@ import {
|
|
|
33
40
|
getReportCardAsciiLines,
|
|
34
41
|
REPORT_CARD_ASCII
|
|
35
42
|
} from './audit/reporter.js';
|
|
43
|
+
import {
|
|
44
|
+
buildGradeFPrompt,
|
|
45
|
+
buildGradeDPrompt,
|
|
46
|
+
buildGradeCPrompt,
|
|
47
|
+
buildGradeBPrompt,
|
|
48
|
+
buildAiSlopPrompt,
|
|
49
|
+
buildHotspotsPrompt,
|
|
50
|
+
buildMasterPrompt,
|
|
51
|
+
formatPromptBox,
|
|
52
|
+
formatGroupedPromptViolations
|
|
53
|
+
} from './audit/prompts.js';
|
|
36
54
|
|
|
37
55
|
const IGNORED_DIRS = new Set([
|
|
38
56
|
'node_modules',
|
|
@@ -160,12 +178,16 @@ export const runAudit = (targetDir = 'src', options = {}) => {
|
|
|
160
178
|
const pillars = calculatePillarBreakdown(violations);
|
|
161
179
|
const contextAnalysis = calculateTokenBurnAnalytics(fileStats, options);
|
|
162
180
|
const hotspots = calculateHotspots(violations, fileStats, 5);
|
|
181
|
+
const aiSlop = calculateAiSlopScore(violations, scannedFiles);
|
|
163
182
|
|
|
164
183
|
const report = {
|
|
184
|
+
targetDir,
|
|
185
|
+
options,
|
|
165
186
|
scannedFiles,
|
|
166
187
|
totalViolations: violations.length,
|
|
167
188
|
metrics,
|
|
168
189
|
health,
|
|
190
|
+
aiSlop,
|
|
169
191
|
pillars,
|
|
170
192
|
contextAnalysis,
|
|
171
193
|
hotspots,
|
|
@@ -188,6 +210,7 @@ export * from './audit/history.js';
|
|
|
188
210
|
export {
|
|
189
211
|
calculateMolecularHealthScore,
|
|
190
212
|
calculateQuantumHealthScore,
|
|
213
|
+
calculateAiSlopScore,
|
|
191
214
|
calculatePillarBreakdown,
|
|
192
215
|
calculateTokenBurnAnalytics,
|
|
193
216
|
calculateHotspots,
|
|
@@ -196,8 +219,14 @@ export {
|
|
|
196
219
|
formatTerminalReport,
|
|
197
220
|
generateMarkdownReport,
|
|
198
221
|
groupViolationsBySeverity,
|
|
222
|
+
groupViolationsByDirectory,
|
|
223
|
+
groupViolationsByRule,
|
|
224
|
+
formatDirectoryDistributionSection,
|
|
225
|
+
formatDirectoryRollupMarkdown,
|
|
226
|
+
renderGroupedViolationsMarkdown,
|
|
199
227
|
resolveTopSectionColor,
|
|
200
228
|
formatScorecardSection,
|
|
229
|
+
formatAiSlopSection,
|
|
201
230
|
formatCriticalSection,
|
|
202
231
|
formatHighMediumSection,
|
|
203
232
|
formatLowSection,
|
|
@@ -215,7 +244,16 @@ export {
|
|
|
215
244
|
getAsciiGradeLines,
|
|
216
245
|
formatAsciiGrade,
|
|
217
246
|
getReportCardAsciiLines,
|
|
218
|
-
REPORT_CARD_ASCII
|
|
247
|
+
REPORT_CARD_ASCII,
|
|
248
|
+
buildGradeFPrompt,
|
|
249
|
+
buildGradeDPrompt,
|
|
250
|
+
buildGradeCPrompt,
|
|
251
|
+
buildGradeBPrompt,
|
|
252
|
+
buildAiSlopPrompt,
|
|
253
|
+
buildHotspotsPrompt,
|
|
254
|
+
buildMasterPrompt,
|
|
255
|
+
formatPromptBox,
|
|
256
|
+
formatGroupedPromptViolations
|
|
219
257
|
};
|
|
220
258
|
|
|
221
259
|
export default {
|
|
@@ -225,8 +263,14 @@ export default {
|
|
|
225
263
|
formatTerminalReport,
|
|
226
264
|
generateMarkdownReport,
|
|
227
265
|
groupViolationsBySeverity,
|
|
266
|
+
groupViolationsByDirectory,
|
|
267
|
+
groupViolationsByRule,
|
|
268
|
+
formatDirectoryDistributionSection,
|
|
269
|
+
formatDirectoryRollupMarkdown,
|
|
270
|
+
renderGroupedViolationsMarkdown,
|
|
228
271
|
resolveTopSectionColor,
|
|
229
272
|
formatScorecardSection,
|
|
273
|
+
formatAiSlopSection,
|
|
230
274
|
formatCriticalSection,
|
|
231
275
|
formatHighMediumSection,
|
|
232
276
|
formatLowSection,
|
|
@@ -246,5 +290,14 @@ export default {
|
|
|
246
290
|
getReportCardAsciiLines,
|
|
247
291
|
REPORT_CARD_ASCII,
|
|
248
292
|
PILLARS,
|
|
249
|
-
RULE_REGISTRY
|
|
293
|
+
RULE_REGISTRY,
|
|
294
|
+
buildGradeFPrompt,
|
|
295
|
+
buildGradeDPrompt,
|
|
296
|
+
buildGradeCPrompt,
|
|
297
|
+
buildGradeBPrompt,
|
|
298
|
+
buildAiSlopPrompt,
|
|
299
|
+
buildHotspotsPrompt,
|
|
300
|
+
buildMasterPrompt,
|
|
301
|
+
formatPromptBox,
|
|
302
|
+
formatGroupedPromptViolations
|
|
250
303
|
};
|