-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopencode.ps1
More file actions
182 lines (131 loc) · 3.87 KB
/
Copy pathopencode.ps1
File metadata and controls
182 lines (131 loc) · 3.87 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
$ErrorActionPreference = "Stop"
$cfg = Join-Path (Get-Location) "opencode.json"
# ----- NEY Startup Banner -----
Write-Host ""
Write-Host " ╭──────────────────────────────────────────────╮" -ForegroundColor Cyan
Write-Host " │ │" -ForegroundColor Cyan
Write-Host " │ NEY Coder AI - Model Config │" -ForegroundColor Cyan
Write-Host " │ │" -ForegroundColor Cyan
Write-Host " │ Select your AI model for OpenCode │" -ForegroundColor Cyan
Write-Host " │ Team: Yui, Ney, Fha, Masa, Eria, Mochi │" -ForegroundColor Cyan
Write-Host " │ │" -ForegroundColor Cyan
Write-Host " ╰──────────────────────────────────────────────╯" -ForegroundColor Cyan
Write-Host ""
Write-Host " Tip: Run '.\startup.ps1' for team health check" -ForegroundColor Green
Write-Host ""
$fallbackModels = @(
"opencode-go/deepseek-v4-flash",
"opencode-go/deepseek-v4-pro",
"opencode-go/glm-5",
"opencode-go/glm-5.1",
"opencode-go/kimi-k2.5",
"opencode-go/kimi-k2.6",
"opencode-go/mimo-v2.5",
"opencode-go/mimo-v2.5-pro",
"opencode-go/minimax-m2.5",
"opencode-go/minimax-m2.7",
"opencode-go/qwen3.5-plus",
"opencode-go/qwen3.6-plus"
)
Write-Host ""
Write-Host "Fetching OpenCode models..."
try {
$raw = opencode models --refresh 2>$null
$models = [regex]::Matches(
($raw | Out-String),
'opencode-go/[A-Za-z0-9._-]+'
) | ForEach-Object {
$_.Value
} | Sort-Object -Unique
}
catch {
$models = @()
}
if (-not $models -or $models.Count -eq 0) {
Write-Host ""
Write-Host "Cannot fetch models automatically."
Write-Host "Using fallback list."
Write-Host ""
$models = $fallbackModels
}
Write-Host ""
Write-Host "Available models"
Write-Host "--------------------------------"
for ($i = 0; $i -lt $models.Count; $i++) {
Write-Host "$($i + 1). $($models[$i])"
}
function PickModel {
param([string]$Title)
while ($true) {
Write-Host ""
$pick = Read-Host $Title
if ($pick -match '^\d+$') {
$idx = [int]$pick - 1
if ($idx -ge 0 -and $idx -lt $models.Count) {
return $models[$idx]
}
}
Write-Host "Invalid choice."
}
}
$mainModel = PickModel "Choose MAIN model number"
$smallModel = PickModel "Choose SMALL model number"
Write-Host ""
Write-Host "Permission mode:"
Write-Host "1. YOLO allow everything"
Write-Host "2. Ask before dangerous actions"
while ($true) {
$perm = Read-Host "Choose number"
if ($perm -eq "1") {
$permissionJson = @'
"permission": {
"*": "allow"
}
'@
break
}
if ($perm -eq "2") {
$permissionJson = @'
"permission": {
"*": "allow",
"bash": "ask",
"edit": "ask"
}
'@
break
}
Write-Host "Invalid choice."
}
if (Test-Path $cfg) {
$backup = "opencode.backup.$(Get-Date -Format 'yyyyMMdd-HHmmss').json"
Copy-Item $cfg $backup
Write-Host ""
Write-Host "Backup saved -> $backup"
}
$json = @"
{
"`$schema": "https://opencode.ai/config.json",
"model": "$mainModel",
"small_model": "$smallModel",
$permissionJson
}
"@
Set-Content -Path $cfg -Value $json -Encoding UTF8
Write-Host ""
Write-Host "Done."
Write-Host ""
Write-Host "Main model:"
Write-Host " $mainModel"
Write-Host ""
Write-Host "Small model:"
Write-Host " $smallModel"
Write-Host ""
Write-Host "Generated config:"
Write-Host "--------------------------------"
Get-Content $cfg
Write-Host ""
Write-Host "Start OpenCode now? (Y/N)"
$run = Read-Host
if ($run -match '^[Yy]') {
opencode
}