ai-exodus 2.0.5 → 2.0.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/claude.js +42 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-exodus",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "Migrate your AI relationship from any platform to Claude. Your AI belongs to you.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/claude.js CHANGED
@@ -16,26 +16,49 @@ import { randomBytes } from 'node:crypto';
16
16
  * Find the claude CLI path
17
17
  */
18
18
  async function findClaude() {
19
+ const { execSync } = await import('node:child_process');
20
+
21
+ // First: just try running "claude" — let the shell resolve it
22
+ // This works regardless of how/where it was installed
23
+ try {
24
+ execSync('claude --version', { stdio: 'pipe', shell: true, timeout: 10000 });
25
+ return 'claude';
26
+ } catch {}
27
+
28
+ // Windows: try common install locations
19
29
  const home = process.env.USERPROFILE || process.env.HOME || '';
20
- const knownPaths = [
21
- join(home, 'AppData', 'Local', 'Microsoft', 'WinGet', 'Links', 'claude.exe'),
22
- join(home, '.npm-global', 'bin', 'claude'),
23
- join(home, '.npm-global', 'bin', 'claude.cmd'),
24
- '/usr/local/bin/claude',
25
- ];
26
-
27
- for (const p of knownPaths) {
28
- if (existsSync(p)) return p;
30
+ if (process.platform === 'win32') {
31
+ const winPaths = [
32
+ join(home, 'AppData', 'Local', 'Microsoft', 'WinGet', 'Links', 'claude.exe'),
33
+ join(home, '.npm-global', 'bin', 'claude.cmd'),
34
+ join(home, '.npm-global', 'claude.cmd'),
35
+ join(home, 'AppData', 'Roaming', 'npm', 'claude.cmd'),
36
+ ];
37
+ for (const p of winPaths) {
38
+ if (existsSync(p)) return p;
39
+ }
40
+
41
+ // Try where command (finds .cmd, .exe, .ps1)
42
+ try {
43
+ const result = execSync('where claude', { stdio: 'pipe', shell: true, timeout: 5000 });
44
+ const found = result.toString().trim().split('\n')[0].trim();
45
+ if (found) return found;
46
+ } catch {}
47
+ } else {
48
+ // Unix
49
+ const unixPaths = ['/usr/local/bin/claude', join(home, '.npm-global', 'bin', 'claude')];
50
+ for (const p of unixPaths) {
51
+ if (existsSync(p)) return p;
52
+ }
53
+ try {
54
+ const result = execSync('which claude', { stdio: 'pipe', timeout: 5000 });
55
+ const found = result.toString().trim();
56
+ if (found) return found;
57
+ } catch {}
29
58
  }
30
59
 
31
- // Fallback
32
- const { exec } = await import('node:child_process');
33
- return new Promise((resolve) => {
34
- const cmd = process.platform === 'win32' ? 'where claude.exe' : 'which claude';
35
- exec(cmd, (err, stdout) => {
36
- resolve(!err && stdout.trim() ? stdout.trim().split('\n')[0].trim() : 'claude');
37
- });
38
- });
60
+ // Last resort — return 'claude' and let it fail with a clear error at call time
61
+ return 'claude';
39
62
  }
40
63
 
41
64
  let claudePath = null;
@@ -79,6 +102,7 @@ export async function callClaude({ system, prompt, model }) {
79
102
  const proc = spawn(claude, args, {
80
103
  stdio: ['pipe', 'pipe', 'pipe'],
81
104
  cwd: tmpdir(), // avoid picking up CLAUDE.md from home/project dirs
105
+ shell: process.platform === 'win32', // Windows needs shell to resolve .cmd files
82
106
  });
83
107
 
84
108
  let stdout = '';
@@ -130,7 +154,7 @@ export async function checkCLI() {
130
154
  try {
131
155
  const claude = await getClaude();
132
156
  return await new Promise((resolve) => {
133
- const proc = spawn(claude, ['--version'], { stdio: ['pipe', 'pipe', 'pipe'] });
157
+ const proc = spawn(claude, ['--version'], { stdio: ['pipe', 'pipe', 'pipe'], shell: process.platform === 'win32' });
134
158
  let stdout = '';
135
159
  proc.stdout.on('data', (d) => { stdout += d.toString(); });
136
160
  proc.on('error', () => resolve({ ok: false, error: 'Claude Code CLI not found' }));