angristan / angristan/opencode-wakatime

feat: Add OpenCode v2 plugin API support

Aperta
#85 1 commento 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
200
Fork
11
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.