Repository navigation
fix(scan): load the SDK helper safely inside OpenCode's compiled binary - #36
Merged
Merged
Conversation
The SDK's bundled helper compares process.argv[1] with its own path when it loads. In OpenCode's binary that argument is a virtual path that exists but cannot be resolved, so the load threw and every scan that reached the end failed with "completed without required artifacts". Load the helper once with the argument blanked, through one shared SDK loader. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016LiHJtDpo3TEPnWZ78vM2X
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.
Every real scan that reached the end inside OpenCode failed with "Codex Security scan completed without required artifacts: scan-manifest.json, findings.json", although both files were on disk.
Cause. The SDK's bundled helper (
_bundled_plugin/mcp/helpers.mjs) checks on load whether it is the main script:existsSync(process.argv[1]) && realpathSync(process.argv[1]) === realpathSync(entryPath). In OpenCode's compiled Bun binaryprocess.argv[1]is/$bunfs/root/opencode, which exists but cannot be resolved, sorealpathSyncthrowsENOENT. The SDK treats anyENOENTin its file check as a missing file.Fix. One shared
loadSdk()that loads the helper once withprocess.argv[1]blanked, then restores it. Later imports reuse the loaded module.Checked
npm run checkpasses, with a new test.Not yet checked: a real scan completing inside OpenCode with this change.
🤖 Generated with Claude Code
https://claude.ai/code/session_016LiHJtDpo3TEPnWZ78vM2X