Skip to content

Architecture

Layers

Layer Where Does
Entry src/index.ts One register call: gate the host, read the options, register the accounts, hand over the handler table.
Manifest package.json capabilities Every method, source and event. src/manifest.ts reads it from the installed package.
Accounts src/accounts.ts The global Slack-app sign-in, one MCP server per alias, the alias's scopes and redirect.
Scopes src/scopes.ts The person's sign-in choice, the scopes it asks for, and the shortfall of a scope it does not hold.
Provider src/provider/ The two endpoints, the MCP tool call and the Web API call.
Handlers src/handlers/ One file per method or planned write, every provider call behind SlackProvider, and Slack's two answer shapes parsed into contract events.
Skills skills/slack/, skills/slack-search/ The main skill (accounts, access, errors) and the search/read workflow.

src/index.ts never adds a tool, an RPC method or a permission rule. register reads the manifest and the handler table, and wires the agent tool, Code Mode, the RPC and the bus from them. The access rules are generated from access and each method's class and effect; nothing is hand-written.

The provider

Two ways into Slack, both with the account's own sign-in:

  • The vendor's MCP tools. events_list, thread_read, direct_thread_read and channels_list run slack_read_channel, slack_read_thread and slack_list_user_channels through the host's executor for <server>_<tool>, with the caller's own context. The person's rules for that tool apply to the inner call, and the plugin never sees the MCP credential.
  • Slack's Web API. probe, mentions_list, direct_list, mark_read, channel_invite and the three actions call auth.test, assistant.search.context, conversations.mark, conversations.invite, chat.postMessage, chat.delete, conversations.open, conversations.info, conversations.replies, users.info and files.completeUploadExternal at https://slack.com/api/. They resolve the alias's MCP sign-in through ctx.integration.connection (OpenCode refreshes it near expiry) and put the access token in one Authorization header. src/provider/web.ts is the only module that reads it; it is never returned, stored, logged or put in an error.

The two endpoints are named once, in src/provider/endpoints.ts.

What is cached

Nothing. There is no plugin-side cache, no polling and no background work: every answer is read at the call, and every cursor belongs to the caller. src/provider/slack.ts keeps a fake-friendly interface and no mutable state beyond the provider context.

The one piece of setup state is the registered accounts: at setup the plugin resolves the Slack app's client ID and registers one server per alias. A client ID pasted in /connect afterwards takes effect on the next OpenCode start, which is why status names it as a problem until the servers carry it.

OpenCode APIs

Only the public plugin context of @opencode/plugin 2.4.1:

API For
ctx.app.version The host gate (assertHost) and status.
ctx.options The plugin's options.
ctx.integration.transform The global slack-app client-ID entry.
ctx.integration.connection The alias's sign-in: active, resolve, status.
ctx.mcp.transform One Slack server per alias.
ctx.tool.list The alias's own Slack tool, for the plugin's reads.
ctx.agent.transform Generated by register's applyAccess.
ctx.permission.assert Called by register for every door.
ctx.rpc.register One registration, id slack, carrying the methods and the bus events.
ctx.command.transform The /slack status command, which renders the same statusOf answer as the method.

The TUI status dialog of v0.0.7 is gone: the contract's status method (a tool, Code Mode and RPC) and the /slack command show the same answer, so a dialog would duplicate a second UI surface.