@vertaaux/cli 0.2.2 → 0.3.0
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/LICENSE +21 -0
- package/README.md +58 -2
- package/dist/auth/device-flow.d.ts.map +1 -1
- package/dist/auth/device-flow.js +46 -14
- package/dist/commands/audit.d.ts +2 -0
- package/dist/commands/audit.d.ts.map +1 -1
- package/dist/commands/audit.js +167 -8
- package/dist/commands/client.d.ts +14 -0
- package/dist/commands/client.d.ts.map +1 -0
- package/dist/commands/client.js +362 -0
- package/dist/commands/compare.d.ts +20 -0
- package/dist/commands/compare.d.ts.map +1 -0
- package/dist/commands/compare.js +335 -0
- package/dist/commands/doc.d.ts +18 -0
- package/dist/commands/doc.d.ts.map +1 -0
- package/dist/commands/doc.js +161 -0
- package/dist/commands/download.d.ts.map +1 -1
- package/dist/commands/download.js +9 -8
- package/dist/commands/drift.d.ts +15 -0
- package/dist/commands/drift.d.ts.map +1 -0
- package/dist/commands/drift.js +309 -0
- package/dist/commands/explain.d.ts +14 -33
- package/dist/commands/explain.d.ts.map +1 -1
- package/dist/commands/explain.js +277 -179
- package/dist/commands/fix-plan.d.ts +15 -0
- package/dist/commands/fix-plan.d.ts.map +1 -0
- package/dist/commands/fix-plan.js +182 -0
- package/dist/commands/patch-review.d.ts +14 -0
- package/dist/commands/patch-review.d.ts.map +1 -0
- package/dist/commands/patch-review.js +200 -0
- package/dist/commands/protect.d.ts +16 -0
- package/dist/commands/protect.d.ts.map +1 -0
- package/dist/commands/protect.js +323 -0
- package/dist/commands/release-notes.d.ts +17 -0
- package/dist/commands/release-notes.d.ts.map +1 -0
- package/dist/commands/release-notes.js +145 -0
- package/dist/commands/report.d.ts +15 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +214 -0
- package/dist/commands/suggest.d.ts +18 -0
- package/dist/commands/suggest.d.ts.map +1 -0
- package/dist/commands/suggest.js +152 -0
- package/dist/commands/triage.d.ts +17 -0
- package/dist/commands/triage.d.ts.map +1 -0
- package/dist/commands/triage.js +205 -0
- package/dist/commands/upload.d.ts.map +1 -1
- package/dist/commands/upload.js +8 -7
- package/dist/index.js +62 -25
- package/dist/output/formats.d.ts.map +1 -1
- package/dist/output/formats.js +18 -2
- package/dist/output/human.d.ts +1 -10
- package/dist/output/human.d.ts.map +1 -1
- package/dist/output/human.js +26 -98
- package/dist/policy/sync.d.ts +67 -0
- package/dist/policy/sync.d.ts.map +1 -0
- package/dist/policy/sync.js +147 -0
- package/dist/prompts/command-catalog.d.ts +46 -0
- package/dist/prompts/command-catalog.d.ts.map +1 -0
- package/dist/prompts/command-catalog.js +187 -0
- package/dist/ui/spinner.d.ts +10 -35
- package/dist/ui/spinner.d.ts.map +1 -1
- package/dist/ui/spinner.js +11 -58
- package/dist/ui/table.d.ts +1 -18
- package/dist/ui/table.d.ts.map +1 -1
- package/dist/ui/table.js +56 -163
- package/dist/utils/ai-error.d.ts +48 -0
- package/dist/utils/ai-error.d.ts.map +1 -0
- package/dist/utils/ai-error.js +190 -0
- package/dist/utils/detect-env.d.ts +6 -8
- package/dist/utils/detect-env.d.ts.map +1 -1
- package/dist/utils/detect-env.js +6 -25
- package/dist/utils/stdin.d.ts +50 -0
- package/dist/utils/stdin.d.ts.map +1 -0
- package/dist/utils/stdin.js +93 -0
- package/package.json +11 -7
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal stdin reader for CLI commands.
|
|
3
|
+
*
|
|
4
|
+
* Detects piped input vs TTY, reads JSON or plaintext from stdin,
|
|
5
|
+
* and provides a consistent interface for all commands that accept
|
|
6
|
+
* piped data (explain, triage, fix-plan, patch-review, etc.).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Check if stdin has piped data available.
|
|
10
|
+
*/
|
|
11
|
+
export function hasPipedInput() {
|
|
12
|
+
return !process.stdin.isTTY;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Read all available data from stdin.
|
|
16
|
+
*
|
|
17
|
+
* Only reads when stdin is piped (not a TTY). Returns null if
|
|
18
|
+
* stdin is a TTY (interactive terminal).
|
|
19
|
+
*
|
|
20
|
+
* @returns Parsed stdin result, or null if no piped input
|
|
21
|
+
*/
|
|
22
|
+
export async function readStdin() {
|
|
23
|
+
if (process.stdin.isTTY) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const chunks = [];
|
|
27
|
+
for await (const chunk of process.stdin) {
|
|
28
|
+
chunks.push(chunk);
|
|
29
|
+
}
|
|
30
|
+
const raw = Buffer.concat(chunks).toString("utf-8").trim();
|
|
31
|
+
if (!raw) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
let json = null;
|
|
35
|
+
let isJson = false;
|
|
36
|
+
try {
|
|
37
|
+
json = JSON.parse(raw);
|
|
38
|
+
isJson = true;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Not JSON — that's fine, could be plaintext (e.g., a diff)
|
|
42
|
+
}
|
|
43
|
+
return { raw, json, isJson };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Read JSON from stdin, a file path, or return null.
|
|
47
|
+
*
|
|
48
|
+
* Provides the common pattern used by AI commands:
|
|
49
|
+
* 1. Check --file flag → read file
|
|
50
|
+
* 2. Check stdin pipe → read piped JSON
|
|
51
|
+
* 3. Return null (caller should check --job or show error)
|
|
52
|
+
*
|
|
53
|
+
* @param filePath - Optional file path from --file flag
|
|
54
|
+
* @returns Parsed JSON object, or null if no input found
|
|
55
|
+
*/
|
|
56
|
+
export async function readJsonInput(filePath) {
|
|
57
|
+
// Priority 1: explicit file path
|
|
58
|
+
if (filePath) {
|
|
59
|
+
const fs = await import("fs");
|
|
60
|
+
const path = await import("path");
|
|
61
|
+
const resolved = path.resolve(process.cwd(), filePath);
|
|
62
|
+
if (!fs.existsSync(resolved)) {
|
|
63
|
+
throw new Error(`Input file not found: ${filePath}`);
|
|
64
|
+
}
|
|
65
|
+
const content = fs.readFileSync(resolved, "utf-8");
|
|
66
|
+
try {
|
|
67
|
+
return JSON.parse(content);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
throw new Error(`Invalid JSON in file: ${filePath}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Priority 2: piped stdin
|
|
74
|
+
const stdin = await readStdin();
|
|
75
|
+
if (stdin) {
|
|
76
|
+
if (!stdin.isJson) {
|
|
77
|
+
throw new Error("Could not parse input as JSON. If piping from vertaa, use --json flag:\n" +
|
|
78
|
+
" vertaa audit https://example.com --json | vertaa explain");
|
|
79
|
+
}
|
|
80
|
+
return stdin.json;
|
|
81
|
+
}
|
|
82
|
+
// No input found
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Read plaintext from stdin (for diffs, code, etc.).
|
|
87
|
+
*
|
|
88
|
+
* @returns Raw text content, or null if no piped input
|
|
89
|
+
*/
|
|
90
|
+
export async function readTextInput() {
|
|
91
|
+
const stdin = await readStdin();
|
|
92
|
+
return stdin?.raw ?? null;
|
|
93
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vertaaux/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Run automated UX audits, accessibility checks, and performance analysis from the terminal or CI pipelines. Supports policy gating, SARIF output, and multi-page crawling. See https://github.com/PetriLahdelma/vertaa/tree/main/cli#readme for full docs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"bin": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"url": "https://github.com/PetriLahdelma/vertaa",
|
|
28
28
|
"directory": "cli"
|
|
29
29
|
},
|
|
30
|
-
"homepage": "https://
|
|
30
|
+
"homepage": "https://vertaaux.ai",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
@@ -40,19 +40,21 @@
|
|
|
40
40
|
"dev": "tsc -w",
|
|
41
41
|
"start": "node dist/index.js",
|
|
42
42
|
"prepublishOnly": "npm run build && node scripts/verify-package.mjs",
|
|
43
|
-
"test": "vitest run --config vitest.config.ts"
|
|
43
|
+
"test": "vitest run --config vitest.config.ts --exclude tests/e2e/**/*.test.ts",
|
|
44
|
+
"test:e2e": "vitest run --config vitest.config.ts tests/e2e/cli-contract.test.ts",
|
|
45
|
+
"test:e2e:package": "vitest run --config vitest.config.ts tests/e2e/package-install.test.ts",
|
|
46
|
+
"test:e2e:ui": "vitest --ui --config vitest.config.ts tests/e2e/cli-contract.test.ts"
|
|
44
47
|
},
|
|
45
48
|
"dependencies": {
|
|
46
49
|
"@inquirer/prompts": "^8.2.0",
|
|
50
|
+
"@vertaaux/tui": "file:../packages/tui",
|
|
47
51
|
"ajv": "^8.17.1",
|
|
48
52
|
"ajv-formats": "^3.0.1",
|
|
49
53
|
"chalk": "^5.6.2",
|
|
50
|
-
"cli-table3": "^0.6.5",
|
|
51
54
|
"commander": "^14.0.2",
|
|
52
55
|
"cosmiconfig": "^9.0.0",
|
|
53
56
|
"dotenv": "^17.2.3",
|
|
54
57
|
"minimatch": "^10.1.1",
|
|
55
|
-
"ora": "^9.1.0",
|
|
56
58
|
"semver": "^7.7.3",
|
|
57
59
|
"yaml": "^2.8.2"
|
|
58
60
|
},
|
|
@@ -60,6 +62,8 @@
|
|
|
60
62
|
"@types/minimatch": "^5.1.2",
|
|
61
63
|
"@types/node": "^20.11.25",
|
|
62
64
|
"@types/semver": "^7.7.1",
|
|
63
|
-
"
|
|
65
|
+
"@vitest/ui": "^4.0.18",
|
|
66
|
+
"typescript": "^5.6.3",
|
|
67
|
+
"vitest": "^4.0.15"
|
|
64
68
|
}
|
|
65
69
|
}
|