You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ba5ed80
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: .github/CONTRIBUTING.md
+16-17Lines changed: 16 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,31 +11,31 @@ Thanks for contributing! Please read this before you open an issue or PR.
11
11
12
12
## Setup
13
13
14
-
Node.js `^22.13.0 || >=23.4.0` and pnpm 11:
14
+
Node.js 22.18+, 24.11+ or 26+ (what Vite+ needs; the published plugin itself runs on `^22.13.0 || >=23.4.0`) and pnpm 11:
15
15
16
16
```sh
17
17
corepack enable
18
-
corepack prepare pnpm@11.0.0 --activate
18
+
corepack prepare pnpm@11.7.0 --activate
19
19
pnpm install
20
20
```
21
21
22
-
`pnpm install` also installs the Git hooks: pre-commit formats staged files with Biome; pre-push runs `pnpm verify`.
22
+
`pnpm install` also installs the Git hooks: pre-commit formats and lints staged files and fixes what it can with Vite+ (`vp check --fix`); pre-push runs `pnpm verify`.
23
23
24
24
## Checks
25
25
26
-
Run `pnpm verify` before opening a PR. It runs lint and formatting, typecheck, build, all tests, the four-surface test, and package checks. CI runs the same command, then installs the packed package on Node 22 and 24 as a smoke test.
26
+
Run `pnpm verify` before opening a PR. It runs lint and formatting, the TypeScript-version and history checks, the build (its `tsc` step is the type check), all tests (the cross-surface test among them), and the package contents check. CI runs the same command, then installs the packed package on Node 22 and 24 as a smoke test.
27
27
28
28
For quick iteration: `pnpm run test:watch`.
29
29
30
30
## Rules the code must keep
31
31
32
32
-**No AI calls.** Never send a request to an AI model to produce anything the plugin shows (quota rows, toasts, command output); it would spend the user's tokens. Calling a provider's quota or billing API is fine.
33
33
-**OpenCode 2 only.** No OpenCode 1 code, APIs, or tables.
34
-
-**Server vs. TUI.** The server plugin (`src/plugin.ts`) computes all text and registers the `quota_status` tool, the slash commands, and the `slkiser.opencode-quota` RPC. The TUI plugin (`src/tui-v2.tsx`) only draws what the RPC returns and never imports provider or credential code. Web and Desktop get slash commands only; OpenCode 2 has no plugin UI hooks there.
35
-
-**One command path.**Every slash command, the `quota_status` tool, and the RPC `command` method go through `buildQuotaDialogCommandOutput()`.
34
+
-**Server vs. TUI.** The server plugin (`src/plugin.ts`) reads providers, settings, and OpenCode's history, and registers the slash commands, the agent tools, and the `slkiser.opencode-quota` RPC. The TUI plugin (`src/tui/index.tsx`) only draws what the RPC returns and never imports provider or credential code. Web and Desktop get the slash commands only; OpenCode 2 has no plugin UI hooks there.
35
+
-**One status report.**`/quota_status`, the `quota_status` tool, and the RPC `status` method go through `buildQuotaDialogCommandOutput()`; `opencode-quota status` uses `buildStatusReportData()`, which that function wraps. Every value the report prints comes from a known list, a formatted number, or a placeholder (`tests/lib.quota-status.test.ts` checks this).
36
36
-**Credentials.** Read OpenCode logins only through `ctx.integration` in `src/lib/opencode-auth.ts`. The only exception is the terminal command (`src/lib/cli-show.ts`), which uses `src/lib/opencode-auth-sqlite.ts`; the plugins must never reach that file.
37
-
-**Money.**Show amounts with the provider's ISO code through the shared formatter (e.g. `USD 12.50`). No symbols, conversions, or adding up different currencies.
38
-
- Keep these boundary tests passing and up to date: `tests/plugin.command-handled-boundary.test.ts`, `tests/tui-dist-import-graph.test.ts`, `tests/plugin.question-hook.test.ts`, `tests/quota-provider-boundary.test.ts`.
37
+
-**Money.**Use the shared formatter, which shows USD as `$12.50` and other currencies with an ISO code after the amount, such as `8.25 CNY`. Never convert amounts or add up different currencies.
38
+
- Keep these boundary tests passing and up to date: `tests/plugin.command-handled-boundary.test.ts`, `tests/tui-dist-import-graph.test.ts`, `tests/quota-provider-boundary.test.ts`, `tests/v6-cross-surface.test.ts`.
39
39
40
40
## Provider changes
41
41
@@ -53,30 +53,29 @@ Even then, it needs a reasonable maintenance cost.
53
53
| You want to… | Use |
54
54
| --- | --- |
55
55
| Use an OpenAI-compatible model service OpenCode doesn't include | an OpenCode custom provider |
56
-
| Track quota for a provider OpenCode already exposes (request estimates or one fixed quota endpoint) | an OpenCode Quota custom provider (`provider add`); its `providerId` must match OpenCode's |
56
+
| Track quota for a provider OpenCode already exposes (request estimates or one fixed quota endpoint) | an OpenCode Quota custom provider ([ask your agent](../docs/readme/providers.md#custom-providers)); its `providerId` must match OpenCode's |
57
57
| Anything the custom path can't do, and the policy above is met | a built-in provider |
58
58
59
-
**Building one:** for API-key or token providers, start from `contributing/provider-template/` (see its README), replace every example name, and add tests for every auth source. Use the README setup label that matches reality: `Automatic` or `Needs setup`.
59
+
**Building one:** for API-key or token providers, start from `.github/provider-template/` (see its README), replace every example name, and add tests for every auth source. Use the setup label in `docs/readme/providers.md` that matches reality: `Automatic` or `Needs setup`.
60
60
61
-
**Every row**carries `AccountingMetadata`. Pick `resultType` by what the number means (`quota`, `rate_limit`, `usage`, `spend`, `budget`, `balance`, `status`), not by what's easiest to draw, and name the real source in `authority`. `user_configured` is only for a basis fact such as a user-set limit, never a row.
61
+
**Every row**follows the row contract in `src/providers/contract.ts`. Pick `type` by what the number means (`quota`, `budget`, `usage`, `balance`, `status`), not by what's easiest to draw; `method` by how it was read (`remote_api`, `dashboard_scrape`, `local_cli`, `local_estimation`); and `authority` by who worked it out (`provider_reported` or `locally_derived`). A row's `key` is part of its id, which users' settings use, so it never changes once released.
62
62
63
63
Rich providers (more than a percentage) also:
64
64
65
-
- send numbers as typed `quantity` rows or percentage `basis` facts, and booleans as `boolean` rows; never pre-formatted money strings;
66
-
- set `semantic` with an explicit `primary` or `supplementary` prominence;
65
+
- send numbers as typed `used`, `limit`, `remaining`or `amount` values and yes/no as `flag`; never pre-formatted money strings;
66
+
- set an explicit `primary` or `supplementary` prominence;
67
67
- keep `used`, `limit`, and `remaining` literal;
68
-
- keep labels short: the concept only, no values, units, or reset text;
69
-
- format through the shared accounting formatter.
68
+
- keep labels short: the concept only, no values, units, or reset text.
70
69
71
-
A simple percentage-only provider may keep the plain percent row, with accurate `AccountingMetadata`.
70
+
A simple percentage-only provider may keep the plain percent row (`quotaRow`).
72
71
73
72
## Fixes
74
73
75
74
Make the smallest safe fix for the root cause. Match current OpenCode behavior instead of adding extra hook layers. Test against the current released OpenCode version and name it in the PR.
76
75
77
76
## Before-and-after screenshots (required)
78
77
79
-
Every PR that changes what users see must include before-and-after screenshots taken with the same config, model, theme, and window size, with credentials, account identifiers, and private paths hidden. For quota changes, report each surface: Web, TUI sidebar, toast, and the compact line under the message input (plus the prompt bar or command dialog if relevant). Say which ones you didn't test. Tests don't replace screenshots, and screenshots don't replace tests. No visible change? Write `Not applicable` and why.
78
+
Every PR that changes what users see must include before-and-after screenshots taken with the same config, model, theme, and window size, with credentials, account identifiers, and private paths hidden. Report each surface the change can reach: TUI sidebar (open and collapsed), the status line below the message input, toasts, the `/quota` window tabs (Usage, Limits, Plugin, and the Settings tabs), Web and Desktop text commands, and CLI `show`/`status`. For export, telemetry, or agent tools, paste the output before and after. Say which ones you didn't test. Tests don't replace screenshots, and screenshots don't replace tests. No visible change? Write `Not applicable` and why.
0 commit comments