@aiready/cli 0.12.9 → 0.12.10

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.
@@ -0,0 +1,277 @@
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 {
10
+ ToolRegistry,
11
+ ToolName,
12
+ calculateOverallScore,
13
+ calculateTokenBudget,
14
+ GLOBAL_SCAN_OPTIONS
15
+ } from "@aiready/core";
16
+ import "@aiready/pattern-detect";
17
+ import "@aiready/context-analyzer";
18
+ import "@aiready/consistency";
19
+ import "@aiready/ai-signal-clarity";
20
+ import "@aiready/agent-grounding";
21
+ import "@aiready/testability";
22
+ import "@aiready/doc-drift";
23
+ import "@aiready/deps";
24
+ import "@aiready/change-amplification";
25
+ var TOOL_PACKAGE_MAP = {
26
+ [ToolName.PatternDetect]: "@aiready/pattern-detect",
27
+ [ToolName.ContextAnalyzer]: "@aiready/context-analyzer",
28
+ [ToolName.NamingConsistency]: "@aiready/consistency",
29
+ [ToolName.AiSignalClarity]: "@aiready/ai-signal-clarity",
30
+ [ToolName.AgentGrounding]: "@aiready/agent-grounding",
31
+ [ToolName.TestabilityIndex]: "@aiready/testability",
32
+ [ToolName.DocDrift]: "@aiready/doc-drift",
33
+ [ToolName.DependencyHealth]: "@aiready/deps",
34
+ [ToolName.ChangeAmplification]: "@aiready/change-amplification",
35
+ // Aliases handled by registry
36
+ patterns: "@aiready/pattern-detect",
37
+ duplicates: "@aiready/pattern-detect",
38
+ context: "@aiready/context-analyzer",
39
+ fragmentation: "@aiready/context-analyzer",
40
+ consistency: "@aiready/consistency",
41
+ "ai-signal": "@aiready/ai-signal-clarity",
42
+ grounding: "@aiready/agent-grounding",
43
+ testability: "@aiready/testability",
44
+ "deps-health": "@aiready/deps",
45
+ "change-amp": "@aiready/change-amplification"
46
+ };
47
+ function sanitizeToolConfig(config) {
48
+ if (!config || typeof config !== "object") return config;
49
+ const sanitized = { ...config };
50
+ GLOBAL_SCAN_OPTIONS.forEach((key) => {
51
+ if (key !== "rootDir") {
52
+ delete sanitized[key];
53
+ }
54
+ });
55
+ return sanitized;
56
+ }
57
+ async function analyzeUnified(options) {
58
+ const startTime = Date.now();
59
+ const requestedTools = options.tools || [
60
+ "patterns",
61
+ "context",
62
+ "consistency"
63
+ ];
64
+ const result = {
65
+ summary: {
66
+ totalIssues: 0,
67
+ criticalIssues: 0,
68
+ // Added as per instruction
69
+ majorIssues: 0,
70
+ // Added as per instruction
71
+ totalFiles: 0,
72
+ toolsRun: [],
73
+ executionTime: 0,
74
+ config: options,
75
+ toolConfigs: {}
76
+ }
77
+ };
78
+ for (const toolName of requestedTools) {
79
+ let provider = ToolRegistry.find(toolName);
80
+ if (!provider) {
81
+ const packageName = TOOL_PACKAGE_MAP[toolName] || (toolName.startsWith("@aiready/") ? toolName : `@aiready/${toolName}`);
82
+ try {
83
+ await import(packageName);
84
+ provider = ToolRegistry.find(toolName);
85
+ if (provider) {
86
+ console.log(
87
+ `\u2705 Successfully loaded tool provider: ${toolName} from ${packageName}`
88
+ );
89
+ } else {
90
+ console.log(
91
+ `\u26A0\uFE0F Loaded ${packageName} but provider ${toolName} still not found in registry.`
92
+ );
93
+ }
94
+ } catch (err) {
95
+ console.log(
96
+ `\u274C Failed to dynamically load tool ${toolName} (${packageName}):`,
97
+ err.message
98
+ );
99
+ }
100
+ }
101
+ if (!provider) {
102
+ console.warn(
103
+ `\u26A0\uFE0F Warning: Tool provider for '${toolName}' not found. Skipping.`
104
+ );
105
+ continue;
106
+ }
107
+ try {
108
+ const sanitizedConfig = { ...options };
109
+ delete sanitizedConfig.onProgress;
110
+ delete sanitizedConfig.progressCallback;
111
+ const toolOptions = {
112
+ rootDir: options.rootDir
113
+ // Always include rootDir
114
+ };
115
+ GLOBAL_SCAN_OPTIONS.forEach((key) => {
116
+ if (key in options && key !== "toolConfigs") {
117
+ toolOptions[key] = options[key];
118
+ }
119
+ });
120
+ if (options.toolConfigs?.[provider.id]) {
121
+ Object.assign(toolOptions, options.toolConfigs[provider.id]);
122
+ } else if (options[provider.id]) {
123
+ Object.assign(toolOptions, options[provider.id]);
124
+ }
125
+ toolOptions.onProgress = (processed, total, message) => {
126
+ if (options.progressCallback) {
127
+ options.progressCallback({
128
+ tool: provider.id,
129
+ processed,
130
+ total,
131
+ message
132
+ });
133
+ }
134
+ };
135
+ const output = await provider.analyze(toolOptions);
136
+ if (output.metadata) {
137
+ output.metadata.config = sanitizeToolConfig(toolOptions);
138
+ }
139
+ if (options.progressCallback) {
140
+ options.progressCallback({ tool: provider.id, data: output });
141
+ }
142
+ result[provider.id] = output;
143
+ result.summary.toolsRun.push(provider.id);
144
+ if (output.summary?.config) {
145
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
146
+ output.summary.config
147
+ );
148
+ } else if (output.metadata?.config) {
149
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
150
+ output.metadata.config
151
+ );
152
+ } else {
153
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(toolOptions);
154
+ }
155
+ const toolFiles = output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
156
+ if (toolFiles > result.summary.totalFiles) {
157
+ result.summary.totalFiles = toolFiles;
158
+ }
159
+ const issueCount = output.results.reduce(
160
+ (sum, file) => sum + (file.issues?.length || 0),
161
+ 0
162
+ );
163
+ result.summary.totalIssues += issueCount;
164
+ if (provider.alias && Array.isArray(provider.alias)) {
165
+ for (const alias of provider.alias) {
166
+ if (!result[alias]) {
167
+ result[alias] = output;
168
+ }
169
+ }
170
+ }
171
+ const camelCaseId = provider.id.replace(
172
+ /-([a-z])/g,
173
+ (g) => g[1].toUpperCase()
174
+ );
175
+ if (camelCaseId !== provider.id && !result[camelCaseId]) {
176
+ result[camelCaseId] = output;
177
+ }
178
+ } catch (err) {
179
+ console.error(`\u274C Error running tool '${provider.id}':`, err);
180
+ }
181
+ }
182
+ result.summary.config = {
183
+ ...options,
184
+ toolConfigs: result.summary.toolConfigs
185
+ };
186
+ result.summary.executionTime = Date.now() - startTime;
187
+ return result;
188
+ }
189
+ async function scoreUnified(results, options) {
190
+ const toolScores = /* @__PURE__ */ new Map();
191
+ for (const toolId of results.summary.toolsRun) {
192
+ const provider = ToolRegistry.get(toolId);
193
+ if (!provider) continue;
194
+ const output = results[toolId];
195
+ if (!output) continue;
196
+ try {
197
+ const toolScore = provider.score(output, options);
198
+ if (!toolScore.tokenBudget) {
199
+ if (toolId === ToolName.PatternDetect && output.duplicates) {
200
+ const wastedTokens = output.duplicates.reduce(
201
+ (sum, d) => sum + (d.tokenCost || 0),
202
+ 0
203
+ );
204
+ toolScore.tokenBudget = calculateTokenBudget({
205
+ totalContextTokens: wastedTokens * 2,
206
+ wastedTokens: {
207
+ duplication: wastedTokens,
208
+ fragmentation: 0,
209
+ chattiness: 0
210
+ }
211
+ });
212
+ } else if (toolId === ToolName.ContextAnalyzer && output.summary) {
213
+ toolScore.tokenBudget = calculateTokenBudget({
214
+ totalContextTokens: output.summary.totalTokens,
215
+ wastedTokens: {
216
+ duplication: 0,
217
+ fragmentation: output.summary.totalPotentialSavings || 0,
218
+ chattiness: 0
219
+ }
220
+ });
221
+ }
222
+ }
223
+ toolScores.set(toolId, toolScore);
224
+ } catch (err) {
225
+ console.error(`\u274C Error scoring tool '${toolId}':`, err);
226
+ }
227
+ }
228
+ if (toolScores.size === 0) {
229
+ return {
230
+ overall: 0,
231
+ rating: "Critical",
232
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
233
+ toolsUsed: [],
234
+ breakdown: [],
235
+ calculation: {
236
+ formula: "0 / 0 = 0",
237
+ weights: {},
238
+ normalized: "0 / 0 = 0"
239
+ }
240
+ };
241
+ }
242
+ return calculateOverallScore(toolScores, options, void 0);
243
+ }
244
+ function generateUnifiedSummary(result) {
245
+ const { summary } = result;
246
+ let output = `\u{1F680} AIReady Analysis Complete
247
+
248
+ `;
249
+ output += `\u{1F4CA} Summary:
250
+ `;
251
+ output += ` Tools run: ${summary.toolsRun.join(", ")}
252
+ `;
253
+ output += ` Total issues found: ${summary.totalIssues}
254
+ `;
255
+ output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
256
+
257
+ `;
258
+ for (const provider of ToolRegistry.getAll()) {
259
+ const toolResult = result[provider.id];
260
+ if (toolResult) {
261
+ const issueCount = toolResult.results.reduce(
262
+ (sum, r) => sum + (r.issues?.length || 0),
263
+ 0
264
+ );
265
+ output += `\u2022 ${provider.id}: ${issueCount} issues
266
+ `;
267
+ }
268
+ }
269
+ return output;
270
+ }
271
+
272
+ export {
273
+ __require,
274
+ analyzeUnified,
275
+ scoreUnified,
276
+ generateUnifiedSummary
277
+ };
package/dist/cli.js CHANGED
@@ -68,6 +68,16 @@ var TOOL_PACKAGE_MAP = {
68
68
  "deps-health": "@aiready/deps",
69
69
  "change-amp": "@aiready/change-amplification"
70
70
  };
71
+ function sanitizeToolConfig(config) {
72
+ if (!config || typeof config !== "object") return config;
73
+ const sanitized = { ...config };
74
+ import_core.GLOBAL_SCAN_OPTIONS.forEach((key) => {
75
+ if (key !== "rootDir") {
76
+ delete sanitized[key];
77
+ }
78
+ });
79
+ return sanitized;
80
+ }
71
81
  async function analyzeUnified(options) {
72
82
  const startTime = Date.now();
73
83
  const requestedTools = options.tools || [
@@ -85,8 +95,8 @@ async function analyzeUnified(options) {
85
95
  totalFiles: 0,
86
96
  toolsRun: [],
87
97
  executionTime: 0,
88
- config: options
89
- // Added as per instruction
98
+ config: options,
99
+ toolConfigs: {}
90
100
  }
91
101
  };
92
102
  for (const toolName of requestedTools) {
@@ -122,27 +132,50 @@ async function analyzeUnified(options) {
122
132
  const sanitizedConfig = { ...options };
123
133
  delete sanitizedConfig.onProgress;
124
134
  delete sanitizedConfig.progressCallback;
125
- const output = await provider.analyze({
126
- ...options,
127
- onProgress: (processed, total, message) => {
128
- if (options.progressCallback) {
129
- options.progressCallback({
130
- tool: provider.id,
131
- processed,
132
- total,
133
- message
134
- });
135
- }
135
+ const toolOptions = {
136
+ rootDir: options.rootDir
137
+ // Always include rootDir
138
+ };
139
+ import_core.GLOBAL_SCAN_OPTIONS.forEach((key) => {
140
+ if (key in options && key !== "toolConfigs") {
141
+ toolOptions[key] = options[key];
136
142
  }
137
143
  });
144
+ if (options.toolConfigs?.[provider.id]) {
145
+ Object.assign(toolOptions, options.toolConfigs[provider.id]);
146
+ } else if (options[provider.id]) {
147
+ Object.assign(toolOptions, options[provider.id]);
148
+ }
149
+ toolOptions.onProgress = (processed, total, message) => {
150
+ if (options.progressCallback) {
151
+ options.progressCallback({
152
+ tool: provider.id,
153
+ processed,
154
+ total,
155
+ message
156
+ });
157
+ }
158
+ };
159
+ const output = await provider.analyze(toolOptions);
138
160
  if (output.metadata) {
139
- output.metadata.config = sanitizedConfig;
161
+ output.metadata.config = sanitizeToolConfig(toolOptions);
140
162
  }
141
163
  if (options.progressCallback) {
142
164
  options.progressCallback({ tool: provider.id, data: output });
143
165
  }
144
166
  result[provider.id] = output;
145
167
  result.summary.toolsRun.push(provider.id);
168
+ if (output.summary?.config) {
169
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
170
+ output.summary.config
171
+ );
172
+ } else if (output.metadata?.config) {
173
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
174
+ output.metadata.config
175
+ );
176
+ } else {
177
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(toolOptions);
178
+ }
146
179
  const toolFiles = output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
147
180
  if (toolFiles > result.summary.totalFiles) {
148
181
  result.summary.totalFiles = toolFiles;
@@ -170,6 +203,10 @@ async function analyzeUnified(options) {
170
203
  console.error(`\u274C Error running tool '${provider.id}':`, err);
171
204
  }
172
205
  }
206
+ result.summary.config = {
207
+ ...options,
208
+ toolConfigs: result.summary.toolConfigs
209
+ };
173
210
  result.summary.executionTime = Date.now() - startTime;
174
211
  return result;
175
212
  }
package/dist/cli.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  __require,
4
4
  analyzeUnified,
5
5
  scoreUnified
6
- } from "./chunk-L4MJHD72.mjs";
6
+ } from "./chunk-YNGTO2UX.mjs";
7
7
 
8
8
  // src/cli.ts
9
9
  import { Command } from "commander";
package/dist/index.js CHANGED
@@ -57,6 +57,16 @@ var TOOL_PACKAGE_MAP = {
57
57
  "deps-health": "@aiready/deps",
58
58
  "change-amp": "@aiready/change-amplification"
59
59
  };
60
+ function sanitizeToolConfig(config) {
61
+ if (!config || typeof config !== "object") return config;
62
+ const sanitized = { ...config };
63
+ import_core.GLOBAL_SCAN_OPTIONS.forEach((key) => {
64
+ if (key !== "rootDir") {
65
+ delete sanitized[key];
66
+ }
67
+ });
68
+ return sanitized;
69
+ }
60
70
  async function analyzeUnified(options) {
61
71
  const startTime = Date.now();
62
72
  const requestedTools = options.tools || [
@@ -74,8 +84,8 @@ async function analyzeUnified(options) {
74
84
  totalFiles: 0,
75
85
  toolsRun: [],
76
86
  executionTime: 0,
77
- config: options
78
- // Added as per instruction
87
+ config: options,
88
+ toolConfigs: {}
79
89
  }
80
90
  };
81
91
  for (const toolName of requestedTools) {
@@ -111,27 +121,50 @@ async function analyzeUnified(options) {
111
121
  const sanitizedConfig = { ...options };
112
122
  delete sanitizedConfig.onProgress;
113
123
  delete sanitizedConfig.progressCallback;
114
- const output = await provider.analyze({
115
- ...options,
116
- onProgress: (processed, total, message) => {
117
- if (options.progressCallback) {
118
- options.progressCallback({
119
- tool: provider.id,
120
- processed,
121
- total,
122
- message
123
- });
124
- }
124
+ const toolOptions = {
125
+ rootDir: options.rootDir
126
+ // Always include rootDir
127
+ };
128
+ import_core.GLOBAL_SCAN_OPTIONS.forEach((key) => {
129
+ if (key in options && key !== "toolConfigs") {
130
+ toolOptions[key] = options[key];
125
131
  }
126
132
  });
133
+ if (options.toolConfigs?.[provider.id]) {
134
+ Object.assign(toolOptions, options.toolConfigs[provider.id]);
135
+ } else if (options[provider.id]) {
136
+ Object.assign(toolOptions, options[provider.id]);
137
+ }
138
+ toolOptions.onProgress = (processed, total, message) => {
139
+ if (options.progressCallback) {
140
+ options.progressCallback({
141
+ tool: provider.id,
142
+ processed,
143
+ total,
144
+ message
145
+ });
146
+ }
147
+ };
148
+ const output = await provider.analyze(toolOptions);
127
149
  if (output.metadata) {
128
- output.metadata.config = sanitizedConfig;
150
+ output.metadata.config = sanitizeToolConfig(toolOptions);
129
151
  }
130
152
  if (options.progressCallback) {
131
153
  options.progressCallback({ tool: provider.id, data: output });
132
154
  }
133
155
  result[provider.id] = output;
134
156
  result.summary.toolsRun.push(provider.id);
157
+ if (output.summary?.config) {
158
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
159
+ output.summary.config
160
+ );
161
+ } else if (output.metadata?.config) {
162
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
163
+ output.metadata.config
164
+ );
165
+ } else {
166
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(toolOptions);
167
+ }
135
168
  const toolFiles = output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
136
169
  if (toolFiles > result.summary.totalFiles) {
137
170
  result.summary.totalFiles = toolFiles;
@@ -159,6 +192,10 @@ async function analyzeUnified(options) {
159
192
  console.error(`\u274C Error running tool '${provider.id}':`, err);
160
193
  }
161
194
  }
195
+ result.summary.config = {
196
+ ...options,
197
+ toolConfigs: result.summary.toolConfigs
198
+ };
162
199
  result.summary.executionTime = Date.now() - startTime;
163
200
  return result;
164
201
  }
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  analyzeUnified,
3
3
  generateUnifiedSummary,
4
4
  scoreUnified
5
- } from "./chunk-L4MJHD72.mjs";
5
+ } from "./chunk-YNGTO2UX.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.12.9",
3
+ "version": "0.12.10",
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/agent-grounding": "0.11.9",
15
- "@aiready/consistency": "0.18.9",
16
- "@aiready/context-analyzer": "0.19.9",
17
- "@aiready/deps": "0.11.9",
18
- "@aiready/core": "0.21.9",
19
- "@aiready/doc-drift": "0.11.9",
20
- "@aiready/ai-signal-clarity": "0.11.9",
21
- "@aiready/visualizer": "0.4.9",
22
- "@aiready/pattern-detect": "0.14.9",
23
- "@aiready/change-amplification": "0.11.9",
24
- "@aiready/testability": "0.4.9"
14
+ "@aiready/agent-grounding": "0.11.10",
15
+ "@aiready/context-analyzer": "0.19.10",
16
+ "@aiready/deps": "0.11.10",
17
+ "@aiready/consistency": "0.18.10",
18
+ "@aiready/doc-drift": "0.11.10",
19
+ "@aiready/core": "0.21.10",
20
+ "@aiready/pattern-detect": "0.14.10",
21
+ "@aiready/ai-signal-clarity": "0.11.10",
22
+ "@aiready/testability": "0.4.10",
23
+ "@aiready/change-amplification": "0.11.10",
24
+ "@aiready/visualizer": "0.4.10"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/node": "^24.0.0",