@masslessai/push-todo 3.5.0 → 3.5.2
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 +20 -1
- package/lib/daemon-health.js +34 -2
- package/lib/index.js +19 -2
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
import { parseArgs } from 'util';
|
|
8
8
|
import { spawn } from 'child_process';
|
|
9
|
+
import { readFileSync } from 'fs';
|
|
10
|
+
import { join, dirname } from 'path';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
9
12
|
import * as fetch from './fetch.js';
|
|
10
13
|
import * as api from './api.js';
|
|
11
14
|
import { runConnect } from './connect.js';
|
|
@@ -15,7 +18,23 @@ import { ensureDaemonRunning, getDaemonStatus, startDaemon, stopDaemon } from '.
|
|
|
15
18
|
import { getScreenshotPath, screenshotExists, openScreenshot } from './utils/screenshots.js';
|
|
16
19
|
import { bold, red, cyan, dim, green } from './utils/colors.js';
|
|
17
20
|
|
|
18
|
-
const
|
|
21
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
22
|
+
const __dirname = dirname(__filename);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Read version from package.json (DRY - single source of truth)
|
|
26
|
+
*/
|
|
27
|
+
function getVersion() {
|
|
28
|
+
try {
|
|
29
|
+
const pkgPath = join(__dirname, '..', 'package.json');
|
|
30
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
31
|
+
return pkg.version || '3.0.0';
|
|
32
|
+
} catch {
|
|
33
|
+
return '3.0.0';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const VERSION = getVersion();
|
|
19
38
|
|
|
20
39
|
const HELP_TEXT = `
|
|
21
40
|
${bold('push-todo')} - Voice tasks from Push iOS app for Claude Code
|
package/lib/daemon-health.js
CHANGED
|
@@ -180,14 +180,46 @@ export function stopDaemon() {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
|
-
*
|
|
184
|
-
|
|
183
|
+
* Get the installed package version (npm package version).
|
|
184
|
+
*/
|
|
185
|
+
function getInstalledVersion() {
|
|
186
|
+
try {
|
|
187
|
+
const pkgPath = join(__dirname, '..', 'package.json');
|
|
188
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
189
|
+
return pkg.version || null;
|
|
190
|
+
} catch {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Ensure daemon is running with correct version - called on every /push-todo command.
|
|
197
|
+
* Auto-restarts daemon if version mismatch detected.
|
|
198
|
+
*
|
|
199
|
+
* This prevents stale daemons from running after npm package updates.
|
|
200
|
+
* See: /docs/20260204_daemon_heartbeat_status_indicator_implementation_plan.md
|
|
185
201
|
*/
|
|
186
202
|
export function ensureDaemonRunning() {
|
|
187
203
|
const status = getDaemonStatus();
|
|
204
|
+
const installedVersion = getInstalledVersion();
|
|
205
|
+
|
|
206
|
+
// Case 1: Daemon not running - start it
|
|
188
207
|
if (!status.running) {
|
|
189
208
|
startDaemon();
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Case 2: Daemon running but version mismatch - restart it
|
|
213
|
+
if (installedVersion && status.version && status.version !== installedVersion) {
|
|
214
|
+
// Version mismatch - restart daemon with new version
|
|
215
|
+
stopDaemon();
|
|
216
|
+
// Brief delay to ensure clean shutdown
|
|
217
|
+
const start = Date.now();
|
|
218
|
+
while (Date.now() - start < 500) {} // 500ms busy wait
|
|
219
|
+
startDaemon();
|
|
190
220
|
}
|
|
221
|
+
|
|
222
|
+
// Case 3: Daemon running with correct version - do nothing
|
|
191
223
|
}
|
|
192
224
|
|
|
193
225
|
export { PID_FILE, LOG_FILE, STATUS_FILE, PUSH_DIR };
|
package/lib/index.js
CHANGED
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
* @module @masslessai/push-todo
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { readFileSync } from 'fs';
|
|
10
|
+
import { join, dirname } from 'path';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
|
|
9
16
|
// CLI entry point
|
|
10
17
|
export { run } from './cli.js';
|
|
11
18
|
|
|
@@ -110,5 +117,15 @@ export {
|
|
|
110
117
|
colorsEnabled
|
|
111
118
|
} from './utils/colors.js';
|
|
112
119
|
|
|
113
|
-
// Version
|
|
114
|
-
|
|
120
|
+
// Version - read from package.json (DRY - single source of truth)
|
|
121
|
+
function getVersion() {
|
|
122
|
+
try {
|
|
123
|
+
const pkgPath = join(__dirname, '..', 'package.json');
|
|
124
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
125
|
+
return pkg.version || '3.0.0';
|
|
126
|
+
} catch {
|
|
127
|
+
return '3.0.0';
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export const VERSION = getVersion();
|