Skip to content

Feature request: support OpenCode v2 API/protocol #487

Description

@wzj-zz

Feature request

Please add support for the OpenCode v2 API/protocol while keeping existing OpenCode v1 users working.

opencode.nvim currently targets the v1 server API. For example, the client calls /session/{id}/message, /session/{id}/abort, /global/health, and subscribes to /global/event (see lua/opencode/api_client.lua and lua/opencode/opencode_server.lua). OpenCode v2 exposes a different HTTP surface under /api, including /api/health, /api/event, /api/session/{id}/prompt, /api/session/{id}/interrupt, /api/session/{id}/message, and location/workspace-aware request and response models.

The current plugin therefore cannot be used with an OpenCode v2 server, even though the v2 API is now documented and available here:

Suggested scope

  • Detect the server/API version at startup, or provide an explicit api_version = "v1" | "v2" option.
  • Add a v2 API client/adapter for the core workflows: health checks, session create/list/load/delete/rename, send prompt, abort/interrupt, message/history loading, permissions, questions/forms, agents/models, file/context lookup, and MCP.
  • Subscribe to the v2 event stream and normalize v2 events into the existing event manager/renderer model. The v2 event payloads include versioned durable sync events and location/workspace metadata, so directory/workspace filtering should be preserved.
  • Map v2 response shapes to the existing UI state where possible, while exposing v2-only concepts such as workspaces, cursor pagination, session inbox/queue, and forms incrementally.
  • Update the documented minimum supported OpenCode version and add replay/unit coverage for representative v2 responses and events.

Expected behavior

  • With OpenCode v1, current behavior remains unchanged.
  • With OpenCode v2, opening a session and submitting a prompt should work without manually patching the plugin or running a compatibility proxy.
  • Unsupported v2-only features should fail clearly rather than silently leaving the UI stale.

I am happy to help test this against the v2 server and provide sample event/API payloads if useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions