opencode-usage-total 0.1.3 → 0.1.4

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.
@@ -0,0 +1,12 @@
1
+ import { TuiPlugin } from '@opencode-ai/plugin/tui';
2
+ export { UsageTotalPlugin } from './usage-total.js';
3
+ import '@opencode-ai/plugin';
4
+
5
+ /** @jsxImportSource @opentui/solid */
6
+
7
+ declare const _default: {
8
+ id: string;
9
+ tui: TuiPlugin;
10
+ };
11
+
12
+ export { _default as default };
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  import { createRoot, createSignal } from "solid-js";
7
7
 
8
8
  // package.json
9
- var version = "0.1.3";
9
+ var version = "0.1.4";
10
10
 
11
11
  // helpers.ts
12
12
  function safeNum(value) {
@@ -17,11 +17,13 @@ function roundCost(n) {
17
17
  return safeNum(Number(n.toFixed(6)));
18
18
  }
19
19
  function fmtTokens(n) {
20
- if (n < 0) return "0";
21
- if (!Number.isFinite(n) || n === 0) return "0";
22
- if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`;
23
- if (n >= 1e3) return `${(n / 1e3).toFixed(1)}k`;
24
- return String(Math.round(n));
20
+ if (!Number.isFinite(n) || n < 0) return "0";
21
+ const r = Math.round(n);
22
+ if (r < 1e3) return String(r);
23
+ if (r >= 1e6 || Math.round(r / 100) >= 1e4) {
24
+ return `${(r / 1e6).toFixed(1)}M`;
25
+ }
26
+ return `${(r / 1e3).toFixed(1)}k`;
25
27
  }
26
28
  function fmtCost(n) {
27
29
  if (n < 0) return "";
@@ -174,8 +176,7 @@ var tui = async (api) => {
174
176
  tokensCacheRead: safeNum(existing.tokensCacheRead + safeCacheRead),
175
177
  tokensCacheWrite: safeNum(
176
178
  existing.tokensCacheWrite + safeCacheWrite
177
- ),
178
- messageCount: existing.messageCount + 1
179
+ )
179
180
  };
180
181
  } else {
181
182
  sessionModels.push({
@@ -185,8 +186,7 @@ var tui = async (api) => {
185
186
  tokensOutput: safeOutput,
186
187
  tokensReasoning: safeReasoning,
187
188
  tokensCacheRead: safeCacheRead,
188
- tokensCacheWrite: safeCacheWrite,
189
- messageCount: 1
189
+ tokensCacheWrite: safeCacheWrite
190
190
  });
191
191
  }
192
192
  setModelState({
@@ -0,0 +1,5 @@
1
+ import { Plugin } from '@opencode-ai/plugin';
2
+
3
+ declare const UsageTotalPlugin: Plugin;
4
+
5
+ export { UsageTotalPlugin };
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "opencode-usage-total",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Track model usage, tokens, and costs per agent in the OpenCode TUI sidebar",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "exports": {
8
- ".": "./dist/index.js",
9
- "./runtime": "./dist/usage-total.js"
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ },
12
+ "./runtime": {
13
+ "types": "./dist/usage-total.d.ts",
14
+ "import": "./dist/usage-total.js"
15
+ }
10
16
  },
11
17
  "files": [
12
18
  "dist",