# SeibertGPT – Einrichtung für OpenWork (Windows). Quelle: https://gpt.seibert.ai/clients # Der Key wird nur lokal abgefragt und landet in deinem Benutzerprofil, nie in einer Datei; gesendet wird er nur an das Gateway. & { $ErrorActionPreference = 'Stop' Write-Host 'SeibertGPT: Einrichtung für OpenWork' if (-not ($true)) { Write-Host 'OpenWork scheint nicht installiert zu sein. Download: https://openworklabs.com/download' $ans = Read-Host 'Trotzdem fortfahren? (j/N)' if ($ans -notmatch '^[jJyY]$') { return } } # „Als Pfad kopieren“ im Explorer liefert den Pfad in Anführungszeichen. $targetDir = ([string](Read-Host 'Pfad zu deinem Workspace-Ordner')).Trim([char[]]'" ') if (-not $targetDir -or -not (Test-Path -LiteralPath $targetDir -PathType Container)) { Write-Host "Ordner nicht gefunden: $targetDir"; return } # Absolut machen: [IO.File] löst relative Pfade gegen das Prozessverzeichnis auf, nicht gegen $PWD (und kennt ~ nicht). $targetDir = (Resolve-Path -LiteralPath $targetDir).ProviderPath $target = Join-Path $targetDir 'opencode.jsonc' $ours = @' { "$schema": "https://opencode.ai/config.json", "model": "seibertgpt/deepseek-v41-flash-fast", "small_model": "seibertgpt/deepseek-v41-flash-fast", "provider": { "seibertgpt": { "npm": "@ai-sdk/openai-compatible", "name": "SeibertGPT", "options": { "baseURL": "https://api.gpt.seibert.ai/v1", "apiKey": "{env:SEIBERTGPT_API_KEY}" }, "models": { "deepseek-v41-flash": { "name": "Standard mit Denkmodus", "tool_call": true, "attachment": true, "limit": { "context": 1000000, "output": 32000 } }, "deepseek-v41-flash-fast": { "name": "ohne Denkmodus – schnell", "tool_call": true, "attachment": true, "limit": { "context": 1000000, "output": 32000 } }, "deepseek-v41-flash-low": { "name": "Denkaufwand niedrig", "tool_call": true, "attachment": true, "limit": { "context": 1000000, "output": 32000 } }, "deepseek-v41-flash-high": { "name": "Denkaufwand hoch", "tool_call": true, "attachment": true, "limit": { "context": 1000000, "output": 32000 } }, "deepseek-v41-flash-max": { "name": "Denkaufwand maximal", "tool_call": true, "attachment": true, "limit": { "context": 1000000, "output": 32000 } } } } } } '@ $mergePaths = @() $mergePaths += ,@('provider','seibertgpt') $absentPaths = @() $absentPaths += ,@('$schema') $absentPaths += ,@('model') $absentPaths += ,@('small_model') function Get-JsonPath($obj, $path) { foreach ($p in $path) { if ($null -eq $obj -or -not ($obj.PSObject.Properties.Name -contains $p)) { return $null }; $obj = $obj.$p }; return ,$obj } function Set-JsonPath($obj, $path, $value) { for ($i = 0; $i -lt $path.Count - 1; $i++) { $p = $path[$i] if (-not ($obj.$p -is [System.Management.Automation.PSCustomObject])) { $obj | Add-Member -NotePropertyName $p -NotePropertyValue ([pscustomobject]@{}) -Force } $obj = $obj.$p } $obj | Add-Member -NotePropertyName $path[-1] -NotePropertyValue $value -Force } $utf8 = New-Object System.Text.UTF8Encoding($false) $raw = $null if (Test-Path -LiteralPath $target) { $raw = Get-Content -Raw -Encoding UTF8 -LiteralPath $target } if ([string]::IsNullOrWhiteSpace($raw)) { [IO.File]::WriteAllText($target, $ours + "`r`n", $utf8) Write-Host "Config angelegt: $target" } else { $existing = $null # PowerShell 7 liest JSON mit Kommentaren, beim Zurückschreiben gingen sie verloren: vorher erkennen (Strings ausgeblendet). if (($raw -replace '"(?:[^"\\]|\\.)*"', '""') -notmatch '//|/\*') { try { $existing = $raw | ConvertFrom-Json } catch { $existing = $null } } if ($existing -isnot [System.Management.Automation.PSCustomObject]) { $side = [IO.Path]::ChangeExtension($target, $null).TrimEnd('.') + '.seibertgpt.json' [IO.File]::WriteAllText($side, $ours + "`r`n", $utf8) Write-Host "Deine Config enthält Kommentare und wurde nicht verändert. Unsere liegt daneben: $side – übernimm den Block 'seibertgpt' von Hand." } else { Copy-Item -LiteralPath $target -Destination ("$target.bak-" + (Get-Date -Format 'yyyyMMdd-HHmmss')) $oursObj = $ours | ConvertFrom-Json foreach ($p in $mergePaths) { $v = Get-JsonPath $oursObj $p; if ($null -ne $v) { Set-JsonPath $existing $p $v } } foreach ($p in $absentPaths) { $v = Get-JsonPath $oursObj $p; if ($null -ne $v -and $null -eq (Get-JsonPath $existing $p)) { Set-JsonPath $existing $p $v } } [IO.File]::WriteAllText($target, ($existing | ConvertTo-Json -Depth 50) + "`r`n", $utf8) Write-Host "Config ergänzt: $target (Sicherung daneben: *.bak-...)" } } Write-Host 'In OpenWork: Settings → Environment → SEIBERTGPT_API_KEY mit deinem Key anlegen, dann „Reload OpenCode config“.' Write-Host 'Fertig.' }