@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.
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ import {
3
3
  ToolName,
4
4
  calculateOverallScore,
5
5
  calculateTokenBudget,
6
+ GLOBAL_SCAN_OPTIONS,
6
7
  } from '@aiready/core';
7
8
  import type {
8
9
  AnalysisResult,
@@ -28,6 +29,7 @@ export type { ToolScoringOutput, ScoringResult };
28
29
  export interface UnifiedAnalysisOptions extends ScanOptions {
29
30
  rootDir: string;
30
31
  tools?: string[];
32
+ toolConfigs?: Record<string, any>;
31
33
  minSimilarity?: number;
32
34
  minLines?: number;
33
35
  maxCandidatesPerBlock?: number;
@@ -55,6 +57,7 @@ export interface UnifiedAnalysisResult {
55
57
  toolsRun: string[];
56
58
  executionTime: number;
57
59
  config?: any;
60
+ toolConfigs?: Record<string, any>;
58
61
  };
59
62
  scoring?: ScoringResult;
60
63
  }
@@ -86,6 +89,20 @@ const TOOL_PACKAGE_MAP: Record<string, string> = {
86
89
  'change-amp': '@aiready/change-amplification',
87
90
  };
88
91
 
92
+ /**
93
+ * Sanitize tool configuration by removing global options (except rootDir)
94
+ */
95
+ function sanitizeToolConfig(config: any): any {
96
+ if (!config || typeof config !== 'object') return config;
97
+ const sanitized = { ...config };
98
+ GLOBAL_SCAN_OPTIONS.forEach((key: string) => {
99
+ if (key !== 'rootDir') {
100
+ delete (sanitized as any)[key];
101
+ }
102
+ });
103
+ return sanitized;
104
+ }
105
+
89
106
  /**
90
107
  * AIReady Unified Analysis
91
108
  * Orchestrates all registered tools via the ToolRegistry.
@@ -108,7 +125,8 @@ export async function analyzeUnified(
108
125
  totalFiles: 0,
109
126
  toolsRun: [],
110
127
  executionTime: 0,
111
- config: options, // Added as per instruction
128
+ config: options,
129
+ toolConfigs: {},
112
130
  },
113
131
  };
114
132
 
@@ -153,23 +171,47 @@ export async function analyzeUnified(
153
171
  delete (sanitizedConfig as any).onProgress;
154
172
  delete (sanitizedConfig as any).progressCallback;
155
173
 
156
- const output = await provider.analyze({
157
- ...options,
158
- onProgress: (processed: number, total: number, message: string) => {
159
- if (options.progressCallback) {
160
- options.progressCallback({
161
- tool: provider!.id,
162
- processed,
163
- total,
164
- message,
165
- });
166
- }
167
- },
174
+ // 1. Start with sanitized global subset
175
+ const toolOptions: any = {
176
+ rootDir: options.rootDir, // Always include rootDir
177
+ };
178
+
179
+ // 2. Add other global options that tools might need
180
+ GLOBAL_SCAN_OPTIONS.forEach((key) => {
181
+ if (key in options && key !== 'toolConfigs') {
182
+ toolOptions[key] = (options as any)[key];
183
+ }
168
184
  });
169
185
 
170
- // Inject configuration into metadata for auditing and fine-tuning
186
+ // 3. Add tool-specific overrides
187
+ if (options.toolConfigs?.[provider.id]) {
188
+ Object.assign(toolOptions, options.toolConfigs[provider.id]);
189
+ } else if ((options as any)[provider.id]) {
190
+ // Fallback for legacy tool-specific keys
191
+ Object.assign(toolOptions, (options as any)[provider.id]);
192
+ }
193
+
194
+ // 4. Attach progress callback
195
+ toolOptions.onProgress = (
196
+ processed: number,
197
+ total: number,
198
+ message: string
199
+ ) => {
200
+ if (options.progressCallback) {
201
+ options.progressCallback({
202
+ tool: provider!.id,
203
+ processed,
204
+ total,
205
+ message,
206
+ });
207
+ }
208
+ };
209
+
210
+ const output = await provider.analyze(toolOptions);
211
+
212
+ // Inject sanitized configuration into metadata for audit
171
213
  if (output.metadata) {
172
- output.metadata.config = sanitizedConfig;
214
+ output.metadata.config = sanitizeToolConfig(toolOptions);
173
215
  }
174
216
 
175
217
  if (options.progressCallback) {
@@ -179,6 +221,21 @@ export async function analyzeUnified(
179
221
  result[provider.id] = output;
180
222
  result.summary.toolsRun.push(provider.id);
181
223
 
224
+ // Collect tool-specific configuration for the audit log
225
+ if (output.summary?.config) {
226
+ result.summary.toolConfigs![provider.id] = sanitizeToolConfig(
227
+ output.summary.config
228
+ );
229
+ } else if (output.metadata?.config) {
230
+ result.summary.toolConfigs![provider.id] = sanitizeToolConfig(
231
+ output.metadata.config
232
+ );
233
+ } else {
234
+ // Fallback to our sanitized input options if spoke didn't return config
235
+ result.summary.toolConfigs![provider.id] =
236
+ sanitizeToolConfig(toolOptions);
237
+ }
238
+
182
239
  // Track total files analyzed across all tools
183
240
  const toolFiles =
184
241
  output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
@@ -214,6 +271,12 @@ export async function analyzeUnified(
214
271
  }
215
272
  }
216
273
 
274
+ // Finalize configuration for metadata
275
+ result.summary.config = {
276
+ ...options,
277
+ toolConfigs: result.summary.toolConfigs,
278
+ };
279
+
217
280
  result.summary.executionTime = Date.now() - startTime;
218
281
  return result;
219
282
  }