feat: export auth hook so auth login --provider axonhub works - #1
Merged
Conversation
opencode's `auth login` builds its provider candidate list only from the models.dev database plus plugins that export an `auth` hook (resolvePluginProviders skips any hook without `auth`). Providers defined only in opencode.jsonc are never added, so `--provider axonhub` fails with `Unknown provider "axonhub"`. Add a minimal `api`-type auth hook for the axonhub provider. The CLI now lists axonhub in the login picker and, on `--provider axonhub`, prompts for the API key and stores it under the `axonhub` key in auth.json — exactly where authFileKey() already reads it. This restores the README's documented `opencode auth login --provider axonhub` workflow, which broke once opencode tightened `--provider` validation (anomalyco/opencode PR #14470, first shipped in v1.2.18). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
56 tasks
55 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Following the README's documented setup,
opencode auth login --provider axonhubfails with:Root cause
opencode's
auth logincommand builds its provider candidate list from only two sources:modelsDev.get()), andresolvePluginProviders(...), which iterates plugin hooks and skips any hook that does not export anauthfield (if (!hook.auth) continue).Providers defined only in the user's
opencode.jsonc(provider.axonhub) are not added to this list. When--provider axonhubis passed, the command doesoptions.find(x => x.value === input || label matches)and, finding no match, throwsUnknown provider.This plugin previously exported only
configandprovider.modelshooks — enough to register a working provider for model use, but not enough to appear in the login picker. Hence the README workflow was broken on current opencode.When this broke in opencode
This is a regression caused by opencode tightening its auth/login flow (upstream repo
sst/opencode, which redirects toanomalyco/opencodefor the API):4ccb82e) — introducedresolvePluginProvidersand theif (!hook.auth) continuegating: the login picker is now sourced from models.dev + plugins that export anauthhook.f363904) — added the--providerflag with strict validation, rejecting anything not in that candidate list withUnknown provider "<id>".Before v1.2.18 there was no
--providerflag; the interactive picker's "Other" escape hatch still accepts arbitrary/config-only ids, but the non-interactive--providerpath does not. Both changes are present in the current release (verified against a local v1.17.13 install, where the logic now lives inpackages/opencode/src/cli/cmd/providers.ts).Fix
Export a minimal
api-typeauthhook for theaxonhubprovider:With no
authorizecallback, opencode'shandlePluginAuthprompts for the API key and stores it under theaxonhubkey inauth.json— exactly where the plugin'sauthFileKey()already reads it. No other behavior changes.Verification
Pointed a local opencode (v1.17.13)
pluginentry at this branch and ran:Unknown provider "axonhub"is gone; the flow now reaches◆ Enter your API key, confirming the provider resolves through the new auth hook.🤖 Generated with Claude Code