angristan / angristan/opencode-wakatime

feat: Add OpenCode v2 plugin API support

Đang mở
#85 1 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
200
Fork
11
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.