@aiready/cli 0.10.6 → 0.12.1

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.10.5 build /Users/pengcao/projects/aiready/packages/cli
3
+ > @aiready/cli@0.12.0 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
-  WARN  ▲ [WARNING] "import.meta" is not available with the "cjs" output format and will be empty [empty-import-meta] 9:38:48 pm
13
+  WARN  ▲ [WARNING] "import.meta" is not available with the "cjs" output format and will be empty [empty-import-meta] 10:34:27 am
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 16.55 KB
24
- CJS dist/cli.js 95.60 KB
25
- CJS ⚡️ Build success in 31ms
23
+ CJS dist/cli.js 66.96 KB
24
+ CJS dist/index.js 8.21 KB
25
+ CJS ⚡️ Build success in 87ms
26
26
  ESM dist/index.mjs 170.00 B
27
- ESM dist/cli.mjs 77.38 KB
28
- ESM dist/chunk-VQCWYJYJ.mjs 14.49 KB
29
- ESM ⚡️ Build success in 31ms
27
+ ESM dist/cli.mjs 56.79 KB
28
+ ESM dist/chunk-LTUQDJPO.mjs 7.08 KB
29
+ ESM ⚡️ Build success in 87ms
@@ -1,5 +1,13 @@
1
1
 
2
2
  
3
- > @aiready/cli@0.9.41 lint /Users/pengcao/projects/aiready/packages/cli
3
+ > @aiready/cli@0.10.6 lint /Users/pengcao/projects/aiready/packages/cli
4
4
  > eslint src
5
5
 
6
+ 
7
+ /Users/pengcao/projects/aiready/packages/cli/src/commands/scan.ts
8
+ 15:3 warning 'calculateOverallScore' is defined but never used @typescript-eslint/no-unused-vars
9
+ 23:3 warning 'parseWeightString' is defined but never used @typescript-eslint/no-unused-vars
10
+ 28:8 warning 'ToolScoringOutput' is defined but never used @typescript-eslint/no-unused-vars
11
+
12
+ ✖ 3 problems (0 errors, 3 warnings)
13
+ 
@@ -1,16 +1,55 @@
1
1
 
2
2
  
