Skip to content

docs: document the v2 plugin API - #60941

Closed
JoshRob297 wants to merge 1 commit into
anomalyco:devfrom
JoshRob297:plugins-v2-docs
Closed

JoshRob297 wants to merge 1 commit into
anomalyco:devfrom
JoshRob297:plugins-v2-docs

Conversation

@JoshRob297

@JoshRob297 JoshRob297 commented Oct 31, 2026 •

Copy link
Copy Markdown

Issue for this PR

No issue; documentation fix.

Type of change

  • Documentation

What does this PR do?

This page documents the OpenCode 1 plugin API, and packages/web serves the 1.x docs. After #58277 removed V2 details from these pages, a V1 reader has no pointer to the v2 API, which lives in services/www/src/docs/content/build/plugins/.

This adds a note next to the intro that states the page covers OpenCode 1 and links the OpenCode 2 plugin overview and the V1 migration guide. It follows the pattern already used on the policies page, which points V1 readers at its v2 equivalent the same way.

Nothing else changes: the 1.x content, examples and the shescape dependency example stay as they were.

How did you verify your code works?

  • Both linked URLs return 200 (https://opencode.ai/v2/docs/build/plugins/, https://opencode.ai/v2/docs/build/plugins/migrate-v1).
  • cd packages/web && astro build: content collections sync and MDX compile without errors.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This puts the v2 plugin API on the wrong docs site, so I don't think it should go in as is. It's docs-only, so there was nothing to run; I compared it with both docs sites.

packages/web serves the OpenCode 1 docs. The front page sends V2 readers to https://opencode.ai/v2/docs/, and #58277 recently removed V2 details from these pages so they match 1.19.x. With this PR, V1 readers would open the page and find the v2 Plugin.define API first, with their working 1.x plugin API presented as legacy that "is not loaded". The v2 loader does reject the 1.x shape, as the description says, but that doesn't apply to readers of this page.

The v2 plugin API is already documented in services/www/src/docs/content/build/plugins/: index.mdx, server.mdx (transforms, hooks, events), effect.mdx, and migrate-v1.mdx for moving 1.x plugins over. If anything is missing or wrong there, a PR against those pages would be the right place. A short link from this page to the V2 plugin docs or the migration guide would also fit here.

Other points:

  • The shescape example, which shows how a V1 plugin imports an npm package, is removed. The bun install paragraph above it no longer has an example.
  • The advice to add @opencode/plugin as a dev dependency doesn't match the v2 docs: the overview lists it under dependencies, and effect.mdx describes the peer/dev setup.
  • The translated plugins.mdx pages are not updated.

Public API: unchanged (docs only).


A plugin is a **JavaScript/TypeScript module** that exports one or more plugin
functions. Each function receives a context object and returns a hooks object.
OpenCode v2 loads a plugin that exports a default definition with an `id` and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page is part of the OpenCode 1 docs (see #58277 and the V2 docs link on index.mdx). For a 1.x user this intro is wrong: their plugin function is what gets loaded. I'd keep the V1 wording here and, if useful, add a short pointer to the V2 plugin docs (/v2/docs/build/plugins) and the V1 migration guide.

}
},
}
### Define a plugin (v2)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These v2 sections (define, transforms, runtime hooks, events) repeat services/www/src/docs/content/build/plugins/index.mdx and server.mdx, in less depth. The dev-dependency advice also conflicts with the v2 overview, which lists @opencode/plugin under dependencies. Any v2 corrections would be better made against those pages. Also, this hunk drops the V1 shescape example that illustrated the bun install paragraph above.

Review feedback on anomalyco#60941: `packages/web` serves the OpenCode 1 documentation,
so the v2 API does not belong on this page. The v2 plugin API already lives in
`services/www/src/docs/content/build/plugins/`, including the migration guide.

Keep the 1.x page as it is and add a note that points V2 readers at the v2
overview and the migration guide, the same way the policies page points at its
v2 equivalent.
@JoshRob297

JoshRob297 commented Oct 31, 2026 •

Copy link
Copy Markdown
Author

You are right, and I rewrote the branch instead of adding the v2 API here.

  • packages/web is the 1.x docs; services/www/src/docs/content/build/plugins/ already documents the v2 API, including migrate-v1.mdx.
  • The page now keeps its 1.x content untouched (the shescape example is back) and adds a note at the top pointing V2 readers at the v2 overview and the migration guide, following the same pattern as the policies page.
  • The dev-dependency advice and the v2 snippets are gone from this PR.

Verified both links return 200 and astro build syncs the content without MDX errors.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both earlier points are fixed. The 1.x page and the shescape example are back as they were, and the v2 content is replaced by a short note that links to the V2 plugin overview and the V1 migration guide. This is the same way policies.mdx points V1 readers to its V2 page. The links match existing pages in services/www. Docs-only, so there was nothing to run. Public API: unchanged. I have no further concerns.

@JoshRob297

Copy link
Copy Markdown
Author

Closing this one: the v2 plugin API is documented in services/www/src/docs/content/build/plugins/, and packages/web is the 1.x documentation site, so this file was the wrong home for it. The rewritten version lives on a separate branch instead of being rebased here.

Thanks for the review that pointed at the mismatched location.

@JoshRob297 JoshRob297 closed this Nov 16, 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