@keeroklab/cli 0.3.0 → 0.5.0
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 +2 -1
- package/src/pty-capture.js +17 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keeroklab/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "CLI wrapper for Keerok Lab — live Claude Code supervision",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"@homebridge/node-pty-prebuilt-multiarch": "^0.13.1",
|
|
34
35
|
"chalk": "^5.3.0",
|
|
35
36
|
"commander": "^12.0.0",
|
|
36
37
|
"ws": "^8.16.0"
|
package/src/pty-capture.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* pty-capture.js — Spawns a process
|
|
3
|
-
* Uses
|
|
4
|
-
* and forward it to both stdout and the WebSocket handler.
|
|
2
|
+
* pty-capture.js — Spawns a process in a real pseudo-terminal.
|
|
3
|
+
* Uses node-pty so interactive TUI apps (like claude) work properly.
|
|
5
4
|
*/
|
|
6
5
|
|
|
7
|
-
import
|
|
6
|
+
import pty from '@homebridge/node-pty-prebuilt-multiarch';
|
|
8
7
|
import os from 'os';
|
|
9
8
|
|
|
10
9
|
export function spawnPty(command, handlers) {
|
|
@@ -12,32 +11,25 @@ export function spawnPty(command, handlers) {
|
|
|
12
11
|
const cols = process.stdout.columns || 80;
|
|
13
12
|
const rows = process.stdout.rows || 24;
|
|
14
13
|
|
|
15
|
-
const child = spawn(shell, ['-c', command], {
|
|
16
|
-
|
|
14
|
+
const child = pty.spawn(shell, ['-c', command], {
|
|
15
|
+
name: 'xterm-256color',
|
|
16
|
+
cols,
|
|
17
|
+
rows,
|
|
17
18
|
cwd: process.cwd(),
|
|
18
19
|
env: {
|
|
19
20
|
...process.env,
|
|
20
|
-
TERM: 'xterm-256color',
|
|
21
21
|
FORCE_COLOR: '1',
|
|
22
|
-
COLUMNS: String(cols),
|
|
23
|
-
LINES: String(rows),
|
|
24
22
|
},
|
|
25
23
|
});
|
|
26
24
|
|
|
27
|
-
// Forward
|
|
28
|
-
child.
|
|
25
|
+
// Forward PTY output to both local terminal and handler
|
|
26
|
+
child.onData((data) => {
|
|
29
27
|
process.stdout.write(data);
|
|
30
|
-
handlers.onData?.(data
|
|
28
|
+
handlers.onData?.(data);
|
|
31
29
|
});
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
process.stderr.write(data);
|
|
36
|
-
handlers.onData?.(data.toString());
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
child.on('exit', (code) => {
|
|
40
|
-
handlers.onExit?.(code ?? 0);
|
|
31
|
+
child.onExit(({ exitCode }) => {
|
|
32
|
+
handlers.onExit?.(exitCode ?? 0);
|
|
41
33
|
});
|
|
42
34
|
|
|
43
35
|
// Forward stdin to child
|
|
@@ -46,15 +38,14 @@ export function spawnPty(command, handlers) {
|
|
|
46
38
|
}
|
|
47
39
|
process.stdin.resume();
|
|
48
40
|
process.stdin.on('data', (data) => {
|
|
49
|
-
|
|
50
|
-
child.stdin.write(data);
|
|
51
|
-
}
|
|
41
|
+
child.write(data.toString());
|
|
52
42
|
});
|
|
53
43
|
|
|
54
44
|
// Handle terminal resize
|
|
55
45
|
process.stdout.on('resize', () => {
|
|
56
46
|
const newCols = process.stdout.columns;
|
|
57
47
|
const newRows = process.stdout.rows;
|
|
48
|
+
child.resize(newCols, newRows);
|
|
58
49
|
handlers.onResize?.(newCols, newRows);
|
|
59
50
|
});
|
|
60
51
|
|
|
@@ -66,12 +57,10 @@ export function spawnPty(command, handlers) {
|
|
|
66
57
|
child.kill();
|
|
67
58
|
},
|
|
68
59
|
write(data) {
|
|
69
|
-
|
|
70
|
-
child.stdin.write(data);
|
|
71
|
-
}
|
|
60
|
+
child.write(data);
|
|
72
61
|
},
|
|
73
|
-
resize() {
|
|
74
|
-
|
|
62
|
+
resize(cols, rows) {
|
|
63
|
+
child.resize(cols, rows);
|
|
75
64
|
},
|
|
76
65
|
};
|
|
77
66
|
}
|