Repository navigation
Conversation
OpenCode V2 requires a plugin's default export to have an `id` plus a
`setup` (or `effect`) function. This package only exported the V1
`{ id, server }` shape, so it failed to load on V2 with:
Plugin must export a default definition with an id and an effect or
setup function.
V2 also renamed or restructured every server endpoint this plugin
uses (session creation/messages/prompt, the permission reply
endpoint, and the SSE event stream), so a V2 `setup()` cannot just
call the existing V1 `server()` body unchanged.
This adds a `createV2Backend`/`createV1Backend` pair implementing a
shared `SlackAgentBackend` interface, and ports `handleMessage`,
`syncAssistantMessagesSinceCursor`, and `handleCommand` to it instead
of calling `pluginClient` directly. The package now default-exports
both a V2 `setup()` and the original V1 `server()`, following
OpenCode's documented dual-support pattern, so it keeps working on V1
hosts.
Known gaps on V2 (see README "OpenCode V2" section):
- Replying to the agent's `question` tool from Slack is not supported;
the V2 plugin API has no reachable way to answer it.
- Plan/todo updates render as a generic tool-progress line instead of
a formatted checklist (V2 removed the `todo.updated` event).
- `!agent`/`@agent` overrides switch the session's agent going
forward instead of applying to one message only.
Also:
- Added a `slack_test_prompt` debug tool that exercises session
creation, prompting, and turn-event handling without a Slack
connection, for verifying this plugin against a real server.
- Removed the unused `better-sqlite3` dependency (not referenced
anywhere in `src/`); its native build fails under newer Node
versions and was blocking `npm install` for development.
Fixes leecoder#13
By default, the plugin forwards every OpenCode tool call to Slack as a `🔧 _<tool> <args>_` progress line, and every reasoning block as a `💭 <snippet>` message, so a chatty session (lots of shell/read/grep calls, or a thinking model) floods the Slack thread. Users have asked for a way to silence these without losing the actually useful messages: final assistant replies, the agent's `question` prompts, permission requests, and background-task notices. This adds a `QUIET_TOOL_CALLS` plugin option (and `SLACK_QUIET_TOOL_CALLS` env var fallback, matching the convention of the other options). When set to `"true"` or `"1"`, `initializeRuntime` flips a module-level `quietToolCalls` flag, and the two `slackSend` calls in the event loop that produce the 🔧 and 💭 messages are gated on `!quietToolCalls`. All other flows are untouched: - `question`-tool forwarding to Slack still happens - `permission.asked` prompts still forward - `collectBackgroundTaskIds` / 🧵 bg-task notices still fire - Final assistant messages still post via the normal syncAssistantMessagesSinceCursor path - `seenParts` dedupe keys are still added, so flipping the option at runtime (next initialize) behaves predictably Default is off (`false`), so existing installs see no behavior change. README's options table has a new row for `QUIET_TOOL_CALLS`, and the "Real-time Streaming" feature bullets now note the option.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
QUIET_TOOL_CALLSplugin option (andSLACK_QUIET_TOOL_CALLSenv fallback) that silences the two most chatty event-stream echoes to Slack:🔧 _<tool> <args>_— the per-tool progress line💭 <snippet>— reasoning blocks from models that expose themA typical OpenCode session runs dozens of shell/read/grep/edit tool calls; forwarded one-per-line to a Slack thread, this drowns out the actually useful output. In Slack threads an engineer is watching passively (not driving the session), only the final assistant reply, question prompts, permission prompts, and background-task notices matter — and all four of those are preserved.
Default is
"false", so existing installs see no behavior change.Dependency
This PR is stacked on #14 (OpenCode V2 plugin API compatibility). It branches from
fix/opencode-v2-plugin-compatibilitybecause the quiet-mode gates live in the shared event loop that #14 feeds from both the V1 and V2 backends. Please merge #14 first; GitHub will auto-rebase this PR's diff view againstmainonce #14 lands, and the commit here will apply cleanly on its own.Until #14 merges, the diff on this PR shows both #14's changes and the quiet-mode change. The
feat: add QUIET_TOOL_CALLS…commit (e48730e) is the only change new to this PR.What changed
src/plugin.ts:quietToolCallsboolean (defaults tofalse).initializeRuntimereadsoptions?.QUIET_TOOL_CALLSfirst, thenprocess.env.SLACK_QUIET_TOOL_CALLS, accepting\"true\"or\"1\". Logs a one-line notice when quiet mode is on, matching the style of theattach timeout/default agent/allowed userslog lines.slackSendcalls in the event loop that produce the 🔧 and 💭 messages are now gated on!quietToolCalls.seenParts.add(evt.id)still runs either way, so dedupe keys stay consistent across runtime flips.question-tool forwarding,permission.askedprompts,collectBackgroundTaskIds/ 🧵 bg-task notices,syncAssistantMessagesSinceCursor(final assistant reply).README.md:Testing
Summary by cubic
Adds OpenCode V2 support alongside the existing V1 plugin API, and introduces a
QUIET_TOOL_CALLSoption to mute per-tool and reasoning echoes in Slack.OpenCode V2 support
serverand V2setupentrypoints, following OpenCode's dual-support pattern.SlackAgentBackendinterface translates each version's wire shapes into a common turn-event stream;handleMessage,handleCommand, and sync logic use it instead of callingpluginClientdirectly.slack_test_promptdebug tool that exercises session creation and turn handling without a Slack connection, logging to/tmp/slack-agent-plugin.log.questiontool from Slack is unsupported, and plan/todo updates render as generic tool lines instead of a formatted checklist.better-sqlite3dependency, which was blockingnpm installon newer Node versions.QUIET_TOOL_CALLS
SLACK_QUIET_TOOL_CALLSenv fallback) suppresses the 🔧 tool-call progress lines and 💭 reasoning snippets posted to Slack threads."true"or"1"to enable.Written for commit e48730e. Summary will update on new commits.