@aiready/cli 0.12.9 → 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.
@@ -140,12 +140,14 @@ export async function scanAction(directory: string, options: ScanOptions) {
140
140
  const { getSmartDefaults } = await import('@aiready/pattern-detect');
141
141
  const patternSmartDefaults = await getSmartDefaults(
142
142
  resolvedDir,
143
- baseOptions
143
+ finalOptions.toolConfigs?.[ToolName.PatternDetect] || {}
144
144
  );
145
- finalOptions = {
145
+
146
+ // Merge smart defaults into toolConfigs instead of root level
147
+ if (!finalOptions.toolConfigs) finalOptions.toolConfigs = {};
148
+ finalOptions.toolConfigs[ToolName.PatternDetect] = {
146
149
  ...patternSmartDefaults,
147
- ...finalOptions,
148
- ...baseOptions,
150
+ ...finalOptions.toolConfigs[ToolName.PatternDetect],
149
151
  };
150
152
  }
151
153
 
@@ -182,7 +184,7 @@ export async function scanAction(directory: string, options: ScanOptions) {
182
184
  const results = await analyzeUnified({
183
185
  ...finalOptions,
184
186
  progressCallback,
185
- onProgress: () => {},
187
+ onProgress: () => { },
186
188
  suppressToolConfig: true,
187
189
  });
188
190
 
package/src/index.ts CHANGED
@@ -3,6 +3,9 @@ import {
3
3
  ToolName,
4
4
  calculateOverallScore,
5
5
  calculateTokenBudget,
6
+ GLOBAL_SCAN_OPTIONS,
7
+ GLOBAL_INFRA_OPTIONS,
8
+ COMMON_FINE_TUNING_OPTIONS,
6
9
  } from '@aiready/core';
7
10
  import type {
8
11
  AnalysisResult,
@@ -28,6 +31,7 @@ export type { ToolScoringOutput, ScoringResult };
28
31
  export interface UnifiedAnalysisOptions extends ScanOptions {
29
32
  rootDir: string;
30
33
  tools?: string[];
34
+ toolConfigs?: Record<string, any>;
31
35
  minSimilarity?: number;
32
36
  minLines?: number;
33
37
  maxCandidatesPerBlock?: number;
@@ -55,6 +59,7 @@ export interface UnifiedAnalysisResult {
55
59
  toolsRun: string[];
56
60
  executionTime: number;
57
61
  config?: any;
62
+ toolConfigs?: Record<string, any>;
58
63
  };
59
64
  scoring?: ScoringResult;
60
65
  }
@@ -86,6 +91,20 @@ const TOOL_PACKAGE_MAP: Record<string, string> = {
86
91
  'change-amp': '@aiready/change-amplification',
87
92
  };
88
93
 
94
+ /**
95
+ * Sanitize tool configuration by removing global options (except rootDir)
96
+ */
97
+ function sanitizeToolConfig(config: any): any {
98
+ if (!config || typeof config !== 'object') return config;
99
+ const sanitized = { ...config };
100
+ GLOBAL_INFRA_OPTIONS.forEach((key: string) => {
101
+ if (key !== 'rootDir') {
102
+ delete (sanitized as any)[key];
103
+ }
104
+ });
105
+ return sanitized;
106
+ }
107
+
89
108
  /**
90
109
  * AIReady Unified Analysis
91
110
  * Orchestrates all registered tools via the ToolRegistry.
@@ -108,7 +127,8 @@ export async function analyzeUnified(
108
127
  totalFiles: 0,
109
128
  toolsRun: [],
110
129
  executionTime: 0,
111
- config: options, // Added as per instruction
130
+ config: options,
131
+ toolConfigs: {},
112
132
  },
113
133
  };
114
134
 
@@ -153,23 +173,49 @@ export async function analyzeUnified(
153
173
  delete (sanitizedConfig as any).onProgress;
154
174
  delete (sanitizedConfig as any).progressCallback;
155
175
 
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
- });
176
+ // 1. Start with sanitized global subset
177
+ const toolOptions: any = {
178
+ rootDir: options.rootDir, // Always include rootDir
179
+ };
180
+
181
+ // 1. Pass through all known infra and fine-tuning options from root level
182
+ [...GLOBAL_INFRA_OPTIONS, ...COMMON_FINE_TUNING_OPTIONS].forEach(
183
+ (key) => {
184
+ if (key in options && key !== 'toolConfigs') {
185
+ toolOptions[key] = (options as any)[key];
166
186
  }
167
- },
168
- });
187
+ }
188
+ );
189
+
190
+ // 3. Add tool-specific overrides
191
+ if (options.toolConfigs?.[provider.id]) {
192
+ Object.assign(toolOptions, options.toolConfigs[provider.id]);
193
+ } else if ((options as any)[provider.id]) {
194
+ // Fallback for legacy tool-specific keys
195
+ Object.assign(toolOptions, (options as any)[provider.id]);
196
+ }
169
197
 
170
- // Inject configuration into metadata for auditing and fine-tuning
198
+ // 4. Attach progress callback
199
+ toolOptions.onProgress = (
200
+ processed: number,
201
+ total: number,
202
+ message: string
203
+ ) => {
204
+ if (options.progressCallback) {
205
+ options.progressCallback({
206
+ tool: provider!.id,
207
+ processed,
208
+ total,
209
+ message,
210
+ });
211
+ }
212
+ };
213
+
214
+ const output = await provider.analyze(toolOptions);
215
+
216
+ // Inject sanitized configuration into metadata for audit
171
217
  if (output.metadata) {
172
- output.metadata.config = sanitizedConfig;
218
+ output.metadata.config = sanitizeToolConfig(toolOptions);
173
219
  }
174
220
 
175
221
  if (options.progressCallback) {
@@ -179,6 +225,21 @@ export async function analyzeUnified(
179
225
  result[provider.id] = output;
180
226
  result.summary.toolsRun.push(provider.id);
181
227
 
228
+ // Collect tool-specific configuration for the audit log
229
+ if (output.summary?.config) {
230
+ result.summary.toolConfigs![provider.id] = sanitizeToolConfig(
231
+ output.summary.config
232
+ );
233
+ } else if (output.metadata?.config) {
234
+ result.summary.toolConfigs![provider.id] = sanitizeToolConfig(
235
+ output.metadata.config
236
+ );
237
+ } else {
238
+ // Fallback to our sanitized input options if spoke didn't return config
239
+ result.summary.toolConfigs![provider.id] =
240
+ sanitizeToolConfig(toolOptions);
241
+ }
242
+
182
243
  // Track total files analyzed across all tools
183
244
  const toolFiles =
184
245
  output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
@@ -214,6 +275,12 @@ export async function analyzeUnified(
214
275
  }
215
276
  }
216
277
 
278
+ // Finalize configuration for metadata
279
+ result.summary.config = {
280
+ ...options,
281
+ toolConfigs: result.summary.toolConfigs,
282
+ };
283
+
217
284
  result.summary.executionTime = Date.now() - startTime;
218
285
  return result;
219
286
  }