mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-08 06:45:55 +02:00
Pi is installed on Windows via npm, which lays down `pi.cmd` → `pi.ps1`
→ `node_modules/@mariozechner/pi-coding-agent/dist/cli.js`. The daemon
spawns Pi with `exec.Command("pi", ...)`; PATHEXT resolves that to
`pi.cmd`, and cmd.exe expands `%*` in the shim by re-tokenising the
original command line, which truncates any argv containing newlines.
buildPiArgs passes the full prompt as the last positional argv, so the
multi-line system+user prompt is silently cut at the first newline
before it reaches the JS entrypoint. The session JSONL then records
only the first line ("You are running as a chat assistant for a Multica
workspace.") and Pi replies as if the user message were missing
(GitHub multica-ai/multica#3306).
Mirror the existing cursor-agent fix: when LookPath resolves Pi to a
.cmd/.bat launcher and a sibling pi.ps1 exists, invoke PowerShell with
`-File <ps1>` directly and forward each arg as a discrete token. This
keeps us on the official launch path while skipping the cmd.exe %*
re-expansion. Falls back to the original launcher when pi.ps1 or
PowerShell can't be located.
The Windows test asserts the rewrite produces the expected argv and
that the multi-line positional prompt survives unchanged.
Co-authored-by: J <j@multica.ai>
Co-authored-by: multica-agent <github@multica.ai>
13 lines
327 B
Go
13 lines
327 B
Go
//go:build !windows
|
|
|
|
package agent
|
|
|
|
import "log/slog"
|
|
|
|
// platformPiInvocation is a no-op on non-Windows platforms: Pi's binstub
|
|
// invokes node directly via shebang and Go's os/exec can pass argv
|
|
// unchanged.
|
|
func platformPiInvocation(_ string, _ []string, _ *slog.Logger) (string, []string, bool) {
|
|
return "", nil, false
|
|
}
|