@zibby/core 0.1.10 → 0.1.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/core",
3
- "version": "0.1.10",
3
+ "version": "0.1.13",
4
4
  "description": "Core test automation engine with multi-agent and multi-MCP support",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -5,13 +5,30 @@ set -e
5
5
  # Get script directory for relative imports
6
6
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
7
 
8
- # Step 1: Check cursor-agent
9
- if ! command -v cursor-agent &> /dev/null; then
8
+ # Step 1: Check cursor-agent (check actual locations, not just PATH)
9
+ CURSOR_AGENT_PATH=""
10
+ if command -v cursor-agent &> /dev/null; then
11
+ CURSOR_AGENT_PATH=$(command -v cursor-agent)
12
+ elif [ -x "$HOME/.local/bin/cursor-agent" ]; then
13
+ CURSOR_AGENT_PATH="$HOME/.local/bin/cursor-agent"
14
+ elif [ -x "$HOME/.cursor/bin/cursor-agent" ]; then
15
+ CURSOR_AGENT_PATH="$HOME/.cursor/bin/cursor-agent"
16
+ fi
17
+
18
+ if [ -z "$CURSOR_AGENT_PATH" ]; then
10
19
  echo "⚠️ cursor-agent not found. Installing..."
11
20
  curl https://cursor.com/install -fsS | bash
12
- export PATH="$HOME/.cursor/bin:$HOME/.local/bin:$PATH"
21
+ # Check again after install
22
+ if [ -x "$HOME/.local/bin/cursor-agent" ]; then
23
+ CURSOR_AGENT_PATH="$HOME/.local/bin/cursor-agent"
24
+ elif [ -x "$HOME/.cursor/bin/cursor-agent" ]; then
25
+ CURSOR_AGENT_PATH="$HOME/.cursor/bin/cursor-agent"
26
+ fi
13
27
  fi
14
28
 
29
+ # Always ensure these directories are in PATH for this script
30
+ export PATH="$HOME/.cursor/bin:$HOME/.local/bin:$PATH"
31
+
15
32
  # Step 2: Find Node.js absolute paths (Cursor GUI doesn't have shell PATH)
16
33
  NODE_PATH=$(which node 2>/dev/null || echo "")
17
34
  NPX_PATH=$(which npx 2>/dev/null || echo "")
@@ -26,6 +26,8 @@ export class CursorAgentStrategy extends AgentStrategy {
26
26
  'agent',
27
27
  '/usr/local/bin/agent',
28
28
  '/usr/local/bin/cursor-agent',
29
+ join(homedir(), '.local', 'bin', 'cursor-agent'),
30
+ join(homedir(), '.cursor', 'bin', 'cursor-agent'),
29
31
  '/Applications/Cursor.app/Contents/Resources/app/bin/cursor'
30
32
  ];
31
33
 
@@ -84,6 +86,8 @@ export class CursorAgentStrategy extends AgentStrategy {
84
86
  'agent',
85
87
  '/usr/local/bin/agent',
86
88
  '/usr/local/bin/cursor-agent',
89
+ join(homedir(), '.local', 'bin', 'cursor-agent'),
90
+ join(homedir(), '.cursor', 'bin', 'cursor-agent'),
87
91
  '/Applications/Cursor.app/Contents/Resources/app/bin/cursor'
88
92
  ];
89
93
 
