@aiready/cli 0.10.3 → 0.10.4
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 +7 -7
- package/.turbo/turbo-test.log +3 -3
- package/dist/chunk-R3O7QPKD.mjs +419 -0
- package/dist/cli.js +97 -25
- package/dist/cli.mjs +88 -16
- package/dist/index.js +13 -11
- package/dist/index.mjs +1 -1
- package/package.json +12 -12
- package/src/.aiready/aiready-report-20260306-191804.json +8281 -0
- package/src/.aiready/aiready-report-20260306-191824.json +8281 -0
- package/src/.aiready/aiready-report-20260306-191838.json +8281 -0
- package/src/.aiready/aiready-report-20260306-192002.json +15942 -0
- package/src/.aiready/aiready-report-20260306-192102.json +15048 -0
- package/src/.aiready/aiready-report-20260306-202328.json +19961 -0
- package/src/commands/scan.ts +124 -14
- package/src/index.ts +27 -13
package/.turbo/turbo-build.log
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
|
|
13
|
-
[
|
|
13
|
+
[43m[30m WARN [39m[49m [33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1m"import.meta" is not available with the "cjs" output format and will be empty[0m [empty-import-meta] [90m8:22:49 pm[39m
|
|
14
14
|
|
|
15
15
|
src/cli.ts:25:31:
|
|
16
16
|
[37m 25 │ return dirname(fileURLToPath([32mimport.meta[37m.url));
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
[32mCJS[39m [1mdist/cli.js [22m[
|
|
24
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
25
|
-
[32mCJS[39m ⚡️ Build success in
|
|
23
|
+
[32mCJS[39m [1mdist/cli.js [22m[32m93.97 KB[39m
|
|
24
|
+
[32mCJS[39m [1mdist/index.js [22m[32m15.13 KB[39m
|
|
25
|
+
[32mCJS[39m ⚡️ Build success in 29ms
|
|
26
26
|
[32mESM[39m [1mdist/index.mjs [22m[32m170.00 B[39m
|
|
27
|
-
[32mESM[39m [1mdist/
|
|
28
|
-
[32mESM[39m [1mdist/
|
|
29
|
-
[32mESM[39m ⚡️ Build success in
|
|
27
|
+
[32mESM[39m [1mdist/cli.mjs [22m[32m77.08 KB[39m
|
|
28
|
+
[32mESM[39m [1mdist/chunk-R3O7QPKD.mjs [22m[32m13.73 KB[39m
|
|
29
|
+
[32mESM[39m ⚡️ Build success in 29ms
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @aiready/cli@0.10.
|
|
3
|
+
> @aiready/cli@0.10.3 test /Users/pengcao/projects/aiready/packages/cli
|
|
4
4
|
> vitest run
|
|
5
5
|
|
|
6
6
|
[?25l
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
12
12
|
[2m Tests [22m [1m[32m3 passed[39m[22m[90m (3)[39m
|
|
13
|
-
[2m Start at [22m
|
|
14
|
-
[2m Duration [22m
|
|
13
|
+
[2m Start at [22m 20:23:07
|
|
14
|
+
[2m Duration [22m 426ms[2m (transform 97ms, setup 0ms, import 295ms, tests 2ms, environment 0ms)[22m
|
|
15
15
|
|
|
16
16
|
[?25h
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
// src/index.ts
|
|
9
|
+
import { analyzePatterns } from "@aiready/pattern-detect";
|
|
10
|
+
import { analyzeContext } from "@aiready/context-analyzer";
|
|
11
|
+
import { analyzeConsistency } from "@aiready/consistency";
|
|
12
|
+
import {
|
|
13
|
+
calculateOverallScore,
|
|
14
|
+
calculateTokenBudget
|
|
15
|
+
} from "@aiready/core";
|
|
16
|
+
var severityOrder = {
|
|
17
|
+
critical: 4,
|
|
18
|
+
major: 3,
|
|
19
|
+
minor: 2,
|
|
20
|
+
info: 1
|
|
21
|
+
};
|
|
22
|
+
function sortBySeverity(results) {
|
|
23
|
+
return results.map((file) => {
|
|
24
|
+
const sortedIssues = [...file.issues].sort((a, b) => {
|
|
25
|
+
const severityDiff = (severityOrder[b.severity] || 0) - (severityOrder[a.severity] || 0);
|
|
26
|
+
if (severityDiff !== 0) return severityDiff;
|
|
27
|
+
return (a.location?.line || 0) - (b.location?.line || 0);
|
|
28
|
+
});
|
|
29
|
+
return { ...file, issues: sortedIssues };
|
|
30
|
+
}).sort((a, b) => {
|
|
31
|
+
const aMaxSeverity = Math.max(
|
|
32
|
+
...a.issues.map((i) => severityOrder[i.severity] || 0),
|
|
33
|
+
0
|
|
34
|
+
);
|
|
35
|
+
const bMaxSeverity = Math.max(
|
|
36
|
+
...b.issues.map((i) => severityOrder[i.severity] || 0),
|
|
37
|
+
0
|
|
38
|
+
);
|
|
39
|
+
if (aMaxSeverity !== bMaxSeverity) {
|
|
40
|
+
return bMaxSeverity - aMaxSeverity;
|
|
41
|
+
}
|
|
42
|
+
if (a.issues.length !== b.issues.length) {
|
|
43
|
+
return b.issues.length - a.issues.length;
|
|
44
|
+
}
|
|
45
|
+
return a.fileName.localeCompare(b.fileName);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async function analyzeUnified(options) {
|
|
49
|
+
const startTime = Date.now();
|
|
50
|
+
const tools = options.tools || ["patterns", "context", "consistency"];
|
|
51
|
+
const result = {
|
|
52
|
+
summary: {
|
|
53
|
+
totalIssues: 0,
|
|
54
|
+
toolsRun: tools,
|
|
55
|
+
executionTime: 0
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
if (tools.includes("patterns")) {
|
|
59
|
+
const patternResult = await analyzePatterns(options);
|
|
60
|
+
if (options.progressCallback) {
|
|
61
|
+
options.progressCallback({ tool: "patterns", data: patternResult });
|
|
62
|
+
}
|
|
63
|
+
result.patternDetect = {
|
|
64
|
+
results: sortBySeverity(patternResult.results),
|
|
65
|
+
summary: patternResult.summary || {},
|
|
66
|
+
duplicates: patternResult.duplicates || []
|
|
67
|
+
};
|
|
68
|
+
result.summary.totalIssues += patternResult.results.reduce(
|
|
69
|
+
(sum, file) => sum + file.issues.length,
|
|
70
|
+
0
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
if (tools.includes("context")) {
|
|
74
|
+
const contextResults = await analyzeContext(options);
|
|
75
|
+
if (options.progressCallback) {
|
|
76
|
+
options.progressCallback({ tool: "context", data: contextResults });
|
|
77
|
+
}
|
|
78
|
+
const sorted = contextResults.sort((a, b) => {
|
|
79
|
+
const severityDiff = (severityOrder[b.severity] || 0) - (severityOrder[a.severity] || 0);
|
|
80
|
+
if (severityDiff !== 0) return severityDiff;
|
|
81
|
+
if (a.tokenCost !== b.tokenCost) return b.tokenCost - a.tokenCost;
|
|
82
|
+
return b.fragmentationScore - a.fragmentationScore;
|
|
83
|
+
});
|
|
84
|
+
const { generateSummary: genContextSummary } = await import("@aiready/context-analyzer");
|
|
85
|
+
result.contextAnalyzer = {
|
|
86
|
+
results: sorted,
|
|
87
|
+
summary: genContextSummary(sorted)
|
|
88
|
+
};
|
|
89
|
+
result.summary.totalIssues += sorted.length;
|
|
90
|
+
}
|
|
91
|
+
if (tools.includes("consistency")) {
|
|
92
|
+
const consistencyOptions = {
|
|
93
|
+
rootDir: options.rootDir,
|
|
94
|
+
include: options.include,
|
|
95
|
+
exclude: options.exclude,
|
|
96
|
+
...options.consistency || {}
|
|
97
|
+
};
|
|
98
|
+
const report = await analyzeConsistency(consistencyOptions);
|
|
99
|
+
if (options.progressCallback) {
|
|
100
|
+
options.progressCallback({ tool: "consistency", data: report });
|
|
101
|
+
}
|
|
102
|
+
result.consistency = {
|
|
103
|
+
results: report.results ? sortBySeverity(report.results) : [],
|
|
104
|
+
summary: report.summary
|
|
105
|
+
};
|
|
106
|
+
result.summary.totalIssues += report.summary.totalIssues;
|
|
107
|
+
}
|
|
108
|
+
if (tools.includes("doc-drift")) {
|
|
109
|
+
const { analyzeDocDrift } = await import("@aiready/doc-drift");
|
|
110
|
+
const report = await analyzeDocDrift({
|
|
111
|
+
rootDir: options.rootDir,
|
|
112
|
+
include: options.include,
|
|
113
|
+
exclude: options.exclude,
|
|
114
|
+
onProgress: options.onProgress
|
|
115
|
+
});
|
|
116
|
+
if (options.progressCallback) {
|
|
117
|
+
options.progressCallback({ tool: "doc-drift", data: report });
|
|
118
|
+
}
|
|
119
|
+
result.docDrift = {
|
|
120
|
+
results: report.results || report.issues || [],
|
|
121
|
+
summary: report.summary || {}
|
|
122
|
+
};
|
|
123
|
+
const issueCount = report.issues?.length || (report.results ? report.results.length : 0);
|
|
124
|
+
result.summary.totalIssues += issueCount;
|
|
125
|
+
}
|
|
126
|
+
if (tools.includes("deps-health")) {
|
|
127
|
+
const { analyzeDeps } = await import("@aiready/deps");
|
|
128
|
+
const report = await analyzeDeps({
|
|
129
|
+
rootDir: options.rootDir,
|
|
130
|
+
include: options.include,
|
|
131
|
+
exclude: options.exclude,
|
|
132
|
+
onProgress: options.onProgress
|
|
133
|
+
});
|
|
134
|
+
if (options.progressCallback) {
|
|
135
|
+
options.progressCallback({ tool: "deps-health", data: report });
|
|
136
|
+
}
|
|
137
|
+
result.dependencyHealth = {
|
|
138
|
+
results: report.results || report.issues || [],
|
|
139
|
+
summary: report.summary || {}
|
|
140
|
+
};
|
|
141
|
+
const issueCount = report.issues?.length || (report.results ? report.results.length : 0);
|
|
142
|
+
result.summary.totalIssues += issueCount;
|
|
143
|
+
}
|
|
144
|
+
if (tools.includes("ai-signal-clarity")) {
|
|
145
|
+
const { analyzeAiSignalClarity } = await import("@aiready/ai-signal-clarity");
|
|
146
|
+
const report = await analyzeAiSignalClarity({
|
|
147
|
+
rootDir: options.rootDir,
|
|
148
|
+
include: options.include,
|
|
149
|
+
exclude: options.exclude,
|
|
150
|
+
onProgress: options.onProgress
|
|
151
|
+
});
|
|
152
|
+
if (options.progressCallback) {
|
|
153
|
+
options.progressCallback({ tool: "ai-signal-clarity", data: report });
|
|
154
|
+
}
|
|
155
|
+
result.aiSignalClarity = {
|
|
156
|
+
...report,
|
|
157
|
+
results: report.results || report.issues || [],
|
|
158
|
+
summary: report.summary || {}
|
|
159
|
+
};
|
|
160
|
+
result.summary.totalIssues += (report.results || report.issues)?.reduce(
|
|
161
|
+
(sum, r) => sum + (r.issues?.length || 1),
|
|
162
|
+
0
|
|
163
|
+
) || 0;
|
|
164
|
+
}
|
|
165
|
+
if (tools.includes("agent-grounding")) {
|
|
166
|
+
const { analyzeAgentGrounding } = await import("@aiready/agent-grounding");
|
|
167
|
+
const report = await analyzeAgentGrounding({
|
|
168
|
+
rootDir: options.rootDir,
|
|
169
|
+
include: options.include,
|
|
170
|
+
exclude: options.exclude,
|
|
171
|
+
onProgress: options.onProgress
|
|
172
|
+
});
|
|
173
|
+
if (options.progressCallback) {
|
|
174
|
+
options.progressCallback({ tool: "agent-grounding", data: report });
|
|
175
|
+
}
|
|
176
|
+
result.agentGrounding = {
|
|
177
|
+
...report,
|
|
178
|
+
results: report.results || report.issues || [],
|
|
179
|
+
summary: report.summary || {}
|
|
180
|
+
};
|
|
181
|
+
result.summary.totalIssues += (report.issues || report.results || []).length;
|
|
182
|
+
}
|
|
183
|
+
if (tools.includes("testability")) {
|
|
184
|
+
const { analyzeTestability } = await import("@aiready/testability");
|
|
185
|
+
const report = await analyzeTestability({
|
|
186
|
+
rootDir: options.rootDir,
|
|
187
|
+
include: options.include,
|
|
188
|
+
exclude: options.exclude,
|
|
189
|
+
onProgress: options.onProgress
|
|
190
|
+
});
|
|
191
|
+
if (options.progressCallback) {
|
|
192
|
+
options.progressCallback({ tool: "testability", data: report });
|
|
193
|
+
}
|
|
194
|
+
result.testability = {
|
|
195
|
+
...report,
|
|
196
|
+
results: report.results || report.issues || [],
|
|
197
|
+
summary: report.summary || {}
|
|
198
|
+
};
|
|
199
|
+
result.summary.totalIssues += (report.issues || report.results || []).length;
|
|
200
|
+
}
|
|
201
|
+
if (tools.includes("change-amplification")) {
|
|
202
|
+
const { analyzeChangeAmplification } = await import("@aiready/change-amplification");
|
|
203
|
+
const report = await analyzeChangeAmplification({
|
|
204
|
+
rootDir: options.rootDir,
|
|
205
|
+
include: options.include,
|
|
206
|
+
exclude: options.exclude,
|
|
207
|
+
onProgress: options.onProgress
|
|
208
|
+
});
|
|
209
|
+
if (options.progressCallback) {
|
|
210
|
+
options.progressCallback({ tool: "change-amplification", data: report });
|
|
211
|
+
}
|
|
212
|
+
result.changeAmplification = {
|
|
213
|
+
results: report.results || [],
|
|
214
|
+
summary: report.summary || {}
|
|
215
|
+
};
|
|
216
|
+
result.summary.totalIssues += report.summary?.totalIssues || 0;
|
|
217
|
+
}
|
|
218
|
+
result.summary.executionTime = Date.now() - startTime;
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
async function scoreUnified(results, options) {
|
|
222
|
+
const toolScores = /* @__PURE__ */ new Map();
|
|
223
|
+
if (results.patternDetect) {
|
|
224
|
+
const { calculatePatternScore } = await import("@aiready/pattern-detect");
|
|
225
|
+
try {
|
|
226
|
+
const patternScore = calculatePatternScore(
|
|
227
|
+
results.patternDetect.duplicates,
|
|
228
|
+
results.patternDetect.results?.length || 0
|
|
229
|
+
);
|
|
230
|
+
const wastedTokens = results.patternDetect.duplicates.reduce(
|
|
231
|
+
(sum, d) => sum + (d.tokenCost || 0),
|
|
232
|
+
0
|
|
233
|
+
);
|
|
234
|
+
patternScore.tokenBudget = calculateTokenBudget({
|
|
235
|
+
totalContextTokens: wastedTokens * 2,
|
|
236
|
+
// Estimated context
|
|
237
|
+
wastedTokens: {
|
|
238
|
+
duplication: wastedTokens,
|
|
239
|
+
fragmentation: 0,
|
|
240
|
+
chattiness: 0
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
toolScores.set("pattern-detect", patternScore);
|
|
244
|
+
} catch (err) {
|
|
245
|
+
void err;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (results.contextAnalyzer) {
|
|
249
|
+
const { calculateContextScore } = await import("@aiready/context-analyzer");
|
|
250
|
+
try {
|
|
251
|
+
const ctxSummary = results.contextAnalyzer.summary;
|
|
252
|
+
const contextScore = calculateContextScore(ctxSummary);
|
|
253
|
+
contextScore.tokenBudget = calculateTokenBudget({
|
|
254
|
+
totalContextTokens: ctxSummary.totalTokens,
|
|
255
|
+
wastedTokens: {
|
|
256
|
+
duplication: 0,
|
|
257
|
+
fragmentation: ctxSummary.totalPotentialSavings || 0,
|
|
258
|
+
chattiness: 0
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
toolScores.set("context-analyzer", contextScore);
|
|
262
|
+
} catch (err) {
|
|
263
|
+
void err;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (results.consistency) {
|
|
267
|
+
const { calculateConsistencyScore } = await import("@aiready/consistency");
|
|
268
|
+
try {
|
|
269
|
+
const issues = results.consistency.results?.flatMap((r) => r.issues) || [];
|
|
270
|
+
const totalFiles = results.consistency.summary?.filesAnalyzed || 0;
|
|
271
|
+
const consistencyScore = calculateConsistencyScore(issues, totalFiles);
|
|
272
|
+
toolScores.set("consistency", consistencyScore);
|
|
273
|
+
} catch (err) {
|
|
274
|
+
void err;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (results.aiSignalClarity) {
|
|
278
|
+
const { calculateAiSignalClarityScore } = await import("@aiready/ai-signal-clarity");
|
|
279
|
+
try {
|
|
280
|
+
const hrScore = calculateAiSignalClarityScore(results.aiSignalClarity);
|
|
281
|
+
toolScores.set("ai-signal-clarity", hrScore);
|
|
282
|
+
} catch (err) {
|
|
283
|
+
void err;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (results.agentGrounding) {
|
|
287
|
+
const { calculateGroundingScore } = await import("@aiready/agent-grounding");
|
|
288
|
+
try {
|
|
289
|
+
const agScore = calculateGroundingScore(results.agentGrounding);
|
|
290
|
+
toolScores.set("agent-grounding", agScore);
|
|
291
|
+
} catch (err) {
|
|
292
|
+
void err;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (results.testability) {
|
|
296
|
+
const { calculateTestabilityScore } = await import("@aiready/testability");
|
|
297
|
+
try {
|
|
298
|
+
const tbScore = calculateTestabilityScore(results.testability);
|
|
299
|
+
toolScores.set("testability", tbScore);
|
|
300
|
+
} catch (err) {
|
|
301
|
+
void err;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (results.docDrift) {
|
|
305
|
+
toolScores.set("doc-drift", {
|
|
306
|
+
toolName: "doc-drift",
|
|
307
|
+
score: results.docDrift.summary.score || results.docDrift.summary.totalScore || 0,
|
|
308
|
+
rawMetrics: results.docDrift.summary,
|
|
309
|
+
factors: [],
|
|
310
|
+
recommendations: (results.docDrift.summary.recommendations || []).map(
|
|
311
|
+
(action) => ({
|
|
312
|
+
action,
|
|
313
|
+
estimatedImpact: 5,
|
|
314
|
+
priority: "medium"
|
|
315
|
+
})
|
|
316
|
+
)
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
if (results.dependencyHealth) {
|
|
320
|
+
toolScores.set("dependency-health", {
|
|
321
|
+
toolName: "dependency-health",
|
|
322
|
+
score: results.dependencyHealth.summary.score || 0,
|
|
323
|
+
rawMetrics: results.dependencyHealth.summary,
|
|
324
|
+
factors: [],
|
|
325
|
+
recommendations: (results.dependencyHealth.summary.recommendations || []).map((action) => ({
|
|
326
|
+
action,
|
|
327
|
+
estimatedImpact: 5,
|
|
328
|
+
priority: "medium"
|
|
329
|
+
}))
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
if (results.changeAmplification) {
|
|
333
|
+
toolScores.set("change-amplification", {
|
|
334
|
+
toolName: "change-amplification",
|
|
335
|
+
score: results.changeAmplification.summary.score || 0,
|
|
336
|
+
rawMetrics: results.changeAmplification.summary,
|
|
337
|
+
factors: [],
|
|
338
|
+
recommendations: (results.changeAmplification.summary.recommendations || []).map((action) => ({
|
|
339
|
+
action,
|
|
340
|
+
estimatedImpact: 5,
|
|
341
|
+
priority: "medium"
|
|
342
|
+
}))
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
if (toolScores.size === 0) {
|
|
346
|
+
return {
|
|
347
|
+
overall: 0,
|
|
348
|
+
rating: "Critical",
|
|
349
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
350
|
+
toolsUsed: [],
|
|
351
|
+
breakdown: [],
|
|
352
|
+
calculation: {
|
|
353
|
+
formula: "0 / 0 = 0",
|
|
354
|
+
weights: {},
|
|
355
|
+
normalized: "0 / 0 = 0"
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
return calculateOverallScore(toolScores, options, void 0);
|
|
360
|
+
}
|
|
361
|
+
function generateUnifiedSummary(result) {
|
|
362
|
+
const { summary } = result;
|
|
363
|
+
let output = `\u{1F680} AIReady Analysis Complete
|
|
364
|
+
|
|
365
|
+
`;
|
|
366
|
+
output += `\u{1F4CA} Summary:
|
|
367
|
+
`;
|
|
368
|
+
output += ` Tools run: ${summary.toolsRun.join(", ")}
|
|
369
|
+
`;
|
|
370
|
+
output += ` Total issues found: ${summary.totalIssues}
|
|
371
|
+
`;
|
|
372
|
+
output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
|
|
373
|
+
|
|
374
|
+
`;
|
|
375
|
+
if (result.patternDetect) {
|
|
376
|
+
output += `\u{1F50D} Pattern Analysis: ${result.patternDetect.results.length} issues
|
|
377
|
+
`;
|
|
378
|
+
}
|
|
379
|
+
if (result.contextAnalyzer) {
|
|
380
|
+
output += `\u{1F9E0} Context Analysis: ${result.contextAnalyzer.results.length} issues
|
|
381
|
+
`;
|
|
382
|
+
}
|
|
383
|
+
if (result.consistency) {
|
|
384
|
+
output += `\u{1F3F7}\uFE0F Consistency Analysis: ${result.consistency.summary.totalIssues} issues
|
|
385
|
+
`;
|
|
386
|
+
}
|
|
387
|
+
if (result.docDrift) {
|
|
388
|
+
output += `\u{1F4DD} Doc Drift Analysis: ${result.docDrift.results?.length || 0} issues
|
|
389
|
+
`;
|
|
390
|
+
}
|
|
391
|
+
if (result.dependencyHealth) {
|
|
392
|
+
output += `\u{1F4E6} Dependency Health: ${result.dependencyHealth.results?.length || 0} issues
|
|
393
|
+
`;
|
|
394
|
+
}
|
|
395
|
+
if (result.aiSignalClarity) {
|
|
396
|
+
output += `\u{1F9E0} AI Signal Clarity: ${result.aiSignalClarity.summary?.totalSignals || 0} signals
|
|
397
|
+
`;
|
|
398
|
+
}
|
|
399
|
+
if (result.agentGrounding) {
|
|
400
|
+
output += `\u{1F9ED} Agent Grounding: ${result.agentGrounding.results?.length || 0} issues
|
|
401
|
+
`;
|
|
402
|
+
}
|
|
403
|
+
if (result.testability) {
|
|
404
|
+
output += `\u{1F9EA} Testability Index: ${result.testability.results?.length || 0} issues
|
|
405
|
+
`;
|
|
406
|
+
}
|
|
407
|
+
if (result.changeAmplification) {
|
|
408
|
+
output += `\u{1F4A5} Change Amplification: ${result.changeAmplification.summary?.totalIssues || 0} cascading risks
|
|
409
|
+
`;
|
|
410
|
+
}
|
|
411
|
+
return output;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export {
|
|
415
|
+
__require,
|
|
416
|
+
analyzeUnified,
|
|
417
|
+
scoreUnified,
|
|
418
|
+
generateUnifiedSummary
|
|
419
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -144,10 +144,11 @@ async function analyzeUnified(options) {
|
|
|
144
144
|
options.progressCallback({ tool: "doc-drift", data: report });
|
|
145
145
|
}
|
|
146
146
|
result.docDrift = {
|
|
147
|
-
results: report.results || [],
|
|
147
|
+
results: report.results || report.issues || [],
|
|
148
148
|
summary: report.summary || {}
|
|
149
149
|
};
|
|
150
|
-
|
|
150
|
+
const issueCount = report.issues?.length || (report.results ? report.results.length : 0);
|
|
151
|
+
result.summary.totalIssues += issueCount;
|
|
151
152
|
}
|
|
152
153
|
if (tools.includes("deps-health")) {
|
|
153
154
|
const { analyzeDeps } = await import("@aiready/deps");
|
|
@@ -161,10 +162,11 @@ async function analyzeUnified(options) {
|
|
|
161
162
|
options.progressCallback({ tool: "deps-health", data: report });
|
|
162
163
|
}
|
|
163
164
|
result.dependencyHealth = {
|
|
164
|
-
results: report.results || [],
|
|
165
|
+
results: report.results || report.issues || [],
|
|
165
166
|
summary: report.summary || {}
|
|
166
167
|
};
|
|
167
|
-
|
|
168
|
+
const issueCount = report.issues?.length || (report.results ? report.results.length : 0);
|
|
169
|
+
result.summary.totalIssues += issueCount;
|
|
168
170
|
}
|
|
169
171
|
if (tools.includes("ai-signal-clarity")) {
|
|
170
172
|
const { analyzeAiSignalClarity } = await import("@aiready/ai-signal-clarity");
|
|
@@ -179,11 +181,11 @@ async function analyzeUnified(options) {
|
|
|
179
181
|
}
|
|
180
182
|
result.aiSignalClarity = {
|
|
181
183
|
...report,
|
|
182
|
-
results: report.results || [],
|
|
184
|
+
results: report.results || report.issues || [],
|
|
183
185
|
summary: report.summary || {}
|
|
184
186
|
};
|
|
185
|
-
result.summary.totalIssues += report.results?.reduce(
|
|
186
|
-
(sum, r) => sum + (r.issues?.length ||
|
|
187
|
+
result.summary.totalIssues += (report.results || report.issues)?.reduce(
|
|
188
|
+
(sum, r) => sum + (r.issues?.length || 1),
|
|
187
189
|
0
|
|
188
190
|
) || 0;
|
|
189
191
|
}
|
|
@@ -200,10 +202,10 @@ async function analyzeUnified(options) {
|
|
|
200
202
|
}
|
|
201
203
|
result.agentGrounding = {
|
|
202
204
|
...report,
|
|
203
|
-
results: report.results || [],
|
|
205
|
+
results: report.results || report.issues || [],
|
|
204
206
|
summary: report.summary || {}
|
|
205
207
|
};
|
|
206
|
-
result.summary.totalIssues += report.issues
|
|
208
|
+
result.summary.totalIssues += (report.issues || report.results || []).length;
|
|
207
209
|
}
|
|
208
210
|
if (tools.includes("testability")) {
|
|
209
211
|
const { analyzeTestability } = await import("@aiready/testability");
|
|
@@ -218,10 +220,10 @@ async function analyzeUnified(options) {
|
|
|
218
220
|
}
|
|
219
221
|
result.testability = {
|
|
220
222
|
...report,
|
|
221
|
-
results: report.results || [],
|
|
223
|
+
results: report.results || report.issues || [],
|
|
222
224
|
summary: report.summary || {}
|
|
223
225
|
};
|
|
224
|
-
result.summary.totalIssues += report.issues
|
|
226
|
+
result.summary.totalIssues += (report.issues || report.results || []).length;
|
|
225
227
|
}
|
|
226
228
|
if (tools.includes("change-amplification")) {
|
|
227
229
|
const { analyzeChangeAmplification } = await import("@aiready/change-amplification");
|
|
@@ -886,18 +888,18 @@ async function scanAction(directory, options) {
|
|
|
886
888
|
topFiles.forEach(([file, issues], idx) => {
|
|
887
889
|
const counts = issues.reduce(
|
|
888
890
|
(acc, it) => {
|
|
889
|
-
const s = (it.severity ||
|
|
891
|
+
const s = (it.severity || import_core3.Severity.Info).toLowerCase();
|
|
890
892
|
acc[s] = (acc[s] || 0) + 1;
|
|
891
893
|
return acc;
|
|
892
894
|
},
|
|
893
895
|
{}
|
|
894
896
|
);
|
|
895
897
|
const sample = issues.find(
|
|
896
|
-
(it) => it.severity ===
|
|
898
|
+
(it) => it.severity === import_core3.Severity.Critical || it.severity === import_core3.Severity.Major
|
|
897
899
|
) || issues[0];
|
|
898
900
|
const sampleMsg = sample ? ` \u2014 ${sample.message}` : "";
|
|
899
901
|
console.log(
|
|
900
|
-
` ${idx + 1}. ${file} \u2014 ${issues.length} issue(s) (critical:${counts.
|
|
902
|
+
` ${idx + 1}. ${file} \u2014 ${issues.length} issue(s) (critical:${counts[import_core3.Severity.Critical] || 0} major:${counts[import_core3.Severity.Major] || 0} minor:${counts[import_core3.Severity.Minor] || 0} info:${counts[import_core3.Severity.Info] || 0})${sampleMsg}`
|
|
901
903
|
);
|
|
902
904
|
});
|
|
903
905
|
const remaining = files.length - topFiles.length;
|
|
@@ -1130,6 +1132,78 @@ async function scanAction(directory, options) {
|
|
|
1130
1132
|
}
|
|
1131
1133
|
}
|
|
1132
1134
|
}
|
|
1135
|
+
const mapToUnifiedReport = (res, scoring) => {
|
|
1136
|
+
const allResults = [];
|
|
1137
|
+
let totalFilesSet = /* @__PURE__ */ new Set();
|
|
1138
|
+
let criticalCount = 0;
|
|
1139
|
+
let majorCount = 0;
|
|
1140
|
+
const collect = (spokeRes, defaultType = import_core3.IssueType.AiSignalClarity) => {
|
|
1141
|
+
if (!spokeRes || !spokeRes.results) return;
|
|
1142
|
+
spokeRes.results.forEach((r) => {
|
|
1143
|
+
const fileName = r.fileName || r.file || "unknown";
|
|
1144
|
+
totalFilesSet.add(fileName);
|
|
1145
|
+
const normalizedResult = {
|
|
1146
|
+
fileName,
|
|
1147
|
+
issues: [],
|
|
1148
|
+
metrics: r.metrics || { tokenCost: r.tokenCost || 0 }
|
|
1149
|
+
};
|
|
1150
|
+
if (r.issues && Array.isArray(r.issues)) {
|
|
1151
|
+
r.issues.forEach((i) => {
|
|
1152
|
+
const normalizedIssue = typeof i === "string" ? {
|
|
1153
|
+
type: defaultType,
|
|
1154
|
+
severity: r.severity || import_core3.Severity.Info,
|
|
1155
|
+
message: i,
|
|
1156
|
+
location: { file: fileName, line: 1 }
|
|
1157
|
+
} : {
|
|
1158
|
+
type: i.type || defaultType,
|
|
1159
|
+
severity: i.severity || r.severity || import_core3.Severity.Info,
|
|
1160
|
+
message: i.message || String(i),
|
|
1161
|
+
location: i.location || { file: fileName, line: 1 },
|
|
1162
|
+
suggestion: i.suggestion
|
|
1163
|
+
};
|
|
1164
|
+
if (normalizedIssue.severity === import_core3.Severity.Critical || normalizedIssue.severity === "critical")
|
|
1165
|
+
criticalCount++;
|
|
1166
|
+
if (normalizedIssue.severity === import_core3.Severity.Major || normalizedIssue.severity === "major")
|
|
1167
|
+
majorCount++;
|
|
1168
|
+
normalizedResult.issues.push(normalizedIssue);
|
|
1169
|
+
});
|
|
1170
|
+
} else if (r.severity) {
|
|
1171
|
+
const normalizedIssue = {
|
|
1172
|
+
type: defaultType,
|
|
1173
|
+
severity: r.severity,
|
|
1174
|
+
message: r.message || "General issue",
|
|
1175
|
+
location: { file: fileName, line: 1 }
|
|
1176
|
+
};
|
|
1177
|
+
if (normalizedIssue.severity === import_core3.Severity.Critical || normalizedIssue.severity === "critical")
|
|
1178
|
+
criticalCount++;
|
|
1179
|
+
if (normalizedIssue.severity === import_core3.Severity.Major || normalizedIssue.severity === "major")
|
|
1180
|
+
majorCount++;
|
|
1181
|
+
normalizedResult.issues.push(normalizedIssue);
|
|
1182
|
+
}
|
|
1183
|
+
allResults.push(normalizedResult);
|
|
1184
|
+
});
|
|
1185
|
+
};
|
|
1186
|
+
collect(res.patternDetect, import_core3.IssueType.DuplicatePattern);
|
|
1187
|
+
collect(res.contextAnalyzer, import_core3.IssueType.ContextFragmentation);
|
|
1188
|
+
collect(res.consistency, import_core3.IssueType.NamingInconsistency);
|
|
1189
|
+
collect(res.docDrift, import_core3.IssueType.DocDrift);
|
|
1190
|
+
collect(res.dependencyHealth, import_core3.IssueType.DependencyHealth);
|
|
1191
|
+
collect(res.aiSignalClarity, import_core3.IssueType.AiSignalClarity);
|
|
1192
|
+
collect(res.agentGrounding, import_core3.IssueType.AgentNavigationFailure);
|
|
1193
|
+
collect(res.testability, import_core3.IssueType.LowTestability);
|
|
1194
|
+
collect(res.changeAmplification, import_core3.IssueType.ChangeAmplification);
|
|
1195
|
+
return {
|
|
1196
|
+
...res,
|
|
1197
|
+
results: allResults,
|
|
1198
|
+
summary: {
|
|
1199
|
+
...res.summary,
|
|
1200
|
+
totalFiles: totalFilesSet.size,
|
|
1201
|
+
criticalIssues: criticalCount,
|
|
1202
|
+
majorIssues: majorCount
|
|
1203
|
+
},
|
|
1204
|
+
scoring
|
|
1205
|
+
};
|
|
1206
|
+
};
|
|
1133
1207
|
const outputFormat = options.output || finalOptions.output?.format || "console";
|
|
1134
1208
|
const userOutputFile = options.outputFile || finalOptions.output?.file;
|
|
1135
1209
|
if (outputFormat === "json") {
|
|
@@ -1141,8 +1215,7 @@ async function scanAction(directory, options) {
|
|
|
1141
1215
|
resolvedDir
|
|
1142
1216
|
);
|
|
1143
1217
|
const outputData = {
|
|
1144
|
-
...results,
|
|
1145
|
-
scoring: scoringResult,
|
|
1218
|
+
...mapToUnifiedReport(results, scoringResult),
|
|
1146
1219
|
repository: repoMetadata
|
|
1147
1220
|
};
|
|
1148
1221
|
(0, import_core3.handleJSONOutput)(
|
|
@@ -1167,8 +1240,7 @@ async function scanAction(directory, options) {
|
|
|
1167
1240
|
resolvedDir
|
|
1168
1241
|
);
|
|
1169
1242
|
const outputData = {
|
|
1170
|
-
...results,
|
|
1171
|
-
scoring: scoringResult,
|
|
1243
|
+
...mapToUnifiedReport(results, scoringResult),
|
|
1172
1244
|
repository: repoMetadata
|
|
1173
1245
|
};
|
|
1174
1246
|
try {
|
|
@@ -1211,7 +1283,7 @@ async function scanAction(directory, options) {
|
|
|
1211
1283
|
}
|
|
1212
1284
|
if (results.patternDetect) {
|
|
1213
1285
|
const criticalPatterns = results.patternDetect.results.flatMap(
|
|
1214
|
-
(p) => p.issues.filter((i) => i.severity ===
|
|
1286
|
+
(p) => p.issues.filter((i) => i.severity === import_core3.Severity.Critical)
|
|
1215
1287
|
);
|
|
1216
1288
|
criticalPatterns.slice(0, 10).forEach((issue) => {
|
|
1217
1289
|
console.log(
|
|
@@ -1234,22 +1306,22 @@ async function scanAction(directory, options) {
|
|
|
1234
1306
|
if (results.patternDetect) {
|
|
1235
1307
|
results.patternDetect.results.forEach((p) => {
|
|
1236
1308
|
p.issues.forEach((i) => {
|
|
1237
|
-
if (i.severity ===
|
|
1238
|
-
if (i.severity ===
|
|
1309
|
+
if (i.severity === import_core3.Severity.Critical) criticalCount++;
|
|
1310
|
+
if (i.severity === import_core3.Severity.Major) majorCount++;
|
|
1239
1311
|
});
|
|
1240
1312
|
});
|
|
1241
1313
|
}
|
|
1242
1314
|
if (results.contextAnalyzer) {
|
|
1243
1315
|
results.contextAnalyzer.results.forEach((c) => {
|
|
1244
|
-
if (c.severity ===
|
|
1245
|
-
if (c.severity ===
|
|
1316
|
+
if (c.severity === import_core3.Severity.Critical) criticalCount++;
|
|
1317
|
+
if (c.severity === import_core3.Severity.Major) majorCount++;
|
|
1246
1318
|
});
|
|
1247
1319
|
}
|
|
1248
1320
|
if (results.consistency) {
|
|
1249
1321
|
results.consistency.results.forEach((r) => {
|
|
1250
1322
|
r.issues?.forEach((i) => {
|
|
1251
|
-
if (i.severity ===
|
|
1252
|
-
if (i.severity ===
|
|
1323
|
+
if (i.severity === import_core3.Severity.Critical) criticalCount++;
|
|
1324
|
+
if (i.severity === import_core3.Severity.Major) majorCount++;
|
|
1253
1325
|
});
|
|
1254
1326
|
});
|
|
1255
1327
|
}
|