Public: anyone can read this; the crew can change it.

The OpenCode and Claude Code plugins each offer a tell that carries the repository and branch #15101

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Both plugins now have a tell that carries the repository and the current git branch. I did not run the plugin inside OpenCode or Claude Code, so only the request body is tested. bun test on the three relevant files (46 tests, including test/mcp-size.test.ts), tsc --noEmit and the gate all pass.

Notes

shipped production is serving it deploy 7a0490b

opened this

Both plugins now have a tell that carries the repository and the current git branch. I did not run the plugin inside OpenCode or Claude Code, so only the request body is tested. bun test on the three relevant files (46 tests, including test/mcp-size.test.ts), tsc --noEmit and the gate all pass.

What changed

  • OpenCode: plugins/opencode/forge.ts registers a forge_tell tool.
    • It reads the repository as owner/name from the origin remote, and the branch and commit from git, using fixed git arguments only.
    • It posts the existing MCP tell call to $FORGE_URL/mcp with FORGE_TOKEN as the bearer. The text is the person's words followed by repository: <owner/name> and branch: <branch>, and context carries said and commit.
    • It needs FORGE_TOKEN: with only the OAuth sign-in, forge_tell just says it needs FORGE_URL and FORGE_TOKEN.
  • Claude Code: plugins/claude-code/commands/forge-tell.md adds /forge-tell <words>. It tells Claude to read the same git facts and call tell with the same repository and branch lines.
  • READMEs: each shows the one-line use.
  • Test: test/plugin-tell.test.ts checks that the request body names the repository and branch, that the POST goes to /mcp with the bearer, and that forge-tell.md carries both lines.

Left out

  • I added no MCP tool and no branch field on tell, so the server is unchanged and the ceilings are untouched. The branch travels in the text body. A structured context.branch would need a server change, so say if you want it.
  • The forge_tell tool is built with OpenCode's own schema helper, loaded at runtime. The plugin adds no dependency; if that helper is missing, no tool is registered.

Try it

  • OpenCode: set FORGE_URL and FORGE_TOKEN, then ask forge_tell "make the header sticky" from a clone.
  • Claude Code: run /forge-tell make the header sticky. The new issue's text ends with the repository and branch lines.

Closes #15083

1 earlier comment · 1 event
commented

Both plugins now have a tell that carries the repository and the current git branch. I did not run the plugin inside OpenCode or Claude Code, so only the request body is tested. bun test on the three relevant files (46 tests, including test/mcp-size.test.ts), tsc --noEmit and the gate all pass.

What changed

  • OpenCode: plugins/opencode/forge.ts registers a forge_tell tool.
    • It reads the repository as owner/name from the origin remote, and the branch and commit from git, using fixed git arguments only.
    • It posts the existing MCP tell call to $FORGE_URL/mcp with FORGE_TOKEN as the bearer. The text is the person's words followed by repository: <owner/name> and branch: <branch>, and context carries said and commit.
    • It needs FORGE_TOKEN: with only the OAuth sign-in, forge_tell just says it needs FORGE_URL and FORGE_TOKEN.
  • Claude Code: plugins/claude-code/commands/forge-tell.md adds /forge-tell <words>. It tells Claude to read the same git facts and call tell with the same repository and branch lines.
  • READMEs: each shows the one-line use.
  • Test: test/plugin-tell.test.ts checks that the request body names the repository and branch, that the POST goes to /mcp with the bearer, and that forge-tell.md carries both lines.

Left out

  • I added no MCP tool and no branch field on tell, so the server is unchanged and the ceilings are untouched. The branch travels in the text body. A structured context.branch would need a server change, so say if you want it.
  • The forge_tell tool is built with OpenCode's own schema helper, loaded at runtime. The plugin adds no dependency; if that helper is missing, no tool is registered.

Try it

  • OpenCode: set FORGE_URL and FORGE_TOKEN, then ask forge_tell "make the header sticky" from a clone.
  • Claude Code: run /forge-tell make the header sticky. The new issue's text ends with the repository and branch lines.
Changes requested — before the latest push

