@aiready/cli 0.14.24 → 0.14.26

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
@@ -20,11 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ ScoringOrchestrator: () => ScoringOrchestrator,
24
+ TOOL_PACKAGE_MAP: () => TOOL_PACKAGE_MAP,
25
+ UnifiedOrchestrator: () => UnifiedOrchestrator,
23
26
  analyzeUnified: () => analyzeUnified,
24
27
  generateUnifiedSummary: () => generateUnifiedSummary,
25
28
  scoreUnified: () => scoreUnified
26
29
  });
27
30
  module.exports = __toCommonJS(index_exports);
31
+
32
+ // src/orchestrator.ts
28
33
  var import_core = require("@aiready/core");
29
34
  var TOOL_PACKAGE_MAP = {
30
35
  [import_core.ToolName.PatternDetect]: "@aiready/pattern-detect",
@@ -48,216 +53,257 @@ var TOOL_PACKAGE_MAP = {
48
53
  "deps-health": "@aiready/deps",
49
54
  "change-amp": "@aiready/change-amplification"
50
55
  };
51
- function sanitizeConfigRecursive(obj) {
52
- if (!obj || typeof obj !== "object" || Array.isArray(obj)) return obj;
53
- const sanitized = {};
54
- const infraToStrip = [
55
- "rootDir",
56
- "onProgress",
57
- "progressCallback",
58
- "streamResults",
59
- "batchSize",
60
- "useSmartDefaults"
61
- ];
62
- for (const [key, value] of Object.entries(obj)) {
63
- if (infraToStrip.includes(key)) continue;
64
- if (typeof value === "object" && value !== null && !Array.isArray(value)) {
65
- sanitized[key] = sanitizeConfigRecursive(value);
66
- } else {
67
- sanitized[key] = value;
68
- }
56
+ var UnifiedOrchestrator = class {
57
+ /**
58
+ * Initialize orchestrator with a tool registry.
59
+ * Injection pattern helps with testability and AI readiness score.
60
+ */
61
+ constructor(registry = import_core.ToolRegistry) {
62
+ this.registry = registry;
69
63
  }
70
- return sanitized;
71
- }
72
- function sanitizeToolConfig(config) {
73
- return sanitizeConfigRecursive(config);
74
- }
75
- async function analyzeUnified(options) {
76
- await (0, import_core.initializeParsers)();
77
- const startTime = Date.now();
78
- const requestedTools = options.tools ?? [
79
- "patterns",
80
- "context",
81
- "consistency"
82
- ];
83
- const result = {
84
- summary: {
85
- totalIssues: 0,
86
- criticalIssues: 0,
87
- // Added as per instruction
88
- majorIssues: 0,
89
- // Added as per instruction
90
- totalFiles: 0,
91
- toolsRun: [],
92
- executionTime: 0,
93
- config: options,
94
- toolConfigs: {}
64
+ /**
65
+ * Deeply sanitizes a configuration object.
66
+ */
67
+ sanitizeConfig(obj) {
68
+ if (!obj || typeof obj !== "object" || Array.isArray(obj)) return obj;
69
+ const sanitized = {};
70
+ const infraToStrip = [
71
+ "rootDir",
72
+ "onProgress",
73
+ "progressCallback",
74
+ "streamResults",
75
+ "batchSize",
76
+ "useSmartDefaults"
77
+ ];
78
+ for (const [key, value] of Object.entries(obj)) {
79
+ if (infraToStrip.includes(key)) continue;
80
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
81
+ sanitized[key] = this.sanitizeConfig(value);
82
+ } else {
83
+ sanitized[key] = value;
84
+ }
95
85
  }
96
- };
97
- for (const toolName of requestedTools) {
98
- let provider = import_core.ToolRegistry.find(toolName);
99
- if (!provider) {
100
- const packageName = TOOL_PACKAGE_MAP[toolName] ?? (toolName.startsWith("@aiready/") ? toolName : `@aiready/${toolName}`);
101
- try {
102
- await import(packageName);
103
- provider = import_core.ToolRegistry.find(toolName);
104
- if (provider) {
105
- console.log(
106
- `\u2705 Successfully loaded tool provider: ${toolName} from ${packageName}`
107
- );
108
- } else {
86
+ return sanitized;
87
+ }
88
+ /**
89
+ * Performs the unified analysis.
90
+ */
91
+ async analyze(options) {
92
+ await (0, import_core.initializeParsers)();
93
+ const startTime = Date.now();
94
+ const requestedTools = options.tools ?? [
95
+ "patterns",
96
+ "context",
97
+ "consistency"
98
+ ];
99
+ const result = {
100
+ summary: {
101
+ totalIssues: 0,
102
+ criticalIssues: 0,
103
+ majorIssues: 0,
104
+ totalFiles: 0,
105
+ toolsRun: [],
106
+ executionTime: 0,
107
+ config: options,
108
+ toolConfigs: {}
109
+ }
110
+ };
111
+ for (const toolName of requestedTools) {
112
+ let provider = this.registry.find(toolName);
113
+ if (!provider) {
114
+ const packageName = TOOL_PACKAGE_MAP[toolName] ?? (toolName.startsWith("@aiready/") ? toolName : `@aiready/${toolName}`);
115
+ try {
116
+ await import(packageName);
117
+ provider = this.registry.find(toolName);
118
+ } catch (err) {
109
119
  console.log(
110
- `\u26A0\uFE0F Loaded ${packageName} but provider ${toolName} still not found in registry.`
120
+ `\u274C Failed to dynamically load tool ${toolName} (${packageName}):`,
121
+ err.message
111
122
  );
112
123
  }
113
- } catch (err) {
114
- console.log(
115
- `\u274C Failed to dynamically load tool ${toolName} (${packageName}):`,
116
- err.message
124
+ }
125
+ if (!provider) {
126
+ console.warn(
127
+ `\u26A0\uFE0F Warning: Tool provider for '${toolName}' not found. Skipping.`
117
128
  );
129
+ continue;
118
130
  }
119
- }
120
- if (!provider) {
121
- console.warn(
122
- `\u26A0\uFE0F Warning: Tool provider for '${toolName}' not found. Skipping.`
123
- );
124
- continue;
125
- }
126
- try {
127
- const sanitizedOptions = { ...options };
128
- delete sanitizedOptions.onProgress;
129
- delete sanitizedOptions.progressCallback;
130
- const toolOptions = {
131
- rootDir: options.rootDir
132
- // Always include rootDir
133
- };
134
- [...import_core.GLOBAL_INFRA_OPTIONS, ...import_core.COMMON_FINE_TUNING_OPTIONS].forEach(
135
- (key) => {
136
- if (key in options && key !== "toolConfigs" && key !== "tools") {
137
- toolOptions[key] = options[key];
131
+ try {
132
+ const toolOptions = {
133
+ rootDir: options.rootDir
134
+ };
135
+ [...import_core.GLOBAL_INFRA_OPTIONS, ...import_core.COMMON_FINE_TUNING_OPTIONS].forEach(
136
+ (key) => {
137
+ if (key in options && key !== "toolConfigs" && key !== "tools") {
138
+ toolOptions[key] = options[key];
139
+ }
138
140
  }
141
+ );
142
+ if (options.toolConfigs?.[provider.id]) {
143
+ Object.assign(toolOptions, options.toolConfigs[provider.id]);
144
+ } else if (options.tools && !Array.isArray(options.tools) && typeof options.tools === "object" && options.tools[provider.id]) {
145
+ Object.assign(toolOptions, options.tools[provider.id]);
146
+ }
147
+ toolOptions.onProgress = (processed, total, msg) => {
148
+ if (options.progressCallback) {
149
+ options.progressCallback({
150
+ tool: provider.id,
151
+ processed,
152
+ total,
153
+ message: msg
154
+ });
155
+ }
156
+ };
157
+ const output = await provider.analyze(toolOptions);
158
+ if (output.metadata) {
159
+ output.metadata.config = this.sanitizeConfig(toolOptions);
139
160
  }
140
- );
141
- if (options.toolConfigs?.[provider.id]) {
142
- Object.assign(toolOptions, options.toolConfigs[provider.id]);
143
- } else if (options.tools && !Array.isArray(options.tools) && typeof options.tools === "object" && options.tools[provider.id]) {
144
- Object.assign(toolOptions, options.tools[provider.id]);
145
- } else if (options[provider.id]) {
146
- Object.assign(toolOptions, options[provider.id]);
147
- }
148
- toolOptions.onProgress = (processed, total, message) => {
149
161
  if (options.progressCallback) {
150
- options.progressCallback({
151
- tool: provider.id,
152
- processed,
153
- total,
154
- message
155
- });
162
+ options.progressCallback({ tool: provider.id, data: output });
156
163
  }
157
- };
158
- const output = await provider.analyze(toolOptions);
159
- if (output.metadata) {
160
- output.metadata.config = sanitizeToolConfig(toolOptions);
161
- }
162
- if (options.progressCallback) {
163
- options.progressCallback({ tool: provider.id, data: output });
164
- }
165
- result[provider.id] = output;
166
- result.summary.toolsRun.push(provider.id);
167
- if (output.summary?.config) {
168
- result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
169
- output.summary.config
170
- );
171
- } else if (output.metadata?.config) {
172
- result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
173
- output.metadata.config
164
+ result[provider.id] = output;
165
+ result.summary.toolsRun.push(provider.id);
166
+ const toolConfig = output.summary?.config ?? output.metadata?.config ?? toolOptions;
167
+ result.summary.toolConfigs[provider.id] = this.sanitizeConfig(toolConfig);
168
+ const toolFiles = output.summary?.totalFiles ?? output.summary?.filesAnalyzed ?? 0;
169
+ if (toolFiles > result.summary.totalFiles) {
170
+ result.summary.totalFiles = toolFiles;
171
+ }
172
+ const issueCount = output.results.reduce(
173
+ (sum, file) => sum + (file.issues?.length ?? 0),
174
+ 0
174
175
  );
175
- } else {
176
- result.summary.toolConfigs[provider.id] = sanitizeToolConfig(toolOptions);
177
- }
178
- const toolFiles = output.summary?.totalFiles ?? output.summary?.filesAnalyzed ?? 0;
179
- if (toolFiles > result.summary.totalFiles) {
180
- result.summary.totalFiles = toolFiles;
176
+ result.summary.totalIssues += issueCount;
177
+ } catch (err) {
178
+ console.error(`\u274C Error running tool '${provider.id}':`, err);
181
179
  }
182
- const issueCount = output.results.reduce(
183
- (sum, file) => sum + (file.issues?.length ?? 0),
184
- 0
185
- );
186
- result.summary.totalIssues += issueCount;
187
- } catch (err) {
188
- console.error(`\u274C Error running tool '${provider.id}':`, err);
189
180
  }
181
+ result.summary.config = this.sanitizeConfig({
182
+ scan: {
183
+ tools: requestedTools,
184
+ include: options.include,
185
+ exclude: options.exclude
186
+ },
187
+ tools: result.summary.toolConfigs
188
+ });
189
+ result.summary.executionTime = Date.now() - startTime;
190
+ this.applyLegacyKeys(result);
191
+ return result;
190
192
  }
191
- result.summary.config = sanitizeConfigRecursive({
192
- scan: {
193
- tools: requestedTools,
194
- include: options.include,
195
- exclude: options.exclude
196
- },
197
- // Use 'tools' for tool-specific configurations to match AIReadyConfig
198
- tools: result.summary.toolConfigs
199
- });
200
- result.summary.executionTime = Date.now() - startTime;
201
- const keyMappings = {
202
- "pattern-detect": ["patternDetect", "patterns"],
203
- "context-analyzer": ["contextAnalyzer", "context"],
204
- "naming-consistency": ["namingConsistency", "consistency"],
205
- "ai-signal-clarity": ["aiSignalClarity"],
206
- "agent-grounding": ["agentGrounding"],
207
- "testability-index": ["testabilityIndex", "testability"],
208
- "doc-drift": ["docDrift"],
209
- "dependency-health": ["dependencyHealth", "deps"],
210
- "change-amplification": ["changeAmplification"]
211
- };
212
- for (const [kebabKey, aliases] of Object.entries(keyMappings)) {
213
- if (result[kebabKey]) {
214
- for (const alias of aliases) {
215
- result[alias] = result[kebabKey];
193
+ applyLegacyKeys(result) {
194
+ const keyMappings = {
195
+ "pattern-detect": ["patternDetect", "patterns"],
196
+ "context-analyzer": ["contextAnalyzer", "context"],
197
+ "naming-consistency": ["namingConsistency", "consistency"],
198
+ "ai-signal-clarity": ["aiSignalClarity"],
199
+ "agent-grounding": ["agentGrounding"],
200
+ "testability-index": ["testabilityIndex", "testability"],
201
+ "doc-drift": ["docDrift"],
202
+ "dependency-health": ["dependencyHealth", "deps"],
203
+ "change-amplification": ["changeAmplification"]
204
+ };
205
+ for (const [kebabKey, aliases] of Object.entries(keyMappings)) {
206
+ if (result[kebabKey]) {
207
+ for (const alias of aliases) {
208
+ result[alias] = result[kebabKey];
209
+ }
216
210
  }
217
211
  }
218
212
  }
219
- return result;
213
+ };
214
+ async function analyzeUnified(options) {
215
+ const orchestrator = new UnifiedOrchestrator(import_core.ToolRegistry);
216
+ return orchestrator.analyze(options);
220
217
  }
221
- async function scoreUnified(results, options) {
222
- const toolScores = /* @__PURE__ */ new Map();
223
- for (const toolId of results.summary.toolsRun) {
224
- const provider = import_core.ToolRegistry.get(toolId);
225
- if (!provider) continue;
226
- const output = results[toolId];
227
- if (!output) continue;
228
- try {
229
- const toolScore = provider.score(output, options);
230
- if (!toolScore.tokenBudget) {
231
- if (toolId === import_core.ToolName.PatternDetect && output.duplicates) {
232
- const wastedTokens = output.duplicates.reduce(
233
- (sum, d) => sum + (d.tokenCost ?? 0),
234
- 0
235
- );
236
- toolScore.tokenBudget = (0, import_core.calculateTokenBudget)({
237
- totalContextTokens: wastedTokens * 2,
238
- wastedTokens: {
239
- duplication: wastedTokens,
240
- fragmentation: 0,
241
- chattiness: 0
242
- }
243
- });
244
- } else if (toolId === import_core.ToolName.ContextAnalyzer && output.summary) {
245
- toolScore.tokenBudget = (0, import_core.calculateTokenBudget)({
246
- totalContextTokens: output.summary.totalTokens,
247
- wastedTokens: {
248
- duplication: 0,
249
- fragmentation: output.summary.totalPotentialSavings ?? 0,
250
- chattiness: 0
251
- }
252
- });
218
+
219
+ // src/scoring-orchestrator.ts
220
+ var import_core2 = require("@aiready/core");
221
+ var ScoringOrchestrator = class {
222
+ /**
223
+ * Initialize scoring orchestrator with a tool registry.
224
+ * Injection pattern helps with testability and AI readiness score.
225
+ */
226
+ constructor(registry = import_core2.ToolRegistry) {
227
+ this.registry = registry;
228
+ }
229
+ /**
230
+ * Calculates scores for all analyzed tools.
231
+ */
232
+ async score(results, options) {
233
+ const toolScores = /* @__PURE__ */ new Map();
234
+ for (const toolId of results.summary.toolsRun) {
235
+ const provider = this.registry.get(toolId);
236
+ if (!provider) continue;
237
+ const output = results[toolId];
238
+ if (!output) continue;
239
+ try {
240
+ const toolScore = provider.score(output, options);
241
+ if (!toolScore.tokenBudget) {
242
+ if (toolId === import_core2.ToolName.PatternDetect && output.duplicates) {
243
+ const wastedTokens = output.duplicates.reduce(
244
+ (sum, d) => sum + (d.tokenCost ?? 0),
245
+ 0
246
+ );
247
+ toolScore.tokenBudget = (0, import_core2.calculateTokenBudget)({
248
+ totalContextTokens: wastedTokens * 2,
249
+ wastedTokens: {
250
+ duplication: wastedTokens,
251
+ fragmentation: 0,
252
+ chattiness: 0
253
+ }
254
+ });
255
+ } else if (toolId === import_core2.ToolName.ContextAnalyzer && output.summary) {
256
+ toolScore.tokenBudget = (0, import_core2.calculateTokenBudget)({
257
+ totalContextTokens: output.summary.totalTokens,
258
+ wastedTokens: {
259
+ duplication: 0,
260
+ fragmentation: output.summary.totalPotentialSavings ?? 0,
261
+ chattiness: 0
262
+ }
263
+ });
264
+ }
253
265
  }
266
+ toolScores.set(toolId, toolScore);
267
+ } catch (err) {
268
+ console.error(`\u274C Error scoring tool '${toolId}':`, err);
269
+ }
270
+ }
271
+ if (toolScores.size === 0) {
272
+ return this.emptyScoringResult();
273
+ }
274
+ return (0, import_core2.calculateOverallScore)(toolScores, options, void 0);
275
+ }
276
+ /**
277
+ * Generate human-readable summary of unified results.
278
+ */
279
+ generateSummary(result) {
280
+ const { summary } = result;
281
+ let output = `\u{1F680} AIReady Analysis Complete
282
+
283
+ `;
284
+ output += `\u{1F4CA} Summary:
285
+ `;
286
+ output += ` Tools run: ${summary.toolsRun.join(", ")}
287
+ `;
288
+ output += ` Total issues found: ${summary.totalIssues}
289
+ `;
290
+ output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
291
+
292
+ `;
293
+ for (const provider of this.registry.getAll()) {
294
+ const toolResult = result[provider.id];
295
+ if (toolResult) {
296
+ const issueCount = toolResult.results.reduce(
297
+ (sum, r) => sum + (r.issues?.length ?? 0),
298
+ 0
299
+ );
300
+ output += `\u2022 ${provider.id}: ${issueCount} issues
301
+ `;
254
302
  }
255
- toolScores.set(toolId, toolScore);
256
- } catch (err) {
257
- console.error(`\u274C Error scoring tool '${toolId}':`, err);
258
303
  }
304
+ return output;
259
305
  }
260
- if (toolScores.size === 0) {
306
+ emptyScoringResult() {
261
307
  return {
262
308
  overall: 0,
263
309
  rating: "Critical",
@@ -271,37 +317,20 @@ async function scoreUnified(results, options) {
271
317
  }
272
318
  };
273
319
  }
274
- return (0, import_core.calculateOverallScore)(toolScores, options, void 0);
320
+ };
321
+ async function scoreUnified(results, options) {
322
+ const orchestrator = new ScoringOrchestrator(import_core2.ToolRegistry);
323
+ return orchestrator.score(results, options);
275
324
  }
276
325
  function generateUnifiedSummary(result) {
277
- const { summary } = result;
278
- let output = `\u{1F680} AIReady Analysis Complete
279
-
280
- `;
281
- output += `\u{1F4CA} Summary:
282
- `;
283
- output += ` Tools run: ${summary.toolsRun.join(", ")}
284
- `;
285
- output += ` Total issues found: ${summary.totalIssues}
286
- `;
287
- output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
288
-
289
- `;
290
- for (const provider of import_core.ToolRegistry.getAll()) {
291
- const toolResult = result[provider.id];
292
- if (toolResult) {
293
- const issueCount = toolResult.results.reduce(
294
- (sum, r) => sum + (r.issues?.length ?? 0),
295
- 0
296
- );
297
- output += `\u2022 ${provider.id}: ${issueCount} issues
298
- `;
299
- }
300
- }
301
- return output;
326
+ const orchestrator = new ScoringOrchestrator(import_core2.ToolRegistry);
327
+ return orchestrator.generateSummary(result);
302
328
  }
303
329
  // Annotate the CommonJS export names for ESM import in node:
304
330
  0 && (module.exports = {
331
+ ScoringOrchestrator,
332
+ TOOL_PACKAGE_MAP,
333
+ UnifiedOrchestrator,
305
334
  analyzeUnified,
306
335
  generateUnifiedSummary,
307
336
  scoreUnified
package/dist/index.mjs CHANGED
@@ -1,9 +1,15 @@
1
1
  import {
2
+ ScoringOrchestrator,
3
+ TOOL_PACKAGE_MAP,
4
+ UnifiedOrchestrator,
2
5
  analyzeUnified,
3
6
  generateUnifiedSummary,
4
7
  scoreUnified
5
- } from "./chunk-HUSUJEQJ.mjs";
8
+ } from "./chunk-SK6WW6HW.mjs";
6
9
  export {
10
+ ScoringOrchestrator,
11
+ TOOL_PACKAGE_MAP,
12
+ UnifiedOrchestrator,
7
13
  analyzeUnified,
8
14
  generateUnifiedSummary,
9
15
  scoreUnified
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/cli",
3
- "version": "0.14.24",
3
+ "version": "0.14.26",
4
4
  "description": "Assess and improve your codebase's AI-readiness. Get an AI Readiness Score (0-100) and detect semantic duplicates, context fragmentation, and naming inconsistencies.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -24,17 +24,17 @@
24
24
  "dependencies": {
25
25
  "chalk": "^5.3.0",
26
26
  "commander": "^14.0.0",
27
- "@aiready/agent-grounding": "0.13.21",
28
- "@aiready/consistency": "0.20.21",
29
- "@aiready/context-analyzer": "0.21.25",
30
- "@aiready/core": "0.23.22",
31
- "@aiready/deps": "0.13.22",
32
- "@aiready/change-amplification": "0.13.21",
33
- "@aiready/doc-drift": "0.13.21",
34
- "@aiready/ai-signal-clarity": "0.13.22",
35
- "@aiready/visualizer": "0.6.21",
36
- "@aiready/pattern-detect": "0.16.21",
37
- "@aiready/testability": "0.6.21"
27
+ "@aiready/agent-grounding": "0.13.23",
28
+ "@aiready/context-analyzer": "0.21.27",
29
+ "@aiready/consistency": "0.20.23",
30
+ "@aiready/core": "0.23.24",
31
+ "@aiready/deps": "0.13.24",
32
+ "@aiready/doc-drift": "0.13.23",
33
+ "@aiready/change-amplification": "0.13.23",
34
+ "@aiready/ai-signal-clarity": "0.13.24",
35
+ "@aiready/visualizer": "0.6.23",
36
+ "@aiready/pattern-detect": "0.16.23",
37
+ "@aiready/testability": "0.6.23"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^24.0.0",