subagent-cli 0.2.7 → 0.2.9
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/dist/cli.cjs +22 -11
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { execSync, spawn } = require('child_process');
|
|
2
|
+
const { spawn, execFileSync } = require('child_process');
|
|
4
3
|
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
5
|
|
|
6
6
|
const libDir = path.resolve(__dirname, '..');
|
|
7
7
|
const entry = path.join(libDir, 'src', 'entrypoints', 'cli.tsx');
|
|
8
8
|
const preload = path.join(libDir, 'stubs', 'globals.ts');
|
|
9
9
|
|
|
10
|
-
// Ensure
|
|
11
|
-
const fs = require('fs');
|
|
10
|
+
// Ensure src symlink for path alias resolution
|
|
12
11
|
const symlinkPath = path.join(libDir, 'node_modules', 'src');
|
|
13
12
|
try {
|
|
14
13
|
if (!fs.existsSync(symlinkPath)) {
|
|
@@ -17,21 +16,33 @@ try {
|
|
|
17
16
|
}
|
|
18
17
|
} catch {}
|
|
19
18
|
|
|
20
|
-
// Find
|
|
19
|
+
// Find bun
|
|
21
20
|
let bunPath;
|
|
22
21
|
try {
|
|
23
|
-
bunPath =
|
|
22
|
+
bunPath = execFileSync('which', ['bun'], { encoding: 'utf-8' }).trim();
|
|
24
23
|
} catch {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const home = process.env.HOME || '';
|
|
25
|
+
for (const p of [home + '/.bun/bin/bun', '/usr/local/bin/bun']) {
|
|
26
|
+
if (fs.existsSync(p)) { bunPath = p; break; }
|
|
27
|
+
}
|
|
28
|
+
if (!bunPath) {
|
|
29
|
+
console.error('Error: Morph Code requires Bun. Install: curl -fsSL https://bun.sh/install | bash');
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
28
32
|
}
|
|
29
33
|
|
|
30
|
-
//
|
|
34
|
+
// Spawn bun with full TTY pass-through
|
|
31
35
|
const child = spawn(bunPath, ['run', '--preload', preload, entry, ...process.argv.slice(2)], {
|
|
32
36
|
stdio: 'inherit',
|
|
33
37
|
cwd: process.cwd(),
|
|
34
38
|
env: process.env,
|
|
35
39
|
});
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
// Forward signals
|
|
42
|
+
process.on('SIGINT', () => child.kill('SIGINT'));
|
|
43
|
+
process.on('SIGTERM', () => child.kill('SIGTERM'));
|
|
44
|
+
|
|
45
|
+
child.on('exit', (code, signal) => {
|
|
46
|
+
if (signal) process.kill(process.pid, signal);
|
|
47
|
+
else process.exit(code ?? 0);
|
|
48
|
+
});
|