metame-cli 1.4.29 → 1.4.31
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/README.md +5 -0
- package/index.js +34 -24
- package/package.json +1 -1
- package/scripts/daemon-claude-engine.js +2 -3
- package/scripts/daemon-task-scheduler.js +2 -3
package/README.md
CHANGED
|
@@ -228,6 +228,11 @@ metame
|
|
|
228
228
|
|
|
229
229
|
> **First time?** Just run `metame` and talk naturally. The interview and setup are conversational — no commands to memorize.
|
|
230
230
|
|
|
231
|
+
**Update MetaMe:**
|
|
232
|
+
```bash
|
|
233
|
+
npm install -g metame-cli
|
|
234
|
+
```
|
|
235
|
+
|
|
231
236
|
> **What does system registration mean?**
|
|
232
237
|
> Once registered, MetaMe runs in the background automatically — screen locked, lid closed, woken from sleep — as long as the machine is on. Scheduled tasks fire on time. No terminal window needed.
|
|
233
238
|
|
package/index.js
CHANGED
|
@@ -8,23 +8,25 @@ const path = require('path');
|
|
|
8
8
|
const os = require('os');
|
|
9
9
|
const { spawn, execSync } = require('child_process');
|
|
10
10
|
|
|
11
|
-
// On Windows,
|
|
12
|
-
//
|
|
13
|
-
function resolveClaudeBin() {
|
|
14
|
-
if (process.platform !== 'win32') return 'claude';
|
|
15
|
-
try {
|
|
16
|
-
return execSync('where claude', { encoding: 'utf8' }).trim().split('\n')[0];
|
|
17
|
-
} catch { return 'claude'; }
|
|
18
|
-
}
|
|
11
|
+
// On Windows, .cmd files (like claude.cmd from npm global) need shell:true to spawn.
|
|
12
|
+
// We use COMSPEC to avoid conda/PATH issues where cmd.exe can't be found.
|
|
19
13
|
function spawnClaude(args, options) {
|
|
20
14
|
if (process.platform === 'win32') {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
return spawn('claude', args, {
|
|
16
|
+
...options,
|
|
17
|
+
shell: process.env.COMSPEC || true,
|
|
18
|
+
});
|
|
24
19
|
}
|
|
25
20
|
return spawn('claude', args, options);
|
|
26
21
|
}
|
|
27
22
|
|
|
23
|
+
// Quick flags (before heavy init)
|
|
24
|
+
const pkgVersion = require('./package.json').version;
|
|
25
|
+
if (process.argv.includes('-V') || process.argv.includes('--version')) {
|
|
26
|
+
console.log(`metame/${pkgVersion}`);
|
|
27
|
+
process.exit(0);
|
|
28
|
+
}
|
|
29
|
+
|
|
28
30
|
// ---------------------------------------------------------
|
|
29
31
|
// 1. CONFIGURATION
|
|
30
32
|
// ---------------------------------------------------------
|
|
@@ -771,7 +773,6 @@ try {
|
|
|
771
773
|
|
|
772
774
|
|
|
773
775
|
|
|
774
|
-
const pkgVersion = require('./package.json').version;
|
|
775
776
|
console.log(`🔮 MetaMe v${pkgVersion}: Link Established.`);
|
|
776
777
|
|
|
777
778
|
// Memory system status — show live stats without blocking launch
|
|
@@ -828,7 +829,7 @@ try {
|
|
|
828
829
|
// ---------------------------------------------------------
|
|
829
830
|
// 4.9 AUTO-UPDATE CHECK (non-blocking)
|
|
830
831
|
// ---------------------------------------------------------
|
|
831
|
-
const CURRENT_VERSION =
|
|
832
|
+
const CURRENT_VERSION = pkgVersion;
|
|
832
833
|
|
|
833
834
|
// Fire-and-forget: check npm for newer version and auto-update
|
|
834
835
|
(async () => {
|
|
@@ -845,13 +846,18 @@ const CURRENT_VERSION = require('./package.json').version;
|
|
|
845
846
|
});
|
|
846
847
|
|
|
847
848
|
if (latest && latest !== CURRENT_VERSION) {
|
|
848
|
-
console.log(`📦 MetaMe ${latest}
|
|
849
|
+
console.log(`📦 MetaMe ${latest} available (current ${CURRENT_VERSION}), updating...`);
|
|
849
850
|
const { execSync } = require('child_process');
|
|
850
851
|
try {
|
|
851
|
-
execSync('npm
|
|
852
|
-
|
|
852
|
+
execSync('npm install -g metame-cli@latest', {
|
|
853
|
+
stdio: 'pipe',
|
|
854
|
+
timeout: 60000,
|
|
855
|
+
...(process.platform === 'win32' ? { shell: process.env.COMSPEC || true } : {}),
|
|
856
|
+
});
|
|
857
|
+
console.log(`✅ Updated to ${latest}. Restart metame to use the new version.`);
|
|
853
858
|
} catch (e) {
|
|
854
|
-
|
|
859
|
+
const msg = e.stderr ? e.stderr.toString().trim().split('\n').pop() : '';
|
|
860
|
+
console.log(`⚠️ Auto-update failed${msg ? ': ' + msg : ''}. Run manually: npm install -g metame-cli`);
|
|
855
861
|
}
|
|
856
862
|
}
|
|
857
863
|
} catch { /* network unavailable, skip silently */ }
|
|
@@ -870,14 +876,15 @@ const CURRENT_VERSION = require('./package.json').version;
|
|
|
870
876
|
if (fs.existsSync(QMD_OFFERED_FILE)) return; // already offered before
|
|
871
877
|
|
|
872
878
|
// Check if QMD already installed
|
|
873
|
-
|
|
879
|
+
const whichCmd = process.platform === 'win32' ? 'where' : 'which';
|
|
880
|
+
try { execSync(`${whichCmd} qmd`, { stdio: 'pipe', timeout: 2000 }); return; } catch { }
|
|
874
881
|
|
|
875
882
|
// Mark as offered NOW — so crash/ctrl-c won't re-ask
|
|
876
883
|
try { fs.writeFileSync(QMD_OFFERED_FILE, new Date().toISOString(), 'utf8'); } catch { }
|
|
877
884
|
|
|
878
885
|
// Check bun availability
|
|
879
886
|
let bunAvailable = false;
|
|
880
|
-
try { execSync(
|
|
887
|
+
try { execSync(`${whichCmd} bun`, { stdio: 'pipe', timeout: 2000 }); bunAvailable = true; } catch { }
|
|
881
888
|
|
|
882
889
|
console.log('');
|
|
883
890
|
console.log('┌─ 🔍 记忆搜索增强(可选,免费)');
|
|
@@ -1831,7 +1838,7 @@ try {
|
|
|
1831
1838
|
let repoProject = cwdProject;
|
|
1832
1839
|
try {
|
|
1833
1840
|
const { execSync } = require('child_process');
|
|
1834
|
-
const remote = execSync('git remote get-url origin
|
|
1841
|
+
const remote = execSync('git remote get-url origin', { encoding: 'utf8', stdio: 'pipe' }).trim();
|
|
1835
1842
|
if (remote) repoProject = path.basename(remote, '.git');
|
|
1836
1843
|
} catch { /* not a git repo, use dirname */ }
|
|
1837
1844
|
|
|
@@ -1853,11 +1860,14 @@ try {
|
|
|
1853
1860
|
|
|
1854
1861
|
// Auto-start daemon if config exists but daemon is not running
|
|
1855
1862
|
try {
|
|
1856
|
-
|
|
1863
|
+
const _daemonCfgPath = path.join(METAME_DIR, 'daemon.yaml');
|
|
1864
|
+
const _daemonScript = path.join(METAME_DIR, 'daemon.js');
|
|
1865
|
+
const _daemonPid = path.join(METAME_DIR, 'daemon.pid');
|
|
1866
|
+
if (fs.existsSync(_daemonCfgPath) && fs.existsSync(_daemonScript)) {
|
|
1857
1867
|
let daemonRunning = false;
|
|
1858
|
-
if (fs.existsSync(
|
|
1868
|
+
if (fs.existsSync(_daemonPid)) {
|
|
1859
1869
|
try {
|
|
1860
|
-
const pid = parseInt(fs.readFileSync(
|
|
1870
|
+
const pid = parseInt(fs.readFileSync(_daemonPid, 'utf8').trim(), 10);
|
|
1861
1871
|
process.kill(pid, 0); // signal 0 = check if alive
|
|
1862
1872
|
daemonRunning = true;
|
|
1863
1873
|
} catch { /* PID file stale, daemon not running */ }
|
|
@@ -1865,7 +1875,7 @@ try {
|
|
|
1865
1875
|
if (!daemonRunning) {
|
|
1866
1876
|
const isNotWindows = process.platform !== 'win32';
|
|
1867
1877
|
const dCmd = isNotWindows ? 'caffeinate' : process.execPath;
|
|
1868
|
-
const dArgs = isNotWindows ? ['-i', process.execPath,
|
|
1878
|
+
const dArgs = isNotWindows ? ['-i', process.execPath, _daemonScript] : [_daemonScript];
|
|
1869
1879
|
const bg = spawn(dCmd, dArgs, {
|
|
1870
1880
|
detached: true,
|
|
1871
1881
|
stdio: 'ignore',
|
package/package.json
CHANGED
|
@@ -42,11 +42,10 @@ function createClaudeEngine(deps) {
|
|
|
42
42
|
fallbackThrottleMs = 8000,
|
|
43
43
|
} = deps;
|
|
44
44
|
|
|
45
|
-
// On Windows,
|
|
45
|
+
// On Windows, .cmd files need shell to spawn; use COMSPEC to avoid conda PATH issues
|
|
46
46
|
function spawn(cmd, args, options) {
|
|
47
47
|
if (process.platform === 'win32' && cmd === CLAUDE_BIN) {
|
|
48
|
-
|
|
49
|
-
return _spawn(comspec, ['/c', `"${cmd}"`, ...args], options);
|
|
48
|
+
return _spawn(cmd, args, { ...options, shell: process.env.COMSPEC || true });
|
|
50
49
|
}
|
|
51
50
|
return _spawn(cmd, args, options);
|
|
52
51
|
}
|
|
@@ -180,11 +180,10 @@ function createTaskScheduler(deps) {
|
|
|
180
180
|
skillEvolution,
|
|
181
181
|
} = deps;
|
|
182
182
|
|
|
183
|
-
// On Windows,
|
|
183
|
+
// On Windows, .cmd files need shell to spawn; use COMSPEC to avoid conda PATH issues
|
|
184
184
|
function spawn(cmd, args, options) {
|
|
185
185
|
if (process.platform === 'win32' && cmd === CLAUDE_BIN) {
|
|
186
|
-
|
|
187
|
-
return _spawn(comspec, ['/c', `"${cmd}"`, ...args], options);
|
|
186
|
+
return _spawn(cmd, args, { ...options, shell: process.env.COMSPEC || true });
|
|
188
187
|
}
|
|
189
188
|
return _spawn(cmd, args, options);
|
|
190
189
|
}
|