Skip to content

refactor(opencode): update plugin templates for v1 hooks#159

Open
Adamcf123 wants to merge 9 commits intomindfold-ai:mainfrom
Adamcf123:refactor/opencode-session-persist
Open

refactor(opencode): update plugin templates for v1 hooks#159
Adamcf123 wants to merge 9 commits intomindfold-ai:mainfrom
Adamcf123:refactor/opencode-session-persist

Conversation

@Adamcf123
Copy link
Copy Markdown

@Adamcf123 Adamcf123 commented Apr 11, 2026

Summary

Updates the OpenCode plugin templates under packages/cli/src/templates/opencode/ to match the current v1 plugin API and remove outdated OMO assumptions.

Adds a follow-up fix so template session-start context is deduped using OpenCode-managed session history instead of process-local or temp-file state, which prevents reinjection after reopening the same session.

Changes

  • Convert template plugins to v1 format (export default { id, server })
  • Add required id fields to the template plugins
  • Remove dead OMO compatibility code from the template trellis-context.js
  • Fix the task tool prompt mutation pattern in the template inject-subagent-context.js by using in-place args.prompt = newPrompt
  • Fix the template session-start.js injection flow to use chat.message output mutation instead of the non-persistent experimental.chat.messages.transform path
  • Simplify the template ContextCollector by removing unused cross-hook methods
  • Add restart-safe template session-start dedupe by checking persisted session history through the OpenCode SDK
  • Mark injected Trellis context with structured metadata and keep a legacy text-marker fallback for older sessions
  • Add regression tests for the template history-based dedupe behavior

Scope

  • packages/cli/src/templates/opencode/lib/trellis-context.js
  • packages/cli/src/templates/opencode/plugins/inject-subagent-context.js
  • packages/cli/src/templates/opencode/plugins/session-start.js
  • packages/cli/test/templates/opencode.test.ts

Verification

  • pnpm lint passes
  • pnpm typecheck passes
  • pnpm test passes

@Adamcf123 Adamcf123 force-pushed the refactor/opencode-session-persist branch 2 times, most recently from e95a380 to 0ad9470 Compare April 11, 2026 04:48
@Adamcf123 Adamcf123 force-pushed the refactor/opencode-session-persist branch from 0ad9470 to 87b7ced Compare April 11, 2026 04:52
@Adamcf123 Adamcf123 changed the title refactor(opencode): fix session-start context persistence, sync templates refactor(opencode): update plugin templates for v1 hooks Apr 11, 2026
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.

1 participant