{"id":31287929,"url":"https://github.com/heyhuynhgiabuu/ocsight","last_synced_at":"2026-05-04T01:31:24.451Z","repository":{"id":314789692,"uuid":"1056325086","full_name":"heyhuynhgiabuu/ocsight","owner":"heyhuynhgiabuu","description":"Track OpenCode AI costs and usage. Real costs, real data.","archived":false,"fork":false,"pushed_at":"2025-10-19T09:11:48.000Z","size":3212,"stargazers_count":8,"open_issues_count":6,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-19T20:08:17.637Z","etag":null,"topics":["analytics","bun","caching","cli","development-tools","export","monitoring","observability","opencode","performance","real-time","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/heyhuynhgiabuu.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":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-09-13T21:07:26.000Z","updated_at":"2025-10-19T09:11:51.000Z","dependencies_parsed_at":"2025-09-14T20:46:30.174Z","dependency_job_id":"791259df-e4e4-46e8-bc43-af49eb90d8cc","html_url":"https://github.com/heyhuynhgiabuu/ocsight","commit_stats":null,"previous_names":["heyhuynhgiabuu/ocusage"],"tags_count":46,"template":false,"template_full_name":null,"purl":"pkg:github/heyhuynhgiabuu/ocsight","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heyhuynhgiabuu%2Focsight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heyhuynhgiabuu%2Focsight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heyhuynhgiabuu%2Focsight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heyhuynhgiabuu%2Focsight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heyhuynhgiabuu","download_url":"https://codeload.github.com/heyhuynhgiabuu/ocsight/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heyhuynhgiabuu%2Focsight/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32591596,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"ssl_error","status_checked_at":"2026-05-03T22:09:10.534Z","response_time":103,"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":["analytics","bun","caching","cli","development-tools","export","monitoring","observability","opencode","performance","real-time","typescript"],"created_at":"2025-09-24T11:35:35.760Z","updated_at":"2026-05-04T01:31:24.446Z","avatar_url":"https://github.com/heyhuynhgiabuu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OCsight - OpenCode Cost Tracking\n\nTrack your OpenCode AI spending. Real costs from real data.\n\n![Usage Summary](assets/summary.png)\n\n## What It Does\n\nocsight reads your OpenCode sessions and shows you exactly what you're spending:\n\n- **Cost tracking** by provider and model\n- **Budget limits** with spending alerts\n- **Token usage** breakdowns\n- **Live monitoring** of active sessions\n\n## Installation\n\n```bash\n# macOS/Linux (Homebrew)\nbrew install heyhuynhgiabuu/tap/ocsight\n\n# Node.js (npm)\nnpm install -g ocsight\n\n# Direct download\ncurl -L https://github.com/heyhuynhgiabuu/ocsight/releases/latest/download/ocsight-$(uname -s)-$(uname -m).zip | tar -xz\n```\n\n## Quick Start\n\n```bash\n# See your spending\nocsight summary\n\n# Set budget limits\nocsight budget set --monthly 200\n\n# Monitor live usage\nocsight live\n```\n\n## Screenshots \u0026 Examples\n\n### 📊 Usage Summary\n\nSee your OpenCode usage at a glance with provider breakdowns and daily activity:\n\n![Summary Command](assets/summary.png)\n\n### 💰 Cost Tracking\n\nTrack your AI spending with daily breakdowns and spending alerts:\n\n![Costs Command](assets/costs.png)\n\n### 📋 Session Management\n\nBrowse, analyze, and drill into individual sessions:\n\n![Sessions Command](assets/sessions.png)\n\n### 🔴 Live Monitoring\n\nReal-time dashboard showing active session costs and tokens:\n\n![Live Monitor](assets/live.png)\n\n### 💰 Budget Management\n\nSet spending limits and get alerts when approaching budgets:\n\n![Budget Status](assets/budget-status.png)\n\nAdd budget limits and configure spending alerts:\n\n![Budget Add](assets/budget-add.png)\n\nView detailed budget information and settings:\n\n![Budget Show](assets/budget-show.png)\n\n### 🤖 Model Database\n\nBrowse pricing across 500+ AI models:\n\n![Models Database](assets/models.png)\n\n## Export Formats\n\nocsight can export your data in multiple formats for reporting and analysis:\n\n### JSON Export\n\n```json\n{\n  \"summary\": {\n    \"totalSessions\": 787,\n    \"totalCost\": 8736.43,\n    \"totalTokens\": 2949563969,\n    \"dateRange\": \"2024-12-12 to 2024-12-19\"\n  },\n  \"providers\": [\n    {\n      \"name\": \"anthropic\",\n      \"sessions\": 26,\n      \"cost\": 8237.66,\n      \"tokens\": 699650136\n    }\n  ]\n}\n```\n\n### CSV Export\n\n```csv\nDate,Provider,Model,Sessions,Tokens,Cost\n2024-12-19,anthropic,claude-3.5-sonnet,15,12345678,234.56\n2024-12-18,openai,gpt-4o,23,23456789,456.78\n2024-12-17,anthropic,claude-3.5-haiku,19,18234567,345.67\n```\n\n### Markdown Report\n\n```markdown\n# OpenCode Usage Report\n\n## Summary\n\n- **Period**: 2024-12-12 to 2024-12-19\n- **Total Sessions**: 787\n- **Total Cost**: $8,736.43\n- **Total Tokens**: 2,949,563,969\n\n## Top Providers\n\n| Provider  | Sessions | Cost      | Tokens      |\n| --------- | -------- | --------- | ----------- |\n| anthropic | 26       | $8,237.66 | 699,650,136 |\n| openai    | 77       | $405.73   | 471,822,278 |\n```\n\n## Commands Reference\n\n### `summary` - Usage Overview\n\n```bash\nocsight summary                    # Last 7 days\nocsight summary --days 30          # Last month\nocsight summary --provider anthropic  # Filter by provider\nocsight summary --detailed          # Full breakdown\n```\n\n### `sessions` - Session Management\n\n```bash\nocsight sessions list              # List all sessions\nocsight sessions list --recent     # Recent only\nocsight sessions show ses_123      # View specific session\nocsight sessions top --cost        # Most expensive sessions\nocsight sessions top --tokens      # Most tokens used\n```\n\n### `costs` - Cost Tracking\n\n```bash\nocsight costs                      # Last 7 days\nocsight costs today                # Today only\nocsight costs --days 30            # Last month\nocsight costs --alert 100          # Alert if \u003e$100/day\nocsight costs --provider anthropic # Filter by provider\n```\n\n### `live` - Real-time Monitoring\n\n```bash\nocsight live                       # Monitor current session\nocsight live --session ses_123     # Monitor specific session\nocsight live --refresh 5           # Update every 5 seconds\n```\n\n### `export` - Export Data\n\n```bash\nocsight export                     # JSON format\nocsight export --format csv        # CSV format\nocsight export --format markdown   # Markdown report\nocsight export --output report.csv # Custom filename\n```\n\n### `models` - Model Pricing\n\n```bash\nocsight models list                # List all models\nocsight models providers           # List providers\nocsight models show gpt-4o         # Model details\n```\n\n### `budget` - Budget Management\n\n```bash\nocsight budget set --monthly 200   # Set $200 monthly limit\nocsight budget add                 # Add provider budget\nocsight budget forecast            # Project month-end costs\nocsight budget status              # Current budget usage\nocsight budget show                # Show budget details\n```\n\n## Example Terminal Output\n\n```\n📊 Usage Summary\n════════════════\n\nOverview\nSessions          │ 787\nTotal Cost        │ $8,736.43\nTotal Tokens      │ 2,949,563,969\nAvg Cost/Session  │ $11.10\n\nProvider Breakdown\n┌──────────┬──────────┬──────────┬───────────────┐\n│ Provider │ Sessions │ Cost     │ Tokens        │\n├──────────┼──────────┼──────────┼───────────────┤\n│ anthropic│      26  │ $8,237.66│ 699,650,136   │\n│ openai   │      77  │   $405.73│ 471,822,278   │\n│ github   │     517  │     $0.00│ 805,039,693   │\n└──────────┴──────────┴──────────┴───────────────┘\n\nDaily Activity (Last 7 Days)\n┌────────────┬─────────┬──────────┬─────────────┐\n│ Date       │ Sessions│ Cost     │ Tokens      │\n├────────────┼─────────┼──────────┼─────────────┤\n│ 2024-12-19 │      15 │   $234.56│  12,345,678 │\n│ 2024-12-18 │      23 │   $456.78│  23,456,789 │\n│ 2024-12-17 │      19 │   $345.67│  18,234,567 │\n└────────────┴─────────┴──────────┴─────────────┘\n```\n\n## Why ocsight?\n\n### ✅ Accurate\n\nReal costs from actual model pricing, no estimates\n\n### 🚀 Fast\n\nBuilt with Bun for maximum performance:\n\n- Zstd compression (faster/smaller than gzip)\n- SIMD-accelerated ANSI processing\n- Native TypeScript execution\n- Concurrent test execution\n- Handles 10k+ sessions instantly with optimized caching\n\n### 💰 Smart Budgets\n\nSet limits, get alerts, forecast spending with conservative projections\n\n### 🔴 Live Monitoring\n\nWatch costs accumulate in real-time\n\n### 📊 Comprehensive Analytics\n\nDetailed breakdowns by provider, model, and time period\n\n### 🔒 Private\n\nRuns locally, never sends your data anywhere\n\n## Requirements\n\n- Bun runtime (recommended) or Node.js 18+\n- OpenCode installed\n- Session data in `~/.local/share/opencode/storage/`\n\n## Performance with Bun\n\nocsight is optimized for Bun v1.3+:\n\n- **6-57x faster ANSI processing** with native SIMD operations\n- **Smaller cache files** using zstd compression instead of gzip\n- **Faster startup** with native TypeScript execution\n- **166ms build time** using Bun.build API\n- **Concurrent testing** for faster test execution\n\nWhen running with Bun, you automatically get:\n\n- Native zstd compression for cache (faster + smaller than gzip)\n- SIMD-accelerated ANSI stripping in live monitoring\n- OS-native credential storage for secrets\n- Faster JSON parsing and file I/O\n\nNode.js fallbacks ensure full compatibility without Bun-specific features.\n\n## Data Sources\n\nocsight reads from your local OpenCode storage:\n\n```\n~/.local/share/opencode/storage/\n├── session/\u003cproject-hash\u003e/ses_*.json   # Session metadata\n└── message/\u003csession-id\u003e/msg_*.json     # Individual messages\n```\n\n## Development\n\n```bash\ngit clone https://github.com/heyhuynhgiabuu/ocsight\ncd ocsight\nbun install\nbun run build\nbun test\nbun run packages/cli/src/index.ts summary\n```\n\n### Build Process\n\nocsight uses Bun's native build system:\n\n```bash\n# Bundle CLI with Bun.build API\nbun run scripts/bundle-cli.ts\n\n# Compile standalone executables\nbun build packages/cli/src/index.ts --compile --outfile ocsight-linux-x64\n\n# Run tests with concurrent execution\nbun test --concurrent\n\n# Watch mode for development\nbun test --watch\n```\n\n### Cross-Platform Builds\n\nNative executables are built via CI:\n\n- **Linux x64** - Ubuntu 22.04 build\n- **macOS x64** - Intel Mac build with code signing\n- **macOS ARM64** - Apple Silicon build with code signing\n- **Windows x64** - Windows build with .exe output\n\nDownload from [releases page](https://github.com/heyhuynhgiabuu/ocsight/releases).\n\n## Configuration\n\nocsight works out of the box. Optional config:\n\n```bash\nocsight budget set --monthly 200    # Set budget\nocsight config show                  # View config\nocsight config doctor               # Validate setup\n```\n\n## Troubleshooting\n\n**No data showing?**\n\n- Check OpenCode is installed: `which opencode`\n- Verify data exists: `ls ~/.local/share/opencode/storage/`\n- Run doctor: `ocsight config doctor`\n\n**Wrong costs?**\n\n- ocsight uses models.dev pricing\n- Some providers (github) show $0.00 for free tiers\n- Custom/enterprise pricing not supported\n\n**Performance issues?**\n\n- First run caches data (may be slow)\n- Use `--days` flag to limit data range\n- Large histories (\u003e10k sessions) may be slow\n- **Tip**: Run with Bun for 6-57x faster performance vs Node.js\n\n## Project Structure\n\n```\nocsight/\n├── packages/\n│   ├── cli/          # CLI implementation\n│   └── web/          # Documentation website\n├── assets/           # Screenshots and examples\n├── scripts/          # Build and release scripts\n└── README.md         # You are here\n```\n\n## Contributing\n\nContributions welcome! Please:\n\n1. Fork the repository\n2. Create a feature branch\n3. Add tests for new features\n4. Submit a pull request\n\n## License\n\nMIT © heyhuynhgiabuu\n\n## Links\n\n- [GitHub Repository](https://github.com/heyhuynhgiabuu/ocsight)\n- [NPM Package](https://www.npmjs.com/package/ocsight)\n- [Documentation](https://ocsight.com)\n- [Issue Tracker](https://github.com/heyhuynhgiabuu/ocsight/issues)\n\n---\n\nTrack your AI costs with confidence · Built with Bun.js for speed\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheyhuynhgiabuu%2Focsight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheyhuynhgiabuu%2Focsight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheyhuynhgiabuu%2Focsight/lists"}