【架构优化】从 runtime.codexConfigArgs 中拆出单个 MCP server 参数渲染 codexMCPServerArgs

未關閉
#414 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@fx-kurumi 已經在處理了。

開始於 2026年11月13日。

  • #415 來自 @fx-kurumi —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
20/100
Issue 類型
重構
描述清晰度
描述清楚
活躍度
停滯
技術堆疊
go
領域
tooling

研究方向

Read internal/runtime/provider_codex.go, focusing on codexConfigArgs and its MCP server argument rendering loop. Add tests in a new test file for an HTTP server, a stdio server with cwd/args/env/timeout, and the combined output; run gofmt, go vet ./internal/runtime/, and go test ./internal/runtime/. Done means the extracted function preserves the existing argument order and formatting, and all checks pass.

由索引模型根據 Issue 內容生成。

描述

现状问题

internal/runtime/provider_codex.go 的 codexConfigArgs 同时负责三件事:开发者指令与 shell 环境策略、skills 配置、以及每个 MCP server 的 -c mcp_servers.<id>.* 参数渲染。其中 MCP server 的渲染(http/stdio 分支、cwd、args 引号拼接、env 排序拼接、tool_timeout_sec)嵌套在 for 循环里达 4 层,占函数大半,可读性差,也无法单独测试单个 server 的渲染结果。

重构方案

把循环体抽成包内函数 codexMCPServerArgs(m domain.MCPServerDefinition) []string,原循环改为 args = append(args, codexMCPServerArgs(m)...)。参数顺序、引号与格式逐字保持一致。

影响范围

仅 internal/runtime/provider_codex.go 一个函数(包内私有),对外接口与行为不变;新增一个测试文件。

验证方式

  • 新增单元测试覆盖 http server、带 cwd/args/env/timeout 的 stdio server,以及 codexConfigArgs 整体输出与逐 server 拼接一致
  • gofmt、go vet ./internal/runtime/、go test ./internal/runtime/
主要語言
Go
星號
141
分支
28
平均合併
1 天 15 小時
30 天內合併 PR
113

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

Tencent/LoopForge 的其他 Issue

查看 Tencent/LoopForge 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。