Repository navigation
fix(launcher): warn when opencode project-layer config bypasses the proxy - #844
Conversation
…roxy opencode's config precedence puts the project layer above the $OPENCODE_CONFIG tempfile the launcher uses to deliver rewritten provider base URLs, so project-level providers silently bypass the proxy (no compression, no warning). Detect the project layer with the same walk rules opencode uses (git-bounded ancestor walk, .opencode dirs, jsonc comments/trailing commas, nearest level wins) and print a per-provider warning naming the offending file. No runtime behavior change. Fixes #843
a1396f9 to
0b64514
Compare
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-844Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr844.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Windows CI: path.resolve('/x/y') yields D:\x\y there, so asserting the
POSIX literal verbatim only holds on POSIX. Use a real mkdtemp abs path
(resolve preserves it on every platform) instead.
[bot] 🏷 Review complete — branch rebased onto current master, one CI-breaking test bug fixed, everything green. Ready for you to merge. Code review (the change itself)
What I had to do (branch was 78 commits behind master)
Verification on final head
Residuals from your write-up stand (noted, not blocking): 一句话中文:分支落后 master 78 个提交无法直接合并——已 rebase 解决三处冲突(均为相邻新增、无逻辑交集),顺手把 PR 里 ~80 行手写 jsonc 解析替换为复用 master 已有的 readConfigFileRoot,并修复了 Windows CI 上因 |
|
继续 |
#843 的修复(方案 (b):检测+警告,issue 中 owner 建议的最小可行路径)。
根因(已 hands-on + 源码双重验证)
launcher 经
$OPENCODE_CONFIG=<临时文件>(env 级)交付改写后的 provider baseURL,但 opencode 的配置优先级是 project 层 > $OPENCODE_CONFIG > global XDG(本机 opencode 1.14.46opencode debug config实测,并对照 sst/opencode dev 分支packages/opencode/src/config/paths.ts/config.ts合并顺序确认):readOpencodeConfig只读 global + $OPENCODE_CONFIG,discovery 根本看不到它 → 无改写、无警告。改动(仅检测+警告,不改变任何运行时行为)
src/client-config.ts:新增readOpencodeProjectLayer(cwd)—— 复刻 opencode 的项目层发现规则:从 cwd 向上走到 git 根为止(无仓库则到文件系统根);每层检查<dir>/opencode.json{,c}与<dir>/.opencode/opencode.json{,c};支持 jsonc 注释与尾逗号;同名 provider 由最近层胜出,记录 blame 文件。src/launcher.ts:新增opencodeEffectiveCwd(识别 opencode 唯一的配置相关 flag--dir)与opencodeProjectBypassWarnings:项目层中未被 bili 路由的显式 baseURL(/bili/wrapped 形式或已在 MITM domains 的 https host 视为已路由)分两类警告——重定义了 discovery 可见的 provider,或仅存在于项目层;baseURL 缺失的条目会经 opencode deep-merge 继承交付值,不告警(避免误报)。launch 时逐条打印,风格对齐 hermes/kimi 先例("traffic will NOT go through the proxy")。tests/launcher.test.ts:新增 4 个测试(git 边界 walk/nearest-wins/.opencode 目录/jsonc、无 git 多层 walk、--dir解析、警告矩阵含各静默场景)。验证
npm run typecheck✅npm test:1515 pass / 0 fail / 2 skipped(gated e2e)npm run build✅BILI_CLIENT_BINshim + 伪造 HOME):项目目录跑bili opencode精确打印两条预期警告(含 blame 文件绝对路径);干净 cwd 无任何警告。遗留(报告,不在本 PR 范围)
OPENCODE_CONFIG_DIR环境变量同样压过$OPENCODE_CONFIG(同类绕过,更罕见)——留给后续评估;Fixes #843