opencode-usage 0.2.5 → 0.3.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.
Files changed (39) hide show
  1. package/dist/__tests__/aggregator.test.d.ts +1 -0
  2. package/dist/__tests__/cli.test.d.ts +1 -0
  3. package/dist/__tests__/codex-client.test.d.ts +1 -0
  4. package/dist/__tests__/dashboard-integration.test.d.ts +1 -0
  5. package/dist/__tests__/loader.perf.test.d.ts +1 -0
  6. package/dist/__tests__/loader.test.d.ts +1 -0
  7. package/dist/__tests__/pricing.test.d.ts +1 -0
  8. package/dist/__tests__/quota-loader.test.d.ts +1 -0
  9. package/dist/__tests__/quota-panel.test.d.ts +1 -0
  10. package/dist/__tests__/renderer.test.d.ts +1 -0
  11. package/dist/__tests__/status-bar.test.d.ts +1 -0
  12. package/dist/__tests__/usage-table.test.d.ts +1 -0
  13. package/dist/cli.d.ts +4 -0
  14. package/dist/codex-client.d.ts +6 -0
  15. package/dist/config-commands.d.ts +5 -0
  16. package/dist/config.d.ts +9 -0
  17. package/dist/dashboard/quota-panel.d.ts +5 -0
  18. package/dist/dashboard/status-bar.d.ts +9 -0
  19. package/dist/dashboard/usage-table.d.ts +7 -0
  20. package/dist/dashboard-solid.d.ts +8 -0
  21. package/dist/dashboard.d.ts +10 -0
  22. package/dist/highlights-eq9cgrbb.scm +604 -0
  23. package/dist/highlights-ghv9g403.scm +205 -0
  24. package/dist/highlights-hk7bwhj4.scm +284 -0
  25. package/dist/highlights-r812a2qc.scm +150 -0
  26. package/dist/highlights-x6tmsnaa.scm +115 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.js +28756 -60
  29. package/dist/index.js.map +17 -7
  30. package/dist/injections-73j83es3.scm +27 -0
  31. package/dist/loader.d.ts +14 -1
  32. package/dist/quota-loader.d.ts +12 -0
  33. package/dist/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
  34. package/dist/tree-sitter-markdown-411r6y9b.wasm +0 -0
  35. package/dist/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
  36. package/dist/tree-sitter-typescript-zxjzwt75.wasm +0 -0
  37. package/dist/tree-sitter-zig-e78zbjpm.wasm +0 -0
  38. package/dist/types.d.ts +78 -0
  39. package/package.json +9 -3
