fix: resolve home directory correctly on Windows (SOUL.md never loads, exec loops on POSIX commands)#345
Open
Matthew-Selvam wants to merge 1 commit into
Conversation
…, exec loops on POSIX commands) process.env.HOME || "/root" was hardcoded across 5 lookup sites. On Windows HOME isn't set (Windows uses USERPROFILE), so every one of these silently fell back to /root, a path that doesn't exist on Windows. That meant SOUL.md, constitution.md, and WORKLOG.md were never found, and the local exec cwd resolved to the wrong place. Separately, the model had no way to know it was running on Windows, so it kept issuing POSIX commands (ls, ~) that cmd.exe doesn't understand, producing a repeating failure loop. - client.ts: execLocal's cwd and resolveLocalPath's tilde-expansion now fall back to os.homedir() instead of a hardcoded /root. - system-prompt.ts, soul/model.ts, soul/tools.ts: same os.homedir() fallback for constitution/SOUL.md/WORKLOG.md loading. - tools.ts: the exec tool description is now platform-aware — on process.platform === "win32" it tells the model to use dir/type/findstr/wsl <cmd> instead of POSIX commands, and that cmd.exe doesn't expand ~. - soul.test.ts: regression test simulating HOME unset with a Windows-like home dir, confirming loadCurrentSoul resolves it via os.homedir(). Fixes Conway-Research#165
Author
|
This is ready for maintainer review whenever you get a chance — happy to make any changes requested. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Problem
On Windows, the automaton never loads
SOUL.md,constitution.md, orWORKLOG.md, and gets stuck repeatedly issuingls -la/POSIX commands that fail.Root cause:
process.env.HOME || "/root"is hardcoded at 5 lookup sites. Windows doesn't setHOME(it usesUSERPROFILE), so every one of these silently fell back to/root— a path that doesn't exist on Windows. Separately, the model has no signal that it's running on Windows, so it keeps issuing commandscmd.exedoesn't understand.Fix
src/conway/client.ts:execLocal'scwdandresolveLocalPath's tilde-expansion fall back toos.homedir()instead of a hardcoded/root.src/agent/system-prompt.ts,src/soul/model.ts,src/soul/tools.ts: sameos.homedir()fallback for constitution/SOUL.md/WORKLOG.md loading.src/agent/tools.ts: theexectool description is now platform-aware — onprocess.platform === "win32"it tells the model to usedir/type/findstr/wsl <cmd>instead of POSIX commands, and thatcmd.exedoesn't expand~.Tests
Added a regression test in
soul.test.tsthat simulatesHOMEunset with a Windows-like home directory (viavi.spyOn(os, "homedir")), confirmingloadCurrentSoulfindsSOUL.mdthere instead of at a hardcoded path.tsc --noEmitpasses;soul.test.ts(42/42),tools-security.test.ts(71/71), andorchestration/local-worker-harness.test.ts(5/5) all pass.Fixes #165