fix(windows): hide terminal windows when spawning child processes

This commit is contained in:
CrystallDEV
2025-12-10 00:15:14 +01:00
parent 65e5411c21
commit 5f36d2bf9a
4 changed files with 23 additions and 15 deletions
+8 -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,7 +260,7 @@ async function runNpmInstall() {
// Run npm install silently
execSync(command, {
cwd: PLUGIN_ROOT,
cwd: MARKETPLACE_ROOT,
stdio: 'pipe', // Silent output unless error
encoding: 'utf-8',
});
+9
View File
@@ -6,6 +6,15 @@
* See src/services/worker/README.md for architecture details.
*/
// Windows terminal window fix: Set process.type to trick MCP SDK into enabling windowsHide
// The 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
if (process.platform === 'win32' && !process.type) {
(process as any).type = 'renderer';
}
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 {