@jeffreyjyz/opencode-command-code 0.3.9 → 0.3.10
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.js +1 -1
- package/dist/sidebar/useRows.d.ts +14 -1
- package/dist/tui.js +25 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4063,7 +4063,7 @@ var commandCodeV2 = {
|
|
|
4063
4063
|
// package.json
|
|
4064
4064
|
var package_default = {
|
|
4065
4065
|
name: "@jeffreyjyz/opencode-command-code",
|
|
4066
|
-
version: "0.3.
|
|
4066
|
+
version: "0.3.10",
|
|
4067
4067
|
description: "Command Code provider + usage dashboard for opencode: two providers (Anthropic wire for Claude, OpenAI wire for everything else) against api.commandcode.ai, live model list, plan gating, /cmd-usage. Requires the cmduse CLI for usage rendering.",
|
|
4068
4068
|
type: "module",
|
|
4069
4069
|
main: "dist/index.js",
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { type SidebarRow, type Usage } from "./rows";
|
|
2
|
+
/** Which provider a session is on, as far as this panel is concerned. */
|
|
3
|
+
export type SessionKind = "ours" | "other" | "unknown";
|
|
4
|
+
/**
|
|
5
|
+
* `unknown` is the frame during a session switch, before the host has resolved
|
|
6
|
+
* the new session's model. It must not be read as "another provider", or the
|
|
7
|
+
* panel blanks and refetches on every tab change.
|
|
8
|
+
*/
|
|
9
|
+
export declare function sessionKind(providerID: string | undefined): SessionKind;
|
|
10
|
+
/** Keep an account snapshot for the next panel that needs it. */
|
|
11
|
+
export declare function rememberSnapshot(snapshot: Usage): void;
|
|
12
|
+
/** Rows to paint before this panel's first fetch of the session completes. */
|
|
13
|
+
export declare function seededRows(): SidebarRow[];
|
|
14
|
+
export declare function useRows(activeModelId: () => string | undefined, providerID: () => string | undefined): import("solid-js").Accessor<SidebarRow[]>;
|
package/dist/tui.js
CHANGED
|
@@ -2009,28 +2009,47 @@ function loadModelUsage(modelID, sinceMs, path = usageDbPath()) {
|
|
|
2009
2009
|
|
|
2010
2010
|
// src/sidebar/useRows.ts
|
|
2011
2011
|
var POLL_MS = 60000;
|
|
2012
|
-
function
|
|
2013
|
-
|
|
2012
|
+
function sessionKind(providerID) {
|
|
2013
|
+
if (!providerID)
|
|
2014
|
+
return "unknown";
|
|
2015
|
+
return providerID.startsWith("command-code") ? "ours" : "other";
|
|
2016
|
+
}
|
|
2017
|
+
var lastSnapshot;
|
|
2018
|
+
function rememberSnapshot(snapshot) {
|
|
2019
|
+
lastSnapshot = snapshot;
|
|
2020
|
+
}
|
|
2021
|
+
function seededRows() {
|
|
2022
|
+
return lastSnapshot ? usageRows(lastSnapshot) : [];
|
|
2023
|
+
}
|
|
2024
|
+
function useRows(activeModelId, providerID) {
|
|
2025
|
+
const [usage, setUsage] = createSignal(seededRows());
|
|
2014
2026
|
const [meta, setMeta] = createSignal(new Map);
|
|
2015
2027
|
const [modelUsage, setModelUsage] = createSignal();
|
|
2028
|
+
const [wasOurs, setWasOurs] = createSignal(false);
|
|
2016
2029
|
loadMeta().then(setMeta).catch(() => {});
|
|
2017
2030
|
const refresh = async () => {
|
|
2018
2031
|
try {
|
|
2019
2032
|
const snapshot = await loadUsage();
|
|
2033
|
+
rememberSnapshot(snapshot);
|
|
2020
2034
|
setUsage(usageRows(snapshot));
|
|
2021
2035
|
const id = activeModelId();
|
|
2022
2036
|
setModelUsage(id ? loadModelUsage(id, periodStart(snapshot)) ?? undefined : undefined);
|
|
2023
2037
|
} catch {}
|
|
2024
2038
|
};
|
|
2025
2039
|
createEffect(() => {
|
|
2026
|
-
|
|
2040
|
+
const kind = sessionKind(providerID());
|
|
2041
|
+
if (kind !== "ours")
|
|
2027
2042
|
return;
|
|
2043
|
+
setWasOurs(true);
|
|
2028
2044
|
refresh();
|
|
2029
2045
|
const timer = setInterval(() => void refresh(), POLL_MS);
|
|
2030
2046
|
onCleanup(() => clearInterval(timer));
|
|
2031
2047
|
});
|
|
2032
2048
|
return createMemo(() => {
|
|
2033
|
-
|
|
2049
|
+
const kind = sessionKind(providerID());
|
|
2050
|
+
if (kind === "other")
|
|
2051
|
+
return [];
|
|
2052
|
+
if (kind === "unknown" && !wasOurs())
|
|
2034
2053
|
return [];
|
|
2035
2054
|
const id = activeModelId();
|
|
2036
2055
|
const found = id ? meta().get(modelKey(id)) ?? meta().get(id) : undefined;
|
|
@@ -2045,11 +2064,10 @@ function useRows(activeModelId, active) {
|
|
|
2045
2064
|
|
|
2046
2065
|
// src/tui.tsx
|
|
2047
2066
|
var ID = "command-code.tui";
|
|
2048
|
-
var isOurs = (providerID) => Boolean(providerID?.startsWith("command-code"));
|
|
2049
2067
|
var themed = (colors) => loadPrefs().colors ? colors : mono(colors);
|
|
2050
2068
|
function PanelV1(props) {
|
|
2051
2069
|
const current = () => props.api.state.session.get(props.sessionID)?.model;
|
|
2052
|
-
const rows = useRows(() => current()?.id, () =>
|
|
2070
|
+
const rows = useRows(() => current()?.id, () => current()?.providerID);
|
|
2053
2071
|
return _$createComponent2(Panel, {
|
|
2054
2072
|
rows,
|
|
2055
2073
|
colors: () => themed(legacyColors(props.api.theme.current))
|
|
@@ -2075,7 +2093,7 @@ function PanelV2(props) {
|
|
|
2075
2093
|
ctx
|
|
2076
2094
|
} = props;
|
|
2077
2095
|
const current = () => ctx.data.session.get(props.sessionID)?.model;
|
|
2078
|
-
const rows = useRows(() => current()?.id, () =>
|
|
2096
|
+
const rows = useRows(() => current()?.id, () => current()?.providerID);
|
|
2079
2097
|
return _$createComponent2(Panel, {
|
|
2080
2098
|
rows,
|
|
2081
2099
|
colors: () => themed(hostColors(ctx.theme))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeffreyjyz/opencode-command-code",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "Command Code provider + usage dashboard for opencode: two providers (Anthropic wire for Claude, OpenAI wire for everything else) against api.commandcode.ai, live model list, plan gating, /cmd-usage. Requires the cmduse CLI for usage rendering.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|