@aiready/cli 0.12.9 → 0.12.11
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.
- package/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-test.log +18 -18
- package/dist/chunk-7MDDDPX6.mjs +273 -0
- package/dist/chunk-CZBMZD6J.mjs +282 -0
- package/dist/chunk-DWSC3FOY.mjs +241 -0
- package/dist/chunk-EPASFL7Y.mjs +281 -0
- package/dist/chunk-HWO2J4GA.mjs +250 -0
- package/dist/chunk-OOQTTRPG.mjs +280 -0
- package/dist/chunk-XUNVVWID.mjs +272 -0
- package/dist/chunk-YNGTO2UX.mjs +277 -0
- package/dist/cli.js +57 -18
- package/dist/cli.mjs +5 -5
- package/dist/index.js +53 -14
- package/dist/index.mjs +1 -1
- package/package.json +12 -12
- package/src/.aiready/aiready-report-20260307-135349.json +57041 -0
- package/src/.aiready/aiready-report-20260307-151834.json +41620 -0
- package/src/.aiready/aiready-report-20260307-152644.json +41620 -0
- package/src/.aiready/aiready-report-20260307-155007.json +41501 -0
- package/src/commands/scan.ts +7 -5
- package/src/index.ts +82 -15
|
@@ -0,0 +1,272 @@
|
|
|
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
|
+
var GLOBAL_SCAN_OPTIONS = [
|
|
47
|
+
"rootDir",
|
|
48
|
+
"tools",
|
|
49
|
+
"toolConfigs",
|
|
50
|
+
"include",
|
|
51
|
+
"exclude",
|
|
52
|
+
"onProgress",
|
|
53
|
+
"progressCallback",
|
|
54
|
+
"includeTests",
|
|
55
|
+
"useSmartDefaults",
|
|
56
|
+
"maxDepth",
|
|
57
|
+
"streamResults",
|
|
58
|
+
"batchSize"
|
|
59
|
+
];
|
|
60
|
+
function sanitizeToolConfig(config) {
|
|
61
|
+
if (!config || typeof config !== "object") return config;
|
|
62
|
+
const sanitized = { ...config };
|
|
63
|
+
GLOBAL_SCAN_OPTIONS.forEach((key) => {
|
|
64
|
+
delete sanitized[key];
|
|
65
|
+
});
|
|
66
|
+
return sanitized;
|
|
67
|
+
}
|
|
68
|
+
async function analyzeUnified(options) {
|
|
69
|
+
const startTime = Date.now();
|
|
70
|
+
const requestedTools = options.tools || [
|
|
71
|
+
"patterns",
|
|
72
|
+
"context",
|
|
73
|
+
"consistency"
|
|
74
|
+
];
|
|
75
|
+
const result = {
|
|
76
|
+
summary: {
|
|
77
|
+
totalIssues: 0,
|
|
78
|
+
criticalIssues: 0,
|
|
79
|
+
// Added as per instruction
|
|
80
|
+
majorIssues: 0,
|
|
81
|
+
// Added as per instruction
|
|
82
|
+
totalFiles: 0,
|
|
83
|
+
toolsRun: [],
|
|
84
|
+
executionTime: 0,
|
|
85
|
+
config: options,
|
|
86
|
+
toolConfigs: {}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
for (const toolName of requestedTools) {
|
|
90
|
+
let provider = ToolRegistry.find(toolName);
|
|
91
|
+
if (!provider) {
|
|
92
|
+
const packageName = TOOL_PACKAGE_MAP[toolName] || (toolName.startsWith("@aiready/") ? toolName : `@aiready/${toolName}`);
|
|
93
|
+
try {
|
|
94
|
+
await import(packageName);
|
|
95
|
+
provider = ToolRegistry.find(toolName);
|
|
96
|
+
if (provider) {
|
|
97
|
+
console.log(
|
|
98
|
+
`\u2705 Successfully loaded tool provider: ${toolName} from ${packageName}`
|
|
99
|
+
);
|
|
100
|
+
} else {
|
|
101
|
+
console.log(
|
|
102
|
+
`\u26A0\uFE0F Loaded ${packageName} but provider ${toolName} still not found in registry.`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
} catch (err) {
|
|
106
|
+
console.log(
|
|
107
|
+
`\u274C Failed to dynamically load tool ${toolName} (${packageName}):`,
|
|
108
|
+
err.message
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (!provider) {
|
|
113
|
+
console.warn(
|
|
114
|
+
`\u26A0\uFE0F Warning: Tool provider for '${toolName}' not found. Skipping.`
|
|
115
|
+
);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
const sanitizedConfig = { ...options };
|
|
120
|
+
delete sanitizedConfig.onProgress;
|
|
121
|
+
delete sanitizedConfig.progressCallback;
|
|
122
|
+
const toolOptions = {
|
|
123
|
+
...options,
|
|
124
|
+
...options.toolConfigs?.[provider.id] || {},
|
|
125
|
+
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
|
+
};
|
|
136
|
+
const output = await provider.analyze(toolOptions);
|
|
137
|
+
if (output.metadata) {
|
|
138
|
+
output.metadata.config = sanitizedConfig;
|
|
139
|
+
}
|
|
140
|
+
if (options.progressCallback) {
|
|
141
|
+
options.progressCallback({ tool: provider.id, data: output });
|
|
142
|
+
}
|
|
143
|
+
result[provider.id] = output;
|
|
144
|
+
result.summary.toolsRun.push(provider.id);
|
|
145
|
+
if (output.summary?.config) {
|
|
146
|
+
result.summary.toolConfigs[provider.id] = sanitizeToolConfig(output.summary.config);
|
|
147
|
+
} else if (output.metadata?.config) {
|
|
148
|
+
result.summary.toolConfigs[provider.id] = sanitizeToolConfig(output.metadata.config);
|
|
149
|
+
}
|
|
150
|
+
const toolFiles = output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
|
|
151
|
+
if (toolFiles > result.summary.totalFiles) {
|
|
152
|
+
result.summary.totalFiles = toolFiles;
|
|
153
|
+
}
|
|
154
|
+
const issueCount = output.results.reduce(
|
|
155
|
+
(sum, file) => sum + (file.issues?.length || 0),
|
|
156
|
+
0
|
|
157
|
+
);
|
|
158
|
+
result.summary.totalIssues += issueCount;
|
|
159
|
+
if (provider.alias && Array.isArray(provider.alias)) {
|
|
160
|
+
for (const alias of provider.alias) {
|
|
161
|
+
if (!result[alias]) {
|
|
162
|
+
result[alias] = output;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const camelCaseId = provider.id.replace(
|
|
167
|
+
/-([a-z])/g,
|
|
168
|
+
(g) => g[1].toUpperCase()
|
|
169
|
+
);
|
|
170
|
+
if (camelCaseId !== provider.id && !result[camelCaseId]) {
|
|
171
|
+
result[camelCaseId] = output;
|
|
172
|
+
}
|
|
173
|
+
} catch (err) {
|
|
174
|
+
console.error(`\u274C Error running tool '${provider.id}':`, err);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
result.summary.config = {
|
|
178
|
+
...options,
|
|
179
|
+
toolConfigs: result.summary.toolConfigs
|
|
180
|
+
};
|
|
181
|
+
result.summary.executionTime = Date.now() - startTime;
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
async function scoreUnified(results, options) {
|
|
185
|
+
const toolScores = /* @__PURE__ */ new Map();
|
|
186
|
+
for (const toolId of results.summary.toolsRun) {
|
|
187
|
+
const provider = ToolRegistry.get(toolId);
|
|
188
|
+
if (!provider) continue;
|
|
189
|
+
const output = results[toolId];
|
|
190
|
+
if (!output) continue;
|
|
191
|
+
try {
|
|
192
|
+
const toolScore = provider.score(output, options);
|
|
193
|
+
if (!toolScore.tokenBudget) {
|
|
194
|
+
if (toolId === ToolName.PatternDetect && output.duplicates) {
|
|
195
|
+
const wastedTokens = output.duplicates.reduce(
|
|
196
|
+
(sum, d) => sum + (d.tokenCost || 0),
|
|
197
|
+
0
|
|
198
|
+
);
|
|
199
|
+
toolScore.tokenBudget = calculateTokenBudget({
|
|
200
|
+
totalContextTokens: wastedTokens * 2,
|
|
201
|
+
wastedTokens: {
|
|
202
|
+
duplication: wastedTokens,
|
|
203
|
+
fragmentation: 0,
|
|
204
|
+
chattiness: 0
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
} else if (toolId === ToolName.ContextAnalyzer && output.summary) {
|
|
208
|
+
toolScore.tokenBudget = calculateTokenBudget({
|
|
209
|
+
totalContextTokens: output.summary.totalTokens,
|
|
210
|
+
wastedTokens: {
|
|
211
|
+
duplication: 0,
|
|
212
|
+
fragmentation: output.summary.totalPotentialSavings || 0,
|
|
213
|
+
chattiness: 0
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
toolScores.set(toolId, toolScore);
|
|
219
|
+
} catch (err) {
|
|
220
|
+
console.error(`\u274C Error scoring tool '${toolId}':`, err);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (toolScores.size === 0) {
|
|
224
|
+
return {
|
|
225
|
+
overall: 0,
|
|
226
|
+
rating: "Critical",
|
|
227
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
228
|
+
toolsUsed: [],
|
|
229
|
+
breakdown: [],
|
|
230
|
+
calculation: {
|
|
231
|
+
formula: "0 / 0 = 0",
|
|
232
|
+
weights: {},
|
|
233
|
+
normalized: "0 / 0 = 0"
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
return calculateOverallScore(toolScores, options, void 0);
|
|
238
|
+
}
|
|
239
|
+
function generateUnifiedSummary(result) {
|
|
240
|
+
const { summary } = result;
|
|
241
|
+
let output = `\u{1F680} AIReady Analysis Complete
|
|
242
|
+
|
|
243
|
+
`;
|
|
244
|
+
output += `\u{1F4CA} Summary:
|
|
245
|
+
`;
|
|
246
|
+
output += ` Tools run: ${summary.toolsRun.join(", ")}
|
|
247
|
+
`;
|
|
248
|
+
output += ` Total issues found: ${summary.totalIssues}
|
|
249
|
+
`;
|
|
250
|
+
output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
|
|
251
|
+
|
|
252
|
+
`;
|
|
253
|
+
for (const provider of ToolRegistry.getAll()) {
|
|
254
|
+
const toolResult = result[provider.id];
|
|
255
|
+
if (toolResult) {
|
|
256
|
+
const issueCount = toolResult.results.reduce(
|
|
257
|
+
(sum, r) => sum + (r.issues?.length || 0),
|
|
258
|
+
0
|
|
259
|
+
);
|
|
260
|
+
output += `\u2022 ${provider.id}: ${issueCount} issues
|
|
261
|
+
`;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return output;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export {
|
|
268
|
+
__require,
|
|
269
|
+
analyzeUnified,
|
|
270
|
+
scoreUnified,
|
|
271
|
+
generateUnifiedSummary
|
|
272
|
+
};
|
|
@@ -0,0 +1,277 @@
|
|
|
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(
|
|
146
|
+
output.summary.config
|
|
147
|
+
);
|
|
148
|
+
} else if (output.metadata?.config) {
|
|
149
|
+
result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
|
|
150
|
+
output.metadata.config
|
|
151
|
+
);
|
|
152
|
+
} else {
|
|
153
|
+
result.summary.toolConfigs[provider.id] = sanitizeToolConfig(toolOptions);
|
|
154
|
+
}
|
|
155
|
+
const toolFiles = output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
|
|
156
|
+
if (toolFiles > result.summary.totalFiles) {
|
|
157
|
+
result.summary.totalFiles = toolFiles;
|
|
158
|
+
}
|
|
159
|
+
const issueCount = output.results.reduce(
|
|
160
|
+
(sum, file) => sum + (file.issues?.length || 0),
|
|
161
|
+
0
|
|
162
|
+
);
|
|
163
|
+
result.summary.totalIssues += issueCount;
|
|
164
|
+
if (provider.alias && Array.isArray(provider.alias)) {
|
|
165
|
+
for (const alias of provider.alias) {
|
|
166
|
+
if (!result[alias]) {
|
|
167
|
+
result[alias] = output;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const camelCaseId = provider.id.replace(
|
|
172
|
+
/-([a-z])/g,
|
|
173
|
+
(g) => g[1].toUpperCase()
|
|
174
|
+
);
|
|
175
|
+
if (camelCaseId !== provider.id && !result[camelCaseId]) {
|
|
176
|
+
result[camelCaseId] = output;
|
|
177
|
+
}
|
|
178
|
+
} catch (err) {
|
|
179
|
+
console.error(`\u274C Error running tool '${provider.id}':`, err);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
result.summary.config = {
|
|
183
|
+
...options,
|
|
184
|
+
toolConfigs: result.summary.toolConfigs
|
|
185
|
+
};
|
|
186
|
+
result.summary.executionTime = Date.now() - startTime;
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
async function scoreUnified(results, options) {
|
|
190
|
+
const toolScores = /* @__PURE__ */ new Map();
|
|
191
|
+
for (const toolId of results.summary.toolsRun) {
|
|
192
|
+
const provider = ToolRegistry.get(toolId);
|
|
193
|
+
if (!provider) continue;
|
|
194
|
+
const output = results[toolId];
|
|
195
|
+
if (!output) continue;
|
|
196
|
+
try {
|
|
197
|
+
const toolScore = provider.score(output, options);
|
|
198
|
+
if (!toolScore.tokenBudget) {
|
|
199
|
+
if (toolId === ToolName.PatternDetect && output.duplicates) {
|
|
200
|
+
const wastedTokens = output.duplicates.reduce(
|
|
201
|
+
(sum, d) => sum + (d.tokenCost || 0),
|
|
202
|
+
0
|
|
203
|
+
);
|
|
204
|
+
toolScore.tokenBudget = calculateTokenBudget({
|
|
205
|
+
totalContextTokens: wastedTokens * 2,
|
|
206
|
+
wastedTokens: {
|
|
207
|
+
duplication: wastedTokens,
|
|
208
|
+
fragmentation: 0,
|
|
209
|
+
chattiness: 0
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
} else if (toolId === ToolName.ContextAnalyzer && output.summary) {
|
|
213
|
+
toolScore.tokenBudget = calculateTokenBudget({
|
|
214
|
+
totalContextTokens: output.summary.totalTokens,
|
|
215
|
+
wastedTokens: {
|
|
216
|
+
duplication: 0,
|
|
217
|
+
fragmentation: output.summary.totalPotentialSavings || 0,
|
|
218
|
+
chattiness: 0
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
toolScores.set(toolId, toolScore);
|
|
224
|
+
} catch (err) {
|
|
225
|
+
console.error(`\u274C Error scoring tool '${toolId}':`, err);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (toolScores.size === 0) {
|
|
229
|
+
return {
|
|
230
|
+
overall: 0,
|
|
231
|
+
rating: "Critical",
|
|
232
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
233
|
+
toolsUsed: [],
|
|
234
|
+
breakdown: [],
|
|
235
|
+
calculation: {
|
|
236
|
+
formula: "0 / 0 = 0",
|
|
237
|
+
weights: {},
|
|
238
|
+
normalized: "0 / 0 = 0"
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
return calculateOverallScore(toolScores, options, void 0);
|
|
243
|
+
}
|
|
244
|
+
function generateUnifiedSummary(result) {
|
|
245
|
+
const { summary } = result;
|
|
246
|
+
let output = `\u{1F680} AIReady Analysis Complete
|
|
247
|
+
|
|
248
|
+
`;
|
|
249
|
+
output += `\u{1F4CA} Summary:
|
|
250
|
+
`;
|
|
251
|
+
output += ` Tools run: ${summary.toolsRun.join(", ")}
|
|
252
|
+
`;
|
|
253
|
+
output += ` Total issues found: ${summary.totalIssues}
|
|
254
|
+
`;
|
|
255
|
+
output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
|
|
256
|
+
|
|
257
|
+
`;
|
|
258
|
+
for (const provider of ToolRegistry.getAll()) {
|
|
259
|
+
const toolResult = result[provider.id];
|
|
260
|
+
if (toolResult) {
|
|
261
|
+
const issueCount = toolResult.results.reduce(
|
|
262
|
+
(sum, r) => sum + (r.issues?.length || 0),
|
|
263
|
+
0
|
|
264
|
+
);
|
|
265
|
+
output += `\u2022 ${provider.id}: ${issueCount} issues
|
|
266
|
+
`;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return output;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export {
|
|
273
|
+
__require,
|
|
274
|
+
analyzeUnified,
|
|
275
|
+
scoreUnified,
|
|
276
|
+
generateUnifiedSummary
|
|
277
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -68,6 +68,16 @@ var TOOL_PACKAGE_MAP = {
|
|
|
68
68
|
"deps-health": "@aiready/deps",
|
|
69
69
|
"change-amp": "@aiready/change-amplification"
|
|
70
70
|
};
|
|
71
|
+
function sanitizeToolConfig(config) {
|
|
72
|
+
if (!config || typeof config !== "object") return config;
|
|
73
|
+
const sanitized = { ...config };
|
|
74
|
+
import_core.GLOBAL_INFRA_OPTIONS.forEach((key) => {
|
|
75
|
+
if (key !== "rootDir") {
|
|
76
|
+
delete sanitized[key];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return sanitized;
|
|
80
|
+
}
|
|
71
81
|
async function analyzeUnified(options) {
|
|
72
82
|
const startTime = Date.now();
|
|
73
83
|
const requestedTools = options.tools || [
|
|
@@ -85,8 +95,8 @@ async function analyzeUnified(options) {
|
|
|
85
95
|
totalFiles: 0,
|
|
86
96
|
toolsRun: [],
|
|
87
97
|
executionTime: 0,
|
|
88
|
-
config: options
|
|
89
|
-
|
|
98
|
+
config: options,
|
|
99
|
+
toolConfigs: {}
|
|
90
100
|
}
|
|
91
101
|
};
|
|
92
102
|
for (const toolName of requestedTools) {
|
|
@@ -122,27 +132,52 @@ async function analyzeUnified(options) {
|
|
|
122
132
|
const sanitizedConfig = { ...options };
|
|
123
133
|
delete sanitizedConfig.onProgress;
|
|
124
134
|
delete sanitizedConfig.progressCallback;
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
message
|
|
134
|
-
});
|
|
135
|
+
const toolOptions = {
|
|
136
|
+
rootDir: options.rootDir
|
|
137
|
+
// Always include rootDir
|
|
138
|
+
};
|
|
139
|
+
[...import_core.GLOBAL_INFRA_OPTIONS, ...import_core.COMMON_FINE_TUNING_OPTIONS].forEach(
|
|
140
|
+
(key) => {
|
|
141
|
+
if (key in options && key !== "toolConfigs") {
|
|
142
|
+
toolOptions[key] = options[key];
|
|
135
143
|
}
|
|
136
144
|
}
|
|
137
|
-
|
|
145
|
+
);
|
|
146
|
+
if (options.toolConfigs?.[provider.id]) {
|
|
147
|
+
Object.assign(toolOptions, options.toolConfigs[provider.id]);
|
|
148
|
+
} else if (options[provider.id]) {
|
|
149
|
+
Object.assign(toolOptions, options[provider.id]);
|
|
150
|
+
}
|
|
151
|
+
toolOptions.onProgress = (processed, total, message) => {
|
|
152
|
+
if (options.progressCallback) {
|
|
153
|
+
options.progressCallback({
|
|
154
|
+
tool: provider.id,
|
|
155
|
+
processed,
|
|
156
|
+
total,
|
|
157
|
+
message
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const output = await provider.analyze(toolOptions);
|
|
138
162
|
if (output.metadata) {
|
|
139
|
-
output.metadata.config =
|
|
163
|
+
output.metadata.config = sanitizeToolConfig(toolOptions);
|
|
140
164
|
}
|
|
141
165
|
if (options.progressCallback) {
|
|
142
166
|
options.progressCallback({ tool: provider.id, data: output });
|
|
143
167
|
}
|
|
144
168
|
result[provider.id] = output;
|
|
145
169
|
result.summary.toolsRun.push(provider.id);
|
|
170
|
+
if (output.summary?.config) {
|
|
171
|
+
result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
|
|
172
|
+
output.summary.config
|
|
173
|
+
);
|
|
174
|
+
} else if (output.metadata?.config) {
|
|
175
|
+
result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
|
|
176
|
+
output.metadata.config
|
|
177
|
+
);
|
|
178
|
+
} else {
|
|
179
|
+
result.summary.toolConfigs[provider.id] = sanitizeToolConfig(toolOptions);
|
|
180
|
+
}
|
|
146
181
|
const toolFiles = output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
|
|
147
182
|
if (toolFiles > result.summary.totalFiles) {
|
|
148
183
|
result.summary.totalFiles = toolFiles;
|
|
@@ -170,6 +205,10 @@ async function analyzeUnified(options) {
|
|
|
170
205
|
console.error(`\u274C Error running tool '${provider.id}':`, err);
|
|
171
206
|
}
|
|
172
207
|
}
|
|
208
|
+
result.summary.config = {
|
|
209
|
+
...options,
|
|
210
|
+
toolConfigs: result.summary.toolConfigs
|
|
211
|
+
};
|
|
173
212
|
result.summary.executionTime = Date.now() - startTime;
|
|
174
213
|
return result;
|
|
175
214
|
}
|
|
@@ -526,12 +565,12 @@ async function scanAction(directory, options) {
|
|
|
526
565
|
const { getSmartDefaults } = await import("@aiready/pattern-detect");
|
|
527
566
|
const patternSmartDefaults = await getSmartDefaults(
|
|
528
567
|
resolvedDir,
|
|
529
|
-
|
|
568
|
+
finalOptions.toolConfigs?.[import_core3.ToolName.PatternDetect] || {}
|
|
530
569
|
);
|
|
531
|
-
finalOptions = {
|
|
570
|
+
if (!finalOptions.toolConfigs) finalOptions.toolConfigs = {};
|
|
571
|
+
finalOptions.toolConfigs[import_core3.ToolName.PatternDetect] = {
|
|
532
572
|
...patternSmartDefaults,
|
|
533
|
-
...finalOptions
|
|
534
|
-
...baseOptions
|
|
573
|
+
...finalOptions.toolConfigs[import_core3.ToolName.PatternDetect]
|
|
535
574
|
};
|
|
536
575
|
}
|
|
537
576
|
console.log(import_chalk3.default.cyan("\n=== AIReady Run Preview ==="));
|
package/dist/cli.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
__require,
|
|
4
4
|
analyzeUnified,
|
|
5
5
|
scoreUnified
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OOQTTRPG.mjs";
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
9
|
import { Command } from "commander";
|
|
@@ -327,12 +327,12 @@ async function scanAction(directory, options) {
|
|
|
327
327
|
const { getSmartDefaults } = await import("@aiready/pattern-detect");
|
|
328
328
|
const patternSmartDefaults = await getSmartDefaults(
|
|
329
329
|
resolvedDir,
|
|
330
|
-
|
|
330
|
+
finalOptions.toolConfigs?.[ToolName.PatternDetect] || {}
|
|
331
331
|
);
|
|
332
|
-
finalOptions = {
|
|
332
|
+
if (!finalOptions.toolConfigs) finalOptions.toolConfigs = {};
|
|
333
|
+
finalOptions.toolConfigs[ToolName.PatternDetect] = {
|
|
333
334
|
...patternSmartDefaults,
|
|
334
|
-
...finalOptions
|
|
335
|
-
...baseOptions
|
|
335
|
+
...finalOptions.toolConfigs[ToolName.PatternDetect]
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
338
|
console.log(chalk3.cyan("\n=== AIReady Run Preview ==="));
|