@clwnd/opencode 0.18.5 → 0.18.6
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/package.json +8 -4
- package/tui.tsx +99 -0
- package/dist/tui.js +0 -92
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clwnd/opencode",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.6",
|
|
4
4
|
"description": "clwnd for opencode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
"import": "./dist/index.js"
|
|
10
10
|
},
|
|
11
11
|
"./tui": {
|
|
12
|
-
"import": "./
|
|
12
|
+
"import": "./tui.tsx"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist/"
|
|
16
|
+
"dist/",
|
|
17
|
+
"tui.tsx"
|
|
17
18
|
],
|
|
18
19
|
"scripts": {
|
|
19
20
|
"build": "tsup",
|
|
@@ -40,7 +41,10 @@
|
|
|
40
41
|
"@ai-sdk/provider-utils": "^4.0.21"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
|
-
"@opencode-ai/plugin": ">=1.3.5"
|
|
44
|
+
"@opencode-ai/plugin": ">=1.3.5",
|
|
45
|
+
"@opentui/core": "^0.1.97",
|
|
46
|
+
"@opentui/solid": "^0.1.97",
|
|
47
|
+
"solid-js": "^1.9.12"
|
|
44
48
|
},
|
|
45
49
|
"devDependencies": {
|
|
46
50
|
"@opencode-ai/plugin": "^1.3.5",
|
package/tui.tsx
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/** @jsxImportSource @opentui/solid */
|
|
2
|
+
import type { TuiPlugin, TuiPluginModule } from "@opencode-ai/plugin/tui"
|
|
3
|
+
import { createSignal, onCleanup, createMemo, Show } from "solid-js"
|
|
4
|
+
|
|
5
|
+
interface DaemonData {
|
|
6
|
+
status: "connected" | "disconnected"
|
|
7
|
+
procs: number
|
|
8
|
+
sessions: number
|
|
9
|
+
uptimeMin: number
|
|
10
|
+
readDedup: number
|
|
11
|
+
bashCapped: number
|
|
12
|
+
contextWarnings: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const SOCK_PATH = (() => {
|
|
16
|
+
const runtime = process.env.XDG_RUNTIME_DIR
|
|
17
|
+
const sock = process.env.CLWND_SOCKET ?? (runtime ? `${runtime}/clwnd/clwnd.sock` : "/tmp/clwnd/clwnd.sock")
|
|
18
|
+
return sock + ".http"
|
|
19
|
+
})()
|
|
20
|
+
|
|
21
|
+
async function fetchDaemon(): Promise<DaemonData> {
|
|
22
|
+
try {
|
|
23
|
+
const [statusResp, savingsResp] = await Promise.all([
|
|
24
|
+
fetch("http://localhost/status", { unix: SOCK_PATH } as RequestInit),
|
|
25
|
+
fetch("http://localhost/savings", { unix: SOCK_PATH } as RequestInit),
|
|
26
|
+
])
|
|
27
|
+
const status = (await statusResp.json()) as any
|
|
28
|
+
const savings = (await savingsResp.json()) as any
|
|
29
|
+
const c = savings.counters ?? {}
|
|
30
|
+
return {
|
|
31
|
+
status: "connected",
|
|
32
|
+
procs: (status.procs ?? []).length,
|
|
33
|
+
sessions: status.sessions ?? 0,
|
|
34
|
+
uptimeMin: Math.round((savings.uptimeMs ?? 0) / 60_000),
|
|
35
|
+
readDedup: c.readDedupHits ?? 0,
|
|
36
|
+
bashCapped: c.bashTruncated ?? 0,
|
|
37
|
+
contextWarnings: c.contextOverThreshold ?? 0,
|
|
38
|
+
}
|
|
39
|
+
} catch {
|
|
40
|
+
return {
|
|
41
|
+
status: "disconnected", procs: 0, sessions: 0, uptimeMin: 0,
|
|
42
|
+
readDedup: 0, bashCapped: 0, contextWarnings: 0,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function SidebarView(props: { api: any; session_id: string }) {
|
|
48
|
+
const theme = () => props.api.theme.current
|
|
49
|
+
const [data, setData] = createSignal<DaemonData>({
|
|
50
|
+
status: "disconnected", procs: 0, sessions: 0, uptimeMin: 0,
|
|
51
|
+
readDedup: 0, bashCapped: 0, contextWarnings: 0,
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const poll = () => fetchDaemon().then(setData).catch(() => {})
|
|
55
|
+
poll()
|
|
56
|
+
const timer = setInterval(poll, 10_000)
|
|
57
|
+
onCleanup(() => clearInterval(timer))
|
|
58
|
+
|
|
59
|
+
const statusLine = createMemo(() => {
|
|
60
|
+
const d = data()
|
|
61
|
+
const dot = d.status === "connected" ? "●" : "○"
|
|
62
|
+
return `${dot} ${d.status} · ${String(d.uptimeMin)}m`
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const procsLine = createMemo(() => {
|
|
66
|
+
const d = data()
|
|
67
|
+
return `${String(d.procs)} proc${d.procs !== 1 ? "s" : ""} · ${String(d.sessions)} session${d.sessions !== 1 ? "s" : ""}`
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const savingsLine = createMemo(() => {
|
|
71
|
+
const d = data()
|
|
72
|
+
if (d.readDedup === 0 && d.bashCapped === 0) return ""
|
|
73
|
+
return `saved: ${String(d.readDedup)} dedup · ${String(d.bashCapped)} capped`
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<box>
|
|
78
|
+
<text fg={theme().text}><b>clwnd</b></text>
|
|
79
|
+
<text fg={data().status === "connected" ? theme().success : theme().error}>{statusLine()}</text>
|
|
80
|
+
<text fg={theme().textMuted}>{procsLine()}</text>
|
|
81
|
+
<Show when={savingsLine() !== ""}>
|
|
82
|
+
<text fg={theme().textMuted}>{savingsLine()}</text>
|
|
83
|
+
</Show>
|
|
84
|
+
</box>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const tui: TuiPlugin = async (api) => {
|
|
89
|
+
api.slots.register({
|
|
90
|
+
order: 150,
|
|
91
|
+
slots: {
|
|
92
|
+
sidebar_content(_ctx, props) {
|
|
93
|
+
return <SidebarView api={api} session_id={props.session_id} />
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export default { id: "@clwnd/opencode", tui } satisfies TuiPluginModule & { id: string }
|
package/dist/tui.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
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
|
-
};
|