@aiready/cli 0.12.10 → 0.12.11

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