fix(core/agents): avoid duplicate Copilot prompt flag

This commit is contained in:
James Peter
2026-03-11 09:13:38 +10:00
parent 11bd845668
commit 2fdb5ddb46
2 changed files with 60 additions and 4 deletions
+4 -4
View File
@@ -25,8 +25,8 @@ const GEMINI_PRO_READ_ONLY: &[&str] = &[];
const GEMINI_PRO_WRITE: &[&str] = &["-y"];
const GEMINI_FLASH_READ_ONLY: &[&str] = &[];
const GEMINI_FLASH_WRITE: &[&str] = &["-y"];
const COPILOT_READ_ONLY: &[&str] = &["-p"];
const COPILOT_WRITE: &[&str] = &["--autopilot", "--yolo", "-p"];
const COPILOT_READ_ONLY: &[&str] = &[];
const COPILOT_WRITE: &[&str] = &["--autopilot", "--yolo"];
const QWEN_3_CODER_READ_ONLY: &[&str] = &[];
const QWEN_3_CODER_WRITE: &[&str] = &["-y"];
const CLOUD_GPT5_CODEX_READ_ONLY: &[&str] = &[];
@@ -527,10 +527,10 @@ mod tests {
#[test]
fn github_copilot_defaults_match_cli_contract() {
assert_eq!(default_params_for("github-copilot", true), vec!["-p"]);
assert!(default_params_for("github-copilot", true).is_empty());
assert_eq!(
default_params_for("github-copilot", false),
vec!["--autopilot", "--yolo", "-p"]
vec!["--autopilot", "--yolo"]
);
let spec = agent_model_spec("copilot").expect("copilot alias should resolve");
+56
View File
@@ -3005,6 +3005,44 @@ mod tests {
assert_eq!(output.trim(), "local-claude");
}
#[tokio::test]
async fn github_copilot_launches_with_single_prompt_flag() {
let dir = tempdir().expect("tempdir");
let copilot = script_path(dir.path(), "copilot");
write_argv_script(&copilot);
let cfg = AgentConfig {
name: "github-copilot".to_string(),
command: copilot.display().to_string(),
args: Vec::new(),
read_only: true,
enabled: true,
description: None,
env: None,
args_read_only: None,
args_write: None,
instructions: None,
};
let output = execute_model_with_permissions(
"agent-test",
"github-copilot",
"hello from copilot",
true,
None,
Some(cfg),
ReasoningEffort::Low,
None,
None,
None,
)
.await
.expect("execute copilot agent");
let args: Vec<&str> = output.trim().split('|').collect();
assert_eq!(args, vec!["-p", "hello from copilot"]);
}
fn env_lock() -> &'static Mutex<()> {
static LOCK: OnceLock<Mutex<()>> = OnceLock::new();
LOCK.get_or_init(|| Mutex::new(()))
@@ -3071,6 +3109,24 @@ mod tests {
std::fs::set_permissions(path, perms).expect("chmod script");
}
#[cfg(target_os = "windows")]
fn write_argv_script(path: &Path) {
let script = "@echo off\r\nsetlocal enabledelayedexpansion\r\nset out=\r\n:loop\r\nif \"%~1\"==\"\" goto done\r\nif defined out (set out=!out!|%~1) else (set out=%~1)\r\nshift\r\ngoto loop\r\n:done\r\necho %out%\r\nexit /b 0\r\n";
std::fs::write(path, script).expect("write argv cmd");
}
#[cfg(not(target_os = "windows"))]
fn write_argv_script(path: &Path) {
let script = "#!/bin/sh\nprintf '%s' \"$1\"\nshift\nfor arg in \"$@\"; do\n printf '|%s' \"$arg\"\ndone\nprintf '\\n'\nexit 0\n";
std::fs::write(path, script).expect("write argv script");
let mut perms = std::fs::metadata(path)
.expect("script metadata")
.permissions();
use std::os::unix::fs::PermissionsExt;
perms.set_mode(0o755);
std::fs::set_permissions(path, perms).expect("chmod script");
}
#[test]
fn gemini_config_dir_is_injected_when_missing_api_key() {
let tmp = tempfile::tempdir().expect("tempdir");