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