@vertaaux/cli 0.3.3 → 0.5.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.
Files changed (227) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/MIGRATION.md +239 -0
  3. package/README.md +34 -16
  4. package/dist/app/interactive-app.d.ts +101 -0
  5. package/dist/app/interactive-app.d.ts.map +1 -0
  6. package/dist/app/interactive-app.js +309 -0
  7. package/dist/app/layout/canvas.d.ts +23 -0
  8. package/dist/app/layout/canvas.d.ts.map +1 -0
  9. package/dist/app/layout/canvas.js +36 -0
  10. package/dist/app/layout/footer.d.ts +31 -0
  11. package/dist/app/layout/footer.d.ts.map +1 -0
  12. package/dist/app/layout/footer.js +41 -0
  13. package/dist/app/layout/header.d.ts +20 -0
  14. package/dist/app/layout/header.d.ts.map +1 -0
  15. package/dist/app/layout/header.js +27 -0
  16. package/dist/app/menu/categories.d.ts +20 -0
  17. package/dist/app/menu/categories.d.ts.map +1 -0
  18. package/dist/app/menu/categories.js +181 -0
  19. package/dist/app/menu/filter.d.ts +17 -0
  20. package/dist/app/menu/filter.d.ts.map +1 -0
  21. package/dist/app/menu/filter.js +33 -0
  22. package/dist/app/menu/menu-view.d.ts +35 -0
  23. package/dist/app/menu/menu-view.d.ts.map +1 -0
  24. package/dist/app/menu/menu-view.js +230 -0
  25. package/dist/app/menu/recent.d.ts +24 -0
  26. package/dist/app/menu/recent.d.ts.map +1 -0
  27. package/dist/app/menu/recent.js +49 -0
  28. package/dist/app/types.d.ts +43 -0
  29. package/dist/app/types.d.ts.map +1 -0
  30. package/dist/app/types.js +7 -0
  31. package/dist/app/views/command-runner.d.ts +36 -0
  32. package/dist/app/views/command-runner.d.ts.map +1 -0
  33. package/dist/app/views/command-runner.js +372 -0
  34. package/dist/app/views/help-overlay.d.ts +21 -0
  35. package/dist/app/views/help-overlay.d.ts.map +1 -0
  36. package/dist/app/views/help-overlay.js +45 -0
  37. package/dist/auth/ci-token.d.ts +14 -2
  38. package/dist/auth/ci-token.d.ts.map +1 -1
  39. package/dist/auth/ci-token.js +15 -30
  40. package/dist/auth/device-flow.d.ts +2 -1
  41. package/dist/auth/device-flow.d.ts.map +1 -1
  42. package/dist/auth/device-flow.js +13 -10
  43. package/dist/auth/token-store.d.ts.map +1 -1
  44. package/dist/auth/token-store.js +12 -2
  45. package/dist/baseline/diff.d.ts +2 -2
  46. package/dist/baseline/diff.d.ts.map +1 -1
  47. package/dist/baseline/diff.js +15 -34
  48. package/dist/commands/a11y.d.ts +9 -0
  49. package/dist/commands/a11y.d.ts.map +1 -0
  50. package/dist/commands/a11y.js +76 -0
  51. package/dist/commands/audit/artifacts.d.ts +27 -0
  52. package/dist/commands/audit/artifacts.d.ts.map +1 -0
  53. package/dist/commands/audit/artifacts.js +158 -0
  54. package/dist/commands/audit/ci-detection.d.ts +18 -0
  55. package/dist/commands/audit/ci-detection.d.ts.map +1 -0
  56. package/dist/commands/audit/ci-detection.js +71 -0
  57. package/dist/commands/audit/explain.d.ts +11 -0
  58. package/dist/commands/audit/explain.d.ts.map +1 -0
  59. package/dist/commands/audit/explain.js +45 -0
  60. package/dist/commands/audit/filters.d.ts +17 -0
  61. package/dist/commands/audit/filters.d.ts.map +1 -0
  62. package/dist/commands/audit/filters.js +40 -0
  63. package/dist/commands/audit/index.d.ts +18 -0
  64. package/dist/commands/audit/index.d.ts.map +1 -0
  65. package/dist/commands/audit/index.js +564 -0
  66. package/dist/commands/audit/output.d.ts +32 -0
  67. package/dist/commands/audit/output.d.ts.map +1 -0
  68. package/dist/commands/audit/output.js +130 -0
  69. package/dist/commands/audit/policy.d.ts +19 -0
  70. package/dist/commands/audit/policy.d.ts.map +1 -0
  71. package/dist/commands/audit/policy.js +102 -0
  72. package/dist/commands/audit/scoring.d.ts +23 -0
  73. package/dist/commands/audit/scoring.d.ts.map +1 -0
  74. package/dist/commands/audit/scoring.js +70 -0
  75. package/dist/commands/audit/types.d.ts +88 -0
  76. package/dist/commands/audit/types.d.ts.map +1 -0
  77. package/dist/commands/audit/types.js +8 -0
  78. package/dist/commands/audit.d.ts +2 -60
  79. package/dist/commands/audit.d.ts.map +1 -1
  80. package/dist/commands/audit.js +2 -1038
  81. package/dist/commands/baseline.d.ts +1 -0
  82. package/dist/commands/baseline.d.ts.map +1 -1
  83. package/dist/commands/baseline.js +205 -121
  84. package/dist/commands/comment.d.ts +22 -0
  85. package/dist/commands/comment.d.ts.map +1 -1
  86. package/dist/commands/comment.js +122 -58
  87. package/dist/commands/compare.d.ts +17 -0
  88. package/dist/commands/compare.d.ts.map +1 -1
  89. package/dist/commands/compare.js +287 -180
  90. package/dist/commands/diff.d.ts +5 -0
  91. package/dist/commands/diff.d.ts.map +1 -1
  92. package/dist/commands/diff.js +168 -141
  93. package/dist/commands/doc.d.ts +10 -0
  94. package/dist/commands/doc.d.ts.map +1 -1
  95. package/dist/commands/doc.js +134 -76
  96. package/dist/commands/doctor.d.ts +2 -0
  97. package/dist/commands/doctor.d.ts.map +1 -1
  98. package/dist/commands/doctor.js +164 -17
  99. package/dist/commands/download.d.ts +10 -0
  100. package/dist/commands/download.d.ts.map +1 -1
  101. package/dist/commands/download.js +169 -112
  102. package/dist/commands/explain.d.ts +5 -0
  103. package/dist/commands/explain.d.ts.map +1 -1
  104. package/dist/commands/explain.js +241 -155
  105. package/dist/commands/fix-all.d.ts +25 -0
  106. package/dist/commands/fix-all.d.ts.map +1 -0
  107. package/dist/commands/fix-all.js +206 -0
  108. package/dist/commands/fix-plan.d.ts +9 -0
  109. package/dist/commands/fix-plan.d.ts.map +1 -1
  110. package/dist/commands/fix-plan.js +152 -89
  111. package/dist/commands/fix.d.ts +17 -0
  112. package/dist/commands/fix.d.ts.map +1 -0
  113. package/dist/commands/fix.js +111 -0
  114. package/dist/commands/init.d.ts +11 -0
  115. package/dist/commands/init.d.ts.map +1 -1
  116. package/dist/commands/init.js +94 -42
  117. package/dist/commands/login.d.ts +18 -0
  118. package/dist/commands/login.d.ts.map +1 -1
  119. package/dist/commands/login.js +268 -95
  120. package/dist/commands/patch-review.d.ts +11 -0
  121. package/dist/commands/patch-review.d.ts.map +1 -1
  122. package/dist/commands/patch-review.js +159 -97
  123. package/dist/commands/policy.d.ts +31 -0
  124. package/dist/commands/policy.d.ts.map +1 -1
  125. package/dist/commands/policy.js +269 -124
  126. package/dist/commands/release-notes.d.ts +10 -0
  127. package/dist/commands/release-notes.d.ts.map +1 -1
  128. package/dist/commands/release-notes.js +127 -73
  129. package/dist/commands/scan.d.ts +13 -0
  130. package/dist/commands/scan.d.ts.map +1 -0
  131. package/dist/commands/scan.js +133 -0
  132. package/dist/commands/status.d.ts +9 -0
  133. package/dist/commands/status.d.ts.map +1 -0
  134. package/dist/commands/status.js +81 -0
  135. package/dist/commands/suggest.d.ts +10 -0
  136. package/dist/commands/suggest.d.ts.map +1 -1
  137. package/dist/commands/suggest.js +153 -82
  138. package/dist/commands/triage.d.ts +35 -0
  139. package/dist/commands/triage.d.ts.map +1 -1
  140. package/dist/commands/triage.js +206 -81
  141. package/dist/commands/upload.d.ts +9 -0
  142. package/dist/commands/upload.d.ts.map +1 -1
  143. package/dist/commands/upload.js +140 -101
  144. package/dist/commands/verify.d.ts +13 -0
  145. package/dist/commands/verify.d.ts.map +1 -0
  146. package/dist/commands/verify.js +118 -0
  147. package/dist/index.d.ts +3 -2
  148. package/dist/index.d.ts.map +1 -1
  149. package/dist/index.js +125 -990
  150. package/dist/interactive/fix-wizard.d.ts +3 -0
  151. package/dist/interactive/fix-wizard.d.ts.map +1 -1
  152. package/dist/interactive/fix-wizard.js +130 -112
  153. package/dist/interactive/init-wizard.d.ts +3 -1
  154. package/dist/interactive/init-wizard.d.ts.map +1 -1
  155. package/dist/interactive/init-wizard.js +207 -138
  156. package/dist/interactive/prompts.d.ts +7 -3
  157. package/dist/interactive/prompts.d.ts.map +1 -1
  158. package/dist/interactive/prompts.js +44 -23
  159. package/dist/output/envelope.d.ts +2 -0
  160. package/dist/output/envelope.d.ts.map +1 -1
  161. package/dist/output/envelope.js +18 -2
  162. package/dist/output/factory.d.ts +9 -1
  163. package/dist/output/factory.d.ts.map +1 -1
  164. package/dist/output/html.d.ts +2 -1
  165. package/dist/output/html.d.ts.map +1 -1
  166. package/dist/output/html.js +3 -2
  167. package/dist/output/human.d.ts +9 -1
  168. package/dist/output/human.d.ts.map +1 -1
  169. package/dist/output/human.js +17 -2
  170. package/dist/output/json.d.ts +2 -1
  171. package/dist/output/json.d.ts.map +1 -1
  172. package/dist/output/junit.d.ts +2 -1
  173. package/dist/output/junit.d.ts.map +1 -1
  174. package/dist/output/sarif.d.ts +2 -1
  175. package/dist/output/sarif.d.ts.map +1 -1
  176. package/dist/types.d.ts +74 -0
  177. package/dist/types.d.ts.map +1 -0
  178. package/dist/types.js +5 -0
  179. package/dist/ui/banner.d.ts +34 -0
  180. package/dist/ui/banner.d.ts.map +1 -1
  181. package/dist/ui/banner.js +97 -5
  182. package/dist/ui/diagnostics.d.ts +9 -4
  183. package/dist/ui/diagnostics.d.ts.map +1 -1
  184. package/dist/ui/diagnostics.js +32 -82
  185. package/dist/ui/strings.d.ts +373 -0
  186. package/dist/ui/strings.d.ts.map +1 -0
  187. package/dist/ui/strings.js +499 -0
  188. package/dist/ui/table.d.ts +0 -2
  189. package/dist/ui/table.d.ts.map +1 -1
  190. package/dist/ui/table.js +3 -4
  191. package/dist/utils/api-client.d.ts +46 -0
  192. package/dist/utils/api-client.d.ts.map +1 -0
  193. package/dist/utils/api-client.js +170 -0
  194. package/dist/utils/client.d.ts +29 -18
  195. package/dist/utils/client.d.ts.map +1 -1
  196. package/dist/utils/client.js +102 -12
  197. package/dist/utils/formatters.d.ts +38 -0
  198. package/dist/utils/formatters.d.ts.map +1 -0
  199. package/dist/utils/formatters.js +277 -0
  200. package/dist/utils/local-capture.d.ts +25 -0
  201. package/dist/utils/local-capture.d.ts.map +1 -0
  202. package/dist/utils/local-capture.js +57 -0
  203. package/dist/utils/url-classify.d.ts +18 -0
  204. package/dist/utils/url-classify.d.ts.map +1 -0
  205. package/dist/utils/url-classify.js +106 -0
  206. package/node_modules/@vertaaux/tui/dist/index.cjs +713 -20
  207. package/node_modules/@vertaaux/tui/dist/index.cjs.map +1 -1
  208. package/node_modules/@vertaaux/tui/dist/index.d.cts +361 -4
  209. package/node_modules/@vertaaux/tui/dist/index.d.ts +361 -4
  210. package/node_modules/@vertaaux/tui/dist/index.js +689 -21
  211. package/node_modules/@vertaaux/tui/dist/index.js.map +1 -1
  212. package/package.json +13 -5
  213. package/dist/commands/client.d.ts +0 -14
  214. package/dist/commands/client.d.ts.map +0 -1
  215. package/dist/commands/client.js +0 -362
  216. package/dist/commands/drift.d.ts +0 -15
  217. package/dist/commands/drift.d.ts.map +0 -1
  218. package/dist/commands/drift.js +0 -309
  219. package/dist/commands/protect.d.ts +0 -16
  220. package/dist/commands/protect.d.ts.map +0 -1
  221. package/dist/commands/protect.js +0 -323
  222. package/dist/commands/report.d.ts +0 -15
  223. package/dist/commands/report.d.ts.map +0 -1
  224. package/dist/commands/report.js +0 -214
  225. package/dist/policy/sync.d.ts +0 -67
  226. package/dist/policy/sync.d.ts.map +0 -1
  227. package/dist/policy/sync.js +0 -147
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertaaux/cli",
3
- "version": "0.3.3",
3
+ "version": "0.5.0",
4
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",
@@ -10,7 +10,9 @@
10
10
  "files": [
11
11
  "dist",
12
12
  "schemas",
13
- "README.md"
13
+ "README.md",
14
+ "CHANGELOG.md",
15
+ "MIGRATION.md"
14
16
  ],
