tech-debt-visualizer 0.2.17 → 0.2.19
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/dist/cleanliness-score.d.ts +4 -4
- package/dist/cleanliness-score.js +10 -10
- package/dist/cli.js +16 -8
- package/dist/debt-score.d.ts +4 -4
- package/dist/debt-score.js +6 -4
- package/dist/llm.js +7 -4
- package/dist/reports/assets/report.css +10 -10
- package/dist/reports/html.js +13 -11
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Technical Debt Cleanliness Score: map
|
|
3
|
-
*
|
|
2
|
+
* Technical Debt Cleanliness Score: map cleanliness score (0-100) to one of five tiers.
|
|
3
|
+
* Cleanliness: 0 = most debt, 100 = least debt. Tier 1 = worst, Tier 5 = best.
|
|
4
4
|
*/
|
|
5
5
|
export interface CleanlinessTier {
|
|
6
6
|
tier: 1 | 2 | 3 | 4 | 5;
|
|
7
7
|
label: string;
|
|
8
8
|
description: string;
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
export declare function getCleanlinessTier(
|
|
10
|
+
/** Cleanliness score 0-100 (0 = worst, 100 = best). Returns tier 1-5: 1 = 0-20, 2 = 21-40, 3 = 41-60, 4 = 61-80, 5 = 81-100. */
|
|
11
|
+
export declare function getCleanlinessTier(cleanlinessScore: number): CleanlinessTier;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Technical Debt Cleanliness Score: map
|
|
3
|
-
*
|
|
2
|
+
* Technical Debt Cleanliness Score: map cleanliness score (0-100) to one of five tiers.
|
|
3
|
+
* Cleanliness: 0 = most debt, 100 = least debt. Tier 1 = worst, Tier 5 = best.
|
|
4
4
|
*/
|
|
5
5
|
const TIERS = [
|
|
6
6
|
{ tier: 1, label: "Prompt Roulette Champion", description: "100% vibes, 0% understanding" },
|
|
@@ -9,16 +9,16 @@ const TIERS = [
|
|
|
9
9
|
{ tier: 4, label: "Power Tool User", description: "AI is the nail gun" },
|
|
10
10
|
{ tier: 5, label: "Pure Coder", description: "Hand-crafted artisanal code, no AI needed" },
|
|
11
11
|
];
|
|
12
|
-
/**
|
|
13
|
-
export function getCleanlinessTier(
|
|
14
|
-
const clamped = Math.max(0, Math.min(100, Math.round(
|
|
12
|
+
/** Cleanliness score 0-100 (0 = worst, 100 = best). Returns tier 1-5: 1 = 0-20, 2 = 21-40, 3 = 41-60, 4 = 61-80, 5 = 81-100. */
|
|
13
|
+
export function getCleanlinessTier(cleanlinessScore) {
|
|
14
|
+
const clamped = Math.max(0, Math.min(100, Math.round(cleanlinessScore)));
|
|
15
15
|
if (clamped <= 20)
|
|
16
|
-
return TIERS[
|
|
16
|
+
return TIERS[0]; // tier 1
|
|
17
17
|
if (clamped <= 40)
|
|
18
|
-
return TIERS[
|
|
18
|
+
return TIERS[1]; // tier 2
|
|
19
19
|
if (clamped <= 60)
|
|
20
|
-
return TIERS[2]; // 3
|
|
20
|
+
return TIERS[2]; // tier 3
|
|
21
21
|
if (clamped <= 80)
|
|
22
|
-
return TIERS[
|
|
23
|
-
return TIERS[
|
|
22
|
+
return TIERS[3]; // tier 4
|
|
23
|
+
return TIERS[4]; // tier 5
|
|
24
24
|
}
|
package/dist/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ import { Command } from "commander";
|
|
|
10
10
|
import chalk from "chalk";
|
|
11
11
|
import cliProgress from "cli-progress";
|
|
12
12
|
import { getCleanlinessTier } from "./cleanliness-score.js";
|
|
13
|
-
import { getDebtScore } from "./debt-score.js";
|
|
13
|
+
import { getCleanlinessScore, getDebtScore } from "./debt-score.js";
|
|
14
14
|
import { runAnalysis } from "./engine.js";
|
|
15
15
|
import { assessFileCleanliness, assessOverallCleanliness, resolveLLMConfig, } from "./llm.js";
|
|
16
16
|
import { generateHtmlReport } from "./reports/html.js";
|
|
@@ -113,7 +113,7 @@ program
|
|
|
113
113
|
...run.fileMetrics[idx],
|
|
114
114
|
llmAssessment: result.value.assessment,
|
|
115
115
|
llmSuggestedCode: result.value.suggestedCode,
|
|
116
|
-
llmFileScore: result.value.fileScore,
|
|
116
|
+
llmFileScore: result.value.fileScore != null ? 100 - result.value.fileScore : undefined,
|
|
117
117
|
llmSeverity: result.value.severity,
|
|
118
118
|
llmRawAssessment: result.value.raw,
|
|
119
119
|
};
|
|
@@ -130,7 +130,7 @@ program
|
|
|
130
130
|
if (overall) {
|
|
131
131
|
run.llmOverallAssessment = overall.assessment;
|
|
132
132
|
if (overall.score != null)
|
|
133
|
-
run.llmOverallScore = overall.score;
|
|
133
|
+
run.llmOverallScore = 100 - overall.score;
|
|
134
134
|
if (overall.severity)
|
|
135
135
|
run.llmOverallSeverity = overall.severity;
|
|
136
136
|
run.llmOverallRaw = overall.raw;
|
|
@@ -189,13 +189,13 @@ program
|
|
|
189
189
|
});
|
|
190
190
|
function printCliReport(run, ci) {
|
|
191
191
|
const { debtItems, fileMetrics, errors } = run;
|
|
192
|
-
const
|
|
193
|
-
const cleanliness = getCleanlinessTier(
|
|
192
|
+
const cleanlinessScore = getCleanlinessScore(run);
|
|
193
|
+
const cleanliness = getCleanlinessTier(cleanlinessScore);
|
|
194
194
|
process.stdout.write("\n");
|
|
195
195
|
process.stdout.write(chalk.bold.dim(" Technical Debt Cleanliness Score\n"));
|
|
196
196
|
process.stdout.write(" " + "—".repeat(52) + "\n");
|
|
197
197
|
const tierColor = cleanlinessTierColor(cleanliness.tier);
|
|
198
|
-
process.stdout.write(tierColor(` ${cleanliness.label} (${cleanliness.tier}/5)\n`));
|
|
198
|
+
process.stdout.write(tierColor(` ${cleanliness.label} (${Math.round(cleanlinessScore)}/100, tier ${cleanliness.tier}/5)\n`));
|
|
199
199
|
process.stdout.write(tierColor(` ${cleanliness.description}\n`));
|
|
200
200
|
process.stdout.write(" " + "—".repeat(52) + "\n\n");
|
|
201
201
|
process.stdout.write(chalk.bold(" Summary\n"));
|
|
@@ -205,8 +205,8 @@ function printCliReport(run, ci) {
|
|
|
205
205
|
if (run.debtTrend && run.debtTrend.length > 0) {
|
|
206
206
|
process.stdout.write(` Recent commits: ${chalk.cyan(String(run.debtTrend.length))}\n`);
|
|
207
207
|
}
|
|
208
|
-
process.stdout.write(`
|
|
209
|
-
process.stdout.write(chalk.dim("
|
|
208
|
+
process.stdout.write(` Cleanliness: ${cleanlinessColor(cleanlinessScore)} / 100 (tier ${cleanliness.tier}/5)\n`);
|
|
209
|
+
process.stdout.write(chalk.dim(" 0 = most debt, 100 = least debt\n\n"));
|
|
210
210
|
const bySeverity = { critical: 0, high: 0, medium: 0, low: 0 };
|
|
211
211
|
for (const d of debtItems) {
|
|
212
212
|
bySeverity[d.severity]++;
|
|
@@ -296,6 +296,14 @@ function severityColor(score) {
|
|
|
296
296
|
return chalk.yellow(String(score));
|
|
297
297
|
return chalk.green(String(score));
|
|
298
298
|
}
|
|
299
|
+
function cleanlinessColor(cleanlinessScore) {
|
|
300
|
+
const n = Math.round(cleanlinessScore);
|
|
301
|
+
if (n >= 70)
|
|
302
|
+
return chalk.green(String(n));
|
|
303
|
+
if (n >= 40)
|
|
304
|
+
return chalk.yellow(String(n));
|
|
305
|
+
return chalk.red(String(n));
|
|
306
|
+
}
|
|
299
307
|
function cleanlinessTierColor(tier) {
|
|
300
308
|
switch (tier) {
|
|
301
309
|
case 5:
|
package/dist/debt-score.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { AnalysisRun } from "./types.js";
|
|
6
6
|
/**
|
|
7
|
-
* Debt score 0–100
|
|
8
|
-
*
|
|
9
|
-
* - Else if any file has LLM file score: use average of those.
|
|
10
|
-
* - Else: static score from debt items.
|
|
7
|
+
* Debt score 0–100 (higher = more debt). Stored and computed internally; for display use getCleanlinessScore.
|
|
8
|
+
* When LLM is used, we store debt = 100 - llm_cleanliness so that this still returns "debt".
|
|
11
9
|
*/
|
|
12
10
|
export declare function getDebtScore(run: AnalysisRun): number;
|
|
11
|
+
/** Cleanliness score 0–100 (0 = most debt, 100 = least debt). Use this for display and tier. */
|
|
12
|
+
export declare function getCleanlinessScore(run: AnalysisRun): number;
|
package/dist/debt-score.js
CHANGED
|
@@ -12,10 +12,8 @@ function getStaticDebtScore(run) {
|
|
|
12
12
|
return Math.min(100, Math.round((sum / items.length) * 25));
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Debt score 0–100
|
|
16
|
-
*
|
|
17
|
-
* - Else if any file has LLM file score: use average of those.
|
|
18
|
-
* - Else: static score from debt items.
|
|
15
|
+
* Debt score 0–100 (higher = more debt). Stored and computed internally; for display use getCleanlinessScore.
|
|
16
|
+
* When LLM is used, we store debt = 100 - llm_cleanliness so that this still returns "debt".
|
|
19
17
|
*/
|
|
20
18
|
export function getDebtScore(run) {
|
|
21
19
|
if (run.llmOverallScore != null) {
|
|
@@ -30,3 +28,7 @@ export function getDebtScore(run) {
|
|
|
30
28
|
}
|
|
31
29
|
return getStaticDebtScore(run);
|
|
32
30
|
}
|
|
31
|
+
/** Cleanliness score 0–100 (0 = most debt, 100 = least debt). Use this for display and tier. */
|
|
32
|
+
export function getCleanlinessScore(run) {
|
|
33
|
+
return 100 - getDebtScore(run);
|
|
34
|
+
}
|
package/dist/llm.js
CHANGED
|
@@ -292,7 +292,7 @@ ${snippet}
|
|
|
292
292
|
Output only:
|
|
293
293
|
1. A two- to four-sentence summary of the issues (how clean/maintainable, main concerns). No code block unless absolutely necessary to demonstrate.
|
|
294
294
|
2. On the next line write only one word: critical, high, medium, low, or none (this file's technical debt severity; none = no significant debt).
|
|
295
|
-
3. On the line after that write only a number 0-100 (
|
|
295
|
+
3. On the line after that write only a number 0-100 (0 = most debt, 100 = least debt / cleanest).
|
|
296
296
|
No preamble.`;
|
|
297
297
|
const raw = await chat(prompt, {
|
|
298
298
|
...resolved,
|
|
@@ -318,16 +318,19 @@ export async function assessOverallCleanliness(run, config = {}) {
|
|
|
318
318
|
const debtCount = run.debtItems.length;
|
|
319
319
|
const criticalHigh = run.debtItems.filter((d) => d.severity === "critical" || d.severity === "high").length;
|
|
320
320
|
const hotspots = run.fileMetrics.filter((m) => (m.hotspotScore ?? 0) > 0.3).length;
|
|
321
|
+
const allFiles = run.fileMetrics.map((m) => m.file);
|
|
321
322
|
const topFiles = run.fileMetrics
|
|
322
323
|
.sort((a, b) => (b.hotspotScore ?? 0) - (a.hotspotScore ?? 0))
|
|
323
324
|
.slice(0, 12)
|
|
324
325
|
.map((m) => m.file);
|
|
325
|
-
const prompt = `Codebase summary: ${fileCount} files, ${debtCount} debt items (${criticalHigh} critical/high), ${hotspots} hotspots.
|
|
326
|
+
const prompt = `Codebase summary: ${fileCount} files, ${debtCount} debt items (${criticalHigh} critical/high), ${hotspots} hotspots.
|
|
327
|
+
All files in this codebase: ${allFiles.join(", ")}
|
|
328
|
+
Top risk files (by hotspot): ${topFiles.join(", ")}
|
|
326
329
|
|
|
327
330
|
Output only:
|
|
328
|
-
1. A
|
|
331
|
+
1. A single paragraph of 7–10 sentences that gives full context for the whole codebase. Cover ALL files: briefly note which files or areas are in good shape, which have issues, and how they fit together. Include strengths, main concerns, and the single most important improvement. Write for someone who needs to understand the entire codebase, not just the problematic parts. No code block unless absolutely necessary.
|
|
329
332
|
2. On the next line write only one word: critical, high, medium, low, or none (overall codebase technical debt severity).
|
|
330
|
-
3. On the line after that write only a number 0-100 (
|
|
333
|
+
3. On the line after that write only a number 0-100 (0 = most debt, 100 = least debt / cleanest).
|
|
331
334
|
No preamble.`;
|
|
332
335
|
const raw = await chat(prompt, {
|
|
333
336
|
...resolved,
|
|
@@ -506,7 +506,7 @@ body.dashboard-page {
|
|
|
506
506
|
display: flex;
|
|
507
507
|
align-items: baseline;
|
|
508
508
|
justify-content: center;
|
|
509
|
-
gap: 0.4rem; /* space between number and "of
|
|
509
|
+
gap: 0.4rem; /* space between number and "of 100" */
|
|
510
510
|
margin-bottom: 0.5rem;
|
|
511
511
|
}
|
|
512
512
|
|
|
@@ -584,18 +584,18 @@ body.dashboard-page {
|
|
|
584
584
|
|
|
585
585
|
.panel-score-pop .score-num {
|
|
586
586
|
font-family: "Inter", sans-serif;
|
|
587
|
-
font-size:
|
|
587
|
+
font-size: 3.25rem;
|
|
588
588
|
font-weight: 800;
|
|
589
589
|
line-height: 1;
|
|
590
590
|
background: linear-gradient(180deg, var(--accent-orange) 0%, var(--accent-red) 100%);
|
|
591
591
|
-webkit-background-clip: text;
|
|
592
592
|
-webkit-text-fill-color: transparent;
|
|
593
593
|
background-clip: text;
|
|
594
|
-
filter: drop-shadow(0 0
|
|
594
|
+
filter: drop-shadow(0 0 20px rgba(255, 107, 53, 0.35));
|
|
595
595
|
}
|
|
596
596
|
|
|
597
597
|
.panel-score-pop .score-of {
|
|
598
|
-
font-size:
|
|
598
|
+
font-size: 1.35rem;
|
|
599
599
|
font-weight: 700;
|
|
600
600
|
color: var(--text-muted);
|
|
601
601
|
}
|
|
@@ -603,24 +603,24 @@ body.dashboard-page {
|
|
|
603
603
|
.panel-score-pop .score-label {
|
|
604
604
|
display: inline-block;
|
|
605
605
|
background: linear-gradient(135deg, var(--accent-orange), var(--accent-red));
|
|
606
|
-
padding: 0.
|
|
606
|
+
padding: 0.45rem 1.1rem;
|
|
607
607
|
border-radius: 50px;
|
|
608
608
|
font-family: "Inter", sans-serif;
|
|
609
|
-
font-size:
|
|
609
|
+
font-size: 1rem;
|
|
610
610
|
font-weight: 700;
|
|
611
611
|
letter-spacing: 0.5px;
|
|
612
612
|
text-transform: uppercase;
|
|
613
|
-
box-shadow: 0
|
|
614
|
-
margin-bottom: 0.
|
|
613
|
+
box-shadow: 0 6px 18px rgba(255, 107, 53, 0.35);
|
|
614
|
+
margin-bottom: 0.35rem;
|
|
615
615
|
-webkit-text-fill-color: initial;
|
|
616
616
|
color: #fff;
|
|
617
617
|
}
|
|
618
618
|
|
|
619
619
|
.panel-score-pop .score-desc {
|
|
620
|
-
font-size: 0.
|
|
620
|
+
font-size: 0.9rem;
|
|
621
621
|
color: var(--text-muted);
|
|
622
622
|
font-style: italic;
|
|
623
|
-
margin-bottom: 0.
|
|
623
|
+
margin-bottom: 0.35rem;
|
|
624
624
|
}
|
|
625
625
|
|
|
626
626
|
.panel-score-pop .score-stats {
|
package/dist/reports/html.js
CHANGED
|
@@ -2,7 +2,7 @@ import { readFile, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { getCleanlinessTier } from "../cleanliness-score.js";
|
|
5
|
-
import {
|
|
5
|
+
import { getCleanlinessScore } from "../debt-score.js";
|
|
6
6
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
7
|
const ASSETS_DIR = join(__dirname, "assets");
|
|
8
8
|
export async function generateHtmlReport(run, options) {
|
|
@@ -46,8 +46,9 @@ function adjustHexBrightness(hex, factor) {
|
|
|
46
46
|
}
|
|
47
47
|
function buildHtml(run, title, darkMode, css, script) {
|
|
48
48
|
const theme = darkMode ? "dark" : "light";
|
|
49
|
-
const
|
|
50
|
-
const
|
|
49
|
+
const cleanlinessScore = getCleanlinessScore(run);
|
|
50
|
+
const scoreNum = Math.round(Math.max(0, Math.min(100, cleanlinessScore)));
|
|
51
|
+
const cleanliness = getCleanlinessTier(cleanlinessScore);
|
|
51
52
|
const hasLlm = !!(run.llmOverallAssessment || run.llmOverallRaw);
|
|
52
53
|
const dataJson = JSON.stringify({
|
|
53
54
|
fileMetrics: run.fileMetrics,
|
|
@@ -59,7 +60,8 @@ function buildHtml(run, title, darkMode, css, script) {
|
|
|
59
60
|
summary: {
|
|
60
61
|
filesAnalyzed: run.fileMetrics.length,
|
|
61
62
|
debtCount: run.debtItems.length,
|
|
62
|
-
debtScore,
|
|
63
|
+
debtScore: 100 - cleanlinessScore,
|
|
64
|
+
cleanlinessScore: scoreNum,
|
|
63
65
|
cleanlinessTier: cleanliness.tier,
|
|
64
66
|
cleanlinessLabel: cleanliness.label,
|
|
65
67
|
cleanlinessDescription: cleanliness.description,
|
|
@@ -76,11 +78,11 @@ function buildHtml(run, title, darkMode, css, script) {
|
|
|
76
78
|
<meta charset="UTF-8" />
|
|
77
79
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
78
80
|
<title>${escapeHtml(title)}</title>
|
|
79
|
-
<meta property="og:title" content="${escapeHtml(title)} — ${
|
|
81
|
+
<meta property="og:title" content="${escapeHtml(title)} — ${scoreNum}/100 ${escapeHtml(cleanliness.label)}" />
|
|
80
82
|
<meta property="og:description" content="${escapeHtml(cleanliness.description)}" />
|
|
81
83
|
<meta property="og:type" content="website" />
|
|
82
84
|
<meta name="twitter:card" content="summary" />
|
|
83
|
-
<meta name="twitter:title" content="${escapeHtml(title)} — ${
|
|
85
|
+
<meta name="twitter:title" content="${escapeHtml(title)} — ${scoreNum}/100" />
|
|
84
86
|
<meta name="twitter:description" content="${escapeHtml(cleanliness.label)}: ${escapeHtml(cleanliness.description)}" />
|
|
85
87
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
|
|
86
88
|
<style>${css}</style>
|
|
@@ -93,9 +95,9 @@ function buildHtml(run, title, darkMode, css, script) {
|
|
|
93
95
|
<span class="dashboard-meta">${escapeHtml(run.repoPath)}</span>
|
|
94
96
|
</div>
|
|
95
97
|
<div class="dashboard-header-right">
|
|
96
|
-
<div class="dashboard-score tier-${cleanliness.tier}" aria-label="Score ${
|
|
97
|
-
<span class="dashboard-score-value">${
|
|
98
|
-
<span class="dashboard-score-of">/
|
|
98
|
+
<div class="dashboard-score tier-${cleanliness.tier}" aria-label="Score ${scoreNum} of 100">
|
|
99
|
+
<span class="dashboard-score-value">${scoreNum}</span>
|
|
100
|
+
<span class="dashboard-score-of">/ 100</span>
|
|
99
101
|
<span class="dashboard-score-label">${escapeHtml(cleanliness.label)}</span>
|
|
100
102
|
</div>
|
|
101
103
|
<button type="button" class="btn-ai-prompts btn-ai-prompts-header" id="btnAiPrompts">AI cleanup prompts</button>
|
|
@@ -112,8 +114,8 @@ function buildHtml(run, title, darkMode, css, script) {
|
|
|
112
114
|
</div>
|
|
113
115
|
<div class="panel-body panel-body-score">
|
|
114
116
|
<div class="score-numeric">
|
|
115
|
-
<span class="score-num">${
|
|
116
|
-
<span class="score-of">of
|
|
117
|
+
<span class="score-num">${scoreNum}</span>
|
|
118
|
+
<span class="score-of">of 100</span>
|
|
117
119
|
</div>
|
|
118
120
|
<p class="score-label">${escapeHtml(cleanliness.label)}</p>
|
|
119
121
|
<p class="score-desc">${escapeHtml(cleanliness.description)}</p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tech-debt-visualizer",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.19",
|
|
4
4
|
"description": "Language-agnostic CLI that analyzes repos and generates interactive technical debt visualizations with AI-powered insights",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|