@@ -113,11 +117,14 @@ export class CursorAgentStrategy extends AgentStrategy {
113
117
 
114
118
  if (!cursorBin) {
115
119
  throw new Error(
116
- 'Cursor Agent CLI not found or not working.\n\n' +
117
- 'Install it with:\n' +
118
- ' npm install -g @cursor/agent\n\n' +
119
- 'Or set CURSOR_API_KEY and ensure "agent" is in your PATH.\n' +
120
- 'Test with: agent --version'
120
+ `Cursor Agent CLI not found or not working.\n\n` +
121
+ `Checked paths:\n` +
122
+ `${possibleBins.map(p => ` - ${p}`).join('\n')}\n\n` +
123
+ `Install cursor-agent:\n` +
124
+ ` curl https://cursor.com/install -fsS | bash\n\n` +
125
+ `Then add to PATH:\n` +
126
+ ` echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc\n\n` +
127
+ `Test with: agent --version`
121
128
  );
122
129
  }
123
130
 
@@ -322,6 +329,7 @@ export class CursorAgentStrategy extends AgentStrategy {
322
329
  let lastOutputTime = Date.now();
323
330
  let lineCount = 0;
324
331
  let killed = false;
332
+ let processStarted = false;
325
333
 
326
334
  const proc = spawn(bin, args, {
327
335
  cwd,
@@ -331,6 +339,24 @@ export class CursorAgentStrategy extends AgentStrategy {
331
339
 
332
340
  logger.debug(`[Agent] PID: ${proc.pid}`);
333
341
 
342
+ const startupTimer = setTimeout(() => {
343
+ if (!processStarted && lineCount === 0) {
344
+ killed = true;
345
+ logger.error(`❌ [Agent] Process failed to start within 5 seconds. Binary may not be in PATH.`);
346
+ logger.error(` Binary: ${bin}`);
347
+ logger.error(` PATH: ${process.env.PATH}`);
348
+ logger.error(` Try: export PATH="$HOME/.local/bin:$PATH"`);
349
+ proc.kill('SIGTERM');
350
+ setTimeout(() => { if (!proc.killed) proc.kill('SIGKILL'); }, 2000);
351
+ reject(new Error(
352
+ `Cursor Agent failed to start. Binary '${bin}' not found or not executable.\n\n` +
353
+ `Install cursor-agent and add ~/.local/bin to your PATH:\n` +
354
+ ` curl https://cursor.com/install -fsS | bash\n` +
355
+ ` echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc`
356
+ ));
357
+ }
358
+ }, 5000);
359
+
334
360
  if (stdinPrompt) {
335
361
  proc.stdin.write(stdinPrompt);
336
362
  proc.stdin.end();
@@ -434,6 +460,11 @@ export class CursorAgentStrategy extends AgentStrategy {
434
460
  stdout += chunk;
435
461
  lastOutputTime = Date.now();
436
462
 
463
+ if (!processStarted) {
464
+ processStarted = true;
465
+ clearTimeout(startupTimer);
466
+ }
467
+
437
468
  const displayText = streamParser.processChunk(chunk);
438
469
  if (displayText) {
439
470
  process.stdout.write(displayText);
@@ -448,6 +479,11 @@ export class CursorAgentStrategy extends AgentStrategy {
448
479
  stderr += chunk;
449
480
  lastOutputTime = Date.now();
450
481
 
482
+ if (!processStarted) {
483
+ processStarted = true;
484
+ clearTimeout(startupTimer);
485
+ }
486
+
451
487
  const lines = chunk.split('\n').filter(l => l.trim());
452
488
  for (const line of lines) {
453
489
  logger.warn(`⚠️ [Agent stderr] ${line}`);
@@ -456,6 +492,7 @@ export class CursorAgentStrategy extends AgentStrategy {
456
492
 
457
493
  proc.on('close', (code, signal) => {
458
494
  clearTimeout(timer);
495
+ clearTimeout(startupTimer);
459
496
  clearInterval(heartbeat);
460
497
  streamParser.flush();
461
498
  const elapsed = Math.round((Date.now() - startTime) / 1000);
@@ -489,8 +526,14 @@ export class CursorAgentStrategy extends AgentStrategy {
489
526
 
490
527
  proc.on('error', (err) => {
491
528
  clearTimeout(timer);
529
+ clearTimeout(startupTimer);
492
530
  clearInterval(heartbeat);
493
- reject(new Error(`Cursor Agent spawn error: ${err.message}`));
531
+ reject(new Error(
532
+ `Cursor Agent spawn error: ${err.message}\n` +
533
+ `Binary: ${bin}\n` +
534
+ `This usually means the binary is not in PATH. Try:\n` +
535
+ ` echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc`
536
+ ));
494
537
  });
495
538
  });
496
539
  }
@@ -47,13 +47,12 @@ export class BrowserTestAutomationAgent extends WorkflowAgent {
47
47
  BrowserTestResultHandler.saveTitle(result, cwd);
48
48
  await BrowserTestResultHandler.saveExecutionData(result);
49
49
 
50
- if (process.env.ZIBBY_MEMORY) {
51
- try {
52
- const { memoryEndRun, memorySyncPush } = await import('@zibby/memory');
53
- const sessionId = result.state.sessionPath?.split('/').pop();
54
- memoryEndRun(cwd, { sessionId, passed: result.success !== false });
55
- memorySyncPush(cwd);
56
- } catch { /* @zibby/memory not available */ }
57
- }
50
+ // Memory end-run hook (if @zibby/memory is installed)
51
+ try {
52
+ const { memoryEndRun, memorySyncPush } = await import('@zibby/memory');
53
+ const sessionId = result.state.sessionPath?.split('/').pop();
54
+ memoryEndRun(cwd, { sessionId, passed: result.success !== false });
55
+ memorySyncPush(cwd);
56
+ } catch { /* @zibby/memory not available */ }
58
57
  }
59
58
  }