@alex123bob/opencode-cache-stats 1.0.2 → 1.0.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.
- package/dist/index.d.ts +1 -4
- package/dist/index.js +2 -6
- package/dist/tui.js +36 -43
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { Plugin } from '@opencode-ai/plugin';
|
|
2
|
-
import { TuiPlugin } from '@opencode-ai/plugin/tui';
|
|
3
2
|
|
|
4
3
|
declare const server: Plugin;
|
|
5
|
-
declare const tui: TuiPlugin;
|
|
6
4
|
declare const id = "opencode-cache-stats";
|
|
7
5
|
declare const _default: {
|
|
8
6
|
id: string;
|
|
9
7
|
server: Plugin;
|
|
10
|
-
tui: TuiPlugin;
|
|
11
8
|
};
|
|
12
9
|
|
|
13
|
-
export { _default as default, id, server
|
|
10
|
+
export { _default as default, id, server };
|
package/dist/index.js
CHANGED
|
@@ -29,11 +29,7 @@ var server = async (_input) => {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
|
-
var tui = async (...args) => {
|
|
33
|
-
const mod = await import('./tui.js');
|
|
34
|
-
return mod.tui(...args);
|
|
35
|
-
};
|
|
36
32
|
var id = "opencode-cache-stats";
|
|
37
|
-
var src_default = { id, server
|
|
33
|
+
var src_default = { id, server };
|
|
38
34
|
|
|
39
|
-
export { src_default as default, id, server
|
|
35
|
+
export { src_default as default, id, server };
|
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
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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.
|
|
4
|
+
"version": "1.0.4",
|
|
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",
|