@aiready/cli 0.9.33 → 0.9.36
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 +26 -8
- package/.turbo/turbo-test.log +5 -5
- package/dist/agent-grounding-DAOSU4MF.mjs +7 -0
- package/dist/chunk-G6SDH7ZS.mjs +126 -0
- package/dist/chunk-N4SLON5K.mjs +152 -0
- package/dist/chunk-RBWLQRKR.mjs +39 -0
- package/dist/chunk-XAF2EW5H.mjs +46 -0
- package/dist/chunk-Y6FXYEAI.mjs +10 -0
- package/dist/chunk-YIS6WTY5.mjs +35 -0
- package/dist/cli.js +513 -213
- package/dist/cli.mjs +146 -21
- package/dist/deps-health-UWVYJ7FZ.mjs +47 -0
- package/dist/doc-drift-G7MGAZAE.mjs +47 -0
- package/dist/hallucination-risk-XU6E7IGN.mjs +7 -0
- package/dist/index.js +44 -0
- package/dist/index.mjs +2 -1
- package/dist/testability-VDZJZ4MF.mjs +7 -0
- package/package.json +14 -9
- package/src/cli.ts +12 -4
- package/src/commands/agent-grounding.ts +47 -0
- package/src/commands/deps-health.ts +56 -0
- package/src/commands/doc-drift.ts +56 -0
- package/src/commands/hallucination-risk.ts +51 -0
- package/src/commands/index.ts +4 -1
- package/src/commands/scan.ts +161 -27
- package/src/commands/testability.ts +60 -0
- package/src/index.ts +41 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @aiready/cli@0.9.
|
|
3
|
+
> @aiready/cli@0.9.36 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,10 +9,28 @@
|
|
|
9
9
|
[34mCLI[39m Target: es2020
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
|
|
13
|
-
[
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
|
|
12
|
+
|
|
13
|
+
[90m[[90m9:41:44 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
|
+
|
|
15
|
+
src/cli.ts:22:31:
|
|
16
|
+
[37m 22 │ return dirname(fileURLToPath([32mimport.meta[37m.url));
|
|
17
|
+
╵ [32m~~~~~~~~~~~[0m
|
|
18
|
+
|
|
19
|
+
You need to set the output format to "esm" for "import.meta" to work correctly.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
[32mCJS[39m [1mdist/cli.js [22m[32m77.14 KB[39m
|
|
24
|
+
[32mCJS[39m [1mdist/index.js [22m[32m6.63 KB[39m
|
|
25
|
+
[32mCJS[39m ⚡️ Build success in 28ms
|
|
26
|
+
[32mESM[39m [1mdist/hallucination-risk-XU6E7IGN.mjs [22m[32m135.00 B[39m
|
|
27
|
+
[32mESM[39m [1mdist/cli.mjs [22m[32m62.85 KB[39m
|
|
28
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m169.00 B[39m
|
|
29
|
+
[32mESM[39m [1mdist/agent-grounding-DAOSU4MF.mjs [22m[32m129.00 B[39m
|
|
30
|
+
[32mESM[39m [1mdist/chunk-XAF2EW5H.mjs [22m[32m1.75 KB[39m
|
|
31
|
+
[32mESM[39m [1mdist/chunk-RBWLQRKR.mjs [22m[32m1.39 KB[39m
|
|
32
|
+
[32mESM[39m [1mdist/chunk-Y6FXYEAI.mjs [22m[32m390.00 B[39m
|
|
33
|
+
[32mESM[39m [1mdist/chunk-YIS6WTY5.mjs [22m[32m1.41 KB[39m
|
|
34
|
+
[32mESM[39m [1mdist/testability-VDZJZ4MF.mjs [22m[32m123.00 B[39m
|
|
35
|
+
[32mESM[39m [1mdist/chunk-N4SLON5K.mjs [22m[32m4.91 KB[39m
|
|
36
|
+
[32mESM[39m ⚡️ Build success in 28ms
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @aiready/cli@0.9.
|
|
3
|
+
> @aiready/cli@0.9.36 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
|
-
[32m✓[39m
|
|
10
|
-
[32m✓[39m
|
|
9
|
+
[32m✓[39m src/__tests__/cli.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 3[2mms[22m[39m
|
|
10
|
+
[32m✓[39m dist/__tests__/cli.test.js [2m([22m[2m3 tests[22m[2m)[22m[32m 3[2mms[22m[39m
|
|
11
11
|
|
|
12
12
|
[2m Test Files [22m [1m[32m2 passed[39m[22m[90m (2)[39m
|
|
13
13
|
[2m Tests [22m [1m[32m6 passed[39m[22m[90m (6)[39m
|
|
14
|
-
[2m Start at [22m
|
|
15
|
-
[2m Duration [22m 1.
|
|
14
|
+
[2m Start at [22m 21:42:04
|
|
15
|
+
[2m Duration [22m 1.60s[2m (transform 926ms, setup 0ms, import 2.72s, tests 5ms, environment 0ms)[22m
|
|
16
16
|
|
|
17
17
|
[?25h
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { analyzePatterns } from "@aiready/pattern-detect";
|
|
3
|
+
import { analyzeContext } from "@aiready/context-analyzer";
|
|
4
|
+
import { analyzeConsistency } from "@aiready/consistency";
|
|
5
|
+
var severityOrder = {
|
|
6
|
+
critical: 4,
|
|
7
|
+
major: 3,
|
|
8
|
+
minor: 2,
|
|
9
|
+
info: 1
|
|
10
|
+
};
|
|
11
|
+
function sortBySeverity(results) {
|
|
12
|
+
return results.map((file) => {
|
|
13
|
+
const sortedIssues = [...file.issues].sort((a, b) => {
|
|
14
|
+
const severityDiff = (severityOrder[b.severity] || 0) - (severityOrder[a.severity] || 0);
|
|
15
|
+
if (severityDiff !== 0) return severityDiff;
|
|
16
|
+
return (a.location?.line || 0) - (b.location?.line || 0);
|
|
17
|
+
});
|
|
18
|
+
return { ...file, issues: sortedIssues };
|
|
19
|
+
}).sort((a, b) => {
|
|
20
|
+
const aMaxSeverity = Math.max(...a.issues.map((i) => severityOrder[i.severity] || 0), 0);
|
|
21
|
+
const bMaxSeverity = Math.max(...b.issues.map((i) => severityOrder[i.severity] || 0), 0);
|
|
22
|
+
if (aMaxSeverity !== bMaxSeverity) {
|
|
23
|
+
return bMaxSeverity - aMaxSeverity;
|
|
24
|
+
}
|
|
25
|
+
if (a.issues.length !== b.issues.length) {
|
|
26
|
+
return b.issues.length - a.issues.length;
|
|
27
|
+
}
|
|
28
|
+
return a.fileName.localeCompare(b.fileName);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async function analyzeUnified(options) {
|
|
32
|
+
const startTime = Date.now();
|
|
33
|
+
const tools = options.tools || ["patterns", "context", "consistency"];
|
|
34
|
+
const result = {
|
|
35
|
+
summary: {
|
|
36
|
+
totalIssues: 0,
|
|
37
|
+
toolsRun: tools,
|
|
38
|
+
executionTime: 0
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
if (tools.includes("patterns")) {
|
|
42
|
+
const patternResult = await analyzePatterns(options);
|
|
43
|
+
if (options.progressCallback) {
|
|
44
|
+
options.progressCallback({ tool: "patterns", data: patternResult });
|
|
45
|
+
}
|
|
46
|
+
result.patterns = sortBySeverity(patternResult.results);
|
|
47
|
+
result.duplicates = patternResult.duplicates;
|
|
48
|
+
result.summary.totalIssues += patternResult.results.reduce(
|
|
49
|
+
(sum, file) => sum + file.issues.length,
|
|
50
|
+
0
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (tools.includes("context")) {
|
|
54
|
+
const contextResults = await analyzeContext(options);
|
|
55
|
+
if (options.progressCallback) {
|
|
56
|
+
options.progressCallback({ tool: "context", data: contextResults });
|
|
57
|
+
}
|
|
58
|
+
result.context = contextResults.sort((a, b) => {
|
|
59
|
+
const severityDiff = (severityOrder[b.severity] || 0) - (severityOrder[a.severity] || 0);
|
|
60
|
+
if (severityDiff !== 0) return severityDiff;
|
|
61
|
+
if (a.tokenCost !== b.tokenCost) return b.tokenCost - a.tokenCost;
|
|
62
|
+
return b.fragmentationScore - a.fragmentationScore;
|
|
63
|
+
});
|
|
64
|
+
result.summary.totalIssues += result.context?.length || 0;
|
|
65
|
+
}
|
|
66
|
+
if (tools.includes("consistency")) {
|
|
67
|
+
const consistencyOptions = {
|
|
68
|
+
rootDir: options.rootDir,
|
|
69
|
+
include: options.include,
|
|
70
|
+
exclude: options.exclude,
|
|
71
|
+
...options.consistency || {}
|
|
72
|
+
};
|
|
73
|
+
const report = await analyzeConsistency(consistencyOptions);
|
|
74
|
+
if (options.progressCallback) {
|
|
75
|
+
options.progressCallback({ tool: "consistency", data: report });
|
|
76
|
+
}
|
|
77
|
+
if (report.results) {
|
|
78
|
+
report.results = sortBySeverity(report.results);
|
|
79
|
+
}
|
|
80
|
+
result.consistency = report;
|
|
81
|
+
result.summary.totalIssues += report.summary.totalIssues;
|
|
82
|
+
}
|
|
83
|
+
result.summary.executionTime = Date.now() - startTime;
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
function generateUnifiedSummary(result) {
|
|
87
|
+
const { summary } = result;
|
|
88
|
+
let output = `\u{1F680} AIReady Analysis Complete
|
|
89
|
+
|
|
90
|
+
`;
|
|
91
|
+
output += `\u{1F4CA} Summary:
|
|
92
|
+
`;
|
|
93
|
+
output += ` Tools run: ${summary.toolsRun.join(", ")}
|
|
94
|
+
`;
|
|
95
|
+
output += ` Total issues found: ${summary.totalIssues}
|
|
96
|
+
`;
|
|
97
|
+
output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
|
|
98
|
+
|
|
99
|
+
`;
|
|
100
|
+
if (result.patterns) {
|
|
101
|
+
output += `\u{1F50D} Pattern Analysis: ${result.patterns.length} issues
|
|
102
|
+
`;
|
|
103
|
+
}
|
|
104
|
+
if (result.context) {
|
|
105
|
+
output += `\u{1F9E0} Context Analysis: ${result.context.length} issues
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
if (result.consistency) {
|
|
109
|
+
output += `\u{1F3F7}\uFE0F Consistency Analysis: ${result.consistency.summary.totalIssues} issues
|
|
110
|
+
`;
|
|
111
|
+
}
|
|
112
|
+
if (result.docDrift) {
|
|
113
|
+
output += `\u{1F4DD} Doc Drift Analysis: ${result.docDrift.issues?.length || 0} issues
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
if (result.deps) {
|
|
117
|
+
output += `\u{1F4E6} Dependency Health: ${result.deps.issues?.length || 0} issues
|
|
118
|
+
`;
|
|
119
|
+
}
|
|
120
|
+
return output;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export {
|
|
124
|
+
analyzeUnified,
|
|
125
|
+
generateUnifiedSummary
|
|
126
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { analyzePatterns } from "@aiready/pattern-detect";
|
|
3
|
+
import { analyzeContext } from "@aiready/context-analyzer";
|
|
4
|
+
import { analyzeConsistency } from "@aiready/consistency";
|
|
5
|
+
var severityOrder = {
|
|
6
|
+
critical: 4,
|
|
7
|
+
major: 3,
|
|
8
|
+
minor: 2,
|
|
9
|
+
info: 1
|
|
10
|
+
};
|
|
11
|
+
function sortBySeverity(results) {
|
|
12
|
+
return results.map((file) => {
|
|
13
|
+
const sortedIssues = [...file.issues].sort((a, b) => {
|
|
14
|
+
const severityDiff = (severityOrder[b.severity] || 0) - (severityOrder[a.severity] || 0);
|
|
15
|
+
if (severityDiff !== 0) return severityDiff;
|
|
16
|
+
return (a.location?.line || 0) - (b.location?.line || 0);
|
|
17
|
+
});
|
|
18
|
+
return { ...file, issues: sortedIssues };
|
|
19
|
+
}).sort((a, b) => {
|
|
20
|
+
const aMaxSeverity = Math.max(...a.issues.map((i) => severityOrder[i.severity] || 0), 0);
|
|
21
|
+
const bMaxSeverity = Math.max(...b.issues.map((i) => severityOrder[i.severity] || 0), 0);
|
|
22
|
+
if (aMaxSeverity !== bMaxSeverity) {
|
|
23
|
+
return bMaxSeverity - aMaxSeverity;
|
|
24
|
+
}
|
|
25
|
+
if (a.issues.length !== b.issues.length) {
|
|
26
|
+
return b.issues.length - a.issues.length;
|
|
27
|
+
}
|
|
28
|
+
return a.fileName.localeCompare(b.fileName);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async function analyzeUnified(options) {
|
|
32
|
+
const startTime = Date.now();
|
|
33
|
+
const tools = options.tools || ["patterns", "context", "consistency"];
|
|
34
|
+
const result = {
|
|
35
|
+
summary: {
|
|
36
|
+
totalIssues: 0,
|
|
37
|
+
toolsRun: tools,
|
|
38
|
+
executionTime: 0
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
if (tools.includes("patterns")) {
|
|
42
|
+
const patternResult = await analyzePatterns(options);
|
|
43
|
+
if (options.progressCallback) {
|
|
44
|
+
options.progressCallback({ tool: "patterns", data: patternResult });
|
|
45
|
+
}
|
|
46
|
+
result.patterns = sortBySeverity(patternResult.results);
|
|
47
|
+
result.duplicates = patternResult.duplicates;
|
|
48
|
+
result.summary.totalIssues += patternResult.results.reduce(
|
|
49
|
+
(sum, file) => sum + file.issues.length,
|
|
50
|
+
0
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (tools.includes("context")) {
|
|
54
|
+
const contextResults = await analyzeContext(options);
|
|
55
|
+
if (options.progressCallback) {
|
|
56
|
+
options.progressCallback({ tool: "context", data: contextResults });
|
|
57
|
+
}
|
|
58
|
+
result.context = contextResults.sort((a, b) => {
|
|
59
|
+
const severityDiff = (severityOrder[b.severity] || 0) - (severityOrder[a.severity] || 0);
|
|
60
|
+
if (severityDiff !== 0) return severityDiff;
|
|
61
|
+
if (a.tokenCost !== b.tokenCost) return b.tokenCost - a.tokenCost;
|
|
62
|
+
return b.fragmentationScore - a.fragmentationScore;
|
|
63
|
+
});
|
|
64
|
+
result.summary.totalIssues += result.context?.length || 0;
|
|
65
|
+
}
|
|
66
|
+
if (tools.includes("consistency")) {
|
|
67
|
+
const consistencyOptions = {
|
|
68
|
+
rootDir: options.rootDir,
|
|
69
|
+
include: options.include,
|
|
70
|
+
exclude: options.exclude,
|
|
71
|
+
...options.consistency || {}
|
|
72
|
+
};
|
|
73
|
+
const report = await analyzeConsistency(consistencyOptions);
|
|
74
|
+
if (options.progressCallback) {
|
|
75
|
+
options.progressCallback({ tool: "consistency", data: report });
|
|
76
|
+
}
|
|
77
|
+
if (report.results) {
|
|
78
|
+
report.results = sortBySeverity(report.results);
|
|
79
|
+
}
|
|
80
|
+
result.consistency = report;
|
|
81
|
+
result.summary.totalIssues += report.summary.totalIssues;
|
|
82
|
+
}
|
|
83
|
+
if (tools.includes("doc-drift")) {
|
|
84
|
+
const { analyzeDocDrift } = await import("@aiready/doc-drift");
|
|
85
|
+
const report = await analyzeDocDrift({
|
|
86
|
+
rootDir: options.rootDir,
|
|
87
|
+
include: options.include,
|
|
88
|
+
exclude: options.exclude
|
|
89
|
+
});
|
|
90
|
+
if (options.progressCallback) {
|
|
91
|
+
options.progressCallback({ tool: "doc-drift", data: report });
|
|
92
|
+
}
|
|
93
|
+
result.docDrift = report;
|
|
94
|
+
result.summary.totalIssues += report.issues?.length || 0;
|
|
95
|
+
}
|
|
96
|
+
if (tools.includes("deps-health")) {
|
|
97
|
+
const { analyzeDeps } = await import("@aiready/deps");
|
|
98
|
+
const report = await analyzeDeps({
|
|
99
|
+
rootDir: options.rootDir,
|
|
100
|
+
include: options.include,
|
|
101
|
+
exclude: options.exclude
|
|
102
|
+
});
|
|
103
|
+
if (options.progressCallback) {
|
|
104
|
+
options.progressCallback({ tool: "deps-health", data: report });
|
|
105
|
+
}
|
|
106
|
+
result.deps = report;
|
|
107
|
+
result.summary.totalIssues += report.issues?.length || 0;
|
|
108
|
+
}
|
|
109
|
+
result.summary.executionTime = Date.now() - startTime;
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
function generateUnifiedSummary(result) {
|
|
113
|
+
const { summary } = result;
|
|
114
|
+
let output = `\u{1F680} AIReady Analysis Complete
|
|
115
|
+
|
|
116
|
+
`;
|
|
117
|
+
output += `\u{1F4CA} Summary:
|
|
118
|
+
`;
|
|
119
|
+
output += ` Tools run: ${summary.toolsRun.join(", ")}
|
|
120
|
+
`;
|
|
121
|
+
output += ` Total issues found: ${summary.totalIssues}
|
|
122
|
+
`;
|
|
123
|
+
output += ` Execution time: ${(summary.executionTime / 1e3).toFixed(2)}s
|
|
124
|
+
|
|
125
|
+
`;
|
|
126
|
+
if (result.patterns) {
|
|
127
|
+
output += `\u{1F50D} Pattern Analysis: ${result.patterns.length} issues
|
|
128
|
+
`;
|
|
129
|
+
}
|
|
130
|
+
if (result.context) {
|
|
131
|
+
output += `\u{1F9E0} Context Analysis: ${result.context.length} issues
|
|
132
|
+
`;
|
|
133
|
+
}
|
|
134
|
+
if (result.consistency) {
|
|
135
|
+
output += `\u{1F3F7}\uFE0F Consistency Analysis: ${result.consistency.summary.totalIssues} issues
|
|
136
|
+
`;
|
|
137
|
+
}
|
|
138
|
+
if (result.docDrift) {
|
|
139
|
+
output += `\u{1F4DD} Doc Drift Analysis: ${result.docDrift.issues?.length || 0} issues
|
|
140
|
+
`;
|
|
141
|
+
}
|
|
142
|
+
if (result.deps) {
|
|
143
|
+
output += `\u{1F4E6} Dependency Health: ${result.deps.issues?.length || 0} issues
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
return output;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export {
|
|
150
|
+
analyzeUnified,
|
|
151
|
+
generateUnifiedSummary
|
|
152
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/commands/hallucination-risk.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { loadConfig, mergeConfigWithDefaults } from "@aiready/core";
|
|
4
|
+
async function hallucinationRiskAction(directory, options) {
|
|
5
|
+
const { analyzeHallucinationRisk, calculateHallucinationScore } = await import("@aiready/hallucination-risk");
|
|
6
|
+
const config = await loadConfig(directory);
|
|
7
|
+
const merged = mergeConfigWithDefaults(config, {
|
|
8
|
+
minSeverity: "info"
|
|
9
|
+
});
|
|
10
|
+
const report = await analyzeHallucinationRisk({
|
|
11
|
+
rootDir: directory,
|
|
12
|
+
minSeverity: options.minSeverity ?? merged.minSeverity ?? "info",
|
|
13
|
+
include: options.include,
|
|
14
|
+
exclude: options.exclude
|
|
15
|
+
});
|
|
16
|
+
const scoring = calculateHallucinationScore(report);
|
|
17
|
+
if (options.output === "json") {
|
|
18
|
+
return scoring;
|
|
19
|
+
}
|
|
20
|
+
const { summary } = report;
|
|
21
|
+
const ratingColors = {
|
|
22
|
+
minimal: chalk.green,
|
|
23
|
+
low: chalk.cyan,
|
|
24
|
+
moderate: chalk.yellow,
|
|
25
|
+
high: chalk.red,
|
|
26
|
+
severe: chalk.bgRed.white
|
|
27
|
+
};
|
|
28
|
+
const color = ratingColors[summary.rating] ?? chalk.white;
|
|
29
|
+
console.log(` \u{1F9E0} Hallucination Risk: ${chalk.bold(scoring.score + "/100")} (${color(summary.rating)})`);
|
|
30
|
+
console.log(` Top Risk: ${chalk.italic(summary.topRisk)}`);
|
|
31
|
+
if (summary.totalSignals > 0) {
|
|
32
|
+
console.log(chalk.dim(` ${summary.criticalSignals} critical ${summary.majorSignals} major ${summary.minorSignals} minor signals`));
|
|
33
|
+
}
|
|
34
|
+
return scoring;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
hallucinationRiskAction
|
|
39
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/commands/testability.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { loadConfig, mergeConfigWithDefaults } from "@aiready/core";
|
|
4
|
+
async function testabilityAction(directory, options) {
|
|
5
|
+
const { analyzeTestability, calculateTestabilityScore } = await import("@aiready/testability");
|
|
6
|
+
const config = await loadConfig(directory);
|
|
7
|
+
const merged = mergeConfigWithDefaults(config, {
|
|
8
|
+
minCoverageRatio: 0.3
|
|
9
|
+
});
|
|
10
|
+
const report = await analyzeTestability({
|
|
11
|
+
rootDir: directory,
|
|
12
|
+
minCoverageRatio: options.minCoverageRatio ?? merged.minCoverageRatio,
|
|
13
|
+
include: options.include,
|
|
14
|
+
exclude: options.exclude
|
|
15
|
+
});
|
|
16
|
+
const scoring = calculateTestabilityScore(report);
|
|
17
|
+
if (options.output === "json") {
|
|
18
|
+
return scoring;
|
|
19
|
+
}
|
|
20
|
+
const safetyIcons = {
|
|
21
|
+
"safe": "\u2705",
|
|
22
|
+
"moderate-risk": "\u26A0\uFE0F ",
|
|
23
|
+
"high-risk": "\u{1F534}",
|
|
24
|
+
"blind-risk": "\u{1F480}"
|
|
25
|
+
};
|
|
26
|
+
const safetyColors = {
|
|
27
|
+
"safe": chalk.green,
|
|
28
|
+
"moderate-risk": chalk.yellow,
|
|
29
|
+
"high-risk": chalk.red,
|
|
30
|
+
"blind-risk": chalk.bgRed.white
|
|
31
|
+
};
|
|
32
|
+
const safety = report.summary.aiChangeSafetyRating;
|
|
33
|
+
const icon = safetyIcons[safety] ?? "\u2753";
|
|
34
|
+
const color = safetyColors[safety] ?? chalk.white;
|
|
35
|
+
console.log(` \u{1F9EA} Testability: ${chalk.bold(scoring.score + "/100")} (${report.summary.rating})`);
|
|
36
|
+
console.log(` AI Change Safety: ${color(`${icon} ${safety.toUpperCase()}`)}`);
|
|
37
|
+
console.log(chalk.dim(` Coverage: ${Math.round(report.summary.coverageRatio * 100)}% (${report.rawData.testFiles} test / ${report.rawData.sourceFiles} source files)`));
|
|
38
|
+
if (safety === "blind-risk") {
|
|
39
|
+
console.log(chalk.red.bold("\n \u26A0\uFE0F NO TESTS \u2014 AI changes to this codebase are completely unverifiable!\n"));
|
|
40
|
+
}
|
|
41
|
+
return scoring;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
testabilityAction
|
|
46
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export {
|
|
9
|
+
__require
|
|
10
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/commands/agent-grounding.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { loadConfig, mergeConfigWithDefaults } from "@aiready/core";
|
|
4
|
+
async function agentGroundingAction(directory, options) {
|
|
5
|
+
const { analyzeAgentGrounding, calculateGroundingScore } = await import("@aiready/agent-grounding");
|
|
6
|
+
const config = await loadConfig(directory);
|
|
7
|
+
const merged = mergeConfigWithDefaults(config, {
|
|
8
|
+
maxRecommendedDepth: 4,
|
|
9
|
+
readmeStaleDays: 90
|
|
10
|
+
});
|
|
11
|
+
const report = await analyzeAgentGrounding({
|
|
12
|
+
rootDir: directory,
|
|
13
|
+
maxRecommendedDepth: options.maxDepth ?? merged.maxRecommendedDepth,
|
|
14
|
+
readmeStaleDays: options.readmeStaleDays ?? merged.readmeStaleDays,
|
|
15
|
+
include: options.include,
|
|
16
|
+
exclude: options.exclude
|
|
17
|
+
});
|
|
18
|
+
const scoring = calculateGroundingScore(report);
|
|
19
|
+
if (options.output === "json") {
|
|
20
|
+
return scoring;
|
|
21
|
+
}
|
|
22
|
+
const scoreColor = (s) => s >= 85 ? chalk.green : s >= 70 ? chalk.cyan : s >= 50 ? chalk.yellow : chalk.red;
|
|
23
|
+
console.log(` \u{1F9ED} Agent Grounding: ${chalk.bold(scoring.score + "/100")} (${report.summary.rating})`);
|
|
24
|
+
const dims = report.summary.dimensions;
|
|
25
|
+
const worstDim = Object.entries(dims).sort(([, a], [, b]) => a - b)[0];
|
|
26
|
+
if (worstDim && worstDim[1] < 70) {
|
|
27
|
+
const name = worstDim[0].replace(/([A-Z])/g, " $1").replace("Score", "").trim();
|
|
28
|
+
console.log(chalk.dim(` Weakest dimension: ${name} (${worstDim[1]}/100)`));
|
|
29
|
+
}
|
|
30
|
+
return scoring;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
agentGroundingAction
|
|
35
|
+
};
|