opencode-raven 2.1.5 → 2.1.6

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.
Files changed (4) hide show
  1. package/CHANGELOG.md +214 -0
  2. package/README.md +212 -317
  3. package/index.ts +604 -374
  4. package/package.json +22 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,214 @@
1
+ # Changelog
2
+
3
+ ## 2.1.6
4
+
5
+ ### Added
6
+ - Bun-based TypeScript verification and reproducible development dependencies.
7
+
8
+ ### Changed
9
+ - On-demand MCP requests now propagate cancellation and SDK-native timeouts, reuse one in-flight connection per session/server, and close idle or deleted-session connections.
10
+ - README structure and wording now focus on installation, usage, configuration, routing, security, and troubleshooting.
11
+ - Removed legacy root-config and embedded MCP-metadata migration support.
12
+
13
+ ### Fixed
14
+ - Quoted `cmd`, PowerShell, and Unix shell search commands can no longer bypass Raven routing.
15
+ - Session event handling now follows the OpenCode SDK event shape.
16
+ - Raven receives configured on-demand MCP guidance while startup health checks are pending.
17
+ - Invalid timeout and stats values are normalized safely.
18
+
19
+ ## 2.1.5
20
+
21
+ ### Changed
22
+ - **On-demand MCP guidance** — autogenerated guidance now preserves existing MCP order and appends newly loaded MCPs at the end.
23
+ - **Guidance descriptions** — full-mode on-demand MCP guidance now keeps generated metadata intact while rendering only first-sentence descriptions to reduce main-model context.
24
+
25
+ ## 2.1.4
26
+
27
+ ### Changed
28
+ - **Subagent prompts** — Raven no longer injects routing guidance into subagent prompts; global instructions and tool enforcement handle routing.
29
+
30
+ ## 2.1.3
31
+
32
+ ### Changed
33
+ - **Default timeout** — Raven's default timeout is now 600s.
34
+ - **Provider errors** — `raven_seek` now reports Raven provider/API retry failures and no-initial-response startup failures quickly instead of waiting for the full timeout.
35
+ - **Raven recovery** — after a Raven provider failure, routed tools stop redirecting to `raven_seek` and tell the user how to switch Raven's model.
36
+
37
+ ## 2.1.2
38
+
39
+ ### Fixed
40
+ - **Local MCP TUI output** — local on-demand MCP stderr is now piped and drained so server logs do not overlay the OpenCode TUI during startup checks or Raven MCP calls.
41
+
42
+ ### Changed
43
+ - **OpenCode-style MCP config** — on-demand MCPs now accept OpenCode-style `local` and `remote` entries, including local `command` arrays, `environment`, per-server `timeout`, and `enabled` flags.
44
+
45
+ ## 2.1.1
46
+
47
+ ### Changed
48
+ - **Context unit formatting** — context estimates now switch from `K` to `M` after one million tokens for easier reading.
49
+ - **Loaded-only MCP guidance** — autogenerated on-demand MCP guidance now includes only successfully loaded MCPs, keeping failed or pending servers out of main-agent instructions.
50
+ - **Startup guidance refresh** — Raven now preserves existing autogenerated on-demand MCP guidance during startup and rewrites it only after MCP health checks update.
51
+
52
+ ## 2.1.0
53
+
54
+ ### Added
55
+ - **On-Demand MCPs** — Raven can now connect to MCP servers from `onDemandMcpServers` internally through Raven-only `raven_mcp`, keeping full MCP schemas out of the main OpenCode session.
56
+ - **Remote and stdio MCP support** — on-demand MCPs support remote HTTP/SSE servers and local stdio servers.
57
+ - **On-demand MCP metadata** — Raven fills missing `autoGeneratedDescription` and `autoGeneratedTools`, with `/raven mcp refresh [server]` and `/raven mcp detail full|minimized` commands.
58
+ - **Avoided MCP schema stats** — `/raven stats` now shows `Avoided MCP schema load` separately from delegated session and all-time savings.
59
+ - **MCP failure notifications** — Raven shows a warning toast after startup or manual refresh when on-demand MCPs fail to load.
60
+ - **Duplicate MCP warnings** — Raven warns when the same MCP server name is configured globally in OpenCode and in `onDemandMcpServers`.
61
+ - **Help command** — `/raven help` now lists all Raven commands.
62
+
63
+ ### Changed
64
+ - **Bundled MCP defaults** — Context7, Exa, and Grep.app now default to on-demand MCP entries instead of global OpenCode MCP injection.
65
+ - **Global MCP routing** — global MCPs configured in OpenCode are now auto-routed by detected server name, so `routeMcpServers` is no longer user-facing config.
66
+ - **Raven prompt/guidance** — guidance now distinguishes globally configured MCPs from on-demand MCPs and teaches Raven to use `raven_mcp` internally.
67
+ - **Global Raven files** — Raven now stores global files under `~/.config/opencode/opencode-raven/`, with generated on-demand MCP metadata split out of `raven-config.json` into `autogenerated-on-demand-mcp-metadata.json`.
68
+ - **Loaded-only schema stats** — failed or pending on-demand MCPs no longer count toward `Avoided MCP schema load`.
69
+ - **On-demand MCP health** — `/raven` and `/raven mcp` now show loaded, failed, and pending MCPs based on current-run connection checks instead of stale generated metadata.
70
+ - **Shorter status output** — `/raven` now points to `/raven help` instead of printing the full command list inline.
71
+ - **Clearer routing labels** — `/raven` now distinguishes routed global MCPs from on-demand MCPs, which are always behind Raven.
72
+ - **Default routed tools** — `websearch` is routed by default because it is a built-in OpenCode search tool.
73
+
74
+ ## 2.0.1
75
+
76
+ ### Added
77
+ - **Keyword tool routing** — `routeToolKeywords` and `/raven route keyword ...` route tools whose names contain a configured keyword, catching suffix-style MCP names like `web_search_exa`.
78
+
79
+ ### Changed
80
+ - **Stats formula** — context saved now uses a balanced estimate: final Raven session tokens minus the first assistant turn's input/cache baseline, then minus the compact answer returned. This counts tool/web/MCP result context while avoiding Raven prompt/tool-schema overhead.
81
+
82
+ ## 2.0.0
83
+
84
+ ### Added
85
+ - **Configurable tool/MCP routing** — Raven can now route arbitrary tools or MCP server prefixes through `raven_seek` using `routeTools`, `routeMcpServers`, or `/raven route ...` commands.
86
+ - **Bundled MCP toggle** — `raven-config.json` now includes `allowBundledMCPServers` to enable or disable Raven's bundled Context7, Exa, and Grep.app MCP defaults while preserving any existing `opencode.jsonc` MCP settings.
87
+ - **Custom Raven instructions** — `ravenInstructions` lets users append extra Raven-only prompt guidance for custom MCPs without editing package files.
88
+
89
+ ### Changed
90
+ - **Hard rerouting, not soft guidance** — Raven is now documented and configured as a hard tool/MCP blocker-rerouter. Configured tools are blocked for non-Raven agents and must go through `raven_seek`.
91
+ - **Generalized beyond search** — Raven still defaults to search/fetch/docs/GitHub routing, but can route any MCP whose opencode tool names share a prefix.
92
+ - **Config migration** — default routed tools/MCP server prefixes are added to `raven-config.json` only when those fields are missing, so user removals stay removed.
93
+ - **Bash routing visibility** — search-like bash command routing is now controlled by `bash` in `routeTools`. Remove `bash` to allow commands like `rg`, `Get-ChildItem -Recurse`, and `dir /s` directly.
94
+ - **Default routing cleanup** — removed `websearch` from default routed tools/MCP prefixes. Users who need it can add it manually with `/raven route tool add websearch` or `/raven route mcp add websearch`.
95
+ - **Compact reroute errors** — blocked MCP/tool calls now strip null and empty args before showing the `raven_seek` retry hint, reducing failed-call context noise.
96
+
97
+ ## 1.2.8
98
+
99
+ ### Fixed
100
+ - **Accurate context saved stats** — `/raven stats` now reflects actual model token usage from `session.messages()` (last assistant message tokens × 4), not string output length. Both `raven_seek` and direct `@Raven` use the same formula: `totalSessionTokens × 4 − prompt − output`.
101
+
102
+ ### Changed
103
+ - **`/raven` output** — now includes `Raven context saved` section with session and all-time totals.
104
+ - **`/raven stats` output** — renamed from "context processed" to "context saved" with clearer labeling.
105
+
106
+ ## 1.2.7
107
+
108
+ ### Changed
109
+ - **More reliable update notifications** — startup update toasts are now shown from the event hook after the TUI event stream is active instead of during config loading.
110
+ - **`/raven` default output** — now shows the loaded Raven package version and npm update availability.
111
+
112
+ ## 1.2.6
113
+
114
+ ### Fixed
115
+ - **Piped bash output filters** — commands like `command | grep ...`, `command | rg ...`, `command | findstr ...`, and `command | head ...` are now allowed as bounded output filters instead of being rerouted to Raven.
116
+ - **Raven recursion prevention** — `raven_seek` is denied inside the Raven agent so Raven cannot recursively call its own wrapper tool.
117
+ - **Model recovery after blocked tools** — blocked tool errors now provide a short direct `raven_seek(query="...")` next-call hint using the attempted query/args.
118
+ - **Bash false positives** — narrowed recursive/listing detection (`ls -r`, plain `cmd /c dir`, simple `Get-ChildItem`, comments, and bash descriptions no longer trigger blocking).
119
+
120
+ ### Changed
121
+ - **Bash search detection** — Raven still blocks primary discovery commands like `rg "foo" .`, `grep -R`, `find . -name`, `dir /s`, and `Get-ChildItem -Recurse`, but no longer treats simple pipeline filtering as a Raven-worthy search.
122
+ - **Raven guidance** — `raven_seek` is described as the primary search/fetch/inspection tool, with explicit URL and command-output inspection support.
123
+ - **MCP defaults** — Context7/Exa/Grep.app defaults now merge with existing user MCP config instead of overwriting custom headers, URLs, or disabled state.
124
+
125
+ ## 1.2.5
126
+
127
+ ### Added
128
+ - **`/raven update`** — checks npm for a newer Raven version, clears opencode's cached Raven plugin package when needed, and prompts the user to restart.
129
+ - **Startup update notification** — Raven checks npm at startup and shows a TUI toast when an update is available.
130
+ - **Config auto-migration** — existing `raven-config.json` files are normalized on startup so newly-added default fields are populated automatically.
131
+
132
+ ### Changed
133
+ - **Update docs** — README now includes `/raven update`, manual `bun`/`npm` update commands, and opencode cache-clearing instructions.
134
+
135
+ ## 1.2.4
136
+
137
+ ### Added
138
+ - **Session tree visibility** — Raven sessions created by `raven_seek` now appear in the session tree (`Ctrl+X Down`) via `parentID` linking.
139
+
140
+ ### Changed
141
+ - **`tool.execute.after`** — no longer a stub; now counts output bytes from direct `@Raven` task calls for accurate stats.
142
+
143
+ ## 1.2.3
144
+
145
+ ### Added
146
+ - **`raven_seek` timeout** — configurable timeout (default 600s). Session kept alive on timeout for inspection. `/raven timeout <seconds>` command.
147
+ - **Session debugger** — `scripts/debug-raven.ts` auto-detects the latest session and shows tool calls, timing, status, and errors.
148
+
149
+ ### Changed
150
+ - **`raven_seek` timing** — every response includes elapsed time and token count.
151
+
152
+ ### Fixed
153
+ - **`cmd /c` bypass** — `cmd /c dir`, `cmd /c findstr`, `cmd /c find`, `cmd /c where`, `cmd /c tree` now blocked.
154
+ - **`raven_seek` wording** — tool description, reroute messages, and guidance clarify Raven handles ALL search types (local codebase, web, docs, GitHub).
155
+ - **Case-insensitive bash blocking** — `SEARCH_BASH_RE` now case-insensitive.
156
+ - **Unrestricted bash for Raven** — `bash: allow` instead of restrictive whitelist. Raven can now use `dir`, `ls`, `Get-ChildItem` for fast filesystem searches instead of slow `glob`.
157
+ - **External directory access** — `external_directory: allow` prevents silent permission-prompt hangs in `raven_seek` sessions.
158
+
159
+ ## 1.2.2
160
+
161
+ ### Added
162
+ - **`websearch`** — built-in web search tool now intercepted.
163
+ - **Session + global stats** — session counter (resets on restart) and all-time counter (persists).
164
+
165
+ ### Changed
166
+ - **Stats refactored** — tracks `raven_seek` context processed (actual output size) instead of blocked tool counts and estimates. Cleaner, more meaningful.
167
+ - **No more error throttling** — full `REROUTE_MSG` on every blocked tool call.
168
+ - **Bytes from real measurements only** — dropped static estimates, numbers reflect actual Raven output.
169
+
170
+ ## 1.2.1
171
+
172
+ ### Added
173
+ - **`/raven stats`** — per-session and global tracking of blocked calls, bytes saved, and token estimates. Global stats persist across restarts.
174
+ - **`excludeTools`** — per-tool allowlist in config. Tools listed in `excludeTools` never get blocked, even for non-excluded agents.
175
+
176
+ ## 1.2.0
177
+
178
+ ### Added
179
+ - **Agent allowlist** — `excludeAgents` in config lets specific agents bypass search tool blocking and prompt injection (case-insensitive).
180
+ - **WebFetch/fetch blocking** — `webfetch` and `fetch` tools are now intercepted, routing all web page fetches through Raven.
181
+ - **Reasoning effort config** — `reasoning_effort` in config overrides Raven.md default. `/raven effort <value>` command.
182
+ - **Error recovery in raven_seek** — rate limits, quota exhaustion, token overflow, model unavailable, and timeouts return actionable recovery guidance instead of raw errors.
183
+ - **Parallel search in Raven** — Raven.md instructs Raven to run independent tool calls in parallel within a single session.
184
+ - **Global config** — config moved to `~/.config/opencode/raven-config.json`, shared across all projects. Auto-creates on first run.
185
+
186
+ ### Changed
187
+ - **raven_seek is primary path** — all guidance now points to `raven_seek` only. `task(subagent_type="raven")` delegation path removed from instructions.
188
+ - **Subagent prompt injection** — `<raven_guidance>` injected into every non-Raven, non-excluded subagent prompt at spawn time via `task`/`subtask` hooks.
189
+ - **Throttled error messages** — full error shown once per session, silent on repeats. Prevents context flooding.
190
+ - **Improved error message** — clean `REROUTE_MSG` with actionable `raven_seek` path.
191
+
192
+ ### Fixed
193
+ - **Bash false positives** — quoted content stripped before regex matching. `echo "use grep here"` no longer triggers blocking.
194
+ - **Allowlist reliability** — `sessionAgents` map tracks session→agent for reliable allowlist lookups (vs `input.agent` which isn't populated on `tool.execute.before`).
195
+
196
+ ### Removed
197
+ - **Dead `tool.execute.after` nullify code** — replaced with stub for future analytics.
198
+
199
+ ## 1.1.1
200
+
201
+ ### Added
202
+ - `raven_seek` tool — fallback for agents that can't use `task` delegation.
203
+ - MCP API key configuration instructions in README.
204
+
205
+ ### Changed
206
+ - README restructured with image-left, text-right header.
207
+
208
+ ### Fixed
209
+ - Exa MCP works without API key.
210
+ - MCP table shows Context7 and Exa offer higher limits with free keys.
211
+
212
+ ## 1.0.0
213
+
214
+ - Initial release. Search tool interception, Raven subagent, Context7/Exa/Grep.app MCPs.