Skip to content

feat(opencode): OpenCode plugin for context-guru - #483

Merged
amiddavid merged 17 commits into
rossoctl:mainfrom
AIMikav:feat/opencode-plugin
Nov 10, 2026
Merged

amiddavid merged 17 commits into
rossoctl:mainfrom
AIMikav:feat/opencode-plugin

Conversation

@AIMikav

@AIMikav AIMikav commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Behavior change (owner approved it on 2026-11-10). The OpenCode plugin now always starts its proxy with content capture off. It does this even when DASHBOARD_CONTENT is set in the environment.

  • Who it affects: OpenCode plugin users who set DASHBOARD_CONTENT.
  • Old: the proxy followed the environment, so DASHBOARD_CONTENT=1 turned capture on.
  • New: always off. Every start path passes --dashboard-content=false and sets DASHBOARD_CONTENT=0.
  • Get the diff view anyway: there is no way with this plugin. It cannot attach to a proxy you start yourself, and CONTEXT_GURU_BIN only picks the binary the plugin starts (which still gets the flag). To see diffs, run your own proxy and point OpenCode at it without this plugin.

Summary

  • Add a local-file OpenCode plugin for Context Guru.
  • Route Anthropic and OpenAI traffic through a per-project local proxy.
  • Preserve gateway paths while avoiding duplicate /v1 segments.
  • Add checksum-verified proxy downloads, project state, logging, dashboard, and recovery.
  • Add local plugin tests and installation documentation.
  • Use local OpenCode plugin installation only; no npm package is required.

Related issue(s)

None.

What we added on top (takeover by the context-guru maintainers)

Anamika's work from #483 (her commits keep her authorship):

  • Plugin core, OpenCode v1 and v2 entry points, gateway path handling.
  • Commands: status, install, update, uninstall.
  • Dead-proxy recovery, EXDEV-safe download, own-proxy URL detection, tests, docs.