15
17
  "keywords": [
16
18
  "vertaaux",
@@ -24,7 +26,7 @@
24
26
  ],
25
27
  "repository": {
26
28
  "type": "git",
27
- "url": "https://github.com/PetriLahdelma/vertaa",
29
+ "url": "git+https://github.com/PetriLahdelma/vertaa.git",
28
30
  "directory": "cli"
29
31
  },
30
32
  "homepage": "https://vertaaux.ai",
@@ -33,7 +35,7 @@
33
35
  "access": "public"
34
36
  },
35
37
  "engines": {
36
- "node": ">=18"
38
+ "node": ">=20"
37
39
  },
38
40
  "bundleDependencies": [
39
41
  "@vertaaux/tui"
@@ -42,14 +44,18 @@
42
44
  "build": "tsc",
43
45
  "dev": "tsc -w",
44
46
  "start": "node dist/index.js",
47
+ "postinstall": "node scripts/fix-node-pty-permissions.mjs 2>/dev/null || true",
45
48
  "prepublishOnly": "npm run build && node scripts/verify-package.mjs",
46
49
  "test": "vitest run --config vitest.config.ts --exclude tests/e2e/**/*.test.ts",
47
50
  "test:e2e": "vitest run --config vitest.config.ts tests/e2e/cli-contract.test.ts",
48
51
  "test:e2e:package": "vitest run --config vitest.config.ts tests/e2e/package-install.test.ts",
49
- "test:e2e:ui": "vitest --ui --config vitest.config.ts tests/e2e/cli-contract.test.ts"
52
+ "test:e2e:ui": "vitest --ui --config vitest.config.ts tests/e2e/cli-contract.test.ts",
53
+ "test:pty": "vitest run --config vitest.config.pty.ts",
54
+ "test:snapshot": "vitest run --config vitest.config.snapshot.ts"
50
55
  },
