mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-05 21:39:54 +02:00
Bug 1: detect copilot.cmd/.bat on Windows and invoke the sibling .ps1 directly via powershell -File, bypassing cmd.exe %* re-tokenisation that mangled the multi-line -p prompt. Shared rewriteCmdToPS1() now serves cursor, pi, and copilot. Bug 2: filterCustomArgs (shared by all agent backends) strips one outer layer of shell quotes via unshellQuoteArg() before processing, so shell-style custom args like --deny-tool='write' no longer reach the CLI with literal quotes.
23 lines
949 B
Go
23 lines
949 B
Go
package agent
|
|
|
|
import "log/slog"
|
|
|
|
// chooseCopilotInvocation selects the actual program (argv[0]) and the full
|
|
// argv to spawn a Copilot CLI run.
|
|
//
|
|
// On macOS/Linux the npm binstub is a shebang script that execs node directly,
|
|
// so argv passes through unchanged. On Windows the npm installer ships
|
|
// copilot.cmd, which routes through cmd.exe; cmd.exe re-tokenises the raw
|
|
// command line via %*, mangling arguments that contain newlines or whitespace
|
|
// (e.g. the multi-line -p prompt). To avoid that, we find the sibling
|
|
// copilot.ps1 and invoke PowerShell with -File <ps1> directly, so Go passes
|
|
// each argument as a discrete token.
|
|
//
|
|
// The Windows rewrite lives in copilot_invocation_windows.go.
|
|
func chooseCopilotInvocation(execName, lookedUp string, args []string, logger *slog.Logger) (string, []string) {
|
|
if argv0, full, ok := platformCopilotInvocation(lookedUp, args, logger); ok {
|
|
return argv0, full
|
|
}
|
|
return execName, args
|
|
}
|