@geminilight/mindos 0.6.5 → 0.6.6

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.
@@ -60,8 +60,9 @@ export async function POST() {
60
60
  const root = process.env.MINDOS_PROJECT_ROOT || resolve(process.cwd(), '..');
61
61
  const mcpDir = resolve(root, 'mcp');
62
62
 
63
- if (!existsSync(resolve(mcpDir, 'node_modules'))) {
64
- return NextResponse.json({ error: 'MCP dependencies not installed' }, { status: 500 });
63
+ const mcpBundle = resolve(mcpDir, 'dist', 'index.cjs');
64
+ if (!existsSync(mcpBundle)) {
65
+ return NextResponse.json({ error: 'MCP bundle not found — reinstall @geminilight/mindos' }, { status: 500 });
65
66
  }
66
67
 
67
68
  const env: NodeJS.ProcessEnv = {
@@ -73,7 +74,7 @@ export async function POST() {
73
74
  ...(authToken ? { AUTH_TOKEN: authToken } : {}),
74
75
  };
75
76
 
76
- const child = spawn('npx', ['tsx', 'src/index.ts'], {
77
+ const child = spawn(process.execPath, [mcpBundle], {
77
78
  cwd: mcpDir,
78
79
  detached: true,
79
80
  stdio: 'ignore',
package/bin/cli.js CHANGED
@@ -433,7 +433,7 @@ const commands = {
433
433
  if (process.env.MCP_TRANSPORT === 'http') {
434
434
  process.env.MCP_PORT = process.env.MINDOS_MCP_PORT || '8781';
435
435
  }
436
- run(`npx tsx src/index.ts`, resolve(ROOT, 'mcp'));
436
+ run(`node dist/index.cjs`, resolve(ROOT, 'mcp'));
437
437
  },
438
438
 
439
439
  // ── stop / restart ─────────────────────────────────────────────────────────
@@ -1,59 +1,21 @@
1
- import { execSync, spawn } from 'node:child_process';
2
- import { existsSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
1
+ import { spawn } from 'node:child_process';
2
+ import { existsSync, readFileSync } from 'node:fs';
3
3
  import { resolve } from 'node:path';
4
- import { arch, platform } from 'node:os';
5
4
  import { ROOT, CONFIG_PATH } from './constants.js';
6
- import { bold, red, yellow } from './colors.js';
7
- import { npmInstall } from './utils.js';
8
-
9
- /**
10
- * If mcp/node_modules was installed on a different platform (e.g. Linux CI → macOS user),
11
- * native packages like esbuild will crash. Detect via stamp or @esbuild heuristics, then reinstall.
12
- */
13
- function ensureMcpNativeDeps() {
14
- const mcpDir = resolve(ROOT, 'mcp');
15
- const nm = resolve(mcpDir, 'node_modules');
16
- if (!existsSync(nm)) return;
17
-
18
- const host = `${platform()}-${arch()}`;
19
- const stamp = resolve(mcpDir, '.mindos-npm-ci-platform');
20
- let needsReinstall = false;
21
-
22
- if (existsSync(stamp)) {
23
- try {
24
- needsReinstall = readFileSync(stamp, 'utf-8').trim() !== host;
25
- } catch { /* fall through */ }
26
- } else {
27
- const esbuildDir = resolve(nm, '@esbuild');
28
- if (existsSync(esbuildDir)) {
29
- try {
30
- const names = readdirSync(esbuildDir);
31
- if (names.length > 0 && !names.includes(host)) needsReinstall = true;
32
- } catch { /* ignore */ }
33
- }
34
- }
35
-
36
- if (!needsReinstall) return;
37
-
38
- console.log(yellow('MCP dependencies were built for another platform — reinstalling...'));
39
- rmSync(nm, { recursive: true, force: true });
40
- npmInstall(mcpDir, '--no-workspaces');
41
- try { writeFileSync(stamp, host, 'utf-8'); } catch { /* non-fatal */ }
42
- }
5
+ import { bold, red } from './colors.js';
43
6
 
44
7
  export function spawnMcp(verbose = false) {
45
8
  const mcpPort = process.env.MINDOS_MCP_PORT || '8781';
46
9
  const webPort = process.env.MINDOS_WEB_PORT || '3456';
47
- // Ensure mcp/node_modules exists (auto-install on first run)
48
- const mcpSdk = resolve(ROOT, 'mcp', 'node_modules', '@modelcontextprotocol', 'sdk', 'package.json');
49
- if (!existsSync(mcpSdk)) {
50
- console.log(yellow('Installing MCP dependencies (first run)...\n'));
51
- npmInstall(resolve(ROOT, 'mcp'), '--no-workspaces');
10
+
11
+ const mcpBundle = resolve(ROOT, 'mcp', 'dist', 'index.cjs');
12
+ if (!existsSync(mcpBundle)) {
13
+ throw new Error(
14
+ `MCP bundle not found: ${mcpBundle}\n` +
15
+ `This MindOS installation may be corrupted. Try: npm install -g @geminilight/mindos@latest`,
16
+ );
52
17
  }
53
- ensureMcpNativeDeps();
54
18
 
55
- // Read AUTH_TOKEN directly from config to avoid stale system env overriding
56
- // the user's configured token. Config is the source of truth for auth.
57
19
  let configAuthToken;
58
20
  try {
59
21
  const cfg = JSON.parse(readFileSync(CONFIG_PATH, 'utf-8'));
@@ -69,7 +31,7 @@ export function spawnMcp(verbose = false) {
69
31
  ...(configAuthToken ? { AUTH_TOKEN: configAuthToken } : {}),
70
32
  ...(verbose ? { MCP_VERBOSE: '1' } : {}),
71
33
  };
72
- const child = spawn('npx', ['tsx', 'src/index.ts'], {
34
+ const child = spawn(process.execPath, [mcpBundle], {
73
35
  cwd: resolve(ROOT, 'mcp'),
74
36
  stdio: 'inherit',
75
37
  env,