Repository navigation
feat(opencode): SQLite memory parser + install-gate plugin (verified against opencode-ai@1.17.x) - #156
Merged
Conversation
…against opencode-ai@1.17.x) Verified both surfaces against a real OpenCode install (opencode-ai@1.17.11), not docs — closes the live-verification gaps in #117 and #146. memory (#117): current OpenCode stores sessions in SQLite (opencode.db), not the legacy flat-JSON storage/ tree our parser assumed — confirmed via `opencode db path` + schema dump; the data dir no longer contains storage/ at all. Add a SQLite path that reads opencode.db read-only (session.directory = cwd; role from message.data JSON; text from part.data JSON), preferring it and falling back to flat-JSON for older installs. Shared store-writer for both. Verified: queries run clean against the real full-schema DB; unit-tested against a synthetic DB built with the verified schema. gate (#146): add installInstallGateOpenCode — OpenCode enforces via a JS plugin, not a config hook. Generate .opencode/plugin/kit-install-gate.js that hooks tool.execute.before (verified @opencode-ai/plugin contract) and throws to block, piping the bash command into `kit gate-bash`. Verified end-to-end: OpenCode loads the generated plugin (appears in resolved config plugin_origins); gate-bash parses the {tool_input:{command}} payload, passes benign commands and exits 2 on an untriaged install (→ plugin throws → tool denied). Wired into installAllInstallGates; README agent matrix + agent-config footer updated to reflect the now-shipped gate for Claude Code/Codex/Amazon Q/Gemini/Cursor (hook) + OpenCode (plugin), with Cline/Continue still tracked in #146. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
|
✅ Docker image built successfully
|
This was referenced Jun 27, 2026
Closed
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.
What
Closes the live-verification gaps that #117 and #146 explicitly deferred — by installing real OpenCode (
opencode-ai@1.17.11) and verifying against the binary, not docs.1. Memory parser → SQLite (#117)
Current OpenCode stores sessions in SQLite (
~/.local/share/opencode/opencode.db), not the legacy flat-JSONstorage/tree our parser assumed — the data dir no longer containsstorage/at all. Confirmed viaopencode db path+ asqlite_masterschema dump.opencode.dbread-only:session.directory= cwd,rolefrom themessage.dataJSON blob, text fromtype:"text"part.datablobs.opencode:<sessionID>:<messageID>uuid keeps it idempotent.2. Install-gate → OpenCode plugin (#146)
OpenCode enforces via a JS plugin, not a config-file hook. Adds
installInstallGateOpenCode, which generates.opencode/plugin/kit-install-gate.js:tool.execute.before(the verified@opencode-ai/plugincontract) and throws to block.bashtool call it pipes{tool_input:{command}}intokit gate-bash; non-zero exit (2 = deny) → throw → tool denied.plugin_origins, no load error);gate-bashpasses benign commands (exit 0) and exits 2 on an untriaged install.Wired into
installAllInstallGates. README agent-support matrix +agent-configfooter corrected: the blocking gate is shipped for Claude Code / Codex / Amazon Q / Gemini CLI / Cursor (exit-2 hooks) + OpenCode (plugin); Cline (JSON-cancel) and Continue (unverified) remain in #146.Honest limitation
The final "throw actually denies the tool" step rests on the documented
tool.execute.beforecontract — driving an LLM session to fire a real bash tool call needs an API key, unavailable in the sandbox. Every other link is verified against the running binary.Dogfooding
Triaged before install per kit's own rule:
opencode-ai88/100,@opencode-ai/plugin100/100 — bothTRIAGE PASSED.Test plan
npm run buildcleannpm run format:checkcleannpm test— 1852/0 (5 new: 2 SQLite-memory + 3 OpenCode-gate, incl. one that imports the generated plugin and invokes the hook)opencode.db→ clean empty resultgate-bashexit 0 (benign) / exit 2 (untriaged install) via the plugin's payload shape🤖 Generated with Claude Code
https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
Generated by Claude Code