new: [opencode-greenpt-usage] add GreenPT credit balance plugin
Show the remaining GreenPT API credit balance in the OpenCode TUI sidebar. The key is resolved from the ``apiKey`` option, the ``GREENPT_API_KEY`` environment variable, or the active OpenCode ``auth.json`` (provider ``greenpt``); the section is hidden when no key is present, so the plugin stays portable across machines and profiles. The balance is read from the ``x-credits-remaining`` header returned by a free ``HEAD /v1/chat/completions`` probe (HTTP 400 before any credit is consumed), which avoids a billable call per refresh. Tests cover the credential resolution, the header parsing and the live API. Distribute via git clone; there is no npm publish.
This commit is contained in:
36
package.json
Normal file
36
package.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "opencode-greenpt-usage",
|
||||
"version": "0.1.0",
|
||||
"description": "OpenCode TUI plugin that shows the remaining GreenPT API credit balance in the sidebar.",
|
||||
"type": "module",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"keywords": [
|
||||
"opencode",
|
||||
"opencode-plugin",
|
||||
"tui",
|
||||
"greenpt",
|
||||
"credits",
|
||||
"balance"
|
||||
],
|
||||
"engines": {
|
||||
"opencode": ">=1.18.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"test:integration": "GREENPT_INTEGRATION=1 vitest run test/integration.greenpt.test.ts",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@opencode-ai/plugin": "*",
|
||||
"@opentui/solid": "*",
|
||||
"solid-js": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@opencode-ai/plugin": "^1.18.33",
|
||||
"@opentui/solid": "^0.5.12",
|
||||
"@types/node": "^24.0.0",
|
||||
"solid-js": "^1.9.0",
|
||||
"typescript": "^5.6.0",
|
||||
"vitest": "^3.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user