metame-cli 1.3.22 → 1.3.23
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/index.js +11 -31
- package/package.json +1 -1
- package/scripts/daemon.js +801 -159
- package/scripts/distill.js +60 -54
- package/scripts/feishu-adapter.js +41 -2
- package/scripts/skill-evolution.js +16 -16
- package/scripts/telegram-adapter.js +12 -4
package/index.js
CHANGED
|
@@ -29,7 +29,7 @@ if (!fs.existsSync(METAME_DIR)) {
|
|
|
29
29
|
|
|
30
30
|
// Auto-deploy bundled scripts to ~/.metame/
|
|
31
31
|
// IMPORTANT: daemon.yaml is USER CONFIG — never overwrite it. Only daemon-default.yaml (template) is synced.
|
|
32
|
-
const BUNDLED_SCRIPTS = ['signal-capture.js', 'distill.js', 'schema.js', 'pending-traits.js', 'migrate-v2.js', 'daemon.js', 'telegram-adapter.js', 'feishu-adapter.js', 'daemon-default.yaml', 'providers.js', 'session-analytics.js', 'resolve-yaml.js', 'utils.js'];
|
|
32
|
+
const BUNDLED_SCRIPTS = ['signal-capture.js', 'distill.js', 'schema.js', 'pending-traits.js', 'migrate-v2.js', 'daemon.js', 'telegram-adapter.js', 'feishu-adapter.js', 'daemon-default.yaml', 'providers.js', 'session-analytics.js', 'resolve-yaml.js', 'utils.js', 'skill-evolution.js'];
|
|
33
33
|
const scriptsDir = path.join(__dirname, 'scripts');
|
|
34
34
|
|
|
35
35
|
// Protect daemon.yaml: create backup before any sync operation
|
|
@@ -62,36 +62,12 @@ for (const script of BUNDLED_SCRIPTS) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
//
|
|
65
|
+
// Daemon restart on script update:
|
|
66
|
+
// Don't kill daemon here — daemon's own file watcher detects ~/.metame/daemon.js changes
|
|
67
|
+
// and has defer logic (waits for active Claude tasks to finish before restarting).
|
|
68
|
+
// Killing here bypasses that and interrupts ongoing conversations.
|
|
66
69
|
if (scriptsUpdated) {
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
if (fs.existsSync(DAEMON_PID_FILE)) {
|
|
70
|
-
const pid = parseInt(fs.readFileSync(DAEMON_PID_FILE, 'utf8').trim(), 10);
|
|
71
|
-
process.kill(pid, 0); // throws if not running
|
|
72
|
-
process.kill(pid, 'SIGTERM');
|
|
73
|
-
// Wait briefly for clean shutdown, then restart
|
|
74
|
-
setTimeout(() => {
|
|
75
|
-
try { process.kill(pid, 0); process.kill(pid, 'SIGKILL'); } catch { /* already dead */ }
|
|
76
|
-
}, 2000);
|
|
77
|
-
const DAEMON_SCRIPT = path.join(METAME_DIR, 'daemon.js');
|
|
78
|
-
setTimeout(() => {
|
|
79
|
-
// Use caffeinate on macOS to prevent sleep while daemon is running
|
|
80
|
-
const isNotWindows = process.platform !== 'win32';
|
|
81
|
-
const cmd = isNotWindows ? 'caffeinate' : process.execPath;
|
|
82
|
-
const args = isNotWindows ? ['-i', process.execPath, DAEMON_SCRIPT] : [DAEMON_SCRIPT];
|
|
83
|
-
const bg = spawn(cmd, args, {
|
|
84
|
-
detached: true,
|
|
85
|
-
stdio: 'ignore',
|
|
86
|
-
env: { ...process.env, HOME: HOME_DIR, METAME_ROOT: __dirname },
|
|
87
|
-
});
|
|
88
|
-
bg.unref();
|
|
89
|
-
console.log(`🔄 Daemon auto-restarted (PID: ${bg.pid}) — scripts updated.`);
|
|
90
|
-
}, 3000);
|
|
91
|
-
}
|
|
92
|
-
} catch {
|
|
93
|
-
// Daemon not running or restart failed — non-fatal
|
|
94
|
-
}
|
|
70
|
+
console.log('📦 Scripts synced to ~/.metame/ — daemon will auto-restart when idle.');
|
|
95
71
|
}
|
|
96
72
|
|
|
97
73
|
// Load daemon config for local launch flags
|
|
@@ -233,9 +209,13 @@ function spawnDistillBackground() {
|
|
|
233
209
|
}
|
|
234
210
|
|
|
235
211
|
// Spawn as detached background process — won't block Claude launch
|
|
212
|
+
// Remove CLAUDECODE env var so distill.js can call `claude -p` without nested-session rejection
|
|
213
|
+
const distillEnvClean = { ...process.env };
|
|
214
|
+
delete distillEnvClean.CLAUDECODE;
|
|
236
215
|
const bg = spawn('node', [distillPath], {
|
|
237
216
|
detached: true,
|
|
238
|
-
stdio: 'ignore'
|
|
217
|
+
stdio: 'ignore',
|
|
218
|
+
env: distillEnvClean,
|
|
239
219
|
});
|
|
240
220
|
bg.unref();
|
|
241
221
|
}
|