Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
}
},
{
"includes": ["src/tui.tsx"],
"includes": ["src/tui.tsx", "src/tui-v2.tsx"],
"linter": {
"rules": {
"a11y": {
Expand Down
2 changes: 1 addition & 1 deletion contributing/provider-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This template is intentionally outside `src/` and is not published to npm. `pack

Use this template for API-key/token providers that support all three trusted sources:

1. existing OpenCode API-key/token auth (`auth.json`)
1. existing OpenCode API-key/token auth (`opencode.db`)
2. trusted user/global OpenCode config
3. environment variables

Expand Down
2 changes: 1 addition & 1 deletion contributing/provider-template/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe("example provider config", () => {
const { resolveExampleProviderApiKey } = await import("../src/lib/example-provider-config.js");
await expect(resolveExampleProviderApiKey()).resolves.toEqual({
key: "auth-key",
source: "auth.json",
source: "opencode.db",
});
});
});
4 changes: 2 additions & 2 deletions contributing/provider-template/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type ExampleProviderKeySource =
| "env:EXAMPLE_PROVIDER_API_KEY"
| "opencode.json"
| "opencode.jsonc"
| "auth.json";
| "opencode.db";

export interface ExampleProviderApiKeyResult {
key: string;
Expand All @@ -39,7 +39,7 @@ export async function resolveExampleProviderApiKey(): Promise<ExampleProviderApi
getConfigCandidates: getGlobalOpencodeConfigCandidatePaths,
auth: {
readAuth: readAuthFile,
authSource: "auth.json",
authSource: "opencode.db",
},
});
}
Expand Down
8 changes: 4 additions & 4 deletions docs/readme/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ The command writes the `experimental.quotaToast.quotaProviders` section. Configu
- Local estimates support 1–16 UTC-day or rolling request windows.
- Automatic models.dev matching runs first. `pricingModelMap` cannot override a successful automatic match.
- If any request cannot be priced, request counts stay visible and the budget percentage is reported unavailable.
- Credentials resolve from `apiKeyEnv`, trusted global `provider.<providerId>.options.apiKey`, then API-key entries in OpenCode `auth.json`.
- Credentials resolve from `apiKeyEnv`, trusted global `provider.<providerId>.options.apiKey`, then API-key entries in OpenCode `opencode.db`.
- Definitions run automatically with `enabledProviders: "auto"`. A manual list must include `quota-providers` and every built-in provider you still want.
- To tune maintained estimates, use the reserved `qwen-code` or `alibaba-coding-plan` ID and its maintained window shape. Do not add a duplicate normal provider block.
- Project secrets, scripts, custom headers, executable mappings, regular expressions, and JSONPath are not accepted.
Expand Down Expand Up @@ -407,11 +407,11 @@ Existing `experimental.quotaToast` settings remain supported. Quota settings do
| `cursorIncludedApiUsd` | unset | Override Cursor monthly included API budget in USD. |
| `cursorBillingCycleStartDay` | unset | Local billing-cycle anchor day `1..28`; when unset, Cursor usage resets on the local calendar month. |

Kilo Gateway has no `quota-toast.json` credential setting. Use `KILO_API_KEY`, trusted user/global `provider.kilo.options.apiKey`, or a strict `kilo` API-key entry in OpenCode `auth.json`; project-local OpenCode config is not read for this secret. See [Kilo Gateway setup](providers.md#kilo-gateway).
Kilo Gateway has no `quota-toast.json` credential setting. Use `KILO_API_KEY`, trusted user/global `provider.kilo.options.apiKey`, or a strict `kilo` API-key entry in OpenCode `opencode.db`; project-local OpenCode config is not read for this secret. See [Kilo Gateway setup](providers.md#kilo-gateway).

Ollama Cloud has no `quota-toast.json` credential setting. Use `OLLAMA_API_KEY`, trusted user/global `provider.ollama-cloud.options.apiKey`, or a strict `ollama-cloud` API-key entry in OpenCode `auth.json`; project-local OpenCode config is not read for this secret. See [Ollama Cloud setup](providers.md#ollama-cloud).
Ollama Cloud has no `quota-toast.json` credential setting. Use `OLLAMA_API_KEY`, trusted user/global `provider.ollama-cloud.options.apiKey`, or a strict `ollama-cloud` API-key entry in OpenCode `opencode.db`; project-local OpenCode config is not read for this secret. See [Ollama Cloud setup](providers.md#ollama-cloud).

OpenCode Go has no `quota-toast.json` workspace ID, cookie, endpoint, credential, or token setting. It automatically uses `OPENCODE_API_KEY`, trusted user/global `provider.opencode-go.options.apiKey`, trusted user/global fallback `provider.opencode.options.apiKey`, a strict `opencode-go` API-key entry in OpenCode `auth.json`, or a strict legacy `opencode` auth entry as the final fallback. `opencodeGoWindows` filters the Five-hour, Weekly, and Monthly rows returned by the official usage API, including the expanded sidebar. Use `tuiSidebarPanel.opencodeGoPreferredWindow` to prefer one available row only while the sidebar is collapsed. See [OpenCode Go setup](providers.md#opencode-go).
OpenCode Go has no `quota-toast.json` workspace ID, cookie, endpoint, credential, or token setting. It automatically uses `OPENCODE_API_KEY`, trusted user/global `provider.opencode-go.options.apiKey`, trusted user/global fallback `provider.opencode.options.apiKey`, a strict `opencode-go` API-key entry in OpenCode `opencode.db`, or a strict legacy `opencode` auth entry as the final fallback. `opencodeGoWindows` filters the Five-hour, Weekly, and Monthly rows returned by the official usage API, including the expanded sidebar. Use `tuiSidebarPanel.opencodeGoPreferredWindow` to prefer one available row only while the sidebar is collapsed. See [OpenCode Go setup](providers.md#opencode-go).

Xiaomi MiMo has no `quota-toast.json` credential or endpoint setting. Use `MIMO_USAGE_COOKIE` or trusted user/global `opencode-quota/mimo.json`; see [Xiaomi MiMo setup](providers.md#xiaomi-mimo).

Expand Down
12 changes: 6 additions & 6 deletions docs/readme/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ Credentials are checked in this order:

1. The environment variable named by `apiKeyEnv`.
2. Trusted global `provider.<providerId>.options.apiKey`.
3. An API-key entry in OpenCode `auth.json`.
3. An API-key entry in OpenCode `opencode.db`.

Project secrets are never read. Custom definitions cannot add scripts, methods, headers, templates, executable mappings, regular expressions, JSONPath, or automatic endpoint discovery.

Expand Down Expand Up @@ -387,7 +387,7 @@ claude auth status

If Claude lives at a custom path, set `anthropicBinaryPath` in `opencode-quota/quota-toast.json`.

When Claude Code does not expose quota windows itself, quota is read from Anthropic's OAuth usage endpoint using the first usable access token: OpenCode's own `anthropic` OAuth credential from `auth.json`, then Claude Code's credentials. `/quota_status` reports which store answered as `oauth_credential_source`.
When Claude Code does not expose quota windows itself, quota is read from Anthropic's OAuth usage endpoint using the first usable access token: OpenCode's own `anthropic` OAuth credential from `opencode.db`, then Claude Code's credentials. `/quota_status` reports which store answered as `oauth_credential_source`.

<a id="cursor"></a>

Expand Down Expand Up @@ -517,7 +517,7 @@ Credentials resolve in this order:

1. `KILO_API_KEY`
2. Trusted user/global OpenCode config: `provider.kilo.options.apiKey`
3. A strict `kilo` API-key entry in OpenCode `auth.json`: `{ "type": "api", "key": "..." }`
3. A strict `kilo` API-key entry in OpenCode `opencode.db`: `{ "type": "api", "key": "..." }`

Project-local `opencode.json` and `opencode.jsonc` files are not read for this secret. The canonical OpenCode provider ID is `kilo`; if you use manual provider selection, include `kilo` in `enabledProviders`.

Expand Down Expand Up @@ -572,7 +572,7 @@ Credentials resolve in this order:

1. `OLLAMA_API_KEY`
2. Trusted user/global OpenCode config: `provider.ollama-cloud.options.apiKey`
3. A strict `ollama-cloud` API-key entry in OpenCode `auth.json`: `{ "type": "api", "key": "..." }`
3. A strict `ollama-cloud` API-key entry in OpenCode `opencode.db`: `{ "type": "api", "key": "..." }`

Project-local `opencode.json` and `opencode.jsonc` files are not read for this secret. The old `OLLAMA_USAGE_COOKIE`, `ollama-cloud.json`, and `ollama-usage/config.yaml` cookie setup is no longer supported.

Expand All @@ -585,8 +585,8 @@ OpenCode Go reads subscription quota from the official `https://opencode.ai/zen/
1. `OPENCODE_API_KEY`
2. Trusted user/global OpenCode config: `provider.opencode-go.options.apiKey`
3. Trusted user/global fallback: `provider.opencode.options.apiKey`
4. A strict `opencode-go` API-key entry in OpenCode `auth.json`: `{ "type": "api", "key": "..." }`. This is the key the OpenCode CLI writes via `opencode auth login -p opencode-go`.
5. A strict legacy `opencode` API-key entry in `auth.json` as the final fallback.
4. A strict `opencode-go` API-key entry in OpenCode `opencode.db`: `{ "type": "api", "key": "..." }`. This is the key the OpenCode CLI writes via `opencode auth login -p opencode-go`.
5. A strict legacy `opencode` API-key entry in `opencode.db` as the final fallback.

Project-local `opencode.json` and `opencode.jsonc` files are not read for this secret. Use `opencodeGoWindows` to choose which validated API results appear across surfaces and in the expanded sidebar: **Five-hour**, **Weekly**, and/or **Monthly**. To keep those rows expanded but prefer one while the sidebar is collapsed, set `tuiSidebarPanel.opencodeGoPreferredWindow` to `rolling`, `weekly`, or `monthly`; an unset or unavailable preference keeps the lowest-remaining selection. These settings do not change authentication or the API request.

Expand Down
6 changes: 3 additions & 3 deletions docs/readme/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Run `/quota_status` and check the OpenAI auth source and token status.

| Symptom | Fix |
| --------------------- | ------------------------------------------------------------------------------------------ |
| OpenAI quota missing | Confirm OpenCode native OpenAI OAuth is present in `auth.json`. |
| OpenAI quota missing | Confirm OpenCode native OpenAI OAuth is present in `opencode.db`. |
| Token expired | Re-run OpenCode's OpenAI auth flow. |
| Provider not detected | Confirm your OpenCode config uses the `openai` provider or a compatible OpenAI auth entry. |

Expand Down Expand Up @@ -255,8 +255,8 @@ Run `/quota_status` and check the `opencode_go` section. It reports safe `auth_*

| Symptom | Fix |
| ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Provider not detected | Set `OPENCODE_API_KEY`, trusted global `provider.opencode-go.options.apiKey`, fallback `provider.opencode.options.apiKey`, a strict `opencode-go` API-key entry in OpenCode `auth.json`, or a strict legacy `opencode` auth entry as the final fallback. Then check `auth_state`, `auth_source`, and `auth_checked_paths`. |
| `auth_state` is `invalid` | Fix the primary `opencode-go` record in `auth.json` so it is `{ "type": "api", "key": "..." }`. A malformed primary record blocks the legacy `opencode` fallback and is reported in `auth_error`. |
| Provider not detected | Set `OPENCODE_API_KEY`, trusted global `provider.opencode-go.options.apiKey`, fallback `provider.opencode.options.apiKey`, a strict `opencode-go` API-key entry in OpenCode `opencode.db`, or a strict legacy `opencode` auth entry as the final fallback. Then check `auth_state`, `auth_source`, and `auth_checked_paths`. |
| `auth_state` is `invalid` | Fix the primary `opencode-go` record in `opencode.db` so it is `{ "type": "api", "key": "..." }`. A malformed primary record blocks the legacy `opencode` fallback and is reported in `auth_error`. |
| API returns 401 or 403 | The usage API rejected the key. Update the winning source shown by `auth_source`, wait briefly for credential caching to expire, and rerun `/quota_status`. |
| Invalid API response | Check `live_fetch_error`. OpenCode Quota requires valid 5h, Weekly, and Monthly results, so one missing or malformed API window rejects the full response instead of showing partial quota. |
| API request times out or fails | Check `live_fetch_error`, confirm `https://opencode.ai/zen/go/v1/usage` is reachable, and retry. Increase `requestTimeoutMs` only when the error is a timeout. |
Expand Down
2 changes: 1 addition & 1 deletion lefthook.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pre-commit:
commands:
biome:
glob: "*.{js,cjs,mjs,jsx,ts,tsx,json,jsonc,css}"
glob: "**/*.{js,cjs,mjs,jsx,ts,tsx,json,jsonc,css}"
run: pnpm exec biome check --write --no-errors-on-unmatched {staged_files}
stage_fixed: true

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"@babel/core": "^7.28.0",
"@babel/preset-typescript": "^7.27.1",
"@biomejs/biome": "2.3.11",
"@opencode-ai/plugin": "1.18.11",
"@opencode-ai/plugin": "1.18.1",
"@opentelemetry/sdk-metrics": "2.10.0",
"@types/node": "^22.0.0",
"babel-preset-solid": "^1.9.12",
Expand All @@ -98,8 +98,8 @@
"dependencies": {
"@clack/prompts": "^1.2.0",
"@opentelemetry/api": "^1.9.1",
"@opentui/core": "0.4.5",
"@opentui/solid": "0.4.5",
"@opentui/core": "^0.5.10",
"@opentui/solid": "^0.5.10",
"comment-json": "^5.0.0",
"jsonc-parser": "^3.3.1",
"solid-js": "^1.9.12",
Expand Down
Loading