@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.
- package/.turbo/turbo-build.log +7 -7
- package/package.json +12 -12
- package/dist/chunk-2QOU5KKW.mjs +0 -301
- package/dist/chunk-55ZUD52M.mjs +0 -290
- package/dist/chunk-7K3CNS6C.mjs +0 -234
- package/dist/chunk-7MDDDPX6.mjs +0 -273
- package/dist/chunk-BD7XZYET.mjs +0 -302
- package/dist/chunk-CZBMZD6J.mjs +0 -282
- package/dist/chunk-DWSC3FOY.mjs +0 -241
- package/dist/chunk-EPASFL7Y.mjs +0 -281
- package/dist/chunk-HWO2J4GA.mjs +0 -250
- package/dist/chunk-L4MJHD72.mjs +0 -239
- package/dist/chunk-LTUQDJPO.mjs +0 -229
- package/dist/chunk-N56YAZVN.mjs +0 -194
- package/dist/chunk-OOQTTRPG.mjs +0 -280
- package/dist/chunk-XUNVVWID.mjs +0 -272
- package/dist/chunk-YBZKPKW3.mjs +0 -161
- package/dist/chunk-YNGTO2UX.mjs +0 -277
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @aiready/cli@0.14.
|
|
3
|
+
> @aiready/cli@0.14.7 build /Users/pengcao/projects/aiready/packages/cli
|
|
4
4
|
> tsup src/index.ts src/cli.ts --format cjs,esm
|
|
5
5
|
|
|
6
6
|
[34mCLI[39m Building entry: src/cli.ts, src/index.ts
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
|
|
13
|
-
[43m[30m WARN [39m[49m [33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1m"import.meta" is not available with the "cjs" output format and will be empty[0m [empty-import-meta]
|
|
13
|
+
[90m[[90m12:34:21 pm[90m][39m [43m[30m WARN [39m[49m [33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1m"import.meta" is not available with the "cjs" output format and will be empty[0m [empty-import-meta]
|
|
14
14
|
|
|
15
15
|
src/cli.ts:29:31:
|
|
16
16
|
[37m 29 │ return dirname(fileURLToPath([32mimport.meta[37m.url));
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m170.00 B[39m
|
|
24
|
-
[32mESM[39m [1mdist/chunk-VOKP7FGM.mjs [22m[32m9.52 KB[39m
|
|
25
|
-
[32mESM[39m [1mdist/cli.mjs [22m[32m70.71 KB[39m
|
|
26
|
-
[32mESM[39m ⚡️ Build success in 40ms
|
|
27
23
|
[32mCJS[39m [1mdist/index.js [22m[32m10.62 KB[39m
|
|
28
24
|
[32mCJS[39m [1mdist/cli.js [22m[32m84.50 KB[39m
|
|
29
|
-
[32mCJS[39m ⚡️ Build success in
|
|
25
|
+
[32mCJS[39m ⚡️ Build success in 69ms
|
|
26
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m170.00 B[39m
|
|
27
|
+
[32mESM[39m [1mdist/cli.mjs [22m[32m70.71 KB[39m
|
|
28
|
+
[32mESM[39m [1mdist/chunk-VOKP7FGM.mjs [22m[32m9.52 KB[39m
|
|
29
|
+
[32mESM[39m ⚡️ Build success in 69ms
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/cli",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.7",
|
|
4
4
|
"description": "Unified CLI for AIReady analysis tools",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -11,17 +11,17 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "^5.3.0",
|
|
13
13
|
"commander": "^14.0.0",
|
|
14
|
-
"@aiready/
|
|
15
|
-
"@aiready/
|
|
16
|
-
"@aiready/
|
|
17
|
-
"@aiready/
|
|
18
|
-
"@aiready/
|
|
19
|
-
"@aiready/doc-drift": "0.13.
|
|
20
|
-
"@aiready/
|
|
21
|
-
"@aiready/
|
|
22
|
-
"@aiready/
|
|
23
|
-
"@aiready/
|
|
24
|
-
"@aiready/
|
|
14
|
+
"@aiready/consistency": "0.20.5",
|
|
15
|
+
"@aiready/context-analyzer": "0.21.9",
|
|
16
|
+
"@aiready/agent-grounding": "0.13.5",
|
|
17
|
+
"@aiready/core": "0.23.6",
|
|
18
|
+
"@aiready/deps": "0.13.5",
|
|
19
|
+
"@aiready/doc-drift": "0.13.5",
|
|
20
|
+
"@aiready/testability": "0.6.5",
|
|
21
|
+
"@aiready/visualizer": "0.6.5",
|
|
22
|
+
"@aiready/pattern-detect": "0.16.5",
|
|
23
|
+
"@aiready/change-amplification": "0.13.5",
|
|
24
|
+
"@aiready/ai-signal-clarity": "0.13.5"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^24.0.0",
|
package/dist/chunk-2QOU5KKW.mjs
DELETED
|
@@ -1,301 +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
|
-
"useSmartDefaults"
|
|
58
|
-
];
|
|
59
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
60
|
-
if (infraToStrip.includes(key)) continue;
|
|
61
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
62
|
-
sanitized[key] = sanitizeConfigRecursive(value);
|
|
63
|
-
} else {
|
|
64
|
-
sanitized[key] = value;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return sanitized;
|
|
68
|
-
}
|
|
69
|
-
function sanitizeToolConfig(config) {
|
|
70
|
-
return sanitizeConfigRecursive(config);
|
|
71
|
-
}
|
|
72
|
-
async function analyzeUnified(options) {
|
|
73
|
-
const startTime = Date.now();
|
|
74
|
-
const requestedTools = options.tools || [
|
|
75
|
-
"patterns",
|
|
76
|
-
"context",
|
|
77
|
-
"consistency"
|
|
78
|
-
];
|
|
79
|
-
const result = {
|
|
80
|
-
summary: {
|
|
81
|
-
totalIssues: 0,
|
|
82
|
-
criticalIssues: 0,
|
|
83
|
-
// Added as per instruction
|
|
84
|
-
majorIssues: 0,
|
|
85
|
-
// Added as per instruction
|
|
86
|
-
totalFiles: 0,
|
|
87
|
-
toolsRun: [],
|
|
88
|
-
executionTime: 0,
|
|
89
|
-
config: options,
|
|
90
|
-
toolConfigs: {}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
for (const toolName of requestedTools) {
|
|
94
|
-
let provider = ToolRegistry.find(toolName);
|
|
95
|
-
if (!provider) {
|
|
96
|
-
const packageName = TOOL_PACKAGE_MAP[toolName] || (toolName.startsWith("@aiready/") ? toolName : `@aiready/${toolName}`);
|
|
97
|
-
try {
|
|
98
|
-
await import(packageName);
|
|
99
|
-
provider = ToolRegistry.find(toolName);
|
|
100
|
-
if (provider) {
|
|
101
|
-
console.log(
|
|
102
|
-
`\u2705 Successfully loaded tool provider: ${toolName} from ${packageName}`
|
|
103
|
-
);
|
|
104
|
-
} else {
|
|
105
|
-
console.log(
|
|
106
|
-
`\u26A0\uFE0F Loaded ${packageName} but provider ${toolName} still not found in registry.`
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
} catch (err) {
|
|
110
|
-
console.log(
|
|
111
|
-
`\u274C Failed to dynamically load tool ${toolName} (${packageName}):`,
|
|
112
|
-
err.message
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (!provider) {
|
|
117
|
-
console.warn(
|
|
118
|
-
`\u26A0\uFE0F Warning: Tool provider for '${toolName}' not found. Skipping.`
|
|
119
|
-
);
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
try {
|
|
123
|
-
const sanitizedOptions = { ...options };
|
|
124
|
-
delete sanitizedOptions.onProgress;
|
|
125
|
-
delete sanitizedOptions.progressCallback;
|
|
126
|
-
const toolOptions = {
|
|
127
|
-
rootDir: options.rootDir
|
|
128
|
-
// Always include rootDir
|
|
129
|
-
};
|
|
130
|
-
[...GLOBAL_INFRA_OPTIONS, ...COMMON_FINE_TUNING_OPTIONS].forEach(
|
|
131
|
-
(key) => {
|
|
132
|
-
if (key in options && key !== "toolConfigs" && key !== "tools") {
|
|
133
|
-
toolOptions[key] = options[key];
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
);
|
|
137
|
-
if (options.toolConfigs?.[provider.id]) {
|
|
138
|
-
Object.assign(toolOptions, options.toolConfigs[provider.id]);
|
|
139
|
-
} else if (options.tools && !Array.isArray(options.tools) && typeof options.tools === "object" && options.tools[provider.id]) {
|
|
140
|
-
Object.assign(toolOptions, options.tools[provider.id]);
|
|
141
|
-
} else if (options[provider.id]) {
|
|
142
|
-
Object.assign(toolOptions, options[provider.id]);
|
|
143
|
-
}
|
|
144
|
-
toolOptions.onProgress = (processed, total, message) => {
|
|
145
|
-
if (options.progressCallback) {
|
|
146
|
-
options.progressCallback({
|
|
147
|
-
tool: provider.id,
|
|
148
|
-
processed,
|
|
149
|
-
total,
|
|
150
|
-
message
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
const output = await provider.analyze(toolOptions);
|
|
155
|
-
if (output.metadata) {
|
|
156
|
-
output.metadata.config = sanitizeToolConfig(toolOptions);
|
|
157
|
-
}
|
|
158
|
-
if (options.progressCallback) {
|
|
159
|
-
options.progressCallback({ tool: provider.id, data: output });
|
|
160
|
-
}
|
|
161
|
-
result[provider.id] = output;
|
|
162
|
-
result.summary.toolsRun.push(provider.id);
|
|
163
|
-
if (output.summary?.config) {
|
|
164
|
-
result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
|
|
165
|
-
output.summary.config
|
|
166
|
-
);
|
|
167
|
-
} else if (output.metadata?.config) {
|
|
168
|
-
result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
|
|
169
|
-
output.metadata.config
|
|
170
|
-
);
|
|
171
|
-
} else {
|
|
172
|
-
result.summary.toolConfigs[provider.id] = sanitizeToolConfig(toolOptions);
|
|
173
|
-
}
|
|
174
|
-
const toolFiles = output.summary?.totalFiles || output.summary?.filesAnalyzed || 0;
|
|
175
|
-
if (toolFiles > result.summary.totalFiles) {
|
|
176
|
-
result.summary.totalFiles = toolFiles;
|
|
177
|
-
}
|
|
178
|
-
const issueCount = output.results.reduce(
|
|
179
|
-
(sum, file) => sum + (file.issues?.length || 0),
|
|
180
|
-
0
|
|
181
|
-
);
|
|
182
|
-
result.summary.totalIssues += issueCount;
|
|
183
|
-
if (provider.alias && Array.isArray(provider.alias)) {
|
|
184
|
-
for (const alias of provider.alias) {
|
|
185
|
-
if (!result[alias]) {
|
|
186
|
-
result[alias] = output;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
const camelCaseId = provider.id.replace(
|
|
191
|
-
/-([a-z])/g,
|
|
192
|
-
(g) => g[1].toUpperCase()
|
|
193
|
-
);
|
|
194
|
-
if (camelCaseId !== provider.id && !result[camelCaseId]) {
|
|
195
|
-
result[camelCaseId] = output;
|
|
196
|
-
}
|
|
197
|
-
} catch (err) {
|
|
198
|
-
console.error(`\u274C Error running tool '${provider.id}':`, err);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
result.summary.config = sanitizeConfigRecursive({
|
|
202
|
-
scan: {
|
|
203
|
-
tools: requestedTools,
|
|
204
|
-
include: options.include,
|
|
205
|
-
exclude: options.exclude
|
|
206
|
-
},
|
|
207
|
-
// Use 'tools' for tool-specific configurations to match AIReadyConfig
|
|
208
|
-
tools: result.summary.toolConfigs
|
|
209
|
-
});
|
|
210
|
-
result.summary.executionTime = Date.now() - startTime;
|
|
211
|
-
return result;
|
|
212
|
-
}
|
|
213
|
-
async function scoreUnified(results, options) {
|
|
214
|
-
const toolScores = /* @__PURE__ */ new Map();
|
|
215
|
-
for (const toolId of results.summary.toolsRun) {
|
|
216
|
-
const provider = ToolRegistry.get(toolId);
|
|
217
|
-
if (!provider) continue;
|
|
218
|
-
const output = results[toolId];
|
|
219
|
-
if (!output) continue;
|
|
220
|
-
try {
|
|
221
|
-
const toolScore = provider.score(output, options);
|
|
222
|
-
if (!toolScore.tokenBudget) {
|
|
223
|
-
if (toolId === ToolName.PatternDetect && output.duplicates) {
|
|
224
|
-
const wastedTokens = output.duplicates.reduce(
|
|
225
|
-
(sum, d) => sum + (d.tokenCost || 0),
|
|
226
|
-
0
|
|
227
|
-
);
|
|
228
|
-
toolScore.tokenBudget = calculateTokenBudget({
|
|
229
|
-
totalContextTokens: wastedTokens * 2,
|
|
230
|
-
wastedTokens: {
|
|
231
|
-
duplication: wastedTokens,
|
|
232
|
-
fragmentation: 0,
|
|
233
|
-
chattiness: 0
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
} else if (toolId === ToolName.ContextAnalyzer && output.summary) {
|
|
237
|
-
toolScore.tokenBudget = calculateTokenBudget({
|
|
238
|
-
totalContextTokens: output.summary.totalTokens,
|
|
239
|
-
wastedTokens: {
|
|
240
|
-
duplication: 0,
|
|
241
|
-
fragmentation: output.summary.totalPotentialSavings || 0,
|
|
242
|
-
chattiness: 0
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
toolScores.set(toolId, toolScore);
|
|
248
|
-
} catch (err) {
|
|
249
|
-
console.error(`\u274C Error scoring tool '${toolId}':`, err);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
if (toolScores.size === 0) {
|
|
253
|
-
return {
|
|
254
|
-
overall: 0,
|
|
255
|
-
rating: "Critical",
|
|
256
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
257
|
-
toolsUsed: [],
|
|
258
|
-
breakdown: [],
|
|
259
|
-
calculation: {
|
|
260
|
-
formula: "0 / 0 = 0",
|
|
261
|
-
weights: {},
|
|
262
|
-
normalized: "0 / 0 = 0"
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
return calculateOverallScore(toolScores, options, void 0);
|
|
267
|
-
}
|
|
268
|
-
function generateUnifiedSummary(result) {
|
|
269
|
-
const { summary } = result;
|
|
270
|
-
let output = `\u{1F680} AIReady Analysis Complete
|
|
271
|
-
|
|
272
|
-
`;
|
|
273
|
-
output += `\u{1F4CA} Summary:
|
|
274
|
-
`;
|
|
275
|
-
output += ` Tools run: ${summary.toolsRun.join(", ")}
|
|
276
|
-
`;
|
|
277
|
-
output += ` Total issues found: ${summary.totalIssues}
|
|
278
|
-
`;
|
|
279
|
-
output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
|
|
280
|
-
|
|
281
|
-
`;
|
|
282
|
-
for (const provider of ToolRegistry.getAll()) {
|
|
283
|
-
const toolResult = result[provider.id];
|
|
284
|
-
if (toolResult) {
|
|
285
|
-
const issueCount = toolResult.results.reduce(
|
|
286
|
-
(sum, r) => sum + (r.issues?.length || 0),
|
|
287
|
-
0
|
|
288
|
-
);
|
|
289
|
-
output += `\u2022 ${provider.id}: ${issueCount} issues
|
|
290
|
-
`;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return output;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export {
|
|
297
|
-
__require,
|
|
298
|
-
analyzeUnified,
|
|
299
|
-
scoreUnified,
|
|
300
|
-
generateUnifiedSummary
|
|
301
|
-
};
|
package/dist/chunk-55ZUD52M.mjs
DELETED
|
@@ -1,290 +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" && key !== "tools") {
|
|
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.tools && !Array.isArray(options.tools) && typeof options.tools === "object" && options.tools[provider.id]) {
|
|
126
|
-
Object.assign(toolOptions, options.tools[provider.id]);
|
|
127
|
-
} else if (options[provider.id]) {
|
|
128
|
-
Object.assign(toolOptions, options[provider.id]);
|
|
129
|
-
}
|
|
130
|
-
toolOptions.onProgress = (processed, total, message) => {
|
|
131
|
-
if (options.progressCallback) {
|
|
132
|
-
options.progressCallback({
|
|
133
|
-
tool: provider.id,
|
|
134
|
-
processed,
|
|
135
|
-
total,
|
|
136
|
-
message
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
};
|
|
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
|
-
scan: {
|
|
189
|
-
tools: requestedTools,
|
|
190
|
-
include: options.include,
|
|
191
|
-
exclude: options.exclude
|
|
192
|
-
},
|
|
193
|
-
// Use 'tools' for tool-specific configurations to match AIReadyConfig
|
|
194
|
-
tools: result.summary.toolConfigs,
|
|
195
|
-
// Keep top-level options for backward compatibility
|
|
196
|
-
rootDir: options.rootDir,
|
|
197
|
-
useSmartDefaults: options.useSmartDefaults
|
|
198
|
-
};
|
|
199
|
-
result.summary.executionTime = Date.now() - startTime;
|
|
200
|
-
return result;
|
|
201
|
-
}
|
|
202
|
-
async function scoreUnified(results, options) {
|
|
203
|
-
const toolScores = /* @__PURE__ */ new Map();
|
|
204
|
-
for (const toolId of results.summary.toolsRun) {
|
|
205
|
-
const provider = ToolRegistry.get(toolId);
|
|
206
|
-
if (!provider) continue;
|
|
207
|
-
const output = results[toolId];
|
|
208
|
-
if (!output) continue;
|
|
209
|
-
try {
|
|
210
|
-
const toolScore = provider.score(output, options);
|
|
211
|
-
if (!toolScore.tokenBudget) {
|
|
212
|
-
if (toolId === ToolName.PatternDetect && output.duplicates) {
|
|
213
|
-
const wastedTokens = output.duplicates.reduce(
|
|
214
|
-
(sum, d) => sum + (d.tokenCost || 0),
|
|
215
|
-
0
|
|
216
|
-
);
|
|
217
|
-
toolScore.tokenBudget = calculateTokenBudget({
|
|
218
|
-
totalContextTokens: wastedTokens * 2,
|
|
219
|
-
wastedTokens: {
|
|
220
|
-
duplication: wastedTokens,
|
|
221
|
-
fragmentation: 0,
|
|
222
|
-
chattiness: 0
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
} else if (toolId === ToolName.ContextAnalyzer && output.summary) {
|
|
226
|
-
toolScore.tokenBudget = calculateTokenBudget({
|
|
227
|
-
totalContextTokens: output.summary.totalTokens,
|
|
228
|
-
wastedTokens: {
|
|
229
|
-
duplication: 0,
|
|
230
|
-
fragmentation: output.summary.totalPotentialSavings || 0,
|
|
231
|
-
chattiness: 0
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
toolScores.set(toolId, toolScore);
|
|
237
|
-
} catch (err) {
|
|
238
|
-
console.error(`\u274C Error scoring tool '${toolId}':`, err);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (toolScores.size === 0) {
|
|
242
|
-
return {
|
|
243
|
-
overall: 0,
|
|
244
|
-
rating: "Critical",
|
|
245
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
246
|
-
toolsUsed: [],
|
|
247
|
-
breakdown: [],
|
|
248
|
-
calculation: {
|
|
249
|
-
formula: "0 / 0 = 0",
|
|
250
|
-
weights: {},
|
|
251
|
-
normalized: "0 / 0 = 0"
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
return calculateOverallScore(toolScores, options, void 0);
|
|
256
|
-
}
|
|
257
|
-
function generateUnifiedSummary(result) {
|
|
258
|
-
const { summary } = result;
|
|
259
|
-
let output = `\u{1F680} AIReady Analysis Complete
|
|
260
|
-
|
|
261
|
-
`;
|
|
262
|
-
output += `\u{1F4CA} Summary:
|
|
263
|
-
`;
|
|
264
|
-
output += ` Tools run: ${summary.toolsRun.join(", ")}
|
|
265
|
-
`;
|
|
266
|
-
output += ` Total issues found: ${summary.totalIssues}
|
|
267
|
-
`;
|
|
268
|
-
output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
|
|
269
|
-
|
|
270
|
-
`;
|
|
271
|
-
for (const provider of ToolRegistry.getAll()) {
|
|
272
|
-
const toolResult = result[provider.id];
|
|
273
|
-
if (toolResult) {
|
|
274
|
-
const issueCount = toolResult.results.reduce(
|
|
275
|
-
(sum, r) => sum + (r.issues?.length || 0),
|
|
276
|
-
0
|
|
277
|
-
);
|
|
278
|
-
output += `\u2022 ${provider.id}: ${issueCount} issues
|
|
279
|
-
`;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return output;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
export {
|
|
286
|
-
__require,
|
|
287
|
-
analyzeUnified,
|
|
288
|
-
scoreUnified,
|
|
289
|
-
generateUnifiedSummary
|
|
290
|
-
};
|