@zibby/core 0.1.13 → 0.1.15

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.13",
3
+ "version": "0.1.15",
4
4
  "description": "Core test automation engine with multi-agent and multi-MCP support",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -23,12 +23,15 @@ export class CursorAgentStrategy extends AgentStrategy {
23
23
 
24
24
  canHandle(_context) {
25
25
  const paths = [
26
- 'agent',
27
- '/usr/local/bin/agent',
28
- '/usr/local/bin/cursor-agent',
26
+ // Try absolute paths first (most reliable)
29
27
  join(homedir(), '.local', 'bin', 'cursor-agent'),
30
28
  join(homedir(), '.cursor', 'bin', 'cursor-agent'),
31
- '/Applications/Cursor.app/Contents/Resources/app/bin/cursor'
29
+ '/usr/local/bin/cursor-agent',
30
+ '/usr/local/bin/agent',
31
+ '/Applications/Cursor.app/Contents/Resources/app/bin/cursor',
32
+ // Try PATH last (may have symlink issues)
33
+ 'agent',
34
+ 'cursor-agent'
32
35
  ];
33
36
 
34
37
  for (const path of paths) {
@@ -83,12 +86,15 @@ export class CursorAgentStrategy extends AgentStrategy {
83
86
  this._setupMcpConfig(sessionPath, workspace, config);
84
87
 
85
88
  const possibleBins = [
86
- 'agent',
87
- '/usr/local/bin/agent',
88
- '/usr/local/bin/cursor-agent',
89
+ // Try absolute paths first (most reliable)
89
90
  join(homedir(), '.local', 'bin', 'cursor-agent'),
90
91
  join(homedir(), '.cursor', 'bin', 'cursor-agent'),
91
- '/Applications/Cursor.app/Contents/Resources/app/bin/cursor'
92
+ '/usr/local/bin/cursor-agent',
93
+ '/usr/local/bin/agent',
94
+ '/Applications/Cursor.app/Contents/Resources/app/bin/cursor',
95
+ // Try PATH last (may have symlink issues)
96
+ 'agent',
97
+ 'cursor-agent'
92
98
  ];
93
99
 
94
100
  let cursorBin = null;
@@ -145,28 +151,19 @@ export class CursorAgentStrategy extends AgentStrategy {
145
151
  writeFileSync(promptFile, prompt, 'utf-8');
146
152
  logger.debug(`📝 [Agent] Prompt written to ${promptFile} (${prompt.length} chars)`);
147
153
 
148
- let args;
149
- if (cursorBin === 'agent') {
150
- args = [
151
- 'chat',
152
- '--print',
153
- '--force',
154
- '--approve-mcps',
155
- '--output-format', 'stream-json',
156
- '--stream-partial-output',
157
- '--model', model || 'auto',
158
- ];
159
- if (process.env.CURSOR_API_KEY) {
160
- args.push('--api-key', process.env.CURSOR_API_KEY);
161
- }
162
- args.push(`@${promptFile}`);
163
- } else {
164
- args = ['agent', '--print', '--force', '--trust', '--approve-mcps'];
165
- if (process.env.CURSOR_API_KEY) {
166
- args.push('--api-key', process.env.CURSOR_API_KEY);
167
- }
168
- args.push('--model', model || 'auto', `@${promptFile}`);
154
+ // All cursor-agent binaries use the same command structure (no subcommand needed)
155
+ const args = [
156
+ '--print',
157
+ '--force',
158
+ '--approve-mcps',
159
+ '--output-format', 'stream-json',
160
+ '--stream-partial-output',
161
+ '--model', model || 'auto',
162
+ ];
163
+ if (process.env.CURSOR_API_KEY) {
164
+ args.push('--api-key', process.env.CURSOR_API_KEY);
169
165
  }
166
+ args.push(`@${promptFile}`);
170
167
 
171
168
  const fullCmd = [cursorBin, ...args].join(' ');
172
169
  logger.debug(`[Agent] Executing: ${fullCmd.slice(0, 200)}`);
@@ -342,17 +339,45 @@ export class CursorAgentStrategy extends AgentStrategy {
342
339
  const startupTimer = setTimeout(() => {
343
340
  if (!processStarted && lineCount === 0) {
344
341
  killed = true;
345
- logger.error(`❌ [Agent] Process failed to start within 5 seconds. Binary may not be in PATH.`);
342
+ const binaryPath = bin.replace(/^"(.*)"$/, '$1');
343
+ const binaryExists = existsSync(binaryPath);
344
+
345
+ logger.error(`❌ [Agent] Process failed to start within 5 seconds.`);
346
346
  logger.error(` Binary: ${bin}`);
347
- logger.error(` PATH: ${process.env.PATH}`);
348
- logger.error(` Try: export PATH="$HOME/.local/bin:$PATH"`);
347
+ logger.error(` File exists: ${binaryExists ? 'Yes (but not working - may be corrupted)' : 'No'}`);
348
+ logger.error(` PATH includes ~/.local/bin: ${process.env.PATH.includes('.local/bin') ? 'Yes' : 'No'}`);
349
+
350
+ if (binaryExists) {
351
+ logger.error(`\n ⚠️ Binary exists but won't start. Try reinstalling:`);
352
+ logger.error(` rm -f "${binaryPath}"`);
353
+ logger.error(` curl https://cursor.com/install -fsS | bash`);
354
+ logger.error(` echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc`);
355
+ } else {
356
+ logger.error(`\n Install cursor-agent:`);
357
+ logger.error(` curl https://cursor.com/install -fsS | bash`);
358
+ logger.error(` echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc`);
359
+ }
360
+
349
361
  proc.kill('SIGTERM');
350
362
  setTimeout(() => { if (!proc.killed) proc.kill('SIGKILL'); }, 2000);
351
363
  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`
364
+ `Cursor Agent failed to start. Binary '${binaryPath}' ${binaryExists ? 'exists but is not working (corrupted?)' : 'not found'}.\n\n` +
365
+ `${binaryExists
366
+ ? '⚠️ The binary file exists but failed to start. It may be corrupted or incomplete.\n\n' +
367
+ 'Try reinstalling cursor-agent:\n' +
368
+ ` rm -f "${binaryPath}"\n` +
369
+ ' curl https://cursor.com/install -fsS | bash\n\n' +
370
+ 'Ensure ~/.local/bin is in your PATH:\n' +
371
+ ' echo \'export PATH="$HOME/.local/bin:$PATH"\' >> ~/.zshrc\n' +
372
+ ' source ~/.zshrc\n\n' +
373
+ 'Test with: agent --version'
374
+ : 'Install cursor-agent:\n' +
375
+ ' curl https://cursor.com/install -fsS | bash\n\n' +
376
+ 'Add ~/.local/bin to your PATH:\n' +
377
+ ' echo \'export PATH="$HOME/.local/bin:$PATH"\' >> ~/.zshrc\n' +
378
+ ' source ~/.zshrc\n\n' +
379
+ 'Test with: agent --version'
380
+ }`
356
381
  ));
357
382
  }
358
383
  }, 5000);