@aiready/cli 0.10.4 → 0.10.6

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,6 +1,6 @@
1
1
 
2
2
  
3
- > @aiready/cli@0.10.3 build /Users/pengcao/projects/aiready/packages/cli
3
+ > @aiready/cli@0.10.5 build /Users/pengcao/projects/aiready/packages/cli
4
4
  > tsup src/index.ts src/cli.ts --format cjs,esm
5
5
 
6
6
  CLI Building entry: src/cli.ts, src/index.ts
@@ -10,7 +10,7 @@
10
10
  CJS Build start
11
11
  ESM Build start
12
12
 
13
-  WARN  ▲ [WARNING] "import.meta" is not available with the "cjs" output format and will be empty [empty-import-meta] 8:22:49 pm
13
+  WARN  ▲ [WARNING] "import.meta" is not available with the "cjs" output format and will be empty [empty-import-meta] 9:38:48 pm
14
14
 
15
15
  src/cli.ts:25:31:
16
16
   25 │ return dirname(fileURLToPath(import.meta.url));
@@ -20,10 +20,10 @@
20
20
 
21
21
 
22
22
 
23
- CJS dist/cli.js 93.97 KB
24
- CJS dist/index.js 15.13 KB
25
- CJS ⚡️ Build success in 29ms
23
+ CJS dist/index.js 16.55 KB
24
+ CJS dist/cli.js 95.60 KB
25
+ CJS ⚡️ Build success in 31ms
26
26
  ESM dist/index.mjs 170.00 B
27
- ESM dist/cli.mjs 77.08 KB
28
- ESM dist/chunk-R3O7QPKD.mjs 13.73 KB
29
- ESM ⚡️ Build success in 29ms
27
+ ESM dist/cli.mjs 77.38 KB
28
+ ESM dist/chunk-VQCWYJYJ.mjs 14.49 KB
29
+ ESM ⚡️ Build success in 31ms
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @aiready/cli@0.10.3 test /Users/pengcao/projects/aiready/packages/cli
3
+ > @aiready/cli@0.10.5 test /Users/pengcao/projects/aiready/packages/cli
4
4
  > vitest run
5
5
 
