orchestrating 0.1.26 → 0.1.28
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/orch +42 -4
- package/package.json +1 -1
package/bin/orch
CHANGED
|
@@ -179,12 +179,20 @@ if (firstArg === "logout") {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
if (firstArg === "daemon") {
|
|
182
|
-
|
|
182
|
+
// Parse daemon flags: orch daemon [--projects <path>]
|
|
183
|
+
const daemonArgs = process.argv.slice(3);
|
|
184
|
+
let projectsDir = null;
|
|
185
|
+
for (let di = 0; di < daemonArgs.length; di++) {
|
|
186
|
+
if ((daemonArgs[di] === "--projects" || daemonArgs[di] === "-d") && daemonArgs[di + 1]) {
|
|
187
|
+
projectsDir = daemonArgs[++di];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
await handleDaemon(projectsDir);
|
|
183
191
|
// handleDaemon runs forever (or exits on fatal error)
|
|
184
192
|
}
|
|
185
193
|
|
|
186
194
|
// --- Daemon mode ---
|
|
187
|
-
async function handleDaemon() {
|
|
195
|
+
async function handleDaemon(projectsDir) {
|
|
188
196
|
const DIM = "\x1b[2m";
|
|
189
197
|
const GREEN = "\x1b[32m";
|
|
190
198
|
const RED = "\x1b[31m";
|
|
@@ -218,10 +226,29 @@ async function handleDaemon() {
|
|
|
218
226
|
let pongTimer = null;
|
|
219
227
|
let reconnectTimer = null;
|
|
220
228
|
|
|
229
|
+
// Scan project directories
|
|
230
|
+
const homeDir = os.homedir();
|
|
231
|
+
const scanRoot = projectsDir || path.join(homeDir, "projects");
|
|
232
|
+
let directories = [];
|
|
233
|
+
try {
|
|
234
|
+
const { readdirSync, statSync } = await import("fs");
|
|
235
|
+
const entries = readdirSync(scanRoot);
|
|
236
|
+
directories = entries
|
|
237
|
+
.filter((e) => !e.startsWith("."))
|
|
238
|
+
.map((e) => path.join(scanRoot, e))
|
|
239
|
+
.filter((p) => { try { return statSync(p).isDirectory(); } catch { return false; } })
|
|
240
|
+
.sort();
|
|
241
|
+
} catch {
|
|
242
|
+
// scanRoot doesn't exist — fall back to home dir
|
|
243
|
+
directories = [homeDir];
|
|
244
|
+
}
|
|
245
|
+
|
|
221
246
|
process.stderr.write(`${GREEN}${PREFIX} Listening for remote sessions as "${hostname}"${RESET}\n`);
|
|
247
|
+
process.stderr.write(`${DIM}${PREFIX} Projects: ${scanRoot} (${directories.length} dirs)${RESET}\n`);
|
|
222
248
|
process.stderr.write(`${DIM}${PREFIX} Tip: Use 'nohup orch daemon &' to run in background${RESET}\n`);
|
|
223
249
|
|
|
224
250
|
let reconnecting = false;
|
|
251
|
+
const recentRequests = new Set();
|
|
225
252
|
|
|
226
253
|
function scheduleReconnect(delaySec) {
|
|
227
254
|
if (reconnecting) return;
|
|
@@ -260,6 +287,7 @@ async function handleDaemon() {
|
|
|
260
287
|
token,
|
|
261
288
|
hostname,
|
|
262
289
|
cliVersion,
|
|
290
|
+
directories,
|
|
263
291
|
}));
|
|
264
292
|
process.stderr.write(`${GREEN}${PREFIX} Connected${RESET}\n`);
|
|
265
293
|
|
|
@@ -303,6 +331,11 @@ async function handleDaemon() {
|
|
|
303
331
|
|
|
304
332
|
if (msg.type === "start_session") {
|
|
305
333
|
const { requestId, command: cmd, args: cmdArgs, cwd, label: lbl, yolo } = msg;
|
|
334
|
+
// Dedup: ignore if we already handled this request
|
|
335
|
+
if (recentRequests.has(requestId)) return;
|
|
336
|
+
recentRequests.add(requestId);
|
|
337
|
+
setTimeout(() => recentRequests.delete(requestId), 30_000);
|
|
338
|
+
|
|
306
339
|
const cmdStr = [cmd, ...cmdArgs].join(" ");
|
|
307
340
|
process.stderr.write(`${GREEN}${PREFIX} Spawning: ${cmdStr}${RESET}\n`);
|
|
308
341
|
|
|
@@ -416,8 +449,12 @@ while (i < args.length) {
|
|
|
416
449
|
console.error(" orch logout — Clear stored credentials");
|
|
417
450
|
console.error(" orch daemon — Run background daemon for remote session launching");
|
|
418
451
|
console.error("");
|
|
419
|
-
console.error(" -l <label>
|
|
420
|
-
console.error(" -y, --yolo
|
|
452
|
+
console.error(" -l <label> Optional human-readable session label");
|
|
453
|
+
console.error(" -y, --yolo Skip all permission prompts (auto-approve everything)");
|
|
454
|
+
console.error("");
|
|
455
|
+
console.error("Daemon options:");
|
|
456
|
+
console.error(" --projects <path> Directory to scan for projects (default: ~/projects)");
|
|
457
|
+
console.error(" -d <path> Short alias for --projects");
|
|
421
458
|
console.error("");
|
|
422
459
|
console.error("Examples:");
|
|
423
460
|
console.error(' orch claude "refactor auth"');
|
|
@@ -425,6 +462,7 @@ while (i < args.length) {
|
|
|
425
462
|
console.error(' orch -l "deploy fix" codex');
|
|
426
463
|
console.error(" orch bash");
|
|
427
464
|
console.error(" orch daemon");
|
|
465
|
+
console.error(" orch daemon --projects ~/work");
|
|
428
466
|
console.error("");
|
|
429
467
|
console.error("Environment:");
|
|
430
468
|
console.error(" ORC_URL WebSocket server URL (default: wss://api.orchestrat.ing/ws)");
|