wakatime-sync
v1.6.1
Published
WakaTime plugin for OpenCode and Claude Code, automatically tracking time spent coding.
Maintainers
Readme
wakatime-sync
WakaTime integration for both OpenCode and Claude Code from a single codebase. It automatically records the time you spend coding with AI — tracking edited files, line changes, and project activity — and reports it to WakaTime via the official wakatime-cli.
Under-the-Hood Architecture
flowchart TD
subgraph Entry [dist/index.js — dual-app entry]
DETECT{argv contains<br/>"claude"?}
end
subgraph OpenCode [OpenCode — in-process plugin]
OC_HOOKS[event / chat.message hooks]
OC_TRACK[extractFileChanges +<br/>in-memory file buffer]
OC_HB["sendHeartbeat (--entity file)"]
OC_HOOKS --> OC_TRACK --> OC_HB
end
subgraph Claude [Claude Code — stdin hook process]
CC_STDIN[parseInput from stdin]
CC_RATE[per-transcript rate limit]
CC_HB["syncAiActivity (--sync-ai-activity)"]
CC_STDIN --> CC_RATE --> CC_HB
end
subgraph Shared [Shared core]
DEPS[dependencies — wakatime-cli install]
CLI[wakatime-cli spawner]
OC_HB --> CLI
CC_HB --> CLI
DEPS --> CLI
end
DETECT -->|no| OpenCode
DETECT -->|yes| Claude
CLI -->|HTTPS| WAKATIME[(WakaTime API)]Structure
src/- TypeScript source (OpenCode plugin +
claude/hook handler +commands.ts) core/— git submodule (intisy-ai/core): shared config, logging, app detection, and the cross-app command framework — bundled intodist/index.jsby esbuild
- TypeScript source (OpenCode plugin +
dist/dist/index.js— single dual-app entry, generated by esbuild; not committed
Installation
Via plugin-updater (recommended)
npx plugin-updater@latest init https://github.com/intisy-ai/wakatime-syncVia npm
npm install wakatime-syncAPI Key Setup
Add your WakaTime API key to ~/.wakatime.cfg:
[settings]
api_key = your-api-key-hereGet your key at https://wakatime.com/settings/api-key.
Configuration
Config file: <configDir>/config/wakatime-sync.json (edit via the loader or /wakatime-sync-config set).
{
"logging": true,
"heartbeat_interval_seconds": 60,
"cli_update_interval_hours": 4,
"api_key": "",
"api_url": "https://api.wakatime.com/api/v1",
"hide_filenames": false,
"proxy": "",
"hostname": "",
"hide_project_names": false
}| Key | Default |
| --- | --- |
| logging | true |
| heartbeat_interval_seconds | 60 |
| cli_update_interval_hours | 4 |
| api_key | "" |
| api_url | "https://api.wakatime.com/api/v1" |
| hide_filenames | false |
| proxy | "" |
| hostname | "" |
| hide_project_names | false |
Commands
| Command | Description | Arguments |
| --- | --- | --- |
| /wakatime-sync-config | View and change wakatime-sync configuration | list | get <key> | set <key> <value> |
| /wakatime | Show today's WakaTime coding activity | |
Dependencies
corewakatime-cli@opencode-ai/plugin
Logging
Logs are written to <configDir>/logs/YYYY-MM-DD/wakatime-sync-HH-MM-SS.log and are toggled by
this plugin's logging config (default on). Console mirroring is global, off by default,
and controlled by the shared config/settings.json logConsole flag.
License
MIT.
