mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
fix(core/agents): avoid duplicate Copilot prompt flag
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user