Skip to content

[PR] feat: WorkBuddy Desktop lane — settings-file routing + auto-compact gate (#7456) - #7457

Merged
ranxianglei merged 5 commits into
masterfrom
2026-11-21_workbuddy-lane
Nov 21, 2026
Merged

ranxianglei merged 5 commits into
masterfrom
2026-11-21_workbuddy-lane

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

What changed

New workbuddy plugin lane: WorkBuddy Desktop (Tencent Electron app, @genie/workbuddy-desktop) embeds a CodeBuddy Code CLI fork for all agent sessions — the desktop-hosted sidecar and manual terminal runs are that CLI. Two decompiled facts make a pure settings-file lane sufficient (evidence in the issue):

  1. The CLI resolves env.CODEBUDDY_BASE_URL from its user settings file before process.env (per-key settings read) — the app spawns its CLI with an explicit env allowlist, so shell exports never reach it, but the settings file does.
  2. Settings key autoCompactEnabled: false skips all non-forced auto-compaction (manual compaction survives) — the dsh-compaction-gate equivalent, so bili owns compression.
  • bili plugin install workbuddy writes ~/.workbuddy/settings.json (WORKBUDDY_CONFIG_DIR/CODEBUDDY_CONFIG_DIR override): wraps env.CODEBUDDY_BASE_URL into the pinned origin (BILI_WORKBUDDY_PROXY override; default resident http://127.0.0.1:8787) and sets the auto-compact gate. Foreign base URLs and an explicit autoCompactEnabled: true are reported, never clobbered (claude-lane ownership rules). Install warns when no live proxy is recorded at the pinned origin (origin-matched instance-file + pid liveness, so a stale record or a live other-lane instance never fakes health).
  • bili plugin remove workbuddy / plugin list row / doctor lane strip exactly the bili-owned values; .bili-bak snapshot semantics shared with the other lanes.

Per-message identity (the "dsh-grade" locating half). WorkBuddy/CodeBuddy stamp their per-conversation UUID in x-conversation-id on every model request (owner-measured, #5488/#5526) and persist each message with a stable UUID + parentId chain in projects/<escaped-cwd>/<conversation-id>.jsonl. The session-key recognition for that header is already on master (low-trust tier of conversationHeaderSource); this PR extends the existing codebuddy harvest source (src/identity-codebuddy.ts) to the WorkBuddy fork's config roots ($WORKBUDDY_CONFIG_DIR / ~/.workbuddy) on top of the CodeBuddy ones — same header, same jsonl schema (verified in the decompiled 5.11.4 bundle: the fork reuses the exact getHomeProjectsDir + compressPath(cwd) + ${conversationId}.jsonl persistence path). A conversation id present under BOTH config roots yields two files and the whole turn degrades to no-ids (conservative by construction). Roster row + adapter docs updated; new fixture tests cover the workbuddy root and the cross-root collision.

Design notes

  • Pure wire mode by design — no MCP entry, no plugin-mode header. Desktop-spawned sessions run --strict-mcp-config, which blocks every user/project/local MCP scope, so a host tool face is impossible for the app's own sessions; stamping the header globally would degrade exactly those sessions (the zcode degraded mode, [Feedback] Noticed during testing that Zcode doesn't seem to trigger compression very often. | [反馈]在测试途中发现Zcode好像不怎么会触发压缩 #4344). Compression rides the proxy (acp_summary carrier), like every OpenAI-wire lane. A terminal-only MCP face is a possible v2 follow-up (dual tool-surface tradeoff, noted in the issue).
  • No wire/format changes in either compression mode: the lane is config-write only on the existing /bili/ forward; the client's own /v2/chat/completions OpenAI path and SSO auth headers pass through untouched (no TLS pinning / client signing on model traffic, verified in the bundle).
  • New env vars (explicit user overrides, documented): BILI_WORKBUDDY_PROXY (origin pin) and BILI_WORKBUDDY_UPSTREAM (relay wrap instead of https://www.workbuddy.ai) — registered in the lifecycle ledger §2.6 and the configuration env tables.
  • No new config-file fields; package.json version untouched; no model-facing text changes.

Config surface

No bili config-file fields added. Two env-only user overrides (BILI_WORKBUDDY_PROXY, BILI_WORKBUDDY_UPSTREAM), both documented (lifecycle ledger + configuration.md/zh/ja + clients.md/zh WorkBuddy sections).

Pre-flight (local, rebased onto branch head incl. the two ci-check commits)

  • npm run typecheck — clean
  • npm run build — clean (dist import-annotation + external checks OK)
  • Targeted tests: tests/workbuddy-plugin-install.test.ts (15 tests) + tests/plugin-agent.test.ts + tests/identity-harvest.test.ts (incl. the new workbuddy-root + cross-root-collision cases) — all pass
  • Guards: config-surface-guard OK, lifecycle-ledger-guard OK, tools/check-architecture-docs.mjs all green
  • Full-suite verdict: remote CI test lanes on this head (local full-suite runs are environment noise per AGENTS.md)

Closes #7456

…ate (#7456)

WorkBuddy Desktop embeds a CodeBuddy Code CLI fork for every agent session.
The CLI reads env.CODEBUDDY_BASE_URL from its user settings file BEFORE
process.env (decompiled evidence in #7456), so a managed block in
~/.workbuddy/settings.json routes desktop-spawned AND terminal sessions
through the resident proxy — the app's explicit spawn env allowlist makes
shell exports unreachable.

- bili plugin install wb: wraps env.CODEBUDDY_BASE_URL into the pinned
  origin (BILI_WB_PROXY override; default http://127.0.0.1:8787) and sets
  autoCompactEnabled:false — bili owns compression, manual compaction
  survives. A foreign base URL and an explicit autoCompactEnabled:true are
  reported, never clobbered. The install warns when no live proxy is
  recorded at the pinned origin (origin-matched instance-file liveness).
- bili plugin remove wb / status row / doctor lane: strips exactly the
  bili-owned values; .bili-bak snapshot semantics shared with other lanes.
- Pure wire mode by design: desktop-spawned sessions run --strict-mcp-config
  (user MCP scopes blocked), so a host tool face is impossible for the app's
  own sessions; compression rides the proxy (acp_summary carrier). No
  wire/format changes in either compression mode — the lane is config-write
  only on the existing /bili/ forward.

Docs: clients.md/.zh-CN WorkBuddy sections, architecture lanes pages
(en/zh/ja), configuration env-var tables, lifecycle ledger
(BILI_WB_PROXY/BILI_WB_UPSTREAM).
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-21_workbuddy-lane (29ff580)

Latest build — install this exact version

npm install -g billion-context@0.0.11208-pr.7457.0d986e5

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
29ff580 billion-context@0.0.11208-pr.7457.0d986e5 build
e6cdf42 billion-context@0.0.11203-pr.7457.e5903a2 build
9dfd2a9 billion-context@0.0.11200-pr.7457.8fe9dfe build
a2610a5 billion-context@0.0.11199-pr.7457.1bcf1b0 build
37f1ac6 billion-context@0.0.11197-pr.7457.384817d build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr7457.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title feat: WorkBuddy Desktop lane — settings-file routing + auto-compact gate (#7456) [PR] feat: WorkBuddy Desktop lane — settings-file routing + auto-compact gate (#7456) Nov 21, 2026
ranxianglei and others added 2 commits November 21, 2026 17:37
#7456)

docs/configuration.*.md is generated from website/config-reference/*.yaml
(docs-sync lane) — add the two workbuddy env pins to env-only.yaml and
regenerate instead of hand-editing the table. check-coverage now passes.
pinnedOriginLive hand-rolled process.kill(pid, 0) in a try/catch, which treats
EPERM (process exists but unsignalable) as dead. The codebase canonical helper
isPidAlive (src/instance.ts) already returns true on EPERM and false on ESRCH.
Use it for correct liveness semantics and DRY. No behavior change for the
same-user proxy case EPERM would only arise from.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重 (duplicate screening): Not a duplicate. Mirror #7458 is the source feature-request issue this PR closes ("WorkBuddy Desktop: route its model traffic through bili"), not a parallel implementation. Mirror #5826 is the unrelated per-client message-id identity-channel investigation (it lists codebuddy only as one of many lanes to study). This PR (#7457) is the only WorkBuddy-lane implementation.

What I did — review + one in-passing fix:

Reviewed the lane end-to-end and found two CI checks red on the original head (37f1ac6c053): docs-coverage and docs-sync. Root cause: the lane reads BILI_WB_PROXY / BILI_WB_UPSTREAM in src/plugin-install.ts (lines 2264/2275/2358) but the PR added rows only to the generated docs/configuration.*.md tables + the lifecycle ledger — not the source-of-truth seed website/config-reference/env-only.yaml. docs-coverage (check-coverage) fails on an env var read in src with no seed entry; docs-sync (generate + git diff --exit-code) fails because the hand-edited .md rows drift from the seed-generated output.

You'd already fixed that in a2610a5223f (seed + regenerate), so I dropped my redundant seed commit and kept only one in-passing fix:

  • 9dfd2a9b2f7 refactor(wb): use isPidAlive in pinnedOriginLive — pinnedOriginLive hand-rolled process.kill(pid, 0) in a try/catch, which treats EPERM (process exists, unsignalable) as dead; the codebase canonical isPidAlive (src/instance.ts:498) returns true on EPERM. Switched to it (+ import). Edge-case correctness + DRY; no behavior change for the same-user proxy case. Verified: npm run typecheck clean, tests/wb-plugin-install.test.ts 15/15, tests/plugin-agent.test.ts green. (Minor: PR description says "17 tests"; the file has 15 — immaterial, all pass.)

CI on the new head (9dfd2a9b2f7): docs-sync ✅, docs-coverage ✅, config-surface-guard / lifecycle-ledger-guard / kernel-guard / architecture-docs / all gates ✅. The test shards (ubuntu/windows × node 22/24 × 5) are still queued/running — the full-regression green is pending on the pushed head (local targeted + typecheck are green; per AGENTS.md the full-suite verdict is the remote CI lanes).

Labels: could not apply triage labels — the ework shim does not implement the labels endpoint (GET /labels and /issues/7459/labels both return endpoint not implemented in ework shim), and tools/add-label.sh is not present in this repo. Flagging rather than claiming it.

Code review (independent of the issue text): logic is sound — applyWbManagedSettings never clobbers a foreign CODEBUDDY_BASE_URL, honors an explicit autoCompactEnabled: true, sets false otherwise, and preserves a wrapped relay; stripWbManagedSettings removes exactly the bili-owned values; isBiliWbBaseUrl only matches loopback /bili/ wrappers; pinnedOriginLive is origin-matched + pid-liveness. No wire/message-shape change (config-write only on the existing /bili/ forward; the client's /v2/chat/completions OpenAI path and SSO/X-User-Id auth pass through untouched). No config-file fields (two env-only vars, documented in lifecycle §2.6 + configuration.md/zh/ja + clients.md/zh). No model-facing text. No version bump.

判定: 可合 — once the test shards go green on 9dfd2a9b2f7. No regression, no cache impact, no design change.


8 问(中文,供 reviewer):

  1. 是什么问题:为 WorkBuddy Desktop(Tencent Electron 应用内嵌的 CodeBuddy CLI fork)新增 wb 插件车道,把它的模型流量路由进 bili 做压缩,并关掉它的自动压缩让 bili 接管。
  2. 什么原因导致的:该 CLI 从用户 settings 文件读 env.CODEBUDDY_BASE_URL(优先于 process.env),且 autoCompactEnabled: false 可跳过非强制自动压缩——所以纯 settings-file 车道就足够,无需 MCP/插件头。
  3. 影响范围与严重程度:纯新增车道,不影响任何既有车道/客户端;未安装 wb 的用户零影响。无外部影响面。
  4. 怎么修复的(本次 review 的修复):CI 红是 BILI_WB_PROXY/BILI_WB_UPSTREAM 只在生成产物 .md 表里加了行、没进 source-of-truth seed env-only.yaml,导致 docs-coverage+docs-sync 红;owner 已在 a2610a5223f 补 seed + 重新生成。我另加一个顺手小修:pinnedOriginLive 改用 codebase 规范的 isPidAlive(EPERM 语义正确 + DRY)。
  5. 是否有回归问题:审过 applyWbManagedSettings/stripWbManagedSettings/isBiliWbBaseUrl/pinnedOriginLive 全路径——不覆盖外部 CODEBUDDY_BASE_URL、尊重显式 autoCompactEnabled:true、只剥 bili 自有值、origin 匹配 + pid 存活;isPidAlive 改动对同用户 proxy 场景无行为变化。无回归。
  6. 是否破坏缓存:不涉及——纯 settings 写,不碰压缩引擎/缓存/重试/去重键。
  7. 是否改了设计方向:不涉及——沿用既有 /bili/ 转发 + proxy 模式(acp_summary 载体),与所有 OpenAI-wire 车道一致;纯 wire 模式(桌面 spawn 的 CLI 跑 --strict-mcp-config,故无 MCP face)。
  8. 是否引入了新的配置:新增 2 个 env-only 用户覆盖项 BILI_WB_PROXY(origin 钉死,默认 http://127.0.0.1:8787)、BILI_WB_UPSTREAM(relay 封装,默认 https://www.workbuddy.ai),均已文档化(lifecycle §2.6 + configuration.md/zh/ja + clients.md/zh);无 config-file 字段,无默认值漂移。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Final CI green confirmed on head 9dfd2a9b2f7: all 11 test shards (ubuntu/windows × node 22/24 × 5) now success; every other check (docs-sync, docs-coverage, config-surface-guard, lifecycle-ledger-guard, kernel-guard, architecture-docs, mysql-contract, lock-sync, build-artifact, gates, …) success/skipped. No reds.

判定: 可合 ✅ — full regression green, no regression, no cache impact, no design change. Ready for you to merge (merge is human-only per AGENTS.md).

ci-check and others added 2 commits November 21, 2026 18:10
The WorkBuddy CLI resolves WORKBUDDY_CONFIG_DIR || CODEBUDDY_CONFIG_DIR
(|| semantics), but wbConfigDir used ?? (null/undefined only). An
empty-string WORKBUDDY_CONFIG_DIR plus a set CODEBUDDY_CONFIG_DIR made
bili write to ~/.workbuddy while the CLI read CODEBUDDY_CONFIG_DIR, so
the routing silently never took effect. Change ?? to || to match the CLI
exactly, and add a regression test for the empty-string edge.
@ranxianglei
ranxianglei merged commit 9bf4d48 into master Nov 21, 2026
48 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1255-master.9bf4d48 (rolling master tag).

npm install -g billion-context@0.0.1255-master.9bf4d48  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WorkBuddy Desktop: route its model traffic through bili (settings-file lane) so the wb app gets in-app compression like dsh

1 participant