chg: [opencode-greenpt-usage] port the TUI plugin to OpenCode 2

V1 TUI modules no longer load: replace ``{ id, tui }`` with
``Plugin.define({ id, setup })``, register the section on
``sidebar.content``, and expose commands through ``context.keymap.layer``.

Move balance, clock and usage state onto ``context.storage.store/memory``
so host subscribers rerender; plugin-created signals stayed stale in the
V2 renderer. Read V2 assistant messages (``type``,
``model.providerID``/``model.id``) and subscribe through ``context.data``.

Configure the package directory in ``cli.json`` instead of the source
file; document the V2 install. Typecheck, 49 unit tests and the live
GreenPT integration test pass, and the sidebar renders the balance.
This commit is contained in:
Stéphan Sainléger
2026-11-18 23:01:40 +01:00
parent 9c84473266
commit dadc93a22d
13 changed files with 4757 additions and 671 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "opencode-greenpt-usage",
"version": "0.1.0",
"description": "OpenCode TUI plugin that shows the remaining GreenPT API credit balance in the sidebar.",
"description": "OpenCode 2 TUI plugin that shows the remaining GreenPT API credit balance in the sidebar.",
"type": "module",
"license": "AGPL-3.0-or-later",
"keywords": [
@@ -13,21 +13,29 @@
"balance"
],
"engines": {
"opencode": ">=1.18.0"
"opencode": ">=2.0.0"
},
"exports": {
".": "./src/index.tsx",
"./tui": "./src/index.tsx"
},
"scripts": {
"test": "vitest run",
"test:integration": "GREENPT_INTEGRATION=1 vitest run test/integration.greenpt.test.ts",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@opencode/plugin": "^2.0.32"
},
"peerDependencies": {
"@opencode-ai/plugin": "*",
"@opentui/solid": "*",
"solid-js": "*"
"@opentui/core": ">=0.6.6",
"@opentui/solid": ">=0.6.6",
"solid-js": ">=1.9.0"
},
"devDependencies": {
"@opencode-ai/plugin": "^1.18.33",
"@opentui/solid": "^0.5.12",
"@opencode/plugin": "^2.0.32",
"@opentui/core": "^0.6.6",
"@opentui/solid": "^0.6.6",
"@types/node": "^24.0.0",
"solid-js": "^1.9.0",
"typescript": "^5.6.0",