@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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @aiready/cli@0.9.33 build /Users/pengcao/projects/aiready/packages/cli
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
  CLI Building entry: src/cli.ts, src/index.ts
@@ -9,10 +9,28 @@
9
9
  CLI Target: es2020
10
10
  CJS Build start
11
11
  ESM Build start
12
- CJS dist/cli.js 64.03 KB
13
- CJS dist/index.js 4.93 KB
14
- CJS ⚡️ Build success in 231ms
15
- ESM dist/cli.mjs 56.83 KB
16
- ESM dist/chunk-5GZDRZ3T.mjs 4.17 KB
17
- ESM dist/index.mjs 138.00 B
18
- ESM ⚡️ Build success in 232ms
12
+
13
+ [9:41:44 PM]  WARN  ▲ [WARNING] "import.meta" is not available with the "cjs" output format and will be empty [empty-import-meta]
14
+
15
+ src/cli.ts:22:31:
16
+  22 │ return dirname(fileURLToPath(import.meta.url));
17
+ ~~~~~~~~~~~
18
+
19
+ You need to set the output format to "esm" for "import.meta" to work correctly.
20
+
21
+
22
+
23
+ CJS dist/cli.js 77.14 KB
24
+ CJS dist/index.js 6.63 KB
25
+ CJS ⚡️ Build success in 28ms
26
+ ESM dist/hallucination-risk-XU6E7IGN.mjs 135.00 B
27
+ ESM dist/cli.mjs 62.85 KB
28
+ ESM dist/index.mjs 169.00 B
29
+ ESM dist/agent-grounding-DAOSU4MF.mjs 129.00 B
30
+ ESM dist/chunk-XAF2EW5H.mjs 1.75 KB
31
+ ESM dist/chunk-RBWLQRKR.mjs 1.39 KB
32
+ ESM dist/chunk-Y6FXYEAI.mjs 390.00 B
33
+ ESM dist/chunk-YIS6WTY5.mjs 1.41 KB
34
+ ESM dist/testability-VDZJZ4MF.mjs 123.00 B
35
+ ESM dist/chunk-N4SLON5K.mjs 4.91 KB
36
+ ESM ⚡️ Build success in 28ms
@@ -1,17 +1,17 @@
1
1
 
2
2
  
3
- > @aiready/cli@0.9.33 test /Users/pengcao/projects/aiready/packages/cli
3
+ > @aiready/cli@0.9.36 test /Users/pengcao/projects/aiready/packages/cli
4
4
  > vitest run
5
5
 
6
6
  [?25l
7
7
   RUN  v4.0.18 /Users/pengcao/projects/aiready/packages/cli
8
8
 
9
- ✓ dist/__tests__/cli.test.js (3 tests) 7ms
10
- ✓ src/__tests__/cli.test.ts (3 tests) 6ms
9
+ ✓ src/__tests__/cli.test.ts (3 tests) 3ms
10
+ ✓ dist/__tests__/cli.test.js (3 tests) 3ms
11
11
 
12
12
   Test Files  2 passed (2)
13
13
   Tests  6 passed (6)
14
-  Start at  18:38:27
15
-  Duration  1.45s (transform 464ms, setup 0ms, import 2.25s, tests 13ms, environment 0ms)
14
+  Start at  21:42:04
15
+  Duration  1.60s (transform 926ms, setup 0ms, import 2.72s, tests 5ms, environment 0ms)
16
16
 
17
17
  [?25h
@@ -0,0 +1,7 @@
1
+ import {
2
+ agentGroundingAction
3
+ } from "./chunk-YIS6WTY5.mjs";
4
+ import "./chunk-Y6FXYEAI.mjs";
5
+ export {
6
+ agentGroundingAction
7
+ };
@@ -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
+ };