3
- > @aiready/cli@0.10.5 test /Users/pengcao/projects/aiready/packages/cli
3
+ > @aiready/cli@0.12.0 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
- ✓ src/__tests__/cli.test.ts (3 tests) 2ms
9
+ stdout | src/__tests__/cli.test.ts
10
+ [ToolRegistry#0.43273800284035346] Registering tool: pattern-detect (patterns, duplicates, duplication)
11
+
12
+ stdout | src/__tests__/cli.test.ts
13
+ [ToolRegistry#0.43273800284035346] Registering tool: context-analyzer (context, fragmentation, budget)
14
+
15
+ stdout | src/__tests__/cli.test.ts
16
+ [ToolRegistry#0.43273800284035346] Registering tool: naming-consistency (consistency, naming, standards)
17
+
18
+ stdout | src/__tests__/cli.test.ts
19
+ [ToolRegistry#0.43273800284035346] Registering tool: ai-signal-clarity (ai-signal, clarity, hallucination)
20
+
21
+ stdout | src/__tests__/cli.test.ts
22
+ [ToolRegistry#0.43273800284035346] Registering tool: agent-grounding (agent-grounding, grounding, navigation)
23
+
24
+ stdout | src/__tests__/cli.test.ts
25
+ [ToolRegistry#0.43273800284035346] Registering tool: testability-index (testability, tests, verification)
26
+
27
+ stdout | src/__tests__/cli.test.ts
28
+ [ToolRegistry#0.43273800284035346] Registering tool: doc-drift (doc-drift, docs, jsdoc)
29
+
30
+ stdout | src/__tests__/cli.test.ts
31
+ [ToolRegistry#0.43273800284035346] Registering tool: dependency-health (deps, deps-health, packages)
32
+
33
+ stdout | src/__tests__/cli.test.ts
34
+ [ToolRegistry#0.43273800284035346] Registering tool: change-amplification (change-amp, change-amplification, coupling)
35
+
36
+ stdout | src/__tests__/cli.test.ts > CLI Unified Analysis > should run unified analysis with both tools
37
+ [ToolRegistry#0.43273800284035346] Registering tool: pattern-detect (patterns)
38
+ [ToolRegistry#0.43273800284035346] Registering tool: context-analyzer (context)
39
+
40
+ stdout | src/__tests__/cli.test.ts > CLI Unified Analysis > should run analysis with only patterns tool
41
+ [ToolRegistry#0.43273800284035346] Registering tool: pattern-detect (patterns)
42
+ [ToolRegistry#0.43273800284035346] Registering tool: context-analyzer (context)
43
+
44
+ stdout | src/__tests__/cli.test.ts > CLI Unified Analysis > should run analysis with only context tool
45
+ [ToolRegistry#0.43273800284035346] Registering tool: pattern-detect (patterns)
46
+ [ToolRegistry#0.43273800284035346] Registering tool: context-analyzer (context)
47
+
48
+ ✓ src/__tests__/cli.test.ts (3 tests) 3ms
10
49
 
11
50
   Test Files  1 passed (1)
12
51
   Tests  3 passed (3)
13
-  Start at  21:39:06
14
-  Duration  411ms (transform 80ms, setup 0ms, import 280ms, tests 2ms, environment 0ms)
52
+  Start at  10:34:45
53
+  Duration  536ms (transform 205ms, setup 0ms, import 411ms, tests 3ms, environment 0ms)
15
54
 
16
55
  [?25h
@@ -0,0 +1,229 @@
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
+ "naming-consistency": "@aiready/consistency",
41
+ "ai-signal": "@aiready/ai-signal-clarity",
42
+ "ai-signal-clarity": "@aiready/ai-signal-clarity",
43
+ grounding: "@aiready/agent-grounding",
44
+ "agent-grounding": "@aiready/agent-grounding",
45
+ testability: "@aiready/testability",
46
+ "testability-index": "@aiready/testability",
47
+ "doc-drift": "@aiready/doc-drift",
48
+ "deps-health": "@aiready/deps",
49
+ "dependency-health": "@aiready/deps",
50
+ "change-amp": "@aiready/change-amplification",
51
+ "change-amplification": "@aiready/change-amplification"
52
+ };
53
+ async function analyzeUnified(options) {
54
+ const startTime = Date.now();
55
+ const requestedTools = options.tools || [
56
+ "patterns",
57
+ "context",
58
+ "consistency"
59
+ ];
60
+ const result = {
61
+ summary: {
62
+ totalIssues: 0,
63
+ toolsRun: [],
64
+ executionTime: 0
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 output = await provider.analyze({
98
+ ...options,
99
+ onProgress: (processed, total, message) => {
100
+ if (options.progressCallback) {
101
+ options.progressCallback({
102
+ tool: provider.id,
103
+ processed,
104
+ total,
105
+ message
106
+ });
107
+ }
108
+ }
109
+ });
110
+ if (options.progressCallback) {
111
+ options.progressCallback({ tool: provider.id, data: output });
112
+ }
113
+ result[provider.id] = output;
114
+ result.summary.toolsRun.push(provider.id);
115
+ const issueCount = output.results.reduce(
116
+ (sum, file) => sum + (file.issues?.length || 0),
117
+ 0
118
+ );
119
+ result.summary.totalIssues += issueCount;
120
+ if (provider.alias && Array.isArray(provider.alias)) {
121
+ for (const alias of provider.alias) {
122
+ if (!result[alias]) {
123
+ result[alias] = output;
124
+ }
125
+ }
126
+ }
127
+ const camelCaseId = provider.id.replace(
128
+ /-([a-z])/g,
129
+ (g) => g[1].toUpperCase()
130
+ );
131
+ if (camelCaseId !== provider.id && !result[camelCaseId]) {
132
+ result[camelCaseId] = output;
133
+ }
134
+ } catch (err) {
135
+ console.error(`\u274C Error running tool '${provider.id}':`, err);
136
+ }
137
+ }
138
+ result.summary.executionTime = Date.now() - startTime;
139
+ return result;
140
+ }
141
+ async function scoreUnified(results, options) {
142
+ const toolScores = /* @__PURE__ */ new Map();
143
+ for (const toolId of results.summary.toolsRun) {
144
+ const provider = ToolRegistry.get(toolId);
145
+ if (!provider) continue;
146
+ const output = results[toolId];
147
+ if (!output) continue;
148
+ try {
149
+ const toolScore = provider.score(output, options);
150
+ if (!toolScore.tokenBudget) {
151
+ if (toolId === ToolName.PatternDetect && output.duplicates) {
152
+ const wastedTokens = output.duplicates.reduce(
153
+ (sum, d) => sum + (d.tokenCost || 0),
154
+ 0
155
+ );
156
+ toolScore.tokenBudget = calculateTokenBudget({
157
+ totalContextTokens: wastedTokens * 2,
158
+ wastedTokens: {
159
+ duplication: wastedTokens,
160
+ fragmentation: 0,
161
+ chattiness: 0
162
+ }
163
+ });
164
+ } else if (toolId === ToolName.ContextAnalyzer && output.summary) {
165
+ toolScore.tokenBudget = calculateTokenBudget({
166
+ totalContextTokens: output.summary.totalTokens,
167
+ wastedTokens: {
168
+ duplication: 0,
169
+ fragmentation: output.summary.totalPotentialSavings || 0,
170
+ chattiness: 0
171
+ }
172
+ });
173
+ }
174
+ }
175
+ toolScores.set(toolId, toolScore);
176
+ } catch (err) {
177
+ console.error(`\u274C Error scoring tool '${toolId}':`, err);
178
+ }
179
+ }
180
+ if (toolScores.size === 0) {
181
+ return {
182
+ overall: 0,
183
+ rating: "Critical",
184
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
185
+ toolsUsed: [],
186
+ breakdown: [],
187
+ calculation: {
188
+ formula: "0 / 0 = 0",
189
+ weights: {},
190
+ normalized: "0 / 0 = 0"
191
+ }
192
+ };
193
+ }
194
+ return calculateOverallScore(toolScores, options, void 0);
195
+ }
196
+ function generateUnifiedSummary(result) {
197
+ const { summary } = result;
198
+ let output = `\u{1F680} AIReady Analysis Complete
199
+
200
+ `;
201
+ output += `\u{1F4CA} Summary:
202
+ `;
203
+ output += ` Tools run: ${summary.toolsRun.join(", ")}
204
+ `;
205
+ output += ` Total issues found: ${summary.totalIssues}
206
+ `;
207
+ output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
208
+
209
+ `;
210
+ for (const provider of ToolRegistry.getAll()) {
211
+ const toolResult = result[provider.id];
212
+ if (toolResult) {
213
+ const issueCount = toolResult.results.reduce(
214
+ (sum, r) => sum + (r.issues?.length || 0),
215
+ 0
216
+ );
217
+ output += `\u2022 ${provider.id}: ${issueCount} issues
218
+ `;
219
+ }
220
+ }
221
+ return output;
222
+ }
223
+
224
+ export {
225
+ __require,
226
+ analyzeUnified,
227
+ scoreUnified,
228
+ generateUnifiedSummary
229
+ };
@@ -0,0 +1,194 @@
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
+ var TOOL_PACKAGE_MAP = {
16
+ [ToolName.PatternDetect]: "@aiready/pattern-detect",
17
+ [ToolName.ContextAnalyzer]: "@aiready/context-analyzer",
18
+ [ToolName.NamingConsistency]: "@aiready/consistency",
19
+ [ToolName.AiSignalClarity]: "@aiready/ai-signal-clarity",
20
+ [ToolName.AgentGrounding]: "@aiready/agent-grounding",
21
+ [ToolName.TestabilityIndex]: "@aiready/testability",
22
+ [ToolName.DocDrift]: "@aiready/doc-drift",
23
+ [ToolName.DependencyHealth]: "@aiready/deps",
24
+ [ToolName.ChangeAmplification]: "@aiready/change-amplification",
25
+ // Aliases handled by registry
26
+ patterns: "@aiready/pattern-detect",
27
+ context: "@aiready/context-analyzer",
28
+ consistency: "@aiready/consistency"
29
+ };
30
+ async function analyzeUnified(options) {
31
+ const startTime = Date.now();
32
+ const requestedTools = options.tools || [
33
+ "patterns",
34
+ "context",
35
+ "consistency"
36
+ ];
37
+ const result = {
38
+ summary: {
39
+ totalIssues: 0,
40
+ toolsRun: [],
41
+ executionTime: 0
42
+ }
43
+ };
44
+ for (const toolName of requestedTools) {
45
+ let provider = ToolRegistry.find(toolName);
46
+ if (!provider) {
47
+ const packageName = TOOL_PACKAGE_MAP[toolName] || (toolName.startsWith("@aiready/") ? toolName : `@aiready/${toolName}`);
48
+ try {
49
+ await import(packageName);
50
+ provider = ToolRegistry.find(toolName);
51
+ if (provider) {
52
+ console.log(
53
+ `\u2705 Successfully loaded tool provider: ${toolName} from ${packageName}`
54
+ );
55
+ } else {
56
+ console.log(
57
+ `\u26A0\uFE0F Loaded ${packageName} but provider ${toolName} still not found in registry.`
58
+ );
59
+ }
60
+ } catch (err) {
61
+ console.log(
62
+ `\u274C Failed to dynamically load tool ${toolName} (${packageName}):`,
63
+ err.message
64
+ );
65
+ }
66
+ }
67
+ if (!provider) {
68
+ console.warn(
69
+ `\u26A0\uFE0F Warning: Tool provider for '${toolName}' not found. Skipping.`
70
+ );
71
+ continue;
72
+ }
73
+ try {
74
+ const output = await provider.analyze(options);
75
+ if (options.progressCallback) {
76
+ options.progressCallback({ tool: provider.id, data: output });
77
+ }
78
+ result[provider.id] = output;
79
+ result.summary.toolsRun.push(provider.id);
80
+ const issueCount = output.results.reduce(
81
+ (sum, file) => sum + (file.issues?.length || 0),
82
+ 0
83
+ );
84
+ result.summary.totalIssues += issueCount;
85
+ if (provider.alias && Array.isArray(provider.alias)) {
86
+ for (const alias of provider.alias) {
87
+ if (!result[alias]) {
88
+ result[alias] = output;
89
+ }
90
+ }
91
+ }
92
+ const camelCaseId = provider.id.replace(
93
+ /-([a-z])/g,
94
+ (g) => g[1].toUpperCase()
95
+ );
96
+ if (camelCaseId !== provider.id && !result[camelCaseId]) {
97
+ result[camelCaseId] = output;
98
+ }
99
+ } catch (err) {
100
+ console.error(`\u274C Error running tool '${provider.id}':`, err);
101
+ }
102
+ }
103
+ result.summary.executionTime = Date.now() - startTime;
104
+ return result;
105
+ }
106
+ async function scoreUnified(results, options) {
107
+ const toolScores = /* @__PURE__ */ new Map();
108
+ for (const toolId of results.summary.toolsRun) {
109
+ const provider = ToolRegistry.get(toolId);
110
+ if (!provider) continue;
111
+ const output = results[toolId];
112
+ if (!output) continue;
113
+ try {
114
+ const toolScore = provider.score(output, options);
115
+ if (!toolScore.tokenBudget) {
116
+ if (toolId === ToolName.PatternDetect && output.duplicates) {
117
+ const wastedTokens = output.duplicates.reduce(
118
+ (sum, d) => sum + (d.tokenCost || 0),
119
+ 0
120
+ );
121
+ toolScore.tokenBudget = calculateTokenBudget({
122
+ totalContextTokens: wastedTokens * 2,
123
+ wastedTokens: {
124
+ duplication: wastedTokens,
125
+ fragmentation: 0,
126
+ chattiness: 0
127
+ }
128
+ });
129
+ } else if (toolId === ToolName.ContextAnalyzer && output.summary) {
130
+ toolScore.tokenBudget = calculateTokenBudget({
131
+ totalContextTokens: output.summary.totalTokens,
132
+ wastedTokens: {
133
+ duplication: 0,
134
+ fragmentation: output.summary.totalPotentialSavings || 0,
135
+ chattiness: 0
136
+ }
137
+ });
138
+ }
139
+ }
140
+ toolScores.set(toolId, toolScore);
141
+ } catch (err) {
142
+ console.error(`\u274C Error scoring tool '${toolId}':`, err);
143
+ }
144
+ }
145
+ if (toolScores.size === 0) {
146
+ return {
147
+ overall: 0,
148
+ rating: "Critical",
149
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
150
+ toolsUsed: [],
151
+ breakdown: [],
152
+ calculation: {
153
+ formula: "0 / 0 = 0",
154
+ weights: {},
155
+ normalized: "0 / 0 = 0"
156
+ }
157
+ };
158
+ }
159
+ return calculateOverallScore(toolScores, options, void 0);
160
+ }
161
+ function generateUnifiedSummary(result) {
162
+ const { summary } = result;
163
+ let output = `\u{1F680} AIReady Analysis Complete
164
+
165
+ `;
166
+ output += `\u{1F4CA} Summary:
167
+ `;
168
+ output += ` Tools run: ${summary.toolsRun.join(", ")}
169
+ `;
170
+ output += ` Total issues found: ${summary.totalIssues}
171
+ `;
172
+ output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
173
+
174
+ `;
175
+ for (const provider of ToolRegistry.getAll()) {
176
+ const toolResult = result[provider.id];
177
+ if (toolResult) {
178
+ const issueCount = toolResult.results.reduce(
179
+ (sum, r) => sum + (r.issues?.length || 0),
180
+ 0
181
+ );
182
+ output += `\u2022 ${provider.id}: ${issueCount} issues
183
+ `;
184
+ }
185
+ }
186
+ return output;
187
+ }
188
+
189
+ export {
190
+ __require,
191
+ analyzeUnified,
192
+ scoreUnified,
193
+ generateUnifiedSummary
194
+ };
@@ -0,0 +1,161 @@
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
+ var TOOL_PACKAGE_MAP = {
16
+ [ToolName.PatternDetect]: "@aiready/pattern-detect",
17
+ [ToolName.ContextAnalyzer]: "@aiready/context-analyzer",
18
+ [ToolName.NamingConsistency]: "@aiready/consistency",
19
+ [ToolName.AiSignalClarity]: "@aiready/ai-signal-clarity",
20
+ [ToolName.AgentGrounding]: "@aiready/agent-grounding",
21
+ [ToolName.TestabilityIndex]: "@aiready/testability",
22
+ [ToolName.DocDrift]: "@aiready/doc-drift",
23
+ [ToolName.DependencyHealth]: "@aiready/deps",
24
+ [ToolName.ChangeAmplification]: "@aiready/change-amplification",
25
+ // Aliases handled by registry
26
+ "patterns": "@aiready/pattern-detect",
27
+ "context": "@aiready/context-analyzer",
28
+ "consistency": "@aiready/consistency"
29
+ };
30
+ async function analyzeUnified(options) {
31
+ const startTime = Date.now();
32
+ const requestedTools = options.tools || ["patterns", "context", "consistency"];
33
+ const result = {
34
+ summary: {
35
+ totalIssues: 0,
36
+ toolsRun: [],
37
+ executionTime: 0
38
+ }
39
+ };
40
+ for (const toolName of requestedTools) {
41
+ let provider = ToolRegistry.find(toolName);
42
+ if (!provider) {
43
+ const packageName = TOOL_PACKAGE_MAP[toolName] || (toolName.startsWith("@aiready/") ? toolName : `@aiready/${toolName}`);
44
+ try {
45
+ await import(packageName);
46
+ provider = ToolRegistry.find(toolName);
47
+ if (provider) {
48
+ console.log(`\u2705 Successfully loaded tool provider: ${toolName} from ${packageName}`);
49
+ } else {
50
+ console.log(`\u26A0\uFE0F Loaded ${packageName} but provider ${toolName} still not found in registry.`);
51
+ }
52
+ } catch (err) {
53
+ console.log(`\u274C Failed to dynamically load tool ${toolName} (${packageName}):`, err.message);
54
+ }
55
+ }
56
+ if (!provider) {
57
+ console.warn(`\u26A0\uFE0F Warning: Tool provider for '${toolName}' not found. Skipping.`);
58
+ continue;
59
+ }
60
+ try {
61
+ const output = await provider.analyze(options);
62
+ if (options.progressCallback) {
63
+ options.progressCallback({ tool: provider.id, data: output });
64
+ }
65
+ result[provider.id] = output;
66
+ result.summary.toolsRun.push(provider.id);
67
+ const issueCount = output.results.reduce(
68
+ (sum, file) => sum + (file.issues?.length || 0),
69
+ 0
70
+ );
71
+ result.summary.totalIssues += issueCount;
72
+ if (provider.id === ToolName.PatternDetect) result.patternDetect = output;
73
+ if (provider.id === ToolName.ContextAnalyzer) result.contextAnalyzer = output;
74
+ } catch (err) {
75
+ console.error(`\u274C Error running tool '${provider.id}':`, err);
76
+ }
77
+ }
78
+ result.summary.executionTime = Date.now() - startTime;
79
+ return result;
80
+ }
81
+ async function scoreUnified(results, options) {
82
+ const toolScores = /* @__PURE__ */ new Map();
83
+ for (const toolId of results.summary.toolsRun) {
84
+ const provider = ToolRegistry.get(toolId);
85
+ if (!provider) continue;
86
+ const output = results[toolId];
87
+ if (!output) continue;
88
+ try {
89
+ const toolScore = provider.score(output, options);
90
+ if (!toolScore.tokenBudget) {
91
+ if (toolId === ToolName.PatternDetect && output.duplicates) {
92
+ const wastedTokens = output.duplicates.reduce(
93
+ (sum, d) => sum + (d.tokenCost || 0),
94
+ 0
95
+ );
96
+ toolScore.tokenBudget = calculateTokenBudget({
97
+ totalContextTokens: wastedTokens * 2,
98
+ wastedTokens: { duplication: wastedTokens, fragmentation: 0, chattiness: 0 }
99
+ });
100
+ } else if (toolId === ToolName.ContextAnalyzer && output.summary) {
101
+ toolScore.tokenBudget = calculateTokenBudget({
102
+ totalContextTokens: output.summary.totalTokens,
103
+ wastedTokens: { duplication: 0, fragmentation: output.summary.totalPotentialSavings || 0, chattiness: 0 }
104
+ });
105
+ }
106
+ }
107
+ toolScores.set(toolId, toolScore);
108
+ } catch (err) {
109
+ console.error(`\u274C Error scoring tool '${toolId}':`, err);
110
+ }
111
+ }
112
+ if (toolScores.size === 0) {
113
+ return {
114
+ overall: 0,
115
+ rating: "Critical",
116
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
117
+ toolsUsed: [],
118
+ breakdown: [],
119
+ calculation: {
120
+ formula: "0 / 0 = 0",
121
+ weights: {},
122
+ normalized: "0 / 0 = 0"
123
+ }
124
+ };
125
+ }
126
+ return calculateOverallScore(toolScores, options, void 0);
127
+ }
128
+ function generateUnifiedSummary(result) {
129
+ const { summary } = result;
130
+ let output = `\u{1F680} AIReady Analysis Complete
131
+
132
+ `;
133
+ output += `\u{1F4CA} Summary:
134
+ `;
135
+ output += ` Tools run: ${summary.toolsRun.join(", ")}
136
+ `;
137
+ output += ` Total issues found: ${summary.totalIssues}
138
+ `;
139
+ output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
140
+
141
+ `;
142
+ for (const provider of ToolRegistry.getAll()) {
143
+ const toolResult = result[provider.id];
144
+ if (toolResult) {
145
+ const issueCount = toolResult.results.reduce(
146
+ (sum, r) => sum + (r.issues?.length || 0),
147
+ 0
148
+ );
149
+ output += `\u2022 ${provider.id}: ${issueCount} issues
150
+ `;
151
+ }
152
+ }
153
+ return output;
154
+ }
155
+
156
+ export {
157
+ __require,
158
+ analyzeUnified,
159
+ scoreUnified,
160
+ generateUnifiedSummary
161
+ };