Repository navigation
feat: report client project directory to proxy sessions (x-bili-plugin-cwd) - #1516
ranxianglei wants to merge 3 commits into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1740-pr.1516.1ef6912This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1516.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Acknowledged. Starting review of PR 已接单,正在按规范审查该 PR(方向核对、回归审查、代码与测试有效性、diff 整洁度),结论稍后给出。 |
Review — verified, mergeable ✅Reviewed the full diff on ① Direction vs #1406. Correct scope: this lands exactly the transport that #1406 item 2 (proxy-mode ② Regression audit — pre-existing behaviors of touched paths:
③–④ Code & test validity. Clean. The 7-test suite has teeth: boundary values (exactly 4096 passes / 4097 rejected), the sneaky-gate case (cwd without ⑤ Diff cleanliness. Every line serves the PR purpose; the stale PLUGIN.md manifest example fix (pre-dated Behavior changes (confirmed additive-only): register POST bodies gain optional Verification evidence: CI on head One process note: open refactors #1449 and #1446 both restructure I can't merge PRs — system rules forbid it. Please merge yourself: #1516 中文摘要:审核了 #1406 的项目级 rules 传输前置件(client cwd 上报,header + register 双通道、会话级 latest-wins 绑定),方向正确、无回归、测试有效且 CI 全绿(13/13),仅两处非阻塞的测试覆盖小建议,可以合并。 |
Part of #1406 — the bili-side transport for project-level rules. The key-value / digest redesign itself stays blocked on acp-kernel#446 (latest kernel 0.0.97 still ships the old rule API); this PR lands the one piece that does not depend on it: making the client's project directory available to the proxy.
Why
#1406 item 2 needs
<cwd>/rules.mdresolution server-side. The proxy's ownprocess.cwd()is wrong whenever a launcher attaches to an already-running proxy started elsewhere, and pure/bili/clients send nothing today. Without this channel there is no safe way to seed project rules in proxy mode.What changed
x-bili-plugin-cwd(src/plugin.ts): stamped by every cooperative host (pi, opencode V1/V2, dsh-native) with itsprocess.cwd(). Same plugin gate as the otherx-bili-plugin-*runtime headers; validated at every entry (string, trimmed, ≤4096 chars, no CR/LF) so session metadata can never carry control characters or unbounded strings.cwdfor launcher lanes that cannot stamp headers (opencode/pi viapostIdentityRegister, mcp shell,bili plugin register).session.metadata.clientCwdbinding insrc/server.ts: per-request header value wins (latest-wins, tracks mid-session/cd, persisted via markDirty); register-payload seeds only-if-absent at both binding sites (identity + pending). Pure/bili/clients degrade gracefully — no field sent, metadata stays unset, global-only rules apply later.headers.cwdso third-party plugins learn the name; goldens regenerated viascripts/update-wire-contract-goldens.ts(additive line only).maxOutput/model).Behavior changes (flagged)
cwd— additive field, older proxies ignore unknown fields.headersobject gains acwdkey — additive.clientCwdkey — additive, inert until the rules follow-up consumes it.Golden changes
tests/golden/wire-contract/manifest-{default,optin}.json: one added line each (cwdheader name), regenerated by the standard script — justification: advertising the new optional header to third-party plugins.Pre-flight
tests/issue1406-client-cwd.test.ts(7 tests): validation rejections, plugin-gate, register threading (both paths + legacy shape unchanged), headless pending seed, identity seed, header-wins-over-stale-register +/cdlatest-wins, oversized-header rejection.Remaining #1406 items (executeRule key/value upsert, digest injection, proxy-mode rules.md seed) land in a single follow-up PR once acp-kernel#446 is released.