6
6
  [?25l
@@ -10,7 +10,7 @@
10
10
 
11
11
   Test Files  1 passed (1)
12
12
   Tests  3 passed (3)
13
-  Start at  20:23:07
14
-  Duration  426ms (transform 97ms, setup 0ms, import 295ms, tests 2ms, environment 0ms)
13
+  Start at  21:39:06
14
+  Duration  411ms (transform 80ms, setup 0ms, import 280ms, tests 2ms, environment 0ms)
15
15
 
16
16
  [?25h
@@ -0,0 +1,438 @@
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
+ ToolName
16
+ } from "@aiready/core";
17
+ var severityOrder = {
18
+ critical: 4,
19
+ major: 3,
20
+ minor: 2,
21
+ info: 1
22
+ };
23
+ function sortBySeverity(results) {
24
+ return results.map((file) => {
25
+ const sortedIssues = [...file.issues].sort((a, b) => {
26
+ const severityDiff = (severityOrder[b.severity] || 0) - (severityOrder[a.severity] || 0);
27
+ if (severityDiff !== 0) return severityDiff;
28
+ return (a.location?.line || 0) - (b.location?.line || 0);
29
+ });
30
+ return { ...file, issues: sortedIssues };
31
+ }).sort((a, b) => {
32
+ const aMaxSeverity = Math.max(
33
+ ...a.issues.map((i) => severityOrder[i.severity] || 0),
34
+ 0
35
+ );
36
+ const bMaxSeverity = Math.max(
37
+ ...b.issues.map((i) => severityOrder[i.severity] || 0),
38
+ 0
39
+ );
40
+ if (aMaxSeverity !== bMaxSeverity) {
41
+ return bMaxSeverity - aMaxSeverity;
42
+ }
43
+ if (a.issues.length !== b.issues.length) {
44
+ return b.issues.length - a.issues.length;
45
+ }
46
+ return a.fileName.localeCompare(b.fileName);
47
+ });
48
+ }
49
+ async function analyzeUnified(options) {
50
+ const startTime = Date.now();
51
+ const tools = options.tools || ["patterns", "context", "consistency"];
52
+ const result = {
53
+ summary: {
54
+ totalIssues: 0,
55
+ toolsRun: tools,
56
+ executionTime: 0
57
+ }
58
+ };
59
+ if (tools.includes("patterns")) {
60
+ const patternResult = await analyzePatterns(options);
61
+ if (options.progressCallback) {
62
+ options.progressCallback({ tool: "patterns", data: patternResult });
63
+ }
64
+ const output = {
65
+ results: sortBySeverity(patternResult.results),
66
+ summary: patternResult.summary || {},
67
+ duplicates: patternResult.duplicates || []
68
+ };
69
+ result[ToolName.PatternDetect] = output;
70
+ result.patternDetect = output;
71
+ result.summary.totalIssues += patternResult.results.reduce(
72
+ (sum, file) => sum + file.issues.length,
73
+ 0
74
+ );
75
+ }
76
+ if (tools.includes("context")) {
77
+ const contextResults = await analyzeContext(options);
78
+ if (options.progressCallback) {
79
+ options.progressCallback({ tool: "context", data: contextResults });
80
+ }
81
+ const sorted = contextResults.sort((a, b) => {
82
+ const severityDiff = (severityOrder[b.severity] || 0) - (severityOrder[a.severity] || 0);
83
+ if (severityDiff !== 0) return severityDiff;
84
+ if (a.tokenCost !== b.tokenCost) return b.tokenCost - a.tokenCost;
85
+ return b.fragmentationScore - a.fragmentationScore;
86
+ });
87
+ const { generateSummary: genContextSummary } = await import("@aiready/context-analyzer");
88
+ const output = {
89
+ results: sorted,
90
+ summary: genContextSummary(sorted)
91
+ };
92
+ result[ToolName.ContextAnalyzer] = output;
93
+ result.contextAnalyzer = output;
94
+ result.summary.totalIssues += sorted.length;
95
+ }
96
+ if (tools.includes("consistency")) {
97
+ const consistencyOptions = {
98
+ rootDir: options.rootDir,
99
+ include: options.include,
100
+ exclude: options.exclude,
101
+ ...options.consistency || {}
102
+ };
103
+ const report = await analyzeConsistency(consistencyOptions);
104
+ if (options.progressCallback) {
105
+ options.progressCallback({ tool: "consistency", data: report });
106
+ }
107
+ result[ToolName.NamingConsistency] = {
108
+ results: report.results ? sortBySeverity(report.results) : [],
109
+ summary: report.summary
110
+ };
111
+ result.summary.totalIssues += report.summary.totalIssues;
112
+ }
113
+ if (tools.includes("doc-drift")) {
114
+ const { analyzeDocDrift } = await import("@aiready/doc-drift");
115
+ const report = await analyzeDocDrift({
116
+ rootDir: options.rootDir,
117
+ include: options.include,
118
+ exclude: options.exclude,
119
+ onProgress: options.onProgress
120
+ });
121
+ if (options.progressCallback) {
122
+ options.progressCallback({ tool: "doc-drift", data: report });
123
+ }
124
+ result[ToolName.DocDrift] = {
125
+ results: report.results || report.issues || [],
126
+ summary: report.summary || {}
127
+ };
128
+ const issueCount = report.issues?.length || (report.results ? report.results.length : 0);
129
+ result.summary.totalIssues += issueCount;
130
+ }
131
+ if (tools.includes("deps-health")) {
132
+ const { analyzeDeps } = await import("@aiready/deps");
133
+ const report = await analyzeDeps({
134
+ rootDir: options.rootDir,
135
+ include: options.include,
136
+ exclude: options.exclude,
137
+ onProgress: options.onProgress
138
+ });
139
+ if (options.progressCallback) {
140
+ options.progressCallback({ tool: "deps-health", data: report });
141
+ }
142
+ result[ToolName.DependencyHealth] = {
143
+ results: report.results || report.issues || [],
144
+ summary: report.summary || {}
145
+ };
146
+ const issueCount = report.issues?.length || (report.results ? report.results.length : 0);
147
+ result.summary.totalIssues += issueCount;
148
+ }
149
+ if (tools.includes("ai-signal-clarity")) {
150
+ const { analyzeAiSignalClarity } = await import("@aiready/ai-signal-clarity");
151
+ const report = await analyzeAiSignalClarity({
152
+ rootDir: options.rootDir,
153
+ include: options.include,
154
+ exclude: options.exclude,
155
+ onProgress: options.onProgress
156
+ });
157
+ if (options.progressCallback) {
158
+ options.progressCallback({ tool: "ai-signal-clarity", data: report });
159
+ }
160
+ result[ToolName.AiSignalClarity] = {
161
+ ...report,
162
+ results: report.results || report.issues || [],
163
+ summary: report.summary || {}
164
+ };
165
+ result.summary.totalIssues += (report.results || report.issues)?.reduce(
166
+ (sum, r) => sum + (r.issues?.length || 1),
167
+ 0
168
+ ) || 0;
169
+ }
170
+ if (tools.includes("agent-grounding")) {
171
+ const { analyzeAgentGrounding } = await import("@aiready/agent-grounding");
172
+ const report = await analyzeAgentGrounding({
173
+ rootDir: options.rootDir,
174
+ include: options.include,
175
+ exclude: options.exclude,
176
+ onProgress: options.onProgress
177
+ });
178
+ if (options.progressCallback) {
179
+ options.progressCallback({ tool: "agent-grounding", data: report });
180
+ }
181
+ result[ToolName.AgentGrounding] = {
182
+ ...report,
183
+ results: report.results || report.issues || [],
184
+ summary: report.summary || {}
185
+ };
186
+ result.summary.totalIssues += (report.issues || report.results || []).length;
187
+ }
188
+ if (tools.includes("testability")) {
189
+ const { analyzeTestability } = await import("@aiready/testability");
190
+ const report = await analyzeTestability({
191
+ rootDir: options.rootDir,
192
+ include: options.include,
193
+ exclude: options.exclude,
194
+ onProgress: options.onProgress
195
+ });
196
+ if (options.progressCallback) {
197
+ options.progressCallback({ tool: "testability", data: report });
198
+ }
199
+ result[ToolName.TestabilityIndex] = {
200
+ ...report,
201
+ results: report.results || report.issues || [],
202
+ summary: report.summary || {}
203
+ };
204
+ result.summary.totalIssues += (report.issues || report.results || []).length;
205
+ }
206
+ if (tools.includes("change-amplification")) {
207
+ const { analyzeChangeAmplification } = await import("@aiready/change-amplification");
208
+ const report = await analyzeChangeAmplification({
209
+ rootDir: options.rootDir,
210
+ include: options.include,
211
+ exclude: options.exclude,
212
+ onProgress: options.onProgress
213
+ });
214
+ if (options.progressCallback) {
215
+ options.progressCallback({ tool: "change-amplification", data: report });
216
+ }
217
+ result[ToolName.ChangeAmplification] = {
218
+ results: report.results || [],
219
+ summary: report.summary || {}
220
+ };
221
+ result.summary.totalIssues += report.summary?.totalIssues || 0;
222
+ }
223
+ result.summary.executionTime = Date.now() - startTime;
224
+ return result;
225
+ }
226
+ async function scoreUnified(results, options) {
227
+ const toolScores = /* @__PURE__ */ new Map();
228
+ if (results[ToolName.PatternDetect]) {
229
+ const data = results[ToolName.PatternDetect];
230
+ const { calculatePatternScore } = await import("@aiready/pattern-detect");
231
+ try {
232
+ const patternScore = calculatePatternScore(
233
+ data.duplicates,
234
+ data.results?.length || 0
235
+ );
236
+ const wastedTokens = data.duplicates.reduce(
237
+ (sum, d) => sum + (d.tokenCost || 0),
238
+ 0
239
+ );
240
+ patternScore.tokenBudget = calculateTokenBudget({
241
+ totalContextTokens: wastedTokens * 2,
242
+ // Estimated context
243
+ wastedTokens: {
244
+ duplication: wastedTokens,
245
+ fragmentation: 0,
246
+ chattiness: 0
247
+ }
248
+ });
249
+ toolScores.set(ToolName.PatternDetect, patternScore);
250
+ } catch (err) {
251
+ void err;
252
+ }
253
+ }
254
+ if (results[ToolName.ContextAnalyzer]) {
255
+ const data = results[ToolName.ContextAnalyzer];
256
+ const { calculateContextScore } = await import("@aiready/context-analyzer");
257
+ try {
258
+ const ctxSummary = data.summary;
259
+ const contextScore = calculateContextScore(ctxSummary);
260
+ contextScore.tokenBudget = calculateTokenBudget({
261
+ totalContextTokens: ctxSummary.totalTokens,
262
+ wastedTokens: {
263
+ duplication: 0,
264
+ fragmentation: ctxSummary.totalPotentialSavings || 0,
265
+ chattiness: 0
266
+ }
267
+ });
268
+ toolScores.set(ToolName.ContextAnalyzer, contextScore);
269
+ } catch (err) {
270
+ void err;
271
+ }
272
+ }
273
+ if (results[ToolName.NamingConsistency]) {
274
+ const data = results[ToolName.NamingConsistency];
275
+ const { calculateConsistencyScore } = await import("@aiready/consistency");
276
+ try {
277
+ const issues = data.results?.flatMap((r) => r.issues) || [];
278
+ const totalFiles = data.summary?.filesAnalyzed || 0;
279
+ const consistencyScore = calculateConsistencyScore(issues, totalFiles);
280
+ toolScores.set(ToolName.NamingConsistency, consistencyScore);
281
+ } catch (err) {
282
+ void err;
283
+ }
284
+ }
285
+ if (results[ToolName.AiSignalClarity]) {
286
+ const { calculateAiSignalClarityScore } = await import("@aiready/ai-signal-clarity");
287
+ try {
288
+ const hrScore = calculateAiSignalClarityScore(
289
+ results[ToolName.AiSignalClarity]
290
+ );
291
+ toolScores.set(ToolName.AiSignalClarity, hrScore);
292
+ } catch (err) {
293
+ void err;
294
+ }
295
+ }
296
+ if (results[ToolName.AgentGrounding]) {
297
+ const { calculateGroundingScore } = await import("@aiready/agent-grounding");
298
+ try {
299
+ const agScore = calculateGroundingScore(results[ToolName.AgentGrounding]);
300
+ toolScores.set(ToolName.AgentGrounding, agScore);
301
+ } catch (err) {
302
+ void err;
303
+ }
304
+ }
305
+ if (results[ToolName.TestabilityIndex]) {
306
+ const { calculateTestabilityScore } = await import("@aiready/testability");
307
+ try {
308
+ const tbScore = calculateTestabilityScore(
309
+ results[ToolName.TestabilityIndex]
310
+ );
311
+ toolScores.set(ToolName.TestabilityIndex, tbScore);
312
+ } catch (err) {
313
+ void err;
314
+ }
315
+ }
316
+ if (results[ToolName.DocDrift]) {
317
+ const data = results[ToolName.DocDrift];
318
+ toolScores.set(ToolName.DocDrift, {
319
+ toolName: ToolName.DocDrift,
320
+ score: data.summary.score || data.summary.totalScore || 0,
321
+ rawMetrics: data.summary,
322
+ factors: [],
323
+ recommendations: (data.summary.recommendations || []).map(
324
+ (action) => ({
325
+ action,
326
+ estimatedImpact: 5,
327
+ priority: "medium"
328
+ })
329
+ )
330
+ });
331
+ }
332
+ if (results[ToolName.DependencyHealth]) {
333
+ const data = results[ToolName.DependencyHealth];
334
+ toolScores.set(ToolName.DependencyHealth, {
335
+ toolName: ToolName.DependencyHealth,
336
+ score: data.summary.score || 0,
337
+ rawMetrics: data.summary,
338
+ factors: [],
339
+ recommendations: (data.summary.recommendations || []).map(
340
+ (action) => ({
341
+ action,
342
+ estimatedImpact: 5,
343
+ priority: "medium"
344
+ })
345
+ )
346
+ });
347
+ }
348
+ if (results[ToolName.ChangeAmplification]) {
349
+ const data = results[ToolName.ChangeAmplification];
350
+ toolScores.set(ToolName.ChangeAmplification, {
351
+ toolName: ToolName.ChangeAmplification,
352
+ score: data.summary.score || 0,
353
+ rawMetrics: data.summary,
354
+ factors: [],
355
+ recommendations: (data.summary.recommendations || []).map(
356
+ (action) => ({
357
+ action,
358
+ estimatedImpact: 5,
359
+ priority: "medium"
360
+ })
361
+ )
362
+ });
363
+ }
364
+ if (toolScores.size === 0) {
365
+ return {
366
+ overall: 0,
367
+ rating: "Critical",
368
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
369
+ toolsUsed: [],
370
+ breakdown: [],
371
+ calculation: {
372
+ formula: "0 / 0 = 0",
373
+ weights: {},
374
+ normalized: "0 / 0 = 0"
375
+ }
376
+ };
377
+ }
378
+ return calculateOverallScore(toolScores, options, void 0);
379
+ }
380
+ function generateUnifiedSummary(result) {
381
+ const { summary } = result;
382
+ let output = `\u{1F680} AIReady Analysis Complete
383
+
384
+ `;
385
+ output += `\u{1F4CA} Summary:
386
+ `;
387
+ output += ` Tools run: ${summary.toolsRun.join(", ")}
388
+ `;
389
+ output += ` Total issues found: ${summary.totalIssues}
390
+ `;
391
+ output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
392
+
393
+ `;
394
+ if (result[ToolName.PatternDetect]) {
395
+ output += `\u{1F50D} Pattern Analysis: ${result[ToolName.PatternDetect].results.length} issues
396
+ `;
397
+ }
398
+ if (result[ToolName.ContextAnalyzer]) {
399
+ output += `\u{1F9E0} Context Analysis: ${result[ToolName.ContextAnalyzer].results.length} issues
400
+ `;
401
+ }
402
+ if (result[ToolName.NamingConsistency]) {
403
+ output += `\u{1F3F7}\uFE0F Consistency Analysis: ${result[ToolName.NamingConsistency].summary.totalIssues} issues
404
+ `;
405
+ }
406
+ if (result[ToolName.DocDrift]) {
407
+ output += `\u{1F4DD} Doc Drift Analysis: ${result[ToolName.DocDrift].results?.length || 0} issues
408
+ `;
409
+ }
410
+ if (result[ToolName.DependencyHealth]) {
411
+ output += `\u{1F4E6} Dependency Health: ${result[ToolName.DependencyHealth].results?.length || 0} issues
412
+ `;
413
+ }
414
+ if (result[ToolName.AiSignalClarity]) {
415
+ output += `\u{1F9E0} AI Signal Clarity: ${result[ToolName.AiSignalClarity].summary?.totalSignals || 0} signals
416
+ `;
417
+ }
418
+ if (result[ToolName.AgentGrounding]) {
419
+ output += `\u{1F9ED} Agent Grounding: ${result[ToolName.AgentGrounding].results?.length || 0} issues
420
+ `;
421
+ }
422
+ if (result[ToolName.TestabilityIndex]) {
423
+ output += `\u{1F9EA} Testability Index: ${result[ToolName.TestabilityIndex].results?.length || 0} issues
424
+ `;
425
+ }
426
+ if (result[ToolName.ChangeAmplification]) {
427
+ output += `\u{1F4A5} Change Amplification: ${result[ToolName.ChangeAmplification].summary?.totalIssues || 0} cascading risks
428
+ `;
429
+ }
430
+ return output;
431
+ }
432
+
433
+ export {
434
+ __require,
435
+ analyzeUnified,
436
+ scoreUnified,
437
+ generateUnifiedSummary
438
+ };