@masslessai/push-todo 3.5.8 → 3.6.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.
Files changed (2) hide show
  1. package/lib/cli.js +34 -1
  2. 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, mkdirSync } 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,37 @@ 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
+ // Worktree was cleaned up after daemon finished, but the session file
327
+ // still exists at ~/.claude/projects/. Re-create the directory so Claude
328
+ // maps CWD to the correct session directory and finds the session.
329
+ try {
330
+ mkdirSync(candidate, { recursive: true });
331
+ resumeCwd = candidate;
332
+ console.log(`Re-created worktree directory for session lookup: ${candidate}`);
333
+ } catch {
334
+ console.log(dim(`Could not create worktree dir at ${candidate}, using current directory`));
335
+ }
336
+ }
337
+ } catch {
338
+ // Fall back to current directory
339
+ }
340
+
309
341
  // Launch claude --resume with the session ID
310
342
  console.log(`Resuming session for task #${displayNumber}...`);
311
343
  console.log(`Session ID: ${sessionId}`);
@@ -313,6 +345,7 @@ export async function run(argv) {
313
345
 
314
346
  // Use spawn with stdio: 'inherit' to give control to Claude
315
347
  const child = spawn('claude', ['--resume', sessionId], {
348
+ cwd: resumeCwd,
316
349
  stdio: 'inherit',
317
350
  shell: true
318
351
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@masslessai/push-todo",
3
- "version": "3.5.8",
3
+ "version": "3.6.0",
4
4
  "description": "Voice tasks from Push iOS app for Claude Code",
5
5
  "type": "module",
6
6
  "bin": {