docs: cover the models-info plugin and oauth2 bearer propagation#21
Conversation
The repo is now a two-plugin workspace, but the top-level README and docs/ only described @vymalo/opencode-oauth2. - docs/models-info.md (new): adopter-depth guide for @vymalo/opencode-models-info — the single config hook, the auth-composition matrix (incl. the oauth2 bearer propagation), URL resolution, caching + failure modes, and the log-event reference. Links the package README for the full config reference rather than duplicating it. - README.md: add models-info to the Workspace Layout and Documentation tables, plus a "Companion plugin: model metadata" section with a combined oauth2 + models-info config example. - docs/architecture.md: note the second plugin up top, document the new config-time Authorization propagation (step 6 of the config hook — the sole, one-directional coupling point between the plugins), and add the two propagation events to the event-name table. Docs-only; no code or behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces documentation and configuration details for the new companion plugin @vymalo/opencode-models-info, which enriches model metadata from an OpenRouter-shaped endpoint. It also details how the existing @vymalo/opencode-oauth2 plugin propagates cached bearer tokens to allow seamless authentication. The review feedback suggests improving documentation clarity by explicitly naming the plugins in the README to avoid ambiguity, and correcting the merge strategy terminology in the models-info documentation from 'upstream-wins' to 'existing-wins' to accurately reflect that local configurations take precedence.
|
|
||
| This workspace also ships [`@vymalo/opencode-models-info`](packages/opencode-models-info) — a separate, **auth-agnostic** plugin that enriches your model entries with full metadata (context length, output limit, USD/M-token cost, modalities, and `tool_call` / `reasoning` / `attachment` flags) by fetching from an OpenRouter-shaped `/models` endpoint. | ||
|
|
||
| It doesn't depend on this plugin: it runs as a `config` hook *after* other plugins, so it composes with oauth2, static API keys, or no auth at all. When paired with `@vymalo/opencode-oauth2` ≥ 0.4.0, OAuth2-protected metadata endpoints work with zero extra config — this plugin stamps the cached bearer onto the provider's headers at config time, and the metadata fetch inherits it. |
There was a problem hiding this comment.
In this workspace-level README.md, using the phrase "this plugin" twice in a section dedicated to the companion plugin (@vymalo/opencode-models-info) is ambiguous and confusing. It can easily lead readers to believe that the companion plugin is the one performing the token stamping, whereas it is actually @vymalo/opencode-oauth2 that does so. Specifying the plugin names explicitly resolves this ambiguity.
| It doesn't depend on this plugin: it runs as a `config` hook *after* other plugins, so it composes with oauth2, static API keys, or no auth at all. When paired with `@vymalo/opencode-oauth2` ≥ 0.4.0, OAuth2-protected metadata endpoints work with zero extra config — this plugin stamps the cached bearer onto the provider's headers at config time, and the metadata fetch inherits it. | |
| It doesn't depend on `@vymalo/opencode-oauth2`: it runs as a `config` hook *after* other plugins, so it composes with oauth2, static API keys, or no auth at all. When paired with `@vymalo/opencode-oauth2` ≥ 0.4.0, OAuth2-protected metadata endpoints work with zero extra config — the oauth2 plugin stamps the cached bearer onto the provider's headers at config time, and the metadata fetch inherits it. |
| 1. **Opts in or skips.** Reads `options.meta.modelsInfoUrl`. No URL → the provider is left untouched. Safe to enable globally. | ||
| 2. **Resolves the URL** against `options.baseURL` (see [URL resolution](#url-resolution)). | ||
| 3. **Loads the catalog** — from the on-disk cache if fresh, otherwise fetches (see [Caching](#caching-and-failure-modes)). | ||
| 4. **Merges** derived metadata onto each model whose `id` (or declared `id`) matches an entry in the catalog. The merge is **upstream-wins**: any field already set on the model entry is never overwritten. Running the hook twice is a no-op. |
There was a problem hiding this comment.
The term upstream-wins is contradictory here. In network and API contexts, "upstream" refers to the remote server/API. Since the behavior described is that "any field already set on the model entry is never overwritten" (meaning the local/existing configuration takes precedence over the fetched remote metadata), this is actually an existing-wins or local-wins merge strategy. Using "upstream-wins" will confuse readers into thinking the remote API's values will overwrite their local overrides.
| 4. **Merges** derived metadata onto each model whose `id` (or declared `id`) matches an entry in the catalog. The merge is **upstream-wins**: any field already set on the model entry is never overwritten. Running the hook twice is a no-op. | |
| 4. **Merges** derived metadata onto each model whose `id` (or declared `id`) matches an entry in the catalog. The merge is **existing-wins** (or **local-wins**): any field already set on the model entry is never overwritten. Running the hook twice is a no-op. |
Summary
The workspace became a two-plugin repo with #18, but the top-level
README.mdanddocs/still only described@vymalo/opencode-oauth2. This fills the gap. Docs-only — no code or behavior change.What changed
docs/models-info.md(new) — adopter-depth guide for@vymalo/opencode-models-info: the singleconfighook, the auth-composition matrix (including the oauth2 bearer propagation), URL resolution, caching + failure modes, and the full log-event reference. Links the package README for the exhaustive config reference instead of duplicating it.README.md—@vymalo/opencode-models-infoadded to the Workspace Layout and Documentation tables, plus a new "Companion plugin: model metadata" section with a combined oauth2 + models-infoopencode.jsonexample.docs/architecture.md— a note up top that a second plugin exists, the new config-timeAuthorizationpropagation documented as step 6 of the config hook (the sole, one-directional coupling point between the two plugins), and the twooauth2_bearer_*events added to the event-name table.Notes for the reviewer
#config--plugin-loadanchor exist).format:check/lintare unaffected (still 62 files clean).🤖 Generated with Claude Code