@aiready/context-analyzer 0.21.26 → 0.21.27
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/.turbo/turbo-build.log +32 -25
- package/.turbo/turbo-test.log +51 -87
- package/coverage/clover.xml +392 -1878
- package/coverage/coverage-final.json +15 -19
- package/coverage/index.html +48 -63
- package/coverage/src/analyzers/index.html +21 -21
- package/coverage/src/analyzers/python-context.ts.html +96 -96
- package/coverage/src/ast-utils.ts.html +34 -109
- package/coverage/src/classifier.ts.html +104 -104
- package/coverage/src/classify/classification-patterns.ts.html +1 -1
- package/coverage/src/classify/file-classifiers.ts.html +1 -1
- package/coverage/src/classify/index.html +1 -1
- package/coverage/src/cluster-detector.ts.html +72 -72
- package/coverage/src/defaults.ts.html +1 -1
- package/coverage/src/graph-builder.ts.html +131 -131
- package/coverage/src/index.html +101 -116
- package/coverage/src/index.ts.html +2 -2
- package/coverage/src/issue-analyzer.ts.html +32 -83
- package/coverage/src/mapper.ts.html +20 -2
- package/coverage/src/metrics.ts.html +127 -130
- package/coverage/src/orchestrator.ts.html +13 -13
- package/coverage/src/provider.ts.html +19 -19
- package/coverage/src/remediation.ts.html +59 -59
- package/coverage/src/report/console-report.ts.html +2 -2
- package/coverage/src/report/html-report.ts.html +60 -84
- package/coverage/src/report/index.html +7 -7
- package/coverage/src/report/interactive-setup.ts.html +1 -1
- package/coverage/src/scoring.ts.html +62 -62
- package/coverage/src/semantic/co-usage.ts.html +1 -1
- package/coverage/src/semantic/consolidation.ts.html +1 -1
- package/coverage/src/semantic/domain-inference.ts.html +1 -1
- package/coverage/src/semantic/index.html +1 -1
- package/coverage/src/semantic/type-graph.ts.html +1 -1
- package/coverage/src/summary.ts.html +67 -67
- package/coverage/src/types.ts.html +1 -1
- package/coverage/src/utils/dependency-graph-utils.ts.html +41 -41
- package/coverage/src/utils/index.html +21 -21
- package/coverage/src/utils/string-utils.ts.html +1 -1
- package/dist/chunk-22ZO4EKZ.mjs +1297 -0
- package/dist/chunk-4U4LDWGF.mjs +360 -0
- package/dist/chunk-BA7QGUHN.mjs +1722 -0
- package/dist/chunk-BCEZGRXI.mjs +1297 -0
- package/dist/chunk-BQCISA2F.mjs +91 -0
- package/dist/chunk-EMYD7NS6.mjs +137 -0
- package/dist/chunk-EWFR366Y.mjs +1740 -0
- package/dist/chunk-FO6YT6RG.mjs +1751 -0
- package/dist/chunk-J3SZQZNU.mjs +221 -0
- package/dist/chunk-OZE3FVZT.mjs +1089 -0
- package/dist/chunk-WHB7QI7N.mjs +91 -0
- package/dist/cli-action-CXIHOVAC.mjs +95 -0
- package/dist/cli-action-SA7SCYNV.mjs +95 -0
- package/dist/cli-action-YAJOJCXJ.mjs +95 -0
- package/dist/cli.js +688 -566
- package/dist/cli.mjs +4 -88
- package/dist/index.js +889 -773
- package/dist/index.mjs +21 -14
- package/dist/orchestrator-3L3NAZYP.mjs +10 -0
- package/dist/orchestrator-MONOZHVW.mjs +10 -0
- package/dist/orchestrator-ZR7JSKWI.mjs +10 -0
- package/dist/summary-7PZVW72O.mjs +7 -0
- package/dist/summary-LKUCJAIS.mjs +7 -0
- package/package.json +2 -2
- package/src/__tests__/analyzer.test.ts +1 -1
- package/src/__tests__/enhanced-cohesion.test.ts +4 -1
- package/src/__tests__/orchestrator.test.ts +19 -4
- package/src/__tests__/python-context.test.ts +6 -0
- package/src/__tests__/report/html-report.test.ts +8 -2
- package/src/ast-utils.ts +1 -26
- package/src/cli-definition.ts +4 -2
- package/src/issue-analyzer.ts +4 -19
- package/src/metrics.ts +1 -2
- package/src/provider.ts +4 -4
- package/src/report/html-report.ts +43 -59
- package/coverage/dist/chunk-64U3PNO3.mjs.html +0 -367
- package/coverage/dist/chunk-J3MUOWHC.mjs.html +0 -5326
- package/coverage/dist/index.html +0 -146
- package/coverage/dist/index.mjs.html +0 -1396
- package/coverage/src/analyzer.ts.html +0 -88
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// src/report/console-report.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
function displayConsoleReport(summary, results, maxResults = 10) {
|
|
4
|
+
const divider = "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
|
|
5
|
+
const totalIssues = summary.criticalIssues + summary.majorIssues + summary.minorIssues;
|
|
6
|
+
console.log(chalk.bold("\u{1F4CA} Context Analysis Summary:\n"));
|
|
7
|
+
console.log(` \u2022 Total Files: ${chalk.cyan(summary.totalFiles)}`);
|
|
8
|
+
console.log(
|
|
9
|
+
` \u2022 Total Tokens: ${chalk.cyan(summary.totalTokens.toLocaleString())}`
|
|
10
|
+
);
|
|
11
|
+
console.log(
|
|
12
|
+
` \u2022 Avg Budget: ${chalk.cyan(summary.avgContextBudget.toFixed(0))} tokens`
|
|
13
|
+
);
|
|
14
|
+
console.log(
|
|
15
|
+
` \u2022 Potential Saving: ${chalk.green(summary.totalPotentialSavings.toLocaleString())} tokens`
|
|
16
|
+
);
|
|
17
|
+
console.log();
|
|
18
|
+
if (totalIssues > 0) {
|
|
19
|
+
console.log(chalk.bold("\u26A0\uFE0F Issues Detected:\n"));
|
|
20
|
+
console.log(` \u2022 ${chalk.red("\u{1F534} Critical:")} ${summary.criticalIssues}`);
|
|
21
|
+
console.log(` \u2022 ${chalk.yellow("\u{1F7E1} Major:")} ${summary.majorIssues}`);
|
|
22
|
+
console.log(` \u2022 ${chalk.blue("\u{1F535} Minor:")} ${summary.minorIssues}`);
|
|
23
|
+
console.log();
|
|
24
|
+
} else {
|
|
25
|
+
console.log(chalk.green("\u2705 No significant context issues detected!\n"));
|
|
26
|
+
}
|
|
27
|
+
if (summary.fragmentedModules.length > 0) {
|
|
28
|
+
console.log(chalk.bold("\u{1F9E9} Top Fragmented Modules:\n"));
|
|
29
|
+
summary.fragmentedModules.slice(0, maxResults).forEach((mod) => {
|
|
30
|
+
const scoreColor = mod.fragmentationScore > 0.7 ? chalk.red : mod.fragmentationScore > 0.4 ? chalk.yellow : chalk.green;
|
|
31
|
+
console.log(
|
|
32
|
+
` ${scoreColor("\u25A0")} ${chalk.white(mod.domain)} ${chalk.dim(`(${mod.files.length} files, ${(mod.fragmentationScore * 100).toFixed(0)}% frag)`)}`
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
console.log();
|
|
36
|
+
}
|
|
37
|
+
if (summary.topExpensiveFiles.length > 0) {
|
|
38
|
+
console.log(chalk.bold("\u{1F4B8} Most Expensive Files (Context Budget):\n"));
|
|
39
|
+
summary.topExpensiveFiles.slice(0, maxResults).forEach((item) => {
|
|
40
|
+
const fileName = item.file.split("/").slice(-2).join("/");
|
|
41
|
+
const severityColor = item.severity === "critical" ? chalk.red : item.severity === "major" ? chalk.yellow : chalk.blue;
|
|
42
|
+
console.log(
|
|
43
|
+
` ${severityColor("\u25CF")} ${chalk.white(fileName)} ${chalk.dim(`- ${item.contextBudget.toLocaleString()} tokens`)}`
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
console.log();
|
|
47
|
+
}
|
|
48
|
+
if (totalIssues > 0) {
|
|
49
|
+
console.log(chalk.bold("\u{1F4A1} Top Recommendations:\n"));
|
|
50
|
+
const topFiles = results.filter((r) => r.severity === "critical" || r.severity === "major").slice(0, 3);
|
|
51
|
+
topFiles.forEach((result, index) => {
|
|
52
|
+
const fileName = result.file.split("/").slice(-2).join("/");
|
|
53
|
+
console.log(chalk.cyan(` ${index + 1}. ${fileName}`));
|
|
54
|
+
result.recommendations.slice(0, 2).forEach((rec) => {
|
|
55
|
+
console.log(chalk.dim(` \u2022 ${rec}`));
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
console.log();
|
|
59
|
+
}
|
|
60
|
+
console.log(chalk.cyan(divider));
|
|
61
|
+
console.log(
|
|
62
|
+
chalk.dim(
|
|
63
|
+
"\n\u2B50 Like aiready? Star us on GitHub: https://github.com/caopengau/aiready-context-analyzer"
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
console.log(
|
|
67
|
+
chalk.dim(
|
|
68
|
+
"\u{1F41B} Found a bug? Report it: https://github.com/caopengau/aiready-context-analyzer/issues\n"
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/report/html-report.ts
|
|
74
|
+
import {
|
|
75
|
+
generateIssueSummary,
|
|
76
|
+
generateTable,
|
|
77
|
+
generateStandardHtmlReport
|
|
78
|
+
} from "@aiready/core";
|
|
79
|
+
function generateHTMLReport(summary, results) {
|
|
80
|
+
const totalIssues = summary.criticalIssues + summary.majorIssues + summary.minorIssues;
|
|
81
|
+
void results;
|
|
82
|
+
const stats = [
|
|
83
|
+
{ value: summary.totalFiles, label: "Files Analyzed" },
|
|
84
|
+
{ value: summary.totalTokens.toLocaleString(), label: "Total Tokens" },
|
|
85
|
+
{ value: summary.avgContextBudget.toFixed(0), label: "Avg Context Budget" },
|
|
86
|
+
{
|
|
87
|
+
value: totalIssues,
|
|
88
|
+
label: "Total Issues",
|
|
89
|
+
color: totalIssues > 0 ? "#f39c12" : void 0
|
|
90
|
+
}
|
|
91
|
+
];
|
|
92
|
+
const sections = [];
|
|
93
|
+
if (totalIssues > 0) {
|
|
94
|
+
sections.push({
|
|
95
|
+
title: "\u26A0\uFE0F Issues Summary",
|
|
96
|
+
content: generateIssueSummary(
|
|
97
|
+
summary.criticalIssues,
|
|
98
|
+
summary.majorIssues,
|
|
99
|
+
summary.minorIssues,
|
|
100
|
+
summary.totalPotentialSavings
|
|
101
|
+
)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (summary.fragmentedModules.length > 0) {
|
|
105
|
+
sections.push({
|
|
106
|
+
title: "\u{1F9E9} Fragmented Modules",
|
|
107
|
+
content: generateTable({
|
|
108
|
+
headers: ["Domain", "Files", "Fragmentation", "Token Cost"],
|
|
109
|
+
rows: summary.fragmentedModules.map((m) => [
|
|
110
|
+
m.domain,
|
|
111
|
+
String(m.files.length),
|
|
112
|
+
`${(m.fragmentationScore * 100).toFixed(0)}%`,
|
|
113
|
+
m.totalTokens.toLocaleString()
|
|
114
|
+
])
|
|
115
|
+
})
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (summary.topExpensiveFiles.length > 0) {
|
|
119
|
+
sections.push({
|
|
120
|
+
title: "\u{1F4B8} Most Expensive Files",
|
|
121
|
+
content: generateTable({
|
|
122
|
+
headers: ["File", "Context Budget", "Severity"],
|
|
123
|
+
rows: summary.topExpensiveFiles.map((f) => [
|
|
124
|
+
f.file,
|
|
125
|
+
`${f.contextBudget.toLocaleString()} tokens`,
|
|
126
|
+
`<span class="issue-${f.severity}">${f.severity.toUpperCase()}</span>`
|
|
127
|
+
])
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return generateStandardHtmlReport(
|
|
132
|
+
{
|
|
133
|
+
title: "Context Analysis Report",
|
|
134
|
+
packageName: "context-analyzer",
|
|
135
|
+
packageUrl: "https://github.com/caopengau/aiready-context-analyzer",
|
|
136
|
+
bugUrl: "https://github.com/caopengau/aiready-context-analyzer/issues",
|
|
137
|
+
emoji: "\u{1F9E0}"
|
|
138
|
+
},
|
|
139
|
+
stats,
|
|
140
|
+
sections
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/report/interactive-setup.ts
|
|
145
|
+
import chalk2 from "chalk";
|
|
146
|
+
import { existsSync, readFileSync } from "fs";
|
|
147
|
+
import { join } from "path";
|
|
148
|
+
import prompts from "prompts";
|
|
149
|
+
async function runInteractiveSetup(directory, current) {
|
|
150
|
+
console.log(chalk2.yellow("\u{1F9ED} Interactive mode: let's tailor the analysis."));
|
|
151
|
+
const pkgPath = join(directory, "package.json");
|
|
152
|
+
let deps = {};
|
|
153
|
+
if (existsSync(pkgPath)) {
|
|
154
|
+
try {
|
|
155
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
156
|
+
deps = { ...pkg.dependencies || {}, ...pkg.devDependencies || {} };
|
|
157
|
+
} catch (e) {
|
|
158
|
+
void e;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const hasNextJs = existsSync(join(directory, ".next")) || !!deps["next"];
|
|
162
|
+
const hasCDK = existsSync(join(directory, "cdk.out")) || !!deps["aws-cdk-lib"] || Object.keys(deps).some((d) => d.startsWith("@aws-cdk/"));
|
|
163
|
+
const recommendedExcludes = new Set(current.exclude || []);
|
|
164
|
+
if (hasNextJs && !Array.from(recommendedExcludes).some((p) => p.includes(".next"))) {
|
|
165
|
+
recommendedExcludes.add("**/.next/**");
|
|
166
|
+
}
|
|
167
|
+
if (hasCDK && !Array.from(recommendedExcludes).some((p) => p.includes("cdk.out"))) {
|
|
168
|
+
recommendedExcludes.add("**/cdk.out/**");
|
|
169
|
+
}
|
|
170
|
+
const { applyExcludes } = await prompts({
|
|
171
|
+
type: "toggle",
|
|
172
|
+
name: "applyExcludes",
|
|
173
|
+
message: `Detected ${hasNextJs ? "Next.js " : ""}${hasCDK ? "AWS CDK " : ""}frameworks. Apply recommended excludes?`,
|
|
174
|
+
initial: true,
|
|
175
|
+
active: "yes",
|
|
176
|
+
inactive: "no"
|
|
177
|
+
});
|
|
178
|
+
const nextOptions = { ...current };
|
|
179
|
+
if (applyExcludes) {
|
|
180
|
+
nextOptions.exclude = Array.from(recommendedExcludes);
|
|
181
|
+
}
|
|
182
|
+
const { focusArea } = await prompts({
|
|
183
|
+
type: "select",
|
|
184
|
+
name: "focusArea",
|
|
185
|
+
message: "Which areas to focus?",
|
|
186
|
+
choices: [
|
|
187
|
+
{ title: "Frontend (web app)", value: "frontend" },
|
|
188
|
+
{ title: "Backend (API/infra)", value: "backend" },
|
|
189
|
+
{ title: "Both", value: "both" }
|
|
190
|
+
],
|
|
191
|
+
initial: 2
|
|
192
|
+
});
|
|
193
|
+
if (focusArea === "frontend") {
|
|
194
|
+
nextOptions.include = ["**/*.{ts,tsx,js,jsx}"];
|
|
195
|
+
nextOptions.exclude = Array.from(
|
|
196
|
+
/* @__PURE__ */ new Set([
|
|
197
|
+
...nextOptions.exclude || [],
|
|
198
|
+
"**/cdk.out/**",
|
|
199
|
+
"**/infra/**",
|
|
200
|
+
"**/server/**",
|
|
201
|
+
"**/backend/**"
|
|
202
|
+
])
|
|
203
|
+
);
|
|
204
|
+
} else if (focusArea === "backend") {
|
|
205
|
+
nextOptions.include = [
|
|
206
|
+
"**/api/**",
|
|
207
|
+
"**/server/**",
|
|
208
|
+
"**/backend/**",
|
|
209
|
+
"**/infra/**",
|
|
210
|
+
"**/*.{ts,js,py,java}"
|
|
211
|
+
];
|
|
212
|
+
}
|
|
213
|
+
console.log(chalk2.green("\u2713 Interactive configuration applied."));
|
|
214
|
+
return nextOptions;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export {
|
|
218
|
+
displayConsoleReport,
|
|
219
|
+
generateHTMLReport,
|
|
220
|
+
runInteractiveSetup
|
|
221
|
+
};
|