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.
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package agent
|
|
|
|
import (
|
|
"io"
|
|
"log/slog"
|
|
"path/filepath"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
// TestChooseCopilotInvocation_PassthroughForNonLauncher verifies that when
|
|
// the resolved executable is not a Windows .cmd/.bat launcher, both argv[0]
|
|
// and the argv list are returned unchanged on every platform. This guards
|
|
// against accidental rewriting on macOS/Linux and for direct binary launches
|
|
// on Windows.
|
|
func TestChooseCopilotInvocation_PassthroughForNonLauncher(t *testing.T) {
|
|
logger := slog.New(slog.NewTextHandler(io.Discard, nil))
|
|
|
|
execName := "copilot"
|
|
lookedUp := filepath.Join(t.TempDir(), "copilot") // no .cmd / .bat
|
|
args := []string{
|
|
"-p", "You are running as a local coding agent.\n\nDo something.",
|
|
"--output-format", "json",
|
|
"--allow-all",
|
|
"--no-ask-user",
|
|
}
|
|
|
|
gotExec, gotArgs := chooseCopilotInvocation(execName, lookedUp, args, logger)
|
|
|
|
if gotExec != execName {
|
|
t.Errorf("argv0 changed unexpectedly: got %q want %q", gotExec, execName)
|
|
}
|
|
if !reflect.DeepEqual(gotArgs, args) {
|
|
t.Errorf("argv changed unexpectedly:\n got %#v\n want %#v", gotArgs, args)
|
|
}
|
|
}
|