Skip to content

[code-review] VendorPresets iterates the endpoints map unordered, so the onboarding wizard's default endpoint (and the desktop DefaultEndpoint flag) is random per launch; mcp_patch's switch omits 'ws' and skips case-normalization (dead code today - active patch path unaffected); npm detection overwrites go.mod-decided commands violating the profile's own priority contract; 'TAGS' substring match injects -tags goolm for DOCKER_TAGS etc.; knight's per-field fallback splices cross-vendor endpoint ids #1523

Description

@topcheer

文件行号

internal/config/onboard.go L83-95(for epID, ep := range vc.Endpoints map 无序——L102-104 只 sortVendors,Endpoints 切片与 DefaultEndpoint 均未排序,L18 注释 "first endpoint key" 意图落空)+ 消费方 internal/tui/onboard.go L110/L254/L469(endpointCursor 零值起——预选随机端点)+ desktop/wailskit/config.go L519-526(随机 DefaultEndpoint 标志传桌面 UI);mcp_patch.go L42-49(switch case "http","https","sse","streamable-http" 清 Command,default 清 URL/Headers——"ws" 缺席(internal/mcp/migration.go L181 明文 "supported: stdio, http, ws")+ 无 ToLower/TrimSpace——type: HTTP 同落 default)——复核修正:PatchMCPServerConfig 零调用方为死代码(活跃路径 config_vendor.go L312-348 小写版仅在 Type 明确不同时按方向清理不受影响);project_profile.go L370-375(Contains(pj, "\"test\"") 命中即无条件 p.TestCommand="npm test" 覆写 go.mod 先定命令——违反 L41-42 自身契约 "earlier entries take priority")+ L328(Contains(mf,"TAGS") —— DOCKER_TAGS/IMAGE_TAGS/BUILD_TAGS 任意命中注入 -tags goolm)+ L332(BuildSystem="Make" 在 goolm if 外无条件覆写 go.mod 先设的 "go"——配对不一致 BuildCommand 仍 go build);knight.go L162-179(三字段独立回退——仅设 knight.vendor: anthropic 时拼 anthropic + <主配置 openai 端点id>——endpoint id 是 per-vendor 作用域(config_vendor.go L34 双层查找实证)→ 或报 "endpoint not configured for anthropic"(意图是回退默认却得错)或同名 "primary" 静默解析错厂商)

问题

案 A(Med):VendorPresets 端点 map 无序——向导预选随机端点

  • 任何多端点 vendor 两次启动预选不同;TUI endpointCursor 随机起点+桌面 DefaultEndpoint 随机标志
    :迭代前对端点 key 排序,DefaultEndpoint 取排序后首个。

案 B(Low-Med·死代码潜伏):mcp_patch ws 缺席+无大小写规范化

  • PatchMCPServerConfig 零调用方(复核修正降级)——若被接线则 ws 服务器 patch 即清 URL 落盘;活跃路径 config_vendor 小写版不受影响
    :接线前补 "ws" case+ToLower;或删除死实现防误用。

案 C(Low-Med):npm 探测覆写 go.mod 命令——违反自身优先级契约

  • Go+package.json 混合仓库(本仓库自身即如此)必触发:go build 被 npm run build 覆写;依赖名含 "test" 字样同误命中
    :npm 检测仅填空不覆写(对照 L41-42 契约)。

案 D(Low×2):TAGS 子串误注入 goolm + BuildSystem/BuildCommand 配对不一致

:TAGS 匹配收紧为 goolm tag 用法模式;BuildSystem 覆写移入配对逻辑。

案 E(Low):knight 逐字段回退跨 vendor 拼凑

  • 部分配置语义缺陷——endpoint/model 应回退目标 vendor 默认而非主配置裸 id
    :knight.vendor 非空时 endpoint/model 用该 vendor 的 DefaultEndpoint/DefaultModel。

干净项

secure_write 全维度无案(原子写/0700+0600 双保险/symlink rename 原子替换/tmp 清理/并发)。knight:#559 已修项在位(MarshalYAML 重注入/显式标记追踪);daily_token_budget:0 经 Save 合并语义闭环验证非 bug。onboard.go 其余:NeedsOnboard 判定链自洽/hasUsableAPIKey ${VAR} 0cbe721 修在位。project_profile 其余:无检测返 nil/appendUnique 单行格式化无问题。

排除

#1515/#1517/#1519 config 族;isMonorepo/detectProfileText 注释漂移 info 级。

严重程度

Med + Low-Med×2 + Low×3


独立复核确认:5/5 属实——消费方索引链、ws 支持证据+PatchMCPServerConfig 零调用方降级(活跃路径不受影响)、契约原文+无条件覆写、子串误命中例、per-vendor 作用域双层查找实证。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions