Skip to content

feat(opencode): add non-breaking V2 plugin entrypoint - #729

Open
pascalandr wants to merge 1 commit into
DietrichGebert:mainfrom
pascalandr:feat/opencode-v2
Open

feat(opencode): add non-breaking V2 plugin entrypoint#729
pascalandr wants to merge 1 commit into
DietrichGebert:mainfrom
pascalandr:feat/opencode-v2

Conversation

@pascalandr

Copy link
Copy Markdown

Summary

  • add a dedicated @dietrichgebert/ponytail/v2 package export while leaving the root V1 export unchanged
  • register the bundled Ponytail commands and skills with OpenCode V2 transforms
  • inject active mode instructions through ctx.session.hook("context"), appending to the existing SystemPart so Qwen-compatible requests keep one system entry
  • document V1/V2 configuration syntax, the V2 beta status, and the current mode-persistence limitation

Compatibility rationale

V1 plugins do not run under V2, but changing Ponytail's root export would break existing V1 consumers. The new subpath keeps @dietrichgebert/ponytail and @dietrichgebert/ponytail/plugin on the existing V1 adapter and gives V2 an explicit default { id, setup } entrypoint.

The current V2 docs expose skill directory registration through draft.source(...). Installed beta 0.0.0-beta-17595 instead exposes draft.add(...). The adapter prefers the documented source API and has a small direct-definition fallback for that concrete beta, verified against the installed runtime.

V2 currently has no command execution lifecycle hook equivalent to V1's command.execute.before. The adapter therefore does not infer mode changes from messages or command templates. /ponytail <level> affects that command prompt only; persistent defaults remain available through PONYTAIL_DEFAULT_MODE or Ponytail's defaultMode config, which the context hook reads each turn. V1 mode persistence is unchanged.

Validation

  • npm test: 88 root tests, 23 Pi tests, and 3 MCP tests pass
  • node --test tests/opencode-plugin.test.js tests/opencode-v2-plugin.test.js: 12/12 pass
  • npm pack --dry-run --json: confirms .opencode/plugins/ponytail-v2.mjs ships
  • package self-reference resolves @dietrichgebert/ponytail/v2
  • isolated real load with opencode2 v0.0.0-beta-17595, private serve, temporary XDG_CONFIG_HOME plus the Windows-specific OPENCODE_CONFIG_DIR override:
    • /api/plugin includes ponytail
    • /api/command lists all six ponytail* commands
    • /api/skill lists all six ponytail* skills

The temporary server, config root, and temporary pandas test dependency were removed afterward. The user's global OpenCode config and V1 state were not modified.

Preserve the existing root export and V1 hook adapter while exposing @dietrichgebert/ponytail/v2 for OpenCode 2 beta configurations.

Register Ponytail commands and skills through V2 transforms, inject mode-aware instructions through the session context hook, and retain the single-system-entry behavior required by Qwen-compatible providers. Support both the current documented skill source draft and beta-17595's direct skill registration shape.

Document the V2 beta caveat and the lack of a command lifecycle hook, including the supported persistent default mechanism. Add structural tests for package resolution, transforms, and context mutation; validate with the full suite and an isolated beta server API load test.
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