-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopencode-config-install.sh
More file actions
executable file
·254 lines (233 loc) · 10.3 KB
/
opencode-config-install.sh
File metadata and controls
executable file
·254 lines (233 loc) · 10.3 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#!/usr/bin/env bash
# One-Liner OpenCode CLI Fireworks Config Installer
# Mit Reasoning-Configs (thinking: enabled, budgetTokens)
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/SIN-Rotator/SINator-FireworksAI/main/opencode-config-install.sh | bash
# curl -fsSL ... | bash -s -- --api-key fw_xxx
# curl -fsSL ... | bash -s -- --dry-run
set -euo pipefail
OPENCODE_DIR="${HOME}/.config/opencode"
CONFIG_FILE="${OPENCODE_DIR}/opencode.json"
BACKUP_DIR="${OPENCODE_DIR}/backups"
RED='\033[0;31m'; GREEN='\033[0;32m'; CYAN='\033[0;36m'; YELLOW='\033[1;33m'; NC='\033[0m'
log_ok() { echo -e "${GREEN}[OK]${NC} $1"; }
log_info() { echo -e "${CYAN}[INFO]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
API_KEY=""
DRY_RUN=false
# Parse args
while [ $# -gt 0 ]; do
case "$1" in
--api-key) API_KEY="$2"; shift 2 ;;
--dry-run) DRY_RUN=true; shift ;;
*) shift ;;
esac
done
echo -e "${CYAN}══════════════════════════════════════════════════════════════${NC}"
echo -e "${CYAN} OpenCode CLI — Fireworks AI Config + Reasoning Installer${NC}"
echo -e "${CYAN}══════════════════════════════════════════════════════════════${NC}"
echo ""
# API Key abfragen wenn nicht via Argument
if [ -z "$API_KEY" ]; then
if [ -n "${FIREWORKS_AI_API_KEY:-}" ]; then
API_KEY="$FIREWORKS_AI_API_KEY"
log_info "Using FIREWORKS_AI_API_KEY from environment"
else
echo -n "Enter your Fireworks API Key (fw_... or press Enter for placeholder): "
read -r API_KEY
if [ -z "$API_KEY" ]; then
API_KEY="<DEIN_API_KEY>"
log_warn "No API key provided — using placeholder"
fi
fi
fi
mkdir -p "$OPENCODE_DIR"
# Backup erstellen
if [ -f "$CONFIG_FILE" ]; then
mkdir -p "$BACKUP_DIR"
BACKUP_FILE="${BACKUP_DIR}/opencode-$(date +%Y%m%d-%H%M%S).json"
if [ "$DRY_RUN" = false ]; then
cp "$CONFIG_FILE" "$BACKUP_FILE"
fi
log_info "Backup created: ${BACKUP_FILE}"
fi
# Fireworks Provider Config mit Reasoning
if [ "$DRY_RUN" = false ]; then
INSTALLER_API_KEY="${API_KEY}" python3 << 'PYEOF'
import json, os
config_path = os.path.expanduser("~/.config/opencode/opencode.json")
# Neues oder bestehendes Config laden
if os.path.exists(config_path):
with open(config_path, 'r') as f:
cfg = json.load(f)
else:
cfg = {
"$schema": "https://opencode.ai/config.json",
"permission": "allow",
"skills": {"paths": [os.path.expanduser("~/.config/opencode/skills")]},
"command": {},
"mcp": {}
}
# Fireworks Provider mit Reasoning-Configs
fireworks_provider = {
"npm": "@ai-sdk/fireworks",
"name": "Fireworks AI",
"models": {
"deepseek-v4-pro": {
"id": "fireworks/deepseek-v4-pro",
"name": "DeepSeek V4 Pro (SIN)",
"options": {
"thinking": {"type": "enabled", "budgetTokens": 64000}
},
"variants": {
"off": {"thinking": {"type": "disabled"}},
"low": {"thinking": {"type": "enabled", "budgetTokens": 4000}},
"medium": {"thinking": {"type": "enabled", "budgetTokens": 16000}},
"high": {"thinking": {"type": "enabled", "budgetTokens": 64000}},
"max": {"thinking": {"type": "enabled", "budgetTokens": 128000}}
},
"limit": {"context": 1048576, "output": 65536}
},
"glm-5p1": {
"id": "fireworks/glm-5p1",
"name": "GLM 5.1 (SIN)",
"options": {
"thinking": {"type": "enabled", "budgetTokens": 32000}
},
"variants": {
"off": {"thinking": {"type": "disabled"}},
"low": {"thinking": {"type": "enabled", "budgetTokens": 4000}},
"medium": {"thinking": {"type": "enabled", "budgetTokens": 16000}},
"high": {"thinking": {"type": "enabled", "budgetTokens": 32000}},
"max": {"thinking": {"type": "enabled", "budgetTokens": 64000}}
},
"limit": {"context": 202752, "output": 32768}
},
"glm-5p1-fast": {
"id": "accounts/fireworks/routers/glm-5p1-fast",
"name": "GLM 5.1 Fast (SIN)",
"options": {
"thinking": {"type": "enabled", "budgetTokens": 32000}
},
"variants": {
"off": {"thinking": {"type": "disabled"}},
"low": {"thinking": {"type": "enabled", "budgetTokens": 4000}},
"medium": {"thinking": {"type": "enabled", "budgetTokens": 16000}},
"high": {"thinking": {"type": "enabled", "budgetTokens": 32000}},
"max": {"thinking": {"type": "enabled", "budgetTokens": 64000}}
},
"limit": {"context": 202752, "output": 32768}
},
"kimi-k2p6": {
"id": "fireworks/kimi-k2p6",
"name": "Kimi K2.6 (SIN)",
"options": {
"thinking": {"type": "enabled", "budgetTokens": 32000}
},
"variants": {
"off": {"thinking": {"type": "disabled"}},
"low": {"thinking": {"type": "enabled", "budgetTokens": 4000}},
"medium": {"thinking": {"type": "enabled", "budgetTokens": 16000}},
"high": {"thinking": {"type": "enabled", "budgetTokens": 32000}},
"max": {"thinking": {"type": "enabled", "budgetTokens": 64000}}
},
"limit": {"context": 262144, "output": 32768},
"modalities": {"input": ["text", "image"], "output": ["text"]}
},
"kimi-k2p6-turbo": {
"id": "accounts/fireworks/routers/kimi-k2p6-turbo",
"name": "Kimi K2.6 Turbo (SIN)",
"options": {
"thinking": {"type": "enabled", "budgetTokens": 32000}
},
"variants": {
"off": {"thinking": {"type": "disabled"}},
"low": {"thinking": {"type": "enabled", "budgetTokens": 4000}},
"medium": {"thinking": {"type": "enabled", "budgetTokens": 16000}},
"high": {"thinking": {"type": "enabled", "budgetTokens": 32000}},
"max": {"thinking": {"type": "enabled", "budgetTokens": 64000}}
},
"limit": {"context": 262144, "output": 32768},
"modalities": {"input": ["text", "image"], "output": ["text"]}
},
"qwen3p6-plus": {
"id": "accounts/fireworks/models/qwen3p6-plus",
"name": "Qwen3.6 Plus (SIN)",
"options": {
"thinking": {"type": "enabled", "budgetTokens": 32000}
},
"variants": {
"off": {"thinking": {"type": "disabled"}},
"low": {"thinking": {"type": "enabled", "budgetTokens": 4000}},
"medium": {"thinking": {"type": "enabled", "budgetTokens": 16000}},
"high": {"thinking": {"type": "enabled", "budgetTokens": 32000}},
"max": {"thinking": {"type": "enabled", "budgetTokens": 64000}}
},
"limit": {"context": 131072, "output": 32768},
"modalities": {"input": ["text", "image"], "output": ["text"]}
},
"minimax-m2p7": {
"id": "fireworks/minimax-m2p7",
"name": "MiniMax M2.7 (SIN)",
"options": {
"thinking": {"type": "enabled", "budgetTokens": 32000}
},
"variants": {
"off": {"thinking": {"type": "disabled"}},
"low": {"thinking": {"type": "enabled", "budgetTokens": 4000}},
"medium": {"thinking": {"type": "enabled", "budgetTokens": 16000}},
"high": {"thinking": {"type": "enabled", "budgetTokens": 32000}},
"max": {"thinking": {"type": "enabled", "budgetTokens": 64000}}
},
"limit": {"context": 196608, "output": 32768}
}
},
"options": {
"baseURL": "https://sinatorpool-router.delqhi.com/inference/v1",
"apiKey": os.environ.get('INSTALLER_API_KEY', '<DEIN_API_KEY>'),
"headers": {
"x-agent-id": "opencode-main"
}
}
}
# Provider setzen
providers = cfg.setdefault("provider", {})
providers["fireworks-ai"] = fireworks_provider
# Default model setzen (wenn nicht vorhanden)
if "defaultModel" not in cfg:
cfg["defaultModel"] = "fireworks-ai/deepseek-v4-pro"
# Default agent setzen (wenn nicht vorhanden)
if "defaultAgent" not in cfg:
cfg["defaultAgent"] = "SIN-Zeus"
with open(config_path, 'w') as f:
json.dump(cfg, f, indent=2)
f.write('\n')
print(f"Fireworks provider configured with {len(fireworks_provider['models'])} models")
print(f"Base URL: {fireworks_provider['options']['baseURL']}")
print(f"Reasoning: enabled (off/low/medium/high/max variants)")
PYEOF
log_ok "opencode.json updated with Fireworks AI + Reasoning"
else
log_info "DRY RUN — Would create/update opencode.json"
fi
echo ""
echo -e "${GREEN}══════════════════════════════════════════════════════════════${NC}"
echo -e "${GREEN} ✅ OpenCode Fireworks Config Complete!${NC}"
echo -e "${GREEN}══════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e " Models: ${CYAN}7 reasoning models (off/low/medium/high/max)${NC}"
echo -e " Base URL: ${CYAN}https://sinatorpool-router.delqhi.com/inference/v1${NC}"
echo -e " Config: ${CYAN}${CONFIG_FILE}${NC}"
if [ -f "$BACKUP_FILE" ]; then
echo -e " Backup: ${CYAN}${BACKUP_FILE}${NC}"
fi
echo ""
echo -e " ${YELLOW}Usage:${NC}"
echo -e " ${CYAN}opencode chat --provider fireworks-ai --model deepseek-v4-pro${NC}"
echo -e " ${CYAN}opencode chat --provider fireworks-ai --model deepseek-v4-pro --variant high${NC}"
echo ""
echo -e " ${YELLOW}Test:${NC}"
echo -e " ${CYAN}curl -s https://sinatorpool-router.delqhi.com/inference/v1/models | head -5${NC}"
echo ""