@zibby/cli 0.1.5 → 0.1.7

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
@@ -44,7 +44,7 @@ program
44
44
  program
45
45
  .command('run')
46
46
  .description('Run a test specification')
47
- .argument('[spec-path]', 'Path to test spec file (e.g., test-specs/auth/login.txt)')
47
+ .argument('[spec-path]', 'Path to test spec file or inline test description in quotes')
48
48
  .option('--sources <ids>', 'Comma-separated test case IDs to fetch from cloud')
49
49
  .option('--execution <id>', 'Execution ID containing the test cases (required with --sources)')
50
50
  .option('--agent <type>', 'Agent to use (claude, cursor) - overrides config')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
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": "*",
36
- "@zibby/core": "^0.1.1",
36
+ "@zibby/core": "^0.1.0",
37
37
  "chalk": "^5.3.0",
38
38
  "commander": "^12.0.0",
39
39
  "dotenv": "^17.2.3",
@@ -205,10 +205,21 @@ export async function initCommand(projectName, options) {
205
205
  }
206
206
  }
207
207
 
208
- // Only create package.json if new project
208
+ // Create package.json for new projects, or ensure "type": "module" in existing ones
209
209
  if (isNewProject) {
210
210
  const packageJsonContent = generatePackageJson(projectNameActual, answers);
211
211
  await writeFile(join(targetDir, 'package.json'), packageJsonContent);
212
+ } else if (!existsSync(join(targetDir, 'package.json'))) {
213
+ const minimalPkg = JSON.stringify({ type: 'module', private: true }, null, 2);
214
+ await writeFile(join(targetDir, 'package.json'), minimalPkg);
215
+ } else {
216
+ try {
217
+ const existingPkg = JSON.parse(await readFile(join(targetDir, 'package.json'), 'utf-8'));
218
+ if (!existingPkg.type) {
219
+ existingPkg.type = 'module';
220
+ await writeFile(join(targetDir, 'package.json'), JSON.stringify(existingPkg, null, 2));
221
+ }
222
+ } catch { /* leave existing package.json alone if unparseable */ }
212
223
  }
213
224
 
214
225
  // Create .gitignore if doesn't exist
@@ -1,5 +1,5 @@
1
1
  import { runTest, logger, DEFAULT_OUTPUT_BASE, SESSIONS_DIR, DEFAULT_MODELS } from '@zibby/core';
2
- import { readFileSync, existsSync, statSync } from 'fs';
2
+ import { readFileSync, existsSync, statSync, mkdirSync, writeFileSync, rmSync } from 'fs';
3
3
  import { resolve, join } from 'path';
4
4
  import { glob } from 'glob';
5
5
  import chalk from 'chalk';
@@ -522,8 +522,6 @@ export async function runCommand(specPath, options) {
522
522
 
523
523
  console.log(chalk.green(`✓ Fetched ${testCases.length} test case(s)`));
524
524
 
525
- // Write each test case to a temp spec file and run sequentially
526
- const { mkdirSync, writeFileSync } = await import('fs');
527
525
  const tmpDir = resolve(process.cwd(), '.zibby-tmp');
528
526
  mkdirSync(tmpDir, { recursive: true });
529
527
 
@@ -541,8 +539,6 @@ export async function runCommand(specPath, options) {
541
539
  await runCommand(tmpSpec, childOptions);
542
540
  }
543
541
 
544
- // Cleanup
545
- const { rmSync } = await import('fs');
546
542
  rmSync(tmpDir, { recursive: true, force: true });
547
543
  return;
548
544
  }
@@ -550,11 +546,24 @@ export async function runCommand(specPath, options) {
550
546
  if (!specPath && !options.sources) {
551
547
  console.log(chalk.red('\n❌ Missing test spec path\n'));
552
548
  console.log(chalk.white('Usage:'));
553
- console.log(chalk.gray(' zibby run <spec-path> Run a test spec file'));
554
- console.log(chalk.gray(' zibby run test-specs/login.txt Example\n'));
549
+ console.log(chalk.gray(' zibby run test-specs/login.txt Run a spec file'));
550
+ console.log(chalk.gray(' zibby run "login and check dashboard" Run inline spec\n'));
555
551
  process.exit(1);
556
552
  }
557
553
 
554
+ const isInlineSpec = specPath
555
+ && !specPath.endsWith('.txt')
556
+ && !existsSync(resolve(process.cwd(), specPath))
557
+ && specPath.includes(' ');
558
+
559
+ if (isInlineSpec) {
560
+ const tmpDir = resolve(process.cwd(), '.zibby-tmp');
561
+ mkdirSync(tmpDir, { recursive: true });
562
+ const tmpSpec = resolve(tmpDir, `inline-${Date.now()}.txt`);
563
+ writeFileSync(tmpSpec, specPath, 'utf-8');
564
+ specPath = tmpSpec;
565
+ }
566
+
558
567
  const fullSpecPath = resolve(process.cwd(), specPath);
559
568
 
560
569
  if (!existsSync(fullSpecPath)) {
@@ -594,6 +603,8 @@ export async function runCommand(specPath, options) {
594
603
  };
595
604
  } catch (_error) {
596
605
  console.log(chalk.yellow(`⚠️ Could not load config from ${options.config}`));
606
+ config.agent = { provider: options.agent || 'claude' };
607
+ config.cloudSync = false;
597
608
  }
598
609
  } else {
599
610
  // No config file, use defaults
@@ -913,6 +924,7 @@ export async function runCommand(specPath, options) {
913
924
  // Check if error is from user interruption
914
925
  if (error.message.includes('Interrupted by user')) {
915
926
  console.log(chalk.yellow('Test execution was interrupted\n'));
927
+ cleanupInlineSpec(isInlineSpec);
916
928
  process.exit(130);
917
929
  }
918
930
 
@@ -920,7 +932,15 @@ export async function runCommand(specPath, options) {
920
932
  if (error.stack) {
921
933
  console.log(chalk.gray(error.stack));
922
934
  }
935
+ cleanupInlineSpec(isInlineSpec);
923
936
  process.exit(1);
924
937
  }
938
+
939
+ cleanupInlineSpec(isInlineSpec);
940
+ }
941
+
942
+ function cleanupInlineSpec(isInline) {
943
+ if (!isInline) return;
944
+ try { rmSync(resolve(process.cwd(), '.zibby-tmp'), { recursive: true, force: true }); } catch {}
925
945
  }
926
946