@alex123bob/opencode-cache-stats 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/dist/tui.js +36 -43
  2. package/package.json +24 -14
package/dist/tui.js CHANGED
@@ -1,6 +1,31 @@
1
1
  import { isCompletedAssistant, extractTokens, accumulateStats, renderCacheStats } from './chunk-OFH6IIJI.js';
2
+ import { onCleanup } from 'solid-js';
3
+ import { jsx } from '@opentui/solid/jsx-runtime';
2
4
 
3
- // src/tui.ts
5
+ function CacheStatsWidget(props) {
6
+ props.sessionID;
7
+ const api = props.api;
8
+ const subscribe = props.subscribe;
9
+ const getStats = props.getStats;
10
+ let textNode;
11
+ const sync = () => {
12
+ if (!textNode) return;
13
+ const content = renderCacheStats(getStats());
14
+ textNode.content = content;
15
+ textNode.visible = content.length > 0;
16
+ textNode.height = content.length > 0 ? "auto" : 0;
17
+ api.renderer.requestRender();
18
+ };
19
+ onCleanup(subscribe(sync));
20
+ return jsx("text", {
21
+ ref: (ref) => {
22
+ textNode = ref;
23
+ sync();
24
+ },
25
+ fg: api.theme.current.textMuted,
26
+ children: renderCacheStats(getStats()) ?? ""
27
+ });
28
+ }
4
29
  var tui = async (api) => {
5
30
  const sessionStats = /* @__PURE__ */ new Map();
6
31
  const listeners = /* @__PURE__ */ new Set();
@@ -19,50 +44,18 @@ var tui = async (api) => {
19
44
  sessionStats.set(sessionID, accumulateStats(sessionStats.get(sessionID), tokens));
20
45
  bump();
21
46
  });
22
- let offSlots;
23
- try {
24
- let CacheStatsText2 = function(props) {
25
- const sessionID = props.sessionID;
26
- const propApi = props.api;
27
- const propSub = props.subscribe;
28
- if (!propSub || !propApi) return null;
29
- let textNode;
30
- const sync = () => {
31
- if (!textNode) return;
32
- const content = renderCacheStats(sessionStats.get(sessionID));
33
- textNode.content = content;
34
- textNode.visible = content.length > 0;
35
- textNode.height = content.length > 0 ? "auto" : 0;
36
- propApi.renderer.requestRender();
37
- };
38
- onCleanup(propSub(sync));
39
- return jsx("text", {
40
- ref: (ref) => {
41
- textNode = ref;
42
- sync();
43
- },
44
- fg: propApi.theme.current.textMuted,
45
- children: renderCacheStats(sessionStats.get(sessionID)) ?? ""
46
- });
47
- };
48
- var CacheStatsText = CacheStatsText2;
49
- const { jsx } = await import('@opentui/solid/jsx-runtime');
50
- const { onCleanup } = await import('solid-js');
51
- const registration = api.slots.register({
52
- slots: {
53
- sidebar_content: (_ctx, slotProps) => jsx(CacheStatsText2, {
54
- sessionID: slotProps.session_id ?? "",
55
- api,
56
- subscribe
57
- })
58
- }
59
- });
60
- offSlots = typeof registration === "function" ? registration : void 0;
61
- } catch {
62
- }
47
+ api.slots.register({
48
+ slots: {
49
+ sidebar_content: (_ctx, slotProps) => jsx(CacheStatsWidget, {
50
+ sessionID: slotProps.session_id ?? "",
51
+ api,
52
+ subscribe,
53
+ getStats: () => sessionStats.get(slotProps.session_id ?? "")
54
+ })
55
+ }
56
+ });
63
57
  api.lifecycle.onDispose(() => {
64
58
  offMessage();
65
- offSlots?.();
66
59
  });
67
60
  };
68
61
  var tui_default = tui;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@alex123bob/opencode-cache-stats",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "description": "opencode plugin — live cache hit rate widget in the TUI sidebar + per-session JSONL stats log",
6
6
  "type": "module",
7
7
  "author": "Alexander Li",
@@ -28,31 +28,41 @@
28
28
  "default": "./dist/tui.js"
29
29
  }
30
30
  },
31
- "files": ["dist", "README.md", "LICENSE"],
32
- "keywords": ["opencode", "plugin", "cache", "llm", "tui", "cache-hit-rate"],
33
- "engines": { "node": ">=22.13" },
31
+ "files": [
32
+ "dist",
33
+ "README.md",
34
+ "LICENSE"
35
+ ],
36
+ "keywords": [
37
+ "opencode",
38
+ "plugin",
39
+ "cache",
40
+ "llm",
41
+ "tui",
42
+ "cache-hit-rate"
43
+ ],
44
+ "engines": {
45
+ "node": ">=22.13"
46
+ },
34
47
  "scripts": {
35
48
  "build": "tsup",
36
49
  "typecheck": "tsc --noEmit",
37
50
  "prepublishOnly": "npm run typecheck && npm run build"
38
51
  },
39
- "peerDependencies": {
40
- "@opencode-ai/plugin": ">=1.15.0 <2",
41
- "@opentui/core": ">=0.4.0 <0.5",
42
- "@opentui/solid": ">=0.4.0 <0.5",
43
- "solid-js": ">=1.9.0 <2"
52
+ "dependencies": {
53
+ "@opentui/core": "^0.4.3",
54
+ "@opentui/solid": "^0.4.3",
55
+ "solid-js": "1.9.12"
44
56
  },
45
- "peerDependenciesMeta": {
46
- "@opentui/core": { "optional": true },
47
- "@opentui/solid": { "optional": true },
48
- "solid-js": { "optional": true }
57
+ "peerDependencies": {
58
+ "@opencode-ai/plugin": ">=1.15.0 <2"
49
59
  },
50
60
  "devDependencies": {
51
61
  "@opencode-ai/plugin": "^1.17.18",
52
62
  "@opentui/core": "^0.4.3",
53
63
  "@opentui/solid": "^0.4.3",
54
64
  "@types/node": "^24.0.0",
55
- "solid-js": "^1.9.14",
65
+ "solid-js": "1.9.12",
56
66
  "tsup": "^8.5.1",
57
67
  "typescript": "^5.8.3"
58
68
  }