@aiready/cli 0.14.5 → 0.14.7

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,241 +0,0 @@
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
- };
@@ -1,281 +0,0 @@
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
- };