Merge pull request #203 from CrystallDEV/fix/windows-terminal-spawning

fix(windows): hide terminal windows when spawning child processes
This commit is contained in:
Alex Newman
2025-12-09 20:19:17 -05:00
committed by GitHub
4 changed files with 39 additions and 15 deletions
+9 -12
View File
@@ -17,18 +17,14 @@ import { join } from 'path';
import { homedir } from 'os';
import { createRequire } from 'module';
// CRITICAL: Always use marketplace directory for ALL operations
// This script may run from the cache directory (plugin/scripts/) but must
// operate on the marketplace directory where package.json and node_modules live.
// This ensures cross-platform compatibility and avoids cache directory confusion.
const MARKETPLACE_ROOT = join(homedir(), '.claude', 'plugins', 'marketplaces', 'thedotmack');
// Use MARKETPLACE_ROOT for all paths - this script can be deployed anywhere
// but always operates on the marketplace directory
const PLUGIN_ROOT = MARKETPLACE_ROOT;
const PACKAGE_JSON_PATH = join(PLUGIN_ROOT, 'package.json');
const VERSION_MARKER_PATH = join(PLUGIN_ROOT, '.install-version');
const NODE_MODULES_PATH = join(PLUGIN_ROOT, 'node_modules');
// CRITICAL: Always use marketplace directory for npm install and PM2/ecosystem
// This script may run from cache directory (plugin/) which has no package.json
// The marketplace root is the canonical location with package.json and node_modules
const MARKETPLACE_ROOT = join(homedir(), '.claude', 'plugins', 'marketplaces', 'thedotmack');
const PACKAGE_JSON_PATH = join(MARKETPLACE_ROOT, 'package.json');
const VERSION_MARKER_PATH = join(MARKETPLACE_ROOT, '.install-version');
const NODE_MODULES_PATH = join(MARKETPLACE_ROOT, 'node_modules');
const BETTER_SQLITE3_PATH = join(NODE_MODULES_PATH, 'better-sqlite3');
// Colors for output
@@ -264,9 +260,10 @@ async function runNpmInstall() {
// Run npm install silently
execSync(command, {
cwd: PLUGIN_ROOT,
cwd: MARKETPLACE_ROOT,
stdio: 'pipe', // Silent output unless error
encoding: 'utf-8',
windowsHide: true,
});
// Verify better-sqlite3 was installed
+24
View File
@@ -6,6 +6,30 @@
* See src/services/worker/README.md for architecture details.
*/
/**
* Windows terminal window fix for MCP SDK (vX.Y.Z):
* The MCP SDK checks `process.type === 'renderer'` (Electron detection) before setting windowsHide.
* By setting process.type, the SDK's isElectron() check becomes truthy on Windows, hiding
* terminal windows when spawning uvx/python processes for Chroma MCP server.
* The type is sometimes not present resulting in the check being false. Setting it like this fixes it.
*
* TODO: Remove this workaround once MCP SDK exposes a config for windowsHide or fixes detection.
* See: https://github.com/modelcontextprotocol/sdk/issues/XXX
*/
function applyWindowsHideWorkaroundIfNeeded() {
if (process.platform === 'win32' && !process.type) {
// Optionally, check MCP SDK version here if available
// Log a warning so this is visible in logs
// eslint-disable-next-line no-console
console.warn(
'[worker-service] Applying MCP SDK windowsHide workaround: setting process.type = "renderer". ' +
'This is a fragile hack. Remove when MCP SDK is fixed. See code comments for details.'
);
(process as any).type = 'renderer';
}
}
applyWindowsHideWorkaroundIfNeeded();
import express from 'express';
import http from 'http';
import path from 'path';
+4 -2
View File
@@ -36,7 +36,8 @@ function execGit(command: string): string {
return execSync(`git ${command}`, {
cwd: INSTALLED_PLUGIN_PATH,
encoding: 'utf-8',
timeout: 30000
timeout: 30000,
windowsHide: true
}).trim();
}
@@ -47,7 +48,8 @@ function execShell(command: string, timeoutMs: number = 60000): string {
return execSync(command, {
cwd: INSTALLED_PLUGIN_PATH,
encoding: 'utf-8',
timeout: timeoutMs
timeout: timeoutMs,
windowsHide: true
}).trim();
}
+2 -1
View File
@@ -89,7 +89,8 @@ export function getCurrentProjectName(): string {
const gitRoot = execSync('git rev-parse --show-toplevel', {
cwd: process.cwd(),
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'ignore']
stdio: ['pipe', 'pipe', 'ignore'],
windowsHide: true
}).trim();
return basename(gitRoot);
} catch {