@jeffreyjyz/opencode-command-code 0.5.18 → 0.5.19
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/ark.d.ts +14 -0
- package/dist/tui.js +35 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2414,7 +2414,7 @@ function superRefine(fn) {
|
|
|
2414
2414
|
// package.json
|
|
2415
2415
|
var package_default = {
|
|
2416
2416
|
name: "@jeffreyjyz/opencode-command-code",
|
|
2417
|
-
version: "0.5.
|
|
2417
|
+
version: "0.5.19",
|
|
2418
2418
|
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.",
|
|
2419
2419
|
type: "module",
|
|
2420
2420
|
main: "dist/index.js",
|
package/dist/sidebar/ark.d.ts
CHANGED
|
@@ -22,6 +22,15 @@ export interface ArkModel {
|
|
|
22
22
|
weekly: ArkTotals;
|
|
23
23
|
month: ArkTotals;
|
|
24
24
|
}
|
|
25
|
+
/** This store's own view of one window (`arkuse`'s `windows` block): AFP against
|
|
26
|
+
* the plan's published quota, the percentage that yields, and the boundary the
|
|
27
|
+
* row counts down to. Present even when no meter answered, which is what keeps
|
|
28
|
+
* a panel row from degrading to AFP alone. */
|
|
29
|
+
export interface ArkWindow {
|
|
30
|
+
quota?: number;
|
|
31
|
+
percent?: number;
|
|
32
|
+
resetAt?: number;
|
|
33
|
+
}
|
|
25
34
|
export interface ArkUsage {
|
|
26
35
|
plan: string;
|
|
27
36
|
profile?: string;
|
|
@@ -34,6 +43,11 @@ export interface ArkUsage {
|
|
|
34
43
|
weekly: ArkTotals;
|
|
35
44
|
month: ArkTotals;
|
|
36
45
|
daily?: ArkTotals;
|
|
46
|
+
windows?: {
|
|
47
|
+
fiveHour?: ArkWindow;
|
|
48
|
+
weekly?: ArkWindow;
|
|
49
|
+
monthly?: ArkWindow;
|
|
50
|
+
};
|
|
37
51
|
account?: {
|
|
38
52
|
fiveHour: ArkMeter;
|
|
39
53
|
daily?: ArkMeter;
|
package/dist/tui.js
CHANGED
|
@@ -2146,6 +2146,16 @@ function meter(value) {
|
|
|
2146
2146
|
resetAt: typeof v.resetAt === "number" ? v.resetAt : undefined
|
|
2147
2147
|
};
|
|
2148
2148
|
}
|
|
2149
|
+
function storeWindow(value) {
|
|
2150
|
+
if (!value || typeof value !== "object")
|
|
2151
|
+
return;
|
|
2152
|
+
const v = value;
|
|
2153
|
+
return {
|
|
2154
|
+
quota: typeof v.quota === "number" ? v.quota : undefined,
|
|
2155
|
+
percent: typeof v.percent === "number" ? v.percent : undefined,
|
|
2156
|
+
resetAt: typeof v.resetAt === "number" ? v.resetAt : undefined
|
|
2157
|
+
};
|
|
2158
|
+
}
|
|
2149
2159
|
function parseArkJson(text) {
|
|
2150
2160
|
let body;
|
|
2151
2161
|
try {
|
|
@@ -2167,6 +2177,7 @@ function parseArkJson(text) {
|
|
|
2167
2177
|
});
|
|
2168
2178
|
}
|
|
2169
2179
|
const summary = body.summary ?? {};
|
|
2180
|
+
const windows = body.windows ?? {};
|
|
2170
2181
|
return {
|
|
2171
2182
|
plan: typeof body.plan === "string" ? body.plan : "medium",
|
|
2172
2183
|
profile: typeof body.profile === "string" ? body.profile : undefined,
|
|
@@ -2180,6 +2191,11 @@ function parseArkJson(text) {
|
|
|
2180
2191
|
weekly: totals(body.weekly),
|
|
2181
2192
|
month: totals(body.monthly),
|
|
2182
2193
|
daily: body.daily ? totals(body.daily) : undefined,
|
|
2194
|
+
windows: body.windows ? {
|
|
2195
|
+
fiveHour: storeWindow(windows.fiveHour),
|
|
2196
|
+
weekly: storeWindow(windows.weekly),
|
|
2197
|
+
monthly: storeWindow(windows.monthly)
|
|
2198
|
+
} : undefined,
|
|
2183
2199
|
account: body.account ? {
|
|
2184
2200
|
fiveHour: meter(account.fiveHour),
|
|
2185
2201
|
daily: account.daily ? meter(account.daily) : undefined,
|
|
@@ -2233,9 +2249,21 @@ function meterRows(label, meter, local, now, durSecs) {
|
|
|
2233
2249
|
exceeded: pct >= 100 || meter.status !== "ok"
|
|
2234
2250
|
}, now, durSecs, `${afp(local.afp)} local${local.requests > 0 ? ` \xB7 ${count(local.requests)} req` : ""}`, (used, cap) => `${brief(used)}/${brief(cap)} (${pctText}%)`);
|
|
2235
2251
|
}
|
|
2236
|
-
function localRows(label, totals) {
|
|
2237
|
-
const
|
|
2238
|
-
|
|
2252
|
+
function localRows(label, totals, window, now, durSecs) {
|
|
2253
|
+
const quota = window?.quota;
|
|
2254
|
+
const percent = window?.percent;
|
|
2255
|
+
if (typeof quota !== "number" || quota <= 0 || typeof percent !== "number") {
|
|
2256
|
+
const detail = totals.requests > 0 ? ` \xB7 ${count(totals.requests)} req` : "";
|
|
2257
|
+
return [[label, `${afp(totals.afp)}${detail}`, "base"]];
|
|
2258
|
+
}
|
|
2259
|
+
const pctText = percent.toFixed(1);
|
|
2260
|
+
return windowRows(label, {
|
|
2261
|
+
cap: quota,
|
|
2262
|
+
used: totals.afp,
|
|
2263
|
+
resetAt: window?.resetAt,
|
|
2264
|
+
sharePct: percent,
|
|
2265
|
+
exceeded: percent >= 100
|
|
2266
|
+
}, now, durSecs, `${count(totals.requests)} req`, (used, cap) => `${brief(used)}/${brief(cap)} (${pctText}% est.)`);
|
|
2239
2267
|
}
|
|
2240
2268
|
function arkRows(usage, fallbackName) {
|
|
2241
2269
|
if (!usage)
|
|
@@ -2255,9 +2283,10 @@ function arkRows(usage, fallbackName) {
|
|
|
2255
2283
|
rows.push(...meterRows("Weekly", account.weekly, usage.weekly, now, WEEKLY_SECS));
|
|
2256
2284
|
rows.push(...meterRows("Monthly", account.monthly, usage.month, now, period?.durSecs ?? 0));
|
|
2257
2285
|
} else {
|
|
2258
|
-
|
|
2259
|
-
rows.push(...localRows("
|
|
2260
|
-
rows.push(...localRows("
|
|
2286
|
+
const windows = usage.windows;
|
|
2287
|
+
rows.push(...localRows("5-hour", usage.fiveHour, windows?.fiveHour, now, FIVE_HOUR_SECS));
|
|
2288
|
+
rows.push(...localRows("Weekly", usage.weekly, windows?.weekly, now, WEEKLY_SECS));
|
|
2289
|
+
rows.push(...localRows("Monthly", usage.month, windows?.monthly, now, period?.durSecs ?? 0));
|
|
2261
2290
|
}
|
|
2262
2291
|
const yuan = typeof usage.summary.yuan === "number" ? ` (${money(usage.summary.yuan)})` : "";
|
|
2263
2292
|
rows.push(["Period", clip(`${count(usage.summary.requests)} requests \xB7 ${afp(usage.summary.afp)}${yuan}`, valueWidth("Period")), "base"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeffreyjyz/opencode-command-code",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.19",
|
|
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",
|