@@ -0,0 +1,27 @@
1
+ ; Query from: https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/refs/heads/master/queries/markdown/injections.scm
2
+ (fenced_code_block
3
+ (info_string
4
+ (language) @_lang)
5
+ (code_fence_content) @injection.content
6
+ (#set-lang-from-info-string! @_lang))
7
+
8
+ ((html_block) @injection.content
9
+ (#set! injection.language "html")
10
+ (#set! injection.combined)
11
+ (#set! injection.include-children))
12
+
13
+ ((minus_metadata) @injection.content
14
+ (#set! injection.language "yaml")
15
+ (#offset! @injection.content 1 0 -1 0)
16
+ (#set! injection.include-children))
17
+
18
+ ((plus_metadata) @injection.content
19
+ (#set! injection.language "toml")
20
+ (#offset! @injection.content 1 0 -1 0)
21
+ (#set! injection.include-children))
22
+
23
+ ([
24
+ (inline)
25
+ (pipe_table_cell)
26
+ ] @injection.content
27
+ (#set! injection.language "markdown_inline"))
package/dist/loader.d.ts CHANGED
@@ -1,3 +1,16 @@
1
- import type { MessageJson } from "./types.js";
1
+ import type { MessageJson, CursorState } from "./types.js";
2
2
  export declare function getOpenCodeStoragePath(): string;
3
+ export declare function loadRecentMessages(storagePath: string, hoursBack?: number, providerFilter?: string): Promise<MessageJson[]>;
3
4
  export declare function loadMessages(storagePath: string, providerFilter?: string): Promise<MessageJson[]>;
5
+ /**
6
+ * Create an empty cursor state for first load
7
+ */
8
+ export declare function createCursor(): CursorState;
9
+ /**
10
+ * Load messages incrementally using cursor state
11
+ * Returns new messages and updated cursor
12
+ */
13
+ export declare function loadMessagesIncremental(storagePath: string, cursor: CursorState, providerFilter?: string): Promise<{
14
+ messages: MessageJson[];
15
+ cursor: CursorState;
16
+ }>;
@@ -0,0 +1,12 @@
1
+ import type { QuotaSnapshot } from "./types.js";
2
+ /**
3
+ * Load quota from anthropic-multi-account state file
4
+ * Path: ~/.local/share/opencode/multi-account-state.json
5
+ */
6
+ export declare function loadMultiAccountQuota(): Promise<QuotaSnapshot[]>;
7
+ /**
8
+ * Load quota from antigravity accounts file
9
+ * Path: ~/.config/opencode/antigravity-accounts.json
10
+ * Note: remainingFraction is inverted (0 = exhausted, 1 = full)
11
+ */
12
+ export declare function loadAntigravityQuota(): Promise<QuotaSnapshot[]>;
package/dist/types.d.ts CHANGED
@@ -54,3 +54,81 @@ export type ModelPricing = {
54
54
  cacheWrite: number;
55
55
  cacheRead: number;
56
56
  };
57
+ /** Unified quota snapshot for display */
58
+ export type QuotaSnapshot = {
59
+ source: "anthropic" | "antigravity" | "codex";
60
+ label: string;
61
+ used: number;
62
+ resetAt?: number;
63
+ error?: string;
64
+ };
65
+ /** Cursor state for incremental message loading */
66
+ export type CursorState = {
67
+ knownSessions: Set<string>;
68
+ fileCountPerSession: Map<string, number>;
69
+ lastTimestamp: number;
70
+ };
71
+ /** Anthropic multi-account state file structure */
72
+ export type MultiAccountState = {
73
+ currentAccount?: string;
74
+ requestCount?: number;
75
+ usage?: Record<string, {
76
+ session5h?: {
77
+ utilization: number;
78
+ reset: number;
79
+ status?: string;
80
+ };
81
+ weekly7d?: {
82
+ utilization: number;
83
+ reset: number;
84
+ status?: string;
85
+ };
86
+ weekly7dSonnet?: {
87
+ utilization: number;
88
+ reset: number;
89
+ status?: string;
90
+ };
91
+ timestamp?: string;
92
+ }>;
93
+ };
94
+ /** Antigravity quota group */
95
+ export type AntigravityQuotaGroup = {
96
+ remainingFraction: number;
97
+ resetTime?: string;
98
+ };
99
+ /** Antigravity accounts file structure */
100
+ export type AntigravityAccount = {
101
+ email?: string;
102
+ disabled?: boolean;
103
+ cachedQuota?: {
104
+ claude?: AntigravityQuotaGroup;
105
+ "gemini-pro"?: AntigravityQuotaGroup;
106
+ "gemini-flash"?: AntigravityQuotaGroup;
107
+ };
108
+ cachedQuotaUpdatedAt?: number;
109
+ };
110
+ export type AntigravityAccountsFile = {
111
+ accounts: AntigravityAccount[];
112
+ };
113
+ /** Codex API response structure */
114
+ export type CodexUsageResponse = {
115
+ user_id?: string;
116
+ account_id?: string;
117
+ plan_type?: string;
118
+ rate_limit?: {
119
+ primary_window?: {
120
+ used_percent: number;
121
+ reset_at: number;
122
+ };
123
+ secondary_window?: {
124
+ used_percent: number;
125
+ reset_at: number;
126
+ };
127
+ };
128
+ code_review_rate_limit?: {
129
+ primary_window?: {
130
+ used_percent: number;
131
+ reset_at: number;
132
+ };
133
+ };
134
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-usage",
3
- "version": "0.2.5",
3
+ "version": "0.3.1",
4
4
  "description": "CLI tool for tracking OpenCode AI coding assistant usage and costs",
5
5
  "keywords": [
6
6
  "ai",
@@ -43,18 +43,24 @@
43
43
  }
44
44
  },
45
45
  "scripts": {
46
- "build": "bun build ./src/index.ts --outdir ./dist --target bun --format esm --sourcemap && bun run build:shebang && bun run build:types",
46
+ "build": "bun run build.ts",
47
47
  "build:shebang": "bun -e \"const f='dist/index.js';Bun.write(f,(await Bun.file(f).text()).replace('#!/usr/bin/env node','#!/usr/bin/env bun'))\"",
48
48
  "build:types": "tsc --emitDeclarationOnly --declaration --outDir dist",
49
49
  "check": "bun check.ts",
50
50
  "check:ci": "bun check.ts ci",
51
51
  "ck:warmup": "bun run scripts/warmup-ck.ts",
52
52
  "compile": "bun build --compile --minify ./src/index.ts --outfile opencode-usage",
53
- "dev": "bun run ck:warmup & bun run ./src/index.ts",
53
+ "dev": "bun run ./src/index.ts",
54
+ "dev:warm": "bun run ck:warmup & bun run ./src/index.ts",
54
55
  "format": "bunx oxfmt",
55
56
  "lint": "bunx oxlint -c ./.oxlintrc.json --deny-warnings",
56
57
  "prepublishOnly": "bun run check && bun run build"
57
58
  },
59
+ "dependencies": {
60
+ "@opentui/core": "^0.1.78",
61
+ "@opentui/solid": "^0.1.79",
62
+ "solid-js": "^1.9.11"
63
+ },
58
64
  "devDependencies": {
59
65
  "@types/bun": "latest",
60
66
  "typescript": "^5.9.3"