Windows: MCP entries start through cmd /c npx or bun cli/index.ts (npx.cmd and the sh launcher cannot be spawned, pitfall 94); desktop download streams with progress and fails after 60 s without data (pitfall 95); getting-started Windows note

This commit is contained in:
CRTkafa 2026-10-21 22:21:49 +08:00
parent e5dffb5533
commit 0ac3cd02b0
6 changed files with 77 additions and 9 deletions

View file

@ -29,7 +29,19 @@ function snapshot(dir: string, base = dir, out = new Map<string, string>()): Map
}
const same = (a: Map<string, string>, b: Map<string, string>) => a.size === b.size && [...a].every(([k, v]) => b.get(k) === v);
export function mcpCommand(project: string, override?: string, runtime: 'bun' | 'node' = rt.runtime.name, version = pkg.version): McpCommand {
/** Windows cannot start `npx` (a .cmd shim) or the /bin/sh launcher as a stdio command (pitfall 94). */
export function winWrap(c: McpCommand, platform: string = process.platform): McpCommand {
if (platform !== 'win32') return c;
if (c.command === 'npx') return { command: 'cmd', args: ['/c', 'npx', ...c.args] };
if (c.command === join(TOOLCHAIN, 'bin', 'storebound')) return { command: 'bun', args: [join(TOOLCHAIN, 'cli', 'index.ts'), ...c.args] };
return c;
}
export function mcpCommand(project: string, override?: string, runtime: 'bun' | 'node' = rt.runtime.name, version = pkg.version, platform: string = process.platform): McpCommand {
return winWrap(mcpCommand0(project, override, runtime, version), platform);
}
function mcpCommand0(project: string, override?: string, runtime: 'bun' | 'node' = rt.runtime.name, version = pkg.version): McpCommand {
if (override) { const [command, ...args] = override.split(/\s+/).filter(Boolean); return { command: command!, args: [...args, 'mcp'] }; }
if (existsSync(join(project, 'node_modules', 'storebound', 'package.json'))) return { command: runtime === 'bun' ? 'bunx' : 'npx', args: ['storebound', 'mcp'] };
if (runtime === 'node') return { command: 'npx', args: ['-y', `storebound@${version}`, 'mcp'] };