@zibby/cli 0.1.23 → 0.1.26

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/bin/zibby.js CHANGED
@@ -2,10 +2,14 @@
2
2
 
3
3
  // Prevent EPIPE errors from crashing when stdout/stderr is closed
4
4
  process.stdout.on('error', (err) => {
5
- if (err.code === 'EPIPE') process.exit(0);
5
+ if (err.code === 'EPIPE') {
6
+ // Suppress EPIPE (broken pipe) errors
7
+ }
6
8
  });
7
9
  process.stderr.on('error', (err) => {
8
- if (err.code === 'EPIPE') process.exit(0);
10
+ if (err.code === 'EPIPE') {
11
+ // Suppress EPIPE (broken pipe) errors
12
+ }
9
13
  });
10
14
 
11
15
  // Suppress dotenv promotional messages
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/cli",
3
- "version": "0.1.23",
3
+ "version": "0.1.26",
4
4
  "description": "Zibby CLI - Test automation generator and runner",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@aws-sdk/client-sqs": "^3.1000.0",
35
35
  "@zibby/skills": "^0.1.3",
36
- "@zibby/core": "^0.1.18",
36
+ "@zibby/core": "^0.1.21",
37
37
  "@zibby/memory": "^0.1.3",
38
38
  "chalk": "^5.3.0",
39
39
  "commander": "^12.0.0",
@@ -24,6 +24,7 @@ import { writeMcpConfig } from '@zibby/core/utils/mcp-config-writer.js';
24
24
 
25
25
  const __filename = fileURLToPath(import.meta.url);
26
26
  const __dirname = dirname(__filename);
27
+ const cliPackageJson = JSON.parse(readFileSync(join(__dirname, '../../package.json'), 'utf-8'));
27
28
 
