@arandevcode/opencode-quota-extended 0.2.4 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README-es.md +23 -1
- package/README.md +23 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +17 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +12 -0
- package/dist/server.js.map +1 -1
- package/dist/tui.d.ts +3 -0
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.tsx +14 -1
- package/dist/v2.d.ts +61 -0
- package/dist/v2.d.ts.map +1 -0
- package/dist/v2.js +67 -0
- package/dist/v2.js.map +1 -0
- package/package.json +12 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.1 — 2026-11-06
|
|
4
|
+
- Fix installation from npm on OpenCode 1.x and 2: accept current `@opentui` versions (0.4 to 0.x), which the OpenCode plugin SDK now pulls in. Before this, `opencode plugin` failed with "unable to resolve dependency tree".
|
|
5
|
+
- README: separate install and uninstall steps for OpenCode 1.x and OpenCode 2, plus a compatibility table.
|
|
6
|
+
|
|
7
|
+
## 0.3.0 — 2026-11-06
|
|
8
|
+
- OpenCode 2 support (early preview): the package now registers on both OpenCode 1.x and 2.x; tested on 2.1.2.
|
|
9
|
+
|
|
10
|
+
## 0.2.4 — 2026-10-21
|
|
11
|
+
- OpenCode Go quota, spend and balance read with a personal API key.
|
|
12
|
+
- More compact sidebar layout.
|
|
13
|
+
|
|
14
|
+
## 0.2.3 — 2026-10-19
|
|
15
|
+
- Credit balance and usage pace in the sidebar.
|
|
16
|
+
- Coalesced TUI refreshes to stop provider error storms.
|
|
17
|
+
|
|
18
|
+
## 0.2.2 — 2026-08-06
|
|
19
|
+
- Allow OpenTUI 0.5 peer dependencies.
|
|
20
|
+
|
|
21
|
+
## 0.2.1 — 2026-08-05
|
|
22
|
+
- Packaging cleanup: removed stray files from the published package.
|
|
23
|
+
|
|
24
|
+
## 0.2.0 — 2026-08-05
|
|
25
|
+
- Theme-aware colors, single-row gauge, error boundary and guarded event handlers.
|
|
26
|
+
|
|
27
|
+
## 0.1.x — 2026-06 / 2026-07
|
|
28
|
+
- First releases: per-window quota cards for OpenAI, GitHub Copilot and OpenCode Go, plus the `quota` CLI.
|
package/README-es.md
CHANGED
|
@@ -29,6 +29,10 @@ Inspirado por [`@slkiser/opencode-quota`](https://github.com/slkiser/opencode-qu
|
|
|
29
29
|
|
|
30
30
|
## Instalación
|
|
31
31
|
|
|
32
|
+
Un solo paquete para las dos generaciones de OpenCode: trae una entrada para cada una y carga la que toca.
|
|
33
|
+
|
|
34
|
+
### OpenCode 1.x
|
|
35
|
+
|
|
32
36
|
```sh
|
|
33
37
|
opencode plugin --global --force @arandevcode/opencode-quota-extended
|
|
34
38
|
```
|
|
@@ -44,9 +48,27 @@ O instala desde GitHub para seguir el desarrollo más reciente:
|
|
|
44
48
|
}
|
|
45
49
|
```
|
|
46
50
|
|
|
51
|
+
### OpenCode 2 (versión preliminar)
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
opencode plugin add @arandevcode/opencode-quota-extended
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
En OpenCode 2 el comando es `plugin add` (no `plugin --global`). El soporte para OpenCode 2 es nuevo; si ves algo raro, [abre un issue](https://github.com/arandevcode/opencode-plugins/issues).
|
|
58
|
+
|
|
59
|
+
### Compatibilidad
|
|
60
|
+
|
|
61
|
+
| Función | OpenCode 1.x | OpenCode 2 |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| Tarjetas de cuota en la barra lateral | ✅ | ✅ |
|
|
64
|
+
| Cuota en vivo de OpenAI, Copilot y OpenCode Go | ✅ | ⚠️ aún no probado con cuentas reales |
|
|
65
|
+
| CLI `quota` | ✅ | ✅ (no depende de OpenCode) |
|
|
66
|
+
|
|
47
67
|
## Desinstalación
|
|
48
68
|
|
|
49
|
-
|
|
69
|
+
**OpenCode 2:** ejecuta `opencode plugin remove @arandevcode/opencode-quota-extended` y después, si quieres, los pasos opcionales de limpieza de abajo.
|
|
70
|
+
|
|
71
|
+
**OpenCode 1.x:** Cuatro pasos, en orden:
|
|
50
72
|
|
|
51
73
|
1. Quita la entrada del plugin en la config de OpenCode (`~/.config/opencode/opencode.json`):
|
|
52
74
|
|
package/README.md
CHANGED
|
@@ -30,6 +30,10 @@ Heavily inspired by [`@slkiser/opencode-quota`](https://github.com/slkiser/openc
|
|
|
30
30
|
|
|
31
31
|
## Install
|
|
32
32
|
|
|
33
|
+
One package for both OpenCode generations: it ships an entry for each and loads the right one.
|
|
34
|
+
|
|
35
|
+
### OpenCode 1.x
|
|
36
|
+
|
|
33
37
|
```sh
|
|
34
38
|
opencode plugin --global --force @arandevcode/opencode-quota-extended
|
|
35
39
|
```
|
|
@@ -45,9 +49,27 @@ Or install from GitHub source to follow latest development:
|
|
|
45
49
|
}
|
|
46
50
|
```
|
|
47
51
|
|
|
52
|
+
### OpenCode 2 (preview)
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
opencode plugin add @arandevcode/opencode-quota-extended
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
On OpenCode 2 the plugin command is `plugin add` (not `plugin --global`). Support for OpenCode 2 is new; please [open an issue](https://github.com/arandevcode/opencode-plugins/issues) if something looks wrong.
|
|
59
|
+
|
|
60
|
+
### Compatibility
|
|
61
|
+
|
|
62
|
+
| Feature | OpenCode 1.x | OpenCode 2 |
|
|
63
|
+
|---|---|---|
|
|
64
|
+
| Quota cards in the sidebar | ✅ | ✅ |
|
|
65
|
+
| Live quota from OpenAI, Copilot and OpenCode Go | ✅ | ⚠️ not yet tested with real accounts |
|
|
66
|
+
| `quota` CLI | ✅ | ✅ (does not depend on OpenCode) |
|
|
67
|
+
|
|
48
68
|
## Uninstall
|
|
49
69
|
|
|
50
|
-
|
|
70
|
+
**OpenCode 2:** run `opencode plugin remove @arandevcode/opencode-quota-extended`, then do the optional clean-up steps below.
|
|
71
|
+
|
|
72
|
+
**OpenCode 1.x:** Four steps, in order:
|
|
51
73
|
|
|
52
74
|
1. Remove the plugin entry from your OpenCode config (`~/.config/opencode/opencode.json`):
|
|
53
75
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6,9 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export default pluginModule;
|
|
13
|
-
export { quotaCardsServerPlugin };
|
|
9
|
+
import plugin from "./server.js";
|
|
10
|
+
export { quotaCardsServerPlugin } from "./server.js";
|
|
11
|
+
export default plugin;
|
|
14
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,eAAe,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode Quota Cards Plugin (server entry)
|
|
3
|
+
*
|
|
4
|
+
* Renders quota usage as progress-bar cards in the TUI sidebar for
|
|
5
|
+
* OpenAI, GitHub Copilot and OpenCode Go (5h / weekly / monthly).
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import plugin from "./server.js";
|
|
10
|
+
export { quotaCardsServerPlugin } from "./server.js";
|
|
11
|
+
export default plugin;
|
|
8
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,eAAe,MAAM,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenCode Quota Cards — server plugin (minimal).
|
|
2
|
+
* OpenCode Quota Cards — server plugin (minimal, dual V1/V2).
|
|
3
3
|
*
|
|
4
4
|
* This plugin is primarily a TUI sidebar plugin. The server module
|
|
5
5
|
* is kept registered for compatibility but provides no additional
|
|
6
6
|
* tools or commands.
|
|
7
|
+
*
|
|
8
|
+
* Both `index.ts` (root) and this `./server` entry export the same object.
|
|
9
|
+
* V1's `oc-plugin: ["server"]` loads it and calls `server`; V2 resolves the
|
|
10
|
+
* `./server` subpath first for dual packages and reads `id` + `setup`. Keeping
|
|
11
|
+
* both entries V2-shaped avoids the "Plugin must export a default definition"
|
|
12
|
+
* error when V2 discovers a directory that contains both files.
|
|
7
13
|
*/
|
|
8
14
|
import type { Plugin } from "@opencode-ai/plugin";
|
|
9
15
|
export declare const quotaCardsServerPlugin: Plugin;
|
|
16
|
+
type V2SetupContext = {
|
|
17
|
+
storage?: unknown;
|
|
18
|
+
location?: unknown;
|
|
19
|
+
};
|
|
20
|
+
declare const plugin: {
|
|
21
|
+
id: string;
|
|
22
|
+
server: Plugin;
|
|
23
|
+
setup(ctx?: V2SetupContext): Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
export default plugin;
|
|
10
26
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,MAAM,EAAS,MAAM,qBAAqB,CAAC;AAEzD,eAAO,MAAM,sBAAsB,EAAE,MAEpC,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,QAAA,MAAM,MAAM;;YAEwB,MAAM;gBACtB,cAAc;CAMjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
export const quotaCardsServerPlugin = async () => {
|
|
2
2
|
return {};
|
|
3
3
|
};
|
|
4
|
+
const plugin = {
|
|
5
|
+
id: "@local/opencode-quota-extended",
|
|
6
|
+
server: quotaCardsServerPlugin,
|
|
7
|
+
async setup(ctx) {
|
|
8
|
+
// OpenCode 1.19.x calls setup() too, but without the V2 context.
|
|
9
|
+
if (!ctx?.storage || !ctx?.location)
|
|
10
|
+
return;
|
|
11
|
+
// V2 has no server-side quota work. The TUI cards are still V1-only;
|
|
12
|
+
// this entry point exists so V2 can load the package without error.
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export default plugin;
|
|
4
16
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,sBAAsB,GAAW,KAAK,IAAoB,EAAE;IACvE,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAOF,MAAM,MAAM,GAAG;IACb,EAAE,EAAE,gCAAgC;IACpC,MAAM,EAAE,sBAAgC;IACxC,KAAK,CAAC,KAAK,CAAC,GAAoB;QAC9B,iEAAiE;QACjE,IAAI,CAAC,GAAG,EAAE,OAAO,IAAI,CAAC,GAAG,EAAE,QAAQ;YAAE,OAAO;QAC5C,qEAAqE;QACrE,oEAAoE;IACtE,CAAC;CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/tui.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { TuiPlugin, TuiPluginModule } from "@opencode-ai/plugin/tui";
|
|
2
|
+
import { type V2Context } from "./v2.js";
|
|
2
3
|
export declare const quotaCardsTuiPlugin: TuiPlugin;
|
|
4
|
+
export declare function quotaCardsTuiV2(context: V2Context): Promise<() => void>;
|
|
3
5
|
declare const pluginModule: TuiPluginModule & {
|
|
4
6
|
id: string;
|
|
7
|
+
setup?: (context: V2Context) => Promise<() => void>;
|
|
5
8
|
};
|
|
6
9
|
export default pluginModule;
|
|
7
10
|
//# sourceMappingURL=tui.d.ts.map
|
package/dist/tui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../src/tui.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../src/tui.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAK1E,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAO3D,eAAO,MAAM,mBAAmB,EAAE,SAkFjC,CAAC;AAEF,wBAAsB,eAAe,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAS7E;AAED,QAAA,MAAM,YAAY,EAAE,eAAe,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,KAAK,OAAO,CAAC,MAAM,IAAI,CAAC,CAAA;CAItG,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/dist/tui.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import { loadCardsConfig } from "./config/loader.js";
|
|
|
5
5
|
import { createRefreshScheduler } from "./lib/refresh-scheduler.js";
|
|
6
6
|
import { collectSnapshot } from "./providers/registry.js";
|
|
7
7
|
import { SidebarPanel } from "./ui/SidebarPanel.js";
|
|
8
|
+
import { createQuotaV2Api, type V2Context } from "./v2.js";
|
|
8
9
|
|
|
9
10
|
const REFRESH_INTERVAL_MS = 60_000;
|
|
10
11
|
const MOUNT_RECOVERY_DELAY_MS = 1_500;
|
|
@@ -95,9 +96,21 @@ export const quotaCardsTuiPlugin: TuiPlugin = async (api, _options, _meta) => {
|
|
|
95
96
|
}
|
|
96
97
|
};
|
|
97
98
|
|
|
98
|
-
|
|
99
|
+
export async function quotaCardsTuiV2(context: V2Context): Promise<() => void> {
|
|
100
|
+
const cleanups: Array<() => void> = [];
|
|
101
|
+
const api = createQuotaV2Api(context, cleanups);
|
|
102
|
+
await quotaCardsTuiPlugin(api, context.options ?? {}, {} as any);
|
|
103
|
+
return () => {
|
|
104
|
+
for (const cleanup of cleanups.reverse()) {
|
|
105
|
+
try { cleanup(); } catch {}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const pluginModule: TuiPluginModule & { id: string; setup?: (context: V2Context) => Promise<() => void> } = {
|
|
99
111
|
id: "@local/opencode-quota-extended",
|
|
100
112
|
tui: quotaCardsTuiPlugin,
|
|
113
|
+
setup: quotaCardsTuiV2,
|
|
101
114
|
};
|
|
102
115
|
|
|
103
116
|
export default pluginModule;
|
package/dist/v2.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export type V2Theme = {
|
|
2
|
+
text?: {
|
|
3
|
+
base?: string;
|
|
4
|
+
muted?: string;
|
|
5
|
+
} | string;
|
|
6
|
+
accent?: {
|
|
7
|
+
base?: string;
|
|
8
|
+
} | string;
|
|
9
|
+
background?: {
|
|
10
|
+
panel?: string;
|
|
11
|
+
element?: string;
|
|
12
|
+
};
|
|
13
|
+
status?: {
|
|
14
|
+
success?: string;
|
|
15
|
+
warning?: string;
|
|
16
|
+
danger?: string;
|
|
17
|
+
error?: string;
|
|
18
|
+
};
|
|
19
|
+
primary?: string;
|
|
20
|
+
success?: string;
|
|
21
|
+
warning?: string;
|
|
22
|
+
error?: string;
|
|
23
|
+
textMuted?: string;
|
|
24
|
+
backgroundPanel?: string;
|
|
25
|
+
backgroundElement?: string;
|
|
26
|
+
};
|
|
27
|
+
export type V2Context = {
|
|
28
|
+
theme?: V2Theme;
|
|
29
|
+
options?: Record<string, unknown>;
|
|
30
|
+
data?: {
|
|
31
|
+
on?: (type: string, handler: (event: unknown) => void) => () => void;
|
|
32
|
+
listen?: (handler: (event: unknown) => void) => () => void;
|
|
33
|
+
};
|
|
34
|
+
ui?: {
|
|
35
|
+
slot?: (input: {
|
|
36
|
+
append?: string;
|
|
37
|
+
render: (props: {
|
|
38
|
+
sessionID?: string;
|
|
39
|
+
}) => unknown;
|
|
40
|
+
}) => () => void;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare function asColor(value: unknown, fallback: string): string;
|
|
44
|
+
export declare function v2Theme(theme?: V2Theme): {
|
|
45
|
+
text: string;
|
|
46
|
+
textMuted: string;
|
|
47
|
+
primary: string;
|
|
48
|
+
accent: string;
|
|
49
|
+
success: string;
|
|
50
|
+
warning: string;
|
|
51
|
+
error: string;
|
|
52
|
+
backgroundPanel: string;
|
|
53
|
+
backgroundElement: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Adapt a V2 CLI plugin context to the V1 TUI API the cards already use.
|
|
57
|
+
* The components only read `theme.current`; events and slots are bridged so
|
|
58
|
+
* the existing refresh scheduler and sidebar markup stay unchanged.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createQuotaV2Api(context: V2Context, cleanups: Array<() => void>): any;
|
|
61
|
+
//# sourceMappingURL=v2.d.ts.map
|
package/dist/v2.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../src/v2.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC;IAClD,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC;IACpC,UAAU,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,EAAE;QACL,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;QACrE,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;KAC5D,CAAC;IACF,EAAE,CAAC,EAAE;QACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE;YAAE,MAAM,CAAC,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,CAAC,KAAK,EAAE;gBAAE,SAAS,CAAC,EAAE,MAAM,CAAA;aAAE,KAAK,OAAO,CAAA;SAAE,KAAK,MAAM,IAAI,CAAC;KACvG,CAAC;CACH,CAAC;AAEF,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMhE;AAED,wBAAgB,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO;;;;;;;;;;EAatC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,GAuCjC,GAAG,CACjD"}
|
package/dist/v2.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export function asColor(value, fallback) {
|
|
2
|
+
if (typeof value === "string")
|
|
3
|
+
return value;
|
|
4
|
+
if (value && typeof value === "object" && typeof value.base === "string") {
|
|
5
|
+
return value.base;
|
|
6
|
+
}
|
|
7
|
+
return fallback;
|
|
8
|
+
}
|
|
9
|
+
export function v2Theme(theme) {
|
|
10
|
+
const text = theme?.text;
|
|
11
|
+
return {
|
|
12
|
+
text: typeof text === "string" ? text : asColor(text?.base, "#ffffff"),
|
|
13
|
+
textMuted: typeof text === "object" ? asColor(text?.muted, "#888888") : asColor(theme?.textMuted, "#888888"),
|
|
14
|
+
primary: asColor(theme?.primary, "#4aa3ff"),
|
|
15
|
+
accent: asColor(theme?.accent, "#4aa3ff"),
|
|
16
|
+
success: asColor(theme?.status?.success ?? theme?.success, "#4cc46a"),
|
|
17
|
+
warning: asColor(theme?.status?.warning ?? theme?.warning, "#e6b450"),
|
|
18
|
+
error: asColor(theme?.status?.danger ?? theme?.status?.error ?? theme?.error, "#e5534b"),
|
|
19
|
+
backgroundPanel: asColor(theme?.background?.panel ?? theme?.backgroundPanel, "#111111"),
|
|
20
|
+
backgroundElement: asColor(theme?.background?.element ?? theme?.backgroundElement, "#222222"),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Adapt a V2 CLI plugin context to the V1 TUI API the cards already use.
|
|
25
|
+
* The components only read `theme.current`; events and slots are bridged so
|
|
26
|
+
* the existing refresh scheduler and sidebar markup stay unchanged.
|
|
27
|
+
*/
|
|
28
|
+
export function createQuotaV2Api(context, cleanups) {
|
|
29
|
+
const currentTheme = v2Theme(context.theme);
|
|
30
|
+
const theme = { current: currentTheme };
|
|
31
|
+
Object.defineProperty(theme, "current", { get: () => v2Theme(context.theme) });
|
|
32
|
+
const event = {
|
|
33
|
+
on(_type, handler) {
|
|
34
|
+
const unsubscribe = context.data?.on?.("session.execution.started", handler)
|
|
35
|
+
?? context.data?.on?.("session.updated", handler)
|
|
36
|
+
?? (() => { });
|
|
37
|
+
if (context.data?.listen) {
|
|
38
|
+
const stop = context.data.listen(handler);
|
|
39
|
+
cleanups.push(stop);
|
|
40
|
+
}
|
|
41
|
+
cleanups.push(unsubscribe);
|
|
42
|
+
return () => {
|
|
43
|
+
unsubscribe();
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const lifecycle = {
|
|
48
|
+
onDispose(fn) {
|
|
49
|
+
cleanups.push(fn);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
const slots = {
|
|
53
|
+
register(input) {
|
|
54
|
+
const render = input.slots.sidebar_content;
|
|
55
|
+
if (!render || !context.ui?.slot)
|
|
56
|
+
return;
|
|
57
|
+
const dispose = context.ui.slot({
|
|
58
|
+
append: "sidebar.content",
|
|
59
|
+
render: (props) => render({}, { session_id: props.sessionID ?? "" }),
|
|
60
|
+
});
|
|
61
|
+
if (typeof dispose === "function")
|
|
62
|
+
cleanups.push(dispose);
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
return { theme, event, lifecycle, slots };
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=v2.js.map
|
package/dist/v2.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v2.js","sourceRoot":"","sources":["../src/v2.ts"],"names":[],"mappings":"AA0BA,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,QAAgB;IACtD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACjG,OAAQ,KAA0B,CAAC,IAAI,CAAC;IAC1C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAe;IACrC,MAAM,IAAI,GAAG,KAAK,EAAE,IAAI,CAAC;IACzB,OAAO;QACL,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC;QACtE,SAAS,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC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C;AACnD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arandevcode/opencode-quota-extended",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "OpenCode plugin: quota usage cards with theme-colored gauge progress bars (5h / weekly / monthly) for OpenAI, GitHub Copilot and OpenCode Go in the TUI sidebar.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"scripts/setup.mjs",
|
|
36
36
|
"README.md",
|
|
37
37
|
"README-es.md",
|
|
38
|
-
"LICENSE"
|
|
38
|
+
"LICENSE",
|
|
39
|
+
"CHANGELOG.md"
|
|
39
40
|
],
|
|
40
41
|
"scripts": {
|
|
41
42
|
"clean": "node scripts/clean.mjs",
|
|
@@ -53,8 +54,8 @@
|
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
56
|
"@opencode-ai/plugin": "^1.4.3",
|
|
56
|
-
"@opentui/core": "
|
|
57
|
-
"@opentui/solid": "
|
|
57
|
+
"@opentui/core": ">=0.4.1 <1",
|
|
58
|
+
"@opentui/solid": ">=0.4.1 <1",
|
|
58
59
|
"solid-js": "^1.9.12"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
@@ -74,5 +75,11 @@
|
|
|
74
75
|
"access": "public"
|
|
75
76
|
},
|
|
76
77
|
"author": "arandevcode",
|
|
77
|
-
"license": "MIT"
|
|
78
|
+
"license": "MIT",
|
|
79
|
+
"repository": {
|
|
80
|
+
"type": "git",
|
|
81
|
+
"url": "git+https://github.com/arandevcode/opencode-plugins.git",
|
|
82
|
+
"directory": "opencode-quota-extended"
|
|
83
|
+
},
|
|
84
|
+
"homepage": "https://github.com/arandevcode/opencode-plugins/tree/main/opencode-quota-extended#readme"
|
|
78
85
|
}
|