# PLGames CLI — установка за 3 шага

Терминальный агент (plan/act, файлы, bash, модели с failover).  
**Node.js не нужен** — один бинарь `plgames` (fork opencode → наш API).

---

## Шаг 1. Установить

### Linux / macOS

```bash
curl -fsSL https://plgames-ai.duckdns.org/install.sh | sh
```

Бинарь: `~/.local/bin/plgames`  
Doctor: `~/.local/bin/plgames-doctor`

```bash
export PATH="$HOME/.local/bin:$PATH"   # если command not found
```

### Windows (PowerShell)

```powershell
iwr -useb https://plgames-ai.duckdns.org/install.ps1 | iex
```

### Проверка

```bash
plgames --version
plgames-doctor
plgames update          # свежий бинарь, конфиг не трогает
```

---

## Шаг 2. API-ключ

1. Web: **https://plgames-ai.duckdns.org/**
2. **API и CLI** → **Создать API key для CLI**
3. Ключ вида `plg-…` (показывается один раз)

```bash
export PLGAMES_API_KEY=plg-ваш-ключ
# в ~/.bashrc / ~/.zshrc
```

---

## Шаг 3. Запуск

```bash
cd ~/your-project
plgames
```

Headless:

```bash
plgames run 'explain this repo'
plgames run -m plgames/class:tools 'review src/'
```

Модели (provider `plgames`):

| id | Зачем |
|----|--------|
| `plgames/plgames-ai` | Auto-routing |
| `plgames/plgames-ai-ultra` | Deep / hard |
| `plgames/class:tools` | Coding + tools |
| `plgames/class:claude-sonnet` | Claude pool |
| `plgames/class:llama-3.3-70b` | Fast balanced |

---

## Что умеет

| | |
|--|--|
| Plan/act | План → правки с подтверждением |
| File tools | Read / Write / Edit + diff |
| Bash | Sandboxed shell |
| Failover | `class:*` на шлюзе |
| Slash | `/deep`, `/council`, `/orchestrate`, `/models` (по тарифу) |

---

## Частые проблемы

| Симптом | Решение |
|---------|---------|
| `command not found` | `export PATH="$HOME/.local/bin:$PATH"` |
| 401 | Проверь `PLGAMES_API_KEY`, новый ключ в UI |
| 404 / hangs на каждом запросе | Старый config с provider `openai` → `curl -fsSL …/install.sh \| PLGAMES_FORCE_CONFIG=1 sh` |
| 403 на /council | Нужен платный тариф |
| Чужой provider в config | Install **добавляет** `plgames`, не стирает Z.ai и т.п. (FORCE перезаписывает/merge) |
| npm / classic | `curl -fsSL …/install-classic.sh \| sh` (Node 20+) |

---

## Doctor

```bash
plgames-doctor
# или
curl -fsSL https://plgames-ai.duckdns.org/static/plgames-doctor.sh | sh
```

Проверяет: бинарь, версию, `PLGAMES_API_KEY`, config (openai-compatible), health API, `/v1/models`.

---

## Dev-профиль (из репо)

```bash
cd cli/opencode
cp .env.example .env   # PLGAMES_API_KEY=
./install.sh           # symlink
plgames
```

См. `cli/opencode/README.md`.

**Важно:** provider id = `plgames` + `npm: @ai-sdk/openai-compatible`.  
Не используй id `openai` — ai-sdk уйдёт в `/v1/responses` (у нас его нет).
