opencode-linkMessaging channel bridge for OpenCode — interact with your AI coding session from Discord, Slack, and more
0
29
近 7 天 6
23.8
生态多维模型
3 个月前
2026-05-11
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-link@0.1.23"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-link@0.1.23"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-linkopencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
Messaging channel bridge for OpenCode. Control your AI coding session from Discord, Slack, or Telegram.
Features
- Send prompts to OpenCode from your messaging channel, get AI responses in real-time
- Real-time streaming — watch AI responses update live in the channel
- Slash commands — control sessions from the channel (
/status,/sessions,/abort, etc.) - Permission requests — approve/deny AI actions directly from the channel
- File attachments — send files to OpenCode from the channel
- Session management — auto-pairs with active session, or creates a new one
Quick Start
npx opencode-link
The interactive setup wizard will guide you through selecting a provider and entering credentials. Then:
opencode
Send a message in your channel to start a session.
Discord Setup
1. Create a Discord Application
- Go to Discord Developer Portal
- Click New Application → name it → Create
- Go to Bot → click Reset Token → copy the token (
botToken) - Enable Message Content Intent (Bot → Privileged Gateway Intents)
- Go to OAuth2 → URL Generator:
- Scopes:
bot - Permissions:
Send Messages,Send Messages in Threads,Read Message History,Use Slash Commands
- Scopes:
- Open the generated URL → invite the bot to your server
2. Get the Channel ID
Enable Developer Mode: Discord Settings → Advanced → Developer Mode. Right-click the target channel → Copy Channel ID (channelId).
3. Run setup
npx opencode-link
Select Discord, enter your Bot Token and Channel ID.
Slack Setup
1. Create a Slack App
- Log in to your Slack workspace at slack.com
- Go to api.slack.com/apps → Create New App
- Choose From scratch (or From a manifest)
- Name the app and select your workspace
2. Enable Socket Mode
- Go to Basic Information → scroll to App-Level Tokens
- Click Generate Token and Scopes
- Name it (e.g. "socket") → add
connections:writescope → Generate - Copy the
xapp-...token (appToken)
3. Configure Bot Scopes & Install
- Go to OAuth & Permissions → Bot Token Scopes → add:
chat:writechat:write.publiccommandschannels:history(for public channels)groups:history(for private channels)
- Click Install to Workspace → authorize
- Copy the
xoxb-...Bot User OAuth Token (botToken)
4. Enable Event Subscriptions
- Go to Event Subscriptions → toggle Enable Events ON
- Under Subscribe to bot events → add:
message.channels(public channels)message.groups(private channels)
- Important: After adding scopes/events, go back to OAuth & Permissions → reinstall your app
5. Create Slash Command
- Go to Slash Commands → Create New Command
- Command:
/opencode→ Request URL: any placeholder (Socket Mode doesn't use it) - Save
6. Invite Bot to Channel
In the target channel, run:
/invite @your-bot-name
7. Run setup
npx opencode-link
Select Slack, enter your Bot Token (xoxb-...), App-Level Token (xapp-...), and Channel ID.
How to get the Channel ID
Right-click the channel name in Slack → Copy Link. The ID is the last part of the URL, e.g. C0ABC123DEF. Alternatively, right-click the channel → Open channel details → scroll to the bottom.
Telegram Setup
1. Create a Telegram Bot
- Open Telegram → search for @BotFather
- Send
/newbot→ follow the prompts to name your bot - Copy the provided bot token (
botToken)
2. Get the Chat ID
- Add the bot to your group or open a direct message with it
- Send a message to the bot/group
- Visit:
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates - Find
"chat":{"id": ...}in the response — that's yourchannelId
3. Run setup
npx opencode-link
Select Telegram, enter your Bot Token and Chat ID.
Permissions
When OpenCode needs approval for an action, interactive buttons appear in the channel:
- Accept — allow once
- Accept Always — allow permanently
- Deny — reject (auto-denied after 5 minutes)
Configuration
Config is stored in .opencode/opencode-link.json:
{
"provider": "discord",
"botToken": "your-bot-token",
"channelId": "your-channel-id"
}
For Slack, an additional field is required:
{
"provider": "slack",
"botToken": "xoxb-...",
"appToken": "xapp-...",
"channelId": "C0..."
}
This file is auto-added to .gitignore.
Development
npm install # Install dependencies
npm run build # Build once
npm run dev # Watch mode (auto-rebuild on changes)
bun test # Run tests
bun run lint # Lint check
bun run fmt # Auto-format code
bun run check # Run all checks (test + lint + format + typecheck + build)
npm run setup:dev # Set up local dev environment
Contributing
See CONTRIBUTING.md for guidelines. All PRs require passing CI checks before merge.
License
MIT