Windows port foundations: MCP IPC, CLI resolution, portable tooling#160
Closed
arul28 wants to merge 2 commits into
Closed
Windows port foundations: MCP IPC, CLI resolution, portable tooling#160arul28 wants to merge 2 commits into
arul28 wants to merge 2 commits into
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Windows port foundations plus follow-ups, updated to address all 12 inline review comments from Greptile and CodeRabbit on this PR.
MCP / IPC
resolveAdeMcpIpcPath; Unix:.ade/mcp.sock.apps/mcp-server/src/index.ts).adeMcpProxy --probe:socketExistsuses a short connect probe for named pipes (not alwaystrue).CLI / usage / sandbox
cliExecutableResolver: Windows PATH augmentation and known dirs; test fixture PATH uses realistic escaping.usageTrackingServiceCodex RPC: total stdout/stderr caps; on Windowscmd /d/s/cwhen spawning.cmd/.bator barecodex.orchestratorConstants:formatregex fixed;reg.exe/format.exe/diskpart.exe/bcdedit.exe/takeown.exevariants; removed wholesaleProgramFilestrust (only System32 / SysWOW64).resolveWorkerShellInvocation:/d /s /con Windows.OpenCode on Windows
Get-CimInstance Win32_Process | ConvertTo-Csv(shared CSV parser).cmd.exe /d/s/cwithset "ADE_OPENCODE_*"beforeopencode … serveso markers appear in CommandLine;isManagedOpenCodeServeCommandhandles cmd-wrapped lines;parseManagedOwnerPidtoleratessetquoting.__isManagedOpenCodeServeCommandForTestsfor unit coverage.Tests
adeMcpIpc.test.ts,cliExecutableResolver.test.ts,universalTools.test.ts,openCodeServerManager.test.tsupdated accordingly.If new bot comments appear after this push, paste them or re-run review on the latest commit.
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Improvements
Greptile Summary
This PR adds Windows port foundations across MCP IPC (named pipes), CLI resolution, process-tree killing, and OpenCode orphan recovery. Most prior review concerns have been resolved: stdout accumulation is now correctly capped,
isSystemExecutableSandboxPathis narrowed to System32/SysWOW64 only, theformatregex trailing\bwas dropped, WMIC unavailability now falls back to PowerShell, and orphan recovery usestaskkill /T /F.universalTools.ts:627):resolveWorkerShellInvocationpasses the raw AI command string directly tocmd.exe /d /s /c. When the command starts with\"(e.g. a quoted executable path), cmd.exe's/sflag strips the outer\"…\"pair, corrupting the command token. The same outer-wrap fix needed forresolveWindowsCmdInvocationapplies here.Confidence Score: 4/5
Safe to merge after addressing the cmd.exe /s /c quote-stripping bug in resolveWorkerShellInvocation.
The PR resolves the majority of prior P1/P2 findings. One new P1 remains in resolveWorkerShellInvocation (universalTools.ts) — the same cmd.exe /s /c outer-quote issue as flagged for resolveWindowsCmdInvocation, but in a new function not covered by the prior thread.
apps/desktop/src/main/services/ai/tools/universalTools.ts (resolveWorkerShellInvocation), apps/desktop/src/main/services/shared/processExecution.ts (resolveWindowsCmdInvocation — prior thread fix still outstanding)
Important Files Changed
resolveWorkerShellInvocationfor Windows bash-tool execution has the same cmd.exe/s /cquote-stripping bug;isSystemExecutableSandboxPathcorrectly narrowed to System32/SysWOW64 only (addressing prior P2).quoteWindowsCmdArg,resolveWindowsCmdInvocation,terminateProcessTree. The/s /cquoting issue flagged in prior review (adding outer"..."around cmdLine) remains unaddressed in this file.killProcessTree(taskkill /T /F), WMIC/PowerShell process listing with CSV fallback, and cmd.exesetmarker injection into CommandLine. The cmdLine for the launch spec starts withset, not", so /s quote-stripping is not triggered here.maxStdout - stdout.lengthdifferential slicing, addressing the prior P1 comment. Windowscmd /d/s/cwrapper for.cmd/.batcodex launchers added correctly.\bafter drive-letterformatpattern removed (fixing the never-matching regex); Windows executables added to safeCommands/blockedPatterns with.exe/.cmdoptional suffixes..ade/ade.sock. Tests confirm stable casing-normalized pipe names.getWindowsKnownBinDirs, case-insensitive PATH key lookup (getPathEnvKey), and PATHEXT-aware extension resolution all look correct.navigator.platformused for browser-side Windows detection is deprecated and may silently fail to detect Windows on modern engines.Comments Outside Diff (2)
apps/desktop/src/main/services/opencode/openCodeServerManager.ts, line 827-841 (link)listWindowsProcessesFromWmicreturns[]on any error includingwmicnot being found (deprecated/removed on Windows 11 22H2+ without the optional feature). The caller then sees an empty process list, meaning orphan OpenCode processes are never detected or killed. A PowerShellGet-CimInstancefallback — or at least a logged warning — would prevent silent orphan leakage on affected systems.Prompt To Fix With AI
apps/desktop/src/main/services/opencode/openCodeServerManager.ts, line 577-581 (link)On Windows,
openCodeProcessController.killProcesscallsprocess.kill(pid, signal), which terminates only the wrappercmd.exe(PID=X). Its children — anothercmd.exerunningopencode.cmd, and the actualnode.exe/opencode.exeserver beneath it — are left running as invisible orphans, defeating the purpose of orphan recovery.By contrast,
stopChildProcess(used for directly managed children) correctly callstaskkill /pid X /T /Fto kill the whole tree. The orphan recovery path needs the same treatment.Evidence:
killProcessat line 299–305 usesprocess.kill(pid, signal)with no tree-kill;stopChildProcessat lines 389–393 usestaskkill /T /F.isManagedOpenCodeServeCommandonly matches the cmd.exe wrapper (via the managed-env markers), so the actual opencode subprocess is never found in subsequent recovery runs, leaving it running indefinitely and causing EADDRINUSE collisions on the same port.Suggested fix: add a Windows-specific
taskkillcall in the orphan kill path (before or instead ofprocess.kill), mirroringstopChildProcess:Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (7): Last reviewed commit: "Add /shipLane command and portable ship-..." | Re-trigger Greptile