@aiready/cli 0.14.6 → 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,234 +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
- "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
- totalFiles: 0,
64
- toolsRun: [],
65
- executionTime: 0
66
- }
67
- };
68
- for (const toolName of requestedTools) {
69
- let provider = ToolRegistry.find(toolName);
70
- if (!provider) {
71
- const packageName = TOOL_PACKAGE_MAP[toolName] || (toolName.startsWith("@aiready/") ? toolName : `@aiready/${toolName}`);
72
- try {
73
- await import(packageName);
74
- provider = ToolRegistry.find(toolName);
75
- if (provider) {
76
- console.log(
77
- `\u2705 Successfully loaded tool provider: ${toolName} from ${packageName}`
78
- );
79
- } else {
80
- console.log(
81
- `\u26A0\uFE0F Loaded ${packageName} but provider ${toolName} still not found in registry.`
82
- );
83
- }
84
- } catch (err) {
85
- console.log(
86
- `\u274C Failed to dynamically load tool ${toolName} (${packageName}):`,
87
- err.message
88
- );
89
- }
90
- }
91
- if (!provider) {
92
- console.warn(
93
- `\u26A0\uFE0F Warning: Tool provider for '${toolName}' not found. Skipping.`
94
- );
95
- continue;
96
- }
97
- try {
98
- const output = await provider.analyze({
99
- ...options,
100
- onProgress: (processed, total, message) => {
101
- if (options.progressCallback) {
102
- options.progressCallback({
103
- tool: provider.id,
104
- processed,
105
- total,
106
- message
107
- });
108
- }
109
- }
110
- });
111
- if (options.progressCallback) {
112
- options.progressCallback({ tool: provider.id, data: output });
113
- }
114
- result[provider.id] = output;
115
- result.summary.toolsRun.push(provider.id);
116
- const toolFiles = output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
117
- if (toolFiles > result.summary.totalFiles) {
118
- result.summary.totalFiles = toolFiles;
119
- }
120
- const issueCount = output.results.reduce(
121
- (sum, file) => sum + (file.issues?.length || 0),
122
- 0
123
- );
124
- result.summary.totalIssues += issueCount;
125
- if (provider.alias && Array.isArray(provider.alias)) {
126
- for (const alias of provider.alias) {
127
- if (!result[alias]) {
128
- result[alias] = output;
129
- }
130
- }
131
- }
132
- const camelCaseId = provider.id.replace(
133
- /-([a-z])/g,
134
- (g) => g[1].toUpperCase()
135
- );
136
- if (camelCaseId !== provider.id && !result[camelCaseId]) {
137
- result[camelCaseId] = output;
138
- }
139
- } catch (err) {
140
- console.error(`\u274C Error running tool '${provider.id}':`, err);
141
- }
142
- }
143
- result.summary.executionTime = Date.now() - startTime;
144
- return result;
145
- }
146
- async function scoreUnified(results, options) {
147
- const toolScores = /* @__PURE__ */ new Map();
148
- for (const toolId of results.summary.toolsRun) {
149
- const provider = ToolRegistry.get(toolId);
150
- if (!provider) continue;
151
- const output = results[toolId];
152
- if (!output) continue;
153
- try {
154
- const toolScore = provider.score(output, options);
155
- if (!toolScore.tokenBudget) {
156
- if (toolId === ToolName.PatternDetect && output.duplicates) {
157
- const wastedTokens = output.duplicates.reduce(
158
- (sum, d) => sum + (d.tokenCost || 0),
159
- 0
160
- );
161
- toolScore.tokenBudget = calculateTokenBudget({
162
- totalContextTokens: wastedTokens * 2,
163
- wastedTokens: {
164
- duplication: wastedTokens,
165
- fragmentation: 0,
166
- chattiness: 0
167
- }
168
- });
169
- } else if (toolId === ToolName.ContextAnalyzer && output.summary) {
170
- toolScore.tokenBudget = calculateTokenBudget({
171
- totalContextTokens: output.summary.totalTokens,
172
- wastedTokens: {
173
- duplication: 0,
174
- fragmentation: output.summary.totalPotentialSavings || 0,
175
- chattiness: 0
176
- }
177
- });
178
- }
179
- }
180
- toolScores.set(toolId, toolScore);
181
- } catch (err) {
182
- console.error(`\u274C Error scoring tool '${toolId}':`, err);
183
- }
184
- }
185
- if (toolScores.size === 0) {
186
- return {
187
- overall: 0,
188
- rating: "Critical",
189
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
190
- toolsUsed: [],
191
- breakdown: [],
192
- calculation: {
193
- formula: "0 / 0 = 0",
194
- weights: {},
195
- normalized: "0 / 0 = 0"
196
- }
197
- };
198
- }
199
- return calculateOverallScore(toolScores, options, void 0);
200
- }
201
- function generateUnifiedSummary(result) {
202
- const { summary } = result;
203
- let output = `\u{1F680} AIReady Analysis Complete
204
-
205
- `;
206
- output += `\u{1F4CA} Summary:
207
- `;
208
- output += ` Tools run: ${summary.toolsRun.join(", ")}
209
- `;
210
- output += ` Total issues found: ${summary.totalIssues}
211
- `;
212
- output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
213
-
214
- `;
215
- for (const provider of ToolRegistry.getAll()) {
216
- const toolResult = result[provider.id];
217
- if (toolResult) {
218
- const issueCount = toolResult.results.reduce(
219
- (sum, r) => sum + (r.issues?.length || 0),
220
- 0
221
- );
222
- output += `\u2022 ${provider.id}: ${issueCount} issues
223
- `;
224
- }
225
- }
226
- return output;
227
- }
228
-
229
- export {
230
- __require,
231
- analyzeUnified,
232
- scoreUnified,
233
- generateUnifiedSummary
234
- };
@@ -1,273 +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_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
- };