Repository navigation
docs: document the v2 plugin API - #60941
JoshRob297 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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
shescapeexample, which shows how a V1 plugin imports an npm package, is removed. Thebun installparagraph above it no longer has an example. - The advice to add
@opencode/pluginas a dev dependency doesn't match the v2 docs: the overview lists it underdependencies, andeffect.mdxdescribes the peer/dev setup. - The translated
plugins.mdxpages 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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
027d270 to
f11772c
Compare
|
You are right, and I rewrote the branch instead of adding the v2 API here.
Verified both links return 200 and |
There was a problem hiding this comment.
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.
|
Closing this one: the v2 plugin API is documented in Thanks for the review that pointed at the mismatched location. |
Issue for this PR
No issue; documentation fix.
Type of change
What does this PR do?
This page documents the OpenCode 1 plugin API, and
packages/webserves the 1.x docs. After #58277 removed V2 details from these pages, a V1 reader has no pointer to the v2 API, which lives inservices/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
shescapedependency example stay as they were.How did you verify your code works?
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