@aiready/cli 0.12.8 → 0.12.10
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 +10 -8
- package/.turbo/turbo-test.log +18 -18
- package/dist/chunk-7MDDDPX6.mjs +273 -0
- package/dist/chunk-DWSC3FOY.mjs +241 -0
- package/dist/chunk-HWO2J4GA.mjs +250 -0
- package/dist/chunk-L4MJHD72.mjs +239 -0
- package/dist/chunk-XUNVVWID.mjs +272 -0
- package/dist/chunk-YNGTO2UX.mjs +277 -0
- package/dist/cli.js +62 -20
- package/dist/cli.mjs +1 -1
- package/dist/index.js +62 -20
- package/dist/index.mjs +1 -1
- package/package.json +12 -12
- package/src/.aiready/aiready-report-20260307-132956.json +57041 -0
- package/src/.aiready/aiready-report-20260307-135349.json +57041 -0
- package/src/.aiready/aiready-report-20260307-151834.json +41620 -0
- package/src/index.ts +100 -20
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @aiready/cli@0.12.
|
|
3
|
+
> @aiready/cli@0.12.9 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
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
[34mCLI[39m Target: es2020
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
[90m[[90m3:17:45 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]
|
|
13
14
|
|
|
14
15
|
src/cli.ts:25:31:
|
|
15
16
|
[37m 25 │ return dirname(fileURLToPath([32mimport.meta[37m.url));
|
|
@@ -18,10 +19,11 @@
|
|
|
18
19
|
You need to set the output format to "esm" for "import.meta" to work correctly.
|
|
19
20
|
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
|
|
23
|
+
[32mCJS[39m [1mdist/index.js [22m[32m9.72 KB[39m
|
|
24
|
+
[32mCJS[39m [1mdist/cli.js [22m[32m68.30 KB[39m
|
|
25
|
+
[32mCJS[39m ⚡️ Build success in 33ms
|
|
26
|
+
[32mESM[39m [1mdist/chunk-YNGTO2UX.mjs [22m[32m8.59 KB[39m
|
|
22
27
|
[32mESM[39m [1mdist/index.mjs [22m[32m170.00 B[39m
|
|
23
|
-
[32mESM[39m [1mdist/
|
|
24
|
-
[32mESM[39m ⚡️ Build success in
|
|
25
|
-
[32mCJS[39m [1mdist/cli.js [22m[32m67.00 KB[39m
|
|
26
|
-
[32mCJS[39m [1mdist/index.js [22m[32m8.42 KB[39m
|
|
27
|
-
[32mCJS[39m ⚡️ Build success in 82ms
|
|
28
|
+
[32mESM[39m [1mdist/cli.mjs [22m[32m56.62 KB[39m
|
|
29
|
+
[32mESM[39m ⚡️ Build success in 34ms
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @aiready/cli@0.12.
|
|
3
|
+
> @aiready/cli@0.12.9 test /Users/pengcao/projects/aiready/packages/cli
|
|
4
4
|
> vitest run
|
|
5
5
|
|
|
6
6
|
[?25l
|
|
7
7
|
[1m[46m RUN [49m[22m [36mv4.0.18 [39m[90m/Users/pengcao/projects/aiready/packages/cli[39m
|
|
8
8
|
|
|
9
9
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
10
|
-
[22m[39m[ToolRegistry#0.
|
|
10
|
+
[22m[39m[ToolRegistry#0.846301580251078] Registering tool: pattern-detect (patterns, duplicates, duplication)
|
|
11
11
|
|
|
12
12
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
13
|
-
[22m[39m[ToolRegistry#0.
|
|
13
|
+
[22m[39m[ToolRegistry#0.846301580251078] Registering tool: context-analyzer (context, fragmentation, budget)
|
|
14
14
|
|
|
15
15
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
16
|
-
[22m[39m[ToolRegistry#0.
|
|
16
|
+
[22m[39m[ToolRegistry#0.846301580251078] Registering tool: naming-consistency (consistency, naming, standards)
|
|
17
17
|
|
|
18
18
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
19
|
-
[22m[39m[ToolRegistry#0.
|
|
19
|
+
[22m[39m[ToolRegistry#0.846301580251078] Registering tool: ai-signal-clarity (ai-signal, clarity, hallucination)
|
|
20
20
|
|
|
21
21
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
22
|
-
[22m[39m[ToolRegistry#0.
|
|
22
|
+
[22m[39m[ToolRegistry#0.846301580251078] Registering tool: agent-grounding (agent-grounding, grounding, navigation)
|
|
23
23
|
|
|
24
24
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
25
|
-
[22m[39m[ToolRegistry#0.
|
|
25
|
+
[22m[39m[ToolRegistry#0.846301580251078] Registering tool: testability-index (testability, tests, verification)
|
|
26
26
|
|
|
27
27
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
28
|
-
[22m[39m[ToolRegistry#0.
|
|
28
|
+
[22m[39m[ToolRegistry#0.846301580251078] Registering tool: doc-drift (doc-drift, docs, jsdoc)
|
|
29
29
|
|
|
30
30
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
31
|
-
[22m[39m[ToolRegistry#0.
|
|
31
|
+
[22m[39m[ToolRegistry#0.846301580251078] Registering tool: dependency-health (deps, deps-health, packages)
|
|
32
32
|
|
|
33
33
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
34
|
-
[22m[39m[ToolRegistry#0.
|
|
34
|
+
[22m[39m[ToolRegistry#0.846301580251078] Registering tool: change-amplification (change-amp, change-amplification, coupling)
|
|
35
35
|
|
|
36
36
|
[90mstdout[2m | src/__tests__/cli.test.ts[2m > [22m[2mCLI Unified Analysis[2m > [22m[2mshould run unified analysis with both tools
|
|
37
|
-
[22m[39m[ToolRegistry#0.
|
|
38
|
-
[ToolRegistry#0.
|
|
37
|
+
[22m[39m[ToolRegistry#0.846301580251078] Registering tool: pattern-detect (patterns)
|
|
38
|
+
[ToolRegistry#0.846301580251078] Registering tool: context-analyzer (context)
|
|
39
39
|
|
|
40
40
|
[90mstdout[2m | src/__tests__/cli.test.ts[2m > [22m[2mCLI Unified Analysis[2m > [22m[2mshould run analysis with only patterns tool
|
|
41
|
-
[22m[39m[ToolRegistry#0.
|
|
42
|
-
[ToolRegistry#0.
|
|
41
|
+
[22m[39m[ToolRegistry#0.846301580251078] Registering tool: pattern-detect (patterns)
|
|
42
|
+
[ToolRegistry#0.846301580251078] Registering tool: context-analyzer (context)
|
|
43
43
|
|
|
44
44
|
[90mstdout[2m | src/__tests__/cli.test.ts[2m > [22m[2mCLI Unified Analysis[2m > [22m[2mshould run analysis with only context tool
|
|
45
|
-
[22m[39m[ToolRegistry#0.
|
|
46
|
-
[ToolRegistry#0.
|
|
45
|
+
[22m[39m[ToolRegistry#0.846301580251078] Registering tool: pattern-detect (patterns)
|
|
46
|
+
[ToolRegistry#0.846301580251078] Registering tool: context-analyzer (context)
|
|
47
47
|
|
|
48
48
|
[32m✓[39m src/__tests__/cli.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 3[2mms[22m[39m
|
|
49
49
|
|
|
50
50
|
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
|
51
51
|
[2m Tests [22m [1m[32m3 passed[39m[22m[90m (3)[39m
|
|
52
|
-
[2m Start at [22m
|
|
53
|
-
[2m Duration [22m
|
|
52
|
+
[2m Start at [22m 15:18:06
|
|
53
|
+
[2m Duration [22m 387ms[2m (transform 113ms, setup 0ms, import 306ms, tests 3ms, environment 0ms)[22m
|
|
54
54
|
|
|
55
55
|
[?25h
|
|
@@ -0,0 +1,273 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,241 @@
|
|
|
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
|
+
};
|