{"id":50043320,"url":"https://github.com/jtyr/opencode-copilot-usage","last_synced_at":"2026-05-21T04:10:38.204Z","repository":{"id":339195265,"uuid":"1160857748","full_name":"jtyr/opencode-copilot-usage","owner":"jtyr","description":"Display GitHub Copilot usage quota information in OpenCode.","archived":false,"fork":false,"pushed_at":"2026-03-03T10:52:58.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-03T13:50:55.703Z","etag":null,"topics":["copilot","opencode","plugin","tool"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jtyr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-18T13:04:21.000Z","updated_at":"2026-03-03T10:53:01.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/jtyr/opencode-copilot-usage","commit_stats":null,"previous_names":["jtyr/opencode-copilot-usage"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jtyr/opencode-copilot-usage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fopencode-copilot-usage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fopencode-copilot-usage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fopencode-copilot-usage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fopencode-copilot-usage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jtyr","download_url":"https://codeload.github.com/jtyr/opencode-copilot-usage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fopencode-copilot-usage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33288290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T02:57:32.698Z","status":"ssl_error","status_checked_at":"2026-05-21T02:57:31.990Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["copilot","opencode","plugin","tool"],"created_at":"2026-05-21T04:10:37.414Z","updated_at":"2026-05-21T04:10:38.197Z","avatar_url":"https://github.com/jtyr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Copilot Usage Tool for OpenCode\n\nDisplay GitHub Copilot usage quota information in OpenCode.\n\n## Features\n\n- **Flexible authentication**: Supports `GITHUB_TOKEN` environment variable or\n  OpenCode's auth.json file\n- **Smart auth detection**: Automatically detects and uses available GitHub\n  Copilot authentication (public or enterprise)\n- **Comprehensive logging**: All operations logged via OpenCode's logging system\n\n## Requirements\n\n- [OpenCode](http://opencode.ai)\n- [GitHub Copilot subscription](https://github.com/features/copilot/plans)\n- Valid GitHub authentication (via `GITHUB_TOKEN` or OpenCode auth)\n- [Bun](https://bun.com/)\n\n## Installation\n\nInstall the dependency and symlink the files to your global OpenCode config\ndirectory:\n\n```bash\n# Dependencies\nbun install\n# Create directories\nmkdir -p ~/.config/opencode/{commands,plugins,tools}\n# Symlink files\nln -s $PWD/tools/copilot-usage.ts ~/.config/opencode/tools/\nln -s $PWD/plugins/copilot-usage.ts ~/.config/opencode/plugins/\n# Public GitHub Copilot\nln -s $PWD/commands/public/copilot-usage.md ~/.config/opencode/commands/\n# Enterprise GitHub Copilot\nln -s $PWD/commands/enterprise/copilot-usage.md ~/.config/opencode/commands/\n```\n\n## Usage\n\n### Slash Commands\n\n```text\n/copilot-usage\n```\n\nThis displays the quota information as formatted markdown text in the chat.\n\n### Natural Language\n\nYou can also ask the AI to check your quota naturally:\n\n```text\nCall the copilot-usage tool and display its output as is.\n```\n\nThe AI will automatically call the `copilot-usage` tool.\n\n### Automatically in AGENTS.md\n\nYou can add the following to your `~/.config/opencode/AGENTS.md` file to display\nthe usage at the end of every response:\n\n```markdown\n- When you are using GitHub Copilot models (e.g.\n  `github-copilot-enterprise/claude-sonnet-4.6`), you MUST invoke the internal\n  tool `copilot-usage` using the runtime tool-calling interface and output of\n  tool's verbatim at the end of the response.\n```\n\n### Direct Tool Invocation\n\nThe AI can call the tool directly with custom parameters:\n\n```json\n{\n  \"authSource\": \"enterprise\"\n}\n```\n\n## Tool Parameters\n\n### `authSource` (string, optional)\n\nPreferred authentication source when both are available.\n\n- **Options**: `\"enterprise\"` or `\"public\"`\n- **Default**: `\"public\"` (if both available), otherwise uses what is available\n- **Example**: `{\"authSource\": \"enterprise\"}` - Use enterprise auth\n\n## Authentication\n\nThe tool supports two authentication methods (tried in order):\n\n### 1. Environment Variable (Preferred)\n\nSet the `GITHUB_TOKEN` environment variable:\n\n```bash\nexport GITHUB_TOKEN=ghp_your_token_here\n```\n\n### 2. OpenCode Auth File (Fallback)\n\nThe tool automatically reads from `~/.local/share/opencode/auth.json` if\n`GITHUB_TOKEN` is not set.\n\nSupports both:\n\n- `github-copilot-enterprise` (GitHub Enterprise)\n- `github-copilot` (Public GitHub)\n\nIf both are present, defaults to `public` unless `authSource` parameter\nspecifies otherwise.\n\n## Output Examples\n\n### Formatted Text Output\n\n```markdown\n# Copilot Pro Usage\n\nPremium requests: 150/200 (75.00%)\n```\n\n### Unlimited Plan\n\n```markdown\n# Copilot Enterprise Usage\n\nPremium requests: unlimited\n```\n\n## Error Handling\n\n```markdown\n# Copilot Usage Error\n\nError: Authentication not found. Set GITHUB_TOKEN env var or authenticate with OpenCode\n```\n\n## Logging\n\nAll operations are logged via OpenCode's logging system with service name\n`copilot-usage-tool`:\n\n- **debug**: Tool execution details, API calls\n- **info**: Successful operations, auth source selection\n- **error**: Failures, exceptions\n\nView logs in OpenCode's log viewer or check the logs directory.\n\n## Troubleshooting\n\n### \"Authentication not found\"\n\n**Solution**: Set `GITHUB_TOKEN` environment variable or authenticate with\nOpenCode.\n\n```bash\nexport GITHUB_TOKEN=ghp_your_token_here\n```\n\n### \"GitHub Copilot authentication not found in auth.json\"\n\n**Solution**: Authenticate with GitHub Copilot in OpenCode first, or use the\n`GITHUB_TOKEN` environment variable.\n\n### \"Premium requests not available for this plan\"\n\n**Solution**: Your GitHub Copilot plan does not include premium requests\ntracking. This tool requires a plan with premium interaction limits (Pro,\nBusiness, or Enterprise).\n\n### \"HTTP 401: Unauthorized\"\n\n**Solution**: Your token is invalid or expired. Generate a new GitHub personal\naccess token or re-authenticate with OpenCode.\n\n## File Structure\n\n```text\ncopilot-usage/\n├── commands/\n│   ├── public/\n│   │   └── copilot-usage.md  # /copilot-usage command for public GitHub\n│   └── enterprise/\n│       └── copilot-usage.md  # /copilot-usage command for enterprise GitHub\n├── tools/\n│   └── copilot-usage.ts      # Main tool implementation\n├── plugins/\n│   └── copilot-usage.ts      # Plugin (for future extensibility)\n└── README.md                 # This file\n```\n\n## Author\n\nJiri Tyr\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtyr%2Fopencode-copilot-usage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjtyr%2Fopencode-copilot-usage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtyr%2Fopencode-copilot-usage/lists"}