fix: scrub OpenCode prompts routed through LiteLLM - #14
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Fixes #10. Accept
passthroughrequests because LiteLLM removes the OpenCode client headers used for adapter detection. Before scrubbing passthrough traffic, require a distinct OpenCode or OhMyOpenCode marker. The shared<env>preamble alone is insufficient evidence; genuine Claude Code requests may contain it and must stay unchanged.The existing direct
opencodepath keeps its behavior. Added regression tests for the LiteLLM classification, genuine Claude Code prompt bytes, incidental OpenCode mentions, and direct OpenCode requests.Validation
bun test src/__tests__/plugin.test.tsfailed 3 of 4: missingpassthroughadapter and two foreign prompts altered when the hook was invoked.npm ci,npm test(21 pass),npm run build, andnpm pack --dry-runpassed.passthrough; the powered-by line and duplicate environment preamble reached the SDK, and OpenCode ended in thebilling_errorsubscription gate. Control artifact:opencode-scrub-live-AEcLtt.opencode-scrub-live-0tBBC7.opencode-scrub-live-Olv8DN); unchanged plugin reproduced the billing gate on Haiku (opencode-scrub-live-v0rurN). The E2E harness is/tmp/opencode-scrub-live-e2e.mjsand keeps credentials/transcript content out of its summary.