pi-wakatime

内容来源:README.md(说明文档) · 原始地址 · 查看安装指南

原始内容

WakaTime for Pi

Track your Pi usage, lines of code generated, time spent prompting the agent, and file activity with WakaTime.

WakaTime is an open source plugin ecosystem for metrics, insights, and automatic time tracking generated from your programming activity.

This project is intentionally modeled after wakatime/claude-code-wakatime, adapted for Pi's extension event model.

Installation

pi install npm:pi-wakatime

Then add your WakaTime API key to ~/.wakatime.cfg:

[settings]
api_key = your_wakatime_api_key

How It Works

Because Pi uses extension lifecycle events instead of Claude hook scripts, this plugin maps Pi events onto the same heartbeat concepts where possible:

  • turn_start → prompt / AI activity heartbeat
  • tool_call → pre-tool activity heartbeat
  • tool_result → post-tool activity heartbeat
  • session_before_compact → pre-compact activity heartbeat
  • session_shutdown → session end heartbeat
  • read / write / edit tool results → file heartbeats

The plugin also:

  • finds a global wakatime-cli when available
  • installs a local wakatime-cli into ~/.wakatime/ when needed
  • checks for updates to the local CLI periodically
  • respects WakaTime proxy and no_ssl_verify settings
  • stores throttle state in ~/.wakatime/pi-wakatime-state.json
  • writes extension logs to ~/.wakatime/pi-wakatime.log

Usage

Open Pi as usual and work normally. Once your API key is configured, heartbeats are sent in the background.

You should see activity on your WakaTime dashboard for:

  • your current project folder
  • .pi-session synthetic session activity
  • individual files read or modified by Pi
  • AI-assisted line changes for write and edit

Development

Run the test suite:

npm test

Troubleshooting

Check that Pi can load the extension:

pi -e ./src/index.ts

Enable debug logging in ~/.wakatime.cfg:

[settings]
debug = true

Then inspect logs:

tail -f ~/.wakatime/pi-wakatime.log

If no activity appears in WakaTime:

  1. verify ~/.wakatime.cfg contains a valid api_key
  2. inspect ~/.wakatime/pi-wakatime.log
  3. check whether ~/.wakatime/wakatime-cli exists
  4. confirm Pi is actually loading the extension

If wakatime-cli download fails:

  • verify network access to GitHub releases
  • verify proxy settings in ~/.wakatime.cfg
  • install wakatime-cli globally as a fallback

Credits