@intisy-ai/wakatime-sync
v1.9.0
Published
WakaTime plugin for OpenCode and Claude Code, automatically tracking time spent coding.
Maintainers
Readme
@intisy-ai/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, run on every import or launch]
DETECT{isClaude via argv?}
GUARD{shouldRunClaudeHook: host.js checks importedByHost}
end
subgraph OpenCode [OpenCode: in-process plugin]
OC_HOOKS[event / chat.message hooks]
OC_TRACK[extractFileChanges plus<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 ApiHost [Api host: imports the bundle in-process]
HOST_DEFAULT[reads plugin.ts's default export, skipping the hook]
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| GUARD
GUARD -->|not host-imported| Claude
GUARD -->|host-imported| ApiHost
CLI -->|HTTPS| WAKATIME[(WakaTime API)]Structure
src/- TypeScript source (OpenCode plugin, the
claude/hook handler,commands.ts,plugin.tsfor the api plugin, andhost.tsfor the host-import guard) plugin.json: the manifest an in-process host reads before importing this bundlecore/(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, the
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 @intisy-ai/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/@intisy-ai/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.
