metame-cli 1.4.30 → 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/index.js CHANGED
@@ -8,19 +8,14 @@ const path = require('path');
8
8
  const os = require('os');
9
9
  const { spawn, execSync } = require('child_process');
10
10
 
11
- // On Windows, resolve the full path to claude.cmd so we can spawn it
12
- // via cmd.exe (using COMSPEC) without relying on shell:true finding cmd.exe in PATH
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
- const claudePath = resolveClaudeBin();
22
- const comspec = process.env.COMSPEC || 'C:\\WINDOWS\\system32\\cmd.exe';
23
- return spawn(comspec, ['/c', `"${claudePath}"`, ...args], options);
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
  }
@@ -881,14 +876,15 @@ const CURRENT_VERSION = pkgVersion;
881
876
  if (fs.existsSync(QMD_OFFERED_FILE)) return; // already offered before
882
877
 
883
878
  // Check if QMD already installed
884
- try { execSync('which qmd', { stdio: 'pipe', timeout: 2000 }); return; } catch { }
879
+ const whichCmd = process.platform === 'win32' ? 'where' : 'which';
880
+ try { execSync(`${whichCmd} qmd`, { stdio: 'pipe', timeout: 2000 }); return; } catch { }
885
881
 
886
882
  // Mark as offered NOW — so crash/ctrl-c won't re-ask
887
883
  try { fs.writeFileSync(QMD_OFFERED_FILE, new Date().toISOString(), 'utf8'); } catch { }
888
884
 
889
885
  // Check bun availability
890
886
  let bunAvailable = false;
891
- try { execSync('which bun', { stdio: 'pipe', timeout: 2000 }); bunAvailable = true; } catch { }
887
+ try { execSync(`${whichCmd} bun`, { stdio: 'pipe', timeout: 2000 }); bunAvailable = true; } catch { }
892
888
 
893
889
  console.log('');
894
890
  console.log('┌─ 🔍 记忆搜索增强(可选,免费)');
@@ -1842,7 +1838,7 @@ try {
1842
1838
  let repoProject = cwdProject;
1843
1839
  try {
1844
1840
  const { execSync } = require('child_process');
1845
- const remote = execSync('git remote get-url origin 2>/dev/null || true', { encoding: 'utf8', stdio: 'pipe' }).trim();
1841
+ const remote = execSync('git remote get-url origin', { encoding: 'utf8', stdio: 'pipe' }).trim();
1846
1842
  if (remote) repoProject = path.basename(remote, '.git');
1847
1843
  } catch { /* not a git repo, use dirname */ }
1848
1844
 
@@ -1864,11 +1860,14 @@ try {
1864
1860
 
1865
1861
  // Auto-start daemon if config exists but daemon is not running
1866
1862
  try {
1867
- if (fs.existsSync(DAEMON_CONFIG) && fs.existsSync(DAEMON_SCRIPT)) {
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)) {
1868
1867
  let daemonRunning = false;
1869
- if (fs.existsSync(DAEMON_PID)) {
1868
+ if (fs.existsSync(_daemonPid)) {
1870
1869
  try {
1871
- const pid = parseInt(fs.readFileSync(DAEMON_PID, 'utf8').trim(), 10);
1870
+ const pid = parseInt(fs.readFileSync(_daemonPid, 'utf8').trim(), 10);
1872
1871
  process.kill(pid, 0); // signal 0 = check if alive
1873
1872
  daemonRunning = true;
1874
1873
  } catch { /* PID file stale, daemon not running */ }
@@ -1876,7 +1875,7 @@ try {
1876
1875
  if (!daemonRunning) {
1877
1876
  const isNotWindows = process.platform !== 'win32';
1878
1877
  const dCmd = isNotWindows ? 'caffeinate' : process.execPath;
1879
- const dArgs = isNotWindows ? ['-i', process.execPath, DAEMON_SCRIPT] : [DAEMON_SCRIPT];
1878
+ const dArgs = isNotWindows ? ['-i', process.execPath, _daemonScript] : [_daemonScript];
1880
1879
  const bg = spawn(dCmd, dArgs, {
1881
1880
  detached: true,
1882
1881
  stdio: 'ignore',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metame-cli",
3
- "version": "1.4.30",
3
+ "version": "1.4.31",
4
4
  "description": "The Cognitive Profile Layer for Claude Code. Knows how you think, not just what you said.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -42,11 +42,10 @@ function createClaudeEngine(deps) {
42
42
  fallbackThrottleMs = 8000,
43
43
  } = deps;
44
44
 
45
- // On Windows, spawn claude.cmd via COMSPEC instead of shell:true
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
- const comspec = process.env.COMSPEC || 'C:\\WINDOWS\\system32\\cmd.exe';
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, spawn claude.cmd via COMSPEC instead of shell:true
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
- const comspec = process.env.COMSPEC || 'C:\\WINDOWS\\system32\\cmd.exe';
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
  }