angristan / angristan/opencode-wakatime

feat: Add OpenCode v2 plugin API support

Abierto
#85 1 comentario 1 reacción 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
200
Forks
11
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.