angristan / angristan/opencode-wakatime

feat: Add OpenCode v2 plugin API support

Open
#85 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
200
Forks
11
PR merge metrics
No merged PRs in 30d

Description

## Summary

OpenCode v2 introduced a completely new (breaking) plugin API. The current `opencode-wakatime` plugin only works with the v1 plugin system and does not load on OpenCode 2 / `opencode2`.

Please add v2 compatibility so WakaTime tracking continues to work for users migrating to OpenCode 2.

## Current state

- Uses the **v1** plugin shape:
```ts
import type { Hooks, Plugin } from "@opencode-ai/plugin";
export const plugin: Plugin = async (ctx) => { ... }
```
- Relies on v1 hooks such as `event` and `chat.message`
- Config examples still use the old `"plugin"` key (singular)
- `peerDependencies` targets `@opencode-ai/plugin >= 1.0.0`

## What changed in OpenCode v2

- **V1 plugins do not work in V2** (hard break)
- New entrypoint:
```ts
import { Plugin } from "@opencode-ai/plugin"

export default Plugin.define({
id: "opencode.wakatime",
setup: async (ctx) => {
// ...
},
})
```
- Config key changed: `"plugin"` → `"plugins"`
- Different context, transform hooks, and runtime hooks
- Plugin API is still marked as **beta**

Relevant links:
- Migration guide: https://v2.opencode.ai/migrate-v1
- V2 Plugins docs: https://opencode.ai/v2/docs/build/plugins

## Requested changes

1. Add a v2-compatible entrypoint using `Plugin.define({ id, setup })`
2. Map existing functionality (tool tracking, heartbeats, session idle/end flush, AI line changes, etc.) to the new v2 hooks / event system
3. Update `peerDependencies` / packaging for the current `@opencode-ai/plugin` used by OpenCode 2
4. Update README with v2 install instructions, e.g.:

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.