cli-setu 0.3.8 → 0.3.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/package.json +4 -2
- package/scripts/postinstall.js +16 -0
- package/src/ptyHelperPerms.js +27 -1
- package/src/supervisor.js +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cli-setu",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "Bridge your terminal to your phone — run and approve Claude Code, Codex CLI and other AI coding agents from anywhere.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"bin": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"main": "src/config.js",
|
|
10
10
|
"scripts": {
|
|
11
|
+
"postinstall": "node scripts/postinstall.js",
|
|
11
12
|
"test": "node test/run-all.js"
|
|
12
13
|
},
|
|
13
14
|
"engines": {
|
|
@@ -32,7 +33,8 @@
|
|
|
32
33
|
},
|
|
33
34
|
"files": [
|
|
34
35
|
"bin",
|
|
35
|
-
"src"
|
|
36
|
+
"src",
|
|
37
|
+
"scripts"
|
|
36
38
|
],
|
|
37
39
|
"dependencies": {
|
|
38
40
|
"@xterm/headless": "^6.0.0",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Runs after `npm install -g cli-setu`. node-pty ships its macOS helper program ("spawn-helper") without permission
|
|
2
|
+
// to run, which made every macOS session fail with "posix_spawnp failed". Doing the fix HERE, at install time, also
|
|
3
|
+
// covers `sudo npm install -g` (the script then runs as root, so it may change root-owned files; the CLI itself
|
|
4
|
+
// runs as the normal user and could not). It never fails the install: a problem here only means the CLI tries again
|
|
5
|
+
// at start-up and, if it still cannot, prints the exact fix command (see src/ptyHelperPerms.js).
|
|
6
|
+
// CLISETU_PTY_DIR lets the tests point it at a fake node-pty folder.
|
|
7
|
+
'use strict';
|
|
8
|
+
try {
|
|
9
|
+
const { ensureSpawnHelperExecutable } = require('../src/ptyHelperPerms');
|
|
10
|
+
const ptyDir = process.env.CLISETU_PTY_DIR || undefined;
|
|
11
|
+
const changed = ensureSpawnHelperExecutable(ptyDir ? { ptyDir } : {});
|
|
12
|
+
if (changed.length) console.log('[cli-setu] Made the terminal helper executable.');
|
|
13
|
+
} catch {
|
|
14
|
+
/* never fail the install */
|
|
15
|
+
}
|
|
16
|
+
process.exit(0);
|
package/src/ptyHelperPerms.js
CHANGED
|
@@ -37,4 +37,30 @@ function ensureSpawnHelperExecutable(opts = {}) {
|
|
|
37
37
|
return changed;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
// When the terminal could not start ("posix_spawnp failed"), find out whether the cause is this helper: present but
|
|
41
|
+
// not executable. Returns a plain-language explanation with the exact command to run, or null when the helper is
|
|
42
|
+
// fine or not found (so the caller prints nothing misleading). Found on a real Mac (2026-11-16): the package was
|
|
43
|
+
// installed with sudo, the helper was owned by root, and the user saw only "posix_spawnp failed".
|
|
44
|
+
function describeSpawnFailure(opts = {}) {
|
|
45
|
+
const platform = opts.platform || process.platform;
|
|
46
|
+
if (platform === 'win32') return null;
|
|
47
|
+
let ptyDir = opts.ptyDir;
|
|
48
|
+
if (!ptyDir) {
|
|
49
|
+
try { ptyDir = path.dirname(require.resolve('node-pty/package.json')); } catch { return null; }
|
|
50
|
+
}
|
|
51
|
+
for (const file of helperCandidates(ptyDir, platform, opts.arch || process.arch)) {
|
|
52
|
+
let mode;
|
|
53
|
+
try { mode = fs.statSync(file).mode; } catch { continue; }
|
|
54
|
+
if ((mode & 0o111) === 0o111) continue;
|
|
55
|
+
return [
|
|
56
|
+
`The terminal helper that CLI Setu needs is not allowed to run: ${file}`,
|
|
57
|
+
'This usually happens when the package was installed with sudo, or by an installer that did not keep the permission.',
|
|
58
|
+
'Fix it with this command, then start the session again:',
|
|
59
|
+
` sudo chmod +x "${file}"`,
|
|
60
|
+
'To avoid it next time, install without sudo (use Node from Homebrew or nvm, or set a user npm folder) and run `npm install -g cli-setu@latest` again.',
|
|
61
|
+
].join('\n');
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = { ensureSpawnHelperExecutable, helperCandidates, describeSpawnFailure };
|
package/src/supervisor.js
CHANGED
|
@@ -1945,7 +1945,14 @@ async function main() {
|
|
|
1945
1945
|
// the user only that something failed, never why. Re-throwing with
|
|
1946
1946
|
// the actual command and cwd attached turns that into an actionable
|
|
1947
1947
|
// message instead of a dead end.
|
|
1948
|
-
|
|
1948
|
+
// 2026-11-16: on a real Mac this was only ever "posix_spawnp failed". When the cause is node-pty's helper not being
|
|
1949
|
+
// allowed to run (a sudo install leaves it owned by root, so the fix at start-up cannot change it), say so and
|
|
1950
|
+
// print the exact command. See ptyHelperPerms.describeSpawnFailure.
|
|
1951
|
+
let helperHint = null;
|
|
1952
|
+
if (/posix_spawnp/i.test(err.message || '')) {
|
|
1953
|
+
try { helperHint = require('./ptyHelperPerms').describeSpawnFailure(); } catch { helperHint = null; }
|
|
1954
|
+
}
|
|
1955
|
+
throw new Error(`Could not start "${adapter.spawn.command}" in ${WORKING_DIR}: ${err.message}${helperHint ? `\n${helperHint}` : ''}`);
|
|
1949
1956
|
}
|
|
1950
1957
|
|
|
1951
1958
|
// Attach the laptop keyboard IMMEDIATELY, before any other start-up work, so
|