@chemx/starter-kit 26.9.9-786 â 26.9.11-481
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/ast-visitors.js +243 -0
- package/cli/audit/discussion-store.js +39 -0
- package/cli/audit/history.d.ts +69 -0
- package/cli/audit/history.js +397 -0
- package/cli/audit/metrics.js +179 -0
- package/cli/audit/prompts.js +174 -0
- package/cli/audit/reporter-ascii.d.ts +4 -0
- package/cli/audit/reporter-ascii.js +99 -0
- package/cli/audit/reporter-grades.js +275 -0
- package/cli/audit/reporter-markdown.js +137 -0
- package/cli/audit/reporter-utils.js +125 -0
- package/cli/audit/reporter.js +497 -0
- package/cli/audit/rules-helpers.js +109 -0
- package/cli/audit/rules-registry.js +97 -0
- package/cli/audit/rules.js +123 -0
- package/cli/audit/social-constants.js +4 -0
- package/cli/audit/social-gh.js +126 -0
- package/cli/audit/social-git.js +214 -0
- package/cli/audit/social-http.js +222 -0
- package/cli/audit/social-publisher.js +193 -0
- package/cli/audit/social.d.ts +69 -0
- package/cli/audit/social.js +303 -0
- package/cli/audit/types.d.ts +140 -0
- package/cli/audit.d.ts +3 -24
- package/cli/audit.js +207 -210
- package/cli/help.d.ts +1 -0
- package/cli/help.js +136 -0
- package/cli/index.js +128 -566
- package/cli/installer-templates.js +91 -0
- package/cli/installer.d.ts +21 -0
- package/cli/installer.js +104 -0
- package/cli/license.js +320 -0
- package/cli/navigator-actions.js +274 -0
- package/cli/navigator-banner.js +98 -0
- package/cli/navigator-conversion.js +100 -0
- package/cli/navigator-grades.js +87 -0
- package/cli/navigator-menu.js +127 -0
- package/cli/navigator-paged.js +86 -0
- package/cli/navigator-share.js +129 -0
- package/cli/navigator.d.ts +43 -0
- package/cli/navigator.js +126 -0
- package/cli/scaffold.js +148 -0
- package/cli/terminal.js +126 -0
- package/docs/CHANGELOG.md +101 -0
- package/package.json +11 -10
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
const CYAN = '\x1b[38;2;98;201;255m';
|
|
2
|
+
const BOLD = '\x1b[1m';
|
|
3
|
+
const DIM = '\x1b[2m';
|
|
4
|
+
const RESET = '\x1b[0m';
|
|
5
|
+
|
|
6
|
+
export const buildGradeFPrompt = (report) => {
|
|
7
|
+
const { violations, hotspots } = report;
|
|
8
|
+
const critical = violations.filter((v) => v.severity === 'CRITICAL');
|
|
9
|
+
const extremeMonoliths = hotspots.filter((h) => h.lineCount >= 2000);
|
|
10
|
+
|
|
11
|
+
if (critical.length === 0 && extremeMonoliths.length === 0) return '';
|
|
12
|
+
|
|
13
|
+
const lines = [];
|
|
14
|
+
lines.push('Act as a Principal Systems Architect. Surgically refactor the following Grade F Critical Context Hazards in our codebase according to Chemical X Molecular Architecture Standards:\n');
|
|
15
|
+
|
|
16
|
+
if (extremeMonoliths.length > 0) {
|
|
17
|
+
lines.push('### EXTREME MONOLITHS (>= 2,000 lines of code) : MONOLITH DECOMPOSITION');
|
|
18
|
+
extremeMonoliths.forEach((h, i) => {
|
|
19
|
+
lines.push(`${i + 1}. File: \`${h.filePath}\` (${h.lineCount} lines)`);
|
|
20
|
+
lines.push(' Action: Decompose this monolith into crystalline single-responsibility capsules (< 100 lines per molecule). Convert top-level view into a declarative Table-of-Contents view.');
|
|
21
|
+
});
|
|
22
|
+
lines.push('');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (critical.length > 0) {
|
|
26
|
+
lines.push('### CRITICAL AST VIOLATIONS');
|
|
27
|
+
critical.forEach((v, i) => {
|
|
28
|
+
lines.push(`${i + 1}. \`${v.filePath}:${v.line}:${v.column}\` [${v.rule}]`);
|
|
29
|
+
lines.push(` Hazard: ${v.hazard}`);
|
|
30
|
+
lines.push(` Directive: ${v.directive}`);
|
|
31
|
+
});
|
|
32
|
+
lines.push('');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
lines.push('### STRICT EXECUTION RULES:');
|
|
36
|
+
lines.push('1. Every new molecule component must stay under 100 lines.');
|
|
37
|
+
lines.push('2. Top-level page views must be 10-20 line declarative Table-of-Contents templates assembling components via named slots.');
|
|
38
|
+
lines.push('3. Zero synthetic or mock data: return live data or explicit empty states.');
|
|
39
|
+
lines.push('4. Zero render-hack setTimeout: replace with await nextTick() or flush: post.');
|
|
40
|
+
lines.push('5. Output surgical diffs or modular replacements. Preserve existing external exports.');
|
|
41
|
+
|
|
42
|
+
return lines.join('\n');
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const buildGradeDPrompt = (report) => {
|
|
46
|
+
const { violations, hotspots } = report;
|
|
47
|
+
const high = violations.filter((v) => v.severity === 'HIGH');
|
|
48
|
+
const severeMonoliths = hotspots.filter((h) => h.lineCount >= 1000 && h.lineCount < 2000);
|
|
49
|
+
|
|
50
|
+
if (high.length === 0 && severeMonoliths.length === 0) return '';
|
|
51
|
+
|
|
52
|
+
const lines = [];
|
|
53
|
+
lines.push('Act as a Principal Systems Architect. Refactor the following Grade D High-Severity Architectural Debts according to Chemical X Molecular Architecture Standards:\n');
|
|
54
|
+
|
|
55
|
+
if (severeMonoliths.length > 0) {
|
|
56
|
+
lines.push('### SEVERE MONOLITHS (1,000 - 1,999 lines of code)');
|
|
57
|
+
severeMonoliths.forEach((h, i) => {
|
|
58
|
+
lines.push(`${i + 1}. File: \`${h.filePath}\` (${h.lineCount} lines)`);
|
|
59
|
+
lines.push(' Action: Extract sub-features into isolated molecule capsules (< 100 lines of code) and domain composables.');
|
|
60
|
+
});
|
|
61
|
+
lines.push('');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (high.length > 0) {
|
|
65
|
+
lines.push('### HIGH SEVERITY VIOLATIONS');
|
|
66
|
+
high.forEach((v, i) => {
|
|
67
|
+
lines.push(`${i + 1}. \`${v.filePath}:${v.line}:${v.column}\` [${v.rule}]`);
|
|
68
|
+
lines.push(` Hazard: ${v.hazard}`);
|
|
69
|
+
lines.push(` Directive: ${v.directive}`);
|
|
70
|
+
});
|
|
71
|
+
lines.push('');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
lines.push('### STRICT EXECUTION RULES:');
|
|
75
|
+
lines.push('1. Hook Saturation: Extract component hooks into dedicated domain composables adhering to the 3-5 property return limit (State + Status + Actions).');
|
|
76
|
+
lines.push('2. Complex Control Flow: Break multi-clause conditionals into 2-stage atomic boolean variables with early-return guard clauses.');
|
|
77
|
+
lines.push('3. Zero breaking changes to caller APIs or existing props.');
|
|
78
|
+
|
|
79
|
+
return lines.join('\n');
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const buildGradeCPrompt = (report) => {
|
|
83
|
+
const { violations, hotspots } = report;
|
|
84
|
+
const medium = violations.filter((v) => v.severity === 'MEDIUM');
|
|
85
|
+
const warningMonoliths = hotspots.filter((h) => h.lineCount >= 500 && h.lineCount < 1000);
|
|
86
|
+
|
|
87
|
+
if (medium.length === 0 && warningMonoliths.length === 0) return '';
|
|
88
|
+
|
|
89
|
+
const lines = [];
|
|
90
|
+
lines.push('Act as a Senior Frontend Engineer. Refactor the following Grade C Medium-Severity Technical Debts according to Chemical X Molecular Architecture Standards:\n');
|
|
91
|
+
|
|
92
|
+
if (warningMonoliths.length > 0) {
|
|
93
|
+
lines.push('### WARNING MONOLITHS (500 - 999 lines of code)');
|
|
94
|
+
warningMonoliths.forEach((h, i) => {
|
|
95
|
+
lines.push(`${i + 1}. File: \`${h.filePath}\` (${h.lineCount} lines)`);
|
|
96
|
+
lines.push(' Action: Bring file under 500 line budget by extracting helper functions, types, and child molecules.');
|
|
97
|
+
});
|
|
98
|
+
lines.push('');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (medium.length > 0) {
|
|
102
|
+
lines.push('### MEDIUM SEVERITY VIOLATIONS');
|
|
103
|
+
medium.forEach((v, i) => {
|
|
104
|
+
lines.push(`${i + 1}. \`${v.filePath}:${v.line}:${v.column}\` [${v.rule}]`);
|
|
105
|
+
lines.push(` Hazard: ${v.hazard}`);
|
|
106
|
+
lines.push(` Directive: ${v.directive}`);
|
|
107
|
+
});
|
|
108
|
+
lines.push('');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
lines.push('### STRICT EXECUTION RULES:');
|
|
112
|
+
lines.push('1. Zero raw inline styles: Replace style={{...}} with atom props, SCSS mixins (@include glass), or scoped BEM classes.');
|
|
113
|
+
lines.push('2. Extract anonymous inline callbacks into named functions before passing as props.');
|
|
114
|
+
lines.push('3. Co-locate granular types (*.d.ts) inside feature capsules (< 100 lines of code). Avoid type monoliths.');
|
|
115
|
+
|
|
116
|
+
return lines.join('\n');
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const buildGradeBPrompt = (report) => {
|
|
120
|
+
const { violations } = report;
|
|
121
|
+
const low = violations.filter((v) => v.severity === 'LOW');
|
|
122
|
+
|
|
123
|
+
if (low.length === 0) return '';
|
|
124
|
+
|
|
125
|
+
const lines = [];
|
|
126
|
+
lines.push('Act as a Clean Code Specialist. Clean up the following Grade B Low-Severity Hygiene Issues according to Chemical X standards:\n');
|
|
127
|
+
|
|
128
|
+
lines.push('### LOW HYGIENE VIOLATIONS');
|
|
129
|
+
low.forEach((v, i) => {
|
|
130
|
+
lines.push(`${i + 1}. \`${v.filePath}:${v.line}:${v.column}\` [${v.rule}]`);
|
|
131
|
+
lines.push(` Hazard: ${v.hazard}`);
|
|
132
|
+
lines.push(` Directive: ${v.directive}`);
|
|
133
|
+
});
|
|
134
|
+
lines.push('');
|
|
135
|
+
|
|
136
|
+
lines.push('### STRICT EXECUTION RULES:');
|
|
137
|
+
lines.push('1. Typography Hygiene: Replace all em dashes with standard hyphens (-) or colons (:).');
|
|
138
|
+
lines.push('2. Logging Hygiene: Remove unguarded console.log calls or route through central debug proxy.');
|
|
139
|
+
lines.push('3. FontAwesome Compliance: Remove text-* utility classes from icons; use :color prop or inline CSS.');
|
|
140
|
+
|
|
141
|
+
return lines.join('\n');
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export const buildMasterPrompt = (report) => {
|
|
145
|
+
const sections = [
|
|
146
|
+
buildGradeFPrompt(report),
|
|
147
|
+
buildGradeDPrompt(report),
|
|
148
|
+
buildGradeCPrompt(report),
|
|
149
|
+
buildGradeBPrompt(report)
|
|
150
|
+
].filter(Boolean);
|
|
151
|
+
|
|
152
|
+
if (sections.length === 0) return '';
|
|
153
|
+
|
|
154
|
+
const header = `Act as a Principal Systems Architect. Execute a phased architectural refactoring of our codebase according to Chemical X Molecular Architecture Standards.\n\n`;
|
|
155
|
+
return header + sections.join('\n\n---\n\n');
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const formatPromptBox = (title, promptText) => {
|
|
159
|
+
if (!promptText) return '';
|
|
160
|
+
|
|
161
|
+
const lines = [];
|
|
162
|
+
lines.push(`\n ${CYAN}ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ${RESET}`);
|
|
163
|
+
lines.push(` ${CYAN}â${RESET} ${BOLD}${title}${RESET}`);
|
|
164
|
+
lines.push(` ${CYAN}â${RESET} ${DIM}Copy and paste the block below directly into Cursor / Claude / Windsurf:${RESET}`);
|
|
165
|
+
lines.push(` ${CYAN}ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤${RESET}`);
|
|
166
|
+
|
|
167
|
+
const promptLines = promptText.split('\n');
|
|
168
|
+
for (const pl of promptLines) {
|
|
169
|
+
lines.push(` ${CYAN}â${RESET} ${pl}`);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
lines.push(` ${CYAN}ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ${RESET}\n`);
|
|
173
|
+
return lines.join('\n');
|
|
174
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const REPORT_CARD_ASCII: readonly string[];
|
|
2
|
+
export declare function getReportCardAsciiLines(color?: string): readonly string[];
|
|
3
|
+
export declare function getAsciiGradeLines(grade?: string, color?: string, withEquals?: boolean): readonly string[];
|
|
4
|
+
export declare function formatAsciiGrade(grade?: string, color?: string, indent?: string, withEquals?: boolean): string;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { BOLD, RESET } from './reporter-utils.js';
|
|
2
|
+
|
|
3
|
+
const EQUALS_GLYPH = [
|
|
4
|
+
' ',
|
|
5
|
+
'ââââââââ',
|
|
6
|
+
'ââââââââ',
|
|
7
|
+
'ââââââââ',
|
|
8
|
+
'ââââââââ',
|
|
9
|
+
' '
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
const LETTER_GLYPHS = {
|
|
13
|
+
A: [
|
|
14
|
+
' ââââââ ',
|
|
15
|
+
'ââââââââ',
|
|
16
|
+
'ââââââââ',
|
|
17
|
+
'ââââââââ',
|
|
18
|
+
'âââ âââ',
|
|
19
|
+
'âââ âââ'
|
|
20
|
+
],
|
|
21
|
+
B: [
|
|
22
|
+
'âââââââ ',
|
|
23
|
+
'ââââââââ',
|
|
24
|
+
'ââââââââ',
|
|
25
|
+
'ââââââââ',
|
|
26
|
+
'ââââââââ',
|
|
27
|
+
'âââââââ '
|
|
28
|
+
],
|
|
29
|
+
C: [
|
|
30
|
+
' âââââââ',
|
|
31
|
+
'ââââââââ',
|
|
32
|
+
'âââ ',
|
|
33
|
+
'âââ ',
|
|
34
|
+
'ââââââââ',
|
|
35
|
+
' âââââââ'
|
|
36
|
+
],
|
|
37
|
+
D: [
|
|
38
|
+
'âââââââ ',
|
|
39
|
+
'ââââââââ',
|
|
40
|
+
'âââ âââ',
|
|
41
|
+
'âââ âââ',
|
|
42
|
+
'ââââââââ',
|
|
43
|
+
'âââââââ '
|
|
44
|
+
],
|
|
45
|
+
F: [
|
|
46
|
+
'ââââââââ',
|
|
47
|
+
'ââââââââ',
|
|
48
|
+
'ââââââ ',
|
|
49
|
+
'ââââââ ',
|
|
50
|
+
'âââ ',
|
|
51
|
+
'âââ '
|
|
52
|
+
],
|
|
53
|
+
PLUS: [
|
|
54
|
+
' ',
|
|
55
|
+
' âââ ',
|
|
56
|
+
'âââââââ',
|
|
57
|
+
'âââââââ',
|
|
58
|
+
' âââ ',
|
|
59
|
+
' '
|
|
60
|
+
]
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const getAsciiGradeLines = (grade = 'A', color = '', withEquals = false) => {
|
|
64
|
+
const normGrade = String(grade || 'A').trim().toUpperCase();
|
|
65
|
+
const letter = normGrade.replace('+', '');
|
|
66
|
+
const hasPlus = normGrade.includes('+');
|
|
67
|
+
const glyph = LETTER_GLYPHS[letter] || LETTER_GLYPHS.A;
|
|
68
|
+
|
|
69
|
+
const lines = [];
|
|
70
|
+
for (let i = 0; i < 6; i++) {
|
|
71
|
+
let letterPart = glyph[i];
|
|
72
|
+
if (hasPlus) {
|
|
73
|
+
letterPart += ` ${LETTER_GLYPHS.PLUS[i]}`;
|
|
74
|
+
}
|
|
75
|
+
const coloredLetter = color ? `${color}${BOLD}${letterPart}${RESET}` : letterPart;
|
|
76
|
+
|
|
77
|
+
if (withEquals) {
|
|
78
|
+
const eqPart = `${BOLD}\x1b[37m${EQUALS_GLYPH[i]}${RESET}`;
|
|
79
|
+
lines.push(`${eqPart} ${coloredLetter}`);
|
|
80
|
+
} else {
|
|
81
|
+
lines.push(coloredLetter);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return lines;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const formatAsciiGrade = (grade = 'A', color = '', indent = ' ', withEquals = false) =>
|
|
88
|
+
getAsciiGradeLines(grade, color, withEquals).map((l) => `${indent}${l}`).join('\n');
|
|
89
|
+
|
|
90
|
+
export const REPORT_CARD_ASCII = [
|
|
91
|
+
'ââââ âââââââââ âââ âââââââââ ââââ âââ ââââ ââââ ',
|
|
92
|
+
'ââ ââââ ââ ââââ ââââ ââ â ââ ââ ââââ ââââ â',
|
|
93
|
+
'ââââââââââââââ ââ âââââââ â ââ ââââââââââââ â',
|
|
94
|
+
'ââ âââââââââ âââââââ ââ â âââââââ ââââ âââââââ'
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
export const getReportCardAsciiLines = (color = '') =>
|
|
98
|
+
REPORT_CARD_ASCII.map((row) => (color ? `${color}${BOLD}${row}${RESET}` : row));
|
|
99
|
+
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildGradeFPrompt,
|
|
3
|
+
buildGradeDPrompt,
|
|
4
|
+
buildGradeCPrompt,
|
|
5
|
+
buildGradeBPrompt,
|
|
6
|
+
formatPromptBox
|
|
7
|
+
} from './prompts.js';
|
|
8
|
+
import {
|
|
9
|
+
CYAN,
|
|
10
|
+
GREEN,
|
|
11
|
+
YELLOW,
|
|
12
|
+
RED,
|
|
13
|
+
ORANGE,
|
|
14
|
+
DIM,
|
|
15
|
+
BOLD,
|
|
16
|
+
RESET,
|
|
17
|
+
groupViolationsBySeverity
|
|
18
|
+
} from './reporter-utils.js';
|
|
19
|
+
import { getReportCardAsciiLines } from './reporter-ascii.js';
|
|
20
|
+
|
|
21
|
+
export const formatGradeFSection = (report) => {
|
|
22
|
+
const { violations, hotspots, pillars } = report;
|
|
23
|
+
const { critical } = groupViolationsBySeverity(violations);
|
|
24
|
+
const extremeMonoliths = hotspots.filter((h) => h.lineCount >= 2000);
|
|
25
|
+
const failedPillars = Object.entries(pillars || {}).filter(([_, p]) => p.status === 'FAILED');
|
|
26
|
+
const lines = [];
|
|
27
|
+
|
|
28
|
+
lines.push('');
|
|
29
|
+
for (const rcLine of getReportCardAsciiLines(RED)) {
|
|
30
|
+
lines.push(` ${rcLine}`);
|
|
31
|
+
}
|
|
32
|
+
lines.push(`${RED}======================================================================${RESET}`);
|
|
33
|
+
lines.push(`${BOLD}${RED} GRADE F : CRITICAL ARCHITECTURAL HAZARDS & EXTREME MONOLITHS${RESET}`);
|
|
34
|
+
lines.push(`${DIM} Immediate action required: >2,000 lines of code monoliths, render hacks, mock data${RESET}`);
|
|
35
|
+
lines.push(`${RED}======================================================================${RESET}`);
|
|
36
|
+
lines.push(` Critical Violations: ${critical.length > 0 ? `${RED}${BOLD}${critical.length}${RESET}` : `${GREEN}0${RESET}`}`);
|
|
37
|
+
lines.push(` Extreme Monoliths: ${extremeMonoliths.length > 0 ? `${RED}${BOLD}${extremeMonoliths.length}${RESET}` : `${GREEN}0${RESET}`}`);
|
|
38
|
+
lines.push(` Failed Pillars: ${failedPillars.length > 0 ? `${RED}${BOLD}${failedPillars.length}${RESET}` : `${GREEN}0${RESET}`}`);
|
|
39
|
+
lines.push(`${RED}----------------------------------------------------------------------${RESET}`);
|
|
40
|
+
|
|
41
|
+
const totalGradeFItems = critical.length + extremeMonoliths.length + failedPillars.length;
|
|
42
|
+
if (totalGradeFItems === 0) {
|
|
43
|
+
lines.push(`\n ${GREEN}â Outstanding! Zero Grade F hazards detected.${RESET}`);
|
|
44
|
+
lines.push(` ${DIM}Codebase is free of extreme monoliths (>2,000 lines of code) and critical violations.${RESET}`);
|
|
45
|
+
} else {
|
|
46
|
+
if (critical.length > 0) {
|
|
47
|
+
lines.push(`\n ${BOLD}${RED}đ¨ CRITICAL AST VIOLATIONS (${critical.length}):${RESET}`);
|
|
48
|
+
critical.forEach((v, idx) => {
|
|
49
|
+
lines.push(` ${RED}[#${idx + 1} CRITICAL]${RESET} [${v.rule}] ${YELLOW}${v.filePath}:${v.line}:${v.column}${RESET}`);
|
|
50
|
+
lines.push(` Hazard: ${v.hazard}`);
|
|
51
|
+
lines.push(` Directive: ${CYAN}${v.directive}${RESET}\n`);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (extremeMonoliths.length > 0) {
|
|
56
|
+
lines.push(` ${BOLD}${RED}đŖ EXTREME MONOLITHS (>= 2,000 LINES):${RESET}`);
|
|
57
|
+
lines.push(` ${DIM}Massive token burn files causing severe context rot and agent hallucination.${RESET}`);
|
|
58
|
+
extremeMonoliths.forEach((h, idx) => {
|
|
59
|
+
lines.push(` [#${idx + 1}] ${YELLOW}${h.filePath}${RESET} (${h.lineCount} lines, ${h.violationCount} hazards) ${RED}[EXTREME MONOLITH]${RESET}`);
|
|
60
|
+
});
|
|
61
|
+
lines.push('');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (failedPillars.length > 0) {
|
|
65
|
+
lines.push(` ${BOLD}${RED}đī¸ FAILED PILLARS (CRITICAL INFECTIONS):${RESET}`);
|
|
66
|
+
for (const [name, p] of failedPillars) {
|
|
67
|
+
lines.push(` â ${YELLOW}${name}${RESET}: ${p.violations} violations (${p.critical} Critical, ${p.high} High, ${p.medium} Med)`);
|
|
68
|
+
}
|
|
69
|
+
lines.push('');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const promptF = buildGradeFPrompt(report);
|
|
74
|
+
if (promptF) {
|
|
75
|
+
lines.push(formatPromptBox('đ¤ AI AGENT REFACTORING PROMPT (GRADE F HAZARDS)', promptF));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
lines.push(`${RED}======================================================================${RESET}\n`);
|
|
79
|
+
return lines.join('\n');
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const formatGradeDSection = (report) => {
|
|
83
|
+
const { violations, hotspots, pillars } = report;
|
|
84
|
+
const { high } = groupViolationsBySeverity(violations);
|
|
85
|
+
const severeMonoliths = hotspots.filter((h) => h.lineCount >= 1000 && h.lineCount < 2000);
|
|
86
|
+
const warnPillars = Object.entries(pillars || {}).filter(([_, p]) => p.status === 'WARN');
|
|
87
|
+
const lines = [];
|
|
88
|
+
|
|
89
|
+
lines.push('');
|
|
90
|
+
for (const rcLine of getReportCardAsciiLines(ORANGE)) {
|
|
91
|
+
lines.push(` ${rcLine}`);
|
|
92
|
+
}
|
|
93
|
+
lines.push(`${ORANGE}======================================================================${RESET}`);
|
|
94
|
+
lines.push(`${BOLD}${ORANGE} GRADE D : HIGH SEVERITY DEBTS & SEVERE MONOLITHS${RESET}`);
|
|
95
|
+
lines.push(`${DIM} Refactoring priorities: 1,000 to 1,999 lines of code files and hook saturation > 5${RESET}`);
|
|
96
|
+
lines.push(`${ORANGE}======================================================================${RESET}`);
|
|
97
|
+
lines.push(` High Severity Debts: ${high.length > 0 ? `${ORANGE}${BOLD}${high.length}${RESET}` : `${GREEN}0${RESET}`}`);
|
|
98
|
+
lines.push(` Severe Monoliths: ${severeMonoliths.length > 0 ? `${ORANGE}${BOLD}${severeMonoliths.length}${RESET}` : `${GREEN}0${RESET}`}`);
|
|
99
|
+
lines.push(` Degraded Pillars: ${warnPillars.length > 0 ? `${ORANGE}${BOLD}${warnPillars.length}${RESET}` : `${GREEN}0${RESET}`}`);
|
|
100
|
+
lines.push(`${ORANGE}----------------------------------------------------------------------${RESET}`);
|
|
101
|
+
|
|
102
|
+
const totalGradeDItems = high.length + severeMonoliths.length + warnPillars.length;
|
|
103
|
+
if (totalGradeDItems === 0) {
|
|
104
|
+
lines.push(`\n ${GREEN}â Zero Grade D debts detected.${RESET}`);
|
|
105
|
+
lines.push(` ${DIM}No severe monoliths (1,000-1,999 lines of code) or saturated hook anti-patterns.${RESET}`);
|
|
106
|
+
} else {
|
|
107
|
+
if (high.length > 0) {
|
|
108
|
+
lines.push(`\n ${BOLD}${ORANGE}â ī¸ HIGH SEVERITY VIOLATIONS (${high.length}):${RESET}`);
|
|
109
|
+
high.forEach((v, idx) => {
|
|
110
|
+
lines.push(` ${ORANGE}[#${idx + 1} HIGH]${RESET} [${v.rule}] ${YELLOW}${v.filePath}:${v.line}:${v.column}${RESET}`);
|
|
111
|
+
lines.push(` Hazard: ${v.hazard}`);
|
|
112
|
+
lines.push(` Directive: ${CYAN}${v.directive}${RESET}\n`);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (severeMonoliths.length > 0) {
|
|
117
|
+
lines.push(` ${BOLD}${ORANGE}đĨ SEVERE MONOLITHS (1,000 - 1,999 LINES):${RESET}`);
|
|
118
|
+
severeMonoliths.forEach((h, idx) => {
|
|
119
|
+
lines.push(` [#${idx + 1}] ${YELLOW}${h.filePath}${RESET} (${h.lineCount} lines, ${h.violationCount} hazards) ${ORANGE}[SEVERE MONOLITH]${RESET}`);
|
|
120
|
+
});
|
|
121
|
+
lines.push('');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (warnPillars.length > 0) {
|
|
125
|
+
lines.push(` ${BOLD}${ORANGE}đī¸ DEGRADED PILLARS (MULTIPLE HIGH/MED DEBTS):${RESET}`);
|
|
126
|
+
for (const [name, p] of warnPillars) {
|
|
127
|
+
lines.push(` â ${YELLOW}${name}${RESET}: ${p.violations} violations (${p.high} High, ${p.medium} Med)`);
|
|
128
|
+
}
|
|
129
|
+
lines.push('');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const promptD = buildGradeDPrompt(report);
|
|
134
|
+
if (promptD) {
|
|
135
|
+
lines.push(formatPromptBox('đ¤ AI AGENT REFACTORING PROMPT (GRADE D DEBTS)', promptD));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
lines.push(`${ORANGE}======================================================================${RESET}\n`);
|
|
139
|
+
return lines.join('\n');
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const formatGradeCSection = (report) => {
|
|
143
|
+
const { violations, hotspots } = report;
|
|
144
|
+
const { medium } = groupViolationsBySeverity(violations);
|
|
145
|
+
const warningMonoliths = hotspots.filter((h) => h.lineCount >= 500 && h.lineCount < 1000);
|
|
146
|
+
const lines = [];
|
|
147
|
+
|
|
148
|
+
lines.push('');
|
|
149
|
+
for (const rcLine of getReportCardAsciiLines(CYAN)) {
|
|
150
|
+
lines.push(` ${rcLine}`);
|
|
151
|
+
}
|
|
152
|
+
lines.push(`${CYAN}======================================================================${RESET}`);
|
|
153
|
+
lines.push(`${BOLD}${CYAN} GRADE C : MEDIUM SEVERITY DEBTS & MONOLITHIC DRIFT${RESET}`);
|
|
154
|
+
lines.push(`${DIM} Architecture debts: 500 to 999 lines of code files and raw inline style attributes${RESET}`);
|
|
155
|
+
lines.push(`${CYAN}======================================================================${RESET}`);
|
|
156
|
+
lines.push(` Medium Debts: ${medium.length > 0 ? `${YELLOW}${BOLD}${medium.length}${RESET}` : `${GREEN}0${RESET}`}`);
|
|
157
|
+
lines.push(` Warning Monoliths: ${warningMonoliths.length > 0 ? `${YELLOW}${BOLD}${warningMonoliths.length}${RESET}` : `${GREEN}0${RESET}`}`);
|
|
158
|
+
lines.push(`${CYAN}----------------------------------------------------------------------${RESET}`);
|
|
159
|
+
|
|
160
|
+
const totalGradeCItems = medium.length + warningMonoliths.length;
|
|
161
|
+
if (totalGradeCItems === 0) {
|
|
162
|
+
lines.push(`\n ${GREEN}â Zero Grade C debts detected.${RESET}`);
|
|
163
|
+
lines.push(` ${DIM}All files remain under 500 lines with clean styling and handlers.${RESET}`);
|
|
164
|
+
} else {
|
|
165
|
+
if (medium.length > 0) {
|
|
166
|
+
lines.push(`\n ${BOLD}${CYAN}⥠MEDIUM SEVERITY VIOLATIONS (${medium.length}):${RESET}`);
|
|
167
|
+
medium.forEach((v, idx) => {
|
|
168
|
+
lines.push(` ${YELLOW}[#${idx + 1} MED]${RESET} [${v.rule}] ${YELLOW}${v.filePath}:${v.line}:${v.column}${RESET}`);
|
|
169
|
+
lines.push(` Hazard: ${v.hazard}`);
|
|
170
|
+
lines.push(` Directive: ${CYAN}${v.directive}${RESET}\n`);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (warningMonoliths.length > 0) {
|
|
175
|
+
lines.push(` ${BOLD}${CYAN}â ī¸ WARNING MONOLITHS (500 - 999 LINES):${RESET}`);
|
|
176
|
+
warningMonoliths.forEach((h, idx) => {
|
|
177
|
+
lines.push(` [#${idx + 1}] ${YELLOW}${h.filePath}${RESET} (${h.lineCount} lines, ${h.violationCount} hazards) ${DIM}[MONOLITH WARNING]${RESET}`);
|
|
178
|
+
});
|
|
179
|
+
lines.push('');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const promptC = buildGradeCPrompt(report);
|
|
184
|
+
if (promptC) {
|
|
185
|
+
lines.push(formatPromptBox('đ¤ AI AGENT REFACTORING PROMPT (GRADE C DEBTS)', promptC));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
lines.push(`${CYAN}======================================================================${RESET}\n`);
|
|
189
|
+
return lines.join('\n');
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export const formatGradeBSection = (report) => {
|
|
193
|
+
const { violations } = report;
|
|
194
|
+
const { low } = groupViolationsBySeverity(violations);
|
|
195
|
+
const lines = [];
|
|
196
|
+
|
|
197
|
+
lines.push('');
|
|
198
|
+
for (const rcLine of getReportCardAsciiLines(YELLOW)) {
|
|
199
|
+
lines.push(` ${rcLine}`);
|
|
200
|
+
}
|
|
201
|
+
lines.push(`${YELLOW}======================================================================${RESET}`);
|
|
202
|
+
lines.push(`${BOLD}${YELLOW} GRADE B : LOW SEVERITY HYGIENE & MINOR CODE SMELLS${RESET}`);
|
|
203
|
+
lines.push(`${DIM} Hygiene & polish: Em dash typography leaks and unguarded console logging${RESET}`);
|
|
204
|
+
lines.push(`${YELLOW}======================================================================${RESET}`);
|
|
205
|
+
lines.push(` Low Hygiene Issues: ${low.length > 0 ? `${YELLOW}${BOLD}${low.length}${RESET}` : `${GREEN}0${RESET}`}`);
|
|
206
|
+
lines.push(`${YELLOW}----------------------------------------------------------------------${RESET}`);
|
|
207
|
+
|
|
208
|
+
if (low.length === 0) {
|
|
209
|
+
lines.push(`\n ${GREEN}â Outstanding hygiene! Zero Grade B issues detected.${RESET}`);
|
|
210
|
+
lines.push(` ${DIM}Zero em dashes and zero unguarded console statements found.${RESET}`);
|
|
211
|
+
} else {
|
|
212
|
+
lines.push(`\n ${BOLD}${YELLOW}âšī¸ LOW HYGIENE VIOLATIONS (${low.length}):${RESET}`);
|
|
213
|
+
low.forEach((v, idx) => {
|
|
214
|
+
lines.push(` ${YELLOW}[#${idx + 1} LOW]${RESET} [${v.rule}] ${YELLOW}${v.filePath}:${v.line}:${v.column}${RESET}`);
|
|
215
|
+
lines.push(` Hazard: ${v.hazard}`);
|
|
216
|
+
lines.push(` Directive: ${CYAN}${v.directive}${RESET}\n`);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const promptB = buildGradeBPrompt(report);
|
|
221
|
+
if (promptB) {
|
|
222
|
+
lines.push(formatPromptBox('đ¤ AI AGENT REFACTORING PROMPT (GRADE B HYGIENE)', promptB));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
lines.push(`${YELLOW}======================================================================${RESET}\n`);
|
|
226
|
+
return lines.join('\n');
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export const formatGradeASection = (report) => {
|
|
230
|
+
const { metrics, health, pillars, hotspots, contextAnalysis } = report;
|
|
231
|
+
const passedPillars = Object.entries(pillars || {}).filter(([_, p]) => p.status === 'PASSED');
|
|
232
|
+
const lines = [];
|
|
233
|
+
|
|
234
|
+
lines.push('');
|
|
235
|
+
for (const rcLine of getReportCardAsciiLines(GREEN)) {
|
|
236
|
+
lines.push(` ${rcLine}`);
|
|
237
|
+
}
|
|
238
|
+
lines.push(`${GREEN}======================================================================${RESET}`);
|
|
239
|
+
lines.push(`${BOLD}${GREEN} GRADE A : COMPLIANT ARCHITECTURE & PASSING PILLARS${RESET}`);
|
|
240
|
+
lines.push(`${DIM} Molecular Architecture verified clean areas and crystalline modules${RESET}`);
|
|
241
|
+
lines.push(`${GREEN}======================================================================${RESET}`);
|
|
242
|
+
lines.push(` Molecular Health Score: ${BOLD}${GREEN}${health.score}/100${RESET} [Grade: ${BOLD}${GREEN}${health.grade}${RESET}]`);
|
|
243
|
+
lines.push(` Passing Pillars: ${BOLD}${GREEN}${passedPillars.length} / 7 Pillars PASSED${RESET}`);
|
|
244
|
+
lines.push(` Capsule Compliance: ${BOLD}${GREEN}${metrics.moleculeCompliantPct}%${RESET} compliant (< 100 lines of code)`);
|
|
245
|
+
lines.push(`${GREEN}----------------------------------------------------------------------${RESET}`);
|
|
246
|
+
|
|
247
|
+
lines.push(`\n ${BOLD}${GREEN}â COMPLIANT PILLARS (${passedPillars.length} / 7):${RESET}`);
|
|
248
|
+
if (passedPillars.length === 0) {
|
|
249
|
+
lines.push(` ${YELLOW}No pillars are currently 100% compliant.${RESET}\n`);
|
|
250
|
+
} else {
|
|
251
|
+
for (const [name] of passedPillars) {
|
|
252
|
+
lines.push(` ${GREEN}â${RESET} ${name} ${DIM}(0 violations)${RESET}`);
|
|
253
|
+
}
|
|
254
|
+
lines.push('');
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
lines.push(` ${BOLD}${CYAN}STANDARDS MET & CLEAN CODEBASE ASSETS:${RESET}`);
|
|
258
|
+
if (metrics.moleculeCompliantPct === 100) {
|
|
259
|
+
lines.push(` ${GREEN}â${RESET} 100% Molecule Capsule Limit (< 100 lines per molecule)`);
|
|
260
|
+
}
|
|
261
|
+
const hasExtremeMonolith = hotspots.some((h) => h.lineCount >= 2000);
|
|
262
|
+
if (!hasExtremeMonolith) {
|
|
263
|
+
lines.push(` ${GREEN}â${RESET} Zero Extreme Monoliths (0 files >= 2,000 lines of code)`);
|
|
264
|
+
}
|
|
265
|
+
const hasSevereMonolith = hotspots.some((h) => h.lineCount >= 1000);
|
|
266
|
+
if (!hasSevereMonolith) {
|
|
267
|
+
lines.push(` ${GREEN}â${RESET} Zero Severe Monoliths (0 files >= 1,000 lines of code)`);
|
|
268
|
+
}
|
|
269
|
+
if (contextAnalysis.riskLevel === 'LOW') {
|
|
270
|
+
lines.push(` ${GREEN}â${RESET} Low Context Hazard & Token Burn Risk`);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
lines.push(`\n${GREEN}======================================================================${RESET}\n`);
|
|
274
|
+
return lines.join('\n');
|
|
275
|
+
};
|