Files

1 line
6.1 KiB
JSON

{"repo": "arandevcode/opencode-plugins", "files": {"opencode-quota-extended/README.md": {"871c729b6ec425f4d1792d843f4954abab4bc81d": {"t": 1785596396.5327992, "n": 5766, "h": "c511af190116f5bc", "c": "<p align=\"center\">\n <img src=\"https://raw.githubusercontent.com/arandevcode/opencode-plugins/main/opencode-quota-extended/images/opencode_quota_extended_sidebar.png\" alt=\"TUI sidebar\" width=\"420\">\n <br>\n <sub><em>-sidebar example-</em></sub>\n</p>\n\n# @arandevcode/opencode-quota-extended\n\n> 🇪🇸 Also available in [Spanish](README-es.md)\n\nQuota usage cards for the TUI sidebar — per-window progress bars with traffic-light colors for OpenAI, GitHub Copilot, and OpenCode Go.\n\n- Progress bar for each quota window (5h rolling, weekly, monthly, code review...)\n- Shows when it resets — time remaining and exact date\n- Color-coded health indication (green = ok, orange = warning, red = critical)\n- OpenCode Go capable!\n\nHeavily inspired by [`@slkiser/opencode-quota`](https://github.com/slkiser/opencode-quota). Both coexist without conflict.\n\n<br>\n<p align=\"center\">🐟 <em>&ldquo;Quien quiera peces que se moje el culo&rdquo;</em> >\n <em>&ldquo;If you want fish, get your ass wet&rdquo;</em> <sub>— for my father, who taught me to roll up my sleeves and get it done</sub>\n</p>\n\n<p align=\"center\">\n <a href=\"https://buymeacoffee.com/arandevcode\"><strong>☕ Buy me a coffee</strong></a>\n <br>\n <sub><a href=\"https://github.com/sponsors/arandevcode\">❤️ Sponsor on GitHub</a></sub>\n</p>\n\n## Install\n\n```sh\nopencode plugin --global --force @arandevcode/opencode-quota-extended\n```\n\nOr install from GitHub source to follow latest development:\n\n```json\n// ~/.config/opencode/opencode.json\n{\n \"plugin\": [\n \"https://github.com/arandevcode/opencode-plugins/tree/main/opencode-quota-extended\"\n ]\n}\n```\n\n## CLI\n\nView quota from the terminal without opening the TUI:\n\n```sh\nnpx opencode-quota # run via npm (no install)\nopencode-quota # if installed globally\nnode bin/quota.mjs # from the repo directory (no build needed)\nnpm run quota # from the repo directory\n```\n\n<p align=\"center\">\n <img src=\"https://raw.githubusercontent.com/arandevcode/opencode-plugins/main/opencode-quota-extended/images/opencode_quota_extended_cli.png\" alt=\"CLI output\" width=\"620\">\n <br>\n <sub><em>-cli example-</em></sub>\n</p>\n\nTraffic-light colors: green (ok), orange (warning), red (error).\n\n## Configuration\n\nOptional sidecar at `~/.config/opencode/opencode-quota-extended.json`:\n\n| Field | Type | Default | Description |\n|---|---|---|---|\n| `enabledProviders` | string[] | `[\"openai\",\"github-copilot\",\"opencode-go\"]` | Providers to fetch |\n| `refreshIntervalMs` | int | `60000` | Polling interval |\n| `cardsSidebar.order` | int | `145` | Sidebar position (lower = higher) |\n\n## More Information\n\n### How it works\n\nRegisters a TUI plugin that renders a `sidebar_content` panel at order 145, showing quota cards for every enabled provider. Each provider fetches quota data independently from its own API.\n\n| Provider | Windows | Auth source |\n|---|---|---|\n| **OpenAI** | 5h rolling, Weekly, Code Review | `auth.json` → `openai` / `chatgpt` entry |\n| **GitHub Copilot** | Premium requests (single window) | `auth.json` → `github-copilot` entry |\n| **OpenCode Go** | 5h, Weekly, Monthly | Config file or env vars |\n\nTraffic-light colors: ≥50% green (`accent`), 25-49% yellow (`warning`), <25% red (`error`).\n\n### Authentication\n\nReads credentials from OpenCode's runtime auth file (`~/.local/share/opencode/auth.json`). Does **not** store, prompt for, or distribute secrets.\n\n**OpenCode Go** requires additional setup — it's a bit tricky because there's no official API yet.\n\nCreate `~/.config/opencode/opencode-quota/opencode-go.json`:\n\n```json\n{\n \"workspaceId\": \"wrk_abc123...\",\n \"authCookie\": \"Fe26.2...\"\n}\n```\n\n| Field | Description | How to get it |\n|---|---|---|\n| `workspaceId` | Your OpenCode workspace ID | Log in at [opencode.ai/go](https://opencode.ai/go). The URL is `https://opencode.ai/workspace/wrk_XXX/go` — copy the `wrk_XXX` part. |\n| `authCookie` | Session cookie for auth | Open DevTools (F12) → Application → Cookies → `opencode.ai` → find the `auth` cookie (starts with `Fe26.2...`). Or run this in the console: `document.cookie.match(/(?:^\\|;\\s*)auth=([^;]+)/)?.[1]` |\n\n**Automated setup** (recommended):\n```sh\nnpm run setup\n```\nThis prompts for both values and creates the file for you. It also prints a bookmarklet you can drag to your bookmarks bar and click while on opencode.ai to extract the auth cookie with one click.\n\n**Tip:** keep a browser tab logged into opencode.ai while using this plugin — the auth cookie may expire.\n\n### Relationship with [`@slkiser/opencode-quota`](https://github.com/slkiser/opencode-quota)\n\n**No dependency.** Both plugins fetch quota independently and render their own sidebar panels. You can have one, both, or none — they do not interfere.\n\n### Troubleshooting\n\n- **Panel doesn't appear**: `grep '@arandevcode/opencode-quota-extended' ~/.local/share/opencode/log/*.log`\n- **OpenCode Go shows \"skipped\"**: confirm sidecar file or env vars are set\n- **Old `@opentui/solid` pinning bug**: update to `^0.4.1` and clean-install (`rm -rf node_modules && npm ci`)\n\n### Development\n\n```sh\nnpm run build # compile TS + copy TUI assets\nnpm run build:watch # watch mode\nnpm test # vitest\nnpm run typecheck # type-check without emitting\n```\n\n### Project structure\n\n```\nsrc/\n index.ts # Plugin module (server entry)\n server.ts # Server plugin (minimal, no tools)\n tui.tsx # TUI plugin: sidebar_content slot\n config/ # defaults, schema, loader\n lib/ # types, auth, http, formatting, credential resolver\n providers/ # openai.ts, copilot.ts, opencode-go.ts, registry.ts\n ui/ # SidebarPanel, cards, progress-bar\ntests/ # vitest unit tests\n```\n\n## License\n\nMIT\n"}}}}