Repository navigation
OpenCode plugin: support the OpenCode 2.x plugin API, keep 1.x (#271) - #272
Conversation
OpenCode 2.x loads only a default object with `id` and `setup`, so the
1.x-shaped plugin was skipped and sessions ran without Project Direction
or the Elon gate. The default export is now `{id, server, setup}`:
1.x calls `server` with the existing hooks; 2.x calls `setup`, which
appends the loader context through `session.hook("context")` and runs
the Elon gate from `tool.hook("execute.before")`. `setup` does nothing
in the reduced context 1.x also passes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
What: Independent review found no blocking defects at d6c4514. Reviewed against main 23e0674. Read Issue #271 in full, the complete PR diff, surrounding plugin/tests/docs, and the base plugin. No repository edits, OpenCode/model runs, or paid calls. Findings
Blocking findings: none. Verdict: PASS. Correctness and scopeThe 1.x README.md and docs/opencode.md describe the two paths and tested versions consistently, apart from the metadata shorthand above. VERSION, all five declared mirrors, and CHANGELOG consistently use 17.5.0. A minor bump fits a backward-compatible capability addition. Falsifiability of the changed testsThese are concrete faulty implementations each test would reject, by assertion inspection; mutation runs were not performed:
Observed proof and limits
GitHub |
|
Agent cost: |
What changed: The OpenCode Project Direction plugin now loads on OpenCode 2.x and still works on 1.x, delivering Project Direction and enforcing the Elon gate on both.
Why: OpenCode 2.x only loads a default object with
idandsetup, so the 1.x-shaped plugin was skipped and 2.x sessions ran silently without it.So what: Needs independent review, then the user's merge; after merge the release and local install follow under repository policy.
Closes #271.
Change
opencode/agentsmd-project-direction.jsdefault-exports{id, server, setup}and nothing else.{id, server};server(ctx)returns hooks{id, setup};setup(ctx)registers hooks;serverignoredctx.directory/ctx.worktreectx.location.directoryexperimental.chat.system.transform, push strings tooutput.systemctx.session.hook("context"), push{type:"text", text}toinput.systemtool.execute.before(input.tool,output.args), throw to blockctx.tool.hook("execute.before")(input.tool,input.input), throw to blockNothing was left unported: 2.x has a real pre-execution hook, and a throw there fails the tool call before it runs. 1.18.32 and 1.19.6 also call
setup, with a reduced context lackingsession/tool;setupreturns without registering in that case so 1.x is not double-injected.Proof
d6c4514:python3 -m unittest discover -s tests -p 'test_*.py'515 OK; versionctl suite OK;versionctl release-check --sha d6c4514…OK (v17.5.0).server(1.x) andsetup(2.x): payload byte-equality, routing pointer, outside-repo verdict, installed link, unreachable/failing loader, export shape, reduced-context no-op; Elon gate blocks/allows/fails closed through both paths.--standalone, local oMLXgemma-4-26B-A4B-it-heretic-5bit, zero paid spend, fixture repo with Objective "Grow heliotrope in the fixture garden.":shellcallgh issue create --title t --body hifailed withAgentsMD blocked \gh issue create`: every Issue needs an Elon record…`.bash.{id, server, setup}shape probe loaded, injected system text and blocked abashcall (probe plugin, not this file).Plugin must export a default definition with an id and an effect or setup function. (cause: SchemaError(Expected object at ["default"])).toolboxmd/toolbox.mdcode search finds no OpenCode mention.Limits
execute.beforetrigger per the 2.3.2 binary; no live run exercised a gh call made insideexecute.bin/agentsmd-opencode runstays pinned to 1.18.32 (non-goal).Elon record
supportedOpenCodeVersionfunction property became a list on the default object.@opencode/plugin2.3.2 types and the 2.3.2/1.19.6 loaders; ran this plugin on 2.3.2 and 1.19.6 in scratch dirs with the local model; ran the full suite.🤖 Generated with Claude Code