65 lines
2.5 KiB
Markdown
65 lines
2.5 KiB
Markdown
# opencode mit dem zentralen LocalAI-Server
|
|
|
|
opencode ist ein Coding-Agent für das Terminal. Er läuft auf dem Client-PC und arbeitet dort auf deinem Code. Nur die Modell-Anfragen gehen an den Server.
|
|
|
|
## 1. opencode installieren
|
|
|
|
| System | Befehl |
|
|
|---|---|
|
|
| Arch / CachyOS | `sudo pacman -S opencode` (oder AUR `opencode-bin`) |
|
|
| Linux / macOS allgemein | `curl -fsSL https://opencode.ai/install \| bash` |
|
|
| macOS (Homebrew) | `brew install sst/tap/opencode` |
|
|
| Windows | `npm i -g opencode-ai` (Node.js nötig) oder `scoop install opencode` |
|
|
|
|
## 2. Konfiguration einspielen
|
|
|
|
| System | Pfad |
|
|
|---|---|
|
|
| Linux / macOS | `~/.config/opencode/opencode.json` |
|
|
| Windows | `%USERPROFILE%\.config\opencode\opencode.json` |
|
|
|
|
```bash
|
|
mkdir -p ~/.config/opencode
|
|
cp ~/.config/opencode/opencode.json ~/.config/opencode/opencode.json.bak 2>/dev/null
|
|
cp client/opencode.json ~/.config/opencode/opencode.json
|
|
```
|
|
|
|
Die Vorlage liegt unter [`client/opencode.json`](../client/opencode.json). Sie nutzt zwei Umgebungsvariablen:
|
|
|
|
| Variable | Wert |
|
|
|---|---|
|
|
| `LOCALAI_HOST` | `127.0.0.1` (auf dem Server), `192.168.178.72` (LAN), `100.73.82.219` (NetBird) |
|
|
| `LOCALAI_API_KEY` | `LLM_API_KEY` aus der `.env` des Servers |
|
|
|
|
**fish** (`~/.config/fish/config.fish`):
|
|
```fish
|
|
set -gx LOCALAI_HOST 100.73.82.219
|
|
set -gx LOCALAI_API_KEY <KEY>
|
|
```
|
|
**bash/zsh** (`~/.bashrc` / `~/.zshrc`):
|
|
```bash
|
|
export LOCALAI_HOST=100.73.82.219
|
|
export LOCALAI_API_KEY=<KEY>
|
|
```
|
|
**Windows (PowerShell, dauerhaft):**
|
|
```powershell
|
|
[Environment]::SetEnvironmentVariable("LOCALAI_HOST", "100.73.82.219", "User")
|
|
[Environment]::SetEnvironmentVariable("LOCALAI_API_KEY", "<KEY>", "User")
|
|
```
|
|
|
|
## 3. Benutzen
|
|
|
|
```bash
|
|
cd ~/mein-projekt
|
|
opencode
|
|
```
|
|
- `/models` zeigt die Modelle. Dort sollten nur `LocalAI (alegab-pc)`-Einträge stehen.
|
|
- `/init` erzeugt eine `AGENTS.md` mit Projektwissen. Das hilft lokalen Modellen sehr und lohnt sich einmal pro Projekt.
|
|
- `Tab` wechselt zwischen dem **Build**-Agenten (darf ändern) und dem **Plan**-Agenten (nur lesen).
|
|
|
|
## Hinweise
|
|
|
|
- `small_model` zeigt bewusst auf dasselbe Modell wie `model`. Ein zweites Chat-Modell würde auf dem Server bei jedem Titel- oder Zusammenfassungs-Aufruf einen Modellwechsel auslösen.
|
|
- Die Kontextgrenzen in `limit.context` passen zur Server-Konfiguration (`-c` in `llama-swap/config.yaml`). Ändert man die eine Seite, muss man die andere mitziehen.
|
|
- Fehlercodes (401/403/Timeout): siehe Tabelle in [continue.md](continue.md#7-fehlersuche). Die Ursachen sind dieselben.
|