subagent-cli 0.2.8 → 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 +14 -6
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const { execFileSync } = require('child_process');
|
|
2
|
+
const { spawn, execFileSync } = require('child_process');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
|
|
@@ -21,8 +21,8 @@ let bunPath;
|
|
|
21
21
|
try {
|
|
22
22
|
bunPath = execFileSync('which', ['bun'], { encoding: 'utf-8' }).trim();
|
|
23
23
|
} catch {
|
|
24
|
-
|
|
25
|
-
for (const p of [
|
|
24
|
+
const home = process.env.HOME || '';
|
|
25
|
+
for (const p of [home + '/.bun/bin/bun', '/usr/local/bin/bun']) {
|
|
26
26
|
if (fs.existsSync(p)) { bunPath = p; break; }
|
|
27
27
|
}
|
|
28
28
|
if (!bunPath) {
|
|
@@ -31,10 +31,18 @@ try {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
//
|
|
35
|
-
const
|
|
36
|
-
require('child_process').execFileSync(bunPath, args.slice(1), {
|
|
34
|
+
// Spawn bun with full TTY pass-through
|
|
35
|
+
const child = spawn(bunPath, ['run', '--preload', preload, entry, ...process.argv.slice(2)], {
|
|
37
36
|
stdio: 'inherit',
|
|
38
37
|
cwd: process.cwd(),
|
|
39
38
|
env: process.env,
|
|
40
39
|
});
|
|
40
|
+
|
|
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
|
+
});
|