@aiready/cli 0.12.11 → 0.12.14
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 +57 -20
- package/dist/chunk-2QOU5KKW.mjs +301 -0
- package/dist/chunk-55ZUD52M.mjs +290 -0
- package/dist/chunk-BD7XZYET.mjs +302 -0
- package/dist/cli.js +39 -15
- package/dist/cli.mjs +4 -1
- package/dist/index.js +36 -15
- package/dist/index.mjs +1 -1
- package/package.json +12 -12
- package/src/.aiready/aiready-report-20260307-155544.json +41501 -0
- package/src/__tests__/config-shape.test.ts +106 -0
- package/src/commands/scan.ts +4 -1
- package/src/index.ts +59 -17
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @aiready/cli@0.12.
|
|
3
|
+
> @aiready/cli@0.12.13 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
|
-
[
|
|
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] [90m8:49:23 pm[39m
|
|
14
14
|
|
|
15
15
|
src/cli.ts:25:31:
|
|
16
16
|
[37m 25 │ return dirname(fileURLToPath([32mimport.meta[37m.url));
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
[
|
|
23
|
+
[32mCJS[39m [1mdist/cli.js [22m[32m69.48 KB[39m
|
|
24
|
+
[32mCJS[39m [1mdist/index.js [22m[32m10.58 KB[39m
|
|
25
|
+
[32mCJS[39m ⚡️ Build success in 26ms
|
|
26
|
+
[32mESM[39m [1mdist/cli.mjs [22m[32m56.89 KB[39m
|
|
27
|
+
[32mESM[39m [1mdist/chunk-2QOU5KKW.mjs [22m[32m9.48 KB[39m
|
|
24
28
|
[32mESM[39m [1mdist/index.mjs [22m[32m170.00 B[39m
|
|
25
|
-
[32mESM[39m
|
|
26
|
-
[32mESM[39m ⚡️ Build success in 29ms
|
|
27
|
-
[32mCJS[39m [1mdist/index.js [22m[32m9.79 KB[39m
|
|
28
|
-
[32mCJS[39m [1mdist/cli.js [22m[32m68.56 KB[39m
|
|
29
|
-
[32mCJS[39m ⚡️ Build success in 29ms
|
|
29
|
+
[32mESM[39m ⚡️ Build success in 26ms
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,55 +1,92 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @aiready/cli@0.12.
|
|
3
|
+
> @aiready/cli@0.12.13 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
|
+
[90mstdout[2m | src/__tests__/config-shape.test.ts
|
|
10
|
+
[22m[39m[ToolRegistry#0.9033815218908418] Registering tool: pattern-detect (patterns, duplicates, duplication)
|
|
11
|
+
|
|
9
12
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
10
|
-
[22m[39m[ToolRegistry#0.
|
|
13
|
+
[22m[39m[ToolRegistry#0.9221699210349066] Registering tool: pattern-detect (patterns, duplicates, duplication)
|
|
14
|
+
|
|
15
|
+
[90mstdout[2m | src/__tests__/config-shape.test.ts
|
|
16
|
+
[22m[39m[ToolRegistry#0.9033815218908418] Registering tool: context-analyzer (context, fragmentation, budget)
|
|
11
17
|
|
|
12
18
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
13
|
-
[22m[39m[ToolRegistry#0.
|
|
19
|
+
[22m[39m[ToolRegistry#0.9221699210349066] Registering tool: context-analyzer (context, fragmentation, budget)
|
|
20
|
+
|
|
21
|
+
[90mstdout[2m | src/__tests__/config-shape.test.ts
|
|
22
|
+
[22m[39m[ToolRegistry#0.9033815218908418] Registering tool: naming-consistency (consistency, naming, standards)
|
|
14
23
|
|
|
15
24
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
16
|
-
[22m[39m[ToolRegistry#0.
|
|
25
|
+
[22m[39m[ToolRegistry#0.9221699210349066] Registering tool: naming-consistency (consistency, naming, standards)
|
|
17
26
|
|
|
18
27
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
19
|
-
[22m[39m[ToolRegistry#0.
|
|
28
|
+
[22m[39m[ToolRegistry#0.9221699210349066] Registering tool: ai-signal-clarity (ai-signal, clarity, hallucination)
|
|
29
|
+
|
|
30
|
+
[90mstdout[2m | src/__tests__/config-shape.test.ts
|
|
31
|
+
[22m[39m[ToolRegistry#0.9033815218908418] Registering tool: ai-signal-clarity (ai-signal, clarity, hallucination)
|
|
32
|
+
|
|
33
|
+
[90mstdout[2m | src/__tests__/config-shape.test.ts
|
|
34
|
+
[22m[39m[ToolRegistry#0.9033815218908418] Registering tool: agent-grounding (agent-grounding, grounding, navigation)
|
|
20
35
|
|
|
21
36
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
22
|
-
[22m[39m[ToolRegistry#0.
|
|
37
|
+
[22m[39m[ToolRegistry#0.9221699210349066] Registering tool: agent-grounding (agent-grounding, grounding, navigation)
|
|
23
38
|
|
|
24
39
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
25
|
-
[22m[39m[ToolRegistry#0.
|
|
40
|
+
[22m[39m[ToolRegistry#0.9221699210349066] Registering tool: testability-index (testability, tests, verification)
|
|
41
|
+
|
|
42
|
+
[90mstdout[2m | src/__tests__/config-shape.test.ts
|
|
43
|
+
[22m[39m[ToolRegistry#0.9033815218908418] Registering tool: testability-index (testability, tests, verification)
|
|
44
|
+
|
|
45
|
+
[90mstdout[2m | src/__tests__/config-shape.test.ts
|
|
46
|
+
[22m[39m[ToolRegistry#0.9033815218908418] Registering tool: doc-drift (doc-drift, docs, jsdoc)
|
|
26
47
|
|
|
27
48
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
28
|
-
[22m[39m[ToolRegistry#0.
|
|
49
|
+
[22m[39m[ToolRegistry#0.9221699210349066] Registering tool: doc-drift (doc-drift, docs, jsdoc)
|
|
50
|
+
|
|
51
|
+
[90mstdout[2m | src/__tests__/config-shape.test.ts
|
|
52
|
+
[22m[39m[ToolRegistry#0.9033815218908418] Registering tool: dependency-health (deps, deps-health, packages)
|
|
29
53
|
|
|
30
54
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
31
|
-
[22m[39m[ToolRegistry#0.
|
|
55
|
+
[22m[39m[ToolRegistry#0.9221699210349066] Registering tool: dependency-health (deps, deps-health, packages)
|
|
56
|
+
|
|
57
|
+
[90mstdout[2m | src/__tests__/config-shape.test.ts
|
|
58
|
+
[22m[39m[ToolRegistry#0.9033815218908418] Registering tool: change-amplification (change-amp, change-amplification, coupling)
|
|
32
59
|
|
|
33
60
|
[90mstdout[2m | src/__tests__/cli.test.ts
|
|
34
|
-
[22m[39m[ToolRegistry#0.
|
|
61
|
+
[22m[39m[ToolRegistry#0.9221699210349066] Registering tool: change-amplification (change-amp, change-amplification, coupling)
|
|
35
62
|
|
|
36
63
|
[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.
|
|
64
|
+
[22m[39m[ToolRegistry#0.9221699210349066] Registering tool: pattern-detect (patterns)
|
|
65
|
+
[ToolRegistry#0.9221699210349066] Registering tool: context-analyzer (context)
|
|
66
|
+
|
|
67
|
+
[90mstdout[2m | src/__tests__/config-shape.test.ts[2m > [22m[2mCLI Configuration Shape[2m > [22m[2mshould generate a strictly portable AIReadyConfig in summary
|
|
68
|
+
[22m[39m[ToolRegistry#0.9033815218908418] Registering tool: pattern-detect (patterns)
|
|
39
69
|
|
|
40
70
|
[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.
|
|
71
|
+
[22m[39m[ToolRegistry#0.9221699210349066] Registering tool: pattern-detect (patterns)
|
|
72
|
+
[ToolRegistry#0.9221699210349066] Registering tool: context-analyzer (context)
|
|
43
73
|
|
|
44
74
|
[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.
|
|
75
|
+
[22m[39m[ToolRegistry#0.9221699210349066] Registering tool: pattern-detect (patterns)
|
|
76
|
+
[ToolRegistry#0.9221699210349066] Registering tool: context-analyzer (context)
|
|
77
|
+
|
|
78
|
+
[90mstdout[2m | src/__tests__/config-shape.test.ts[2m > [22m[2mCLI Configuration Shape[2m > [22m[2mshould strip internal keys like useSmartDefaults and batchSize
|
|
79
|
+
[22m[39m[ToolRegistry#0.9033815218908418] Registering tool: pattern-detect (patterns)
|
|
80
|
+
|
|
81
|
+
[90mstdout[2m | src/__tests__/config-shape.test.ts[2m > [22m[2mCLI Configuration Shape[2m > [22m[2mshould produce a config that is compatible with tool specific collection
|
|
82
|
+
[22m[39m[ToolRegistry#0.9033815218908418] Registering tool: pattern-detect (patterns)
|
|
47
83
|
|
|
48
84
|
[32m✓[39m src/__tests__/cli.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 3[2mms[22m[39m
|
|
85
|
+
[32m✓[39m src/__tests__/config-shape.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 3[2mms[22m[39m
|
|
49
86
|
|
|
50
|
-
[2m Test Files [22m [1m[
|
|
51
|
-
[2m Tests [22m [1m[
|
|
52
|
-
[2m Start at [22m
|
|
53
|
-
[2m Duration [22m
|
|
87
|
+
[2m Test Files [22m [1m[32m2 passed[39m[22m[90m (2)[39m
|
|
88
|
+
[2m Tests [22m [1m[32m6 passed[39m[22m[90m (6)[39m
|
|
89
|
+
[2m Start at [22m 20:49:43
|
|
90
|
+
[2m Duration [22m 460ms[2m (transform 241ms, setup 0ms, import 659ms, tests 6ms, environment 0ms)[22m
|
|
54
91
|
|
|
55
92
|
[?25h
|
|
@@ -0,0 +1,301 @@
|
|
|
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
|
+
};
|