Skip to content

feat: export auth hook so auth login --provider axonhub works - #1

Merged
pandada8 merged 1 commit into
pandada8:masterfrom
zsxsoft:feat/auth-hook
Jul 4, 2026
Merged

feat: export auth hook so auth login --provider axonhub works#1
pandada8 merged 1 commit into
pandada8:masterfrom
zsxsoft:feat/auth-hook

Conversation

@zsxsoft

@zsxsoft zsxsoft commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Problem

Following the README's documented setup, opencode auth login --provider axonhub fails with:

Error: Unknown provider "axonhub"

Root cause

opencode's auth login command builds its provider candidate list from only two sources:

  1. the models.dev provider database (modelsDev.get()), and
  2. resolvePluginProviders(...), which iterates plugin hooks and skips any hook that does not export an auth field (if (!hook.auth) continue).

Providers defined only in the user's opencode.jsonc (provider.axonhub) are not added to this list. When --provider axonhub is passed, the command does options.find(x => x.value === input || label matches) and, finding no match, throws Unknown provider.

This plugin previously exported only config and provider.models hooks — 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 to anomalyco/opencode for the API):

  • v1.2.7 (2026-02-19, PR #13921, commit 4ccb82e) — introduced resolvePluginProviders and the if (!hook.auth) continue gating: the login picker is now sourced from models.dev + plugins that export an auth hook.
  • v1.2.18 (2026-03-05, PR #14470, commit f363904) — added the --provider flag with strict validation, rejecting anything not in that candidate list with Unknown provider "<id>".

Before v1.2.18 there was no --provider flag; the interactive picker's "Other" escape hatch still accepts arbitrary/config-only ids, but the non-interactive --provider path does not. Both changes are present in the current release (verified against a local v1.17.13 install, where the logic now lives in packages/opencode/src/cli/cmd/providers.ts).

Fix

Export a minimal api-type auth hook for the axonhub provider:

auth: {
  provider: PROVIDER_ID,
  methods: [{ type: "api", label: "API Key" }],
},

With no authorize callback, opencode's handlePluginAuth prompts for the API key and stores it under the axonhub key in auth.json — exactly where the plugin's authFileKey() already reads it. No other behavior changes.

Verification

Pointed a local opencode (v1.17.13) plugin entry at this branch and ran:

opencode auth login --provider axonhub

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

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>
@pandada8
pandada8 merged commit 0507a7b into pandada8:master Jul 4, 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.

2 participants