@slkiser/opencode-quota 3.11.1 → 3.11.2
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/README.md +61 -43
- package/dist/bin/opencode-quota.d.ts.map +1 -1
- package/dist/bin/opencode-quota.js +8 -0
- package/dist/bin/opencode-quota.js.map +1 -1
- package/dist/lib/anthropic.d.ts.map +1 -1
- package/dist/lib/anthropic.js +106 -3
- package/dist/lib/anthropic.js.map +1 -1
- package/dist/lib/atomic-json.d.ts +1 -0
- package/dist/lib/atomic-json.d.ts.map +1 -1
- package/dist/lib/atomic-json.js +5 -2
- package/dist/lib/atomic-json.js.map +1 -1
- package/dist/lib/init-installer.d.ts.map +1 -1
- package/dist/lib/init-installer.js +40 -18
- package/dist/lib/init-installer.js.map +1 -1
- package/dist/lib/openai.d.ts +9 -12
- package/dist/lib/openai.d.ts.map +1 -1
- package/dist/lib/openai.js +69 -40
- package/dist/lib/openai.js.map +1 -1
- package/dist/lib/scoped-update.d.ts +63 -0
- package/dist/lib/scoped-update.d.ts.map +1 -0
- package/dist/lib/scoped-update.js +301 -0
- package/dist/lib/scoped-update.js.map +1 -0
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +1 -0
- package/dist/providers/openai.js.map +1 -1
- package/dist/tui.d.ts.map +1 -1
- package/dist/tui.js +1 -279
- package/dist/tui.tsx +5 -246
- package/package.json +2 -1
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { lstat, readFile, realpath, rm } from "node:fs/promises";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
4
|
+
import { applyEdits, modify, parse } from "jsonc-parser";
|
|
5
|
+
import { writeTextAtomic } from "./atomic-json.js";
|
|
6
|
+
import { findGitWorktreeRoot } from "./config-file-utils.js";
|
|
7
|
+
import { getOpencodeRuntimeDirCandidates, getOpencodeRuntimeDirs, } from "./opencode-runtime-paths.js";
|
|
8
|
+
export const QUOTA_PACKAGE_NAME = "@slkiser/opencode-quota";
|
|
9
|
+
export const QUOTA_LATEST_SPEC = `${QUOTA_PACKAGE_NAME}@latest`;
|
|
10
|
+
const EXACT_SEMVER = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
11
|
+
export class ScopedUpdateError extends Error {
|
|
12
|
+
details;
|
|
13
|
+
constructor(message, details) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.details = details;
|
|
16
|
+
this.name = "ScopedUpdateError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function isCanonicalQuotaUpdateSpec(spec) {
|
|
20
|
+
if (spec === QUOTA_PACKAGE_NAME || spec === QUOTA_LATEST_SPEC)
|
|
21
|
+
return true;
|
|
22
|
+
const prefix = `${QUOTA_PACKAGE_NAME}@`;
|
|
23
|
+
return spec.startsWith(prefix) && EXACT_SEMVER.test(spec.slice(prefix.length));
|
|
24
|
+
}
|
|
25
|
+
export function sanitizeOpenCodePackageSpec(spec, platform = process.platform) {
|
|
26
|
+
if (platform !== "win32")
|
|
27
|
+
return spec;
|
|
28
|
+
return Array.from(spec, (char) => new Set(["<", ">", ":", '"', "|", "?", "*"]).has(char) || char.charCodeAt(0) < 32 ? "_" : char).join("");
|
|
29
|
+
}
|
|
30
|
+
function effectiveGlobalConfigDir(params) {
|
|
31
|
+
const fallback = getOpencodeRuntimeDirs({
|
|
32
|
+
env: params.env,
|
|
33
|
+
homeDir: params.homeDir,
|
|
34
|
+
}).configDir;
|
|
35
|
+
const configured = params.env.OPENCODE_CONFIG_DIR?.trim();
|
|
36
|
+
if (!configured)
|
|
37
|
+
return fallback;
|
|
38
|
+
return isAbsolute(configured) ? configured : resolve(fallback, configured);
|
|
39
|
+
}
|
|
40
|
+
function selectedConfigPaths(root) {
|
|
41
|
+
const result = [];
|
|
42
|
+
for (const kind of ["opencode", "tui"]) {
|
|
43
|
+
const jsonc = join(root, `${kind}.jsonc`);
|
|
44
|
+
const json = join(root, `${kind}.json`);
|
|
45
|
+
if (existsSync(jsonc))
|
|
46
|
+
result.push(jsonc);
|
|
47
|
+
else if (existsSync(json))
|
|
48
|
+
result.push(json);
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
async function dedupeByRealPath(paths) {
|
|
53
|
+
const output = [];
|
|
54
|
+
const seen = new Set();
|
|
55
|
+
for (const path of paths) {
|
|
56
|
+
const resolved = await realpath(path);
|
|
57
|
+
if (seen.has(resolved))
|
|
58
|
+
continue;
|
|
59
|
+
seen.add(resolved);
|
|
60
|
+
output.push(path);
|
|
61
|
+
}
|
|
62
|
+
return output;
|
|
63
|
+
}
|
|
64
|
+
function pluginArrays(config) {
|
|
65
|
+
if (!config || typeof config !== "object" || Array.isArray(config))
|
|
66
|
+
return [];
|
|
67
|
+
const root = config;
|
|
68
|
+
const arrays = [];
|
|
69
|
+
if (Array.isArray(root.plugin))
|
|
70
|
+
arrays.push({ path: ["plugin"], entries: root.plugin });
|
|
71
|
+
if (root.tui && typeof root.tui === "object" && !Array.isArray(root.tui)) {
|
|
72
|
+
const tui = root.tui;
|
|
73
|
+
if (Array.isArray(tui.plugin))
|
|
74
|
+
arrays.push({ path: ["tui", "plugin"], entries: tui.plugin });
|
|
75
|
+
}
|
|
76
|
+
return arrays;
|
|
77
|
+
}
|
|
78
|
+
function updateConfig(raw, path) {
|
|
79
|
+
const errors = [];
|
|
80
|
+
const parsed = parse(raw, errors, { allowTrailingComma: true, disallowComments: false });
|
|
81
|
+
if (errors.length > 0) {
|
|
82
|
+
throw new ScopedUpdateError(`Cannot update unparseable config: ${path}`, { path });
|
|
83
|
+
}
|
|
84
|
+
let updated = raw;
|
|
85
|
+
let replacements = 0;
|
|
86
|
+
const specs = [];
|
|
87
|
+
for (const array of pluginArrays(parsed)) {
|
|
88
|
+
for (let index = array.entries.length - 1; index >= 0; index--) {
|
|
89
|
+
const entry = array.entries[index];
|
|
90
|
+
const spec = typeof entry === "string"
|
|
91
|
+
? entry
|
|
92
|
+
: Array.isArray(entry) && typeof entry[0] === "string"
|
|
93
|
+
? entry[0]
|
|
94
|
+
: null;
|
|
95
|
+
if (spec === null || !isCanonicalQuotaUpdateSpec(spec))
|
|
96
|
+
continue;
|
|
97
|
+
specs.push(spec);
|
|
98
|
+
if (spec === QUOTA_LATEST_SPEC)
|
|
99
|
+
continue;
|
|
100
|
+
const targetPath = typeof entry === "string" ? [...array.path, index] : [...array.path, index, 0];
|
|
101
|
+
updated = applyEdits(updated, modify(updated, targetPath, QUOTA_LATEST_SPEC, {}));
|
|
102
|
+
replacements++;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return { updated, replacements, specs };
|
|
106
|
+
}
|
|
107
|
+
export async function planScopedUpdate(params = {}) {
|
|
108
|
+
const cwd = params.cwd ?? process.cwd();
|
|
109
|
+
const env = params.env ?? process.env;
|
|
110
|
+
const projectRoot = findGitWorktreeRoot(cwd) ?? cwd;
|
|
111
|
+
const globalRoot = effectiveGlobalConfigDir({ env, homeDir: params.homeDir });
|
|
112
|
+
const configPaths = await dedupeByRealPath([
|
|
113
|
+
...selectedConfigPaths(projectRoot),
|
|
114
|
+
...selectedConfigPaths(globalRoot),
|
|
115
|
+
]);
|
|
116
|
+
const configEdits = [];
|
|
117
|
+
const configSnapshots = [];
|
|
118
|
+
const foundSpecs = [];
|
|
119
|
+
for (const path of configPaths) {
|
|
120
|
+
const originalBytes = await readFile(path);
|
|
121
|
+
const original = originalBytes.toString("utf8");
|
|
122
|
+
const planned = updateConfig(original, path);
|
|
123
|
+
foundSpecs.push(...planned.specs);
|
|
124
|
+
const changed = planned.updated !== original;
|
|
125
|
+
configSnapshots.push({
|
|
126
|
+
path,
|
|
127
|
+
originalBytes,
|
|
128
|
+
expectedBytes: changed ? Buffer.from(planned.updated, "utf8") : originalBytes,
|
|
129
|
+
updated: planned.updated,
|
|
130
|
+
changed,
|
|
131
|
+
});
|
|
132
|
+
if (changed) {
|
|
133
|
+
configEdits.push({
|
|
134
|
+
path,
|
|
135
|
+
original,
|
|
136
|
+
originalBytes,
|
|
137
|
+
updated: planned.updated,
|
|
138
|
+
replacements: planned.replacements,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const uniqueSpecs = [...new Set(foundSpecs)];
|
|
143
|
+
const cacheSpecs = [...new Set([...uniqueSpecs, QUOTA_LATEST_SPEC])];
|
|
144
|
+
const runtime = getOpencodeRuntimeDirCandidates({
|
|
145
|
+
platform: params.platform,
|
|
146
|
+
env,
|
|
147
|
+
homeDir: params.homeDir,
|
|
148
|
+
});
|
|
149
|
+
const cacheCandidates = runtime.cacheDirs.flatMap((cacheDir) => cacheSpecs.map((spec) => join(cacheDir, "packages", sanitizeOpenCodePackageSpec(spec, params.platform))));
|
|
150
|
+
return {
|
|
151
|
+
configEdits,
|
|
152
|
+
configSnapshots,
|
|
153
|
+
configPaths,
|
|
154
|
+
foundSpecs: uniqueSpecs,
|
|
155
|
+
cacheCandidates: [...new Set(cacheCandidates)],
|
|
156
|
+
authoritativeLatest: uniqueSpecs.length > 0,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function containedBy(root, candidate) {
|
|
160
|
+
const rel = relative(root, candidate);
|
|
161
|
+
return rel === "" || (!rel.startsWith("..") && !isAbsolute(rel));
|
|
162
|
+
}
|
|
163
|
+
async function removeVerifiedCacheCandidate(path) {
|
|
164
|
+
const packagesPath = dirname(dirname(path));
|
|
165
|
+
try {
|
|
166
|
+
const packagesStat = await lstat(packagesPath);
|
|
167
|
+
const ownerStat = await lstat(dirname(path));
|
|
168
|
+
if (packagesStat.isSymbolicLink() || ownerStat.isSymbolicLink())
|
|
169
|
+
return "skipped";
|
|
170
|
+
const packagesReal = await realpath(packagesPath);
|
|
171
|
+
const stat = await lstat(path);
|
|
172
|
+
if (stat.isSymbolicLink() || !stat.isDirectory())
|
|
173
|
+
return "skipped";
|
|
174
|
+
const candidateReal = await realpath(path);
|
|
175
|
+
if (!containedBy(packagesReal, candidateReal) || candidateReal === packagesReal)
|
|
176
|
+
return "skipped";
|
|
177
|
+
const manifestPath = join(candidateReal, "node_modules", "@slkiser", "opencode-quota", "package.json");
|
|
178
|
+
const manifestStat = await lstat(manifestPath);
|
|
179
|
+
if (manifestStat.isSymbolicLink() || !manifestStat.isFile())
|
|
180
|
+
return "skipped";
|
|
181
|
+
const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
182
|
+
if (manifest.name !== QUOTA_PACKAGE_NAME)
|
|
183
|
+
return "skipped";
|
|
184
|
+
await rm(candidateReal, { recursive: true, force: false });
|
|
185
|
+
return "removed";
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
return "skipped";
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
export async function applyScopedUpdatePlan(plan, options = {}) {
|
|
192
|
+
if (options.dryRun) {
|
|
193
|
+
return { writtenPaths: [], removedCachePaths: [], skippedCachePaths: [] };
|
|
194
|
+
}
|
|
195
|
+
const readBytes = options.readBytes ?? ((path) => readFile(path));
|
|
196
|
+
const writeText = options.writeText ?? writeTextAtomic;
|
|
197
|
+
const writtenPaths = [];
|
|
198
|
+
const failure = (action, path) => {
|
|
199
|
+
const changed = writtenPaths.length > 0 ? ` Changed before failure: ${writtenPaths.join(", ")}.` : "";
|
|
200
|
+
return new ScopedUpdateError(`${action} ${path}; no cache was deleted.${changed}`, {
|
|
201
|
+
path,
|
|
202
|
+
writtenPaths: [...writtenPaths],
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
for (const snapshot of plan.configSnapshots) {
|
|
206
|
+
let current;
|
|
207
|
+
try {
|
|
208
|
+
current = await readBytes(snapshot.path);
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
throw failure("Failed reading", snapshot.path);
|
|
212
|
+
}
|
|
213
|
+
if (!current.equals(snapshot.originalBytes)) {
|
|
214
|
+
throw failure("Config changed since preview:", snapshot.path);
|
|
215
|
+
}
|
|
216
|
+
if (!snapshot.changed)
|
|
217
|
+
continue;
|
|
218
|
+
try {
|
|
219
|
+
await writeText(snapshot.path, snapshot.updated);
|
|
220
|
+
writtenPaths.push(snapshot.path);
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
throw failure("Failed writing", snapshot.path);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
await options.beforeCacheDeletion?.();
|
|
227
|
+
let authoritativeLatest = false;
|
|
228
|
+
for (const snapshot of plan.configSnapshots) {
|
|
229
|
+
let current;
|
|
230
|
+
try {
|
|
231
|
+
current = await readBytes(snapshot.path);
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
throw failure("Failed re-reading", snapshot.path);
|
|
235
|
+
}
|
|
236
|
+
if (!current.equals(snapshot.expectedBytes)) {
|
|
237
|
+
throw failure("Config changed before cache deletion:", snapshot.path);
|
|
238
|
+
}
|
|
239
|
+
const currentPlan = updateConfig(current.toString("utf8"), snapshot.path);
|
|
240
|
+
if (currentPlan.specs.includes(QUOTA_LATEST_SPEC))
|
|
241
|
+
authoritativeLatest = true;
|
|
242
|
+
}
|
|
243
|
+
const removedCachePaths = [];
|
|
244
|
+
const skippedCachePaths = [];
|
|
245
|
+
if (authoritativeLatest) {
|
|
246
|
+
for (const candidate of plan.cacheCandidates) {
|
|
247
|
+
const result = await removeVerifiedCacheCandidate(candidate);
|
|
248
|
+
(result === "removed" ? removedCachePaths : skippedCachePaths).push(candidate);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return { writtenPaths, removedCachePaths, skippedCachePaths };
|
|
252
|
+
}
|
|
253
|
+
export async function runScopedUpdateCommand(params = {}) {
|
|
254
|
+
const argv = params.argv ?? [];
|
|
255
|
+
const unknown = argv.filter((arg) => arg !== "--dry-run" && arg !== "--yes");
|
|
256
|
+
if (unknown.length > 0)
|
|
257
|
+
return 1;
|
|
258
|
+
const dryRun = argv.includes("--dry-run");
|
|
259
|
+
const yes = argv.includes("--yes");
|
|
260
|
+
const log = params.log ?? console.log;
|
|
261
|
+
try {
|
|
262
|
+
const plan = await planScopedUpdate(params);
|
|
263
|
+
log("Scoped OpenCode Quota update preview:");
|
|
264
|
+
for (const edit of plan.configEdits) {
|
|
265
|
+
log(` edit ${edit.path} (${edit.replacements} replacement(s))`);
|
|
266
|
+
}
|
|
267
|
+
for (const candidate of plan.cacheCandidates)
|
|
268
|
+
log(` cache candidate ${candidate}`);
|
|
269
|
+
if (plan.configPaths.length === 0 || !plan.authoritativeLatest) {
|
|
270
|
+
log("No authoritative OpenCode config references an updatable OpenCode Quota spec.");
|
|
271
|
+
return 0;
|
|
272
|
+
}
|
|
273
|
+
if (dryRun)
|
|
274
|
+
return 0;
|
|
275
|
+
if (!yes) {
|
|
276
|
+
const confirm = params.confirm ??
|
|
277
|
+
(async (message) => {
|
|
278
|
+
const prompts = await import("@clack/prompts");
|
|
279
|
+
const answer = await prompts.confirm({ message });
|
|
280
|
+
return !prompts.isCancel(answer) && answer === true;
|
|
281
|
+
});
|
|
282
|
+
if (!(await confirm("Apply these config edits and delete only verified cache directories?"))) {
|
|
283
|
+
log("Update cancelled.");
|
|
284
|
+
return 0;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const result = await applyScopedUpdatePlan(plan);
|
|
288
|
+
for (const path of result.writtenPaths)
|
|
289
|
+
log(`Updated ${path}`);
|
|
290
|
+
for (const path of result.removedCachePaths)
|
|
291
|
+
log(`Removed ${path}`);
|
|
292
|
+
for (const path of result.skippedCachePaths)
|
|
293
|
+
log(`Skipped unverified cache candidate ${path}`);
|
|
294
|
+
return 0;
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
log(error instanceof Error ? error.message : String(error));
|
|
298
|
+
return 1;
|
|
299
|
+
}
|
|
300
|
+
}
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AAmB,CAAC;AAclG,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAA6C,MAAM,mBAAmB,CAAC;AAclG,eAAO,MAAM,cAAc,EAAE,aA6C5B,CAAC"}
|
package/dist/providers/openai.js
CHANGED
|
@@ -31,6 +31,7 @@ export const openaiProvider = {
|
|
|
31
31
|
windows: [
|
|
32
32
|
{ window: result.windows.hourly, suffix: "5h", label: "5h:" },
|
|
33
33
|
{ window: result.windows.weekly, suffix: "Weekly", label: "Weekly:" },
|
|
34
|
+
{ window: result.windows.monthly, suffix: "Monthly", label: "Monthly:" },
|
|
34
35
|
{ window: result.windows.codeReview, suffix: "Code Review", label: "Code Review:" },
|
|
35
36
|
],
|
|
36
37
|
}), [], {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACL,oCAAoC,EACpC,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,CAAC,MAAM,cAAc,GAAkB;IAC3C,EAAE,EAAE,QAAQ;IAEZ,KAAK,CAAC,WAAW,CAAC,GAAyB;QACzC,gFAAgF;QAChF,MAAM,qBAAqB,GAAG,MAAM,4BAA4B,CAAC;YAC/D,GAAG;YACH,UAAU,EAAE,QAAQ;YACpB,eAAe,EAAE,IAAI;SACtB,CAAC,CAAC;QAEH,IAAI,qBAAqB,EAAE,CAAC;YAC1B,OAAO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,EAAE,KAAK,EAAE,SAAS,EAAE;oBACrE,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE;oBACxE,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,cAAc,EAAE;iBACpF;aACF,CAAC,EACF,EAAE,EACF;gBACE,uBAAuB,EAAE,MAAM,CAAC,KAAK;aACtC,CACF;SACJ,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
package/dist/tui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../src/tui.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,eAAe,EAEhB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../src/tui.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,eAAe,EAEhB,MAAM,yBAAyB,CAAC;AAqgBjC,QAAA,MAAM,YAAY,EAAE,eAAe,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAGjD,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/dist/tui.js
CHANGED
|
@@ -11,8 +11,7 @@ import { createElement as _$createElement } from "@opentui/solid";
|
|
|
11
11
|
import { Show, createEffect, createSignal, onCleanup } from "solid-js";
|
|
12
12
|
import { getCompactStatusText, getHomeBottomAnnouncementText, getSidebarPanelLines, getSidebarPanelLinesExpanded, shouldRenderCompactStatus, shouldRenderHomeBottom, shouldRenderSidebarPanel } from "./lib/tui-panel-state.js";
|
|
13
13
|
import { getSidebarBodyLineColor } from "./lib/tui-line-style.js";
|
|
14
|
-
import {
|
|
15
|
-
import { QUOTA_DIALOG_COMMANDS, buildQuotaDialogCommandOutput } from "./lib/quota-dialog-commands.js";
|
|
14
|
+
import { loadTuiHomeBottomStatus, loadTuiSessionQuotaSurfaces, resolveTuiSurfaceRegistration, writeTuiQuotaExportIfEnabled } from "./lib/tui-runtime.js";
|
|
16
15
|
const id = "@slkiser/opencode-quota";
|
|
17
16
|
// Place Quota near the top so variable-height built-in sections
|
|
18
17
|
// (MCP/LSP/Todo/Files) do not push it below the visible fold.
|
|
@@ -437,282 +436,6 @@ function HomeBottomView(props) {
|
|
|
437
436
|
}
|
|
438
437
|
});
|
|
439
438
|
}
|
|
440
|
-
function getActiveTuiSessionID(api) {
|
|
441
|
-
const route = api.route?.current;
|
|
442
|
-
if (route?.name !== "session" && route?.type !== "session") return undefined;
|
|
443
|
-
return normalizeTuiSessionID(route.params?.sessionID ?? route.params?.session_id ?? route.params?.id ?? route.sessionID);
|
|
444
|
-
}
|
|
445
|
-
function getTuiCommandArguments(input) {
|
|
446
|
-
if (!input || typeof input !== "object") return undefined;
|
|
447
|
-
const record = input;
|
|
448
|
-
for (const key of ["arguments", "args", "query"]) {
|
|
449
|
-
const value = record[key];
|
|
450
|
-
if (typeof value === "string" && value.trim()) return value.trim();
|
|
451
|
-
}
|
|
452
|
-
return undefined;
|
|
453
|
-
}
|
|
454
|
-
function CommandLoadingDialog(props) {
|
|
455
|
-
return (() => {
|
|
456
|
-
var _el$19 = _$createElement("box"),
|
|
457
|
-
_el$20 = _$createElement("text"),
|
|
458
|
-
_el$21 = _$createElement("b"),
|
|
459
|
-
_el$22 = _$createElement("text");
|
|
460
|
-
_$insertNode(_el$19, _el$20);
|
|
461
|
-
_$insertNode(_el$19, _el$22);
|
|
462
|
-
_$setProp(_el$19, "gap", 1);
|
|
463
|
-
_$insertNode(_el$20, _el$21);
|
|
464
|
-
_$insert(_el$21, () => props.title);
|
|
465
|
-
_$insertNode(_el$22, _$createTextNode(`Loading deterministic local output…`));
|
|
466
|
-
_$effect(_p$ => {
|
|
467
|
-
var _v$3 = props.api.theme.current.text,
|
|
468
|
-
_v$4 = props.api.theme.current.textMuted;
|
|
469
|
-
_v$3 !== _p$.e && (_p$.e = _$setProp(_el$20, "fg", _v$3, _p$.e));
|
|
470
|
-
_v$4 !== _p$.t && (_p$.t = _$setProp(_el$22, "fg", _v$4, _p$.t));
|
|
471
|
-
return _p$;
|
|
472
|
-
}, {
|
|
473
|
-
e: undefined,
|
|
474
|
-
t: undefined
|
|
475
|
-
});
|
|
476
|
-
return _el$19;
|
|
477
|
-
})();
|
|
478
|
-
}
|
|
479
|
-
function CommandOutputDialog(props) {
|
|
480
|
-
const lines = () => props.output.split("\n");
|
|
481
|
-
const bodyHeight = () => Math.min(28, Math.max(6, lines().length));
|
|
482
|
-
return (() => {
|
|
483
|
-
var _el$24 = _$createElement("box"),
|
|
484
|
-
_el$25 = _$createElement("text"),
|
|
485
|
-
_el$26 = _$createElement("b"),
|
|
486
|
-
_el$27 = _$createElement("scrollbox"),
|
|
487
|
-
_el$28 = _$createElement("box"),
|
|
488
|
-
_el$29 = _$createElement("text");
|
|
489
|
-
_$insertNode(_el$24, _el$25);
|
|
490
|
-
_$insertNode(_el$24, _el$27);
|
|
491
|
-
_$insertNode(_el$24, _el$29);
|
|
492
|
-
_$setProp(_el$24, "gap", 1);
|
|
493
|
-
_$setProp(_el$24, "width", "100%");
|
|
494
|
-
_$setProp(_el$24, "flexGrow", 1);
|
|
495
|
-
_$setProp(_el$24, "paddingLeft", 2);
|
|
496
|
-
_$setProp(_el$24, "paddingRight", 2);
|
|
497
|
-
_$setProp(_el$24, "paddingBottom", 1);
|
|
498
|
-
_$insertNode(_el$25, _el$26);
|
|
499
|
-
_$insert(_el$26, () => props.title);
|
|
500
|
-
_$insertNode(_el$27, _el$28);
|
|
501
|
-
_$setProp(_el$27, "width", "100%");
|
|
502
|
-
_$setProp(_el$27, "flexGrow", 1);
|
|
503
|
-
_$setProp(_el$27, "maxHeight", 28);
|
|
504
|
-
_$setProp(_el$28, "gap", 0);
|
|
505
|
-
_$setProp(_el$28, "width", "100%");
|
|
506
|
-
_$setProp(_el$28, "minWidth", 0);
|
|
507
|
-
_$insert(_el$28, () => lines().map(line => (() => {
|
|
508
|
-
var _el$31 = _$createElement("text");
|
|
509
|
-
_$setProp(_el$31, "wrapMode", "word");
|
|
510
|
-
_$setProp(_el$31, "width", "100%");
|
|
511
|
-
_$insert(_el$31, line || " ");
|
|
512
|
-
_$effect(_$p => _$setProp(_el$31, "fg", props.api.theme.current.text, _$p));
|
|
513
|
-
return _el$31;
|
|
514
|
-
})()));
|
|
515
|
-
_$insertNode(_el$29, _$createTextNode(`esc closes`));
|
|
516
|
-
_$effect(_p$ => {
|
|
517
|
-
var _v$5 = props.api.theme.current.text,
|
|
518
|
-
_v$6 = bodyHeight(),
|
|
519
|
-
_v$7 = props.api.theme.current.textMuted;
|
|
520
|
-
_v$5 !== _p$.e && (_p$.e = _$setProp(_el$25, "fg", _v$5, _p$.e));
|
|
521
|
-
_v$6 !== _p$.t && (_p$.t = _$setProp(_el$27, "minHeight", _v$6, _p$.t));
|
|
522
|
-
_v$7 !== _p$.a && (_p$.a = _$setProp(_el$29, "fg", _v$7, _p$.a));
|
|
523
|
-
return _p$;
|
|
524
|
-
}, {
|
|
525
|
-
e: undefined,
|
|
526
|
-
t: undefined,
|
|
527
|
-
a: undefined
|
|
528
|
-
});
|
|
529
|
-
return _el$24;
|
|
530
|
-
})();
|
|
531
|
-
}
|
|
532
|
-
function CommandErrorDialog(props) {
|
|
533
|
-
const message = props.error instanceof Error ? props.error.message : String(props.error);
|
|
534
|
-
return (() => {
|
|
535
|
-
var _el$32 = _$createElement("box"),
|
|
536
|
-
_el$33 = _$createElement("text"),
|
|
537
|
-
_el$34 = _$createElement("b"),
|
|
538
|
-
_el$35 = _$createElement("text"),
|
|
539
|
-
_el$37 = _$createElement("text"),
|
|
540
|
-
_el$38 = _$createElement("text");
|
|
541
|
-
_$insertNode(_el$32, _el$33);
|
|
542
|
-
_$insertNode(_el$32, _el$35);
|
|
543
|
-
_$insertNode(_el$32, _el$37);
|
|
544
|
-
_$insertNode(_el$32, _el$38);
|
|
545
|
-
_$setProp(_el$32, "gap", 1);
|
|
546
|
-
_$insertNode(_el$33, _el$34);
|
|
547
|
-
_$insert(_el$34, () => props.title);
|
|
548
|
-
_$insertNode(_el$35, _$createTextNode(`OpenCode Quota command failed.`));
|
|
549
|
-
_$setProp(_el$37, "wrapMode", "none");
|
|
550
|
-
_$insert(_el$37, message || "Unknown error");
|
|
551
|
-
_$insertNode(_el$38, _$createTextNode(`esc closes`));
|
|
552
|
-
_$effect(_p$ => {
|
|
553
|
-
var _v$8 = props.api.theme.current.text,
|
|
554
|
-
_v$9 = props.api.theme.current.text,
|
|
555
|
-
_v$0 = props.api.theme.current.textMuted,
|
|
556
|
-
_v$1 = props.api.theme.current.textMuted;
|
|
557
|
-
_v$8 !== _p$.e && (_p$.e = _$setProp(_el$33, "fg", _v$8, _p$.e));
|
|
558
|
-
_v$9 !== _p$.t && (_p$.t = _$setProp(_el$35, "fg", _v$9, _p$.t));
|
|
559
|
-
_v$0 !== _p$.a && (_p$.a = _$setProp(_el$37, "fg", _v$0, _p$.a));
|
|
560
|
-
_v$1 !== _p$.o && (_p$.o = _$setProp(_el$38, "fg", _v$1, _p$.o));
|
|
561
|
-
return _p$;
|
|
562
|
-
}, {
|
|
563
|
-
e: undefined,
|
|
564
|
-
t: undefined,
|
|
565
|
-
a: undefined,
|
|
566
|
-
o: undefined
|
|
567
|
-
});
|
|
568
|
-
return _el$32;
|
|
569
|
-
})();
|
|
570
|
-
}
|
|
571
|
-
function TokensBetweenPromptDialog(props) {
|
|
572
|
-
const DialogPrompt = props.api.ui?.DialogPrompt;
|
|
573
|
-
if (DialogPrompt) {
|
|
574
|
-
return _$createComponent(DialogPrompt, {
|
|
575
|
-
title: "OpenCode Quota Token Range",
|
|
576
|
-
placeholder: "YYYY-MM-DD YYYY-MM-DD",
|
|
577
|
-
description: () => (() => {
|
|
578
|
-
var _el$40 = _$createElement("text");
|
|
579
|
-
_$insertNode(_el$40, _$createTextNode(`Enter start and end dates, for example: 2026-01-01 2026-01-15`));
|
|
580
|
-
_$setProp(_el$40, "wrapMode", "none");
|
|
581
|
-
_$effect(_$p => _$setProp(_el$40, "fg", props.api.theme.current.textMuted, _$p));
|
|
582
|
-
return _el$40;
|
|
583
|
-
})(),
|
|
584
|
-
get onConfirm() {
|
|
585
|
-
return props.onConfirm;
|
|
586
|
-
},
|
|
587
|
-
get onCancel() {
|
|
588
|
-
return props.onCancel;
|
|
589
|
-
}
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
return _$createComponent(CommandOutputDialog, {
|
|
593
|
-
get api() {
|
|
594
|
-
return props.api;
|
|
595
|
-
},
|
|
596
|
-
title: "OpenCode Quota Token Range",
|
|
597
|
-
output: "Missing arguments for /tokens_between\n\nExpected: /tokens_between YYYY-MM-DD YYYY-MM-DD\nExample: /tokens_between 2026-01-01 2026-01-15"
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
function replaceDialog(api, size, render) {
|
|
601
|
-
const dialog = api.ui?.dialog;
|
|
602
|
-
dialog?.replace?.(render);
|
|
603
|
-
// OpenCode's dialog.replace() resets size to medium; xlarge is the widest supported dialog.
|
|
604
|
-
dialog?.setSize?.(size);
|
|
605
|
-
}
|
|
606
|
-
function clearDialog(api) {
|
|
607
|
-
api.ui?.dialog?.clear?.();
|
|
608
|
-
}
|
|
609
|
-
async function runQuotaDialogCommandAsync(api, command, rawInput, state) {
|
|
610
|
-
const spec = QUOTA_DIALOG_COMMANDS.find(item => item.id === command);
|
|
611
|
-
const args = getTuiCommandArguments(rawInput);
|
|
612
|
-
const sessionID = getActiveTuiSessionID(api);
|
|
613
|
-
if (command === "tokens_between" && !args) {
|
|
614
|
-
replaceDialog(api, "medium", () => _$createComponent(TokensBetweenPromptDialog, {
|
|
615
|
-
api: api,
|
|
616
|
-
onCancel: () => clearDialog(api),
|
|
617
|
-
onConfirm: value => {
|
|
618
|
-
const nextArgs = value.trim();
|
|
619
|
-
if (!nextArgs) {
|
|
620
|
-
replaceDialog(api, "large", () => _$createComponent(CommandOutputDialog, {
|
|
621
|
-
api: api,
|
|
622
|
-
get title() {
|
|
623
|
-
return spec.title;
|
|
624
|
-
},
|
|
625
|
-
output: "Missing arguments for /tokens_between\n\nExpected: /tokens_between YYYY-MM-DD YYYY-MM-DD\nExample: /tokens_between 2026-01-01 2026-01-15"
|
|
626
|
-
}));
|
|
627
|
-
return;
|
|
628
|
-
}
|
|
629
|
-
runQuotaDialogCommand(api, command, {
|
|
630
|
-
arguments: nextArgs
|
|
631
|
-
}, state);
|
|
632
|
-
}
|
|
633
|
-
}));
|
|
634
|
-
return;
|
|
635
|
-
}
|
|
636
|
-
replaceDialog(api, spec.dialogSize, () => _$createComponent(CommandLoadingDialog, {
|
|
637
|
-
api: api,
|
|
638
|
-
get title() {
|
|
639
|
-
return spec.title;
|
|
640
|
-
}
|
|
641
|
-
}));
|
|
642
|
-
try {
|
|
643
|
-
const result = await buildQuotaDialogCommandOutput({
|
|
644
|
-
command,
|
|
645
|
-
arguments: args,
|
|
646
|
-
client: createTuiQuotaClient(api),
|
|
647
|
-
roots: getTuiRuntimeRootHints(api),
|
|
648
|
-
sessionID,
|
|
649
|
-
resolveSessionMeta: id => getTuiSessionModelMeta(api, id),
|
|
650
|
-
lastSessionTokenError: state?.lastSessionTokenError,
|
|
651
|
-
setLastSessionTokenError: state ? error => {
|
|
652
|
-
state.lastSessionTokenError = error;
|
|
653
|
-
} : undefined,
|
|
654
|
-
log: async (message, extra) => {
|
|
655
|
-
await api.client?.app?.log?.({
|
|
656
|
-
body: {
|
|
657
|
-
service: "quota-toast",
|
|
658
|
-
level: "debug",
|
|
659
|
-
message,
|
|
660
|
-
extra
|
|
661
|
-
}
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
});
|
|
665
|
-
if (result.state === "noop") {
|
|
666
|
-
clearDialog(api);
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
replaceDialog(api, result.dialogSize, () => _$createComponent(CommandOutputDialog, {
|
|
670
|
-
api: api,
|
|
671
|
-
get title() {
|
|
672
|
-
return result.title;
|
|
673
|
-
},
|
|
674
|
-
get output() {
|
|
675
|
-
return result.output;
|
|
676
|
-
}
|
|
677
|
-
}));
|
|
678
|
-
} catch (error) {
|
|
679
|
-
replaceDialog(api, "large", () => _$createComponent(CommandErrorDialog, {
|
|
680
|
-
api: api,
|
|
681
|
-
get title() {
|
|
682
|
-
return spec.title;
|
|
683
|
-
},
|
|
684
|
-
error: error
|
|
685
|
-
}));
|
|
686
|
-
api.ui?.toast?.({
|
|
687
|
-
variant: "error",
|
|
688
|
-
message: "OpenCode Quota command failed"
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
function runQuotaDialogCommand(api, command, rawInput, state) {
|
|
693
|
-
void runQuotaDialogCommandAsync(api, command, rawInput, state);
|
|
694
|
-
}
|
|
695
|
-
function registerQuotaDialogCommands(api) {
|
|
696
|
-
const keymap = api.keymap;
|
|
697
|
-
if (!keymap?.registerLayer) return;
|
|
698
|
-
const commandState = {};
|
|
699
|
-
const dispose = keymap.registerLayer({
|
|
700
|
-
commands: QUOTA_DIALOG_COMMANDS.map(spec => ({
|
|
701
|
-
namespace: "palette",
|
|
702
|
-
name: `opencode-quota.${spec.id}`,
|
|
703
|
-
title: spec.title,
|
|
704
|
-
desc: spec.description,
|
|
705
|
-
category: "OpenCode Quota",
|
|
706
|
-
slashName: spec.slashName,
|
|
707
|
-
run(input) {
|
|
708
|
-
runQuotaDialogCommand(api, spec.id, input, commandState);
|
|
709
|
-
}
|
|
710
|
-
}))
|
|
711
|
-
});
|
|
712
|
-
if (typeof dispose === "function") {
|
|
713
|
-
api.lifecycle.onDispose(dispose);
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
439
|
function registerSidebarSlots(api) {
|
|
717
440
|
api.slots.register({
|
|
718
441
|
order: SIDEBAR_ORDER,
|
|
@@ -729,7 +452,6 @@ function registerSidebarSlots(api) {
|
|
|
729
452
|
});
|
|
730
453
|
}
|
|
731
454
|
const tui = async api => {
|
|
732
|
-
registerQuotaDialogCommands(api);
|
|
733
455
|
let surfaceRegistration;
|
|
734
456
|
try {
|
|
735
457
|
surfaceRegistration = await resolveTuiSurfaceRegistration(api);
|