Files
magpie/internal
yetone be7d22edda gateway: a pi 1.x run of the Claude bridge starts in pi's own folder
fysly on X: a Pi turn on a Claude subscription told the model two working
directories, Pi's own and magpie's shared work folder under /private/var/
folders (magpie-claude-work-<uid>), where the bridge's Claude Code ran.

Pi 1.x states its folder as a system prompt section with the path on a
line of its own, "<cwd>\n/x\n</cwd>" (buildSystemPromptSections, joined
by getSystemMessageText). clientSaidWorkDir and clientTurnWorkDir read
<cwd> only on one line, as Codex writes it, so clientWorkDir found no
folder and the run started in the shared folder: Claude Code's own
environment then named that folder beside Pi's <cwd>. The folder rules'
reader (workDirIn) already allowed whitespace inside <cwd>; the bridge's
now does too.

Sibling in the same reader: workDirIn decodes the path's &, < and > as
entities (Codex escapes them in <cwd>, Claude Code < and >), the bridge's
did not, so such a folder failed os.Stat and its run went to the shared
folder too. Now decoded the same way.

No text of Claude Code's prompt changes: only the folder it runs in, the
existing clientWorkDir path for Claude Code, Codex and OpenCode callers
(--setting-sources "", no auto memory, CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS).

Run (mote, at 0caa09b3d plus this change): gofmt -l internal/ clean;
go vet ./internal/gateway/ for darwin, GOOS=linux and GOOS=windows ok;
go test -count=1 -timeout 45m ./internal/gateway/ ok (894.8s).
Rebased onto 3e38e4ba2 (codexcat, antigravity, codeassist): go vet and
go test -run 'WorkDir|WorkPlace|Claude' ./internal/gateway/ ok (150.5s)
at the pushed tree.
Broken by hand: with origin/main's claude_subscription.go and the new
tests, TestClaudeRunsInTheCallersWorkDir's "pi 1.x" and "Codex, a folder
written as entities" are red (both runs in magpie-claude-work-<uid>);
green with the fix.
Real pi: pi 1.4.0 in a sandbox HOME/PI_CODING_AGENT_DIR, pointed at a
local capture server; its real /v1/messages body ends
"<cwd>\n<proj>\n</cwd>". That body, sent through the bridge with a fake
claude, ran in <proj>, not the shared folder.
Not tried: a real Claude subscription turn from pi (no sandbox Claude
account here); the full go test ./... (mote and mica both over their load
limits); pi 1.5.x's prompt (1.4.0 installed, workdir.go names the same
<cwd> form since 1.1).
2026-11-14 15:01:56 +08:00
..
…
…
…
…
…
…
…
…
…
…