@kirrosh/zond 0.13.0 → 0.14.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/CHANGELOG.md CHANGED
@@ -48,6 +48,13 @@ All notable changes to this project will be documented in this file.
48
48
 
49
49
  ## [Unreleased]
50
50
 
51
+ ### Removed
52
+
53
+ - **AI subsystem** — removed `ai-generate` CLI, `chat` CLI, AI agent loop, LLM client, TUI chat UI, and all AI SDK dependencies (`ai`, `@ai-sdk/openai`, `@ai-sdk/anthropic`)
54
+ - **CLI commands** — removed `add-api`, `init`, `collections`, `runs`, `compare`, `doctor`, `update` (available via MCP tools or unnecessary)
55
+ - **Directories** — removed `generated/`, `examples/`, `self-tests/`, `apis/`, `docs/archive/`
56
+ - **Files** — removed `seed-demo.ts`, `BACKLOG.md`, `docs/agent.md`
57
+
51
58
  ### Added
52
59
 
53
60
  - **Extended YAML test format** — 12 new assertion operators, flow control, and data transforms:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kirrosh/zond",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "API testing platform — define tests in YAML, run from CLI or WebUI, generate from OpenAPI specs",
5
5
  "license": "MIT",
6
6
  "module": "index.ts",
@@ -26,9 +26,8 @@
26
26
  "scripts": {
27
27
  "zond": "bun run src/cli/index.ts",
28
28
  "test": "bun run test:unit && bun run test:mocked",
29
- "test:unit": "bun test tests/db/ tests/parser/ tests/runner/ tests/generator/ tests/core/ tests/cli/args.test.ts tests/cli/chat.test.ts tests/cli/ci-init.test.ts tests/cli/commands.test.ts tests/cli/doctor.test.ts tests/cli/init.test.ts tests/cli/runs.test.ts tests/cli/safe-run.test.ts tests/cli/update.test.ts tests/integration/ tests/web/ tests/mcp/tools.test.ts tests/mcp/save-test-suite.test.ts tests/agent/agent-loop.test.ts tests/agent/context-manager.test.ts tests/agent/system-prompt.test.ts tests/reporter/ tests/version-sync.test.ts",
29
+ "test:unit": "bun test tests/db/ tests/parser/ tests/runner/ tests/generator/ tests/core/ tests/cli/args.test.ts tests/cli/ci-init.test.ts tests/cli/commands.test.ts tests/cli/safe-run.test.ts tests/integration/ tests/web/ tests/mcp/tools.test.ts tests/mcp/save-test-suite.test.ts tests/reporter/ tests/version-sync.test.ts",
30
30
  "test:mocked": "bun run scripts/run-mocked-tests.ts",
31
- "test:ai": "bun test tests/ai/",
32
31
  "check": "tsc --noEmit --project tsconfig.json",
33
32
  "build": "bun build --compile src/cli/index.ts --outfile zond",
34
33
  "version:sync": "bun run scripts/sync-version.ts",
@@ -42,12 +41,9 @@
42
41
  },
