feat(ai): 添加 Codex CLI 命令解析和环境变量处理功能

- 实现了对 Codex CLI 命令的解析,支持路径解析和环境变量设置
- 增加了对命令环境的处理,确保正确的执行路径
- 添加了相关的单元测试,确保功能的正确性
This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-06-25 16:47:43 +08:00
1 parent d96448b5a5
commit c2aeaaa8f7
6 files changed
+360 -12

No files matched your search

+3
View File
@@ -29,6 +29,7 @@ pub enum CliAgentJsonlDialect {
pub struct CliAgentProcessSpec {
pub command: CliAgentCommandSpec,
pub env: Vec<(String, String)>,
pub dialect: CliAgentJsonlDialect,
pub classify_spawn_error: fn(&str) -> String,
pub classify_run_error: fn(&str) -> String,
@@ -327,6 +328,7 @@ pub async fn run_cli_jsonl_agent(
) -> Result<String, String> {
let mut child = Command::new(&spec.command.program)
.args(&spec.command.args)
.envs(spec.env.iter().map(|(key, value)| (key.as_str(), value.as_str())))
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
@@ -439,6 +441,7 @@ mod tests {
let spec = CliAgentProcessSpec {
command: CliAgentCommandSpec { program: "sh".to_string(), args: vec!["-c".to_string(), script] },
env: Vec::new(),
dialect: CliAgentJsonlDialect::CodexExec,
classify_spawn_error,
classify_run_error,