@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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @aiready/cli@0.12.9 build /Users/pengcao/projects/aiready/packages/cli
3
+ > @aiready/cli@0.12.10 build /Users/pengcao/projects/aiready/packages/cli
4
4
  > tsup src/index.ts src/cli.ts --format cjs,esm
5
5
 
6
6
  CLI Building entry: src/cli.ts, src/index.ts
@@ -10,7 +10,7 @@
10
10
  CJS Build start
11
11
  ESM Build start
12
12
 
13
- [3:17:45 PM]  WARN  ▲ [WARNING] "import.meta" is not available with the "cjs" output format and will be empty [empty-import-meta]
13
+ [3:48:58 PM]  WARN  ▲ [WARNING] "import.meta" is not available with the "cjs" output format and will be empty [empty-import-meta]
14
14
 
15
15
  src/cli.ts:25:31:
16
16
   25 │ return dirname(fileURLToPath(import.meta.url));
@@ -20,10 +20,10 @@
20
20
 
21
21
 
22
22
 
23
- CJS dist/index.js 9.72 KB
24
- CJS dist/cli.js 68.30 KB
25
- CJS ⚡️ Build success in 33ms
26
- ESM dist/chunk-YNGTO2UX.mjs 8.59 KB
23
+ ESM dist/chunk-OOQTTRPG.mjs 8.68 KB
27
24
  ESM dist/index.mjs 170.00 B
28
- ESM dist/cli.mjs 56.62 KB
29
- ESM ⚡️ Build success in 34ms
25
+ ESM dist/cli.mjs 56.77 KB
26
+ ESM ⚡️ Build success in 29ms
27
+ CJS dist/index.js 9.79 KB
28
+ CJS dist/cli.js 68.56 KB
29
+ CJS ⚡️ Build success in 29ms
@@ -1,55 +1,55 @@
1
1
 
2
2
  
3
- > @aiready/cli@0.12.9 test /Users/pengcao/projects/aiready/packages/cli
3
+ > @aiready/cli@0.12.10 test /Users/pengcao/projects/aiready/packages/cli
4
4
  > vitest run
5
5
 
