@aiready/cli 0.10.6 → 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,414 +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 || [],
121
- summary: report.summary || {}
122
- };
123
- result.summary.totalIssues += report.issues?.length || 0;
124
- }
125
- if (tools.includes("deps-health")) {
126
- const { analyzeDeps } = await import("@aiready/deps");
127
- const report = await analyzeDeps({
128
- rootDir: options.rootDir,
129
- include: options.include,
130
- exclude: options.exclude,
131
- onProgress: options.onProgress
132
- });
133
- if (options.progressCallback) {
134
- options.progressCallback({ tool: "deps-health", data: report });
135
- }
136
- result.dependencyHealth = {
137
- results: report.results || [],
138
- summary: report.summary || {}
139
- };
140
- result.summary.totalIssues += report.issues?.length || 0;
141
- }
142
- if (tools.includes("ai-signal-clarity")) {
143
- const { analyzeAiSignalClarity } = await import("@aiready/ai-signal-clarity");
144
- const report = await analyzeAiSignalClarity({
145
- rootDir: options.rootDir,
146
- include: options.include,
147
- exclude: options.exclude,
148
- onProgress: options.onProgress
149
- });
150
- if (options.progressCallback) {
151
- options.progressCallback({ tool: "ai-signal-clarity", data: report });
152
- }
153
- result.aiSignalClarity = {
154
- results: report.results || [],
155
- summary: report.summary || {}
156
- };
157
- result.summary.totalIssues += report.results?.reduce(
158
- (sum, r) => sum + (r.issues?.length || 0),
159
- 0
160
- ) || 0;
161
- }
162
- if (tools.includes("agent-grounding")) {
163
- const { analyzeAgentGrounding } = await import("@aiready/agent-grounding");
164
- const report = await analyzeAgentGrounding({
165
- rootDir: options.rootDir,
166
- include: options.include,
167
- exclude: options.exclude,
168
- onProgress: options.onProgress
169
- });
170
- if (options.progressCallback) {
171
- options.progressCallback({ tool: "agent-grounding", data: report });
172
- }
173
- result.agentGrounding = {
174
- results: report.results || [],
175
- summary: report.summary || {}
176
- };
177
- result.summary.totalIssues += report.issues?.length || 0;
178
- }
179
- if (tools.includes("testability")) {
180
- const { analyzeTestability } = await import("@aiready/testability");
181
- const report = await analyzeTestability({
182
- rootDir: options.rootDir,
183
- include: options.include,
184
- exclude: options.exclude,
185
- onProgress: options.onProgress
186
- });
187
- if (options.progressCallback) {
188
- options.progressCallback({ tool: "testability", data: report });
189
- }
190
- result.testability = {
191
- results: report.results || [],
192
- summary: report.summary || {}
193
- };
194
- result.summary.totalIssues += report.issues?.length || 0;
195
- }
196
- if (tools.includes("change-amplification")) {
197
- const { analyzeChangeAmplification } = await import("@aiready/change-amplification");
198
- const report = await analyzeChangeAmplification({
199
- rootDir: options.rootDir,
200
- include: options.include,
201
- exclude: options.exclude,
202
- onProgress: options.onProgress
203
- });
204
- if (options.progressCallback) {
205
- options.progressCallback({ tool: "change-amplification", data: report });
206
- }
207
- result.changeAmplification = {
208
- results: report.results || [],
209
- summary: report.summary || {}
210
- };
211
- result.summary.totalIssues += report.summary?.totalIssues || 0;
212
- }
213
- result.summary.executionTime = Date.now() - startTime;
214
- return result;
215
- }
216
- async function scoreUnified(results, options) {
217
- const toolScores = /* @__PURE__ */ new Map();
218
- if (results.patternDetect) {
219
- const { calculatePatternScore } = await import("@aiready/pattern-detect");
220
- try {
221
- const patternScore = calculatePatternScore(
222
- results.patternDetect.duplicates,
223
- results.patternDetect.results?.length || 0
224
- );
225
- const wastedTokens = results.patternDetect.duplicates.reduce(
226
- (sum, d) => sum + (d.tokenCost || 0),
227
- 0
228
- );
229
- patternScore.tokenBudget = calculateTokenBudget({
230
- totalContextTokens: wastedTokens * 2,
231
- // Estimated context
232
- wastedTokens: {
233
- duplication: wastedTokens,
234
- fragmentation: 0,
235
- chattiness: 0
236
- }
237
- });
238
- toolScores.set("pattern-detect", patternScore);
239
- } catch (err) {
240
- void err;
241
- }
242
- }
243
- if (results.contextAnalyzer) {
244
- const { calculateContextScore } = await import("@aiready/context-analyzer");
245
- try {
246
- const ctxSummary = results.contextAnalyzer.summary;
247
- const contextScore = calculateContextScore(ctxSummary);
248
- contextScore.tokenBudget = calculateTokenBudget({
249
- totalContextTokens: ctxSummary.totalTokens,
250
- wastedTokens: {
251
- duplication: 0,
252
- fragmentation: ctxSummary.totalPotentialSavings || 0,
253
- chattiness: 0
254
- }
255
- });
256
- toolScores.set("context-analyzer", contextScore);
257
- } catch (err) {
258
- void err;
259
- }
260
- }
261
- if (results.consistency) {
262
- const { calculateConsistencyScore } = await import("@aiready/consistency");
263
- try {
264
- const issues = results.consistency.results?.flatMap((r) => r.issues) || [];
265
- const totalFiles = results.consistency.summary?.filesAnalyzed || 0;
266
- const consistencyScore = calculateConsistencyScore(issues, totalFiles);
267
- toolScores.set("consistency", consistencyScore);
268
- } catch (err) {
269
- void err;
270
- }
271
- }
272
- if (results.aiSignalClarity) {
273
- const { calculateAiSignalClarityScore } = await import("@aiready/ai-signal-clarity");
274
- try {
275
- const hrScore = calculateAiSignalClarityScore(results.aiSignalClarity);
276
- toolScores.set("ai-signal-clarity", hrScore);
277
- } catch (err) {
278
- void err;
279
- }
280
- }
281
- if (results.agentGrounding) {
282
- const { calculateGroundingScore } = await import("@aiready/agent-grounding");
283
- try {
284
- const agScore = calculateGroundingScore(results.agentGrounding);
285
- toolScores.set("agent-grounding", agScore);
286
- } catch (err) {
287
- void err;
288
- }
289
- }
290
- if (results.testability) {
291
- const { calculateTestabilityScore } = await import("@aiready/testability");
292
- try {
293
- const tbScore = calculateTestabilityScore(results.testability);
294
- toolScores.set("testability", tbScore);
295
- } catch (err) {
296
- void err;
297
- }
298
- }
299
- if (results.docDrift) {
300
- toolScores.set("doc-drift", {
301
- toolName: "doc-drift",
302
- score: results.docDrift.summary.score || results.docDrift.summary.totalScore || 0,
303
- rawMetrics: results.docDrift.summary,
304
- factors: [],
305
- recommendations: (results.docDrift.summary.recommendations || []).map(
306
- (action) => ({
307
- action,
308
- estimatedImpact: 5,
309
- priority: "medium"
310
- })
311
- )
312
- });
313
- }
314
- if (results.dependencyHealth) {
315
- toolScores.set("dependency-health", {
316
- toolName: "dependency-health",
317
- score: results.dependencyHealth.summary.score || 0,
318
- rawMetrics: results.dependencyHealth.summary,
319
- factors: [],
320
- recommendations: (results.dependencyHealth.summary.recommendations || []).map((action) => ({
321
- action,
322
- estimatedImpact: 5,
323
- priority: "medium"
324
- }))
325
- });
326
- }
327
- if (results.changeAmplification) {
328
- toolScores.set("change-amplification", {
329
- toolName: "change-amplification",
330
- score: results.changeAmplification.summary.score || 0,
331
- rawMetrics: results.changeAmplification.summary,
332
- factors: [],
333
- recommendations: (results.changeAmplification.summary.recommendations || []).map((action) => ({
334
- action,
335
- estimatedImpact: 5,
336
- priority: "medium"
337
- }))
338
- });
339
- }
340
- if (toolScores.size === 0) {
341
- return {
342
- overall: 0,
343
- rating: "Critical",
344
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
345
- toolsUsed: [],
346
- breakdown: [],
347
- calculation: {
348
- formula: "0 / 0 = 0",
349
- weights: {},
350
- normalized: "0 / 0 = 0"
351
- }
352
- };
353
- }
354
- return calculateOverallScore(toolScores, options, void 0);
355
- }
356
- function generateUnifiedSummary(result) {
357
- const { summary } = result;
358
- let output = `\u{1F680} AIReady Analysis Complete
359
-
360
- `;
361
- output += `\u{1F4CA} Summary:
362
- `;
363
- output += ` Tools run: ${summary.toolsRun.join(", ")}
364
- `;
365
- output += ` Total issues found: ${summary.totalIssues}
366
- `;
367
- output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
368
-
369
- `;
370
- if (result.patternDetect) {
371
- output += `\u{1F50D} Pattern Analysis: ${result.patternDetect.results.length} issues
372
- `;
373
- }
374
- if (result.contextAnalyzer) {
375
- output += `\u{1F9E0} Context Analysis: ${result.contextAnalyzer.results.length} issues
376
- `;
377
- }
378
- if (result.consistency) {
379
- output += `\u{1F3F7}\uFE0F Consistency Analysis: ${result.consistency.summary.totalIssues} issues
380
- `;
381
- }
382
- if (result.docDrift) {
383
- output += `\u{1F4DD} Doc Drift Analysis: ${result.docDrift.results?.length || 0} issues
384
- `;
385
- }
386
- if (result.dependencyHealth) {
387
- output += `\u{1F4E6} Dependency Health: ${result.dependencyHealth.results?.length || 0} issues
388
- `;
389
- }
390
- if (result.aiSignalClarity) {
391
- output += `\u{1F9E0} AI Signal Clarity: ${result.aiSignalClarity.summary?.totalSignals || 0} signals
392
- `;
393
- }
394
- if (result.agentGrounding) {
395
- output += `\u{1F9ED} Agent Grounding: ${result.agentGrounding.results?.length || 0} issues
396
- `;
397
- }
398
- if (result.testability) {
399
- output += `\u{1F9EA} Testability Index: ${result.testability.results?.length || 0} issues
400
- `;
401
- }
402
- if (result.changeAmplification) {
403
- output += `\u{1F4A5} Change Amplification: ${result.changeAmplification.summary?.totalIssues || 0} cascading risks
404
- `;
405
- }
406
- return output;
407
- }
408
-
409
- export {
410
- __require,
411
- analyzeUnified,
412
- scoreUnified,
413
- generateUnifiedSummary
414
- };