@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.
package/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
@@ -35,339 +25,137 @@ __export(index_exports, {
35
25
  scoreUnified: () => scoreUnified
36
26
  });
37
27
  module.exports = __toCommonJS(index_exports);
38
- var import_pattern_detect = require("@aiready/pattern-detect");
39
- var import_context_analyzer = require("@aiready/context-analyzer");
40
- var import_consistency = require("@aiready/consistency");
41
28
  var import_core = require("@aiready/core");
42
- var severityOrder = {
43
- critical: 4,
44
- major: 3,
45
- minor: 2,
46
- info: 1
29
+ var TOOL_PACKAGE_MAP = {
30
+ [import_core.ToolName.PatternDetect]: "@aiready/pattern-detect",
31
+ [import_core.ToolName.ContextAnalyzer]: "@aiready/context-analyzer",
32
+ [import_core.ToolName.NamingConsistency]: "@aiready/consistency",
33
+ [import_core.ToolName.AiSignalClarity]: "@aiready/ai-signal-clarity",
34
+ [import_core.ToolName.AgentGrounding]: "@aiready/agent-grounding",
35
+ [import_core.ToolName.TestabilityIndex]: "@aiready/testability",
36
+ [import_core.ToolName.DocDrift]: "@aiready/doc-drift",
37
+ [import_core.ToolName.DependencyHealth]: "@aiready/deps",
38
+ [import_core.ToolName.ChangeAmplification]: "@aiready/change-amplification",
39
+ // Aliases handled by registry
40
+ patterns: "@aiready/pattern-detect",
41
+ context: "@aiready/context-analyzer",
42
+ consistency: "@aiready/consistency"
47
43
  };
48
- function sortBySeverity(results) {
49
- return results.map((file) => {
50
- const sortedIssues = [...file.issues].sort((a, b) => {
51
- const severityDiff = (severityOrder[b.severity] || 0) - (severityOrder[a.severity] || 0);
52
- if (severityDiff !== 0) return severityDiff;
53
- return (a.location?.line || 0) - (b.location?.line || 0);
54
- });
55
- return { ...file, issues: sortedIssues };
56
- }).sort((a, b) => {
57
- const aMaxSeverity = Math.max(
58
- ...a.issues.map((i) => severityOrder[i.severity] || 0),
59
- 0
60
- );
61
- const bMaxSeverity = Math.max(
62
- ...b.issues.map((i) => severityOrder[i.severity] || 0),
63
- 0
64
- );
65
- if (aMaxSeverity !== bMaxSeverity) {
66
- return bMaxSeverity - aMaxSeverity;
67
- }
68
- if (a.issues.length !== b.issues.length) {
69
- return b.issues.length - a.issues.length;
70
- }
71
- return a.fileName.localeCompare(b.fileName);
72
- });
73
- }
74
44
  async function analyzeUnified(options) {
75
45
  const startTime = Date.now();
76
- const tools = options.tools || ["patterns", "context", "consistency"];
46
+ const requestedTools = options.tools || [
47
+ "patterns",
48
+ "context",
49
+ "consistency"
50
+ ];
77
51
  const result = {
78
52
  summary: {
79
53
  totalIssues: 0,
80
- toolsRun: tools,
54
+ toolsRun: [],
81
55
  executionTime: 0
82
56
  }
83
57
  };
84
- if (tools.includes("patterns")) {
85
- const patternResult = await (0, import_pattern_detect.analyzePatterns)(options);
86
- if (options.progressCallback) {
87
- options.progressCallback({ tool: "patterns", data: patternResult });
88
- }
89
- result.patternDetect = {
90
- results: sortBySeverity(patternResult.results),
91
- summary: patternResult.summary || {},
92
- duplicates: patternResult.duplicates || []
93
- };
94
- result.summary.totalIssues += patternResult.results.reduce(
95
- (sum, file) => sum + file.issues.length,
96
- 0
97
- );
98
- }
99
- if (tools.includes("context")) {
100
- const contextResults = await (0, import_context_analyzer.analyzeContext)(options);
101
- if (options.progressCallback) {
102
- options.progressCallback({ tool: "context", data: contextResults });
103
- }
104
- const sorted = contextResults.sort((a, b) => {
105
- const severityDiff = (severityOrder[b.severity] || 0) - (severityOrder[a.severity] || 0);
106
- if (severityDiff !== 0) return severityDiff;
107
- if (a.tokenCost !== b.tokenCost) return b.tokenCost - a.tokenCost;
108
- return b.fragmentationScore - a.fragmentationScore;
109
- });
110
- const { generateSummary: genContextSummary } = await import("@aiready/context-analyzer");
111
- result.contextAnalyzer = {
112
- results: sorted,
113
- summary: genContextSummary(sorted)
114
- };
115
- result.summary.totalIssues += sorted.length;
116
- }
117
- if (tools.includes("consistency")) {
118
- const consistencyOptions = {
119
- rootDir: options.rootDir,
120
- include: options.include,
121
- exclude: options.exclude,
122
- ...options.consistency || {}
123
- };
124
- const report = await (0, import_consistency.analyzeConsistency)(consistencyOptions);
125
- if (options.progressCallback) {
126
- options.progressCallback({ tool: "consistency", data: report });
127
- }
128
- result.consistency = {
129
- results: report.results ? sortBySeverity(report.results) : [],
130
- summary: report.summary
131
- };
132
- result.summary.totalIssues += report.summary.totalIssues;
133
- }
134
- if (tools.includes("doc-drift")) {
135
- const { analyzeDocDrift } = await import("@aiready/doc-drift");
136
- const report = await analyzeDocDrift({
137
- rootDir: options.rootDir,
138
- include: options.include,
139
- exclude: options.exclude,
140
- onProgress: options.onProgress
141
- });
142
- if (options.progressCallback) {
143
- options.progressCallback({ tool: "doc-drift", data: report });
144
- }
145
- result.docDrift = {
146
- results: report.results || report.issues || [],
147
- summary: report.summary || {}
148
- };
149
- const issueCount = report.issues?.length || (report.results ? report.results.length : 0);
150
- result.summary.totalIssues += issueCount;
151
- }
152
- if (tools.includes("deps-health")) {
153
- const { analyzeDeps } = await import("@aiready/deps");
154
- const report = await analyzeDeps({
155
- rootDir: options.rootDir,
156
- include: options.include,
157
- exclude: options.exclude,
158
- onProgress: options.onProgress
159
- });
160
- if (options.progressCallback) {
161
- options.progressCallback({ tool: "deps-health", data: report });
162
- }
163
- result.dependencyHealth = {
164
- results: report.results || report.issues || [],
165
- summary: report.summary || {}
166
- };
167
- const issueCount = report.issues?.length || (report.results ? report.results.length : 0);
168
- result.summary.totalIssues += issueCount;
169
- }
170
- if (tools.includes("ai-signal-clarity")) {
171
- const { analyzeAiSignalClarity } = await import("@aiready/ai-signal-clarity");
172
- const report = await analyzeAiSignalClarity({
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: "ai-signal-clarity", data: report });
180
- }
181
- result.aiSignalClarity = {
182
- ...report,
183
- results: report.results || report.issues || [],
184
- summary: report.summary || {}
185
- };
186
- result.summary.totalIssues += (report.results || report.issues)?.reduce(
187
- (sum, r) => sum + (r.issues?.length || 1),
188
- 0
189
- ) || 0;
190
- }
191
- if (tools.includes("agent-grounding")) {
192
- const { analyzeAgentGrounding } = await import("@aiready/agent-grounding");
193
- const report = await analyzeAgentGrounding({
194
- rootDir: options.rootDir,
195
- include: options.include,
196
- exclude: options.exclude,
197
- onProgress: options.onProgress
198
- });
199
- if (options.progressCallback) {
200
- options.progressCallback({ tool: "agent-grounding", data: report });
201
- }
202
- result.agentGrounding = {
203
- ...report,
204
- results: report.results || report.issues || [],
205
- summary: report.summary || {}
206
- };
207
- result.summary.totalIssues += (report.issues || report.results || []).length;
208
- }
209
- if (tools.includes("testability")) {
210
- const { analyzeTestability } = await import("@aiready/testability");
211
- const report = await analyzeTestability({
212
- rootDir: options.rootDir,
213
- include: options.include,
214
- exclude: options.exclude,
215
- onProgress: options.onProgress
216
- });
217
- if (options.progressCallback) {
218
- options.progressCallback({ tool: "testability", data: report });
58
+ for (const toolName of requestedTools) {
59
+ let provider = import_core.ToolRegistry.find(toolName);
60
+ if (!provider) {
61
+ const packageName = TOOL_PACKAGE_MAP[toolName] || (toolName.startsWith("@aiready/") ? toolName : `@aiready/${toolName}`);
62
+ try {
63
+ await import(packageName);
64
+ provider = import_core.ToolRegistry.find(toolName);
65
+ if (provider) {
66
+ console.log(
67
+ `\u2705 Successfully loaded tool provider: ${toolName} from ${packageName}`
68
+ );
69
+ } else {
70
+ console.log(
71
+ `\u26A0\uFE0F Loaded ${packageName} but provider ${toolName} still not found in registry.`
72
+ );
73
+ }
74
+ } catch (err) {
75
+ console.log(
76
+ `\u274C Failed to dynamically load tool ${toolName} (${packageName}):`,
77
+ err.message
78
+ );
79
+ }
219
80
  }
220
- result.testability = {
221
- ...report,
222
- results: report.results || report.issues || [],
223
- summary: report.summary || {}
224
- };
225
- result.summary.totalIssues += (report.issues || report.results || []).length;
226
- }
227
- if (tools.includes("change-amplification")) {
228
- const { analyzeChangeAmplification } = await import("@aiready/change-amplification");
229
- const report = await analyzeChangeAmplification({
230
- rootDir: options.rootDir,
231
- include: options.include,
232
- exclude: options.exclude,
233
- onProgress: options.onProgress
234
- });
235
- if (options.progressCallback) {
236
- options.progressCallback({ tool: "change-amplification", data: report });
81
+ if (!provider) {
82
+ console.warn(
83
+ `\u26A0\uFE0F Warning: Tool provider for '${toolName}' not found. Skipping.`
84
+ );
85
+ continue;
237
86
  }
238
- result.changeAmplification = {
239
- results: report.results || [],
240
- summary: report.summary || {}
241
- };
242
- result.summary.totalIssues += report.summary?.totalIssues || 0;
243
- }
244
- result.summary.executionTime = Date.now() - startTime;
245
- return result;
246
- }
247
- async function scoreUnified(results, options) {
248
- const toolScores = /* @__PURE__ */ new Map();
249
- if (results.patternDetect) {
250
- const { calculatePatternScore } = await import("@aiready/pattern-detect");
251
87
  try {
252
- const patternScore = calculatePatternScore(
253
- results.patternDetect.duplicates,
254
- results.patternDetect.results?.length || 0
255
- );
256
- const wastedTokens = results.patternDetect.duplicates.reduce(
257
- (sum, d) => sum + (d.tokenCost || 0),
88
+ const output = await provider.analyze(options);
89
+ if (options.progressCallback) {
90
+ options.progressCallback({ tool: provider.id, data: output });
91
+ }
92
+ result[provider.id] = output;
93
+ result.summary.toolsRun.push(provider.id);
94
+ const issueCount = output.results.reduce(
95
+ (sum, file) => sum + (file.issues?.length || 0),
258
96
  0
259
97
  );
260
- patternScore.tokenBudget = (0, import_core.calculateTokenBudget)({
261
- totalContextTokens: wastedTokens * 2,
262
- // Estimated context
263
- wastedTokens: {
264
- duplication: wastedTokens,
265
- fragmentation: 0,
266
- chattiness: 0
98
+ result.summary.totalIssues += issueCount;
99
+ if (provider.alias && Array.isArray(provider.alias)) {
100
+ for (const alias of provider.alias) {
101
+ if (!result[alias]) {
102
+ result[alias] = output;
103
+ }
267
104
  }
268
- });
269
- toolScores.set("pattern-detect", patternScore);
105
+ }
106
+ const camelCaseId = provider.id.replace(
107
+ /-([a-z])/g,
108
+ (g) => g[1].toUpperCase()
109
+ );
110
+ if (camelCaseId !== provider.id && !result[camelCaseId]) {
111
+ result[camelCaseId] = output;
112
+ }
270
113
  } catch (err) {
271
- void err;
114
+ console.error(`\u274C Error running tool '${provider.id}':`, err);
272
115
  }
273
116
  }
274
- if (results.contextAnalyzer) {
275
- const { calculateContextScore } = await import("@aiready/context-analyzer");
117
+ result.summary.executionTime = Date.now() - startTime;
118
+ return result;
119
+ }
120
+ async function scoreUnified(results, options) {
121
+ const toolScores = /* @__PURE__ */ new Map();
122
+ for (const toolId of results.summary.toolsRun) {
123
+ const provider = import_core.ToolRegistry.get(toolId);
124
+ if (!provider) continue;
125
+ const output = results[toolId];
126
+ if (!output) continue;
276
127
  try {
277
- const ctxSummary = results.contextAnalyzer.summary;
278
- const contextScore = calculateContextScore(ctxSummary);
279
- contextScore.tokenBudget = (0, import_core.calculateTokenBudget)({
280
- totalContextTokens: ctxSummary.totalTokens,
281
- wastedTokens: {
282
- duplication: 0,
283
- fragmentation: ctxSummary.totalPotentialSavings || 0,
284
- chattiness: 0
128
+ const toolScore = provider.score(output, options);
129
+ if (!toolScore.tokenBudget) {
130
+ if (toolId === import_core.ToolName.PatternDetect && output.duplicates) {
131
+ const wastedTokens = output.duplicates.reduce(
132
+ (sum, d) => sum + (d.tokenCost || 0),
133
+ 0
134
+ );
135
+ toolScore.tokenBudget = (0, import_core.calculateTokenBudget)({
136
+ totalContextTokens: wastedTokens * 2,
137
+ wastedTokens: {
138
+ duplication: wastedTokens,
139
+ fragmentation: 0,
140
+ chattiness: 0
141
+ }
142
+ });
143
+ } else if (toolId === import_core.ToolName.ContextAnalyzer && output.summary) {
144
+ toolScore.tokenBudget = (0, import_core.calculateTokenBudget)({
145
+ totalContextTokens: output.summary.totalTokens,
146
+ wastedTokens: {
147
+ duplication: 0,
148
+ fragmentation: output.summary.totalPotentialSavings || 0,
149
+ chattiness: 0
150
+ }
151
+ });
285
152
  }
286
- });
287
- toolScores.set("context-analyzer", contextScore);
288
- } catch (err) {
289
- void err;
290
- }
291
- }
292
- if (results.consistency) {
293
- const { calculateConsistencyScore } = await import("@aiready/consistency");
294
- try {
295
- const issues = results.consistency.results?.flatMap((r) => r.issues) || [];
296
- const totalFiles = results.consistency.summary?.filesAnalyzed || 0;
297
- const consistencyScore = calculateConsistencyScore(issues, totalFiles);
298
- toolScores.set("consistency", consistencyScore);
299
- } catch (err) {
300
- void err;
301
- }
302
- }
303
- if (results.aiSignalClarity) {
304
- const { calculateAiSignalClarityScore } = await import("@aiready/ai-signal-clarity");
305
- try {
306
- const hrScore = calculateAiSignalClarityScore(results.aiSignalClarity);
307
- toolScores.set("ai-signal-clarity", hrScore);
308
- } catch (err) {
309
- void err;
310
- }
311
- }
312
- if (results.agentGrounding) {
313
- const { calculateGroundingScore } = await import("@aiready/agent-grounding");
314
- try {
315
- const agScore = calculateGroundingScore(results.agentGrounding);
316
- toolScores.set("agent-grounding", agScore);
317
- } catch (err) {
318
- void err;
319
- }
320
- }
321
- if (results.testability) {
322
- const { calculateTestabilityScore } = await import("@aiready/testability");
323
- try {
324
- const tbScore = calculateTestabilityScore(results.testability);
325
- toolScores.set("testability", tbScore);
153
+ }
154
+ toolScores.set(toolId, toolScore);
326
155
  } catch (err) {
327
- void err;
156
+ console.error(`\u274C Error scoring tool '${toolId}':`, err);
328
157
  }
329
158
  }
330
- if (results.docDrift) {
331
- toolScores.set("doc-drift", {
332
- toolName: "doc-drift",
333
- score: results.docDrift.summary.score || results.docDrift.summary.totalScore || 0,
334
- rawMetrics: results.docDrift.summary,
335
- factors: [],
336
- recommendations: (results.docDrift.summary.recommendations || []).map(
337
- (action) => ({
338
- action,
339
- estimatedImpact: 5,
340
- priority: "medium"
341
- })
342
- )
343
- });
344
- }
345
- if (results.dependencyHealth) {
346
- toolScores.set("dependency-health", {
347
- toolName: "dependency-health",
348
- score: results.dependencyHealth.summary.score || 0,
349
- rawMetrics: results.dependencyHealth.summary,
350
- factors: [],
351
- recommendations: (results.dependencyHealth.summary.recommendations || []).map((action) => ({
352
- action,
353
- estimatedImpact: 5,
354
- priority: "medium"
355
- }))
356
- });
357
- }
358
- if (results.changeAmplification) {
359
- toolScores.set("change-amplification", {
360
- toolName: "change-amplification",
361
- score: results.changeAmplification.summary.score || 0,
362
- rawMetrics: results.changeAmplification.summary,
363
- factors: [],
364
- recommendations: (results.changeAmplification.summary.recommendations || []).map((action) => ({
365
- action,
366
- estimatedImpact: 5,
367
- priority: "medium"
368
- }))
369
- });
370
- }
371
159
  if (toolScores.size === 0) {
372
160
  return {
373
161
  overall: 0,
@@ -398,41 +186,16 @@ function generateUnifiedSummary(result) {
398
186
  output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
399
187
 
400
188
  `;
401
- if (result.patternDetect) {
402
- output += `\u{1F50D} Pattern Analysis: ${result.patternDetect.results.length} issues
403
- `;
404
- }
405
- if (result.contextAnalyzer) {
406
- output += `\u{1F9E0} Context Analysis: ${result.contextAnalyzer.results.length} issues
407
- `;
408
- }
409
- if (result.consistency) {
410
- output += `\u{1F3F7}\uFE0F Consistency Analysis: ${result.consistency.summary.totalIssues} issues
411
- `;
412
- }
413
- if (result.docDrift) {
414
- output += `\u{1F4DD} Doc Drift Analysis: ${result.docDrift.results?.length || 0} issues
415
- `;
416
- }
417
- if (result.dependencyHealth) {
418
- output += `\u{1F4E6} Dependency Health: ${result.dependencyHealth.results?.length || 0} issues
419
- `;
420
- }
421
- if (result.aiSignalClarity) {
422
- output += `\u{1F9E0} AI Signal Clarity: ${result.aiSignalClarity.summary?.totalSignals || 0} signals
423
- `;
424
- }
425
- if (result.agentGrounding) {
426
- output += `\u{1F9ED} Agent Grounding: ${result.agentGrounding.results?.length || 0} issues
427
- `;
428
- }
429
- if (result.testability) {
430
- output += `\u{1F9EA} Testability Index: ${result.testability.results?.length || 0} issues
431
- `;
432
- }
433
- if (result.changeAmplification) {
434
- output += `\u{1F4A5} Change Amplification: ${result.changeAmplification.summary?.totalIssues || 0} cascading risks
189
+ for (const provider of import_core.ToolRegistry.getAll()) {
190
+ const toolResult = result[provider.id];
191
+ if (toolResult) {
192
+ const issueCount = toolResult.results.reduce(
193
+ (sum, r) => sum + (r.issues?.length || 0),
194
+ 0
195
+ );
196
+ output += `\u2022 ${provider.id}: ${issueCount} issues
435
197
  `;
198
+ }
436
199
  }
437
200
  return output;
438
201
  }
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  analyzeUnified,
3
3
  generateUnifiedSummary,
4
4
  scoreUnified
5
- } from "./chunk-R3O7QPKD.mjs";
5
+ } from "./chunk-N56YAZVN.mjs";
6
6
  export {
7
7
  analyzeUnified,
8
8
  generateUnifiedSummary,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/cli",
3
- "version": "0.10.4",
3
+ "version": "0.12.0",
4
4
  "description": "Unified CLI for AIReady analysis tools",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -11,17 +11,17 @@
11
11
  "dependencies": {
12
12
  "chalk": "^5.3.0",
13
13
  "commander": "^14.0.0",
14
- "@aiready/core": "0.19.3",
15
- "@aiready/agent-grounding": "0.9.3",
16
- "@aiready/consistency": "0.16.3",
17
- "@aiready/change-amplification": "0.9.3",
18
- "@aiready/context-analyzer": "0.17.3",
19
- "@aiready/deps": "0.9.3",
20
- "@aiready/visualizer": "0.2.4",
21
- "@aiready/pattern-detect": "0.12.3",
22
- "@aiready/ai-signal-clarity": "0.9.3",
23
- "@aiready/testability": "0.2.3",
24
- "@aiready/doc-drift": "0.9.3"
14
+ "@aiready/agent-grounding": "0.11.0",
15
+ "@aiready/context-analyzer": "0.19.0",
16
+ "@aiready/doc-drift": "0.11.0",
17
+ "@aiready/consistency": "0.18.0",
18
+ "@aiready/core": "0.21.0",
19
+ "@aiready/change-amplification": "0.11.0",
20
+ "@aiready/pattern-detect": "0.14.0",
21
+ "@aiready/ai-signal-clarity": "0.11.0",
22
+ "@aiready/testability": "0.4.0",
23
+ "@aiready/deps": "0.11.0",
24
+ "@aiready/visualizer": "0.4.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/node": "^24.0.0",