@aiready/cli 0.12.8 → 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,
@@ -26,14 +27,22 @@ import '@aiready/change-amplification';
26
27
  export type { ToolScoringOutput, ScoringResult };
27
28
 
28
29
  export interface UnifiedAnalysisOptions extends ScanOptions {
30
+ rootDir: string;
29
31
  tools?: string[];
32
+ toolConfigs?: Record<string, any>;
30
33
  minSimilarity?: number;
31
34
  minLines?: number;
32
35
  maxCandidatesPerBlock?: number;
33
36
  minSharedTokens?: number;
34
37
  useSmartDefaults?: boolean;
35
38
  consistency?: any;
36
- progressCallback?: (event: { tool: string; data: any }) => void;
39
+ progressCallback?: (event: {
40
+ tool: string;
41
+ data?: any;
42
+ processed?: number;
43
+ total?: number;
44
+ message?: string;
45
+ }) => void;
37
46
  }
38
47
 
39
48
  export interface UnifiedAnalysisResult {
@@ -41,9 +50,14 @@ export interface UnifiedAnalysisResult {
41
50
  [key: string]: any;
42
51
 
43
52
  summary: {
53
+ totalFiles: number;
44
54
  totalIssues: number;
55
+ criticalIssues: number;
56
+ majorIssues: number;
45
57
  toolsRun: string[];
46
58
  executionTime: number;
59
+ config?: any;
60
+ toolConfigs?: Record<string, any>;
47
61
  };
48
62
  scoring?: ScoringResult;
49
63
  }
@@ -68,20 +82,27 @@ const TOOL_PACKAGE_MAP: Record<string, string> = {
68
82
  context: '@aiready/context-analyzer',
69
83
  fragmentation: '@aiready/context-analyzer',
70
84
  consistency: '@aiready/consistency',
71
- 'naming-consistency': '@aiready/consistency',
72
85
  'ai-signal': '@aiready/ai-signal-clarity',
73
- 'ai-signal-clarity': '@aiready/ai-signal-clarity',
74
86
  grounding: '@aiready/agent-grounding',
75
- 'agent-grounding': '@aiready/agent-grounding',
76
87
  testability: '@aiready/testability',
77
- 'testability-index': '@aiready/testability',
78
- 'doc-drift': '@aiready/doc-drift',
79
88
  'deps-health': '@aiready/deps',
80
- 'dependency-health': '@aiready/deps',
81
89
  'change-amp': '@aiready/change-amplification',
82
- 'change-amplification': '@aiready/change-amplification',
83
90
  };
84
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
+
85
106
  /**
86
107
  * AIReady Unified Analysis
87
108
  * Orchestrates all registered tools via the ToolRegistry.
@@ -99,9 +120,13 @@ export async function analyzeUnified(
99
120
  const result: UnifiedAnalysisResult = {
100
121
  summary: {
101
122
  totalIssues: 0,
123
+ criticalIssues: 0, // Added as per instruction
124
+ majorIssues: 0, // Added as per instruction
102
125
  totalFiles: 0,
103
126
  toolsRun: [],
104
127
  executionTime: 0,
128
+ config: options,
129
+ toolConfigs: {},
105
130
  },
106
131
  };
107
132
 
@@ -141,20 +166,54 @@ export async function analyzeUnified(
141
166
  }
142
167
 
143
168
  try {
144
- const output = await provider.analyze({
145
- ...options,
146
- onProgress: (processed: number, total: number, message: string) => {
147
- if (options.progressCallback) {
148
- options.progressCallback({
149
- tool: provider!.id,
150
- processed,
151
- total,
152
- message,
153
- });
154
- }
155
- },
169
+ // Sanitize options for metadata tracking (remove functions/internal keys)
170
+ const sanitizedConfig = { ...options };
171
+ delete (sanitizedConfig as any).onProgress;
172
+ delete (sanitizedConfig as any).progressCallback;
173
+
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
+ }
156
184
  });
157
185
 
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
213
+ if (output.metadata) {
214
+ output.metadata.config = sanitizeToolConfig(toolOptions);
215
+ }
216
+
158
217
  if (options.progressCallback) {
159
218
  options.progressCallback({ tool: provider.id, data: output });
160
219
  }
@@ -162,6 +221,21 @@ export async function analyzeUnified(
162
221
  result[provider.id] = output;
163
222
  result.summary.toolsRun.push(provider.id);
164
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
+
165
239
  // Track total files analyzed across all tools
166
240
  const toolFiles =
167
241
  output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
@@ -197,6 +271,12 @@ export async function analyzeUnified(
197
271
  }
198
272
  }
199
273
 
274
+ // Finalize configuration for metadata
275
+ result.summary.config = {
276
+ ...options,
277
+ toolConfigs: result.summary.toolConfigs,
278
+ };
279
+
200
280
  result.summary.executionTime = Date.now() - startTime;
201
281
  return result;
202
282
  }