{"id":40742810,"url":"https://github.com/ca-srg/tosage","last_synced_at":"2026-01-21T15:09:20.404Z","repository":{"id":305577403,"uuid":"1022205199","full_name":"ca-srg/tosage","owner":"ca-srg","description":"A Go application that tracks Claude Code and Cursor token usage and sends metrics to Prometheus. It can run in CLI mode (outputs today's token count) or daemon mode (system tray application with periodic metrics sending).","archived":false,"fork":false,"pushed_at":"2025-08-14T10:20:40.000Z","size":1951,"stargazers_count":12,"open_issues_count":5,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-14T12:19:49.886Z","etag":null,"topics":["claude-code","cursor","prometheus","token"],"latest_commit_sha":null,"homepage":"https://ca-srg.dev","language":"Go","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/ca-srg.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}},"created_at":"2025-07-18T16:24:45.000Z","updated_at":"2025-08-14T10:20:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"dbbb74c3-2caa-4bb9-857e-ade989246ad1","html_url":"https://github.com/ca-srg/tosage","commit_stats":null,"previous_names":["ca-srg/tosage"],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/ca-srg/tosage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ca-srg%2Ftosage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ca-srg%2Ftosage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ca-srg%2Ftosage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ca-srg%2Ftosage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ca-srg","download_url":"https://codeload.github.com/ca-srg/tosage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ca-srg%2Ftosage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28635123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T14:50:40.221Z","status":"ssl_error","status_checked_at":"2026-01-21T14:48:59.225Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["claude-code","cursor","prometheus","token"],"created_at":"2026-01-21T15:09:20.330Z","updated_at":"2026-01-21T15:09:20.387Z","avatar_url":"https://github.com/ca-srg.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tosage\n\n[🇯🇵 日本語版](./README_JA.md)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/icon.png\" alt=\"tosage logo\" width=\"256\" height=\"256\"\u003e\n\u003c/p\u003e\n\nA Go application that tracks token usage from Claude Code, Cursor, AWS Bedrock, and Google Vertex AI, and sends metrics to Prometheus. It can run in CLI mode (outputs today's token count) or daemon mode (system tray application with periodic metrics sending).\n\n## Features\n\n- **Multi-Provider Token Tracking**: Monitors token usage from Claude Code, Cursor, AWS Bedrock, and Google Vertex AI\n- **Prometheus Integration**: Sends metrics via remote write API\n- **Dual Mode Operation**: CLI mode for quick checks, daemon mode for continuous monitoring\n- **macOS System Tray**: Native system tray support for daemon mode (Claude Code/Cursor only)\n- **Automatic Data Discovery**: Finds Claude Code data across multiple locations\n- **CSV Export**: Export historical metrics data to CSV format for analysis and reporting\n- **API Integrations**: \n  - Cursor API for premium request usage and pricing\n  - AWS CloudWatch for Bedrock metrics\n  - Google Cloud Monitoring for Vertex AI metrics\n\n```mermaid\nflowchart TD\n    subgraph \"Data Sources\"\n        CC[Claude Code\u003cbr/\u003eLocal Directories]\n        CA[Cursor API]\n        AWSCW[AWS CloudWatch\u003cbr/\u003eBedrock Metrics]\n        GCPM[Google Cloud\u003cbr/\u003eVertex AI Metrics]\n    end\n    \n    subgraph \"Infrastructure Layer\"\n        JSONL[JSONL Repository\u003cbr/\u003eRead Claude Code data files]\n        CAPI[Cursor API Repository\u003cbr/\u003eFetch usage data]\n        CDB[Cursor DB Repository\u003cbr/\u003eSQLite storage]\n        BR[Bedrock Repository\u003cbr/\u003eCloudWatch API]\n        VAR[Vertex AI Repository\u003cbr/\u003eMonitoring API]\n    end\n    \n    subgraph \"Use Case Layer\"\n        CCS[Claude Code Service\u003cbr/\u003eProcess token usage]\n        CS[Cursor Service\u003cbr/\u003eProcess API data \u0026 track tokens]\n        BS[Bedrock Service\u003cbr/\u003eProcess AWS metrics]\n        VAS[Vertex AI Service\u003cbr/\u003eProcess GCP metrics]\n        MS[Metrics Service\u003cbr/\u003eCollect \u0026 aggregate metrics]\n    end\n    \n    subgraph \"External Systems\"\n        PROM[Prometheus\u003cbr/\u003eRemote Write API]\n    end\n    \n    CC --\u003e JSONL\n    CA --\u003e CAPI\n    AWSCW --\u003e BR\n    GCPM --\u003e VAR\n    JSONL --\u003e CCS\n    CAPI --\u003e CDB\n    CDB --\u003e CS\n    BR --\u003e BS\n    VAR --\u003e VAS\n    CCS --\u003e MS\n    CS --\u003e MS\n    BS --\u003e MS\n    VAS --\u003e MS\n    MS --\u003e PROM\n```\n\n### Grafana Dashboard\n\nMonitor your token usage with our pre-configured Grafana dashboard:\n\n![Grafana Dashboard](./assets/grafana.png)\n\nImport the [Grafana dashboard configuration](./assets/grafana.json) to visualize:\n- Token usage per person per hour\n- Team-wide token usage trends\n- Daily token totals\n- Tool breakdown (Claude Code, Cursor, Bedrock, Vertex AI)\n- Multi-cloud AI service cost tracking\n\n### Monitoring Infrastructure\n\n**Grafana Cloud** is ideally suited as the monitoring and data infrastructure for tosage. Grafana Cloud provides Prometheus, Grafana, Loki, and many other monitoring and visualization products for free, including all the features necessary for metrics collection and visualization with this tool.\n\nOur company uses Grafana Cloud's free plan for metrics collection and visualization, which provides sufficient functionality for personal use through small to medium enterprise operations.\n\n**Note**: Not PR - This is informational content based on actual operational experience, not a product endorsement.\n\n#### Key Benefits of Grafana Cloud\n\n- **Completely Free Plan**: 14 days of metrics retention, 10,000 series, and 50GB logs available at no cost\n- **Integrated Solution**: Prometheus, Grafana, Loki, and Tempo provided on a single platform\n- **Maintenance-Free**: No infrastructure management required, ready to use immediately\n- **Scalable**: Flexible plan upgrades as usage grows\n- **High Availability**: Stable service with SLA guarantees\n\n## Installation\n\n### Quick Installation (Recommended)\n\nThe easiest way to install tosage is using our automated installation script:\n\n```bash\n# Download and run the installer\ncurl -fsSL https://raw.githubusercontent.com/ca-srg/tosage/main/scripts/install.sh | bash\n```\n\nOr download the script first to review it:\n\n```bash\n# Download the script\ncurl -fsSL https://raw.githubusercontent.com/ca-srg/tosage/main/scripts/install.sh -o install-tosage.sh\n\n# Review the script\nless install-tosage.sh\n\n# Run the installer\nbash install-tosage.sh\n```\n\nThe installation script will:\n1. Download the latest tosage DMG for your architecture (arm64/x86_64)\n2. Install the application to `/Applications/tosage.app`\n3. Guide you through configuration setup interactively\n4. Create the configuration file at `~/.config/tosage/config.json`\n\n#### Prerequisites\n\n- macOS (the installer is macOS-only)\n- `curl` and `jq` (usually pre-installed)\n- Internet connection to download from GitHub\n- Administrator password (for installing to /Applications)\n\n#### Configuration Values Needed\n\nDuring installation, you'll be prompted for:\n- **Prometheus Remote Write URL** (required): Your Prometheus endpoint (e.g., `https://prometheus.example.com/api/prom/push`)\n- **Prometheus Username** (required): Authentication username\n- **Prometheus Password** (required): Authentication password\n- **Host Label** (optional): Custom label for metrics\n- **Metrics Interval** (optional): How often to send metrics in seconds (default: 600)\n- **Promtail Configuration** (optional): For log forwarding\n\n### Pre-built Binaries\n\nDownload the latest release from [GitHub Releases](https://github.com/ca-srg/tosage/releases).\n\n### From Source\n\n```bash\ngit clone https://github.com/ca-srg/tosage.git\ncd tosage\nmake build\n```\n\n## Configuration\n\n```bash\n# 1. Run application to generate config.json\n\n# 2. Modify config.json\n$ cat ~/.config/tosage/config.json\n{\n  \"prometheus\": {\n    \"remote_write_url\": \"https://\u003cprometheus_url\u003e/api/prom/push\",\n    \"username\": \"\",\n    \"password\": \"\"\n  },\n  \"logging\": {\n    \"promtail\": {\n      \"url\": \"https://\u003clogs_url\u003e\",\n      \"username\": \"\",\n      \"password\": \"\"\n    }\n  },\n  \"bedrock\": {\n    \"enabled\": false,\n    \"regions\": [\"us-east-1\", \"us-west-2\"],\n    \"aws_profile\": \"\",\n    \"assume_role_arn\": \"\",\n    \"collection_interval_sec\": 900\n  },\n  \"vertex_ai\": {\n    \"enabled\": false,\n    \"project_id\": \"\",\n    \"locations\": [\"us-central1\", \"us-east1\", \"asia-northeast1\"],\n    \"service_account_key_path\": \"\",\n    \"collection_interval_sec\": 900\n  }\n}\n\n# 3. Run again\n```\n\n### AWS Bedrock Configuration\n\nTo enable Bedrock metrics:\n1. Set `bedrock.enabled` to `true`\n2. Configure AWS credentials using one of:\n   - `aws_profile`: AWS profile name from ~/.aws/credentials\n   - `assume_role_arn`: IAM role ARN to assume\n   - Default AWS credential chain (environment variables, IAM role, etc.)\n3. Specify regions to monitor in `bedrock.regions`\n\n### Google Vertex AI Configuration\n\nTo enable Vertex AI metrics:\n1. Set `vertex_ai.enabled` to `true`\n2. Set `vertex_ai.project_id` to your GCP project ID\n3. Configure GCP credentials using one of these methods (in priority order):\n   - **Service Account Key JSON** (highest priority):\n     - Config: `service_account_key`: JSON content as string\n     - Environment: `TOSAGE_VERTEX_AI_SERVICE_ACCOUNT_KEY` (base64 encoded JSON)\n   - **Service Account Key File**:\n     - Config: `service_account_key_path`: Path to JSON key file\n     - Environment: `TOSAGE_VERTEX_AI_SERVICE_ACCOUNT_KEY_PATH`\n   - **Application Default Credentials** (lowest priority):\n     - Environment: `GOOGLE_APPLICATION_CREDENTIALS`\n     - gcloud auth application-default login\n     - GCP metadata service (when running on GCP)\n4. Specify locations to monitor in `vertex_ai.locations`\n\n#### Authentication Priority System\n\nThe Vertex AI integration uses a three-tier authentication priority system:\n\n1. **Direct Service Account Key** - If `service_account_key` is provided in config or via `TOSAGE_VERTEX_AI_SERVICE_ACCOUNT_KEY` environment variable (must be base64 encoded when using environment variable)\n2. **Service Account Key File** - If `service_account_key_path` is provided\n3. **Application Default Credentials** - Uses Google's default credential discovery\n\nThis allows flexible deployment scenarios:\n- For local development: Use `gcloud auth application-default login`\n- For CI/CD: Set service account key as environment variable\n- For production: Use service account key file or GCP metadata service\n\n## Usage\n\n### CLI Mode\n\nOutputs today's token count:\n\n```bash\n# Claude Code and Cursor tokens (default)\ntosage\n\n# AWS Bedrock metrics only\ntosage --bedrock\n\n# Google Vertex AI metrics only\ntosage --vertex-ai\n```\n\n**Note**: When using `--bedrock` or `--vertex-ai` flags, Claude Code and Cursor metrics are skipped.\n\n### CSV Export Mode\n\nExport metrics data to CSV file for analysis:\n\n```bash\n# Export all metrics for the last 30 days\ntosage --export-csv\n\n# Export to specific file\ntosage --export-csv --output metrics_report.csv\n\n# Export specific date range\ntosage --export-csv --start-time \"2025-01-01T00:00:00Z\" --end-time \"2025-01-31T23:59:59Z\"\n\n# Export only specific metric types\ntosage --export-csv --metrics-types \"claude_code,cursor\"\n\n# Combine options\ntosage --export-csv \\\n  --output quarterly_report.csv \\\n  --start-time \"2025-01-01T00:00:00Z\" \\\n  --end-time \"2025-03-31T23:59:59Z\" \\\n  --metrics-types \"claude_code,cursor,bedrock,vertex_ai\"\n```\n\n#### CSV Export Options\n\n- `--export-csv`: Enable CSV export mode\n- `--output`: Output file path (default: `metrics_YYYYMMDD_HHMMSS.csv`)\n- `--start-time`: Start time in ISO 8601 format (default: 30 days ago)\n- `--end-time`: End time in ISO 8601 format (default: now)\n- `--metrics-types`: Comma-separated list of metric types to export\n  - Available types: `claude_code`, `cursor`, `bedrock`, `vertex_ai`\n  - Default: all available types\n\n#### CSV Format\n\nThe exported CSV includes the following columns:\n- `timestamp`: ISO 8601 formatted timestamp\n- `source`: Metric source (claude_code, cursor, bedrock, vertex_ai)\n- `project`: Project or workspace identifier\n- `value`: Numeric value (tokens, requests)\n- `unit`: Unit of measurement (tokens, requests)\n- Additional metadata columns specific to each source\n\nExample CSV output:\n```csv\ntimestamp,source,project,value,unit,input_tokens,output_tokens,cost,currency\n2025-01-15T00:00:00Z,claude_code,all_projects,150000.00,tokens,120000,30000,1.2500,USD\n2025-01-15T00:00:00Z,cursor,all_workspaces,25.00,requests,,,2.5000,USD\n2025-01-15T00:00:00Z,bedrock,all_models,50000.00,tokens,40000,10000,0.7500,USD\n```\n\n#### Security Features\n\nThe CSV export includes several security measures:\n- Path traversal prevention\n- System directory write protection\n- CSV injection prevention\n- Secure file permissions (600)\n- UTF-8 BOM for proper encoding\n\n### Daemon Mode\n\nRuns as a system tray application with periodic metrics sending (Claude Code/Cursor only):\n\n```bash\ntosage -d\n```\n\n**Note**: Daemon mode is not supported when using `--bedrock` or `--vertex-ai` flags.\n\n## Container Usage\n\ntosage is available as a multi-architecture container image on GitHub Container Registry (ghcr.io). The container supports both `linux/amd64` and `linux/arm64` architectures.\n\n### Pull the Image\n\n```bash\n# Latest version\ndocker pull ghcr.io/ca-srg/tosage:latest\n\n# Specific version\ndocker pull ghcr.io/ca-srg/tosage:v1.0.0\n\n# For a specific architecture\ndocker pull --platform linux/arm64 ghcr.io/ca-srg/tosage:latest\n```\n\n### Running the Container\n\nThe container runs in CLI mode by default:\n\n```bash\n# Run with default configuration\ndocker run --rm ghcr.io/ca-srg/tosage:latest\n\n# Run with custom configuration file\ndocker run --rm \\\n  -v ~/.config/tosage/config.json:/home/nonroot/.config/tosage/config.json:ro \\\n  ghcr.io/ca-srg/tosage:latest\n\n# Run with environment variables\ndocker run --rm \\\n  -e TOSAGE_PROMETHEUS_URL=\"https://prometheus.example.com/api/prom/push\" \\\n  -e TOSAGE_PROMETHEUS_USERNAME=\"user\" \\\n  -e TOSAGE_PROMETHEUS_PASSWORD=\"pass\" \\\n  ghcr.io/ca-srg/tosage:latest\n\n# Check Bedrock metrics\ndocker run --rm \\\n  -e AWS_REGION=\"us-east-1\" \\\n  ghcr.io/ca-srg/tosage:latest --bedrock\n\n# Check Vertex AI metrics with Application Default Credentials\ndocker run --rm \\\n  -e GOOGLE_CLOUD_PROJECT=\"my-project\" \\\n  -v ~/.config/gcloud:/home/nonroot/.config/gcloud:ro \\\n  ghcr.io/ca-srg/tosage:latest --vertex-ai\n\n# Check Vertex AI metrics with service account key file\ndocker run --rm \\\n  -e TOSAGE_VERTEX_AI_ENABLED=\"true\" \\\n  -e TOSAGE_VERTEX_AI_PROJECT_ID=\"my-project\" \\\n  -v /path/to/service-account-key.json:/key.json:ro \\\n  -e TOSAGE_VERTEX_AI_SERVICE_ACCOUNT_KEY_PATH=\"/key.json\" \\\n  ghcr.io/ca-srg/tosage:latest --vertex-ai\n\n# Check Vertex AI metrics with service account key as environment variable (base64 encoded)\n# First encode your service account key: base64 -i service-account-key.json\ndocker run --rm \\\n  -e TOSAGE_VERTEX_AI_ENABLED=\"true\" \\\n  -e TOSAGE_VERTEX_AI_PROJECT_ID=\"my-project\" \\\n  -e TOSAGE_VERTEX_AI_SERVICE_ACCOUNT_KEY='base64_encoded_json_here' \\\n  ghcr.io/ca-srg/tosage:latest --vertex-ai\n```\n\n### Docker Compose Example\n\n```yaml\nversion: '3.8'\n\nservices:\n  tosage:\n    image: ghcr.io/ca-srg/tosage:latest\n    restart: unless-stopped\n    volumes:\n      - ~/.config/tosage/config.json:/home/nonroot/.config/tosage/config.json:ro\n    environment:\n      - TOSAGE_PROMETHEUS_URL=${PROMETHEUS_URL}\n      - TOSAGE_PROMETHEUS_USERNAME=${PROMETHEUS_USERNAME}\n      - TOSAGE_PROMETHEUS_PASSWORD=${PROMETHEUS_PASSWORD}\n    command: [\"--mode\", \"cli\"]\n```\n\n### Kubernetes Example\n\n```yaml\napiVersion: batch/v1\nkind: CronJob\nmetadata:\n  name: tosage-metrics\nspec:\n  schedule: \"0 */6 * * *\"  # Every 6 hours\n  jobTemplate:\n    spec:\n      template:\n        spec:\n          containers:\n          - name: tosage\n            image: ghcr.io/ca-srg/tosage:latest\n            env:\n            - name: TOSAGE_PROMETHEUS_URL\n              valueFrom:\n                secretKeyRef:\n                  name: tosage-config\n                  key: prometheus-url\n            - name: TOSAGE_PROMETHEUS_USERNAME\n              valueFrom:\n                secretKeyRef:\n                  name: tosage-config\n                  key: prometheus-username\n            - name: TOSAGE_PROMETHEUS_PASSWORD\n              valueFrom:\n                secretKeyRef:\n                  name: tosage-config\n                  key: prometheus-password\n          restartPolicy: OnFailure\n```\n\n### Container Image Details\n\n- **Base Image**: `gcr.io/distroless/static:nonroot` - Minimal distroless image for security\n- **User**: Runs as non-root user (65532:65532)\n- **Architectures**: `linux/amd64`, `linux/arm64`\n- **Entry Point**: `/tosage`\n- **Default Command**: `[\"--mode\", \"cli\"]`\n\n### Available Tags\n\n- `latest` - Latest stable release\n- `vX.Y.Z` - Specific version (e.g., `v1.0.0`)\n- `vX.Y` - Minor version (e.g., `v1.0`)\n- `vX` - Major version (e.g., `v1`)\n- `main-\u003cshort-sha\u003e` - Development builds from main branch\n\n## Building\n\n### Requirements\n\n#### Build Requirements\n\n- Go 1.21 or higher\n- macOS (for daemon mode)\n- Make\n\n#### Runtime Requirements\n\n- Prometheus Remote Write API endpoint for metrics collection\n- Grafana Loki (optional) for log aggregation via Promtail\n\n### Build Commands\n\n```bash\n# Build for current platform\nmake build\n\n# Build macOS ARM64 binary\nmake build-darwin\n\n# Build app bundle for macOS\nmake app-bundle-arm64\n\n# Build DMG installer\nmake dmg-arm64\n\n# Run all checks (fmt, vet, lint, test)\nmake check\n```\n\n### macOS App Bundle and DMG Creation\n\n#### App Bundle Targets\n\n##### `app-bundle-arm64`\n**Purpose**: Creates a macOS app bundle (.app)\n\n1. **Binary Build**: Executes `build-darwin` to create Go binary\n2. **Dependency Check**: Runs `dmg-check` to verify required tools\n3. **App Bundle Creation**: Executes `create-app-bundle.sh` to create:\n   - `tosage.app/Contents/MacOS/tosage` - Executable file\n   - `tosage.app/Contents/Info.plist` - App metadata\n   - `tosage.app/Contents/Resources/app.icns` - App icon\n   - `tosage.app/Contents/PkgInfo` - App type information\n\n#### DMG Targets\n\n##### `dmg-arm64`\n**Purpose**: Creates unsigned DMG installers\n\n1. Creates app bundle (executes `app-bundle-*`)\n2. Runs `create-dmg.sh` to create DMG:\n   - Includes app bundle in DMG\n   - Adds symlink to `/Applications`\n   - Sets background image and window layout\n   - Output: `tosage-{version}-darwin-{arch}.dmg`\n\n##### `dmg-signed-arm64`\n**Purpose**: Creates signed DMGs\n\n- Requires `CODESIGN_IDENTITY` environment variable\n- Adds code signature to app bundle and DMG\n\n##### `dmg-notarized-arm64`\n**Purpose**: Creates signed and notarized DMGs\n\n- Adds Apple notarization in addition to signing\n- Allows installation without Gatekeeper warnings\n\n### Build Process Flow\n\n```\nGo Source Code\n    ↓ (go build)\nExecutable Binary\n    ↓ (create-app-bundle.sh)\n.app Bundle\n    ↓ (create-dmg.sh)\n.dmg Installer\n    ↓ (codesign + notarization)\nDistributable DMG\n```\n\n### Usage Examples\n\n#### Create unsigned DMG:\n```bash\nmake dmg-arm64\n```\n\n#### Create signed DMG:\n```bash\nexport CODESIGN_IDENTITY=\"Developer ID Application: Your Name (TEAMID)\"\nmake dmg-signed-arm64\n```\n\n#### Create signed and notarized DMG:\n```bash\nexport CODESIGN_IDENTITY=\"Developer ID Application: Your Name (TEAMID)\"\nexport API_KEY_ID=\"your-key-id\"\nexport API_KEY_PATH=\"/path/to/AuthKey_XXXXX.p8\"\nexport API_ISSUER=\"your-issuer-id\"\nmake dmg-notarized-arm64\n```\n\n#### Create for all architectures:\n```bash\nmake dmg-notarized-all\n```\n\n## Architecture\n\nThe project follows Clean Architecture with clear separation of concerns:\n\n### Domain Layer\n- **Entities**: Core business entities (Claude Code entries, Cursor usage data)\n- **Repository Interfaces**: Abstractions for data access\n- **Domain Errors**: Business logic specific errors\n\n### Infrastructure Layer\n- **Configuration**: Application settings management\n- **Dependency Injection**: IoC container for clean dependency management\n- **Logging**: Multiple logger implementations (debug, promtail)\n- **Repository Implementations**: \n  - Cursor API client for usage data\n  - SQLite database for Cursor token history\n  - JSONL reader for Claude Code data\n  - Prometheus remote write client\n\n### Use Case Layer\n- **Services**: Business logic implementation\n  - Claude Code data processing\n  - Cursor API integration and token tracking\n  - AWS Bedrock CloudWatch metrics processing\n  - Google Vertex AI monitoring metrics processing\n  - Metrics collection and sending\n  - Application status tracking\n\n### Interface Layer\n- **Controllers**: Application entry points\n  - CLI controller for command-line interface\n  - Daemon controller for background service\n  - System tray controller for UI\n\n## Data Sources\n\n### Claude Code\nSearches for data in:\n- `~/.config/claude/projects/` (new default)\n- `~/.claude/projects/` (legacy)\n- `~/Library/Application Support/claude/projects/` (macOS)\n\n### Cursor\nUses Cursor API to fetch:\n- Premium (GPT-4) request usage\n- Usage-based pricing information\n- Team membership status\n\n### AWS Bedrock\nUses CloudWatch API to fetch:\n- Input/output token counts per model\n- Daily aggregated usage\n- Multi-region support\n\n### Google Vertex AI\nUses Cloud Monitoring API to fetch:\n- Token usage by model and location\n- Daily aggregated metrics\n- Multi-location support\n\n\n## Notes\n\n- macOS only (uses CGO for system tray)\n- Time calculations use JST (Asia/Tokyo) timezone\n- Configuration file: `~/.config/tosage/config.json`\n\n## Troubleshooting\n\n### Installation Issues\n\n#### \"GitHub API rate limit exceeded\"\n- Wait for the rate limit to reset (usually 1 hour)\n- Or download the DMG manually from [GitHub Releases](https://github.com/ca-srg/tosage/releases)\n\n#### \"Failed to mount DMG\"\n- Ensure you have sufficient disk space\n- Check if another DMG is already mounted\n- Try manually mounting the DMG from Finder\n\n#### \"Permission denied\" during installation\n- The installer requires administrator privileges to copy to /Applications\n- Enter your password when prompted by `sudo`\n\n#### \"No DMG found for architecture\"\n- Check that your macOS version is supported\n- For Apple Silicon Macs, ensure you're using arm64 builds\n- For Intel Macs, x86_64 builds may not be available yet\n\n### Configuration Issues\n\n#### \"Invalid URL format\"\n- Ensure your Prometheus URL includes the protocol (http:// or https://)\n- Example: `https://prometheus.example.com/api/prom/push`\n\n#### \"Configuration file permission denied\"\n- The config file is created with secure permissions (600)\n- Use `sudo` if you need to manually edit it\n\n### Runtime Issues\n\n#### \"tosage.app is damaged and can't be opened\"\n- This is a macOS Gatekeeper issue\n- The installer automatically removes quarantine attributes\n- If the issue persists, run: `sudo xattr -cr /Applications/tosage.app`\n\n#### \"Cannot find Claude Code data\"\n- Ensure Claude Code has been run at least once\n- Check that data exists in one of the search directories\n- See \"Data Sources\" section for locations\n\n## TODO\n\n- [x] Add Vertex AI token usage tracking\n- [x] Add Amazon Bedrock token usage tracking\n\n## GitHub Actions Setup\n\nFor maintainers who want to build signed releases, see [GitHub Secrets Setup Guide](GITHUB_SECRETS_SETUP.md) for required configuration.\n\n## License\n\nMIT License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fca-srg%2Ftosage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fca-srg%2Ftosage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fca-srg%2Ftosage/lists"}