@clwnd/opencode 0.18.4 → 0.18.5
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/tui.js +92 -0
- package/package.json +4 -1
package/dist/tui.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// tui.tsx
|
|
2
|
+
import { createSignal, onCleanup, createMemo } from "solid-js";
|
|
3
|
+
var SOCK_PATH = (() => {
|
|
4
|
+
const runtime = process.env.XDG_RUNTIME_DIR;
|
|
5
|
+
const sock = process.env.CLWND_SOCKET ?? (runtime ? `${runtime}/clwnd/clwnd.sock` : "/tmp/clwnd/clwnd.sock");
|
|
6
|
+
return sock + ".http";
|
|
7
|
+
})();
|
|
8
|
+
async function fetchDaemon() {
|
|
9
|
+
try {
|
|
10
|
+
const [statusResp, savingsResp] = await Promise.all([
|
|
11
|
+
fetch("http://localhost/status", { unix: SOCK_PATH }),
|
|
12
|
+
fetch("http://localhost/savings", { unix: SOCK_PATH })
|
|
13
|
+
]);
|
|
14
|
+
const status = await statusResp.json();
|
|
15
|
+
const savings = await savingsResp.json();
|
|
16
|
+
const c = savings.counters ?? {};
|
|
17
|
+
return {
|
|
18
|
+
status: "connected",
|
|
19
|
+
procs: (status.procs ?? []).length,
|
|
20
|
+
sessions: status.sessions ?? 0,
|
|
21
|
+
uptimeMin: Math.round((savings.uptimeMs ?? 0) / 6e4),
|
|
22
|
+
readDedup: c.readDedupHits ?? 0,
|
|
23
|
+
bashCapped: c.bashTruncated ?? 0,
|
|
24
|
+
contextWarnings: c.contextOverThreshold ?? 0
|
|
25
|
+
};
|
|
26
|
+
} catch {
|
|
27
|
+
return {
|
|
28
|
+
status: "disconnected",
|
|
29
|
+
procs: 0,
|
|
30
|
+
sessions: 0,
|
|
31
|
+
uptimeMin: 0,
|
|
32
|
+
readDedup: 0,
|
|
33
|
+
bashCapped: 0,
|
|
34
|
+
contextWarnings: 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function View(props) {
|
|
39
|
+
const theme = () => props.api.theme.current;
|
|
40
|
+
const [data, setData] = createSignal({
|
|
41
|
+
status: "disconnected",
|
|
42
|
+
procs: 0,
|
|
43
|
+
sessions: 0,
|
|
44
|
+
uptimeMin: 0,
|
|
45
|
+
readDedup: 0,
|
|
46
|
+
bashCapped: 0,
|
|
47
|
+
contextWarnings: 0
|
|
48
|
+
});
|
|
49
|
+
const poll = () => fetchDaemon().then(setData).catch(() => {
|
|
50
|
+
});
|
|
51
|
+
poll();
|
|
52
|
+
const timer = setInterval(poll, 1e4);
|
|
53
|
+
onCleanup(() => clearInterval(timer));
|
|
54
|
+
const dot = createMemo(() => data().status === "connected" ? "\u25CF" : "\u25CB");
|
|
55
|
+
const dotColor = createMemo(() => data().status === "connected" ? theme().success : theme().error);
|
|
56
|
+
return <box>
|
|
57
|
+
<text fg={theme().text}>
|
|
58
|
+
<b>clwnd</b>
|
|
59
|
+
</text>
|
|
60
|
+
<text>
|
|
61
|
+
<text fg={dotColor()}>{dot()}</text>
|
|
62
|
+
<text fg={theme().textMuted}> {data().status} · {data().uptimeMin}m uptime</text>
|
|
63
|
+
</text>
|
|
64
|
+
<text fg={theme().textMuted}>
|
|
65
|
+
{data().procs} proc{data().procs !== 1 ? "s" : ""} · {data().sessions} session{data().sessions !== 1 ? "s" : ""}
|
|
66
|
+
</text>
|
|
67
|
+
{data().readDedup > 0 || data().bashCapped > 0 ? <text fg={theme().textMuted}>
|
|
68
|
+
saved: {data().readDedup} dedup · {data().bashCapped} capped
|
|
69
|
+
</text> : null}
|
|
70
|
+
{data().contextWarnings > 0 ? <text fg={theme().warning}>
|
|
71
|
+
⚠ {data().contextWarnings} context warning{data().contextWarnings !== 1 ? "s" : ""}
|
|
72
|
+
</text> : null}
|
|
73
|
+
</box>;
|
|
74
|
+
}
|
|
75
|
+
var tui = async (api) => {
|
|
76
|
+
api.slots.register({
|
|
77
|
+
order: 200,
|
|
78
|
+
// after OC's built-in Context (100), before Footer
|
|
79
|
+
slots: {
|
|
80
|
+
sidebar_content(_ctx, props) {
|
|
81
|
+
return <View api={api} session_id={props.session_id} />;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
var plugin = {
|
|
87
|
+
tui
|
|
88
|
+
};
|
|
89
|
+
var tui_default = plugin;
|
|
90
|
+
export {
|
|
91
|
+
tui_default as default
|
|
92
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clwnd/opencode",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.5",
|
|
4
4
|
"description": "clwnd for opencode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"import": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./tui": {
|
|
12
|
+
"import": "./dist/tui.js"
|
|
10
13
|
}
|
|
11
14
|
},
|
|
12
15
|
"files": [
|