opencode-kimi-code-auth
v0.1.7
Published
OpenCode OAuth bridge for Kimi Code CLI
Maintainers
Readme
OpenCode Kimi OAuth Plugin
Use your existing Kimi CLI OAuth session directly inside OpenCode.
This plugin reads the token created by kimi login from ~/.kimi/credentials/kimi-code.json and wires it into OpenCode auth.
For Humans
What it does
- Attaches to the built-in OpenCode provider
moonshotai(no custom provider IDs). - Adds
kimicode-*model aliases undermoonshotai/(e.g.moonshotai/kimicode-kimi-k2.5) that route to the Kimi Code API. - Uses the token created by
kimi loginat~/.kimi/credentials/kimi-code.json, including automatic refresh.
Install
- Add this plugin in your OpenCode config (
~/.config/opencode/opencode.json):
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
"opencode-kimi-code-auth@latest"
]
}- Authenticate:
kimi login
opencode auth login- In the picker:
- Provider:
Moonshot AI - Method:
Kimi CLI OAuth
- Verify:
opencode auth list
opencode models moonshotai
opencode run --model moonshotai/kimicode-kimi-k2.5 "Say hello"Troubleshooting
Only seeing
Enter your API key:- Ensure config has
"plugin": ["opencode-kimi-code-auth@latest"]. - Re-run
opencode auth loginand chooseMoonshot AI.
- Ensure config has
Kimi CLI is not authenticated:- Run
kimi login, then retryopencode auth login.
- Run
Previously working setup starts failing with auth errors:
- Your Kimi refresh token likely expired or was revoked.
- Run
kimi loginonce to renew the underlying Kimi CLI session.
For LLMs
Copy/paste this prompt into your coding agent:
Configure OpenCode on this machine to use Kimi OAuth via the published plugin.
Goal:
- Use Kimi CLI OAuth tokens in OpenCode for `moonshotai/kimicode-*` models (without adding a custom provider)
Rules:
- Never print credential values.
- Only modify config fields required for this setup.
Steps:
1. Validate tools:
- Run: opencode --version
- Run: kimi --version
2. Update OpenCode config:
- File: ~/.config/opencode/opencode.json (or %USERPROFILE%\\.config\\opencode\\opencode.json on Windows)
- Ensure plugin array includes this published package entry:
"opencode-kimi-code-auth@latest"
- Preserve other existing plugin entries (remove only local file paths/source-checkout plugin references).
3. Verify OpenCode starts cleanly with plugin enabled:
- Run: opencode auth list
- If this fails with plugin install/import errors, fix the plugin entry before continuing.
4. Do not attempt interactive auth in this session.
- Ask the human to run: opencode auth login
- Ask the human to choose provider `Moonshot AI` and method `Kimi CLI OAuth`, then confirm they saw `Login successful`.
5. Verify setup after user confirmation:
- Run: opencode auth list
- Run: opencode models moonshotai
- Confirm output includes moonshotai/kimicode-kimi-k2.5
6. Return a concise report of changes and verification results.Development
npm run typecheck
npm run build
npm pack --dry-runMaintainer Release Flow (OIDC)
This repo uses GitHub Actions OIDC trusted publishing (no npm token in secrets).
One-time npm setup:
- Open npm package settings for
opencode-kimi-code-auth. - Add a Trusted Publisher for GitHub Actions:
- Owner:
Simplereally - Repository:
opencode-kimi-code-auth - Workflow file:
.github/workflows/release.yml - Environment: leave empty unless you explicitly configure one
- Owner:
Release steps:
- Update
package.jsonversion onmain. - Push
main. - Run workflow:
Release(Actions tab,workflow_dispatch).
The workflow publishes to npm with provenance, creates a matching git tag, and creates a GitHub release from that exact main commit.
License
MIT. See LICENSE.
