@aiready/cli 0.14.6 → 0.14.8

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,302 +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 sanitizeConfigRecursive(obj) {
49
- if (!obj || typeof obj !== "object" || Array.isArray(obj)) return obj;
50
- const sanitized = {};
51
- const infraToStrip = [
52
- "rootDir",
53
- "onProgress",
54
- "progressCallback",
55
- "streamResults",
56
- "batchSize"
57
- ];
58
- for (const [key, value] of Object.entries(obj)) {
59
- if (infraToStrip.includes(key)) continue;
60
- if (typeof value === "object" && value !== null && !Array.isArray(value)) {
61
- sanitized[key] = sanitizeConfigRecursive(value);
62
- } else {
63
- sanitized[key] = value;
64
- }
65
- }
66
- return sanitized;
67
- }
68
- function sanitizeToolConfig(config) {
69
- return sanitizeConfigRecursive(config);
70
- }
71
- async function analyzeUnified(options) {
72
- const startTime = Date.now();
73
- const requestedTools = options.tools || [
74
- "patterns",
75
- "context",
76
- "consistency"
77
- ];
78
- const result = {
79
- summary: {
80
- totalIssues: 0,
81
- criticalIssues: 0,
82
- // Added as per instruction
83
- majorIssues: 0,
84
- // Added as per instruction
85
- totalFiles: 0,
86
- toolsRun: [],
87
- executionTime: 0,
88
- config: options,
89
- toolConfigs: {}
90
- }
91
- };
92
- for (const toolName of requestedTools) {
93
- let provider = ToolRegistry.find(toolName);
94
- if (!provider) {
95
- const packageName = TOOL_PACKAGE_MAP[toolName] || (toolName.startsWith("@aiready/") ? toolName : `@aiready/${toolName}`);
96
- try {
97
- await import(packageName);
98
- provider = ToolRegistry.find(toolName);
99
- if (provider) {
100
- console.log(
101
- `\u2705 Successfully loaded tool provider: ${toolName} from ${packageName}`
102
- );
103
- } else {
104
- console.log(
105
- `\u26A0\uFE0F Loaded ${packageName} but provider ${toolName} still not found in registry.`
106
- );
107
- }
108
- } catch (err) {
109
- console.log(
110
- `\u274C Failed to dynamically load tool ${toolName} (${packageName}):`,
111
- err.message
112
- );
113
- }
114
- }
115
- if (!provider) {
116
- console.warn(
117
- `\u26A0\uFE0F Warning: Tool provider for '${toolName}' not found. Skipping.`
118
- );
119
- continue;
120
- }
121
- try {
122
- const sanitizedOptions = { ...options };
123
- delete sanitizedOptions.onProgress;
124
- delete sanitizedOptions.progressCallback;
125
- const toolOptions = {
126
- rootDir: options.rootDir
127
- // Always include rootDir
128
- };
129
- [...GLOBAL_INFRA_OPTIONS, ...COMMON_FINE_TUNING_OPTIONS].forEach(
130
- (key) => {
131
- if (key in options && key !== "toolConfigs" && key !== "tools") {
132
- toolOptions[key] = options[key];
133
- }
134
- }
135
- );
136
- if (options.toolConfigs?.[provider.id]) {
137
- Object.assign(toolOptions, options.toolConfigs[provider.id]);
138
- } else if (options.tools && !Array.isArray(options.tools) && typeof options.tools === "object" && options.tools[provider.id]) {
139
- Object.assign(toolOptions, options.tools[provider.id]);
140
- } else if (options[provider.id]) {
141
- Object.assign(toolOptions, options[provider.id]);
142
- }
143
- toolOptions.onProgress = (processed, total, message) => {
144
- if (options.progressCallback) {
145
- options.progressCallback({
146
- tool: provider.id,
147
- processed,
148
- total,
149
- message
150
- });
151
- }
152
- };
153
- const output = await provider.analyze(toolOptions);
154
- if (output.metadata) {
155
- output.metadata.config = sanitizeToolConfig(toolOptions);
156
- }
157
- if (options.progressCallback) {
158
- options.progressCallback({ tool: provider.id, data: output });
159
- }
160
- result[provider.id] = output;
161
- result.summary.toolsRun.push(provider.id);
162
- if (output.summary?.config) {
163
- result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
164
- output.summary.config
165
- );
166
- } else if (output.metadata?.config) {
167
- result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
168
- output.metadata.config
169
- );
170
- } else {
171
- result.summary.toolConfigs[provider.id] = sanitizeToolConfig(toolOptions);
172
- }
173
- const toolFiles = output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
174
- if (toolFiles > result.summary.totalFiles) {
175
- result.summary.totalFiles = toolFiles;
176
- }
177
- const issueCount = output.results.reduce(
178
- (sum, file) => sum + (file.issues?.length || 0),
179
- 0
180
- );
181
- result.summary.totalIssues += issueCount;
182
- if (provider.alias && Array.isArray(provider.alias)) {
183
- for (const alias of provider.alias) {
184
- if (!result[alias]) {
185
- result[alias] = output;
186
- }
187
- }
188
- }
189
- const camelCaseId = provider.id.replace(
190
- /-([a-z])/g,
191
- (g) => g[1].toUpperCase()
192
- );
193
- if (camelCaseId !== provider.id && !result[camelCaseId]) {
194
- result[camelCaseId] = output;
195
- }
196
- } catch (err) {
197
- console.error(`\u274C Error running tool '${provider.id}':`, err);
198
- }
199
- }
200
- result.summary.config = sanitizeConfigRecursive({
201
- scan: {
202
- tools: requestedTools,
203
- include: options.include,
204
- exclude: options.exclude
205
- },
206
- // Use 'tools' for tool-specific configurations to match AIReadyConfig
207
- tools: result.summary.toolConfigs,
208
- // Keep top-level options for backward compatibility
209
- useSmartDefaults: options.useSmartDefaults
210
- });
211
- result.summary.executionTime = Date.now() - startTime;
212
- return result;
213
- }
214
- async function scoreUnified(results, options) {
215
- const toolScores = /* @__PURE__ */ new Map();
216
- for (const toolId of results.summary.toolsRun) {
217
- const provider = ToolRegistry.get(toolId);
218
- if (!provider) continue;
219
- const output = results[toolId];
220
- if (!output) continue;
221
- try {
222
- const toolScore = provider.score(output, options);
223
- if (!toolScore.tokenBudget) {
224
- if (toolId === ToolName.PatternDetect && output.duplicates) {
225
- const wastedTokens = output.duplicates.reduce(
226
- (sum, d) => sum + (d.tokenCost || 0),
227
- 0
228
- );
229
- toolScore.tokenBudget = calculateTokenBudget({
230
- totalContextTokens: wastedTokens * 2,
231
- wastedTokens: {
232
- duplication: wastedTokens,
233
- fragmentation: 0,
234
- chattiness: 0
235
- }
236
- });
237
- } else if (toolId === ToolName.ContextAnalyzer && output.summary) {
238
- toolScore.tokenBudget = calculateTokenBudget({
239
- totalContextTokens: output.summary.totalTokens,
240
- wastedTokens: {
241
- duplication: 0,
242
- fragmentation: output.summary.totalPotentialSavings || 0,
243
- chattiness: 0
244
- }
245
- });
246
- }
247
- }
248
- toolScores.set(toolId, toolScore);
249
- } catch (err) {
250
- console.error(`\u274C Error scoring tool '${toolId}':`, err);
251
- }
252
- }
253
- if (toolScores.size === 0) {
254
- return {
255
- overall: 0,
256
- rating: "Critical",
257
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
258
- toolsUsed: [],
259
- breakdown: [],
260
- calculation: {
261
- formula: "0 / 0 = 0",
262
- weights: {},
263
- normalized: "0 / 0 = 0"
264
- }
265
- };
266
- }
267
- return calculateOverallScore(toolScores, options, void 0);
268
- }
269
- function generateUnifiedSummary(result) {
270
- const { summary } = result;
271
- let output = `\u{1F680} AIReady Analysis Complete
272
-
273
- `;
274
- output += `\u{1F4CA} Summary:
275
- `;
276
- output += ` Tools run: ${summary.toolsRun.join(", ")}
277
- `;
278
- output += ` Total issues found: ${summary.totalIssues}
279
- `;
280
- output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
281
-
282
- `;
283
- for (const provider of ToolRegistry.getAll()) {
284
- const toolResult = result[provider.id];
285
- if (toolResult) {
286
- const issueCount = toolResult.results.reduce(
287
- (sum, r) => sum + (r.issues?.length || 0),
288
- 0
289
- );
290
- output += `\u2022 ${provider.id}: ${issueCount} issues
291
- `;
292
- }
293
- }
294
- return output;
295
- }
296
-
297
- export {
298
- __require,
299
- analyzeUnified,
300
- scoreUnified,
301
- generateUnifiedSummary
302
- };
@@ -1,282 +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
- 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
- };