angristan / angristan/opencode-wakatime

feat: Add OpenCode v2 plugin API support

オープン
#85 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
200
フォーク
11
PR マージ指標
30日以内にマージされた PR はありません

説明

## 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"]
}
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。