Repository navigation
feat(#1958): expose conflicting pre-routed /bili/ opencode configs at install and runtime - #1972
ranxianglei wants to merge 3 commits into
Conversation
… install and runtime "Native plugin + hand-written /bili/ provider baseURL" is a conflicting configuration: two mutually exclusive access paths claiming routing ownership of the same requests. It used to be silently absorbed (missing plugin identity, proxy-mode degradation, #1958/#1959). Now it is exposed: - install: bili plugin install opencode scans the real effective config surface (global candidates in opencode's own merge order + OPENCODE_CONFIG + cwd project layer) and refuses with exit code 1 when any provider baseURL carries a /bili/ prefix — listing file/provider/baseURL per hit plus the two-way fix-it guide. Effective-surface semantics mean an overridden stale entry never false-positives. Nothing is written before the check, so the failure is clean. - runtime: the V2 native route warns (console.error) once per (session, origin) on a pre-routed model URL with the same guide. An explicit pin of the SAME origin (BILLION_CONTEXT_PROXY pointing at the proxy the URLs already ride) is the supported attach posture and stays silent — compared against the env (URL.origin-normalized), not state.origin, because attach arming does not freeze state.origin synchronously. Stamping still binds to the baked origin (#1959 fallback); pinned-channel semantics (#1365/#1370) are untouched.
The launcher / native-plugin / pure-proxy paths each own routing of the same requests; exactly one may be active per host instance. A hand-written /bili/ provider baseURL is the pure-proxy path's marker — writing it while the native plugin is installed is a conflicting configuration that is now exposed: install refuses (exit 1, listing file/provider/baseURL), and the runtime warns once per session with the same fix-it guide. The supported exception is an explicit pin of the same origin (BILLION_CONTEXT_PROXY pointing at the proxy the URLs already ride), which stays silent.
[bot] 🏷 收到,按 [PR] 流程处理(不重做工作):拉分支核对代码 + CI 状态 + 回归审查。 已核实:
审查中发现一个本 PR 引入的测试确定性问题,正在 PR 分支上直接修: |
…s exposed by the #1972 scan The new install-time /bili/ scan reads the real effective config surface (process.env + cwd), so pluginInstall("opencode") now depends on the ambient global opencode config. Four test sites in this file isolated OPENCODE_CONFIG but not XDG_CONFIG_HOME, so on any machine whose real ~/.config/opencode carries pre-routed /bili/ provider baseURLs (exactly the user group #1958 targets) the suites fail for environmental reasons (§7.2: tests must be deterministic). Pin XDG_CONFIG_HOME into the fake home at all four sites. Verified: with a poisoned ambient XDG (pre-routed baseURL present) the suite went from 6 failures to 62/62 green; clean environments stay green.
[bot] 🏷 Review 完成 — 分支已核对、代码逐行审过、定向验证全绿、CI 状态已确认。审查中发现并已在 PR 分支直接修复一个测试确定性问题(commit ① 原 issue 方向关(最高优先)维护者指令(#1958 floor 4)要求:安装时检测+评估拒绝、运行时去重警告、良性钉住不误报、module-eval seam 评估、文档写明三路径互斥、给出 (a)/(b) 分析。PR 逐条落实且方向正确:安装时选了拒绝(比警告更强,理由成立——检查点在一切写入之前,失败零副作用);module-eval 评估结论有据(V2PluginContext 只暴露模型清单,无 provider-baseURL seam,#1569);(a)/(b) 按我此前推荐的 (a) 实现并在 PR 正文注明 (b) 的 delta。#1959 遵嘱未合并,等你定夺。方向无问题。 ② 回归审查(既有行为清点)逐项审过 diff 触碰路径的既有行为:
有意行为变更(old → new,PR 已披露,我复核成立):
③ 代码审查(主关)
④ 测试有效性8 例新测试都是真测试:驱动真实 ⑤ diff 整洁度10 文件 +512/-6,每行都与本 PR 目的相关;无空白重排、无 lockfile/生成物变动;3 个线性提交 stack 正确。干净。 审查中直接修掉的问题(commit f9fdf2d,已在 PR 分支)新扫描让 CI 状态与门禁说明
结构化七问
判定可合(人工执行):#1972 代码/测试/文档均达标,CI 在 PR 层面能跑的全绿,全矩阵随合入 master 的 push 把关;合并前先给 (a)/(b) 定夺(当前实现 = a)。合并顺序:先 #1959 再 #1972,或直接合 #1972(带入两 PR 全部提交)皆可。 |
…e config — expose, don't absorb, don't gate install Maintainer direction change on ranxianglei#1958: the 'native plugin + hand-written /bili/ provider baseURL' combo is a conflicting configuration (two access paths claiming routing ownership of the same requests). The correction is a loud runtime warning — not silent compat (no stamping/rewrite, the request stays on the plain-proxy path it encodes) and not an install-time refusal (a scanner false positive would permanently block installs). - src/agent/opencode-native.ts (createNativeRoute): on a pre-routed model URL, warn once per (session, origin) unless BILLION_CONTEXT_PROXY pins the SAME origin (supported attach posture — compared via URL.origin so trailing-slash/default-port spellings fold; env, not state.origin, because attach arming does not freeze state.origin synchronously). No behavior change to the request itself: ranxianglei#1365 pinned-channel recording (noteRoutedOrigin) and the isModelApiUrl fall-through are untouched; s.proxyBase stays unset for pre-routed URLs. - tests/issue1958-routed-warn.test.ts: 4 cases — dedup per (session, origin) + no stamping; benign pin silent incl. port folding; mismatched pin warns; non-model /bili/ paths and /__bili/health never warn. - CLIENTS(.zh-CN).md / CONFIGURATION(.zh-CN).md: the three OpenCode access paths are mutually exclusive; runtime warning + fix-it guide documented. Supersedes ranxianglei#1959 (silent stamping) and ranxianglei#1972 (install refusal + stamping).
Stacked on #1959 (head
2026-10-03_opencode-v2-routed-proxybase). Closes #1958 once both land — #1959 fixes the missing-stamp defect; this PR implements the maintainer-directed conflict exposure for the same root configuration.What
"Native plugin + hand-written
/bili/provider baseURL" is a conflicting configuration: two mutually exclusive access paths claim routing ownership of the same requests. It used to be silently absorbed (#1958: missing plugin identity headers → proxy-mode degradation). Now it is exposed loudly:bili plugin install opencodescans the real effective config surface (global candidates in opencode's own merge order + OPENCODE_CONFIG + cwd project layer) and refuses with exit code 1 when any provider baseURL carries a/bili/prefix, listing every hit as file/provider/baseURL plus the two-way fix-it guide. Nothing is written before the check.console.error) once per (session, origin) on a pre-routed model URL with the same guide. An explicit pin of the SAME origin (BILLION_CONTEXT_PROXYpointing at the proxy the URLs already ride) is the supported attach posture (bug: dsh-native — attach 目标瞬时不可达 → 回退 spawn 第二实例:routed baseURL 下工具/模型通道必然脑裂(工具 404 → preflight 502 → 会话不可自愈) #1365/fix: never spawn over a pinned model channel when the attach target is down (#1365) #1370 pinned-channel semantics preserved) and stays silent.Behavior changes (old → new)
bili plugin install opencodeover a config carrying pre-routed/bili/provider baseURLs: succeeded (plugin installed alongside the prefix) → refused, exit 1, nothing written. Why: the combo is defined as misconfiguration by owner direction (maintainer comment on [Bug][OpenCode V2] 已带 /bili/ 前缀的模型请求跳过 proxyBase 初始化,缺失插件会话标记 #1958); silent coexistence produced the [Bug][OpenCode V2] 已带 /bili/ 前缀的模型请求跳过 proxyBase 初始化,缺失插件会话标记 #1958 defect class.console.errorper (session, origin) with fix-it guidance. Benign same-origin pin: unchanged, silent. Wire behavior unchanged: request URL untouched,s.proxyBasebound to the baked origin exactly as in fix(#1958): bind V2 hook proxyBase to the baked origin on already-routed model requests #1959.Notes
s.proxyBase = bakedline and flip the two binding assertions — the detection/warning/docs layers stand unchanged.