43
42
  "dependencies": {
44
43
  "@humanwhocodes/momoa": "^2.0.3",
45
- "@ai-sdk/anthropic": "^2",
46
- "@ai-sdk/openai": "^2",
47
44
  "@hono/zod-openapi": "^1.2.2",
48
45
  "@modelcontextprotocol/sdk": "^1.27.1",
49
46
  "@readme/openapi-parser": "^5.5.0",
50
- "ai": "^6",
51
47
  "hono": "^4.12.2",
52
48
  "openapi-types": "^12.1.3",
53
49
  "zod": "^4.3.6"
package/src/cli/index.ts CHANGED
@@ -3,18 +3,9 @@
3
3
  import { runCommand } from "./commands/run.ts";
4
4
  import { validateCommand } from "./commands/validate.ts";
5
5
  import { serveCommand } from "./commands/serve.ts";
6
- import { collectionsCommand } from "./commands/collections.ts";
7
- import { aiGenerateCommand } from "./commands/ai-generate.ts";
8
6
  import { mcpCommand } from "./commands/mcp.ts";
9
- import { initCommand } from "./commands/init.ts";
10
- import { updateCommand } from "./commands/update.ts";
11
- import { chatCommand } from "./commands/chat.ts";
12
- import { runsCommand } from "./commands/runs.ts";
13
7
  import { coverageCommand } from "./commands/coverage.ts";
14
- import { doctorCommand } from "./commands/doctor.ts";
15
- import { addApiCommand } from "./commands/add-api.ts";
16
8
  import { ciInitCommand } from "./commands/ci-init.ts";
17
- import { compareCommand } from "./commands/compare.ts";
18
9
  import { printError } from "./output.ts";
19
10
  import { getRuntimeInfo } from "./runtime.ts";
20
11
  import { getDb } from "../db/schema.ts";
@@ -75,51 +66,13 @@ function printUsage(): void {
75
66
  console.log(`zond - API Testing Platform
76
67
 
77
68
  Usage:
78
- zond add-api <name> Register a new API (collection)
79
69
  zond run <path> Run API tests
80
70
  zond validate <path> Validate test files without running
81
- zond ai-generate --from <spec> --prompt "..." Generate tests with AI
82
- zond runs [id] View test run history
83
- zond coverage --spec <path> --tests <dir> Analyze API test coverage
84
- zond collections List test collections
71
+ zond coverage Analyze API test coverage
85
72
  zond serve Start web dashboard
86
- zond init Initialize a new zond project
87
- zond ci init Generate CI/CD workflow (GitHub Actions, GitLab CI)
88
73
  zond mcp Start MCP server (stdio transport for AI agents)
89
74
  --dir <path> Set working directory (relative paths resolve here)
90
- zond chat Start interactive AI chat for API testing
91
- zond compare <runA> <runB> Compare two test runs (regressions/fixes)
92
- zond doctor Run diagnostic checks
93
- zond update Update to latest version
94
-
95
- Options for 'add-api':
96
- --spec <path-or-url> OpenAPI spec (extracts base_url from servers[0])
97
- --dir <directory> Base directory (default: ./apis/<name>/)
98
- --env key=value Set environment variables (repeatable)
99
- --insecure Skip TLS verification (self-signed certs)
100
-
101
- Options for 'chat':
102
- --provider <name> LLM provider: ollama, openai, anthropic, custom (default: ollama)
103
- --model <name> Model name (default: provider-specific)
104
- --api-key <key> API key (or set ZOND_AI_KEY env var)
105
- --base-url <url> Provider base URL override
106
- --safe Only allow running GET tests (read-only mode)
107
-
108
- Options for 'runs':
109
- runs List recent test runs
110
- runs <id> Show run details with step results
111
- --limit <n> Number of runs to show (default: 20)
112
-
113
- Options for 'compare':
114
- compare <runA> <runB> Compare two run IDs
115
- Exit code 1 if regressions found, 0 otherwise
116
-
117
- Options for 'coverage':
118
- --api <name> Use API collection (auto-resolves spec and tests dir)
119
- --spec <path> Path to OpenAPI spec (required unless --api used)
120
- --tests <dir> Path to test files directory (required unless --api used)
121
- --fail-on-coverage N Exit 1 when coverage percentage is below N (0–100)
122
- --run-id <number> Cross-reference with a test run for pass/fail/5xx breakdown
75
+ zond ci init Generate CI/CD workflow (GitHub Actions, GitLab CI)
123
76
 
124
77
  Options for 'run':
125
78
  --dry-run Show requests without sending them (exit code always 0)
@@ -135,15 +88,12 @@ Options for 'run':
135
88
  --safe Run only GET tests (read-only, safe mode)
136
89
  --tag <tag> Filter suites by tag (repeatable, comma-separated, OR logic)
137
90
 
138
- Options for 'ai-generate':
139
- --api <name> Use API collection (auto-resolves spec and output dir)
140
- --from <spec> Path to OpenAPI spec (required unless --api used)
141
- --prompt <text> Test scenario description (required)
142
- --provider <name> LLM provider: ollama, openai, anthropic, custom (default: ollama)
143
- --model <name> Model name (default: provider-specific)
144
- --api-key <key> API key (or set ZOND_AI_KEY env var)
145
- --base-url <url> Provider base URL override
146
- --output <dir> Output directory (default: ./generated/ai/)
91
+ Options for 'coverage':
92
+ --api <name> Use API collection (auto-resolves spec and tests dir)
93
+ --spec <path> Path to OpenAPI spec (required unless --api used)
94
+ --tests <dir> Path to test files directory (required unless --api used)
95
+ --fail-on-coverage N Exit 1 when coverage percentage is below N (0–100)
96
+ --run-id <number> Cross-reference with a test run for pass/fail/5xx breakdown
147
97
 
148
98
  Options for 'serve':
149
99
  --port <port> Server port (default: 8080)
@@ -186,35 +136,6 @@ async function main(): Promise<number> {
186
136
  }
187
137
 
188
138
  switch (command) {
189
- case "add-api": {
190
- const name = positional[0];
191
- if (!name) {
192
- printError("Missing name argument. Usage: zond add-api <name> [--spec <path>] [--dir <dir>]");
193
- return 2;
194
- }
195
-
196
- // Collect all --env flags (parseArgs only stores last one, so re-parse)
197
- const envValues: string[] = [];
198
- const rawArgs = process.argv.slice(2);
199
- for (let i = 0; i < rawArgs.length; i++) {
200
- if (rawArgs[i] === "--env" && rawArgs[i + 1] && rawArgs[i + 1]!.includes("=")) {
201
- envValues.push(rawArgs[i + 1]!);
202
- i++;
203
- } else if (rawArgs[i]?.startsWith("--env=") && rawArgs[i]!.slice(6).includes("=")) {
204
- envValues.push(rawArgs[i]!.slice(6));
205
- }
206
- }
207
-
208
- return addApiCommand({
209
- name,
210
- spec: typeof flags["spec"] === "string" ? flags["spec"] : undefined,
211
- dir: typeof flags["dir"] === "string" ? flags["dir"] : undefined,
212
- envPairs: envValues.length > 0 ? envValues : undefined,
213
- dbPath: typeof flags["db"] === "string" ? flags["db"] : undefined,
214
- insecure: flags["insecure"] === true,
215
- });
216
- }
217
-
218
139
  case "run": {
219
140
  let path = positional[0];
220
141
  const apiFlag = typeof flags["api"] === "string" ? flags["api"] : undefined;
@@ -297,51 +218,6 @@ async function main(): Promise<number> {
297
218
  return validateCommand({ path });
298
219
  }
299
220
 
300
- case "ai-generate": {
301
- let from = flags["from"] as string | undefined;
302
- let output = typeof flags["output"] === "string" ? flags["output"] : undefined;
303
- const aiGenApiFlag = typeof flags["api"] === "string" ? flags["api"] : undefined;
304
-
305
- // Resolve --api to spec and output dir from collection
306
- if (aiGenApiFlag) {
307
- try {
308
- getDb(typeof flags["db"] === "string" ? flags["db"] : undefined);
309
- const col = findCollectionByNameOrId(aiGenApiFlag);
310
- if (!col) { printError(`API '${aiGenApiFlag}' not found`); return 1; }
311
- if (!from && col.openapi_spec) from = col.openapi_spec;
312
- if (!output && col.test_path) output = col.test_path;
313
- } catch (err) {
314
- printError(`Failed to resolve --api: ${(err as Error).message}`);
315
- return 2;
316
- }
317
- }
318
-
319
- if (typeof from !== "string") {
320
- printError("Missing --from <spec>. Usage: zond ai-generate --from <spec> --prompt \"...\"");
321
- return 2;
322
- }
323
- const prompt = flags["prompt"];
324
- if (typeof prompt !== "string") {
325
- printError("Missing --prompt <text>. Usage: zond ai-generate --from <spec> --prompt \"...\"");
326
- return 2;
327
- }
328
- return aiGenerateCommand({
329
- from,
330
- prompt,
331
- provider: typeof flags["provider"] === "string" ? flags["provider"] : "ollama",
332
- model: typeof flags["model"] === "string" ? flags["model"] : undefined,
333
- apiKey: typeof flags["api-key"] === "string" ? flags["api-key"] : undefined,
334
- baseUrl: typeof flags["base-url"] === "string" ? flags["base-url"] : undefined,
335
- output,
336
- });
337
- }
338
-
339
- case "collections": {
340
- return collectionsCommand(
341
- typeof flags["db"] === "string" ? flags["db"] : undefined,
342
- );
343
- }
344
-
345
221
  case "serve": {
346
222
  const portRaw = flags["port"];
347
223
  let port: number | undefined;
@@ -361,12 +237,6 @@ async function main(): Promise<number> {
361
237
  });
362
238
  }
363
239
 
364
- case "init": {
365
- return initCommand({
366
- force: flags["force"] === true,
367
- });
368
- }
369
-
370
240
  case "mcp": {
371
241
  return mcpCommand({
372
242
  dbPath: typeof flags["db"] === "string" ? flags["db"] : undefined,
@@ -374,49 +244,6 @@ async function main(): Promise<number> {
374
244
  });
375
245
  }
376
246
 
377
- case "chat": {
378
- return chatCommand({
379
- provider: typeof flags["provider"] === "string" ? flags["provider"] : undefined,
380
- model: typeof flags["model"] === "string" ? flags["model"] : undefined,
381
- apiKey: typeof flags["api-key"] === "string" ? flags["api-key"] : undefined,
382
- baseUrl: typeof flags["base-url"] === "string" ? flags["base-url"] : undefined,
383
- safe: flags["safe"] === true,
384
- dbPath: typeof flags["db"] === "string" ? flags["db"] : undefined,
385
- });
386
- }
387
-
388
- case "update": {
389
- return updateCommand({ force: flags["force"] === true });
390
- }
391
-
392
- case "runs": {
393
- const idRaw = positional[0];
394
- let runId: number | undefined;
395
- if (idRaw) {
396
- runId = parseInt(idRaw, 10);
397
- if (isNaN(runId)) {
398
- printError(`Invalid run ID: ${idRaw}`);
399
- return 2;
400
- }
401
- }
402
-
403
- const limitRaw = flags["limit"];
404
- let limit: number | undefined;
405
- if (typeof limitRaw === "string") {
406
- limit = parseInt(limitRaw, 10);
407
- if (isNaN(limit) || limit <= 0) {
408
- printError(`Invalid limit value: ${limitRaw}`);
409
- return 2;
410
- }
411
- }
412
-
413
- return runsCommand({
414
- runId,
415
- limit,
416
- dbPath: typeof flags["db"] === "string" ? flags["db"] : undefined,
417
- });
418
- }
419
-
420
247
  case "ci": {
421
248
  const ciSub = positional[0];
422
249
  if (ciSub !== "init") {
@@ -433,32 +260,6 @@ async function main(): Promise<number> {
433
260
  });
434
261
  }
435
262
 
436
- case "compare": {
437
- const rawA = positional[0];
438
- const rawB = positional[1];
439
- if (!rawA || !rawB) {
440
- printError("Usage: zond compare <runA> <runB>");
441
- return 2;
442
- }
443
- const runA = parseInt(rawA, 10);
444
- const runB = parseInt(rawB, 10);
445
- if (isNaN(runA) || isNaN(runB)) {
446
- printError("Run IDs must be integers");
447
- return 2;
448
- }
449
- return compareCommand({
450
- runA,
451
- runB,
452
- dbPath: typeof flags["db"] === "string" ? flags["db"] : undefined,
453
- });
454
- }
455
-
456
- case "doctor": {
457
- return doctorCommand({
458
- dbPath: typeof flags["db"] === "string" ? flags["db"] : undefined,
459
- });
460
- }
461
-
462
263
  case "coverage": {
463
264
  let spec = flags["spec"] as string | undefined;
464
265
  let tests = flags["tests"] as string | undefined;
@@ -2,9 +2,6 @@ export { readOpenApiSpec, extractEndpoints, extractSecuritySchemes } from "./ope
2
2
  export { serializeSuite, isRelativeUrl, sanitizeEnvName, resolveSpecPath } from "./serializer.ts";
3
3
  export type { RawSuite, RawStep } from "./serializer.ts";
4
4
  export { generateFromSchema } from "./data-factory.ts";
5
- export { generateWithAI } from "./ai/ai-generator.ts";
6
- export { resolveProviderConfig, PROVIDER_DEFAULTS } from "./ai/types.ts";
7
- export type { AIProviderConfig, AIGenerateOptions, AIGenerateResult } from "./ai/types.ts";
8
5
  export { scanCoveredEndpoints, filterUncoveredEndpoints, normalizePath, specPathToRegex } from "./coverage-scanner.ts";
9
6
  export type { CoveredEndpoint } from "./coverage-scanner.ts";
10
7
  export { analyzeEndpoints } from "./endpoint-warnings.ts";
@@ -1,53 +0,0 @@
1
- import { setupApi } from "../../core/setup-api.ts";
2
- import { printError, printSuccess } from "../output.ts";
3
-
4
- export interface AddApiOptions {
5
- name: string;
6
- spec?: string;
7
- dir?: string;
8
- envPairs?: string[];
9
- dbPath?: string;
10
- insecure?: boolean;
11
- }
12
-
13
- export async function addApiCommand(options: AddApiOptions): Promise<number> {
14
- const { name, spec, envPairs, dbPath, dir, insecure } = options;
15
-
16
- // Parse --env key=value pairs into a record
17
- const envVars: Record<string, string> = {};
18
- if (envPairs) {
19
- for (const pair of envPairs) {
20
- const idx = pair.indexOf("=");
21
- if (idx === -1) continue;
22
- const key = pair.slice(0, idx).trim();
23
- const value = pair.slice(idx + 1).trim();
24
- if (key) envVars[key] = value;
25
- }
26
- }
27
-
28
- try {
29
- const result = await setupApi({
30
- name,
31
- spec,
32
- dir,
33
- envVars: Object.keys(envVars).length > 0 ? envVars : undefined,
34
- dbPath,
35
- insecure,
36
- });
37
-
38
- printSuccess(`API '${name}' created (id=${result.collectionId})`);
39
- console.log(` Directory: ${result.testPath.replace(/\/tests$/, "")}`);
40
- console.log(` Tests: ${result.testPath}/`);
41
- if (spec) console.log(` Spec: ${spec}`);
42
- if (result.baseUrl) console.log(` Base URL: ${result.baseUrl}`);
43
- console.log();
44
- console.log("Next steps:");
45
- console.log(` zond ai-generate --api ${name} --prompt "test the user endpoints"`);
46
- console.log(` zond run --api ${name}`);
47
-
48
- return 0;
49
- } catch (err) {
50
- printError((err as Error).message);
51
- return 1;
52
- }
53
- }
@@ -1,106 +0,0 @@
1
- import { resolve, dirname } from "path";
2
- import { generateWithAI } from "../../core/generator/ai/ai-generator.ts";
3
- import { resolveProviderConfig } from "../../core/generator/ai/types.ts";
4
- import type { AIProviderConfig } from "../../core/generator/ai/types.ts";
5
- import { printError, printSuccess } from "../output.ts";
6
-
7
- export interface AIGenerateCommandOptions {
8
- from: string;
9
- prompt: string;
10
- provider: string;
11
- model?: string;
12
- apiKey?: string;
13
- baseUrl?: string;
14
- output?: string;
15
- }
16
-
17
- export async function aiGenerateCommand(options: AIGenerateCommandOptions): Promise<number> {
18
- try {
19
- const providerName = options.provider as AIProviderConfig["provider"];
20
- if (!["ollama", "openai", "anthropic", "custom"].includes(providerName)) {
21
- printError(`Unknown provider: ${options.provider}. Use: ollama, openai, anthropic, custom`);
22
- return 2;
23
- }
24
-
25
- const provider = resolveProviderConfig({
26
- provider: providerName,
27
- model: options.model,
28
- baseUrl: options.baseUrl,
29
- apiKey: options.apiKey ?? process.env.ZOND_AI_KEY,
30
- });
31
-
32
- console.log(`Provider: ${provider.provider} (${provider.model})`);
33
- console.log(`Spec: ${options.from}`);
34
- console.log(`Prompt: ${options.prompt}`);
35
- console.log(`Generating...`);
36
-
37
- const startTime = Date.now();
38
- const result = await generateWithAI({
39
- specPath: options.from,
40
- prompt: options.prompt,
41
- provider,
42
- });
43
- const durationMs = Date.now() - startTime;
44
-
45
- console.log(`Done in ${(durationMs / 1000).toFixed(1)}s (model: ${result.model})`);
46
- if (result.promptTokens) {
47
- console.log(`Tokens: ${result.promptTokens} prompt + ${result.completionTokens} completion`);
48
- }
49
-
50
- // Write output
51
- const outputDir = options.output ?? "./generated/ai/";
52
- const { mkdir } = await import("node:fs/promises");
53
- await mkdir(outputDir, { recursive: true });
54
-
55
- const timestamp = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
56
- const fileName = `ai-generated-${timestamp}.yaml`;
57
- const filePath = resolve(outputDir, fileName);
58
-
59
- await Bun.write(filePath, result.yaml);
60
- printSuccess(`Written: ${filePath}`);
61
-
62
- // Auto-create collection if DB is available
63
- try {
64
- const { getDb } = await import("../../db/schema.ts");
65
- getDb();
66
- const { findCollectionByTestPath, findCollectionBySpec, createCollection, normalizePath, saveAIGeneration } = await import("../../db/queries.ts");
67
- const { resolveSpecPath } = await import("../../core/generator/serializer.ts");
68
- const normalizedOutput = normalizePath(outputDir);
69
- const resolvedSpec = resolveSpecPath(options.from);
70
-
71
- let collectionId: number | undefined;
72
- const existing = findCollectionByTestPath(normalizedOutput) ?? findCollectionBySpec(resolvedSpec);
73
- if (existing) {
74
- collectionId = existing.id;
75
- } else {
76
- const specName = `AI Tests (${new Date().toLocaleDateString()})`;
77
- collectionId = createCollection({
78
- name: specName,
79
- test_path: normalizedOutput,
80
- openapi_spec: resolvedSpec,
81
- });
82
- printSuccess(`Created collection "${specName}" (id: ${collectionId})`);
83
- }
84
-
85
- saveAIGeneration({
86
- collection_id: collectionId,
87
- prompt: options.prompt,
88
- model: result.model,
89
- provider: providerName,
90
- generated_yaml: result.yaml,
91
- output_path: filePath,
92
- status: "success",
93
- prompt_tokens: result.promptTokens,
94
- completion_tokens: result.completionTokens,
95
- duration_ms: durationMs,
96
- });
97
- } catch {
98
- // DB not critical
99
- }
100
-
101
- return 0;
102
- } catch (err) {
103
- printError(err instanceof Error ? err.message : String(err));
104
- return 2;
105
- }
106
- }
@@ -1,43 +0,0 @@
1
- import { resolveProviderConfig, PROVIDER_DEFAULTS } from "../../core/generator/ai/types.ts";
2
- import type { AIProviderConfig } from "../../core/generator/ai/types.ts";
3
- import { printError } from "../output.ts";
4
-
5
- export interface ChatCommandOptions {
6
- provider?: string;
7
- model?: string;
8
- apiKey?: string;
9
- baseUrl?: string;
10
- safe?: boolean;
11
- dbPath?: string;
12
- }
13
-
14
- const VALID_PROVIDERS = new Set(["ollama", "openai", "anthropic", "custom"]);
15
-
16
- export async function chatCommand(options: ChatCommandOptions): Promise<number> {
17
- const providerName = options.provider ?? "ollama";
18
-
19
- if (!VALID_PROVIDERS.has(providerName)) {
20
- printError(`Unknown provider: ${providerName}. Available: ollama, openai, anthropic, custom`);
21
- return 2;
22
- }
23
-
24
- const providerConfig = resolveProviderConfig({
25
- provider: providerName as AIProviderConfig["provider"],
26
- model: options.model,
27
- apiKey: options.apiKey ?? process.env["ZOND_AI_KEY"],
28
- baseUrl: options.baseUrl,
29
- });
30
-
31
- try {
32
- const { startChatUI } = await import("../../tui/chat-ui.ts");
33
- await startChatUI({
34
- provider: providerConfig,
35
- safeMode: options.safe,
36
- dbPath: options.dbPath,
37
- });
38
- return 0;
39
- } catch (err) {
40
- printError(`Chat error: ${(err as Error).message}`);
41
- return 2;
42
- }
43
- }
@@ -1,41 +0,0 @@
1
- import { getDb } from "../../db/schema.ts";
2
- import { listCollections } from "../../db/queries.ts";
3
- import { formatDuration } from "../../core/reporter/console.ts";
4
-
5
- export function collectionsCommand(dbPath?: string): number {
6
- getDb(dbPath);
7
- const collections = listCollections();
8
-
9
- if (collections.length === 0) {
10
- console.log("No collections found.");
11
- console.log("Hint: use `zond generate --from <spec>` to create a collection automatically.");
12
- return 0;
13
- }
14
-
15
- // Print table header
16
- const header = [
17
- "ID".padEnd(5),
18
- "Name".padEnd(30),
19
- "Runs".padEnd(6),
20
- "Pass Rate".padEnd(11),
21
- "Last Run".padEnd(20),
22
- ].join(" ");
23
-
24
- console.log(header);
25
- console.log("-".repeat(header.length));
26
-
27
- for (const c of collections) {
28
- const passRate = c.total_runs > 0 ? `${c.pass_rate}%` : "-";
29
- const lastRun = c.last_run_at ?? "-";
30
- const row = [
31
- String(c.id).padEnd(5),
32
- c.name.slice(0, 30).padEnd(30),
33
- String(c.total_runs).padEnd(6),
34
- passRate.padEnd(11),
35
- lastRun.slice(0, 20).padEnd(20),
36
- ].join(" ");
37
- console.log(row);
38
- }
39
-
40
- return 0;
41
- }