claude-code-remote-pilot 0.2.4 → 0.2.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.
- package/bin/claude-pilot.js +22 -3
- package/lib/SessionManager.js +6 -0
- package/lib/Watcher.js +5 -5
- package/package.json +1 -1
package/bin/claude-pilot.js
CHANGED
|
@@ -146,6 +146,24 @@ function startWatch(manager, rl) {
|
|
|
146
146
|
process.stdin.on('keypress', onKeypress);
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
// ─── exit handling ───────────────────────────────────────────────────────────
|
|
150
|
+
|
|
151
|
+
async function handleExit(manager, rl) {
|
|
152
|
+
const sessions = manager.list();
|
|
153
|
+
if (!sessions.length) {
|
|
154
|
+
console.log('');
|
|
155
|
+
process.exit(0);
|
|
156
|
+
}
|
|
157
|
+
const answer = await questionRaw(rl, `\n Kill all ${sessions.length} session(s) before exiting? (y/n) `);
|
|
158
|
+
if (answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
|
|
159
|
+
manager.killAll();
|
|
160
|
+
console.log(' All sessions killed.\n');
|
|
161
|
+
} else {
|
|
162
|
+
console.log(' Sessions keep running. Use tmux to attach.\n');
|
|
163
|
+
}
|
|
164
|
+
process.exit(0);
|
|
165
|
+
}
|
|
166
|
+
|
|
149
167
|
// ─── REPL ─────────────────────────────────────────────────────────────────────
|
|
150
168
|
|
|
151
169
|
const HELP = `
|
|
@@ -155,7 +173,7 @@ const HELP = `
|
|
|
155
173
|
attach <name> Open tmux session in this terminal
|
|
156
174
|
kill <name> Stop a session
|
|
157
175
|
help Show this help
|
|
158
|
-
exit Quit pilot (
|
|
176
|
+
exit Quit pilot (asks whether to kill sessions)
|
|
159
177
|
`;
|
|
160
178
|
|
|
161
179
|
function startREPL(manager) {
|
|
@@ -218,8 +236,8 @@ function startREPL(manager) {
|
|
|
218
236
|
}
|
|
219
237
|
case 'exit':
|
|
220
238
|
case 'quit': {
|
|
221
|
-
|
|
222
|
-
|
|
239
|
+
await handleExit(manager, rl);
|
|
240
|
+
return;
|
|
223
241
|
}
|
|
224
242
|
default:
|
|
225
243
|
console.log(` Unknown command: ${cmd}. Type help.`);
|
|
@@ -232,6 +250,7 @@ function startREPL(manager) {
|
|
|
232
250
|
});
|
|
233
251
|
|
|
234
252
|
rl.on('close', () => {
|
|
253
|
+
// stdin closed (Ctrl+D) — can't ask interactively, keep sessions running
|
|
235
254
|
console.log('\n Sessions keep running. Use tmux to attach.\n');
|
|
236
255
|
process.exit(0);
|
|
237
256
|
});
|
package/lib/SessionManager.js
CHANGED
|
@@ -51,6 +51,12 @@ class SessionManager {
|
|
|
51
51
|
this.sessions.delete(name);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
killAll() {
|
|
55
|
+
for (const name of [...this.sessions.keys()]) {
|
|
56
|
+
try { this.kill(name); } catch {}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
54
60
|
list() {
|
|
55
61
|
return [...this.sessions.values()].map(e => e.session);
|
|
56
62
|
}
|
package/lib/Watcher.js
CHANGED
|
@@ -4,10 +4,10 @@ const crypto = require('crypto');
|
|
|
4
4
|
const notifier = require('./notifier');
|
|
5
5
|
|
|
6
6
|
const LIMIT_RE = /hit your limit|usage limit|rate limit|limit reached|try again|resets/i;
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
// Claude Code shows ">"
|
|
10
|
-
const IDLE_RE = /^\s
|
|
7
|
+
// Matches Claude Code's permission/action prompt UI
|
|
8
|
+
const RESPONSE_RE = /do you want to proceed|esc to cancel|ctrl\+e to explain|❯\s*\d+\.\s*yes/i;
|
|
9
|
+
// Claude Code shows ">" alone on the last line when idle/waiting for next prompt
|
|
10
|
+
const IDLE_RE = /^\s*>\s*$/;
|
|
11
11
|
|
|
12
12
|
class Watcher {
|
|
13
13
|
constructor(session, opts = {}) {
|
|
@@ -75,7 +75,7 @@ class Watcher {
|
|
|
75
75
|
|
|
76
76
|
if (LIMIT_RE.test(text)) {
|
|
77
77
|
await this._handleLimit(text);
|
|
78
|
-
} else if (
|
|
78
|
+
} else if (RESPONSE_RE.test(text)) {
|
|
79
79
|
if (this.session.status !== 'needs-response') {
|
|
80
80
|
this.session.status = 'needs-response';
|
|
81
81
|
notifier.send(this.telegram.token, this.telegram.chatId,
|
package/package.json
CHANGED