Skip to content

fix: support OpenCode v2 plugin lifecycle - #152

Merged
Grivn merged 1 commit into
masterfrom
codex/issue-150-opencode-v2
Oct 3, 2026
Merged

Grivn merged 1 commit into
masterfrom
codex/issue-150-opencode-v2

Conversation

@Grivn

@Grivn Grivn commented Oct 3, 2026

Copy link
Copy Markdown
Member

OpenCode 2 rejects the installed Mnemon plugin's V1-only named export, so conversations continue without recall, shell environment setup, or compaction guidance. Export one { id, setup, server } definition: setup uses the V2 hook contracts, while server keeps compatibility with OpenCode 1.18.29 and newer.

Closes #150.

Recall is attached to the latest user message on every outgoing model request. Fresh tool-continuation copies reuse the current turn's recall; session isolation, a bounded cache, and unload cleanup prevent stale or repeated injection. CLI execution uses argument arrays and a hard timeout, resolving standard npm installs to their native executable so a timed-out launcher cannot leave its child running. The setup notes explain the supported versions and how to refresh existing installations.

Verified against real OpenCode 2.0.18 processes with the original and fixed templates installed by mnemon setup, an isolated synthetic store, and a local deterministic provider:

Observation Original template Fixed template
Plugin state Loader error, no active Mnemon plugin Exactly one active Mnemon plugin
Two sessions, three turns, six model requests including real shell continuations No memory context Exactly one context block with the recalled fact in each request
Mnemon calls None One status/recall pair per turn
Actual shell command Missing environment marker MNEMON_OPENCODE=1
Completed compaction No Mnemon guidance Guidance included in the provider request
Persisted conversation No injected context Still no injected context

Validation:

  • go build -o mnemon . and make test pass.
  • go test ./test/memory/opencode -v -count=1 passes, including real SIGTERM-ignoring child processes for direct and npm installation paths.
  • Real OpenCode 1.18.29 also loads exactly once and includes recall in both initial and tool-continuation requests.
  • Independent CLI smoke, local/global setup/reinstall/eject, and Memory CLI E2E pass (258/258 checks).

The callback and process regressions remain in the explicit integration tier. Actual host runs used macOS arm64; Windows command resolution is covered by mocked path fixtures. All model traffic uses the local fixture; no paid provider is required. The older V1 loader support floor is documented as 1.18.29.

Export one shared definition for OpenCode v2 setup and v1.18.29+ server hooks. Inject recall into model-facing content, reuse it per session and user turn across tool continuations, and bound cached state and subprocess work. Resolve npm installations to their native executable so forced timeouts reap the memory command, including Windows installs.

Validated go build, make test, focused plugin runtime and timeout tests, and 258 CLI E2E checks. Official OpenCode 2.0.18 and 1.18.29 runs against an isolated local model fixture verify plugin loading, recall, shell environment, and v2 compaction without paid providers. Document the supported versions and required setup refresh.
@Grivn
Grivn merged commit a454cbf into master Oct 3, 2026
2 checks passed
@Grivn
Grivn deleted the codex/issue-150-opencode-v2 branch October 11, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode v2: installed plugin template fails to load (V1 API; needs default export { id, setup })

1 participant