@raindrop-ai/opencode-plugin 0.1.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -54,10 +54,70 @@ then send its `event_id` to [`/v1/signals`](https://docs.raindrop.ai):
54
54
  }
55
55
  ```
56
56
 
57
+ ## OpenCode v2 plugin API
58
+
59
+ OpenCode's newer plugin API (`@opencode/plugin`, `@opencode/sdk` v2) is served
60
+ by the `@raindrop-ai/opencode-plugin/v2` subpath. Use it instead of the default
61
+ export when running against the v2 plugin host:
62
+
63
+ ```jsonc
64
+ // opencode.json
65
+ { "plugin": ["@raindrop-ai/opencode-plugin/v2"] }
66
+ ```
67
+
68
+ ```bash
69
+ npm install @raindrop-ai/opencode-plugin @opencode/plugin
70
+ ```
71
+
72
+ The v2 entry exposes the plugin object plus a `raindrop` handle
73
+ (`users.identify`, `signals.track`, `currentEventId(sessionID)`, `flush`,
74
+ `shutdown`). Configuration, event/tracing semantics, and payload bounds are the
75
+ same as the v1 entry. `@opencode/plugin` and `@opencode/sdk` are optional peer
76
+ dependencies — v1 users install neither.
77
+
78
+ ## Self-diagnostics
79
+
80
+ The plugin can inject a `__raindrop_report` tool that lets the agent flag
81
+ serious, unrecoverable problems for developer review. When the agent calls it,
82
+ a `self diagnostics - <category>` signal is posted to `signals/track`, attached
83
+ to the session's currently-open turn event. The tool is invisible to the end
84
+ user — its output is a bare acknowledgement and the model is instructed never
85
+ to mention it.
86
+
87
+ Enable it via `raindrop.json` (`~/.config/opencode/raindrop.json` or
88
+ `.opencode/raindrop.json`), or set `RAINDROP_SELF_DIAGNOSTICS=true` to override
89
+ just the `enabled` flag:
90
+
91
+ ```json
92
+ {
93
+ "self_diagnostics": { "enabled": true }
94
+ }
95
+ ```
96
+
97
+ For the v2 host API, pass the option directly:
98
+
99
+ ```ts
100
+ import raindrop from "@raindrop-ai/opencode-plugin/v2";
101
+
102
+ export default raindrop({ selfDiagnostics: { enabled: true } });
103
+ ```
104
+
105
+ Optional `signals` (custom category → `{ description, sentiment? }` map),
106
+ `guidance` (extra instructions appended to the tool prompt), and `tool_name` /
107
+ `toolName` overrides are supported. The built-in categories are:
108
+
109
+ - `missing_context` — blocked on information or access the user cannot provide
110
+ - `repeatedly_broken_tool` — a tool failed across multiple distinct attempts
111
+ - `capability_gap` — the task needs a tool/permission/capability the agent lacks
112
+ - `complete_task_failure` — the agent genuinely could not deliver what was asked
113
+
114
+ Signals only ship to the cloud destination, so the tool is not registered in
115
+ local-only mode (no `RAINDROP_WRITE_KEY`).
116
+
57
117
  ## Notes
58
118
 
59
- - `@opencode-ai/plugin` is required.
60
- - `@opencode-ai/sdk` is an optional peer dependency.
119
+ - `@opencode-ai/plugin` is required for the default (v1) export; `@opencode/plugin` for `/v2`.
120
+ - `@opencode-ai/sdk` and `@opencode/sdk` are optional peer dependencies.
61
121
  - Tests live in the nested `tests/` package and validate HTTP payloads and tracing behavior.
62
122
 
63
123
  ## Application Git identity