Added on top (a merge of main, then three commits):

  • Cache strategies come from the proxy. The plugin runs context-guru-proxy strategies (feat(config): named cache strategies in the proxy config #987) and keeps no copy of the table. It offers only the strategies that fit a provider it routes. 5-min-ping is read as auto. It writes only cache.strategy: <name> to proxy.yaml.
  • Presets now include ultrahigh. List matches preset-picker.
  • /context-guru-preset and /context-guru-strategy. Each lists the choices (Claude Code wording), saves after a yes, and restarts the project proxy only after a second yes. A saved choice wins over the plugin options.
  • Native pickers in the TUI (opencode-plugin/tui.js, a second plugin entry listed in tui.json). A select list marks the current choice. Two confirm dialogs follow: save, then restart. It uses api.keymap.registerLayer (api.command.register is the fallback). Chat stays the fallback for opencode run, web, desktop and a setup without tui.json. Both paths run the same set NAME [--restart] script.
  • TUI picker fix. The first real OpenCode test found that tui.js loaded but its commands never showed. The host lists a keymap command only with namespace: "palette", and reads slashName, not slash: { name }. The fix adds both. The palette (ctrl+p, "Context Guru") now lists the two entries, and the dialogs open. The native pickers have no slash name: /context-guru-preset and /context-guru-strategy open only the chat commands (owner decision, option A).
  • Content capture is always off. Every proxy the plugin starts gets --dashboard-content=false and DASHBOARD_CONTENT=0. See the Behavior block.
  • Header scope fix. x-context-guru-session is sent only for providers the plugin routed (v1 was sending it for all).
  • Race fix. One machine-wide lock covers port choice, proxy start and the pid/install files. The holder refreshes it every 5 s. The download runs outside it. The plugin counts a proxy as started only while its own child is alive. Temp file names are unique.
  • Settings change. A changed saved setting makes the next start replace the project's proxy on the same port.
  • Picker fix. A picker saves only the key it changed. A set before the first install no longer saves a default that beats a plugin option. A restart checks both keys the way startup does, renders the new file before it stops the old proxy, and puts the old proxy back if the new one does not start.
  • Fix in the original code. uninstall --purge deleted a binary the plugin did not download. It now removes only a binary in the state directory that the plugin downloaded. Purge also removes the saved choices and the scripts.
  • Hardening. The release tag is checked. The kill guard matches the recorded binary path. A PATH entry must be executable. No session id means no header.
  • A CI workflow runs the Node tests (.github/workflows/opencode-plugin.yaml).
  • Docs: docs/how-to/install-opencode-plugin.md, opencode-plugin/README.md.

Merge order

v0.7.1 was published on 2026-11-10. It includes #987, which adds context-guru-proxy strategies. The plugin downloads v0.7.1 and needs a proxy of v0.7.1 or later. There is no merge-order blocker now.

Behavior and data dependence

  • No Go change. No change to the proxy, the library, or the Claude Code plugin.
  • Data dependence: the plugin keeps only its own metadata: ports, pids, paths, the preset and strategy names, and a hash of the project path. It starts the proxy with content capture off, even when DASHBOARD_CONTENT is set in the environment. No new row is needed in docs/data-dependence.md. The dashboard still keeps counts, sizes, ids, and the names and text of tool declarations.
  • The plugin sends the proxy the same traffic OpenCode sends the provider. It adds one header, the OpenCode session ID, and only for providers it routed.
  • It stores locally under ~/.local/state/context-guru-opencode/<project>/: pid, port, binary path, proxy.yaml, settings.env, options.env, the strategy files, log, dashboard DB. It stores no prompt text.
  • The strategy table has one owner, the proxy. The plugin reads it with context-guru-proxy strategies (from feat(config): named cache strategies in the proxy config #987) and keeps no copy. It writes only cache.strategy: <name>. It offers only the strategies that fit a provider it routes.
  • The plugin downloads release v0.7.1 and needs a proxy of v0.7.1 or later. An older binary is not started. The plugin logs an error that says to update.
  • Default auto pings with the user's own credential. The Claude Code plugin does the same.

How it was tested

  • node --test opencode-plugin/test/*.test.mjs: 81 passed, 0 failed, 5 runs in a clean environment. CI runs it on Node 22 (.github/workflows/opencode-plugin.yaml).
  • Mutations: every fix and every guard was undone once, and a test failed each time. This includes /v1 (v1 and v2), the default strategy, the alias, the header scope, the confirm steps in the TUI, the provider filter, the cache keys the plugin must not write, the lock heartbeat, the download outside the lock, the child watch, and the picker saving one key. Several first survived because the test was weak, and I fixed the tests.
  • Real OpenCode test (OpenCode 1.19.5, released proxy v0.7.1, port 8797, plain gateway as the upstream):
    • opencode run "say ok" through the proxy returned ok. The proxy logged cg.request route=/v1/messages provider=anthropic. The dashboard row has upstream status 200 and the same OpenCode session id as the proxy log.
    • With DASHBOARD_CONTENT=1 in the environment: the proxy command line ends with --dashboard-content=false, its environment has DASHBOARD_CONTENT=0, and the log says content_capture=false. The request_content table has 0 rows after the 200 request.
    • TUI under tmux, no model call: the palette lists "Context Guru: preset" and "Context Guru: cache strategy". The preset entry opens the select list "Context Guru: preset (saved: off).", then "Switch preset?", then "Restart the proxy now?". The choice is saved only after the first yes.
    • Preset and strategy changes, uninstall with an external binary kept, and fail-open (base URL stays on the gateway) also passed. The wrong-token 401s came from my test environment, not the plugin.
    • Slash menu (no slashName on the native commands): each /context-guru-* name is listed once, and the palette still lists both native commands.
    • Not covered: /context-guru-status end to end through the model, and OpenCode 2.
  • Integration with a real proxy built from b49cbeb6 (darwin/arm64), dead upstream 127.0.0.1:1, no API keys:
    • 7 cases (Anthropic: auto, 2-ping, 1-hour-head, none. OpenAI: default and 30-min-ping. Both: auto) return 502, not 404 on /anthropic/v1/messages, /openai/v1/chat/completions and /openai/v1/responses. The proxy accepts cache.strategy.
    • A restart through the picker script starts a new proxy. Three restart cases pass with the real proxy: OpenAI only keeps strategy: none, typo options still start the proxy, and a refused new file puts the old proxy back (old_proxy=restored).
  • A restart through the picker script starts a new proxy. uninstall --purge removes the state and keeps an external binary.
    • The v0.7.0 proxy treats strategies as an argument and starts serving. The plugin's loopback port 0 and 5 s limit stop it, and it logs the update error.
  • The native TUI dialogs were tested with a fake api.ui. I did not run a real OpenCode.

Gaps against the Claude Code plugin

Claude Code OpenCode
install, update, uninstall, status Done
preset-picker Done (/context-guru-preset, native dialog in the TUI)
cache-strategy-picker Done (/context-guru-strategy, native dialog in the TUI)
doctor Not ported
insights Not ported
save-more Not ported
remove-mcp-and-skills Not ported
cache-campaign Not ported
statusline, signal hooks Not ported
manual ping header Not ported

CI note

Open questions

  • Field names. namespace: "palette" and slashName come from reading OpenCode 1.19.5, not from a published type. A later OpenCode may change them. The legacy api.command.register stays as the fallback.

🤖 Generated with Claude Code

@amiddavid

Copy link
Copy Markdown
Collaborator
Reviewer:    Claude Code main session (review-pr-483 worktree), with the code-review skill
Kind:        AI agent (Claude Code, Opus 5.5)
Started by:  integrator
Context:     fresh
Review:      1 of 2
Head:        c2f2ca6561196d88d57719fda95f28d0ea0a9548
Verdict:     blocking: Anthropic requests 404 (missing /v1); no recovery after the proxy stops

Summary

The plugin starts the proxy and routes OpenAI correctly. Every Anthropic request fails with 404. The plugin also covers about 4 of the ~18 user commands that the Claude Code plugin has.

Blocking

  1. Anthropic route is missing /v1 (opencode-plugin/index.js, routeProviders).

    • The plugin sets baseURL to http://127.0.0.1:<port>/anthropic.
    • @ai-sdk/anthropic appends /messages. Its own default base is https://api.anthropic.com/v1.
    • The proxy serves only POST /anthropic/v1/messages (proxy/proxy.go:376).
    • I ran @ai-sdk/anthropic@2 and @ai-sdk/openai@2 against a stub server with the plugin's URLs. Result: POST /anthropic/messages (404 on the proxy) and POST /openai/v1/responses (correct).
    • Fix: use /anthropic/v1. Add a test that asserts the rewritten baseURL for each dialect.
  2. No recovery after the proxy stops. The config hook runs once, at OpenCode startup. The proxy exits after --idle-exit 24h, or on a crash. After that, OpenCode keeps sending to a dead port, and every request fails until a restart. The Claude Code plugin handles this with start-proxy.sh (SessionStart) and check-proxy.sh (UserPromptSubmit). Proposal: check health in chat.params or chat.headers and restart the proxy on the same port.

Should fix

  1. A local gateway is replaced by the public API. Any baseURL that contains 127.0.0.1: or localhost: is ignored, and the upstream becomes api.anthropic.com / api.openai.com. A user with LiteLLM at http://localhost:4000 loses their gateway. Compare against this plugin's own recorded port, not against every loopback host.
  2. The session header goes to every provider. chat.headers adds x-context-guru-session with no provider check. Unrouted providers receive it too. Add the header only for the providers that the plugin routed.
  3. renameSync from os.tmpdir() can fail with EXDEV when /tmp is tmpfs and the state directory is on disk (common on Linux). The download then fails on every start. Extract into a directory under the state directory instead. (Code reading; not reproduced.)
  4. Two OpenCode instances in one project race. freePort checks and then releases the port. Both instances can spawn a proxy; one exits on bind, and the last writer owns install.json and proxy.pid. (Code reading.)

Gaps against the Claude Code plugin

The Claude Code plugin (context-guru-plugin on current main) has these commands and hooks. "OpenCode" shows what this PR gives.

Claude Code plugin What it does OpenCode (this PR)
install Install binary, pick port, route, status line Partial. User edits opencode.json by hand. Binary download and port pick are automatic.
uninstall Remove routing, stop proxy, optionally delete binary Partial. User edits config by hand; context-guru-reset stops the proxy.
update Check for and install a newer proxy binary Missing. The binary is downloaded once and never updated, unless CONTEXT_GURU_VERSION changes.
status Proxy up, routed, saved today, top 3 actions Missing. Only the dashboard URL in the log.
doctor Check routing, proxy, prices, status line Missing.
insights (savings, cache, tools) Savings, cache misses, unused tools Missing (the dashboard shows some of it).
preset-picker Show and switch the preset Partial. Tuple option in config; no way to see the current one.
cache-strategy-picker Show and switch none / 5-min-ping / 1-hour-head Partial. Config option only; 1-hour-head is not accepted.
save-more Replay history under each preset/strategy, apply the best Missing.
remove-mcp-and-skills Find and filter unused MCP servers and skills Missing.
cache-campaign Cache plan from history, shadow/live Missing.
statusline Saved/spent, cache state, context fill in the terminal Missing.
watch, chart, heatmap, fill, session, timeline Live view and reports Missing.
Hook: SessionStart start-proxy.sh Start the proxy each session Partial. Only at OpenCode startup (see item 2).
Hook: UserPromptSubmit check-proxy.sh Warn when the proxy is down before the request hangs Missing (see item 2).
Hooks: signal.sh (SessionStart, SessionEnd) Tell the proxy the user left, came back or compacted, so keep-alive stops spending Missing. OpenCode has session.idle, session.compacted and session.deleted events for the event hook.
Option port Pin a port Missing (auto only).
Option idle_exit Proxy exit timeout Missing (fixed 24h).
Option upstream Gateway URL Covered through the provider baseURL.
Option client_signals Turn session signals on/off Missing.

Most important gap: no signal.sh equivalent. With the 5-min-ping default, the proxy keeps paying for pings after the user closes OpenCode, because it never hears that the session ended.

OpenCode plugins can add commands through the config hook (config.command) and tools through the tool hook. So most of the reports can reuse scripts/insights.py later. This does not need to block the first version, but the docs must say which commands do not exist yet.

How it was tested

  • node --test opencode-plugin/test/plugin.test.mjs: 3 of 3 pass. The tests do not check any rewritten URL, so they did not catch item 1.
  • Stub-server run of @ai-sdk/anthropic@2 and @ai-sdk/openai@2 with the plugin's URLs (item 1).
  • No Go files change, so no eval-box run. No live traffic.
  • The branch is 12 days behind main; it merges without conflicts.

Non-blocking

  • The README badge for OpenCode uses logo=openai.
  • chmod/rm through spawnSync can be chmodSync/rmSync.

@amiddavid

Copy link
Copy Markdown
Collaborator

Follow-up on blocking item 1: why Anthropic requests fail, although the proxy handles the traffic.

The proxy handles a request only after the request arrives on one of its routes. The client builds the URL. The plugin sets the base of that URL.

Test with the released proxy

I ran context-guru-proxy v0.5.2 on a laptop and sent the same Anthropic request to both paths:

Path Proxy answer
/anthropic/messages (where OpenCode sends with this PR) 404: no route; the request never goes upstream
/anthropic/v1/messages (the route the proxy serves) 502: routed and processed; it failed only because the test upstream was a dead port

Why it happens

  • The proxy serves fixed paths: POST /anthropic/v1/messages (proxy/proxy.go:415).
  • The plugin's config hook sets the provider baseURL to http://127.0.0.1:<port>/anthropic.
  • OpenCode's Anthropic SDK (@ai-sdk/anthropic) adds only /messages to baseURL. Its own default base is https://api.anthropic.com/v1, so it expects /v1 in the base. A run of the real SDK against a stub server sent POST /anthropic/messages.
  • Claude Code works with the same /anthropic base URL, because Claude Code adds /v1/messages itself. The two clients build the path differently.
  • OpenAI works in this PR, because the plugin sets /openai/v1 and the SDK adds /responses.

Fix

  • In routeProviders, set the Anthropic baseURL to http://127.0.0.1:<port>/anthropic/v1.
  • Add a test that checks the rewritten baseURL for each dialect.

@amiddavid

Copy link
Copy Markdown
Collaborator

the main gaps in terms of plugin commands that
we MUST fix to get this approved
install, uninstall, update, status
the next set which would really be nice if we have is
preset-picker, cache-strategy-picker

- Use the Claude Code plugin names and numbers for cache strategies:
  none, auto (default), 1-ping, 2-ping, 1-hour-head. 5-min-ping is an
  alias for auto. Add the ultrahigh preset.
- Add /context-guru-preset and /context-guru-strategy (v1 and v2).
  They save the choice, then restart the proxy after a yes.
- Send x-context-guru-session only for providers the plugin routed.
- Take one machine-wide lock around port choice and proxy start, so
  two OpenCode instances cannot race for a port or a pid file.
- Replace a running proxy when the saved settings change.
- Tests: strategy mapping, pickers, header scope, lock, restart.
- Docs: commands, strategies, and a "Not ported yet" list.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
(cherry picked from commit 12b8ca0)
Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid amiddavid changed the title Feat(plugin): Add local OpenCode context-guru plugin feat(opencode): OpenCode plugin for context-guru Nov 9, 2026
@amiddavid

Copy link
Copy Markdown
Collaborator

Thank you, Anamika. We added one commit and one merge of main on top of your history. Your commits are unchanged.

What we added:

  • Cache strategies now match the Claude Code plugin: none, auto (default), 1-ping, 2-ping, 1-hour-head. 5-min-ping is an alias for auto.
  • The ultrahigh preset.
  • New commands: /context-guru-preset and /context-guru-strategy.
  • The session header is sent only for providers the plugin routed.
  • A lock stops two OpenCode instances from racing for a port or pid file.
  • Tests: 31 pass. Docs and a "Not ported yet" list are updated.

The PR description has the full list, the test numbers and the open questions.

🤖 Generated with Claude Code

amiddavid added a commit that referenced this pull request Nov 9, 2026
scripts/offload-review.sh fetched the PR's head branch from origin.
A PR from a fork has no branch there, so every round failed before a
reviewer started (seen on #483). It now fetches refs/pull/<n>/head,
and checks that the head gh reported is present.

Behavior change: none. Dev tooling only.
Data dependence: none.

Reviews: 2 offload reviews (GLM), round 1, both approve at aa7401b.
8e3a3fa changes only comment lines (approval-still-valid.sh: COMMENTS
ONLY).

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
- Add opencode-plugin/tui.js, a TUI plugin entry loaded from tui.json.
  It registers /context-guru-preset and /context-guru-strategy with
  api.keymap.registerLayer (api.command.register is the fallback).
- Show a select list with the current choice marked, then one confirm
  dialog to save and one to restart the proxy.
- Run the same "set NAME [--restart]" script as the chat commands, so
  the native and chat paths cannot differ. Chat stays the fallback for
  opencode run, web, desktop and a setup without tui.json.
- Remove the ultrahigh tool-defer probe from the pickers.
- Tests: fake api.ui for the native flow, cancel paths, fallback.
- Docs: tui.json install step.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 1f214ac0c6bd blocking

Verdict: blocking

Findings

  1. opencode-plugin/index.js:792 — the lock's 60 s stale age is shorter than the work it protects, so two instances can start two proxies for one project.

    • What fails: a first run downloads the release while holding the lock. downloadBinary uses fetch with no timeout (index.js:93, 104-107), so a slow or stalled download holds the lock for minutes. A second OpenCode window opened after 60 s sees the lock as stale (index.js:792), deletes it, and takes it. Both windows then run startProxy for the same project: the second starts its own proxy, and the first starts another one on the next port. Result: two proxies for one project, each pinging with the user's credential (double keep-alive spend), split dashboard and cache state, and proxy.pid / install.json describing only the last writer. The proxy the records do not name is never stopped by uninstall or reset.
    • Proof: startProxy holds the lock across downloadBinary (index.js:848, 861). withLock removes any lock older than 60 s (index.js:792) and a waiter only gives up at its own 45 s deadline, so an instance arriving after 60 s breaks a live lock instead of failing open. The narrow variant is worse: both instances can pass freePort (index.js:159-171) before either proxy binds, and waitForHealthy (index.js:182-188) never checks that the spawned child is alive, so the loser records a foreign proxy as its own. cmd/context-guru-proxy/main.go:47-53 documents this exact hazard: a sibling on the port answers /healthz with 200 and "served ITS corpus". The README claim "Two OpenCode instances share one lock. They cannot pick the same port or write the same pid file" does not hold on this path.
    • Fix: download outside the lock, or write a heartbeat into the lock while holding it and treat age from the heartbeat. Also fail startProxy when its own child exits before waitForHealthy succeeds.
  2. opencode-plugin/index.js:965 — no test for the fail-open path when proxy startup fails with routes present.

    • What fails: the repo's first rule is fail open: a component error reverts that component only. The v1 catch (index.js:965-967) and the v2 catch (index.js:1059-1061) leave the provider base URLs untouched when the proxy cannot start. No test drives that path. Every test either has no Anthropic/OpenAI provider, a disabled marker, or a working stub binary.
    • Proof: I read all six test files. plugin.test.mjs covers an unsupported provider and the disabled marker. No test gives a routed provider a binary that never becomes healthy, or a dead release server, and asserts the base URL stays unchanged. The multiple <dialect> upstreams throw (index.js:762, 1034) is also untested.
    • Fix: add one test per generation: CONTEXT_GURU_BIN points at a script that exits at once, an Anthropic provider is configured, and the test asserts the base URL is unchanged after config / setup.

Non-blocking

  • index.js:793-795 — the catch { continue } in withLock skips the deadline check. A statSync error that is not transient (permissions) spins the loop forever. Move the deadline check above the continue.
  • index.js:809 — stopRecordedProxy reads proxy.pid with no existence check. A running proxy plus a missing pid file throws, and the whole config hook fails open for that glitch. Guard the read.
  • index.js:69-76 — executableOnPath tests existence, not the executable bit. A non-executable file named context-guru-proxy in a PATH directory wins over a good one further along, and startup fails.
  • index.js:978 — chat.headers writes String(undefined) when the host gives no session ID. Skip the header instead.
  • index.js:1045 — v2 checks routedIds.length right after await ctx.provider.transform(...) returns. This assumes the host invokes the transform callback before transform resolves. If a real OpenCode 2 defers it, the session hooks are never registered and dead-proxy recovery is silently off. The mock in test/v2.test.mjs cannot catch this. Worth one manual check against a real OpenCode 2 before release.
  • README.md:60 — the OpenCode install badge reuses the OpenAI logo, same as the Codex row. Cosmetic.

What I checked

  • Read the full diff (12 files, 2,549 lines) and the code around each change: opencode-plugin/index.js, tui.js, all six test files, both READMEs, the install doc, mkdocs.yml.
  • Checked strategy parity against context-guru-plugin/scripts/settings.py (STRATEGIES, STRATEGY_ALIASES, DEFAULT_STRATEGY, ONE_HOUR_DEFAULTS): names, numbers, and the omitted _1h defaults all match. keepalive_max_usd_per_ping: 0.5 equals 0.50.
  • Checked the proxy side the plugin drives: --anthropic-upstream, --openai-upstream, --dashboard, --dashboard-db, --idle-exit 24h all exist in cmd/context-guru-proxy/main.go; --idle-exit refuses only --upstreams/--bob-upstream, not the per-dialect flags; x-context-guru-session is the header name the Go tests use.
  • Traced the fail-open paths: disabled marker, no routes, multiple upstreams, startup failure, logging failure, recovery failure. All revert to the original provider config, except the mid-session dead-proxy case, which the install doc discloses.
  • Traced the picker scripts line by line (render, alias, save, restart) and the TUI dialog flow against parsePickerOutput.
  • Verified BSD grep supports the \| alternation used in the generated scripts, so the install.env rewrite works on macOS as well as Linux.
  • Checked the shell pid-kill guards (ps -o command= match before every kill) and the download checksum verification.
  • Did not run the node tests (live tests not approved). Did not verify the OpenCode 1/v2 host API shapes beyond the repo's own mocks; no OpenCode SDK or docs exist in this repo.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.319 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 1f214ac0c6bd blocking

Verdict: blocking

Findings

  1. opencode-plugin/index.js:493 — a picker set before the first successful install saves a default for the OTHER setting, and that default then overrides the user's plugin options.
    • What fails: the user sets {"preset": "high", "cacheStrategy": "none"} in the plugin options. No install exists yet (no Anthropic or OpenAI provider at startup, or the first download failed, so install.env was never written). The user runs /context-guru-preset set medium. The generated script falls back to cur_strategy=${strategy:-auto} (index.js:494) because install.env is absent — it never consults the plugin options. Line 528 then writes preset=medium and strategy=auto into settings.env. At the next startup effectiveSettings (index.js:833-839) lets the saved strategy=auto win over the option none, so the proxy runs keep-alive pings that spend the user's credential, which the user explicitly turned off. The same shape downgrades an options preset to off when the user switches strategy. The show path has the same wrong fallback: it reports saved=off / saved=auto while the options say otherwise.
    • Proof: trace of index.js:491-494 (cur_preset/cur_strategy fall back to DEFAULT_PRESET/DEFAULT_CACHE_STRATEGY when both settings.env and install.env are absent — the plugin options are not an input to the script), index.js:526-528 (set persists BOTH keys, not just the one the user chose), index.js:836-837 (a saved value that validates wins over the option). writeInstallFacts (index.js:558-570) runs only after a healthy proxy (index.js:876), which is why the no-install state has no recorded effective values. No test covers set without an install.env.
    • Fix: persist only the key the picker changed (leave the other absent from settings.env), or bake the effective option values into the generated script as the fallback defaults. Add a test: options cacheStrategy: "none", no install, preset set medium, then effectiveSettings must still return cacheStrategy: "none".

Non-blocking

  • index.js:564 / index.js:360 (updateScript) — version is written unquoted into install.env, which the scripts source. The value comes from the release redirect URL (downloadBinary, index.js:95) or the Location header (updateScript). A tag like v1;cmd would execute on sourcing. The release endpoint is already fully trusted (it also supplies the binary and its checksum), so this is hardening, not a broken boundary: validate the tag against ^v?[A-Za-z0-9._-]+$ or shQuote it.
  • index.js:809 — stopRecordedProxy throws when proxy.pid is missing but the recorded port is healthy. The throw propagates to the config hook's catch, so the whole routing is skipped (fail open, no proxy) instead of reusing or replacing the running proxy. Wrapping the read in a try, or killing by port owner, keeps the startup working.
  • index.js:692-700 — a gateway baseURL that does not end in /v1 gets /v1 inserted into its path. The proxy appends /v1/messages etc. to the upstream (proxy/proxy.go:583-586), and proxyUpstreamURL only strips a trailing /v1. A gateway that serves at baseURL/messages (no /v1) worked before the plugin and 404s after. The strip rule matches the @ai-sdk convention, so this is an accepted edge; worth one line in the docs' troubleshooting.
  • index.js:812 and the shell scripts — the pid-kill guard matches *context-guru-proxy* in the command line. A CONTEXT_GURU_BIN path whose file is named differently is never killed by reset, uninstall, update, or set --restart; the scripts then report success while the proxy keeps running.
  • CI runs nothing for opencode-plugin/. make test and .github/workflows/ci.yaml are Go-only, so the 1097 lines of node:test tests run only on a developer's machine. This matches the Claude Code plugin's Python tests, so it is precedent, not a regression — but a node --test opencode-plugin/test/ job is cheap.
  • uninstall --purge leaves settings.env and the command scripts behind, while the docs say it "also removes the binary and state files". The leftover settings.env still wins over plugin options at the next install.
  • Data dependence (repo rule): the plugin keeps only its own metadata (ports, pids, paths, a hash of the project path) and starts the proxy with --dashboard and content capture off, matching the Claude Code plugin. docs/data-dependence.md needs no new row for that, but the PR description should state it in plain words, as CLAUDE.md requires.

What I checked

  • Read the full diff 569c609b..HEAD (12 files, +2549) and the code around each change: opencode-plugin/index.js, tui.js, all six test files, both READMEs, the install doc, mkdocs.yml.
  • Read all 8 commits, including the merge 33e0eb8b and the path-normalization fix 761153ce.
  • Verified the plugin's assumptions against the proxy: --anthropic-upstream/--openai-upstream/--config/--dashboard/--dashboard-db/--idle-exit flags exist (cmd/context-guru-proxy/main.go), the served paths /anthropic/v1/messages, /openai/v1/chat/completions, /openai/v1/responses, /healthz match the rewritten baseURLs (proxy/proxy.go:560-596), and x-context-guru-session is the header the proxy reads (proxy/proxy.go:743).
  • Verified the strategy table, aliases, ONE_HOUR_DEFAULTS omission rule, and the 1-hour-head deprecated token key against context-guru-plugin/scripts/settings.py (STRATEGIES, lines 3626-3754) — they match.
  • Verified the cache: keys the plugin writes exist in the strict YAML loader (config/config.go:143-232).
  • Traced the fail-open paths: config-hook errors leave provider config untouched; chat.headers/http.request recovery failures never break the request; the disabled marker blocks recovery; the lock, single-flight recovery, port reuse, and picker restart flows.
  • Checked the generated shell scripts by hand: quoting (shQuote on every path), heredoc structure in render(), pid guards, atomic writes, and macOS portability (verified locally that BSD grep accepts \| BRE alternation and /bin/sleep accepts 0.2; no Go builds or tests were run).
  • Checked the README table HTML stays well-formed with the new rowspan="3" row.

- Remove the plugin's own copy of the strategy table. Read it with
  "context-guru-proxy strategies" (from rossoctl#987). There is no fallback
  for an older binary: the plugin logs an error that says to update.
- Run the command with a loopback port 0 and a 5 s limit. An older
  proxy treats the word as an argument and starts serving.
- Offer only strategies whose providers match a routed provider.
  The default is the proxy default. An unfit default runs none.
- Write "cache.strategy: <name>" to proxy.yaml. The proxy fills the keys.
- Pin the download to v0.7.1, the first release with "strategies".
- Tests: fake table, provider filter, old-binary error, kill at the limit.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Blocking:
- A picker "set" saves only the key it changed. "show" reads
  saved, then the plugin options, then the default. Before, a set
  before the first install saved a default strategy that beat the
  option and could turn on pings.
- The lock has a heartbeat (5 s) and a 30 s stale age. The download
  runs outside the lock. startProxy fails when its own child exits,
  so a stranger on the port is not taken for the child.
- Tests for fail-open when the proxy cannot start (v1 and v2) and for
  the "multiple upstreams" error.

Also fixed:
- uninstall --purge and reset deleted a binary the plugin did not
  download: the marker file was tested for existence, not content.
  A binary is now removed only if the marker says yes and it lives in
  the state directory.
- uninstall --purge also removes the saved choices and the scripts.
- The stop and reset guard matches the recorded binary path, so a
  binary with another file name is stopped.
- The release tag in install.env is checked. The update script
  refuses an odd tag.
- stopRecordedProxy does not throw when proxy.pid is missing.
- withLock checks its deadline before it retries.
- A PATH entry must be executable.
- No session id means no session header (v1 and v2).
- v2 registers the session hook from the provider callback, so the
  order of the callback and transform() does not matter.
- A CI workflow runs the Node tests on Node 22.
- The README badge no longer uses the OpenAI logo.
- Docs: the /v1 gateway note, the guard rule, the lock.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator

Round 1 reply

Head is now bb9ebe83. It holds two new commits on top of 1f214ac0:

  • 8530f14b reads the cache strategy table from the proxy.
  • bb9ebe83 fixes the findings below.

Both reviewers blocked. All findings are fixed except one, which is kept with a reason.

Reviewer 1

  1. Blocking: a picker set saves a default for the other setting. Fixed in bb9ebe83.
    • The picker now saves only the key it changed.
    • show reads saved choice, then plugin option, then default. The plugin writes the options to options.env at every start, also when nothing is routed.
    • Tests: a preset set with no install keeps cacheStrategy: "none". A strategy set keeps the preset.
  2. version in install.env and the update script. Fixed. The plugin writes the tag only if it matches ^v?[A-Za-z0-9._-]+$, else external. The update script refuses an odd tag (reason=odd-tag). Both have tests.
  3. stopRecordedProxy throws when proxy.pid is missing. Fixed. The read is guarded. The test shows a new proxy starts on a new port.
  4. Gateway baseURL and /v1. Kept as designed, with a doc line. The @ai-sdk rule adds /v1. The troubleshooting section now says a gateway baseURL must end in /v1 or have no path.
  5. The kill guard matches *context-guru-proxy*. Fixed. I chose to match the binary path the plugin recorded. A binary with any file name is stopped. A reused pid is not. Test: a proxy named my-proxy is stopped by reset.
  6. No CI for opencode-plugin/. Fixed. New file .github/workflows/opencode-plugin.yaml, Node 22, runs only on opencode-plugin/** changes. I used a separate file, as docs.yaml does. ci.yaml ignores docs paths and would run the whole Go suite for a JS change.
  7. uninstall --purge leaves settings.env and scripts. Fixed. It now removes them. It keeps context-guru-install, which undoes the uninstall.
  8. Data dependence. Stated in the PR body.

Reviewer 2

  1. Blocking: the 60 s stale lock is shorter than the download. Fixed in bb9ebe83.
    • The download runs outside the lock. It writes a temp name and renames it.
    • The holder refreshes the lock every 5 s. A lock nobody touched for 30 s is broken.
    • startProxy now fails when its own child exits. A stranger on the port is not taken for the child.
    • Tests: a live lock is not broken, even when old. A dead lock is broken. The download does not hold the lock. A child that exits fails fast.
  2. Blocking: no test for fail-open. Fixed. Tests for v1 and v2: the binary exits at once, the base URL stays. Tests for the multiple <dialect> upstreams error, v1 and v2.
  3. withLock deadline. Fixed. The deadline is checked before the retry.
  4. executableOnPath. Fixed. It checks the executable bit.
  5. chat.headers without a session id. Fixed in v1 and v2. No id, no header.
  6. v2 routedIds timing. Fixed. The hook is registered from inside the provider callback. Each hook checks the routed set when a request comes. A test runs the callback after transform() has resolved. I did not run a real OpenCode 2.
  7. README badge. Fixed. No logo.

Found while fixing: a bug in the original code

uninstall --purge deleted the binary even when the plugin did not download it. The marker file managed-binary is always written, and the script tested only that it existed. My integration run lost its test binary this way. Now a binary is removed only if the marker says yes and the file is in the state directory. Two tests cover purge and reset with an external binary.

Checks

  • Tests: 65 pass, 0 fail, in a clean environment, 5 runs.
  • Mutations: each fix was undone, and a test failed each time. Two mutations first survived because the test was weak. I fixed those tests.
  • Integration, real proxy built from b49cbeb6, dead upstream: 7 strategy cases return 502 on the routes. A restart through the picker, and a purge, work.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.321 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 bb9ebe837de4 blocking

Verdict: blocking

Earlier findings

  • My round-1 finding 1 (lock vs. download): fixed. The download runs outside the lock (index.js:905-908), the holder heartbeats every 5 s with a 30 s stale age (index.js:831-862), and startProxy fails when its own child exits (index.js:941-950), so a stranger on the port is not taken for the child. Tests: review1.test.mjs:71-147 cover a live old lock, a dead lock, the download outside the lock, and the fast child-exit failure.
  • My round-1 finding 2 (missing fail-open tests): fixed. review1.test.mjs:150-176 and v2.test.mjs:206-236 cover v1 and v2 with a dead binary and with two upstreams for one dialect.
  • My round-1 non-blocking items: all fixed (deadline before retry, guarded proxy.pid read, executable bit, no header without a session id, v2 hook timing with a late-callback test, badge).
  • Reviewer 1's blocking finding (picker saves a default over the option): fixed. The picker saves only the key it changed (index.js:562) and show reads saved, then option, then default (index.js:519-520). Tests: review1.test.mjs:28-68.
  • Reviewer 1's non-blocking items: fixed, except the gateway /v1 rule, which the author kept with a reason. I checked the reason: the @ai-sdk clients add /v1 themselves, and the troubleshooting section now states the rule (install doc, "A gateway stops working after the plugin routes it"). I accept it.
  • The purge bug the author found while fixing: verified fixed. A binary is removed only when the marker says yes and the path is under the state directory (index.js:428-432). Tests cover purge and reset with an external binary.

Findings

  1. opencode-plugin/index.js:14 — the pinned release v0.7.1 does not exist, so every fresh install fails, and a v0.7.0 managed install hits an update dead end.

    • What fails: PINNED_VERSION = "v0.7.1" and downloadBinary never asks which release is latest (index.js:117). A fresh install (no PATH binary, no managed binary) fetches /download/v0.7.1/…, gets 404, and the plugin fails open with no routing. A user whose managed binary is v0.7.0 (downloaded as "latest" by this PR's earlier heads) gets "update the proxy to v0.7.1 or later (/context-guru-update, …)", but the update script compares against the real latest release, v0.7.0, finds installed = latest, and answers result=latest. The plugin demands an update the updater says does not exist. Only the manual "remove the binary" escape works.
    • Proof: the GitHub releases list tops at v0.7.0 (created 2026-11-09T14:53:05Z); there is no v0.7.1 tag or release (checked releases, releases/tags/v0.7.1 → 404, tags). The strategies subcommand the plugin depends on landed in #987 (b49cbeb6, merged 18:54Z), about four hours after v0.7.0 was cut, so v0.7.0 does not have it. The author's integration run used a binary built from b49cbeb6, not a release.
    • Fix: cut and publish release v0.7.1 before this merges (and before anyone installs the plugin), or resolve the pin to a release that exists. Until the tag exists, the merge must wait.
  2. opencode-plugin/index.js:577 — a picker set --restart writes the OTHER setting's raw option value into proxy.yaml without validation, and a bad value leaves the project with no proxy.

    • What fails: the restart path takes new_strategy / new_preset from the saved value, else the raw plugin option (index.js:519-520, 560), and writes both into proxy.yaml (index.js:577). writeOptionsFile stores the option as typed, not resolved (index.js:613-617). The startup path resolves the option through the proxy's table and the preset list (index.js:915-918, 895-899); the picker path does not. So: the user types {"preset": "hgh"} (a typo) or {"cacheStrategy": "aut0"}; the plugin warns at startup and runs off/none; later the user runs /context-guru-strategy set 2-ping --restart. The script kills the running proxy, writes preset: hgh into proxy.yaml, and the proxy exits with config: unknown preset "hgh" (config/config.go:488 on main; an unknown cache.strategy is a config error too, config/strategy.go applyStrategy). Result: the old proxy is dead, the new one refuses to start, ensureProxyRunning keeps failing on the same bad config, and every request fails until the user repairs the config by hand. That is fail-closed, against the repo's first rule. A milder case needs no typo: an OpenAI-only setup (option auto, not offered) gets strategy: auto written by any preset switch with restart, silently undoing the plugin's own unfit-to-none decision.
    • Proof: trace of index.js:519-520 (fallback chain ends at the raw options.env value), 613-617 (raw option written), 560 and 577 (both keys rendered into proxy.yaml), against the validated startup path at 915-918. No test covers set --restart with an option value the proxy rejects.
    • Fix: in the restart path, validate the other key the way startProxy does — preset against the preset list, strategy against strategies.tsv after alias mapping — and fall back to the default when it does not validate. Add a test: option preset: "hgh", then strategy set 2-ping --restart, and the proxy must still start.

Non-blocking

  • index.js:1141-1145 — the comment says "setup waits for them", but await Promise.all(pendingHooks) returns at once when the provider callback has not run yet, and if (!hooked.size) then logs "no Anthropic or OpenAI provider is configured" wrongly. The hooks still register when the late callback runs, so only the log is wrong. Cosmetic, and only under a host that defers the callback.
  • index.js:29-32 — loadStrategyTable does not check the spends and desc types. A row without desc would show "undefined" in the picker. Hardening only; the real proxy always sends them.
  • tui.js:35 — when strategies.tsv is missing (nothing routed yet), the toast says "No cache strategy script found", but the script exists; the table is what is missing. Wording only.

What I checked

  • Last review: round 1, 1f214ac, 2026-11-09T18:55:12Z
  • New commits read: 2 (8530f14 feat(opencode): read the cache strategy table from the proxy; bb9ebe8 fix(opencode): fix round 1 review findings)
  • Read in full: 2 reviews, 5 comments, 0 inline comments (from the three files)
  • New items since my last review: reviewer 1's round-1 review (read in full; its blocking finding and non-blocking list checked in code); the author's round-1 reply (each "fixed" claim verified at the named lines; the one "kept with a reason" checked and accepted); commits 8530f14 and bb9ebe8 (full diff, and every changed file read whole: index.js, tui.js, all test files, the workflow, both READMEs, the install doc).
  • Verified the plugin's new dependency against main: context-guru-proxy strategies and cache.strategy come from #987 (b49cbeb6, on origin/main, NOT in this PR's head); the table shape the plugin parses matches config.StrategiesJSON; aliases are canonicalized by the proxy's LookupStrategy, so an alias written into proxy.yaml loads; an unknown preset or strategy name is a config error that stops the proxy.
  • Checked the release the plugin pins: v0.7.1 has no tag and no release; the latest release is v0.7.0, cut before #987 merged (finding 1).
  • Re-traced the lock (heartbeat, stale age, download outside), the child-exit race, the fail-open paths, the picker save/show/restart flows, options.env, and the purge and kill guards against the tests that now cover them.
  • Did not run the node tests (live tests not approved). The author reports 65 passing and mutation checks; I read the tests instead.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.321 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 bb9ebe837de4 blocking

Verdict: blocking

All round-1 findings from both reviewers are fixed, except one the author kept with a reason I accept. The two new commits add two defects of their own.

Findings

  1. opencode-plugin/index.js:577 — set NAME --restart writes the OTHER setting into proxy.yaml without the check that startup applies.

    • What fails, case A (silent spend): an OpenAI-only project, no saved strategy, no plugin option. The picker falls back to cur_strategy=$DEFAULT (index.js:520). strategies.default holds the raw proxy default auto (index.js:59), not a name that fits openai. The user runs /context-guru-preset set high --restart. Line 560 copies that auto into new_strategy, and line 577 writes strategy: auto into proxy.yaml. The proxy accepts the name — its table does not check providers (Providers field, config/strategy.go) — and auto sets keepalive: true, the same switch the openai 30-min-ping row uses. The proxy then runs refresh pings that spend the user's credential. Startup refuses exactly this: resolveStrategy (index.js:42-47, called at index.js:916) maps auto to none for openai-only and logs why. One preset switch turns on spending that the plugin itself refuses.
    • What fails, case B (proxy down): the user sets a typo option, cacheStrategy: "hourly". Startup runs none and warns. Then preset set high --restart writes strategy: hourly into proxy.yaml. The proxy rejects the unknown name at config load (config: cache: unknown strategy, config/strategy.go:171) and exits. context-guru-start fails, the script prints result=not_applied. But lines 570-575 already killed the old proxy. The project has no proxy until the next OpenCode start, and open sessions send to a dead port.
    • Proof: the valid check at line 556 covers only the key the user set. Lines 560 and 577 pass the other key through with no check. Startup resolves the same value and writes the resolved name (index.js:916-923). The preset side has the same shape: a bogus option preset reaches proxy.yaml the same way. No test covers this: the set --restart test (test/picker.test.mjs:177) routes anthropic only, where auto fits.
    • Fix: run the other key through valid before the render. When it fails, use the value install.env records — writeInstallFacts (index.js:605) writes the resolved strategy — or refuse with result=error. Add a test: openai-only routing, preset set high --restart, proxy.yaml must keep the resolved strategy; a typo option must not leave the proxy down.
  2. opencode-plugin/index.js:14 — the pinned release v0.7.1 does not exist yet, so a fresh install downloads nothing.

    • What fails: I read the GitHub releases list during this review. The newest release is v0.7.0 (2026-11-09T14:53:05Z). downloadBinary fetches .../releases/download/v0.7.1/context-guru_0.7.1_<os>_<arch>.tar.gz (index.js:117-123). The answer is 404. startProxy then throws, the plugin fails open, and routing stays off. Every machine with no proxy on PATH and no managed binary gets a no-op plugin and one error line in the log.
    • The error text in loadStrategyTable (index.js:20) tells the user to remove the old binary so the plugin downloads v0.7.1. That download 404s too.
    • The author's integration run used a proxy built from b49cbeb6, not a release. #987 (the strategies subcommand) is on origin/main at b49cbeb6, so the release can be cut before this PR merges.
    • Fix: cut v0.7.1 from a main that includes #987, before or at merge. Name the merge order in the PR description. No code change.

Earlier findings, re-checked

Reviewer 1 (mine), round 1:

  1. Picker set saves a default for the other setting — fixed (bb9ebe8). set saves only the key it changed (index.js:562). show reads saved, then option, then default (index.js:519-520). effectiveSettings returns the raw request (index.js:895-899). Tests: test/review1.test.mjs:28-68. The restart path still writes the other key; that is new finding 1.
  2. version written unquoted into install.env — fixed. safeVersion keeps only tag characters (index.js:593-595). The update script refuses an odd tag. Both tested.
  3. stopRecordedProxy throws on a missing pid file — fixed (index.js:866-876), tested.
  4. Gateway baseURL and /v1 — kept by the author, reason accepted. The @ai-sdk rule is real, and the troubleshooting doc now names it (docs/how-to/install-opencode-plugin.md: a gateway base must end in /v1 or have no path). I verified the line exists.
  5. Kill guard matches only *context-guru-proxy* — fixed. The scripts match the recorded binary path (index.js:572-573), and stopRecordedProxy matches the path in install.json (index.js:872). Tested with a renamed binary.
  6. No CI for opencode-plugin/ — fixed. .github/workflows/opencode-plugin.yaml, Node 22, path-filtered, node --check and node --test.
  7. uninstall --purge leaves settings.env and scripts — fixed and tested. It keeps context-guru-install, which undoes the uninstall.
  8. Data dependence in the PR body — the author states it is there. The plugin itself keeps only metadata, so I agree no docs/data-dependence.md row is needed.

Reviewer 2, round 1 (checked, not raised again):

  1. Lock stale age shorter than the download — fixed. The download runs before the lock (index.js:905-908). The holder heartbeats every 5 s. A lock untouched for 30 s is stale. startProxy fails when its own child exits (index.js:941-950). Four tests cover it.
  2. No fail-open test — fixed. v1 and v2 tests with a binary that exits at once, plus the two-upstreams error for both generations.
  3. withLock deadline after continue — fixed. The deadline is checked before the retry.
  4. executableOnPath ignores the executable bit — fixed and tested.
  5. Session header without a session id — fixed in v1 and v2, tested.
  6. v2 routedIds timing — fixed. Hooks register from inside the provider callback and check the routed set per request. A test runs the callback late. The author notes no real OpenCode 2 run; that check stays open.
  7. README badge — fixed.

The author's own find, purge deleting an external binary — fixed. The marker must say yes and the file must sit in the state directory. Two tests cover purge and reset.

Non-blocking

  • opencode-plugin/README.md:36 and :55 say the default strategy is auto with no caveat. The install doc has the caveat (docs/how-to/install-opencode-plugin.md:54: if auto does not fit the routed providers, the plugin runs none). Copy that one line into the plugin README.

What I checked

  • Last review: round 1, 1f214ac0c6bd326923644c4c2e4ceddaf1febda2, 2026-11-09T18:55:49Z.
  • New commits read: 2 (8530f14b feat(opencode): read the cache strategy table from the proxy; bb9ebe83 fix(opencode): fix round 1 review findings).
  • Read in full: 2 reviews, 5 comments, 0 inline comments (from the three saved files).
  • New items since my last review: the author's "Round 1 reply" (2026-11-09T19:42:48Z) — I checked every claim against the code, results above; commits 8530f14b and bb9ebe83 — reviewed like a first review, findings 1 and 2.
  • Read the full diff 1f214ac0..bb9ebe83 and the whole files around it: index.js (1161 lines), tui.js, test/review1.test.mjs in full, the diffs of the other test files, .github/workflows/opencode-plugin.yaml, and the three docs.
  • Verified the strategy-table contract against the proxy: read config/strategy.go and the subcommand dispatch from origin/main (b49cbeb6, #987). The JSON shape, the cache.strategy key, the alias map, and the unknown-name config error all match what the plugin expects. #987 is not in this PR's base; it must reach main before the release (finding 2).
  • Checked the table rows by provider: auto, 1-ping, 2-ping, 1-hour-head are anthropic-only; none fits any; 30-min-ping is openai-only. An openai-only install resolves the default to none with a logged reason, as the docs say.
  • Read the GitHub releases list for the tag check (finding 2).
  • Traced the picker script again line by line: fallback chain, save-only-changed-key, kill guard, install.env rewrite, restart order.
  • Did not run the node tests (live tests not approved). No Go builds or tests; Go is not on this machine.

Blocking (both reviewers, round 2):
- "set NAME --restart" wrote the OTHER setting into proxy.yaml
  without the check that startup does. On an OpenAI-only project, a
  preset switch wrote "strategy: auto", which turns on pings that the
  plugin refuses at startup. A typo in an option wrote a name that
  the proxy refuses, and the old proxy was already dead.
- Both keys now come from pick_preset and pick_strategy. A value
  counts only if it is in the preset list or in strategies.tsv (the
  proxy table, after the alias map, filtered to the routed
  providers). The order is: saved, plugin option, what the running
  proxy records, the default.
- The script renders the new file before it touches the old proxy.
  If the new proxy does not start, the old file goes back, the old
  proxy starts again, and the result is not_applied.

Also:
- loadStrategyTable rejects a row without a boolean spends or a
  string desc.
- The TUI toast says the strategy table is missing when the script
  reports that, not that the script is missing.
- The v2 setup no longer logs "no provider is configured" when the
  host runs the provider callback late.
- A 404 for the pinned release says the release is not published.
- Docs: the "auto does not fit" caveat in the plugin README, and the
  v0.7.0 update dead end.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator

Round 2 reply

Head is now 68890abe. It adds one commit on top of bb9ebe83.

Both reviewers blocked on the same new defect in the round 1 fix. It is fixed. The release finding is a merge-order item, not code.

Blocking: set NAME --restart wrote the other setting without the startup check. Fixed in 68890abe.

Both reviewers found this. It is a defect in the round 1 fix.

  • Case A (silent spend). An OpenAI-only project. A preset switch with restart wrote strategy: auto, which turns on pings that the plugin itself refuses at startup.
  • Case B (no proxy). A typo in an option (preset: "hgh", cacheStrategy: "aut0"). The script stopped the old proxy, then wrote the bad name. The new proxy refused to start.

What changed:

  • Both keys now come from pick_preset and pick_strategy. A value counts only if it is in the preset list, or in the strategy table after the alias map and the provider filter. The order is: saved choice, plugin option, what the running proxy records, the default. If the proxy default does not fit, the result is none.
  • The script renders the new file before it touches the old proxy.
  • If the new proxy does not start, the old file goes back and the old proxy starts again. The script prints old_proxy=restored and result=not_applied.
  • I did not add a pre-check for the written values. They can only be valid names, so such a check would never fire. I removed it after a mutation showed that nothing depended on it.

Tests, each one fails when its fix is undone:

  • OpenAI only, preset set high --restart: proxy.yaml keeps strategy: none.
  • Option preset: "hgh", then strategy set 2-ping --restart: the proxy starts with preset: off.
  • Option cacheStrategy: "aut0", then preset set high --restart: the file holds no aut0.
  • A proxy that refuses the new file leaves the old proxy running, with the old file.
  • A name that is not in the table is refused by the script (exit 2), and the old proxy keeps its pid.

I also ran the restart path against the real proxy built from b49cbeb6, for A, B and a refused file. All three pass.

Blocking (reviewer 1, finding 2; reviewer 2, finding 1): v0.7.1 is not released. Kept, no code change.

The pin stays at v0.7.1. The release is a merge-order item. The PR body now has a "Merge order" section: v0.7.1 (with #987) must be released before #483 merges.

Two small changes make the gap clear:

  • A 404 on the pinned release now says: release v0.7.1 is not published yet (HTTP 404); put a v0.7.1 or later context-guru-proxy on PATH, or set CONTEXT_GURU_BIN. A test covers it.
  • Both docs say that /context-guru-update answers "latest" for a v0.7.0 binary until v0.7.1 exists. The update script reads the latest release from GitHub, and the plugin cannot change that answer.

I did not add a release lookup to the error for an old binary. That would add a network call to a failure path.

Non-blocking

  • README caveat (reviewer 1). Fixed. The plugin README says that auto becomes none when it does not fit the routed providers, in both places.
  • Wrong "no provider" log when the callback runs late (reviewer 2). Fixed. The line now says "no provider routed so far; hooks are added if the host lists one later". A test checks that the wrong text is not logged.
  • loadStrategyTable types (reviewer 2). Fixed. A row needs a boolean spends and a string desc. Three bad tables are rejected in a test.
  • tui.js toast (reviewer 2). Fixed. When the script reports no-strategy-table, the toast says the strategy table is missing. When the script itself is missing, it says so.

Checks

  • Tests: 73 pass, 0 fail, three runs in a clean environment.
  • Mutations: every fix above was undone once, and a test failed each time.
  • Not run: a real OpenCode 1 or 2 host, and the real TUI dialogs.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.321 offload-review skill, @amiddavid's session resumed 1 of 2 3 of 3 68890abed3c9 approve

Verdict: approve

The round-2 blocking defect is fixed and tested. The release item is now a named merge-order condition, and I accept the author's reason. One condition on merge: do not merge before release v0.7.1 is published. At review time it is still missing (see below).

Findings

None.

Merge condition (round 2, finding 2 — accepted as merge order, not code)

  • The pin stays at v0.7.1 and the release still does not exist. I checked again during this review: the newest release is v0.7.0, and releases/tags/v0.7.1 answers 404.
  • The author's reason is right: no code change can publish a release, and v0.7.1 is the correct pin, because it is the first release with the strategies subcommand (#987, on origin/main at b49cbeb6).
  • What the PR now does about it: the PR body has a "Merge order" section (verified: release v0.7.1 with #987, then merge #483); a 404 on the pinned download prints release v0.7.1 is not published yet (HTTP 404); put a v0.7.1 or later context-guru-proxy on PATH, or set CONTEXT_GURU_BIN (index.js:128, tested); both docs say a fresh install cannot download its proxy until v0.7.1 exists, and that /context-guru-update answers "latest" for a v0.7.0 binary in the meantime.
  • The merge must wait for the release. That is the whole remaining action.

Earlier findings, re-checked

Round 2, mine:

  1. set NAME --restart writes the other setting into proxy.yaml without the startup check — fixed (68890ab). Both keys now come from pick_preset / pick_strategy (index.js:523-545). A value counts only if it is in the preset list, or in strategies.tsv after the alias map and the provider filter. The candidate order is: saved choice, plugin option, what install.env records, then the default — and the default counts only if it fits the routed providers, else none. I traced every state against the startup path (effectiveSettings + resolveStrategy, index.js:895-918): openai-only with no choice gives none, a typo option falls through to the recorded value, a saved name that stopped fitting falls through too. Same result as startup in each case. The script also renders the new file before it kills the old proxy (index.js:595-599), and on a failed start it puts the old file back and starts the old proxy again (index.js:615-618). context-guru-start writes proxy.pid itself (index.js:466-469), so the restored proxy stays stoppable.
  2. v0.7.1 not released — accepted as merge order, see the section above.

Round 2, reviewer 2 (checked myself, not repeated as findings):

  1. Same restart-path defect, with the preset-typo variant — fixed by the same change. Their extra detail holds: an unknown preset is also a config error that stops the proxy, so the render-before-kill reorder matters for that side too.
  2. v0.7.1 not released, plus the v0.7.0 update dead end — accepted as merge order, same as mine. The dead end is now documented in both docs and the 404 message names the escape.

Round 2, reviewer 2 non-blocking (all in 68890ab):

  • v2 "no provider is configured" log when the callback runs late — fixed, wording now says "routed so far", with a test that the old text is not logged.
  • loadStrategyTable row types — fixed, a row needs a boolean spends and a string desc (index.js:30), three bad tables rejected in a test.
  • tui.js toast for a missing strategy table — fixed, the toast names the table, not the script, with a test for both causes.

Round 2, mine, non-blocking:

  • Plugin README auto-default caveat — fixed, both places now say auto becomes none when it does not fit the routed providers.

Non-blocking

  • index.js:595-618 — if the kill guard fails to stop the old proxy (pid reuse, changed command line), context-guru-start sees the port healthy, prints proxy=already-running, exits 0, and the script reports result=restarted while the old config still runs. Pre-existing shape, not new in this commit, and it needs the recorded-proxy guard to fail. The show path discloses the saved-versus-running gap. Not worth blocking.

What I checked

  • Last review: round 2, bb9ebe837de40caf1e31d9f67f9e37f717e997a9, 2026-11-09T19:55:39Z.
  • New commits read: 1 (68890abe fix(opencode): check the other setting on a picker restart).
  • Read in full: 4 reviews, 6 comments, 0 inline comments (from the three saved files).
  • New items since my last review: reviewer 2's round-2 review (2026-11-09T19:51:49Z) — read in full, both findings and all three non-blocking items checked in code; the author's round-2 reply (2026-11-09T20:20:09Z) — every claim checked against the code, results above; commit 68890abe — full diff, every changed file read around the changes.
  • Read the new picker logic line by line: valid_in, alias_of, pick_preset, pick_strategy (index.js:523-545), the candidate order, the alias map, the provider filter through strategies.tsv, and the default-fits check.
  • Traced the restart flow in order: render to .new, copy to .old, kill, wait for health to die, move, start, and the rollback on failure. Confirmed context-guru-start rewrites proxy.pid (index.js:466-469), so the rollback leaves a stoppable proxy.
  • Read the five new tests in test/review1.test.mjs (openai-only keeps none, preset typo, strategy typo, rollback restores the old file and proxy, refused name exits 2 untouched) and the new pickyProxyBinary helper: it reads --config and refuses unknown names, like the real proxy's strict loader, so the tests exercise the real failure mode.
  • Read the smaller diffs: loadStrategyTable row validation, the 404 message, the v2 log wording, the tui.js toast, and the doc lines in both files.
  • Checked the release state again through the GitHub API: newest release v0.7.0, releases/tags/v0.7.1 → 404. Verified the "Merge order" section exists in the PR body.
  • Did not run the node tests (live tests not approved). The author reports 73 passing with mutation checks; I read the tests instead.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.321 offload-review skill, @amiddavid's session resumed 2 of 2 3 of 3 68890abed3c9 approve

Verdict: approve

Both round-2 findings are resolved. I found no new defect in 68890abe.

Merge condition (not a finding)

The PR must not merge before release v0.7.1 is published. The PR body now says this in its "Merge order" section, and I accept it. I re-checked the releases list during this review: v0.7.1 still does not exist, and the latest release is v0.7.0. So the merge waits for the release, not for more code.

Earlier findings

  • My round-2 finding 1 (pinned release v0.7.1 does not exist): resolved as a merge-order item. The pin stays at v0.7.1 by design. The PR body now states the order: release v0.7.1 (with #987), then merge #483. This is the fix both reviewers asked for; no code change was needed. The failure mode stays fail-open, and the gap is now visible in three places:
    • A 404 on the download says release v0.7.1 is not published yet (HTTP 404); put a v0.7.1 or later context-guru-proxy on PATH, or set CONTEXT_GURU_BIN (index.js:128). A test covers it (review1.test.mjs, "a pinned release that is not published").
    • Both docs say a fresh install cannot download its proxy until v0.7.1 exists, and that /context-guru-update answers "latest" for a v0.7.0 binary.
  • My round-2 finding 2 (set --restart wrote the other setting without the startup check): fixed. I traced the new code line by line:
    • Both keys now come from pick_preset and pick_strategy (index.js:528-543). A value counts only if it is in the preset list, or in strategies.tsv after the alias map and the provider filter. The order is: saved choice, plugin option, the running proxy's record in install.env, the default. A default that does not fit gives none. So case A (OpenAI-only, silent auto) and case B (a typo option) cannot reach proxy.yaml.
    • The script renders the new file before it kills the old proxy (index.js:597). It keeps proxy.yaml.old (index.js:599). If the new proxy does not start, the old file goes back, the old proxy starts again, and the script prints old_proxy=restored and result=not_applied (index.js:614-620). install.env is rewritten only on success (index.js:610-611), so the record keeps describing the proxy that runs.
    • A name not in the table is refused before anything is touched (exit 2, index.js:581).
    • Tests cover all five paths I flagged: OpenAI-only restart keeps strategy: none; a typo preset and a typo strategy each restart cleanly; a refused file leaves the old proxy running with the old file; an unknown name exits 2 with the old proxy untouched. The pickyProxyBinary stub refuses names the way the real proxy does at config load.
  • My round-2 non-blocking items: all fixed. loadStrategyTable rejects a row without a boolean spends or a string desc (index.js:29-30), with a three-case test. The TUI toast names the missing table, not the missing script (tui.js:35-38), with a test. The v2 "no provider" log now says "routed so far", with a test that the old wording is not logged.
  • Reviewer 1's round-2 findings: both match mine. Finding 1 is the same restart defect, fixed as above. Finding 2 is the same release pin, resolved the same way. Nothing to add.

What I checked

  • Last review: round 2, bb9ebe837de40caf1e31d9f67f9e37f717e997a9, 2026-11-09T19:51:49Z
  • New commits read: 1 (68890abe fix(opencode): check the other setting on a picker restart)
  • Read in full: 4 reviews, 6 comments, 0 inline comments (from the three saved files)
  • New items since my last review: reviewer 1's round-2 review (2026-11-09T19:55:39Z, read in full; its two findings are my round-2 findings, both resolved above); the author's round-2 reply (2026-11-09T20:20:09Z, every claim checked in code); commit 68890abe (full diff, and each changed file read around the changes: index.js, tui.js, helpers.mjs, review1.test.mjs, picker.test.mjs, tui.test.mjs, v2.test.mjs, both docs).
  • Re-checked the release state: releases lists v0.7.0 as latest; releases/tags/v0.7.1 answers 404. The PR body's "Merge order" section says v0.7.1 must be released first. Head on the PR is 68890abe, as given.
  • Re-traced the restart flow end to end: candidate validation, alias mapping, render-before-kill, the rollback (file restore, old-proxy restart, install.env untouched on failure), and the wait-for-death loop. Checked that a saved-but-not-applied choice still resolves safely at the next startup, because resolveStrategy validates it there.
  • Checked the pickyProxyBinary stub against the real proxy's behavior: an unknown preset or strategy name is a config error that stops the proxy, so the stub models the failure the rollback must survive.
  • Did not run the node tests (live tests not approved). The author reports 73 passing and mutation checks; I read the tests instead.

- README: add an "OpenCode (experimental)" row to the install table,
  after Codex. The organization cell and its rowspan are the same as
  on main, because docs/hosted.md does not describe OpenCode.
- README: add a short "OpenCode (experimental)" section with the
  install steps, the commands, and how to remove it.
- How-to: add an "Experimental" note at the top, and a known issue for
  the native dialogs (they did not appear in OpenCode 1.19.5).
- Remove the "Until v0.7.1 is released" lines in both docs. v0.7.1 is
  published. The docs now say that v0.7.1 or later is required.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
The first real OpenCode test (1.19.5) found that tui.js loaded and
ran, but its two commands never showed in the ctrl+p palette or in
the slash menu. They registered without an error and stayed hidden.

Cause: the host lists a keymap command only when it has
namespace "palette". It reads the slash name from slashName, not from
slash: { name }. The published types do not list these fields. They
come from the host's own api.command shim, which builds a command as
{ namespace: "palette", name, title, desc, category, slashName, run }.

- tui.js: add namespace "palette" and slashName, and a desc.
- Test: a fake host that lists only commands that have namespace
  "palette" and a string slashName. The old code fails it. Four
  mutations (no namespace, slash object, wrong namespace, no
  category) all fail it.
- Proved in the real TUI under tmux: the palette lists "Context Guru:
  preset" and "Context Guru: cache strategy". The preset entry opens
  the select list ("Context Guru: preset (saved: off)."), then the
  "Switch preset?" confirm, then the "Restart the proxy now?" confirm.
  The choice is saved only after the first yes.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
- Replace the "dialogs did not appear" notes. The dialogs appear in the
  ctrl+p palette in OpenCode 1.19.5. The slash menu lists a chat entry
  and a native entry with the same name; the docs say to use the
  palette for the native dialog.
- Add a troubleshooting entry: a running proxy keeps the key it
  started with. Uninstall, then install, starts a new one.
- Say that --purge leaves the disabled marker and the proxy's
  dashboard.db.accountant-state.json, and that the next OpenCode start
  writes the command scripts again.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Behavior change, approved by the owner on 2026-11-10. Who it affects:
OpenCode plugin users who set DASHBOARD_CONTENT. Old behavior: the
proxy the plugin started followed the environment, so DASHBOARD_CONTENT=1
turned capture on. New behavior: always off. The real v0.7.1 test
showed content_capture=true because the owner's settings set it.

- Every start path gets "--dashboard-content=false" on the command line
  and DASHBOARD_CONTENT=0 in the environment: the first start, the
  recovery spawn, the start script (picker --restart, install, update).
  The flag wins over the environment in the proxy; both are set so no
  path can miss it.
- The recovery spawn also fixes an older install.json that was written
  without the flag.
- No other DASHBOARD_* setting is touched.
- There is no way to turn capture on from the plugin. It cannot attach
  to a proxy the user starts.
- Tests: the stub proxy records its argv and environment. With
  DASHBOARD_CONTENT=1 in the parent, every start path launches with
  capture off. Seven mutations (flag or env removed from each path,
  the helper keeping another value) all fail a test.
- Real check, v0.7.1 binary, DASHBOARD_CONTENT=1 in the environment:
  the log says content_capture=false, and the request_content table has
  0 rows after a 200 request.
- Docs: "The plugin never stores message text; the dashboard shows
  metadata only", in the how-to and both READMEs.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator

Update: real OpenCode test, TUI fix, content capture off

Head is now a0dbd317. Four new commits sit on top of 68890abe.

The 4 new commits

  1. 56722910 docs: mark OpenCode experimental, add short install steps.
    • The README table has an "OpenCode (experimental)" row. The organization cell is the same as on main, because docs/hosted.md does not describe OpenCode.
    • A short install section and a note at the top of the how-to.
  2. 937e7f1c fix: register the TUI pickers the way OpenCode lists them.
    • Problem: tui.js loaded and ran, but its two commands never showed in the palette or the slash menu.
    • Cause: OpenCode 1.19.5 lists a keymap command only with namespace: "palette". It reads slashName, not slash: { name }. The published types do not list these fields.
    • Fix: tui.js now sets both. A unit test uses a fake host with the same rule. Four mutations fail it.
  3. 881b5e95 docs: use the steps that worked in a real OpenCode.
    • The docs say where the native dialog is: ctrl+p, then "Context Guru".
    • New troubleshooting entry: a running proxy keeps the key it started with. Run uninstall, then install.
    • The docs say that --purge leaves the disabled marker and the proxy's dashboard.db.accountant-state.json.
  4. a0dbd317 feat: always start the proxy with content capture off. Behavior change, approved by the owner on 2026-11-10.
    • Every proxy the plugin starts gets --dashboard-content=false and DASHBOARD_CONTENT=0, even when DASHBOARD_CONTENT is set in your environment.
    • This covers the first start, the recovery, and the start script (picker restart, install, update). An older install.json without the flag is fixed at recovery.
    • Seven new tests. Seven mutations fail them.
    • There is no way to turn capture on with this plugin.

Real test evidence

  • OpenCode 1.19.5, released proxy v0.7.1, the plain gateway as the upstream.
  • opencode run "say ok" through the proxy returned ok. The dashboard row has upstream status 200. The proxy log and the row carry the same OpenCode session id.
  • With DASHBOARD_CONTENT=1 in the environment: the proxy log says content_capture=false, and request_content has 0 rows after the 200 request.
  • The TUI under tmux: the palette lists "Context Guru: preset" and "Context Guru: cache strategy". The preset entry opens the select list, then "Switch preset?", then "Restart the proxy now?". The choice is saved only after the first yes.
  • Preset change, strategy change, uninstall (the external binary stays) and fail-open also passed.
  • The two earlier 401 answers came from the test environment (wrong token, then a stale proxy key), not from the plugin.

Checks

Not covered

  • /context-guru-status end to end through the model.
  • OpenCode 2.
  • Which of the two same-named slash entries runs on Enter in the TUI.

Open question

The chat commands and the native commands share the slash names /context-guru-preset and /context-guru-strategy. The owner has not decided: rename the native ones, or drop the chat picker commands when tui.js is present. The names are unchanged.

README.md conflicted with rossoctl#1009 (Pi). The install table now lists
Claude Code, Codex, Pi, OpenCode. The OpenCode row has "Not yet" in the
enterprise column, like Pi. The Pi section stays as on main, and the
OpenCode section follows it in the same shape.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 1 of 2 4 of 4 f2bc703bc667 approve

Verdict: approve

The merge condition is satisfied: release v0.7.1 is published and includes #987. The four new commits fix a real-host defect, document a real OpenCode run, and add an owner-approved behavior change. I found no new defect. One non-blocking note about an upgrade window.

Findings

None.

The round-3 merge condition: satisfied

  • v0.7.1 was published on 2026-11-10T06:51:34Z. I checked the tag through the API.
  • It includes #987: compare/b49cbeb6...v0.7.1 answers ahead, so the strategies subcommand is in the release.
  • The assets include the four context-guru_0.7.1_<os>_<arch>.tar.gz files and checksums.txt that downloadBinary fetches. The extra bob-installer assets from #971 do not interfere.
  • The docs dropped the "until v0.7.1 is released" lines, which is now right.

Earlier findings, re-checked

  • All findings from rounds 1 to 3 are fixed and stay fixed. The new commits touch the same start paths, and the round-3 tests still cover them.
  • Reviewer 2's round-3 review (approve, same conclusions) — read in full; nothing to add.

What the new commits do, checked

  1. 56722910 — docs: mark OpenCode experimental, short install steps. README table restructured (OpenCode row with &mdash; in the organization cell, rowspan adjusted to 2). I checked the HTML stays well-formed. Experimental notes added to all three docs.
  2. 937e7f1c — fix: register the TUI pickers the way OpenCode lists them. OpenCode 1.19.5 lists a keymap command only with namespace: "palette" and reads slashName, not slash: { name }. tui.js now sets both, plus desc. I cannot run a real OpenCode host here, so I checked what I could: the test models the host rule exactly (hostVisible in tui.test.mjs), the legacy api.command fallback keeps its own field shape and has a test, and the owner's comment reports the real-host result — the palette lists both entries and the dialogs work end to end. The defect (registers without error, invisible) matches the code shape before the fix.
  3. 881b5e95 — docs: steps that worked in a real OpenCode. Read in full: the ctrl+p path, the 401-after-key-change troubleshooting entry, and the two files --purge leaves (disabled, dashboard.db.accountant-state.json).
  4. a0dbd317 — feat: always start the proxy with content capture off. Behavior change, and the repo rule needs a human's yes: the owner's comment (2026-11-10T08:40:56Z) states the approval and the date. The change reduces what is stored, and the docs say who it affects (a user with DASHBOARD_CONTENT in the environment) and what changes. I verified the mechanism:
    • The flag exists in the proxy: --dashboard-content with the default from envBool("DASHBOARD_CONTENT", false) (cmd/context-guru-proxy/main.go:159). An explicit --dashboard-content=false overrides the env default, and the plugin also sets DASHBOARD_CONTENT=0 in the spawn environment. Both paths are closed.
    • Every start path applies it: startProxy (flag in args, captureOffEnv() in the spawn, index.js:989-990), recoverProxy (withCaptureOff(record.args ?? []) plus the env, index.js:1047 — an older install.json without the flag is compensated at every recovery), and startScript (env DASHBOARD_CONTENT=0 and the flag baked into the command, index.js:460). The install, update, and picker scripts restart through context-guru-start, so they inherit it.
    • withCaptureOff removes any other --dashboard-content value and adds the flag once; a unit test pins that.
    • test/capture.test.mjs (224 lines, read in full) covers the first start, the recovery after a crash, an old install.json without the flag, the picker restart and the install script, the script text, and the update restart — each with DASHBOARD_CONTENT=1 in the parent environment and a recording stub that logs argv and the env value.
  5. f2bc703b — merge of origin/main. Verified lossless for the plugin: the diff between the merge and a0dbd317 on opencode-plugin/ is empty. The PR's diff against its base 7fd26dcd touches only opencode-plugin/, the two docs, README.md, mkdocs.yml, and the workflow — the 15 main commits the merge brings are main's own reviewed PRs and are not part of what #483 changes. I read their stats and checked the ones the plugin can interact with: #999 adds fields to /api/stats (the picker's running_preset extraction still works, it is additive JSON), #991 and #996 change dash and proxy internals with no CLI change, #971 adds release assets without touching the tar.gz layout.

Non-blocking

  • index.js:980 and 1003 — a start script written by an earlier head of this PR is not rewritten on the early-return path. When the proxy runs and the config matches, startProxy returns at index.js:980 before it writes context-guru-start at index.js:1003. A machine that ran an earlier head keeps the old script, which has no DASHBOARD_CONTENT=0 and no flag. A picker set --restart or /context-guru-install then starts the proxy with the inherited environment, so DASHBOARD_CONTENT=1 turns capture on — the one thing this change says cannot happen. The window is narrow: no released plugin version exists, so only pre-merge test installs can hold an old script, and any config change or recovery rewrites or bypasses it. If wanted, the fix is one line: write the start script before the early return.
  • The two same-named slash entries (chat command and native command, both /context-guru-preset and /context-guru-strategy) are an open question the owner has not decided. The docs disclose it and say to use the palette. Not a defect.

What I checked

  • Last review: round 3, 68890abed3c95fb09dd5d3530b4ad5eb09e340b9, 2026-11-09T20:24:41Z.
  • New commits read: 5 (56722910 docs: mark OpenCode experimental, add short install steps; 937e7f1c fix: register the TUI pickers the way OpenCode lists them; 881b5e95 docs: use the steps that worked in a real OpenCode; a0dbd317 feat: always start the proxy with content capture off; f2bc703b merge origin/main). The merge also brings 15 main commits (7bfd2f42..7fd26dcd); I read their stats and checked the plugin-facing ones, and verified they are outside this PR's diff against its base.
  • Read in full: 6 reviews, 7 comments, 0 inline comments (from the three saved files).
  • New items since my last review: reviewer 2's round-3 review (2026-11-09T20:26:14Z) — read in full, same conclusions as mine, nothing to add; the owner's update comment (2026-11-10T08:40:56Z) — every claim checked against the code, results above, including the real-host evidence and the CI failure it names (pre-existing on main, #1017, no Go code in this PR); the 5 new commits — full diff read, every changed file read around the changes.
  • Verified the capture flag against the proxy source: --dashboard-content exists with the env-derived default (cmd/context-guru-proxy/main.go:159), so the explicit =false wins.
  • Traced every start path for the capture change and read test/capture.test.mjs in full.
  • Verified the merge kept all plugin changes (empty diff on opencode-plugin/ between f2bc703b and a0dbd317) and that the PR diff against its base is plugin-only.
  • Checked the release through the API: v0.7.1 published, contains b49cbeb6 (#987), assets match the downloader's names.
  • Did not run the node tests (live tests not approved). The owner reports 81 passing and seven failing mutations; I read the tests instead. I could not run a real OpenCode host; the owner's comment carries that evidence.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 2 of 2 4 of 4 f2bc703bc667 blocking

Verdict: blocking

One finding, in the new capture-off commit. Everything else in the four new commits and the merge checks out. The round-3 merge condition is satisfied: v0.7.1 is published.

Findings

  1. opencode-plugin/index.js:980 — the capture-off guarantee does not hold for a start script written before a0dbd317, and a healthy proxy keeps that script forever.
    • What fails: an install made by an earlier head of this PR has a context-guru-start without --dashboard-content=false and without DASHBOARD_CONTENT=0. The old script ran [binary, ...args] only; both capture-off mechanisms landed in a0dbd317 (index.js:462). At OpenCode start, startProxy returns early when the recorded proxy is healthy and the config text is unchanged (index.js:980). That return sits before the only line that rewrites context-guru-start (index.js:1003). So the stale script is never refreshed while the proxy stays healthy. Three scripts start the proxy through it: /context-guru-update --yes (index.js:399), the picker set --restart (index.js:622, and the rollback at 631), and /context-guru-install (index.js:322). The restarted proxy inherits the environment of the OpenCode host. With DASHBOARD_CONTENT=1 set, content capture turns on, silently, against the docs' promise "This holds even when DASHBOARD_CONTENT is set in your environment". The next OpenCode start early-returns again, so nothing repairs it.
    • Proof: grep shows context-guru-start is written only at index.js:1003, which the early return at index.js:980 skips. The commit fixed the parallel transition case — an old install.json without the flag gets withCaptureOff at recovery (index.js:1047), with a test — but not the old start script. No test covers a stale start script.
    • Who can hit it: a machine that installed the plugin from an earlier, unreleased head of this PR. The commit message says the owner's settings set DASHBOARD_CONTENT=1, and a real v0.7.1 run before the fix showed content_capture=true — so that machine holds exactly this state. Fresh installs after merge write the new script and cannot hit it.
    • Fix: rewrite context-guru-start on the early-return path too, or run the wrappers as DASHBOARD_CONTENT=0 sh "$STATE/context-guru-start" in the update, install and picker scripts. Add a test: a start script written the old way, a healthy proxy, run the update script, and assert the restarted proxy has capture off.

Non-blocking

  • The chat commands and the native TUI commands share the slash names /context-guru-preset and /context-guru-strategy. The author lists this as an open question, and the docs say to use the palette. The owner should decide before wider release.
  • Reviewer 1's round-3 note stands unaddressed: if the kill guard fails to stop the old proxy, context-guru-start reports already-running and the picker prints result=restarted while the old config runs. Pre-existing shape, needs a guard failure. I agree it is not worth blocking.

Earlier findings and the merge condition

  • Round-3 merge condition (release v0.7.1 before merge): satisfied. v0.7.1 was published 2026-11-10T07:05:05Z with 8 assets. Commit 56722910 removed the "Until v0.7.1 is released" lines from both docs.
  • All findings from rounds 1 to 3, both reviewers: fixed and verified in the earlier rounds. The round-4 commits do not touch the picker logic or the rollback; I re-read them at the new head (line shifts only) and nothing regressed.
  • The a0dbd317 behavior change follows the repo rules. The PR body names it at the top: who it affects, the old and the new behavior, and that there is no opt-out, with the owner's approval dated 2026-11-10. Data dependence is stated; capture off only reduces what is stored.
  • The TUI registration fix (937e7f1c) is sound. The host rule (namespace "palette", slashName) cannot be verified from this repo, but the author read it from the host's own code and proved it in a real OpenCode 1.19.5. The legacy fallback is unchanged and still tested.
  • The merge (f2bc703b) resolves the README conflict correctly. The install table lists Claude Code, Codex, Pi, OpenCode; the OpenCode row has "Not yet" in the organization column, like Pi. The Pi section matches main.
  • The CI failure the author reports is not this PR's. git log 7fd26dc..HEAD -- '*.go' is empty: the PR's own commits touch no Go file. The failing TestDashboardAddsNoRequestLatencyWithContentCapture also fails on main (#1017).

What I checked

  • Last review: round 3, 68890abed3c95fb09dd5d3530b4ad5eb09e340b9, 2026-11-09T20:26:14Z
  • New commits read: 5 (56722910 docs: mark OpenCode experimental, add short install steps; 937e7f1c fix: register the TUI pickers the way OpenCode lists them; 881b5e95 docs: use the steps that worked in a real OpenCode; a0dbd317 feat: always start the proxy with content capture off; f2bc703b Merge origin/main into feat/opencode-plugin). The rest of 68890abe..HEAD came from main through the merge (#987, #977, #982, #968, #971, #991, #992, #996, #999, #981, #1009, #983, #979) — already-merged, already-reviewed main commits; I checked the merge resolution in README.md and mkdocs.yml, and that the merge brings #987 into the base, which the plugin depends on.
  • Read in full: 6 reviews, 7 comments, 0 inline comments (from the three saved files)
  • New items since my last review: reviewer 1's round-3 review (2026-11-09T20:24:41Z, read in full; it approved with the same merge condition, and its non-blocking "already-running" note is re-checked above); the author's update comment (2026-11-10T08:40:56Z, every claim checked: the real-host TUI fix, capture off with real-binary evidence, the CI failure on main's #1017, and the open slash-name question); the four new commits and the merge (full diffs; each changed file read around the changes: index.js, tui.js, capture.test.mjs, helpers.mjs, tui.test.mjs, README.md, both docs).
  • Verified the capture-off mechanics against the proxy: --dashboard-content exists in cmd/context-guru-proxy/main.go:159, with envBool("DASHBOARD_CONTENT", false) as its default, so a command-line flag wins over the environment. The flag predates v0.7.1 (it landed in #58/#649), so the pinned binary accepts it.
  • Traced every proxy start path at the new head: first start (index.js:989-990), recovery (index.js:1047, which also fixes an old install.json), the start script (index.js:462), and the three script consumers of context-guru-start (install index.js:322, update index.js:399, picker restart index.js:622/631). The stale-script hole is finding 1.
  • Read the new capture tests (test/capture.test.mjs, 224 lines) and the recording stub in helpers.mjs: they cover the first start, the recovery, an old install.json, the picker restart, the install script, the update restart, and the reset guard. None covers a start script written before the change.
  • Re-checked the release state: v0.7.1 published 2026-11-10T07:05:05Z, 8 assets.
  • Did not run the node tests (live tests not approved). The author reports 81 passing with mutation checks; I read the tests instead.

@amiddavid

Copy link
Copy Markdown
Collaborator

Reply to round 4, reviewer 2, finding 1 (a start script written before a0dbd317): rejected by the owner.

  • Owner decision (David Amid, 2026-11-10): no OpenCode installation of this plugin exists from an earlier head.
  • No version of the plugin was ever released. Only this PR's own throwaway test folders under /tmp ran earlier heads. No user machine holds an old context-guru-start.
  • A fresh install writes the new script, with --dashboard-content=false and DASHBOARD_CONTENT=0. Both reviewers confirmed that a fresh install cannot hit the gap.
  • So the gap has no one to affect, and the PR does not change for it.

Non-blocking notes:

  • The same-named slash entries (/context-guru-preset, /context-guru-strategy) stay an open question for the owner. The docs say to use the palette.
  • The kill-guard note (from reviewer 1, round 3) is a pre-existing shape. It stays as it is.

Reviewer 1 approved at f2bc703b.

Owner decision, option A. With slashName set, the TUI slash menu
listed /context-guru-preset and /context-guru-strategy twice: the chat
command of the server plugin, and the native command. Now the native
commands are palette-only. The slash names open only the chat commands.

- tui.js: remove slashName (keymap form) and slash (legacy form). Keep
  namespace "palette", title, desc and category.
- Real TUI check (OpenCode 1.19.5, tmux, no model call): the ctrl+p
  palette still lists "Context Guru: preset" and "Context Guru: cache
  strategy" without slashName. The preset entry opens "Context Guru:
  preset (saved: off).". The slash menu lists each name once.
- Test: the fake host lists palette commands with or without slashName,
  and the test asserts that no native command has a slash name, in both
  forms. Four mutations fail it: slashName back, slash back in the
  legacy form, a slash object in the keymap form, a wrong namespace.
- Docs: /context-guru-preset and /context-guru-strategy are the chat
  commands. For the native dialogs, press ctrl+p and search "Context
  Guru". The "two entries" note is gone.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator

Update: native pickers are palette-only

Head is now 6244d0ce. One new commit: fix(opencode): give the native pickers no slash name.

What changed

  • Problem: the TUI slash menu listed /context-guru-preset and /context-guru-strategy twice. One entry was the chat command. The other was the native command.
  • Decision (owner, option A): the slash names open only the chat commands. The native dialogs are in the ctrl+p palette only.
  • Fix: tui.js no longer sets slashName (keymap form) or slash (legacy form). It keeps namespace: "palette", title, desc and category.

Real TUI check (OpenCode 1.19.5, tmux, no model call)

  • The palette still lists "Context Guru: preset" and "Context Guru: cache strategy" without slashName.
  • The preset entry opens the select list "Context Guru: preset (saved: off)."
  • The slash menu lists each /context-guru-* name once: status, update, preset, install, strategy, uninstall.

Tests

  • Unit tests: 81 pass, 0 fail.
  • The fake host lists palette commands with or without slashName. The test asserts that no native command has a slash name, in both forms.
  • Four mutations fail it: slashName put back, slash put back in the legacy form, a slash object in the keymap form, and a wrong namespace.

Docs

  • /context-guru-preset and /context-guru-strategy are the chat commands.
  • For the native dialogs: press ctrl+p and search "Context Guru".
  • The "two entries" note is gone from the README, the how-to and the plugin README.
  • The slash-name item is gone from "Open questions".

Still open

  • The field names namespace and slashName come from reading OpenCode 1.19.5. A later OpenCode may change them.
  • The DCO check fails on one commit from before the takeover (d21ea6d8, no Signed-off-by). The owner decides how to fix it.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.322 offload-review skill, @amiddavid's session resumed 1 of 2 5 of 5 6244d0ce040d approve

Verdict: approve

One new commit. It applies the owner's decision on the slash names. The round-4 split between the reviewers is settled: the owner rejected reviewer 2's finding with a reason I checked and accept. No new defect.

Findings

None.

Earlier findings, re-checked

  • Reviewer 2, round 4, finding 1 (a start script written before a0dbd317 keeps the capture-off promise from holding): rejected by the owner, and I accept the rejection. The owner's comment (2026-11-10T09:38:45Z) states the decision and the reason: no OpenCode installation of this plugin exists from an earlier head. The plugin was never released. Only throwaway test folders under /tmp ran earlier heads, so no machine holds an old context-guru-start. A fresh install writes the new script with the flag and the env set. I checked what I can check:
    • The code trace is the one I gave in round 4 as a non-blocking note: the early return at index.js:980 sits before the start-script write at index.js:1003, and the install, update, and picker scripts restart through context-guru-start. Reviewer 2 and I agree on the mechanics.
    • The reason is a statement about which machines exist, and only the owner can know it. I cannot show it is wrong. It also matches my own round-4 severity call: I marked the same trace non-blocking because no released version exists, so only pre-merge test installs could hold an old script. The owner now says none do, as persistent installs.
    • The boundary stays as written in round 4: every script this code writes carries the flag, and the docs' promise holds for all of them. The rejection rests on "no old script exists anywhere", not on the code.
  • My round-4 non-blocking item (two same-named slash entries): fixed by 6244d0ce. See below.
  • My round-3 kill-guard note (a failed kill can make the picker print result=restarted while the old config runs): the owner keeps it as it is. Pre-existing shape, needs a guard failure. Agreed.
  • All findings from rounds 1 to 3, both reviewers: fixed and unchanged. The new commit touches no proxy-start path.

What the new commit does, checked

6244d0ce — fix: give the native pickers no slash name. Owner decision, option A.

  • tui.js removes slashName from the keymap form and slash: { name } from the legacy form. It keeps namespace: "palette", title, desc, category. So the native pickers show only in the ctrl+p palette, and /context-guru-preset and /context-guru-strategy open only the chat commands of the server plugin. Each slash name lists once.
  • I checked for leftovers: no reference to the removed slash field of KINDS remains in tui.js or index.js. The chat commands still register the six /context-guru-* names; that code is untouched.
  • The tests model the host rule both ways: hostVisible collects palette commands with or without a slashName, and the test asserts the slash list is empty and that no command carries slashName or slash in either form. Four mutations are named for it. The legacy-form test asserts the same absence.
  • I cannot run a real OpenCode host. The owner's comment (2026-11-10T09:47:17Z) carries the real check: OpenCode 1.19.5 under tmux, the palette lists both entries without slashName, the preset entry opens the select list, and the slash menu lists each /context-guru-* name once.
  • The docs match the code in all three places: the slash names are the chat commands, the native dialogs are in the palette, and the "two entries" note is gone.

Non-blocking

  • The DCO check fails on d21ea6d8 (the update comment names it; I verified: the commit is in the PR history, by the original author, with no Signed-off-by line). The repo requires a sign-off on every commit. The owner decides how to fix it before merge; GitHub's own check holds the merge until then, so it needs no change from this review.
  • The namespace and slashName field names come from reading OpenCode 1.19.5's bundled code, and the published types do not list them. A later OpenCode may change them. The plugin is marked experimental and the docs say which version it ran in. Acceptable.

What I checked

  • Last review: round 4, f2bc703bc667a3d947a522fbcde74b33dd7b02e8, 2026-11-10T08:50:50Z.
  • New commits read: 1 (6244d0ce fix(opencode): give the native pickers no slash name).
  • Read in full: 8 reviews, 9 comments, 0 inline comments (from the three saved files).
  • New items since my last review: reviewer 2's round-4 review (2026-11-10T08:51:44Z, blocking) — read in full, and its finding traced again at the new head (index.js is unchanged between f2bc703b and 6244d0ce: early return at 980, start-script write at 1003); the owner's rejection comment (2026-11-10T09:38:45Z) — reason checked as above; the owner's update comment (2026-11-10T09:47:17Z) — every claim checked, including the DCO fact; commit 6244d0ce — full diff read, tui.js and index.js grepped for leftover slash references (none).
  • Verified the PR diff against its base is still plugin-only (15 files, all under opencode-plugin/, the docs, README.md, mkdocs.yml, the workflow).
  • Verified the DCO claim: git log -1 d21ea6d8 shows no Signed-off-by, and the commit is an ancestor of the head.
  • Did not run the node tests (live tests not approved). The owner reports 81 passing with four failing mutations for the new test; I read the tests instead. I could not run a real OpenCode host; the owner's comment carries that evidence.

@amiddavid
amiddavid merged commit 407d9d1 into rossoctl:main Nov 10, 2026
9 of 10 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 10, 2026
amiddavid added a commit that referenced this pull request Nov 11, 2026
…0.2.12, Pi 0.1.1)

Claude Code plugin 0.6.7 -> 0.7.2:
- #981, #989, #1018, #1035: subscription band and savings show saved tokens.
- #1038: insights drop the finding that credits a user's own removal.
- #1039, #1040: dash and keep-alive fixes that touch the plugin files.

Codex plugin 0.2.11 -> 0.2.12:
- #1051: read the cache strategies and presets from the proxy.
- The vendored cg.py gets the same plugin changes.

Pi package 0.1.0 -> 0.1.1:
- #1010: chain the proxy in front of an existing base URL.
- #1011: check the proxy at session start and restart it once.
- #1049, #1058: write the cache strategy by name; review fixes.

OpenCode plugin (#483): new in v0.7.2, no version file, not changed.
Bob plugin 0.1.0: no change since v0.7.1, not changed.

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
amiddavid added a commit that referenced this pull request Nov 11, 2026
Bump the plugin versions for v0.7.2.

- Claude Code plugin 0.6.7 -> 0.7.2: #981, #989, #1018, #1035 (savings
  in tokens on a subscription), #1038, #1039, #1040, #1055 (cache
  strategies read from the proxy).
- Codex plugin 0.2.11 -> 0.2.12: #1051 (cache strategies and presets
  read from the proxy), plus the vendored cg.py changes.
- Pi package 0.1.0 -> 0.1.1: #1010, #1011, #1049, #1058, and the #1040
  README line.
- OpenCode plugin: new in v0.7.2 (#483), no version file. Its first
  start now downloads proxy v0.7.2 (was v0.7.1). Nothing compares
  against PINNED_VERSION; the floor stays "v0.7.1 or later". The README
  lines, the install guide and 3 tests follow.
- Bob plugin: 0.1.0, no change since v0.7.1.

Behavior change: the OpenCode plugin's first download is proxy v0.7.2,
not v0.7.1. Owner's yes, 2026-11-11, in the integrator session: "option1
it is"; the version bumps: "I approve the version bumps for the
plugins".

Data dependence: none.

Reviews: 3 offload review rounds (GLM; round 3 pre-approved by the
owner). Both reviewers approve at 3cf6176, which is the PR head.

Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants