@slkiser/opencode-quota 3.0.0 → 3.0.1

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 CHANGED
@@ -10,8 +10,8 @@
10
10
 
11
11
  What you get:
12
12
 
13
+ - TUI sidebar panel with quota
13
14
  - popup quota toasts after assistant responses
14
- - TUI sidebar panel
15
15
  - manual `/quota`, `/quota_status`, and `/tokens_*` commands
16
16
 
17
17
  **Quota providers**: Anthropic (Claude), GitHub Copilot, OpenAI (Plus/Pro), Cursor, Qwen Code, Alibaba Coding Plan, MiniMax Coding Plan, Chutes AI, Firmware AI, Google Antigravity, Z.ai Coding Plan, NanoGPT, and OpenCode Go.
@@ -20,21 +20,31 @@ What you get:
20
20
 
21
21
  <table>
22
22
  <tr>
23
- <td width="50%" align="center">Example of toast</td>
24
- <td width="50%" align="center">Example of <code>/tokens_weekly</code></td>
23
+ <td width="100%">
24
+ <img src="https://shawnkiser.com/opencode-quota/sidebar.webp" alt="Image of opencode-quota /tokens_weekly output" />
25
+ </td>
26
+ </tr>
27
+ <tr>
28
+ <td width="100%" align="center">Example of TUI sidebar</td>
25
29
  </tr>
30
+ </table>
31
+
32
+ <table>
33
+
26
34
  <tr>
27
35
  <td width="50%">
28
- <img src="https://shawnkiser.com/opencode-quota/toasts.webp" alt="Image of opencode-quota toast" />
36
+ <img src="https://shawnkiser.com/opencode-quota/toast.webp" alt="Image of opencode-quota toast" />
29
37
  </td>
30
38
  <td width="50%">
31
- <img src="https://shawnkiser.com/opencode-quota/tokens.webp" alt="Image of opencode-quota /tokens_weekly output" />
39
+ <img src="https://shawnkiser.com/opencode-quota/token.webp" alt="Image of opencode-quota /tokens_weekly output" />
32
40
  </td>
33
41
  </tr>
42
+ <tr>
43
+ <td width="50%" align="center">Example of popup toast</td>
44
+ <td width="50%" align="center">Example of <code>/tokens_weekly</code></td>
45
+ </tr>
34
46
  </table>
35
47
 
36
- ## Start here
37
-
38
48
  OpenCode `>= 1.4.3` is required.
39
49
 
40
50
  If you are coming back later:
@@ -52,11 +62,11 @@ npx @slkiser/opencode-quota init
52
62
 
53
63
  The installer (append-only, preserves existing values) asks for:
54
64
 
55
- - **Scope**: `Project` or `Global` (`Project` is the usual default)
65
+ - **Scope**: `Project` or `Global`
56
66
  - **Quota UI**: `Toast`, `Sidebar`, `Toast + Sidebar`, or `None (manual /quota and /tokens_* only)`
57
- - **Provider mode**: `Auto-detect` or `Manual select` (`Auto-detect` is the usual default)
58
- - **Layout style**: `classic` or `grouped` (`classic` is the usual default)
59
- - **Show session input/output tokens**: `Yes` or `No` (`Yes` is the usual default)
67
+ - **Provider mode**: `Auto-detect` or `Manual select`
68
+ - **Layout style**: `classic` or `grouped`
69
+ - **Show session input/output tokens**: `Yes` or `No`
60
70
 
61
71
  All quota settings live in `opencode.json` or `opencode.jsonc`. `tui.json` or `tui.jsonc` is only for loading the sidebar plugin.
62
72
 
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env node
2
+ export declare function cliShouldRunMain(argv1?: string | undefined, modulePath?: string, resolvePath?: (filePath: string) => string): boolean;
2
3
  export declare function main(argv?: string[]): Promise<number>;
3
4
  //# sourceMappingURL=opencode-quota.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"opencode-quota.d.ts","sourceRoot":"","sources":["../../src/bin/opencode-quota.ts"],"names":[],"mappings":";AAmBA,wBAAsB,IAAI,CAAC,IAAI,WAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBxE"}
1
+ {"version":3,"file":"opencode-quota.d.ts","sourceRoot":"","sources":["../../src/bin/opencode-quota.ts"],"names":[],"mappings":";AA6BA,wBAAgB,gBAAgB,CAC9B,KAAK,GAAE,MAAM,GAAG,SAA2B,EAC3C,UAAU,GAAE,MAAuC,EACnD,WAAW,GAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAuB,GACzD,OAAO,CAMT;AAED,wBAAsB,IAAI,CAAC,IAAI,WAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmBxE"}
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { pathToFileURL } from "url";
2
+ import { realpathSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
3
5
  import { runInitInstaller } from "../lib/init-installer.js";
4
6
  const USAGE = [
5
7
  "Usage:",
@@ -12,6 +14,20 @@ const USAGE = [
12
14
  function printUsage() {
13
15
  console.log(USAGE);
14
16
  }
17
+ function resolveCliPath(filePath) {
18
+ try {
19
+ return realpathSync.native(filePath);
20
+ }
21
+ catch {
22
+ return resolve(filePath);
23
+ }
24
+ }
25
+ export function cliShouldRunMain(argv1 = process.argv[1], modulePath = fileURLToPath(import.meta.url), resolvePath = resolveCliPath) {
26
+ if (!argv1) {
27
+ return false;
28
+ }
29
+ return resolvePath(modulePath) === resolvePath(argv1);
30
+ }
15
31
  export async function main(argv = process.argv.slice(2)) {
16
32
  const [command, ...rest] = argv;
17
33
  if (!command) {
@@ -28,8 +44,7 @@ export async function main(argv = process.argv.slice(2)) {
28
44
  printUsage();
29
45
  return 1;
30
46
  }
31
- const isDirectRun = process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href;
32
- if (isDirectRun) {
47
+ if (cliShouldRunMain()) {
33
48
  void main().then((code) => {
34
49
  process.exitCode = code;
35
50
  });
@@ -1 +1 @@
1
- {"version":3,"file":"opencode-quota.js","sourceRoot":"","sources":["../../src/bin/opencode-quota.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,KAAK,GAAG;IACZ,QAAQ;IACR,oCAAoC;IACpC,sCAAsC;IACtC,EAAE;IACF,WAAW;IACX,+CAA+C;CAChD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,SAAS,UAAU;IACjB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAA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AAO,MAAM,gBAAgB,EAAE,CAAC;IAClC,CAAC;IAED,UAAU,EAAE,CAAC;IACb,OAAO,CAAC,CAAC;AACX,CAAC;AAED,IAAI,gBAAgB,EAAE,EAAE,CAAC;IACvB,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slkiser/opencode-quota",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "OpenCode quota & tokens usage with zero context window pollution. Supports GitHub Copilot, OpenAI (Plus/Pro), Qwen Code, Chutes AI, Firmware AI, Google Antigravity, Z.ai coding plan and more.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",