51
56
  "dependencies": {
52
57
  "@inquirer/prompts": "^8.2.0",
58
+ "@vertaaux/sdk": "1.0.0",
53
59
  "@vertaaux/tui": "file:../packages/tui",
54
60
  "ajv": "^8.17.1",
55
61
  "ajv-formats": "^3.0.1",
@@ -66,6 +72,8 @@
66
72
  "@types/node": "^20.11.25",
67
73
  "@types/semver": "^7.7.1",
68
74
  "@vitest/ui": "^4.0.18",
75
+ "node-pty": "^1.1.0",
76
+ "strip-ansi": "^7.2.0",
69
77
  "typescript": "^5.6.3",
70
78
  "vitest": "^4.0.15"
71
79
  }
@@ -1,14 +0,0 @@
1
- /**
2
- * Client management commands for VertaaUX CLI.
3
- *
4
- * Provides agency client CRUD operations and batch auditing
5
- * across client URL portfolios with bounded concurrency.
6
- *
7
- * Implements 46-06: CLI client management and batch audit.
8
- */
9
- import { Command } from "commander";
10
- /**
11
- * Register the client command with the Commander program.
12
- */
13
- export declare function registerClientCommand(program: Command): void;
14
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/commands/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0HpC;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAwX5D"}
@@ -1,362 +0,0 @@
1
- /**
2
- * Client management commands for VertaaUX CLI.
3
- *
4
- * Provides agency client CRUD operations and batch auditing
5
- * across client URL portfolios with bounded concurrency.
6
- *
7
- * Implements 46-06: CLI client management and batch audit.
8
- */
9
- import chalk from "chalk";
10
- import pLimit from "p-limit";
11
- import { resolveApiBase, getApiKey, apiRequest } from "../utils/client.js";
12
- /**
13
- * Auto-generate a URL-friendly slug from a name.
14
- */
15
- function generateSlug(name) {
16
- return name
17
- .toLowerCase()
18
- .replace(/[^a-z0-9]+/g, "-")
19
- .replace(/^-|-$/g, "");
20
- }
21
- /**
22
- * Determine if an identifier looks like a CUID (starts with 'c' followed by alphanumerics).
23
- */
24
- function looksLikeCuid(identifier) {
25
- return /^c[a-z0-9]{20,}$/i.test(identifier);
26
- }
27
- /**
28
- * Resolve API connection settings.
29
- * Reads from environment variables (standard CLI pattern).
30
- */
31
- function resolveConnection() {
32
- return {
33
- base: resolveApiBase(),
34
- apiKey: getApiKey(),
35
- };
36
- }
37
- /**
38
- * Format a date string for display.
39
- */
40
- function formatDate(dateStr) {
41
- try {
42
- const d = new Date(dateStr);
43
- return d.toISOString().split("T")[0];
44
- }
45
- catch {
46
- return dateStr;
47
- }
48
- }
49
- /**
50
- * Wait for an audit to complete by polling the status endpoint.
51
- */
52
- async function waitForAuditCompletion(base, apiKey, jobId, timeoutMs = 120000, intervalMs = 3000) {
53
- const start = Date.now();
54
- while (true) {
55
- const status = await apiRequest(base, `/audit/${jobId}`, { method: "GET" }, apiKey);
56
- if (status.status === "completed")
57
- return status;
58
- if (status.status === "failed") {
59
- throw new Error(status.error || `Audit ${jobId} failed`);
60
- }
61
- if (Date.now() - start > timeoutMs) {
62
- throw new Error(`Timed out waiting for audit ${jobId}`);
63
- }
64
- await new Promise((resolve) => setTimeout(resolve, intervalMs));
65
- }
66
- }
67
- /**
68
- * Compute overall score as mean of category scores.
69
- */
70
- function computeOverallScore(scores) {
71
- const values = Object.values(scores);
72
- if (values.length === 0)
73
- return null;
74
- const sum = values.reduce((acc, v) => acc + v, 0);
75
- return Math.round((sum / values.length) * 100) / 100;
76
- }
77
- /**
78
- * Register the client command with the Commander program.
79
- */
80
- export function registerClientCommand(program) {
81
- const clientCmd = program
82
- .command("client")
83
- .description("Manage agency clients");
84
- // vertaa client create <name>
85
- clientCmd
86
- .command("create <name>")
87
- .description("Create a new client")
88
- .option("--slug <slug>", "URL-friendly identifier (auto-generated from name if omitted)")
89
- .option("--urls <urls...>", "URLs to associate with this client")
90
- .option("--policy <id>", "Policy ID to assign")
91
- .action(async (name, options) => {
92
- try {
93
- const { base, apiKey } = resolveConnection();
94
- const slug = options.slug || generateSlug(name);
95
- const body = { name, slug };
96
- if (options.urls && options.urls.length > 0) {
97
- body.urls = options.urls;
98
- }
99
- if (options.policy) {
100
- body.policyId = options.policy;
101
- }
102
- const client = await apiRequest(base, "/clients", { method: "POST", body }, apiKey);
103
- process.stderr.write(chalk.green(`Client created successfully\n\n`));
104
- process.stderr.write(` Name: ${client.name}\n`);
105
- process.stderr.write(` Slug: ${client.slug}\n`);
106
- process.stderr.write(` ID: ${client.id}\n`);
107
- if (client.urls.length > 0) {
108
- process.stderr.write(` URLs: ${client.urls.join(", ")}\n`);
109
- }
110
- if (client.policy) {
111
- process.stderr.write(` Policy: ${client.policy.name}\n`);
112
- }
113
- process.stderr.write("\n");
114
- }
115
- catch (error) {
116
- process.stderr.write(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}\n`));
117
- process.exit(1);
118
- }
119
- });
120
- // vertaa client list
121
- clientCmd
122
- .command("list")
123
- .description("List all clients")
124
- .option("--format <format>", "Output format: human|json", "human")
125
- .action(async (options) => {
126
- try {
127
- const { base, apiKey } = resolveConnection();
128
- const clients = await apiRequest(base, "/clients", { method: "GET" }, apiKey);
129
- if (options.format === "json") {
130
- process.stdout.write(JSON.stringify(clients, null, 2) + "\n");
131
- return;
132
- }
133
- // Human format: table
134
- if (clients.length === 0) {
135
- process.stderr.write(chalk.dim("No clients found. Create one with: vertaa client create <name>\n"));
136
- return;
137
- }
138
- // Table header
139
- const nameWidth = 20;
140
- const slugWidth = 20;
141
- const urlsWidth = 8;
142
- const policyWidth = 20;
143
- const updatedWidth = 12;
144
- const header = padRight("Name", nameWidth) +
145
- padRight("Slug", slugWidth) +
146
- padRight("URLs", urlsWidth) +
147
- padRight("Policy", policyWidth) +
148
- padRight("Updated", updatedWidth);
149
- process.stderr.write("\n");
150
- process.stderr.write(chalk.bold(header) + "\n");
151
- process.stderr.write(chalk.dim("-".repeat(nameWidth + slugWidth + urlsWidth + policyWidth + updatedWidth)) + "\n");
152
- for (const client of clients) {
153
- const row = padRight(truncate(client.name, nameWidth - 2), nameWidth) +
154
- padRight(truncate(client.slug, slugWidth - 2), slugWidth) +
155
- padRight(String(client.urls.length), urlsWidth) +
156
- padRight(truncate(client.policy?.name || "-", policyWidth - 2), policyWidth) +
157
- padRight(formatDate(client.updatedAt), updatedWidth);
158
- process.stderr.write(row + "\n");
159
- }
160
- process.stderr.write("\n");
161
- process.stderr.write(chalk.dim(`${clients.length} client${clients.length !== 1 ? "s" : ""}\n`));
162
- }
163
- catch (error) {
164
- process.stderr.write(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}\n`));
165
- process.exit(1);
166
- }
167
- });
168
- // vertaa client remove <identifier>
169
- clientCmd
170
- .command("remove <identifier>")
171
- .description("Remove a client")
172
- .option("--force", "Skip confirmation")
173
- .action(async (identifier, options) => {
174
- try {
175
- const { base, apiKey } = resolveConnection();
176
- // Resolve the client: try ID first, then slug lookup
177
- let clientId;
178
- let clientName;
179
- let urlCount;
180
- if (looksLikeCuid(identifier)) {
181
- // Looks like an ID, use directly but verify it exists
182
- const client = await apiRequest(base, `/clients/${identifier}`, { method: "GET" }, apiKey);
183
- clientId = client.id;
184
- clientName = client.name;
185
- urlCount = client.urls.length;
186
- }
187
- else {
188
- // Treat as slug -- look up in the list
189
- const clients = await apiRequest(base, "/clients", { method: "GET" }, apiKey);
190
- const match = clients.find((c) => c.slug === identifier || c.name === identifier);
191
- if (!match) {
192
- process.stderr.write(chalk.red(`Error: Client "${identifier}" not found.\n`));
193
- process.exit(1);
194
- return;
195
- }
196
- clientId = match.id;
197
- clientName = match.name;
198
- urlCount = match.urls.length;
199
- }
200
- // Confirmation gate
201
- if (!options.force) {
202
- process.stderr.write(chalk.yellow(`About to delete client '${clientName}' with ${urlCount} URL${urlCount !== 1 ? "s" : ""}. This cannot be undone.\n`));
203
- process.stderr.write(chalk.dim("Add --force to confirm deletion.\n"));
204
- process.exit(1);
205
- return;
206
- }
207
- await apiRequest(base, `/clients/${clientId}`, { method: "DELETE" }, apiKey);
208
- process.stderr.write(chalk.green(`Client '${clientName}' removed.\n`));
209
- }
210
- catch (error) {
211
- process.stderr.write(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}\n`));
212
- process.exit(1);
213
- }
214
- });
215
- // vertaa client audit
216
- clientCmd
217
- .command("audit")
218
- .description("Run batch audit across client URLs")
219
- .option("--client <names>", "Comma-separated client names/slugs (default: all)")
220
- .option("--concurrency <n>", "Concurrent audits", "3")
221
- .option("--format <format>", "Output format: human|json", "human")
222
- .action(async (options) => {
223
- try {
224
- const { base, apiKey } = resolveConnection();
225
- // Fetch all clients
226
- const allClients = await apiRequest(base, "/clients", { method: "GET" }, apiKey);
227
- if (allClients.length === 0) {
228
- process.stderr.write(chalk.dim("No clients found. Create one with: vertaa client create <name>\n"));
229
- return;
230
- }
231
- // Filter by --client if provided
232
- let selectedClients;
233
- if (options.client) {
234
- const names = options.client.split(",").map((n) => n.trim().toLowerCase());
235
- selectedClients = allClients.filter((c) => names.includes(c.slug.toLowerCase()) ||
236
- names.includes(c.name.toLowerCase()));
237
- if (selectedClients.length === 0) {
238
- process.stderr.write(chalk.red(`Error: No matching clients found for: ${options.client}\n`));
239
- process.stderr.write(chalk.dim(`Available: ${allClients.map((c) => c.slug).join(", ")}\n`));
240
- process.exit(1);
241
- return;
242
- }
243
- }
244
- else {
245
- selectedClients = allClients;
246
- }
247
- // Flatten all URLs
248
- const urlTasks = [];
249
- for (const client of selectedClients) {
250
- for (const url of client.urls) {
251
- urlTasks.push({ client, url });
252
- }
253
- }
254
- if (urlTasks.length === 0) {
255
- process.stderr.write(chalk.dim("No URLs to audit across selected clients.\n"));
256
- return;
257
- }
258
- const concurrency = parseInt(options.concurrency, 10) || 3;
259
- const limit = pLimit(concurrency);
260
- process.stderr.write(chalk.dim(`Auditing ${urlTasks.length} URL${urlTasks.length !== 1 ? "s" : ""} across ${selectedClients.length} client${selectedClients.length !== 1 ? "s" : ""} (concurrency: ${concurrency})\n\n`));
261
- // Run batch audits with bounded concurrency
262
- const results = [];
263
- let completed = 0;
264
- const promises = urlTasks.map(({ client, url }) => limit(async () => {
265
- completed++;
266
- process.stderr.write(`[${completed}/${urlTasks.length}] Auditing ${url}...`);
267
- try {
268
- // Start audit
269
- const job = await apiRequest(base, "/audit", { method: "POST", body: { url, mode: "basic" } }, apiKey);
270
- if (!job.job_id) {
271
- throw new Error("No job_id in audit response");
272
- }
273
- // Wait for completion
274
- const result = await waitForAuditCompletion(base, apiKey, job.job_id);
275
- const scores = (result.scores || {});
276
- const overall = computeOverallScore(scores);
277
- process.stderr.write(` ${chalk.green("done")} (score: ${overall !== null ? overall : "n/a"})\n`);
278
- results.push({
279
- client: client.name,
280
- url,
281
- score: overall,
282
- status: "success",
283
- jobId: job.job_id,
284
- });
285
- }
286
- catch (err) {
287
- process.stderr.write(` ${chalk.red("failed")}\n`);
288
- results.push({
289
- client: client.name,
290
- url,
291
- score: null,
292
- status: "error",
293
- error: err instanceof Error ? err.message : String(err),
294
- });
295
- }
296
- }));
297
- await Promise.all(promises);
298
- // Output results
299
- process.stderr.write("\n");
300
- if (options.format === "json") {
301
- // Group by client for JSON output
302
- const grouped = {};
303
- for (const r of results) {
304
- if (!grouped[r.client])
305
- grouped[r.client] = [];
306
- grouped[r.client].push(r);
307
- }
308
- process.stdout.write(JSON.stringify(grouped, null, 2) + "\n");
309
- return;
310
- }
311
- // Human format: per-client summary
312
- const grouped = {};
313
- for (const r of results) {
314
- if (!grouped[r.client])
315
- grouped[r.client] = [];
316
- grouped[r.client].push(r);
317
- }
318
- for (const [clientName, clientResults] of Object.entries(grouped)) {
319
- process.stderr.write(chalk.bold(`${clientName}\n`));
320
- for (const r of clientResults) {
321
- const scoreStr = r.status === "success"
322
- ? r.score !== null
323
- ? String(r.score)
324
- : "n/a"
325
- : chalk.red("error");
326
- process.stderr.write(` ${r.url} ${scoreStr}\n`);
327
- }
328
- // Client average
329
- const successScores = clientResults
330
- .filter((r) => r.status === "success" && r.score !== null)
331
- .map((r) => r.score);
332
- if (successScores.length > 0) {
333
- const avg = Math.round((successScores.reduce((a, b) => a + b, 0) / successScores.length) * 100) / 100;
334
- process.stderr.write(chalk.dim(` Average: ${avg}\n`));
335
- }
336
- process.stderr.write("\n");
337
- }
338
- // Overall summary
339
- const totalSuccess = results.filter((r) => r.status === "success").length;
340
- const totalFailed = results.filter((r) => r.status === "error").length;
341
- process.stderr.write(chalk.dim(`Summary: ${totalSuccess} succeeded, ${totalFailed} failed out of ${results.length} audits\n`));
342
- }
343
- catch (error) {
344
- process.stderr.write(chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}\n`));
345
- process.exit(1);
346
- }
347
- });
348
- }
349
- /**
350
- * Pad a string to the right to a given width.
351
- */
352
- function padRight(str, width) {
353
- return str.length >= width ? str : str + " ".repeat(width - str.length);
354
- }
355
- /**
356
- * Truncate a string to a maximum length with ellipsis.
357
- */
358
- function truncate(str, maxLen) {
359
- if (str.length <= maxLen)
360
- return str;
361
- return str.slice(0, maxLen - 1) + "\u2026";
362
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * Drift detection command for VertaaUX CLI.
3
- *
4
- * Compares current audit scores against a baseline and reports
5
- * per-category regressions with delta magnitudes. Used in local
6
- * workflows and CI pipelines to detect score regressions before merging.
7
- *
8
- * Implements DRIFT-01: CLI drift check command.
9
- */
10
- import { Command } from "commander";
11
- /**
12
- * Register the drift command with the Commander program.
13
- */
14
- export declare function registerDriftCommand(program: Command): void;
15
- //# sourceMappingURL=drift.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"drift.d.ts","sourceRoot":"","sources":["../../src/commands/drift.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyNpC;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsK3D"}