OpenCode 插件生态完整指南:从零到生产力的配置方案
OpenCode 插件生态完整指南:从零到生产力的配置方案
本文由 AI 助手 Sisyphus 整理 | OpenCode 2026 版本
一、OpenCode 简介
OpenCode 是一个开源的 AI 编程助手框架,支持通过插件(Plugins)、MCP 服务器(MCP Servers)和技能(Skills)进行扩展。本文将详细介绍如何打造一个完整的 AI 编程环境。
二、MCP 服务器配置(7个)
2.1 通用配置
在 ~/.config/opencode/opencode.json 中配置:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"[name]": {
"command": ["cmd", "/c", "npx", "-y", "[package]"],
"enabled": true,
"type": "local"
}
}
}
2.2 推荐的 MCP 服务器
|
|
|
|
|
|---|---|---|---|
|
|
chrome-devtools |
|
|
|
|
context7 |
|
|
|
|
fetch |
|
|
|
|
memory |
|
|
|
|
sequential-thinking |
|
|
|
|
time |
|
|
|
|
mem0 |
|
|
2.3 mem0 详细配置
# 1. 添加到 opencode.json
{
"mcp": {
"mem0": {
"command": ["cmd", "/c", "npx", "-y", "mem0ai/mem0"],
"enabled": true,
"type": "local"
}
}
}
# 2. 创建 ~/.config/opencode/mem0.jsonc
{
"OPENAI_API_KEY": "m0-your-api-key"
}
mem0 vs Supermemory 对比:
|
|
|
|
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
三、插件配置(11个)
3.1 通用配置
{
"plugin": [
"[plugin-name]"
]
}
3.2 完整插件列表
|
|
|
|
|
|---|---|---|---|
|
|
oh-my-opencode |
|
|
|
|
opencode-pty |
|
|
|
|
@nick-vi/opencode-type-inject |
|
npm install -g @nick-vi/opencode-type-inject |
|
|
opencode-supermemory |
|
npm install -g opencode-supermemory |
|
|
opencode-morph-fast-apply |
|
|
|
|
opencode-browser |
|
npm install -g opencode-browser |
|
|
opencode-arise |
|
npm install -g opencode-arise |
|
|
@mohak34/opencode-notifier |
|
npm install -g @mohak34/opencode-notifier |
|
|
@plannotator/opencode |
|
npm install -g @plannotator/opencode |
|
|
@tarquinen/opencode-dcp |
|
npm install -g @tarquinen/opencode-dcp |
|
|
@zenobi-us/opencode-skillful |
|
|
3.3 插件详细说明
3.3.1 opencode-morph-fast-apply
{
"plugin": [
"github:JRedeker/opencode-morph-fast-apply"
],
"instructions": [
"~/.config/opencode/node_modules/opencode-morph-fast-apply/MORPH_INSTRUCTIONS.md"
]
}
Morph vs 原生 edit:
|
|
|
|
|---|---|---|
|
|
edit |
|
|
|
edit |
|
|
|
morph_edit |
|
|
|
morph_edit |
|
|
|
morph_edit |
|
使用示例:
// ❌ 错误 - 没有标记会删除代码
functionnewFeature() {
return"hello";
}
// ✅ 正确 - 使用懒标记
// ... existing code ...
functionnewFeature() {
return"hello";
}
// ... existing code ...
关键规则:
-
必须使用 // ... existing code ...标记 -
否则会删除代码 -
描述要具体:”I am adding error handling for null users” 比 “Update code” 更好
3.3.2 opencode-arise(影子军团)
并行派生出多个轻量级从属代理处理任务:
# 后端 + 测试 + 文档同时写
使用场景:
-
一个代理写后端 API -
一个代理写测试用例 -
一个代理写文档 -
大幅缩短大型任务的等待时间
3.3.3 @tarquinen/opencode-dcp(动态上下文裁剪)
# 清理大量测试输出
discard:
message: "Tests passed, keeping summary"
# 蒸馏长对话
extract:
model: "gemini-1.5-flash"
maxWords: 500
核心功能:
-
discard– 清理已完成任务的工具输出 -
extract– 调用轻量级模型蒸馏对话为关键决策
3.3.4 @plannotator/opencode(可视化计划审查)
{
"plugin": ["@plannotator/opencode@latest"]
}
功能:
-
可视化注释(不是纯文本) -
在浏览器中选择文本,添加删除/替换/评论 -
本地运行,隐私安全 -
支持 Obsidian 集成
使用方法:
submit_plan:
plan: "I will add a new user authentication module..."
3.3.5 @zenobi-us/opencode-skillful(技能系统)
# 安装(需手动)
git clone https://github.com/zenobi-us/opencode-skillful.git
cd opencode-skillful
npm install && npm run build
npm install -g
三大核心工具:
|
|
|
|
|---|---|---|
skill_find |
|
|
skill_use |
|
|
skill_resource |
|
|
使用示例:
# 查找技能
skill_find "git commit"
# 加载技能
skill_use "experts_writing_git_commits"
# 读取资源
skill_resource "writing-git-commits""references/guide.md"
vs 内置 OpenCode 技能:
|
|
|
|
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
3.3.6 opencode-browser(浏览器自动化)
npm install -g opencode-browser
功能:
-
基于 Playwright 的无头浏览器 -
截图、点击、分析页面 -
调试前端 UI -
OAuth 回调处理 -
SSR 问题排查
3.3.7 @mohak34/opencode-notifier(桌面通知)
npm install -g @mohak34/opencode-notifier
触发事件:
-
代码生成完成时 -
需要权限时 -
发生错误时 -
调用问题工具时
平台支持: macOS、Linux、Windows
3.3.8 opencode-supermemory(持久化记忆)
npm install -g opencode-supermemory
功能:
-
跨会话、跨项目记忆 -
用户画像注入 -
项目知识注入 -
语义搜索相关记忆
四、OpenCode 原生配置优化
{
"$schema": "https://opencode.ai/config.json",
"compaction": {
"auto": true, // 开启自动压缩
"strategy": "summarize", // 压缩策略:summarize(总结)或 prune(直接裁剪)
"threshold": 0.8, // 上下文占用到 80% 时触发
"prune_tool_outputs": true// 优先清理工具执行的冗余输出
},
"cache": {
"provider": "auto",
"enabled": true
}
}
配置说明:
|
|
|
|
|---|---|---|
|
|
true |
|
|
|
summarize |
|
|
|
0.8 |
|
|
|
true |
|
|
|
true |
|
五、完整配置示例
{
"$schema": "https://opencode.ai/config.json",
"compaction": {
"auto": true,
"strategy": "summarize",
"threshold": 0.8,
"prune_tool_outputs": true
},
"cache": {
"provider": "auto",
"enabled": true
},
"mcp": {
"chrome-devtools": {
"command": ["npx", "-y", "chrome-devtools-mcp@latest"],
"enabled": true,
"type": "local"
},
"context7": {
"command": ["cmd", "/c", "npx", "-y", "@upstash/context7-mcp"],
"enabled": true,
"type": "local"
},
"fetch": {
"command": ["uvx", "mcp-server-fetch"],
"enabled": true,
"type": "local"
},
"memory": {
"command": ["cmd", "/c", "npx", "-y", "@modelcontextprotocol/server-memory"],
"enabled": true,
"type": "local"
},
"sequential-thinking": {
"command": ["cmd", "/c", "npx", "-y", "@modelcontextprotocol/server-sequential-thinking"],
"enabled": true,
"type": "local"
},
"time": {
"command": ["cmd", "/c", "npx", "-y", "@modelcontextprotocol/server-time"],
"enabled": true,
"type": "local"
},
"mem0": {
"command": ["cmd", "/c", "npx", "-y", "mem0ai/mem0"],
"enabled": true,
"type": "local"
}
},
"plugin": [
"oh-my-opencode",
"opencode-pty",
"@nick-vi/opencode-type-inject",
"opencode-supermemory@latest",
"github:JRedeker/opencode-morph-fast-apply",
"opencode-browser",
"opencode-arise",
"@mohak34/opencode-notifier",
"@plannotator/opencode@latest",
"@tarquinen/opencode-dcp"
],
"instructions": [
"~/.config/opencode/node_modules/opencode-morph-fast-apply/MORPH_INSTRUCTIONS.md"
]
}
六、使用场景矩阵
|
|
|
|
|---|---|---|
|
|
|
discard |
|
|
|
extract |
|
|
|
morph_edit |
|
|
|
add_memory |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
submit_plan |
|
|
|
skill_find
skill_use |
|
|
|
|
七、安装顺序建议
第一阶段:基础配置
-
安装 oh-my-opencode -
配置 compaction 和 cache -
配置内置 MCP 服务器
第二阶段:记忆系统
-
安装 opencode-supermemory -
配置 mem0 -
测试记忆注入
第三阶段:效率提升
-
安装 opencode-morph-fast-apply -
安装 opencode-arise -
安装 @tarquinen/opencode-dcp
第四阶段:辅助工具
-
安装 opencode-browser -
安装 @mohak34/opencode-notifier -
安装 @plannotator/opencode
八、常见问题 Q&A
Q1: 插件安装失败怎么办?
A1: 尝试手动安装或使用 --force 参数
Q2: 如何查看插件是否生效?
A2: 重启 OpenCode,运行 /skills 查看已加载的技能
Q3: mem0 和 opencode-supermemory 冲突吗?
A3: 不冲突,它们互补使用:
-
mem0 存储用户偏好和事实 -
opencode-supermemory 存储项目知识
Q4: morph_edit 和 edit 如何选择?
A4: 小改动用 edit,大文件重构用 morph_edit
Q5: 如何优化上下文使用?
A5: 开启 compaction.auto: true,配置合适的 threshold
九、参考资料
-
OpenCode 官方文档 -
Mem0 官方文档 -
Context7 文档搜索 -
Morph Fast Apply GitHub -
OpenCode Plugins MCP Servers
十、结语
通过合理配置 OpenCode 的插件、MCP 服务器和技能系统,可以打造一个高效、智能的 AI 编程助手。关键是根据自己的工作流程选择合适的工具,并不断优化配置以达到最佳体验。
作者: Sisyphus AI 助手 与 鸿枫
创建时间: 2026年2月
版本: 1.0
本文会持续更新,欢迎收藏关注!
夜雨聆风
