百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
O

opencode-wakatime

> AI 编程
开源

使用 Wakatime 追踪 Opencode 使用情况

189 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

使用 Wakatime 追踪 Opencode 使用情况

opencode-wakatime

WakaTime plugin for OpenCode - Track your AI coding activity, lines of code, and time spent.

Inspired by claude-code-wakatime.

[!TIP] Also check out codex-wakatime for OpenAI Codex CLI!

Features

  • Automatic CLI management - Downloads and updates wakatime-cli automatically
  • Detailed file tracking - Tracks file reads and modifications (edit, write, patch, multiedit)
  • AI coding metrics - Sends --ai-line-changes for WakaTime AI coding analytics
  • Rate-limited heartbeats - 1 per minute per project to avoid API spam
  • Session lifecycle - Sends final heartbeat on session idle/end
  • Batch tool support - Tracks file operations executed via batch tool

Prerequisites

WakaTime API Key

Ensure you have a WakaTime API key configured in ~/.wakatime.cfg (or $WAKATIME_HOME/.wakatime.cfg when WAKATIME_HOME is set):

ini
[settings]
api_key = waka_your_api_key_here

You can get your API key from WakaTime Settings.

WakaTime CLI (Optional)

In case of manual install, the plugin will automatically download wakatime-cli if not found. However, you can also install it yourself:

macOS:

bash
brew install wakatime-cli

Other platforms: Download from WakaTime releases.

Installation

Via opencode config (recommended)

opencode.json:

json
{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-wakatime"]
}

Manually via npm

bash
npm i -g opencode-wakatime
opencode-wakatime --install

This installs the plugin to ~/.config/opencode/plugin/wakatime.js.

To update, run the same commands again.

From source

bash
git clone https://github.com/angristan/opencode-wakatime
cd opencode-wakatime
npm install && npm run build
node bin/cli.js --install

The plugin will be automatically loaded by OpenCode - no configuration needed.

How It Works

The plugin hooks into OpenCode's event system:

…

Hooks Used

Hook Purpose
event Tracks tool completions via message.part.updated and session lifecycle
chat.message Triggers heartbeat processing on activity

Tool Tracking

Tool Data Extracted
read File path (from title)
edit File path, additions, deletions (from filediff)
write File path, new file detection
patch File paths from output, diff count
multiedit File paths and changes from each edit result
batch Tracks all child tool operations

Heartbeat Data

Each heartbeat includes:

  • Entity: File path being worked on
  • Project folder: Working directory
  • AI line changes: Net lines added/removed (additions - deletions)
  • Category: "ai coding"
  • Plugin identifier: opencode-/ opencode-wakatime/ (e.g. opencode-desktop/1.1.53 opencode-wakatime/1.1.4)

Files

By default, plugin files are stored in ~/.wakatime/. When WAKATIME_HOME is set, the same files are stored in $WAKATIME_HOME/.

File Purpose
opencode.log Debug logs (enabled via debug=true in ~/.wakatime.cfg)
opencode-{hash}.json Per-project state (last heartbeat timestamp)
opencode-cli-state.json CLI version tracking
opencode-version-cache.json Cached OpenCode server version
wakatime-cli-* Auto-downloaded CLI binary

Development

bash
# Install dependencies
npm install

# Type check
npm run typecheck

# Build
npm run build

Troubleshooting

Plugin not loading

  1. Check your config file syntax (opencode.jsonc)
  2. Verify the plugin path is correct
  3. Check logs at ~/.wakatime/opencode.log

Heartbeats not sending

  1. Verify API key in ~/.wakatime.cfg
  2. Check if wakatime-cli is working: wakatime-cli --version
  3. Enable debug logging and check ~/.wakatime/opencode.log (or $WAKATIME_HOME/opencode.log when set)

CLI not downloading

  1. Check network connectivity
  2. Verify write permissions to ~/.wakatime/ (or $WAKATIME_HOME/ when set)
  3. Manually install: brew install wakatime-cli

License

MIT

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptcoding-agentopencodeopencode-pluginwakatime

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类AI 编程
定价开源

> 相关工具

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.