@masslessai/push-todo 3.5.8 → 3.5.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/lib/cli.js +25 -1
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { parseArgs } from 'util';
|
|
8
8
|
import { spawn } from 'child_process';
|
|
9
|
-
import { readFileSync } from 'fs';
|
|
9
|
+
import { readFileSync, existsSync } from 'fs';
|
|
10
10
|
import { join, dirname } from 'path';
|
|
11
11
|
import { fileURLToPath } from 'url';
|
|
12
12
|
import * as fetch from './fetch.js';
|
|
@@ -17,6 +17,7 @@ import { showSettings, toggleSetting, setMaxBatchSize } from './config.js';
|
|
|
17
17
|
import { ensureDaemonRunning, getDaemonStatus, startDaemon, stopDaemon } from './daemon-health.js';
|
|
18
18
|
import { getScreenshotPath, screenshotExists, openScreenshot } from './utils/screenshots.js';
|
|
19
19
|
import { bold, red, cyan, dim, green } from './utils/colors.js';
|
|
20
|
+
import { getMachineId } from './machine-id.js';
|
|
20
21
|
|
|
21
22
|
const __filename = fileURLToPath(import.meta.url);
|
|
22
23
|
const __dirname = dirname(__filename);
|
|
@@ -306,6 +307,28 @@ export async function run(argv) {
|
|
|
306
307
|
process.exit(1);
|
|
307
308
|
}
|
|
308
309
|
|
|
310
|
+
// Find the worktree directory where the daemon ran this task.
|
|
311
|
+
// Sessions are directory-scoped in Claude Code, so we must launch
|
|
312
|
+
// from the same directory (worktree) where the session was created.
|
|
313
|
+
let resumeCwd = process.cwd();
|
|
314
|
+
try {
|
|
315
|
+
const machineId = getMachineId();
|
|
316
|
+
const parts = machineId.split('-');
|
|
317
|
+
const suffix = parts.length > 1 ? parts[parts.length - 1].slice(0, 8) : machineId.slice(0, 8);
|
|
318
|
+
const worktreeName = `push-${displayNumber}-${suffix}`;
|
|
319
|
+
|
|
320
|
+
// Try to find the worktree relative to CWD's parent (sibling directory)
|
|
321
|
+
const candidate = join(dirname(process.cwd()), worktreeName);
|
|
322
|
+
if (existsSync(candidate)) {
|
|
323
|
+
resumeCwd = candidate;
|
|
324
|
+
console.log(`Found daemon worktree: ${candidate}`);
|
|
325
|
+
} else {
|
|
326
|
+
console.log(dim(`Worktree not found at ${candidate}, using current directory`));
|
|
327
|
+
}
|
|
328
|
+
} catch {
|
|
329
|
+
// Fall back to current directory
|
|
330
|
+
}
|
|
331
|
+
|
|
309
332
|
// Launch claude --resume with the session ID
|
|
310
333
|
console.log(`Resuming session for task #${displayNumber}...`);
|
|
311
334
|
console.log(`Session ID: ${sessionId}`);
|
|
@@ -313,6 +336,7 @@ export async function run(argv) {
|
|
|
313
336
|
|
|
314
337
|
// Use spawn with stdio: 'inherit' to give control to Claude
|
|
315
338
|
const child = spawn('claude', ['--resume', sessionId], {
|
|
339
|
+
cwd: resumeCwd,
|
|
316
340
|
stdio: 'inherit',
|
|
317
341
|
shell: true
|
|
318
342
|
});
|