fix(v2): register tools with the opencode2 API shape - #8
Conversation
|
Verified & ready to merge — requesting approval. The fixed build was installed as the plugin in the running opencode2 and confirmed live; the full suite is green:
Known follow-up (not part of this PR): the \compressToolName\ kernel fix on |
|
@rorshopping heads up — repo contribution policy update 🎉
What changed: What this means for you:
Guardrails still in place (unchanged):
Soft ask: for external-contributor PRs (@5258MF's), please give the code a quick eyeball before merging — the review gate is now voluntary rather than enforced. For your own PRs you're trusted. Your Write access (push/triage) is active. Feel free to triage the open PRs, rebase/merge what's ready, and keep pushing V2 work. Welcome to drive the repo. 🚀 |
|
Closing as superseded by #18 (now merged). Huge thanks @rorshopping — you correctly identified and fixed two real bugs, and both were confirmed present on
Why this PR wasn't merged directly, and your fixes were ported instead:
What landed in #18 (your work, credited):
You're credited in the #18 commit message and PR description. The one thing neither this PR nor #18 covers is the kernel hardcoding the generic tool name Thanks again for the solid diagnosis. 🙇 |
|
前面的我尽可能的都合并了,新进来再修可能的问题. |
What
Fixes the opencode2 tool registration in
packages/v2. The fourbili_*tools were registered as raw V1ToolDefobjects, but opencode2'stools.add()expects the AI-SDK-style shape:{ name, description, input (JSON schema), execute(input, ctx) }.Also fixes a non-idempotent system-prompt injection in the V2 context hook.
Changes
packages/v2/src/tools.ts(new) — V2 wrappers over@bili/core's tool makers:name(bili_compress/bili_decompress/bili_search/bili_status)input: JSON-schema (was zodargs; V2Info.inputis aValueSchema, the zod object was never usable as a schema)execute(input, ctx)maps the V2ToolContext({ sessionID, agent?, messageID?, id, progress? }) onto the V1ToolContext(callID: ctx.id, nodirectory/worktree) and returns{ content }(V2Tool.Result)packages/v2/src/index.ts— register the V2-shaped tools;SYSTEM_MARKERchanged from"BILI CONTEXT MANAGEMENT"to"ACP TOOLS (billion-context)"(the actual header line of@bili/core'sSYSTEM_PROMPT). PreviouslyfindIndexnever matched, so a duplicate system prompt was appended on every dispatch.packages/v2/smoke.mjs(new) +smokescript — regression test asserting the tool shape, idempotent system upsert, end-to-end hook→compress→search→decompress flow, and thatcompressCallIdmaps from V2ctx.id.Verification
npm run typecheck(all workspaces) — passnpm test(v1) — 26/26 passnpm run build(v1 + v2) — passnpm run smoke --workspace billion-context-opencode-v2— all assertions pass (tool shape, idempotent tags,bili_status/bili_compress/bili_search/bili_decompressreturn{ content },compressCallId= V2 call id)Notes
@bili/corekeeps its V1ToolDefuntouched — the V2 adaptation lives inpackages/v2only.compressToolNamepairing fix (kernel hardcodes'compress'; consumedbili_compressinvocations leak). Kernel change is PR-ready onrorshopping/acp-kernel; happy to follow up.