-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
196 lines (163 loc) · 7.08 KB
/
Copy pathinstall.sh
File metadata and controls
196 lines (163 loc) · 7.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/env bash
# opencode-agents 一键安装脚本
# 用法: curl -fsSL https://gitee.com/aerlee/opencode-agents/raw/master/install.sh | bash
set -euo pipefail
REPO_URL="https://gitee.com/aerlee/opencode-agents.git"
TARGET_DIR="${HOME}/.config/opencode/agents"
REFERENCES_DIR="${HOME}/.config/opencode/references"
BACKUP_DIR="${HOME}/.config/opencode/agents-备份-$(date +%Y%m%d%H%M%S)"
TEMP_DIR=$(mktemp -d)
echo "🚀 opencode-agents 安装脚本"
echo "================================"
# 检查 git
if ! command -v git &>/dev/null; then
echo "❌ 需要安装 git"
exit 1
fi
# 备份已有 agents
if [ -d "$TARGET_DIR" ]; then
echo "📦 备份已有 agents 到: $BACKUP_DIR"
cp -r "$TARGET_DIR" "$BACKUP_DIR"
fi
# 克隆仓库到临时目录
echo "📥 正在下载 agents..."
git clone --depth 1 "$REPO_URL" "$TEMP_DIR" 2>/dev/null
# 创建目标目录
mkdir -p "$TARGET_DIR"
mkdir -p "$REFERENCES_DIR"
# 复制 agents 文件
echo "📂 安装 agents 到: $TARGET_DIR"
cp "$TEMP_DIR"/agents/*.md "$TARGET_DIR/"
# 复制 references 文件
if [ -d "$TEMP_DIR/references" ]; then
echo "📚 安装 references 到: $REFERENCES_DIR"
cp -r "$TEMP_DIR"/references/* "$REFERENCES_DIR/"
fi
# 复制 plugins 文件
PLUGIN_DIR="${HOME}/.config/opencode/plugins"
if ls "$TEMP_DIR"/plugins/*.js &>/dev/null || ls "$TEMP_DIR"/plugins/*.ts &>/dev/null; then
mkdir -p "$PLUGIN_DIR"
echo "🔌 安装 plugins 到: $PLUGIN_DIR"
cp "$TEMP_DIR"/plugins/*.js "$PLUGIN_DIR/" 2>/dev/null || true
cp "$TEMP_DIR"/plugins/*.ts "$PLUGIN_DIR/" 2>/dev/null || true
fi
# 清理
rm -rf "$TEMP_DIR"
# 配置环境变量以启用异步子代理处理
echo "⚙️ 配置环境变量..."
# 设置 shell 环境变量
SHELL_RC=""
if [ -f "$HOME/.bashrc" ]; then
SHELL_RC="$HOME/.bashrc"
elif [ -f "$HOME/.zshrc" ]; then
SHELL_RC="$HOME/.zshrc"
fi
if [ -n "$SHELL_RC" ]; then
if ! grep -q "OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS" "$SHELL_RC"; then
echo "" >> "$SHELL_RC"
echo "# OpenCode 异步子代理支持" >> "$SHELL_RC"
echo "export OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true" >> "$SHELL_RC"
echo " ✅ 已添加环境变量到 $SHELL_RC"
# 立即生效
export OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true
else
echo " ℹ️ 环境变量已存在于 $SHELL_RC"
fi
fi
# 统计
AGENT_COUNT=$(ls -1 "$TARGET_DIR"/*.md 2>/dev/null | wc -l)
REFERENCE_COUNT=$(find "$REFERENCES_DIR" -name "*.md" 2>/dev/null | wc -l)
echo ""
echo "✅ 安装完成!共 ${AGENT_COUNT} 个智能体,${REFERENCE_COUNT} 个参考文档"
echo ""
echo "已安装的智能体:"
echo " 主智能体:"
ls -1 "$TARGET_DIR"/{Zero,Erribaba}.md 2>/dev/null | while read f; do
echo " - $(basename "$f" .md)"
done
echo " 子智能体:"
ls -1 "$TARGET_DIR"/*.md 2>/dev/null | grep -v -E '(Zero|Erribaba)\.md' | while read f; do
echo " - $(basename "$f" .md)"
done
echo ""
echo "已安装的参考文档:"
find "$REFERENCES_DIR" -name "*.md" 2>/dev/null | while read f; do
echo " - $(basename "$f" .md)"
done
echo ""
echo "📋 下一步:"
echo " 1. 编辑 ~/.config/opencode/opencode.json 配置模型和 provider"
echo " 2. 在 opencode.json 中设置 \"default_agent\" 选择主智能体"
echo " 3. 在 opencode.json 中配置 \"references\" 指向参考文档目录"
echo " 4. 启动 opencode 开始使用"
echo ""
echo "⚡ 已启用异步子代理处理功能,主智能体现在可以并行处理多个子任务!"
echo ""
echo "💡 提示:将下方提示词复制到你的 OpenCode 智能体中,"
echo " 它会帮你自动配置模型并更新智能体文件。"
echo ""
echo "================================"
cat << 'PROMPT'
--- 复制以下提示词发送给你的 OpenCode 智能体 ---
我刚刚安装了 opencode-agents 智能体集合(位于 ~/.config/opencode/agents/)。
请你帮我完成以下配置:
## 第一步:确认已有 provider 和模型
请读取 ~/.config/opencode/opencode.json,列出我当前已配置的 provider 和模型。
## 第二步:选择模型
以下是智能体集合中每个智能体默认使用的模型,请根据我已有的 provider 和模型,
为每个智能体选择一个可用的模型(优先选择能力更强的模型):
| 智能体 | 默认模型 | 角色 |
|--------|----------|------|
| Zero | opencode-go/mimo-v2.5 | 主智能体(快速原型,多模态) |
| Erribaba | Xianyu/mimo-v2.5-pro | 主智能体(生产代码,深度分析) |
| api-designer | opencode-go/mimo-v2.5-pro | API 设计 |
| architect | opencode-go/glm-5.1 | 架构设计 |
| code-generator | opencode-go/mimo-v2.5-pro | 代码生成 |
| db-engineer | opencode-go/deepseek-v4-pro | 数据库工程 |
| debugger | opencode-go/deepseek-v4-pro | 调试诊断 |
| devops | opencode-go/mimo-v2.5-pro | DevOps/CI-CD |
| doc-writer | opencode-go/qwen3.7-plus | 文档编写 |
| e2e-tester | opencode-go/mimo-v2.5-pro | 端到端测试 |
| executor | opencode-go/minimax-m2.7 | 命令执行 |
| frontend-dev | opencode-go/kimi-k2.6 | 前端开发 |
| frontend-reviewer | opencode-go/mimo-v2.5 | 前端审查 |
| git-assistant | opencode-go/mimo-v2.5 | Git 工作流 |
| migration | opencode-go/deepseek-v4-pro | 迁移专家 |
| perf-optimizer | opencode-go/mimo-v2.5-pro | 性能优化 |
| plan-writer | opencode-go/mimo-v2.5-pro | 实现计划编写 |
| project-manager | opencode-go/qwen3.7-plus | 项目管理 |
| refactorer | opencode-go/mimo-v2.5-pro | 代码重构 |
| research | opencode-go/qwen3.7-plus | 信息研究 |
| reviewer | opencode-go/deepseek-v4-pro | 代码审查(Stage 2) |
| security-auditor | opencode-go/deepseek-v4-pro | 安全审计 |
| software-engineer | opencode-go/mimo-v2.5 | 全栈实现 |
| spec-reviewer | opencode-go/deepseek-v4-pro | 规范合规性审查(Stage 1) |
| test-writer | opencode-go/mimo-v2.5-pro | 测试编写 |
| ui-designer | opencode-go/kimi-k2.6 | UI 设计 |
| validator | opencode-go/minimax-m2.7 | 结果验证 |
| vision-dev | opencode-go/mimo-v2.5 | 视觉开发 |
| workflow-orchestrator | opencode-go/mimo-v2.5-pro | 工作流编排 |
如果我没有某个 provider,告诉我哪些模型需要额外配置。
如果我已有对应的模型,直接进入第三步。
## 第三步:更新智能体文件
读取 ~/.config/opencode/agents/ 下所有 .md 文件,将每个文件 frontmatter 中的 `model:`
字段替换为你在第二步中为该智能体选择的模型。
## 第四步:设置主智能体
将 ~/.config/opencode/opencode.json 中的 `default_agent` 设置为 "Erribaba"。
(如果用户更喜欢快速原型模式,改为 "Zero")
## 第五步:配置参考文档
在 ~/.config/opencode/opencode.json 中添加 references 配置,指向工作流文档:
```json
"references": {
"workflow-docs": {
"path": "~/.config/opencode/references/workflow",
"description": "智能体工作流文档和快速参考,包含结构化工作流指南、代理配置和最佳实践",
"hidden": false
}
}
```
## 第六步:验证
列出所有智能体及其使用的模型,确认配置完成。
验证 references 配置是否正确。
PROMPT
echo ""