28
29
  /**
29
30
  * Node execution middleware - Captures logs and reports progress
@@ -188,6 +189,7 @@ export async function analyzeCommand(options) {
188
189
  const promptsDir = join(dirname(dirname(dirname(__dirname))), 'core', 'templates', 'code-analysis', 'prompts');
189
190
 
190
191
  console.log('\nšŸš€ Zibby Analysis (Graph Mode)');
192
+ console.log(`@zibby/cli v${cliPackageJson.version} | Node.js ${process.version}`);
191
193
  console.log('─'.repeat(60));
192
194
  console.log(`Ticket: ${TICKET_KEY}`);
193
195
  console.log(`Repositories: ${repos.length}`);
@@ -286,30 +286,11 @@ export async function initCommand(projectName, options) {
286
286
  const configContent = generateConfig(answers, options);
287
287
  await writeFile(join(targetDir, '.zibby.config.mjs'), configContent);
288
288
 
289
- // Always create .env.example
290
- const envContent = generateEnvFile(answers, options);
289
+ // Create .env.example as a template (never auto-create .env)
290
+ const envContent = answers.apiKey && answers.apiKey.trim()
291
+ ? generateEnvFileWithKey(answers, answers.apiKey.trim())
292
+ : generateEnvFile(answers);
291
293
  await writeFile(join(targetDir, '.env.example'), envContent);
292
-
293
- // Create/update .env file
294
- const envPath = join(targetDir, '.env');
295
- if (answers.apiKey && answers.apiKey.trim()) {
296
- await createOrUpdateEnvFile(targetDir, answers.apiKey.trim(), answers, options);
297
- } else if (!existsSync(envPath)) {
298
- // Create .env from .env.example if it doesn't exist
299
- await writeFile(envPath, envContent);
300
- } else if (options.force) {
301
- // On force reinit, merge memory vars into existing .env if using --mem
302
- if (options.mem) {
303
- let existingEnv = await readFile(envPath, 'utf-8');
304
- if (!existingEnv.includes('ZIBBY_MEMORY_MAX_RUNS')) {
305
- existingEnv += `\n# Test Memory (Dolt DB) - Auto-compaction settings\n`;
306
- existingEnv += `# ZIBBY_MEMORY_MAX_RUNS=3000 # Max test runs to keep per spec\n`;
307
- existingEnv += `# ZIBBY_MEMORY_MAX_AGE=1095 # Max age in days for stale data (~3 years)\n`;
308
- existingEnv += `# ZIBBY_MEMORY_COMPACT_EVERY=1500 # Auto-compact every N runs (0 to disable)\n`;
309
- await writeFile(envPath, existingEnv);
310
- }
311
- }
312
- }
313
294
 
314
295
 
315
296
  // Create package.json for new projects only (don't modify existing ones)
@@ -432,10 +413,8 @@ export async function initCommand(projectName, options) {
432
413
 
433
414
  mcpSpinner.succeed(message);
434
415
 
435
- if (cloudSync && answers.apiKey) {
436
- console.log(chalk.gray('\n āœ“ ZIBBY_API_KEY saved to .env\n'));
437
- } else if (cloudSync) {
438
- console.log(chalk.gray('\n Set ZIBBY_API_KEY in .env to enable uploads\n'));
416
+ if (cloudSync) {
417
+ console.log(chalk.gray('\n Copy .env.example to .env and set ZIBBY_API_KEY to enable uploads\n'));
439
418
  }
440
419
  } catch (error) {
441
420
  // Error during MCP setup - check if MCP is already configured
@@ -456,22 +435,10 @@ export async function initCommand(projectName, options) {
456
435
  console.log(chalk.white(' zibby run test-specs/examples/example-domain.txt\n'));
457
436
 
458
437
  console.log(chalk.cyan('Next steps:'));
459
- if (answers.agent === 'claude') {
460
- let step = 1;
461
- console.log(chalk.white(` ${step++}. ${answers.apiKey ? 'Update' : 'Copy .env.example to .env and add'} ANTHROPIC_API_KEY`));
462
- if (answers.cloudSync && !answers.apiKey) {
463
- console.log(chalk.white(` ${step++}. Add ZIBBY_API_KEY to .env for cloud sync`));
464
- }
465
- console.log(chalk.white(` ${step++}. Write test specs in test-specs/`));
466
- console.log(chalk.white(` ${step++}. Run: npx zibby run <spec-file>\n`));
467
- } else if (answers.agent === 'cursor') {
468
- let step = 1;
469
- if (answers.cloudSync && !answers.apiKey) {
470
- console.log(chalk.white(` ${step++}. Add ZIBBY_API_KEY to .env for cloud sync`));
471
- }
472
- console.log(chalk.white(` ${step++}. Write test specs in test-specs/`));
473
- console.log(chalk.white(` ${step++}. Run: npx zibby run <spec-file>\n`));
474
- }
438
+ let step = 1;
439
+ console.log(chalk.white(` ${step++}. cp .env.example .env ${chalk.gray('# then add your API keys')}`));
440
+ console.log(chalk.white(` ${step++}. Write test specs in test-specs/`));
441
+ console.log(chalk.white(` ${step++}. Run: npx zibby run <spec-file>\n`));
475
442
 
476
443
  } catch (error) {
477
444
  spinner.fail('Failed to create project');
@@ -553,86 +520,38 @@ function generateConfig(answers, _options = {}) {
553
520
  `;
554
521
  }
555
522
 
556
- function generateEnvFile(answers, options = {}) {
557
- let content = `# Zibby Test Automation - Environment Variables
523
+ function generateEnvFile(answers) {
524
+ return `# Zibby Test Automation - Environment Variables
558
525
 
559
526
  # AI Provider Keys
560
- ${answers.agent === 'claude' ? '# Claude (Anthropic) - Direct API\nANTHROPIC_API_KEY=sk-ant-your_key_here\n' : '# ANTHROPIC_API_KEY=sk-ant-your_key_here\n'}
561
- ${answers.agent === 'cursor' ? '# Cursor Agent (uses cursor-agent CLI)\n# No API key needed if cursor-agent is installed\n# Run: curl https://cursor.com/install -fsS | bash\n' : ''}
527
+ ${answers.agent === 'claude' ? '# Claude (Anthropic) - Direct API\nANTHROPIC_API_KEY=sk-ant-your_key_here' : '# ANTHROPIC_API_KEY=sk-ant-your_key_here'}
528
+ ${answers.agent === 'cursor' ? '# Cursor Agent (uses cursor-agent CLI)\n# No API key needed if cursor-agent is installed\n# Run: curl https://cursor.com/install -fsS | bash' : ''}
562
529
 
563
530
  # Zibby Cloud Sync (for uploading test results & videos)
564
531
  # Get your API key from: https://zibby.app/settings/tokens
565
532
  # ZIBBY_API_KEY=zby_your_api_key_here
566
533
 
567
- # Optional: Notifications
568
- # SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
569
- `;
570
-
571
- // Add memory configuration if --mem flag is used
572
- if (options.mem) {
573
- content += `
574
534
  # Test Memory (Dolt DB) - Auto-compaction settings
575
535
  # ZIBBY_MEMORY_MAX_RUNS=3000 # Max test runs to keep per spec
576
536
  # ZIBBY_MEMORY_MAX_AGE=1095 # Max age in days for stale data (~3 years)
577
537
  # ZIBBY_MEMORY_COMPACT_EVERY=1500 # Auto-compact every N runs (0 to disable)
578
538
  `;
579
- }
580
-
581
- return content;
582
- }
583
-
584
- async function createOrUpdateEnvFile(targetDir, apiKey, answers, options = {}) {
585
- const envPath = join(targetDir, '.env');
586
- let envContent;
587
-
588
- // Read existing .env if it exists
589
- if (existsSync(envPath)) {
590
- try {
591
- envContent = await readFile(envPath, 'utf-8');
592
-
593
- // Update or add ZIBBY_API_KEY
594
- if (envContent.includes('ZIBBY_API_KEY=')) {
595
- envContent = envContent.replace(
596
- /ZIBBY_API_KEY=.*/g,
597
- `ZIBBY_API_KEY=${apiKey}`
598
- );
599
- } else {
600
- envContent += `\n# Zibby Cloud Sync\nZIBBY_API_KEY=${apiKey}\n`;
601
- }
602
- } catch (_error) {
603
- envContent = generateEnvFileWithKey(answers, apiKey, options);
604
- }
605
- } else {
606
- envContent = generateEnvFileWithKey(answers, apiKey, options);
607
- }
608
-
609
- await writeFile(envPath, envContent);
610
539
  }