6
6
  [?25l
7
7
   RUN  v4.0.18 /Users/pengcao/projects/aiready/packages/cli
8
8
 
9
9
  stdout | src/__tests__/cli.test.ts
10
- [ToolRegistry#0.846301580251078] Registering tool: pattern-detect (patterns, duplicates, duplication)
10
+ [ToolRegistry#0.7181242020735591] Registering tool: pattern-detect (patterns, duplicates, duplication)
11
11
 
12
12
  stdout | src/__tests__/cli.test.ts
13
- [ToolRegistry#0.846301580251078] Registering tool: context-analyzer (context, fragmentation, budget)
13
+ [ToolRegistry#0.7181242020735591] Registering tool: context-analyzer (context, fragmentation, budget)
14
14
 
15
15
  stdout | src/__tests__/cli.test.ts
16
- [ToolRegistry#0.846301580251078] Registering tool: naming-consistency (consistency, naming, standards)
16
+ [ToolRegistry#0.7181242020735591] Registering tool: naming-consistency (consistency, naming, standards)
17
17
 
18
18
  stdout | src/__tests__/cli.test.ts
19
- [ToolRegistry#0.846301580251078] Registering tool: ai-signal-clarity (ai-signal, clarity, hallucination)
19
+ [ToolRegistry#0.7181242020735591] Registering tool: ai-signal-clarity (ai-signal, clarity, hallucination)
20
20
 
21
21
  stdout | src/__tests__/cli.test.ts
22
- [ToolRegistry#0.846301580251078] Registering tool: agent-grounding (agent-grounding, grounding, navigation)
22
+ [ToolRegistry#0.7181242020735591] Registering tool: agent-grounding (agent-grounding, grounding, navigation)
23
23
 
24
24
  stdout | src/__tests__/cli.test.ts
25
- [ToolRegistry#0.846301580251078] Registering tool: testability-index (testability, tests, verification)
25
+ [ToolRegistry#0.7181242020735591] Registering tool: testability-index (testability, tests, verification)
26
26
 
27
27
  stdout | src/__tests__/cli.test.ts
28
- [ToolRegistry#0.846301580251078] Registering tool: doc-drift (doc-drift, docs, jsdoc)
28
+ [ToolRegistry#0.7181242020735591] Registering tool: doc-drift (doc-drift, docs, jsdoc)
29
29
 
30
30
  stdout | src/__tests__/cli.test.ts
31
- [ToolRegistry#0.846301580251078] Registering tool: dependency-health (deps, deps-health, packages)
31
+ [ToolRegistry#0.7181242020735591] Registering tool: dependency-health (deps, deps-health, packages)
32
32
 
33
33
  stdout | src/__tests__/cli.test.ts
34
- [ToolRegistry#0.846301580251078] Registering tool: change-amplification (change-amp, change-amplification, coupling)
34
+ [ToolRegistry#0.7181242020735591] Registering tool: change-amplification (change-amp, change-amplification, coupling)
35
35
 
36
36
  stdout | src/__tests__/cli.test.ts > CLI Unified Analysis > should run unified analysis with both tools
37
- [ToolRegistry#0.846301580251078] Registering tool: pattern-detect (patterns)
38
- [ToolRegistry#0.846301580251078] Registering tool: context-analyzer (context)
37
+ [ToolRegistry#0.7181242020735591] Registering tool: pattern-detect (patterns)
38
+ [ToolRegistry#0.7181242020735591] Registering tool: context-analyzer (context)
39
39
 
40
40
  stdout | src/__tests__/cli.test.ts > CLI Unified Analysis > should run analysis with only patterns tool
41
- [ToolRegistry#0.846301580251078] Registering tool: pattern-detect (patterns)
42
- [ToolRegistry#0.846301580251078] Registering tool: context-analyzer (context)
41
+ [ToolRegistry#0.7181242020735591] Registering tool: pattern-detect (patterns)
42
+ [ToolRegistry#0.7181242020735591] Registering tool: context-analyzer (context)
43
43
 
44
44
  stdout | src/__tests__/cli.test.ts > CLI Unified Analysis > should run analysis with only context tool
45
- [ToolRegistry#0.846301580251078] Registering tool: pattern-detect (patterns)
46
- [ToolRegistry#0.846301580251078] Registering tool: context-analyzer (context)
45
+ [ToolRegistry#0.7181242020735591] Registering tool: pattern-detect (patterns)
46
+ [ToolRegistry#0.7181242020735591] Registering tool: context-analyzer (context)
47
47
 
48
48
  ✓ src/__tests__/cli.test.ts (3 tests) 3ms
49
49
 
50
50
   Test Files  1 passed (1)
51
51
   Tests  3 passed (3)
52
-  Start at  15:18:06
53
-  Duration  387ms (transform 113ms, setup 0ms, import 306ms, tests 3ms, environment 0ms)
52
+  Start at  15:49:41
53
+  Duration  386ms (transform 112ms, setup 0ms, import 304ms, tests 3ms, environment 0ms)
54
54
 
55
55
  [?25h
@@ -0,0 +1,282 @@
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
+ console.log(`[analyzeUnified] Starting analysis with toolConfigs:`, JSON.stringify(options.toolConfigs, null, 2));
60
+ const startTime = Date.now();
61
+ const requestedTools = options.tools || [
62
+ "patterns",
63
+ "context",
64
+ "consistency"
65
+ ];
66
+ const result = {
67
+ summary: {
68
+ totalIssues: 0,
69
+ criticalIssues: 0,
70
+ // Added as per instruction
71
+ majorIssues: 0,
72
+ // Added as per instruction
73
+ totalFiles: 0,
74
+ toolsRun: [],
75
+ executionTime: 0,
76
+ config: options,
77
+ toolConfigs: {}
78
+ }
79
+ };
80
+ for (const toolName of requestedTools) {
81
+ let provider = ToolRegistry.find(toolName);
82
+ if (!provider) {
83
+ const packageName = TOOL_PACKAGE_MAP[toolName] || (toolName.startsWith("@aiready/") ? toolName : `@aiready/${toolName}`);
84
+ try {
85
+ await import(packageName);
86
+ provider = ToolRegistry.find(toolName);
87
+ if (provider) {
88
+ console.log(
89
+ `\u2705 Successfully loaded tool provider: ${toolName} from ${packageName}`
90
+ );
91
+ } else {
92
+ console.log(
93
+ `\u26A0\uFE0F Loaded ${packageName} but provider ${toolName} still not found in registry.`
94
+ );
95
+ }
96
+ } catch (err) {
97
+ console.log(
98
+ `\u274C Failed to dynamically load tool ${toolName} (${packageName}):`,
99
+ err.message
100
+ );
101
+ }
102
+ }
103
+ if (!provider) {
104
+ console.warn(
105
+ `\u26A0\uFE0F Warning: Tool provider for '${toolName}' not found. Skipping.`
106
+ );
107
+ continue;
108
+ }
109
+ try {
110
+ const sanitizedConfig = { ...options };
111
+ delete sanitizedConfig.onProgress;
112
+ delete sanitizedConfig.progressCallback;
113
+ const toolOptions = {
114
+ rootDir: options.rootDir
115
+ // Always include rootDir
116
+ };
117
+ [...GLOBAL_INFRA_OPTIONS, ...COMMON_FINE_TUNING_OPTIONS].forEach(
118
+ (key) => {
119
+ if (key in options && key !== "toolConfigs") {
120
+ toolOptions[key] = options[key];
121
+ }
122
+ }
123
+ );
124
+ if (options.toolConfigs?.[provider.id]) {
125
+ Object.assign(toolOptions, options.toolConfigs[provider.id]);
126
+ } else if (options[provider.id]) {
127
+ Object.assign(toolOptions, options[provider.id]);
128
+ }
129
+ toolOptions.onProgress = (processed, total, message) => {
130
+ if (options.progressCallback) {
131
+ options.progressCallback({
132
+ tool: provider.id,
133
+ processed,
134
+ total,
135
+ message
136
+ });
137
+ }
138
+ };
139
+ console.log(`[analyzeUnified] Running tool ${provider.id} with options:`, JSON.stringify(toolOptions, null, 2));
140
+ const output = await provider.analyze(toolOptions);
141
+ if (output.metadata) {
142
+ output.metadata.config = sanitizeToolConfig(toolOptions);
143
+ }
144
+ if (options.progressCallback) {
145
+ options.progressCallback({ tool: provider.id, data: output });
146
+ }
147
+ result[provider.id] = output;
148
+ result.summary.toolsRun.push(provider.id);
149
+ if (output.summary?.config) {
150
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
151
+ output.summary.config
152
+ );
153
+ } else if (output.metadata?.config) {
154
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
155
+ output.metadata.config
156
+ );
157
+ } else {
158
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(toolOptions);
159
+ }
160
+ const toolFiles = output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
161
+ if (toolFiles > result.summary.totalFiles) {
162
+ result.summary.totalFiles = toolFiles;
163
+ }
164
+ const issueCount = output.results.reduce(
165
+ (sum, file) => sum + (file.issues?.length || 0),
166
+ 0
167
+ );
168
+ result.summary.totalIssues += issueCount;
169
+ if (provider.alias && Array.isArray(provider.alias)) {
170
+ for (const alias of provider.alias) {
171
+ if (!result[alias]) {
172
+ result[alias] = output;
173
+ }
174
+ }
175
+ }
176
+ const camelCaseId = provider.id.replace(
177
+ /-([a-z])/g,
178
+ (g) => g[1].toUpperCase()
179
+ );
180
+ if (camelCaseId !== provider.id && !result[camelCaseId]) {
181
+ result[camelCaseId] = output;
182
+ }
183
+ } catch (err) {
184
+ console.error(`\u274C Error running tool '${provider.id}':`, err);
185
+ }
186
+ }
187
+ result.summary.config = {
188
+ ...options,
189
+ toolConfigs: result.summary.toolConfigs
190
+ };
191
+ result.summary.executionTime = Date.now() - startTime;
192
+ return result;
193
+ }
194
+ async function scoreUnified(results, options) {
195
+ const toolScores = /* @__PURE__ */ new Map();
196
+ for (const toolId of results.summary.toolsRun) {
197
+ const provider = ToolRegistry.get(toolId);
198
+ if (!provider) continue;
199
+ const output = results[toolId];
200
+ if (!output) continue;
201
+ try {
202
+ const toolScore = provider.score(output, options);
203
+ if (!toolScore.tokenBudget) {
204
+ if (toolId === ToolName.PatternDetect && output.duplicates) {
205
+ const wastedTokens = output.duplicates.reduce(
206
+ (sum, d) => sum + (d.tokenCost || 0),
207
+ 0
208
+ );
209
+ toolScore.tokenBudget = calculateTokenBudget({
210
+ totalContextTokens: wastedTokens * 2,
211
+ wastedTokens: {
212
+ duplication: wastedTokens,
213
+ fragmentation: 0,
214
+ chattiness: 0
215
+ }
216
+ });
217
+ } else if (toolId === ToolName.ContextAnalyzer && output.summary) {
218
+ toolScore.tokenBudget = calculateTokenBudget({
219
+ totalContextTokens: output.summary.totalTokens,
220
+ wastedTokens: {
221
+ duplication: 0,
222
+ fragmentation: output.summary.totalPotentialSavings || 0,
223
+ chattiness: 0
224
+ }
225
+ });
226
+ }
227
+ }
228
+ toolScores.set(toolId, toolScore);
229
+ } catch (err) {
230
+ console.error(`\u274C Error scoring tool '${toolId}':`, err);
231
+ }
232
+ }
233
+ if (toolScores.size === 0) {
234
+ return {
235
+ overall: 0,
236
+ rating: "Critical",
237
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
238
+ toolsUsed: [],
239
+ breakdown: [],
240
+ calculation: {
241
+ formula: "0 / 0 = 0",
242
+ weights: {},
243
+ normalized: "0 / 0 = 0"
244
+ }
245
+ };
246
+ }
247
+ return calculateOverallScore(toolScores, options, void 0);
248
+ }
249
+ function generateUnifiedSummary(result) {
250
+ const { summary } = result;
251
+ let output = `\u{1F680} AIReady Analysis Complete
252
+
253
+ `;
254
+ output += `\u{1F4CA} Summary:
255
+ `;
256
+ output += ` Tools run: ${summary.toolsRun.join(", ")}
257
+ `;
258
+ output += ` Total issues found: ${summary.totalIssues}
259
+ `;
260
+ output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
261
+
262
+ `;
263
+ for (const provider of ToolRegistry.getAll()) {
264
+ const toolResult = result[provider.id];
265
+ if (toolResult) {
266
+ const issueCount = toolResult.results.reduce(
267
+ (sum, r) => sum + (r.issues?.length || 0),
268
+ 0
269
+ );
270
+ output += `\u2022 ${provider.id}: ${issueCount} issues
271
+ `;
272
+ }
273
+ }
274
+ return output;
275
+ }
276
+
277
+ export {
278
+ __require,
279
+ analyzeUnified,
280
+ scoreUnified,
281
+ generateUnifiedSummary
282
+ };
@@ -0,0 +1,281 @@
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
+ console.log(`[analyzeUnified] Running tool ${provider.id} with options:`, JSON.stringify(toolOptions, null, 2));
139
+ const output = await provider.analyze(toolOptions);
140
+ if (output.metadata) {
141
+ output.metadata.config = sanitizeToolConfig(toolOptions);
142
+ }
143
+ if (options.progressCallback) {
144
+ options.progressCallback({ tool: provider.id, data: output });
145
+ }
146
+ result[provider.id] = output;
147
+ result.summary.toolsRun.push(provider.id);
148
+ if (output.summary?.config) {
149
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
150
+ output.summary.config
151
+ );
152
+ } else if (output.metadata?.config) {
153
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
154
+ output.metadata.config
155
+ );
156
+ } else {
157
+ result.summary.toolConfigs[provider.id] = sanitizeToolConfig(toolOptions);
158
+ }
159
+ const toolFiles = output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
160
+ if (toolFiles > result.summary.totalFiles) {
161
+ result.summary.totalFiles = toolFiles;
162
+ }
163
+ const issueCount = output.results.reduce(
164
+ (sum, file) => sum + (file.issues?.length || 0),
165
+ 0
166
+ );
167
+ result.summary.totalIssues += issueCount;
168
+ if (provider.alias && Array.isArray(provider.alias)) {
169
+ for (const alias of provider.alias) {
170
+ if (!result[alias]) {
171
+ result[alias] = output;
172
+ }
173
+ }
174
+ }
175
+ const camelCaseId = provider.id.replace(
176
+ /-([a-z])/g,
177
+ (g) => g[1].toUpperCase()
178
+ );
179
+ if (camelCaseId !== provider.id && !result[camelCaseId]) {
180
+ result[camelCaseId] = output;
181
+ }
182
+ } catch (err) {
183
+ console.error(`\u274C Error running tool '${provider.id}':`, err);
184
+ }
185
+ }
186
+ result.summary.config = {
187
+ ...options,
188
+ toolConfigs: result.summary.toolConfigs
189
+ };
190
+ result.summary.executionTime = Date.now() - startTime;
191
+ return result;
192
+ }
193
+ async function scoreUnified(results, options) {
194
+ const toolScores = /* @__PURE__ */ new Map();
195
+ for (const toolId of results.summary.toolsRun) {
196
+ const provider = ToolRegistry.get(toolId);
197
+ if (!provider) continue;
198
+ const output = results[toolId];
199
+ if (!output) continue;
200
+ try {
201
+ const toolScore = provider.score(output, options);
202
+ if (!toolScore.tokenBudget) {
203
+ if (toolId === ToolName.PatternDetect && output.duplicates) {
204
+ const wastedTokens = output.duplicates.reduce(
205
+ (sum, d) => sum + (d.tokenCost || 0),
206
+ 0
207
+ );
208
+ toolScore.tokenBudget = calculateTokenBudget({
209
+ totalContextTokens: wastedTokens * 2,
210
+ wastedTokens: {
211
+ duplication: wastedTokens,
212
+ fragmentation: 0,
213
+ chattiness: 0
214
+ }
215
+ });
216
+ } else if (toolId === ToolName.ContextAnalyzer && output.summary) {
217
+ toolScore.tokenBudget = calculateTokenBudget({
218
+ totalContextTokens: output.summary.totalTokens,
219
+ wastedTokens: {
220
+ duplication: 0,
221
+ fragmentation: output.summary.totalPotentialSavings || 0,
222
+ chattiness: 0
223
+ }
224
+ });
225
+ }
226
+ }
227
+ toolScores.set(toolId, toolScore);
228
+ } catch (err) {
229
+ console.error(`\u274C Error scoring tool '${toolId}':`, err);
230
+ }
231
+ }
232
+ if (toolScores.size === 0) {
233
+ return {
234
+ overall: 0,
235
+ rating: "Critical",
236
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
237
+ toolsUsed: [],
238
+ breakdown: [],
239
+ calculation: {
240
+ formula: "0 / 0 = 0",
241
+ weights: {},
242
+ normalized: "0 / 0 = 0"
243
+ }
244
+ };
245
+ }
246
+ return calculateOverallScore(toolScores, options, void 0);
247
+ }
248
+ function generateUnifiedSummary(result) {
249
+ const { summary } = result;
250
+ let output = `\u{1F680} AIReady Analysis Complete
251
+
252
+ `;
253
+ output += `\u{1F4CA} Summary:
254
+ `;
255
+ output += ` Tools run: ${summary.toolsRun.join(", ")}
256
+ `;
257
+ output += ` Total issues found: ${summary.totalIssues}
258
+ `;
259
+ output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
260
+
261
+ `;
262
+ for (const provider of ToolRegistry.getAll()) {
263
+ const toolResult = result[provider.id];
264
+ if (toolResult) {
265
+ const issueCount = toolResult.results.reduce(
266
+ (sum, r) => sum + (r.issues?.length || 0),
267
+ 0
268
+ );
269
+ output += `\u2022 ${provider.id}: ${issueCount} issues
270
+ `;
271
+ }
272
+ }
273
+ return output;
274
+ }
275
+
276
+ export {
277
+ __require,
278
+ analyzeUnified,
279
+ scoreUnified,
280
+ generateUnifiedSummary
281
+ };