{"id":34979179,"url":"https://github.com/angristan/opencode-wakatime","last_synced_at":"2026-02-24T00:09:01.539Z","repository":{"id":328615614,"uuid":"1110243009","full_name":"angristan/opencode-wakatime","owner":"angristan","description":"Track Opencode usage with Wakatime","archived":false,"fork":false,"pushed_at":"2026-01-30T17:49:50.000Z","size":179,"stargazers_count":58,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-31T11:33:51.785Z","etag":null,"topics":["coding-agent","opencode","opencode-plugin","wakatime"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/opencode-wakatime","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/angristan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2025-12-04T23:05:47.000Z","updated_at":"2026-01-31T10:28:21.000Z","dependencies_parsed_at":"2026-01-24T01:08:51.824Z","dependency_job_id":null,"html_url":"https://github.com/angristan/opencode-wakatime","commit_stats":null,"previous_names":["angristan/opencode-wakatime"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/angristan/opencode-wakatime","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angristan%2Fopencode-wakatime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angristan%2Fopencode-wakatime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angristan%2Fopencode-wakatime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angristan%2Fopencode-wakatime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/angristan","download_url":"https://codeload.github.com/angristan/opencode-wakatime/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angristan%2Fopencode-wakatime/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29135916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T21:59:57.939Z","status":"ssl_error","status_checked_at":"2026-02-05T21:59:57.628Z","response_time":65,"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":["coding-agent","opencode","opencode-plugin","wakatime"],"created_at":"2025-12-27T00:51:39.628Z","updated_at":"2026-02-24T00:09:01.531Z","avatar_url":"https://github.com/angristan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# opencode-wakatime\n\n[![npm version](https://img.shields.io/npm/v/opencode-wakatime)](https://www.npmjs.com/package/opencode-wakatime)\n[![npm downloads](https://img.shields.io/npm/dm/opencode-wakatime)](https://www.npmjs.com/package/opencode-wakatime)\n[![CI](https://github.com/angristan/opencode-wakatime/actions/workflows/workflow.yml/badge.svg)](https://github.com/angristan/opencode-wakatime/actions/workflows/workflow.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n\nWakaTime plugin for [OpenCode](https://github.com/sst/opencode) - Track your AI coding activity, lines of code, and time spent.\n\nInspired by [claude-code-wakatime](https://github.com/wakatime/claude-code-wakatime).\n\n\u003e [!TIP]\n\u003e Also check out [codex-wakatime](https://github.com/angristan/codex-wakatime) for OpenAI Codex CLI!\n\n## Features\n\n- **Automatic CLI management** - Downloads and updates wakatime-cli automatically\n- **Detailed file tracking** - Tracks file reads and modifications (edit, write, patch, multiedit)\n- **AI coding metrics** - Sends `--ai-line-changes` for WakaTime AI coding analytics\n- **Rate-limited heartbeats** - 1 per minute per project to avoid API spam\n- **Session lifecycle** - Sends final heartbeat on session idle/end\n- **Batch tool support** - Tracks file operations executed via batch tool\n\n## Prerequisites\n\n### WakaTime API Key\n\nEnsure you have a WakaTime API key configured in `~/.wakatime.cfg`:\n\n```ini\n[settings]\napi_key = waka_your_api_key_here\n```\n\nYou can get your API key from [WakaTime Settings](https://wakatime.com/api-key).\n\n### WakaTime CLI (Optional)\n\nIn case of manual install, the plugin will automatically download wakatime-cli if not found. However, you can also install it yourself:\n\n**macOS:**\n\n```bash\nbrew install wakatime-cli\n```\n\n**Other platforms:**\nDownload from [WakaTime releases](https://github.com/wakatime/wakatime-cli/releases/latest).\n\n## Installation\n\n### Via opencode config (recommended)\n\nopencode.json:\n\n```json\n{\n  \"$schema\": \"https://opencode.ai/config.json\",\n  \"plugin\": [\"opencode-wakatime\"]\n}\n```\n\n### Manually via npm\n\n```bash\nnpm i -g opencode-wakatime\nopencode-wakatime --install\n```\n\nThis installs the plugin to `~/.config/opencode/plugin/wakatime.js`.\n\nTo update, run the same commands again.\n\n### From source\n\n```bash\ngit clone https://github.com/angristan/opencode-wakatime\ncd opencode-wakatime\nnpm install \u0026\u0026 npm run build\nnode bin/cli.js --install\n```\n\nThe plugin will be automatically loaded by OpenCode - no configuration needed.\n\n## How It Works\n\nThe plugin hooks into OpenCode's event system:\n\n```mermaid\nflowchart TB\n    subgraph OpenCode[\"OpenCode\"]\n        A[Tool Execution\u003cbr/\u003eread, edit, write, patch, multiedit, batch] --\u003e H1[message.part.updated]\n        B[Chat Activity] --\u003e H2[chat.message]\n        C[Session Events\u003cbr/\u003eidle, end] --\u003e H3[event]\n    end\n\n    subgraph Plugin[\"opencode-wakatime Plugin\"]\n        H1 --\u003e P1[Extract File Changes\u003cbr/\u003epath, additions, deletions]\n        P1 --\u003e Q[Heartbeat Queue]\n\n        H2 -.-\u003e|triggers| P2[Process Queue]\n        Q --\u003e P2\n        P2 --\u003e R[Rate Limiter\u003cbr/\u003e1 per minute per project]\n\n        H3 --\u003e P3[Flush Final\u003cbr/\u003eHeartbeat]\n        P3 --\u003e R\n    end\n\n    subgraph WakaTime[\"WakaTime\"]\n        R --\u003e CLI[wakatime-cli]\n        CLI --\u003e API[WakaTime API]\n        API --\u003e D[Dashboard\u003cbr/\u003eAI Coding Metrics]\n    end\n\n```\n\n### Hooks Used\n\n| Hook           | Purpose                                                          |\n| -------------- | ---------------------------------------------------------------- |\n| `event`        | Tracks tool completions via `message.part.updated` and session lifecycle |\n| `chat.message` | Triggers heartbeat processing on activity                        |\n\n### Tool Tracking\n\n| Tool        | Data Extracted                                    |\n| ----------- | ------------------------------------------------- |\n| `read`      | File path (from title)                            |\n| `edit`      | File path, additions, deletions (from `filediff`) |\n| `write`     | File path, new file detection                     |\n| `patch`     | File paths from output, diff count                |\n| `multiedit` | File paths and changes from each edit result      |\n| `batch`     | Tracks all child tool operations                  |\n\n### Heartbeat Data\n\nEach heartbeat includes:\n\n- **Entity**: File path being worked on\n- **Project folder**: Working directory\n- **AI line changes**: Net lines added/removed (`additions - deletions`)\n- **Category**: \"ai coding\"\n- **Plugin identifier**: `opencode-\u003cclient\u003e/\u003cversion\u003e opencode-wakatime/\u003cversion\u003e` (e.g. `opencode-desktop/1.1.53 opencode-wakatime/1.1.4`)\n\n## Files\n\n| File                                  | Purpose                                    |\n| ------------------------------------- | ------------------------------------------ |\n| `~/.wakatime/opencode.log`                  | Debug logs (enabled via `debug=true` in `~/.wakatime.cfg`) |\n| `~/.wakatime/opencode-{hash}.json`          | Per-project state (last heartbeat timestamp) |\n| `~/.wakatime/opencode-cli-state.json`       | CLI version tracking                       |\n| `~/.wakatime/opencode-version-cache.json`   | Cached OpenCode server version             |\n| `~/.wakatime/wakatime-cli-*`                | Auto-downloaded CLI binary                 |\n\n## Development\n\n```bash\n# Install dependencies\nnpm install\n\n# Type check\nnpm run typecheck\n\n# Build\nnpm run build\n```\n\n## Troubleshooting\n\n### Plugin not loading\n\n1. Check your config file syntax (`opencode.jsonc`)\n2. Verify the plugin path is correct\n3. Check logs at `~/.wakatime/opencode.log`\n\n### Heartbeats not sending\n\n1. Verify API key in `~/.wakatime.cfg`\n2. Check if wakatime-cli is working: `wakatime-cli --version`\n3. Enable debug logging and check `~/.wakatime/opencode.log`\n\n### CLI not downloading\n\n1. Check network connectivity\n2. Verify write permissions to `~/.wakatime/`\n3. Manually install: `brew install wakatime-cli`\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangristan%2Fopencode-wakatime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangristan%2Fopencode-wakatime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangristan%2Fopencode-wakatime/lists"}