@aiready/cli 0.10.4 → 0.12.0

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.
@@ -1,419 +0,0 @@
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
- };