tech-debt-visualizer 0.1.1 → 0.1.2
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/cli.d.ts +1 -1
- package/dist/cli.js +41 -32
- package/package.json +2 -1
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* CLI entry: colorful terminal output, progress bars, actionable insights.
|
|
4
4
|
*/
|
|
5
|
+
import "dotenv/config";
|
|
5
6
|
import { Command } from "commander";
|
|
6
7
|
import chalk from "chalk";
|
|
7
8
|
import cliProgress from "cli-progress";
|
|
@@ -9,7 +10,7 @@ import { readFile } from "node:fs/promises";
|
|
|
9
10
|
import { join } from "node:path";
|
|
10
11
|
import { getCleanlinessTier } from "./cleanliness-score.js";
|
|
11
12
|
import { runAnalysis } from "./engine.js";
|
|
12
|
-
import { assessFileCleanliness, assessOverallCleanliness, enrichDebtWithInsights, suggestNextSteps, } from "./llm.js";
|
|
13
|
+
import { assessFileCleanliness, assessOverallCleanliness, enrichDebtWithInsights, resolveLLMConfig, suggestNextSteps, } from "./llm.js";
|
|
13
14
|
import { generateHtmlReport } from "./reports/html.js";
|
|
14
15
|
import { generateJsonReport } from "./reports/json.js";
|
|
15
16
|
import { generateMarkdownReport } from "./reports/markdown.js";
|
|
@@ -57,39 +58,47 @@ program
|
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
if (useLlm) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const content = fileContents.get(m.file);
|
|
66
|
-
if (!content)
|
|
67
|
-
continue;
|
|
68
|
-
const result = await assessFileCleanliness(m.file, content, m, {}, { filePaths: allFilePaths });
|
|
69
|
-
if (result) {
|
|
70
|
-
const idx = run.fileMetrics.findIndex((x) => x.file === m.file);
|
|
71
|
-
if (idx >= 0)
|
|
72
|
-
run.fileMetrics[idx] = {
|
|
73
|
-
...run.fileMetrics[idx],
|
|
74
|
-
llmAssessment: result.assessment,
|
|
75
|
-
llmSuggestedCode: result.suggestedCode,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
61
|
+
const llmConfig = resolveLLMConfig();
|
|
62
|
+
if (!llmConfig) {
|
|
63
|
+
process.stderr.write(chalk.yellow(" No LLM API key found. Set one of: GEMINI_API_KEY, OPENAI_API_KEY, or OPENROUTER_API_KEY.\n" +
|
|
64
|
+
" Example: export GEMINI_API_KEY=your_key_here\n" +
|
|
65
|
+
" Skipping AI insights for this run.\n\n"));
|
|
78
66
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
67
|
+
else {
|
|
68
|
+
progress.update(3, { task: "LLM: per-file cleanliness..." });
|
|
69
|
+
const allFilePaths = run.fileMetrics.map((m) => m.file);
|
|
70
|
+
const maxFiles = 80;
|
|
71
|
+
const filesToAssess = run.fileMetrics.slice(0, maxFiles);
|
|
72
|
+
for (const m of filesToAssess) {
|
|
73
|
+
const content = fileContents.get(m.file);
|
|
74
|
+
if (!content)
|
|
75
|
+
continue;
|
|
76
|
+
const result = await assessFileCleanliness(m.file, content, m, {}, { filePaths: allFilePaths });
|
|
77
|
+
if (result) {
|
|
78
|
+
const idx = run.fileMetrics.findIndex((x) => x.file === m.file);
|
|
79
|
+
if (idx >= 0)
|
|
80
|
+
run.fileMetrics[idx] = {
|
|
81
|
+
...run.fileMetrics[idx],
|
|
82
|
+
llmAssessment: result.assessment,
|
|
83
|
+
llmSuggestedCode: result.suggestedCode,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
progress.update(4, { task: "LLM: debt item insights..." });
|
|
88
|
+
let debtItems = run.debtItems;
|
|
89
|
+
if (debtItems.length > 0) {
|
|
90
|
+
debtItems = await enrichDebtWithInsights(debtItems.slice(0, 25), fileContents);
|
|
91
|
+
const byId = new Map(debtItems.map((d) => [d.id, d]));
|
|
92
|
+
run.debtItems = run.debtItems.map((d) => byId.get(d.id) ?? d);
|
|
93
|
+
}
|
|
94
|
+
progress.update(5, { task: "LLM: overall assessment..." });
|
|
95
|
+
const overall = await assessOverallCleanliness(run);
|
|
96
|
+
if (overall)
|
|
97
|
+
run.llmOverallAssessment = overall;
|
|
98
|
+
const nextSteps = await suggestNextSteps(run);
|
|
99
|
+
if (nextSteps?.length)
|
|
100
|
+
run.llmNextSteps = nextSteps;
|
|
85
101
|
}
|
|
86
|
-
progress.update(5, { task: "LLM: overall assessment..." });
|
|
87
|
-
const overall = await assessOverallCleanliness(run);
|
|
88
|
-
if (overall)
|
|
89
|
-
run.llmOverallAssessment = overall;
|
|
90
|
-
const nextSteps = await suggestNextSteps(run);
|
|
91
|
-
if (nextSteps?.length)
|
|
92
|
-
run.llmNextSteps = nextSteps;
|
|
93
102
|
}
|
|
94
103
|
progress.update(totalSteps, { task: "Done" });
|
|
95
104
|
progress.stop();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tech-debt-visualizer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"README.md"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"dotenv": "^16.4.5",
|
|
33
34
|
"chalk": "^5.3.0",
|
|
34
35
|
"cli-progress": "^3.12.0",
|
|
35
36
|
"commander": "^12.1.0",
|