fix(plugin): port to OpenCode V2 session hooks
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- bun, typescript
- Domain
- backend-api-design, devtools
Research direction
Start by locating the plugin's setup function and its compaction hook, then compare the callback shape with the OpenCode V2 contract described in the issue. Trace how session directories and the two configuration paths are resolved, and review the hook tests for deduplication, durable instructions, and error handling. Done means bun test passes and the isolated E2E checks in the issue succeed.
Written by the indexing model from the issue text.
Description
Problem
0.1.11 never re-injects AGENTS.md. It registers ctx.session.hook("compaction", ...) and mutates event.context / event.options.context / event.prompt. In OpenCode V2 (verified on 2.2.5) ctx.session.hook exists but the callback receives one mutable event with system, messages, and options — none of the mutated fields above, so the hook is a silent no-op.
Additionally, the V1-style setup() that returns a hooks object (instead of registering hooks and returning a cleanup function) can break plugin loading on a shared opencode serve.
Evidence
- V2 docs:
compactionruns for checkpoint summaries; inject context by pushing intoevent.system;contextruns before every agent model request. opencode plugin listand the binary contract:Expected plugin to have a non-empty name/setup() function.
Fix
compactionhook: push a bounded fullAGENTS.mdblock intoevent.systemso the summary preserves the mandates.contexthook: push a bounded digest every request and record a durable session instruction entry (session.instructions.entry.put, once per session) so the rules survive compaction.- Resolve
AGENTS.mdfrom the session directory upward, then~/.config/opencode/AGENTS.md, then~/.config/opencode/prompts/AGENTS.md. - Skip injection when the system prompt already carries the file (avoid duplication with native
instructions). - Wrap every hook in try/catch: a plugin failure must never break model resolution or a request.
- Unit tests for hooks, dedupe, durable entry, resolution and error swallowing.
Verification
bun test: 13 pass.- Isolated E2E (
OPENCODE_CONFIG_DIR,--standalone, mock OpenAI server): model answers; digest present on every request; full rules present in the compaction request; post-compaction request carries the digest.
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Similar issues
-
clawsweeper:intake:bug clawsweeper:intake:needs-environment
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
openclaw/openclaw#212827 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
KT-2245 e2e specs that call the backend directly fall back to the developer's own Kronn on :3140Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Use one constant for the 10,000-character input limitPossibly taken @NginxL claimed this today. Opengood first issue refactor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
aniru-dh21/snap-validate#51 ·
Maintainers usually reply within 1 day
-
dependencies effort: small good first issue priority: low
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
TMHSDigital/screencast-mcp#509 ·
Maintainers usually reply within 1 day
-
from-review tech-debt testing
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
blamechris/chroxy#9520 ·
Maintainers usually reply within 1 day