611
540
 
612
- function generateEnvFileWithKey(answers, apiKey, options = {}) {
613
- let content = `# Zibby Test Automation - Environment Variables
541
+ function generateEnvFileWithKey(answers, apiKey) {
542
+ return `# Zibby Test Automation - Environment Variables
614
543
 
615
544
  # AI Provider Keys
616
- ${answers.agent === 'claude' ? 'ANTHROPIC_API_KEY=sk-ant-your_key_here\n' : '# ANTHROPIC_API_KEY=sk-ant-your_key_here\n'}
545
+ ${answers.agent === 'claude' ? 'ANTHROPIC_API_KEY=sk-ant-your_key_here' : '# ANTHROPIC_API_KEY=sk-ant-your_key_here'}
617
546
 
618
547
  # Zibby Cloud Sync
619
548
  ZIBBY_API_KEY=${apiKey}
620
549
 
621
- # Optional: Notifications
622
- # SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
623
- `;
624
-
625
- // Add memory configuration if --mem flag is used
626
- if (options.mem) {
627
- content += `
628
550
  # Test Memory (Dolt DB) - Auto-compaction settings
629
551
  # ZIBBY_MEMORY_MAX_RUNS=3000 # Max test runs to keep per spec
630
552
  # ZIBBY_MEMORY_MAX_AGE=1095 # Max age in days for stale data (~3 years)
631
553
  # ZIBBY_MEMORY_COMPACT_EVERY=1500 # Auto-compact every N runs (0 to disable)
632
554
  `;
633
- }
634
-
635
- return content;
636
555
  }
637
556
 
638
557
  function generatePackageJson(projectName, _answers) {
@@ -647,8 +566,8 @@ function generatePackageJson(projectName, _answers) {
647
566
  'test:headed': 'playwright test --headed'
648
567
  },
649
568
  dependencies: {
650
- '@zibby/cli': '^0.1.23',
651
- '@zibby/core': '^0.1.18'
569
+ '@zibby/cli': '^0.1.25',
570
+ '@zibby/core': '^0.1.20'
652
571
  },
653
572
  devDependencies: {
654
573
  '@playwright/test': '^1.49.0',
@@ -835,7 +754,7 @@ ${projectName}/
835
754
  │ └── output/ # Workflow execution results (gitignored)
836
755
  │ └── sessions/ # Session artifacts & recordings
837
756
  ā”œā”€ā”€ .zibby.config.mjs # Configuration
838
- ā”œā”€ā”€ .env # API keys (gitignored)
757
+ ā”œā”€ā”€ .env.example # Environment template (cp to .env and configure)
839
758
  ā”œā”€ā”€ test-specs/ # Test specifications (committed)
840
759
  │ └── examples/
841
760
  │ └── example-domain.txt
@@ -1,6 +1,7 @@
1
1
  import { runTest, logger, DEFAULT_OUTPUT_BASE, SESSIONS_DIR, DEFAULT_MODELS } from '@zibby/core';
2
2
  import { readFileSync, existsSync, statSync, mkdirSync, writeFileSync, rmSync } from 'fs';
3
- import { resolve, join } from 'path';
3
+ import { resolve, join, dirname } from 'path';
4
+ import { fileURLToPath } from 'url';
4
5
  import { glob } from 'glob';
5
6
  import chalk from 'chalk';
6
7
  import ora from 'ora';
@@ -9,6 +10,10 @@ import open from 'open';
9
10
  import { getApiUrl, getAccountApiUrl, getCurrentEnvironment, getFrontendUrl } from '../config/environments.js';
10
11
  import { getSessionToken, getUserInfo } from '../config/config.js';
11
12
 
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = dirname(__filename);
15
+ const cliPackageJson = JSON.parse(readFileSync(join(__dirname, '../../package.json'), 'utf-8'));
16
+
12
17
  process.env.DOTENV_CONFIG_QUIET = 'true';
13
18
 
14
19
  const nodeEnv = process.env.NODE_ENV || 'development';
@@ -497,6 +502,7 @@ export async function runCommand(specPath, options) {
497
502
  // Let the agent's executePrompt handle it and propagate naturally
498
503
 
499
504
  console.log(chalk.bold.cyan('\nZibby Test Automation\n'));
505
+ console.log(chalk.gray(`@zibby/cli v${cliPackageJson.version} | Node.js ${process.version}`));
500
506
  console.log(chalk.gray('━'.repeat(50)));
501
507
 
502
508
  // --sources mode: fetch test cases from cloud and run them