Repository navigation
feat: in-process pi compression entry (true non-server native) — deprecates billion-context-pi - #2008
ranxianglei wants to merge 6 commits into
Conversation
[bot] 🏷 收到,开始 review。初步状态:PR open、非 draft,GitHub 报 |
Conflict resolution (union of intent): - tsup.config.ts: noExternal gains both "ws" (master, preflight transport resilience) and "typebox" (this PR, inlined build-time dep). - README.md: pi row keeps this PR's in-process-default semantics (#1988) plus master's #2000 entry points (bili pi launcher / bili plugin install pi).
…ess changes (#2008) Mirror the EN doc updates this PR introduced (pi row in 'Which do I need?', native-vs-standalone paragraph, install note bullet, status paragraph, BILI_PI_INPROC env-var row, acp_summary carrier reference) into the zh-CN twins. AGENTS.md 7.3: keep zh/en in sync.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2037-pr.2008.8f0886bThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2008.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 Review 完成 — 判定:HOLD(方向通过、代码质量良好,3 个合并阻塞项,均已验证非猜测) Review 期间已完成的分支工作(2 个额外 commit,已推送,fast-forward):
结构化七问:
合并阻塞项(CI 实测,head ① typecheck 门禁红:CI 的
② e2e-native-pi(真 pi e2e)红,与 PR 直接相关: ③ 建议合并顺序:先合 #2007(修 master 那 12 个)→ 本 PR re-sync → 修 ① 的 173 + ② 的 e2e → CI 绿 → 合。否则本 PR 修完 CI 仍会因 master 残留而红。 CI 证据(head 其他发现(不阻塞):AGENTS.md 里 "master pins acp-kernel 0.0.100" 一句已过时——master 实际 pin 0.0.101(本 PR 未动 pin,auto-merge 取到的是 0.0.101)。一词陈旧,留给 owner 顺手处理。 判定:HOLD。 方向、设计、代码质量全部通过;被 ① 173 个测试 typing 错误 + ② e2e-native-pi 断言更新 + ③ #2007 合并顺序卡住。三项修完预计即可合入。若需要,我可以在本分支继续:分别以独立 commit 修 ① 和重写 ② 的断言,CI 绿后回报。 |
4d48231 to
3a4ab65
Compare
|
[bot] 🏷 Rebased onto current master (33d58e5, v0.1.181) and pushed (head 3a4ab65). Two follow-on commits on top of the rebased feat:
Local battery: typecheck 0 errors; build OK; targeted suite 876 tests / 873 pass / 0 fail / 3 skip. Watching CI. |
3a4ab65 to
edd68b5
Compare
edd68b5 to
a739d26
Compare
e2e-native-pi fix (head a739d26)The Root cause: the suite drove real pi with the repo root installed as a package and asserted the server-based lane's behavior (per-request x-bili-plugin stamping, proxy instance records, proxy-side session persistence). This PR flips Fix — the suite now covers BOTH postures of the pi lane:
Also added Verified locally before pushing: full gated suite green 5/5 against real pi 0.83.6 (previously-failing assertions included). Working tree content is byte-identical to what the previous CI run saw (only the commit split changed: the e2e update moved into the feat commit; the typecheck-gate fix commit keeps its 4-file scope). |
EN TECHNICAL-NOTES.md already says src/agent/pi-inprocess/messages.ts; the zh twin still cited billion-context-pi's src/messages.ts after the rebase. One-line zh/en sync.
[bot] 🏷 Round 2 验证完成 — 两个阻塞项均已解决并独立核实,剩一个我顺手修掉的小问题。判定:CI 绿即可合。 对上一轮阻塞项的独立核实(不是只看你说绿): ① typecheck:新 head ② e2e-native-pi:读了新增第五个测试的断言,有牙:逐请求断言直连( 其他核对:
顺手修掉的一个小问题(独立标注 commit,已推送): CI 现状: 判定:READY(待最终 CI 绿)。 方向、设计、代码、测试有效性、diff 整洁度全部通过;无回归发现;无缓存破坏;设计变更即 #1988 本身且已披露;唯一新配置 |
…refix (#2008) The repo's #816/#828/#1615 family gate (tests/text-safe.test.ts) scans src/ for raw negative .slice(-N) on strings outside its allowlist and failed CI on this head: four vendored sites predate #1615 on the bcp side. Replace them with the dependency-free clamps from src/text-safe.ts (the gate's own prescription): - compress-tool.ts summaryFingerprintLine: head/tail excerpts are model-visible integrity fingerprints — both cuts now clamped - live-only-tail.ts weakMessageSig: internal dedup signature tail - update.ts entry-import smoke reason + auto-install-failed log tail Byte-identical output for ASCII input; surrogate-boundary cuts become safe instead of emitting lone halves. No behavior change otherwise.
[bot] 🏷 Round 3 — 修正我上一轮的 READY:最终 head 的主 CI 出了第 4 个阻塞项,已定位并修掉(已推送 先认错:上一轮说「待最终 CI 绿」时,全量 test matrix 在更早的 head 上还没跑完就被新 push 顶替了,所以我没看到它红。最终 head 根因(已本地复现):仓库的 #816/#828/#1615 家族闸门
作者本地跑的是定向电池(pi-inprocess 套件 + 直接受影响套件),没覆盖 修复(独立标注 commit 本地验证:闸门测试转绿;gate + compress-tool + live-only-tail(+cache) + state + wiring 共 77/77 过; 顺带确认(master 侧,不属本 PR):master 自身在 另外:你们会话在我 doc fix 之上又加了一个 devlog-only commit( 判定:HOLD(等 |
…pare (#2008) Windows CI checkouts materialize text fixtures as CRLF (core.autocrlf); the in-memory template buildAcpSystemPrompt produces LF, so the byte-identical assertion failed only on windows-latest (ubuntu green). Normalize at read time — the fixture records an LF template, CRLF is a checkout artifact. Verified A/B locally: test passes with both a CRLF-converted and the original LF fixture.
[bot] 🏷 Round 4 — 根因(已本地复现): 修复(独立标注 commit 判定:HOLD(等 |
[bot] 🏷 Round 5(终局)— head 判定:READY。 四轮 review 的全部发现均已闭环:① 173 个移植测试 typing 错误(作者修)② e2e-native-pi 双姿态覆盖(作者修)③ master 残留 typecheck(fix commit 内,建议合前关闭 #2007 为 superseded)④ slice-family 闸门违规(review 修, 可以合并了(人工操作): #2008 ——按仓库规则我不执行合并。合并前请顺手处理两件事:1) 关闭 #2007(superseded by this PR 的 fix commit);2) AGENTS.md "master pins acp-kernel 0.0.100" 一词陈旧(master 实为 0.0.101)。 收工。 |
Closes #1988
What
Vendors the billion-context-pi compression core into this repo as a new tsup entry
dist/agent/pi-inprocess.js(source:src/agent/pi-inprocess/, 46 files) and makes it the default pi extension (package.jsonpi.extensions). Compression runs in pi's own process; model traffic goes direct to upstream — no local server, no fetch patching, no watchdog. The old server-based native (dist/agent/pi-native.js) stays reachable behind the new kill-switchBILI_PI_INPROC=0.This is the prep step for fully retiring
billion-context-pi(Phase 3 = deprecating the npm package after migration evidence — deliberately NOT part of this PR).Config surface (owner-gated section)
BILI_PI_INPROC0/false/off/no(case-insensitive). When set, the pi entry delegates at load time to the server-based native path instead of running in-process. Read once at extension load → restart pi after changing.Why a new key instead of an existing mechanism:
BILI_NATIVE_PIgoverns the server-based entry's plan (off/attach/spawn) and does not exist in the in-process entry's decision space;BILLION_CONTEXT_PLUGIN=0disables the shared plugin tooling, not the engine posture. The new key follows the existing kill-switch family convention (BILI_*per-lane switches) and gives a one-line rollback for the default-mode flip below. Noconfig.jsonfield touched; no CLI flag.Behavior changes (disclosed)
npm:billion-contextget in-process compression without opting in. Rollback:BILI_PI_INPROC=0(restart pi); repo-level: revert this commit./__bili,/acp-cachereport, image billing/compression) do not apply to in-process sessions (they never traversed the proxy). Known gap, disclosed; follow-up fix: address all code review findings (condense, routing, session-id, dead code) #2 below.billion-context/pi(runtime entry:createAcpExtension/createRuntime/deriveChildState),billion-context/contract(sidecar schema constants + types),billion-context/contract/schema(JSON Schema file). These are the migration target for bcp host-adapter consumers (docs/host-adapter.md).typebox@1.3.34(bundled inline into the pi-inprocess entry, same discipline as acp-kernel),@earendil-works/pi-coding-agent@0.83.0+@earendil-works/pi-tui@0.83.0(kept external — host-provided at runtime; typecheck only).producerbecomesbillion-context@<version>(wasbillion-context-pi@…); console/log prefixes[bcp]→[bili-pi]; stand-down messages[billion-context-pi]→[billion-context]. The sidecar FORMAT itself is unchanged (v1, byte-compatible) — existing bcp state loads with zero migration; extras (liveRefOrigins/derivedFrom/activePack) carried through.billion-contextpackage (channel-based dist-tag from host deps), installed into pi's extensionnode_modulesroot; throttle/marker files renamed.billion-context-pi-*→.bili-pi-inproc-*under the agent dir (one-time reset; prevents cross-suppression by a legacy co-resident updater). Install-Lane Contract §2 compliant (self-heal through its own install channel; converges with the global-drivenpi updatelane within ~one check cycle).dist/agent/*.jspreviously resolved a missingdist/package.jsonand silently fell back to"dev"; it now walks up to the real package root (name-guarded). Version strings in logs/status panels are corrected for every agent entry.CompactionSummaryMessageunion member (live-only-tail.ts).Both-modes reasoning (§6)
In-process mode is a THIRD posture alongside pluginMode/proxyMode (KDD #7): like pluginMode the agent OWNS compression — call+result live in the client's own history and no
acp_summarycarrier is injected on the wire (the wire is direct; there is no proxy at all). Proxy-mode and plugin-mode paths are untouched except thepi-native.tsrefactor (module-level bootstrap extracted into idempotentstartPiNative(); standalone-entry behavior preserved incl. sync marker stamping — covered by the existing pi-native tests). Mutual-exclusion protocol unchanged: installer entry swap +BILLION_CONTEXT_NATIVEmarker (value-distinguishespivspi-inprocess; non-clobbering first-writer-wins) + both entries warn on co-resident legacy bcp (<0.1.72 lacks marker support = double-compression risk, stated in the warning).Tests
tests/pi-inprocess-*.test.ts) + fixtures; delegate/fleet/TUI tests excluded (those surfaces were not ported).tests/pi-inprocess-wiring.test.ts: kill-switch parsing + delegation (no spawn), marker symmetry (own marker ignored, foreign honored, never clobbered), every stand-down signal, legacy bcp sidecar adoption, contract smoke, no-server-spawn assertions.Scope notes / follow-ups (separate issues post-merge, 来源 marker → this PR)
~/.local/share/billion-context/sessions/so the web UI panel sees these sessions (deferred: panel-shape coupling risk could hit proxy users'/__bilipage).Post-rebase update (head 3a4ab65)
Rebased onto current master (33d58e5, v0.1.181). Conflicts resolved: README pi row (union of both changes), tsup.config.ts (kept object-form entry map; noExternal union = master's
ws+ this PR'stypebox). package.json / lock / CONFIGURATION.md / TECHNICAL-NOTES.md auto-merged.Two follow-on items, one per commit:
tests/(2e6e508). The ported suite needed typing fixes across ~33 files under acp-kernel 0.0.101 + pi-coding-agent 0.83.0 strict typings. All typing-only; where host types diverge from runtime data (AgentMessage.content typed parts-only while pi also delivers plain strings), fixtures stay byte-exact and bridge via casts. zh docs synced in the same commit (README.zh-CN.md, CONFIGURATION.zh-CN.mdBILI_PI_INPROCrow).Battery after remediation:
npm run typecheck0 errors; build OK; targeted suite 876 tests / 873 pass / 0 fail / 3 skip.