@aiready/cli 0.14.8 → 0.14.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 +28 -29
- package/.turbo/turbo-test.log +74 -76
- package/dist/chunk-HBPSESJV.mjs +289 -0
- package/dist/chunk-JRRBBFYB.mjs +307 -0
- package/dist/chunk-YP2EVXQN.mjs +303 -0
- package/dist/chunk-ZQOTGPK4.mjs +289 -0
- package/dist/cli.js +71 -65
- package/dist/cli.mjs +48 -46
- package/dist/index.js +25 -21
- package/dist/index.mjs +1 -1
- package/package.json +12 -12
- package/src/cli.ts +7 -5
- package/src/commands/bug.ts +1 -1
- package/src/commands/consistency.ts +5 -5
- package/src/commands/context.ts +4 -4
- package/src/commands/patterns.ts +3 -3
- package/src/commands/report-formatter.ts +23 -10
- package/src/commands/scan.ts +18 -18
- package/src/commands/upload.ts +6 -6
- package/src/commands/visualize.ts +4 -4
- package/src/index.ts +49 -28
- package/src/utils/helpers.ts +30 -3
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
[
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
[32mESM[39m ⚡️ Build success in 152ms
|
|
1
|
+
|
|
2
|
+
> @aiready/cli@0.14.10 build /Users/pengcao/projects/aiready/packages/cli
|
|
3
|
+
> tsup src/index.ts src/cli.ts --format cjs,esm
|
|
4
|
+
|
|
5
|
+
CLI Building entry: src/cli.ts, src/index.ts
|
|
6
|
+
CLI Using tsconfig: tsconfig.json
|
|
7
|
+
CLI tsup v8.5.1
|
|
8
|
+
CLI Target: es2020
|
|
9
|
+
CJS Build start
|
|
10
|
+
ESM Build start
|
|
11
|
+
|
|
12
|
+
WARN [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
|
+
src/cli.ts:29:31:
|
|
15
|
+
[37m 29 │ return dirname(fileURLToPath([32mimport.meta[37m.url));
|
|
16
|
+
╵ [32m~~~~~~~~~~~[0m
|
|
17
|
+
|
|
18
|
+
You need to set the output format to "esm" for "import.meta" to work correctly.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
CJS dist/cli.js 84.95 KB
|
|
23
|
+
CJS dist/index.js 10.87 KB
|
|
24
|
+
CJS ⚡️ Build success in 42ms
|
|
25
|
+
ESM dist/index.mjs 170.00 B
|
|
26
|
+
ESM dist/chunk-JRRBBFYB.mjs 9.77 KB
|
|
27
|
+
ESM dist/cli.mjs 70.91 KB
|
|
28
|
+
ESM ⚡️ Build success in 42ms
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,76 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
[
|
|
13
|
-
[22m[
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
[90mstdout[2m | src/commands/__tests__/visualize.test.ts[2m > [22m[2mVisualize CLI Action[2m > [22m[2mshould
|
|
34
|
-
[22m[
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
[
|
|
42
|
-
[22m[39m
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
[
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
[32m✓[39m src/commands/__tests__/
|
|
59
|
-
[32m✓[39m src/
|
|
60
|
-
[32m✓[39m src/
|
|
61
|
-
[32m✓[39m src/commands/__tests__/
|
|
62
|
-
[32m✓[39m src/commands/__tests__/
|
|
63
|
-
[32m✓[39m src/commands/__tests__/
|
|
64
|
-
[32m✓[39m src/
|
|
65
|
-
[32m✓[39m src/__tests__/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
[2m
|
|
72
|
-
[2m
|
|
73
|
-
[2m
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
[?25h
|
|
1
|
+
|
|
2
|
+
> @aiready/cli@0.14.9 test /Users/pengcao/projects/aiready/packages/cli
|
|
3
|
+
> vitest run
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[1m[46m RUN [49m[22m [36mv4.0.18 [39m[90m/Users/pengcao/projects/aiready/packages/cli[39m
|
|
7
|
+
|
|
8
|
+
[90mstdout[2m | src/commands/__tests__/visualize.test.ts[2m > [22m[2mVisualize CLI Action[2m > [22m[2mshould generate HTML from specified report
|
|
9
|
+
[22m[39mBuilding graph from report...
|
|
10
|
+
|
|
11
|
+
[32m✓[39m src/commands/__tests__/agent-grounding.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 11[2mms[22m[39m
|
|
12
|
+
[32m✓[39m src/commands/__tests__/testability.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 12[2mms[22m[39m
|
|
13
|
+
[90mstdout[2m | src/commands/__tests__/visualize.test.ts[2m > [22m[2mVisualize CLI Action[2m > [22m[2mshould generate HTML from specified report
|
|
14
|
+
[22m[39mGenerating HTML...
|
|
15
|
+
✅ Visualization written to: /Users/pengcao/projects/aiready/packages/cli/visualization.html
|
|
16
|
+
|
|
17
|
+
[90mstdout[2m | src/commands/__tests__/visualize.test.ts[2m > [22m[2mVisualize CLI Action[2m > [22m[2mshould find latest report if none specified
|
|
18
|
+
[22m[39mFound latest report: latest.json
|
|
19
|
+
Building graph from report...
|
|
20
|
+
|
|
21
|
+
[90mstdout[2m | src/commands/__tests__/visualize.test.ts[2m > [22m[2mVisualize CLI Action[2m > [22m[2mshould find latest report if none specified
|
|
22
|
+
[22m[39mGenerating HTML...
|
|
23
|
+
✅ Visualization written to: /Users/pengcao/projects/aiready/packages/cli/visualization.html
|
|
24
|
+
|
|
25
|
+
[90mstdout[2m | src/commands/__tests__/visualize.test.ts[2m > [22m[2mVisualize CLI Action[2m > [22m[2mshould handle missing reports
|
|
26
|
+
[22m[39m
|
|
27
|
+
Generate a report with:
|
|
28
|
+
aiready scan --output json
|
|
29
|
+
|
|
30
|
+
Or specify a custom report:
|
|
31
|
+
aiready visualise --report <path-to-report.json>
|
|
32
|
+
|
|
33
|
+
[90mstdout[2m | src/commands/__tests__/visualize.test.ts[2m > [22m[2mVisualize CLI Action[2m > [22m[2mshould attempt to open visualization if requested
|
|
34
|
+
[22m[39mBuilding graph from report...
|
|
35
|
+
|
|
36
|
+
[90mstdout[2m | src/commands/__tests__/visualize.test.ts[2m > [22m[2mVisualize CLI Action[2m > [22m[2mshould attempt to open visualization if requested
|
|
37
|
+
[22m[39mGenerating HTML...
|
|
38
|
+
✅ Visualization written to: /Users/pengcao/projects/aiready/packages/cli/visualization.html
|
|
39
|
+
|
|
40
|
+
[32m✓[39m src/commands/__tests__/doc-drift.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 7[2mms[22m[39m
|
|
41
|
+
[32m✓[39m src/commands/__tests__/ai-signal-clarity.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 8[2mms[22m[39m
|
|
42
|
+
[32m✓[39m src/commands/__tests__/visualize.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 27[2mms[22m[39m
|
|
43
|
+
[32m✓[39m src/commands/__tests__/deps-health.test.ts [2m([22m[2m1 test[22m[2m)[22m[32m 9[2mms[22m[39m
|
|
44
|
+
[90mstdout[2m | src/commands/__tests__/upload.test.ts[2m > [22m[2mUpload CLI Action[2m > [22m[2mshould fail if API key is missing
|
|
45
|
+
[22m[39m Set AIREADY_API_KEY environment variable or use --api-key flag.
|
|
46
|
+
Get an API key from https://platform.getaiready.dev/dashboard
|
|
47
|
+
🚀 Uploading report to https://dev.platform.getaiready.dev...
|
|
48
|
+
Reading report from /Users/pengcao/projects/aiready/packages/cli/report.json...
|
|
49
|
+
Successfully parsed report JSON.
|
|
50
|
+
|
|
51
|
+
[90mstdout[2m | src/commands/__tests__/upload.test.ts[2m > [22m[2mUpload CLI Action[2m > [22m[2mshould fail if API key is missing
|
|
52
|
+
[22m[39m
|
|
53
|
+
✅ Upload successful! (0.00s)
|
|
54
|
+
View results: https://dev.platform.getaiready.dev/dashboard
|
|
55
|
+
Analysis ID: 123
|
|
56
|
+
Score: 80/100
|
|
57
|
+
|
|
58
|
+
[32m✓[39m src/commands/__tests__/upload.test.ts [2m([22m[2m2 tests[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
59
|
+
[32m✓[39m src/utils/__tests__/helpers.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 2[2mms[22m[39m
|
|
60
|
+
[32m✓[39m src/commands/__tests__/init.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 5[2mms[22m[39m
|
|
61
|
+
[32m✓[39m src/commands/__tests__/consistency.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 4[2mms[22m[39m
|
|
62
|
+
[32m✓[39m src/commands/__tests__/scan.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 94[2mms[22m[39m
|
|
63
|
+
[32m✓[39m src/commands/__tests__/extra-commands.test.ts [2m([22m[2m8 tests[22m[2m)[22m[32m 122[2mms[22m[39m
|
|
64
|
+
[32m✓[39m src/__tests__/unified.test.ts [2m([22m[2m4 tests[22m[2m)[22m[32m 3[2mms[22m[39m
|
|
65
|
+
[32m✓[39m src/__tests__/cli.test.ts [2m([22m[2m3 tests[22m[2m)[22m[33m 4113[2mms[22m[39m
|
|
66
|
+
[33m[2m✓[22m[39m should run unified analysis with both tools [33m 4112[2mms[22m[39m
|
|
67
|
+
[32m✓[39m src/__tests__/config-shape.test.ts [2m([22m[2m3 tests[22m[2m)[22m[33m 4113[2mms[22m[39m
|
|
68
|
+
[33m[2m✓[22m[39m should generate a strictly portable AIReadyConfig in summary [33m 4112[2mms[22m[39m
|
|
69
|
+
|
|
70
|
+
[2m Test Files [22m [1m[32m15 passed[39m[22m[90m (15)[39m
|
|
71
|
+
[2m Tests [22m [1m[32m46 passed[39m[22m[90m (46)[39m
|
|
72
|
+
[2m Start at [22m 15:39:46
|
|
73
|
+
[2m Duration [22m 5.18s[2m (transform 2.58s, setup 0ms, import 5.99s, tests 8.53s, environment 2ms)[22m
|
|
74
|
+
|
|
@@ -0,0 +1,289 @@
|
|
|
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
|
+
initializeParsers
|
|
17
|
+
} from "@aiready/core";
|
|
18
|
+
import "@aiready/pattern-detect";
|
|
19
|
+
import "@aiready/context-analyzer";
|
|
20
|
+
import "@aiready/consistency";
|
|
21
|
+
import "@aiready/ai-signal-clarity";
|
|
22
|
+
import "@aiready/agent-grounding";
|
|
23
|
+
import "@aiready/testability";
|
|
24
|
+
import "@aiready/doc-drift";
|
|
25
|
+
import "@aiready/deps";
|
|
26
|
+
import "@aiready/change-amplification";
|
|
27
|
+
var TOOL_PACKAGE_MAP = {
|
|
28
|
+
[ToolName.PatternDetect]: "@aiready/pattern-detect",
|
|
29
|
+
[ToolName.ContextAnalyzer]: "@aiready/context-analyzer",
|
|
30
|
+
[ToolName.NamingConsistency]: "@aiready/consistency",
|
|
31
|
+
[ToolName.AiSignalClarity]: "@aiready/ai-signal-clarity",
|
|
32
|
+
[ToolName.AgentGrounding]: "@aiready/agent-grounding",
|
|
33
|
+
[ToolName.TestabilityIndex]: "@aiready/testability",
|
|
34
|
+
[ToolName.DocDrift]: "@aiready/doc-drift",
|
|
35
|
+
[ToolName.DependencyHealth]: "@aiready/deps",
|
|
36
|
+
[ToolName.ChangeAmplification]: "@aiready/change-amplification",
|
|
37
|
+
// Aliases handled by registry
|
|
38
|
+
patterns: "@aiready/pattern-detect",
|
|
39
|
+
duplicates: "@aiready/pattern-detect",
|
|
40
|
+
context: "@aiready/context-analyzer",
|
|
41
|
+
fragmentation: "@aiready/context-analyzer",
|
|
42
|
+
consistency: "@aiready/consistency",
|
|
43
|
+
"ai-signal": "@aiready/ai-signal-clarity",
|
|
44
|
+
grounding: "@aiready/agent-grounding",
|
|
45
|
+
testability: "@aiready/testability",
|
|
46
|
+
"deps-health": "@aiready/deps",
|
|
47
|
+
"change-amp": "@aiready/change-amplification"
|
|
48
|
+
};
|
|
49
|
+
function sanitizeConfigRecursive(obj) {
|
|
50
|
+
if (!obj || typeof obj !== "object" || Array.isArray(obj)) return obj;
|
|
51
|
+
const sanitized = {};
|
|
52
|
+
const infraToStrip = [
|
|
53
|
+
"rootDir",
|
|
54
|
+
"onProgress",
|
|
55
|
+
"progressCallback",
|
|
56
|
+
"streamResults",
|
|
57
|
+
"batchSize",
|
|
58
|
+
"useSmartDefaults"
|
|
59
|
+
];
|
|
60
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
61
|
+
if (infraToStrip.includes(key)) continue;
|
|
62
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
63
|
+
sanitized[key] = sanitizeConfigRecursive(value);
|
|
64
|
+
} else {
|
|
65
|
+
sanitized[key] = value;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return sanitized;
|
|
69
|
+
}
|
|
70
|
+
function sanitizeToolConfig(config) {
|
|
71
|
+
return sanitizeConfigRecursive(config);
|
|
72
|
+
}
|
|
73
|
+
async function analyzeUnified(options) {
|
|
74
|
+
await initializeParsers();
|
|
75
|
+
const startTime = Date.now();
|
|
76
|
+
const requestedTools = options.tools ?? [
|
|
77
|
+
"patterns",
|
|
78
|
+
"context",
|
|
79
|
+
"consistency"
|
|
80
|
+
];
|
|
81
|
+
const result = {
|
|
82
|
+
summary: {
|
|
83
|
+
totalIssues: 0,
|
|
84
|
+
criticalIssues: 0,
|
|
85
|
+
// Added as per instruction
|
|
86
|
+
majorIssues: 0,
|
|
87
|
+
// Added as per instruction
|
|
88
|
+
totalFiles: 0,
|
|
89
|
+
toolsRun: [],
|
|
90
|
+
executionTime: 0,
|
|
91
|
+
config: options,
|
|
92
|
+
toolConfigs: {}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
for (const toolName of requestedTools) {
|
|
96
|
+
let provider = ToolRegistry.find(toolName);
|
|
97
|
+
if (!provider) {
|
|
98
|
+
const packageName = TOOL_PACKAGE_MAP[toolName] ?? (toolName.startsWith("@aiready/") ? toolName : `@aiready/${toolName}`);
|
|
99
|
+
try {
|
|
100
|
+
await import(packageName);
|
|
101
|
+
provider = ToolRegistry.find(toolName);
|
|
102
|
+
if (provider) {
|
|
103
|
+
console.log(
|
|
104
|
+
`\u2705 Successfully loaded tool provider: ${toolName} from ${packageName}`
|
|
105
|
+
);
|
|
106
|
+
} else {
|
|
107
|
+
console.log(
|
|
108
|
+
`\u26A0\uFE0F Loaded ${packageName} but provider ${toolName} still not found in registry.`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
} catch (err) {
|
|
112
|
+
console.log(
|
|
113
|
+
`\u274C Failed to dynamically load tool ${toolName} (${packageName}):`,
|
|
114
|
+
err.message
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (!provider) {
|
|
119
|
+
console.warn(
|
|
120
|
+
`\u26A0\uFE0F Warning: Tool provider for '${toolName}' not found. Skipping.`
|
|
121
|
+
);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const sanitizedOptions = { ...options };
|
|
126
|
+
delete sanitizedOptions.onProgress;
|
|
127
|
+
delete sanitizedOptions.progressCallback;
|
|
128
|
+
const toolOptions = {
|
|
129
|
+
rootDir: options.rootDir
|
|
130
|
+
// Always include rootDir
|
|
131
|
+
};
|
|
132
|
+
[...GLOBAL_INFRA_OPTIONS, ...COMMON_FINE_TUNING_OPTIONS].forEach(
|
|
133
|
+
(key) => {
|
|
134
|
+
if (key in options && key !== "toolConfigs" && key !== "tools") {
|
|
135
|
+
toolOptions[key] = options[key];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
if (options.toolConfigs?.[provider.id]) {
|
|
140
|
+
Object.assign(toolOptions, options.toolConfigs[provider.id]);
|
|
141
|
+
} else if (options.tools && !Array.isArray(options.tools) && typeof options.tools === "object" && options.tools[provider.id]) {
|
|
142
|
+
Object.assign(toolOptions, options.tools[provider.id]);
|
|
143
|
+
} else if (options[provider.id]) {
|
|
144
|
+
Object.assign(toolOptions, options[provider.id]);
|
|
145
|
+
}
|
|
146
|
+
toolOptions.onProgress = (processed, total, message) => {
|
|
147
|
+
if (options.progressCallback) {
|
|
148
|
+
options.progressCallback({
|
|
149
|
+
tool: provider.id,
|
|
150
|
+
processed,
|
|
151
|
+
total,
|
|
152
|
+
message
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const output = await provider.analyze(toolOptions);
|
|
157
|
+
if (output.metadata) {
|
|
158
|
+
output.metadata.config = sanitizeToolConfig(toolOptions);
|
|
159
|
+
}
|
|
160
|
+
if (options.progressCallback) {
|
|
161
|
+
options.progressCallback({ tool: provider.id, data: output });
|
|
162
|
+
}
|
|
163
|
+
result[provider.id] = output;
|
|
164
|
+
result.summary.toolsRun.push(provider.id);
|
|
165
|
+
if (output.summary?.config) {
|
|
166
|
+
result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
|
|
167
|
+
output.summary.config
|
|
168
|
+
);
|
|
169
|
+
} else if (output.metadata?.config) {
|
|
170
|
+
result.summary.toolConfigs[provider.id] = sanitizeToolConfig(
|
|
171
|
+
output.metadata.config
|
|
172
|
+
);
|
|
173
|
+
} else {
|
|
174
|
+
result.summary.toolConfigs[provider.id] = sanitizeToolConfig(toolOptions);
|
|
175
|
+
}
|
|
176
|
+
const toolFiles = output.summary?.totalFiles ?? output.summary?.filesAnalyzed ?? 0;
|
|
177
|
+
if (toolFiles > result.summary.totalFiles) {
|
|
178
|
+
result.summary.totalFiles = toolFiles;
|
|
179
|
+
}
|
|
180
|
+
const issueCount = output.results.reduce(
|
|
181
|
+
(sum, file) => sum + (file.issues?.length ?? 0),
|
|
182
|
+
0
|
|
183
|
+
);
|
|
184
|
+
result.summary.totalIssues += issueCount;
|
|
185
|
+
} catch (err) {
|
|
186
|
+
console.error(`\u274C Error running tool '${provider.id}':`, err);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
result.summary.config = sanitizeConfigRecursive({
|
|
190
|
+
scan: {
|
|
191
|
+
tools: requestedTools,
|
|
192
|
+
include: options.include,
|
|
193
|
+
exclude: options.exclude
|
|
194
|
+
},
|
|
195
|
+
// Use 'tools' for tool-specific configurations to match AIReadyConfig
|
|
196
|
+
tools: result.summary.toolConfigs
|
|
197
|
+
});
|
|
198
|
+
result.summary.executionTime = Date.now() - startTime;
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
201
|
+
async function scoreUnified(results, options) {
|
|
202
|
+
const toolScores = /* @__PURE__ */ new Map();
|
|
203
|
+
for (const toolId of results.summary.toolsRun) {
|
|
204
|
+
const provider = ToolRegistry.get(toolId);
|
|
205
|
+
if (!provider) continue;
|
|
206
|
+
const output = results[toolId];
|
|
207
|
+
if (!output) continue;
|
|
208
|
+
try {
|
|
209
|
+
const toolScore = provider.score(output, options);
|
|
210
|
+
if (!toolScore.tokenBudget) {
|
|
211
|
+
if (toolId === ToolName.PatternDetect && output.duplicates) {
|
|
212
|
+
const wastedTokens = output.duplicates.reduce(
|
|
213
|
+
(sum, d) => sum + (d.tokenCost ?? 0),
|
|
214
|
+
0
|
|
215
|
+
);
|
|
216
|
+
toolScore.tokenBudget = calculateTokenBudget({
|
|
217
|
+
totalContextTokens: wastedTokens * 2,
|
|
218
|
+
wastedTokens: {
|
|
219
|
+
duplication: wastedTokens,
|
|
220
|
+
fragmentation: 0,
|
|
221
|
+
chattiness: 0
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
} else if (toolId === ToolName.ContextAnalyzer && output.summary) {
|
|
225
|
+
toolScore.tokenBudget = calculateTokenBudget({
|
|
226
|
+
totalContextTokens: output.summary.totalTokens,
|
|
227
|
+
wastedTokens: {
|
|
228
|
+
duplication: 0,
|
|
229
|
+
fragmentation: output.summary.totalPotentialSavings ?? 0,
|
|
230
|
+
chattiness: 0
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
toolScores.set(toolId, toolScore);
|
|
236
|
+
} catch (err) {
|
|
237
|
+
console.error(`\u274C Error scoring tool '${toolId}':`, err);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (toolScores.size === 0) {
|
|
241
|
+
return {
|
|
242
|
+
overall: 0,
|
|
243
|
+
rating: "Critical",
|
|
244
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
245
|
+
toolsUsed: [],
|
|
246
|
+
breakdown: [],
|
|
247
|
+
calculation: {
|
|
248
|
+
formula: "0 / 0 = 0",
|
|
249
|
+
weights: {},
|
|
250
|
+
normalized: "0 / 0 = 0"
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
return calculateOverallScore(toolScores, options, void 0);
|
|
255
|
+
}
|
|
256
|
+
function generateUnifiedSummary(result) {
|
|
257
|
+
const { summary } = result;
|
|
258
|
+
let output = `\u{1F680} AIReady Analysis Complete
|
|
259
|
+
|
|
260
|
+
`;
|
|
261
|
+
output += `\u{1F4CA} Summary:
|
|
262
|
+
`;
|
|
263
|
+
output += ` Tools run: ${summary.toolsRun.join(", ")}
|
|
264
|
+
`;
|
|
265
|
+
output += ` Total issues found: ${summary.totalIssues}
|
|
266
|
+
`;
|
|
267
|
+
output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
|
|
268
|
+
|
|
269
|
+
`;
|
|
270
|
+
for (const provider of ToolRegistry.getAll()) {
|
|
271
|
+
const toolResult = result[provider.id];
|
|
272
|
+
if (toolResult) {
|
|
273
|
+
const issueCount = toolResult.results.reduce(
|
|
274
|
+
(sum, r) => sum + (r.issues?.length ?? 0),
|
|
275
|
+
0
|
|
276
|
+
);
|
|
277
|
+
output += `\u2022 ${provider.id}: ${issueCount} issues
|
|
278
|
+
`;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return output;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export {
|
|
285
|
+
__require,
|
|
286
|
+
analyzeUnified,
|
|
287
|
+
scoreUnified,
|
|
288
|
+
generateUnifiedSummary
|
|
289
|
+
};
|