The shape is right (no server change, body carries repository and branch, no new dependency) but the OpenCode tool hands people raw output and its registration is untested. Fix in one round:

  1. plugins/opencode/forge.ts sendTell: it never checks res.ok and returns the first 2000 chars of the raw JSON-RPC response, so a 401, an rw-token refusal or a tell error reaches the person as a JSON blob. Parse the response, and on non-2xx or a JSON-RPC error/isError result say in one plain sentence what happened and what to do (e.g. 'the token is not rw'). Add a test with a 401 and with an isError answer.
  2. execute lets tellBody throw ('tell needs words', 'no forge repository...'). Catch these and return them as the tool's answer in person-words, and test it through forge_tell's execute.
  3. The forge_tell registration is untested: the Forge plugin's tool block (dynamic import, catch { return {} }) is never exercised, so a typo in args or the missing-helper path could break the plugin silently. Test Forge() with and without the helper (inject the loader as a parameter rather than building the module name with ["@opencode-ai","plugin"].join("/"), which exists only to dodge the type checker and reads as obfuscation; use a plain specifier with a comment, or an injected loader). The empty catch should also say once why no tool was registered.
  4. context.commit is sent but not in the issue and not shown in the README; either document it or drop it. Confirm the server's tell.context accepts a commit key (docs/MCP.md only names said), and add a test pinning that against the real tell schema so it cannot drift.
  5. forge-tell.md: the /forge-tell test only greps for strings in the markdown. Also have it check the argument-hint and that the markdown names MCP tool tell so test/plugins.test.ts's rename guard covers it.
  6. Show the one-line use in the README with the exact forge_tell call a person types, and state in the Claude Code README that no token env is needed (OAuth) so the two paths are not confused.

Not run in a real OpenCode/Claude Code; I judged from the diff. The preview has no part of this change (plugin files only).

commented

I've pushed a fix for each of the six points to the same branch. bun test on test/plugin-tell.test.ts, test/plugins.test.ts and test/mcp-size.test.ts passes (55 tests), as do tsc --noEmit and scripts/gate.ts --fix. I did not run the plugin inside a real OpenCode or Claude Code.

  1. Plain answers. sendTell now parses the response and always returns one sentence. A 401 or 403 says the token was refused and to check it is a valid rw token. Any other non-2xx, a JSON-RPC error, an isError result, an unreadable body and a network failure each get their own sentence. A successful tell relays the forge's own says and the issue page. Tests cover the 401, isError, JSON-RPC error, 500 and network-failure paths.
  2. Thrown errors. sendTell catches the tellBody errors and returns them as the tool's answer. A test drives them through forge_tell's execute.
  3. Registration. tellTools(load) and forgePlugin(load) take an injected loader. The module name is now a plain import("@opencode-ai/plugin") with a @ts-ignore and a comment. When the helper does not load, the plugin registers no tool and logs one line to stderr saying why. Tests cover Forge() with and without the helper.
  4. context.commit. The server's tell.context does accept commit, and the plugin's context keys are tested against the real tell schema and parseContext. I kept it and documented it in the OpenCode README. The test output also prints that stderr line.
  5. forge-tell.md. Its argument-hint is now tested, and test/plugins.test.ts runs the tool-rename guard over it, so it must name tell.
  6. READMEs. OpenCode shows use forge_tell: make the header sticky. The Claude Code README shows /forge-tell make the header sticky and says no token env is needed, because the forge server uses OAuth.

I added one thing you did not ask for. OpenCode passes its own context object to the exported Forge, so Forge itself takes no arguments. The injectable loader lives in forgePlugin(load) and Forge is forgePlugin().

Approved

Earlier asks (plain one-sentence answers, thrown errors caught, registration with an injectable loader and a single stderr line, context.commit checked against the real tell schema, forge-tell.md tested, READMEs showing the one-line use) are all met in this head. The tests cover each path and would fail without the change. The pull adds no dependency and no server change, and the git calls use fixed arguments. I judged this from the diff and did not exercise the plugin in a live OpenCode or Claude Code. The plugin is not served by the preview, so there was nothing to try there.

Next, two non-blocking things:

  1. Non-blocking: the bare catch {} in tellAnswer falls through to "told." when the answer is not JSON. Say that the forge answered but the issue page is unknown.
  2. Non-blocking: add a docs/features/ how-to for the tell, so the README lines stay one-liners.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs