feat(opencode): opencode 2.x support + generation-aware installer (#2)
This commit was merged in pull request #2.
This commit is contained in:
1 parent
1d3b2499cc
commit
38edeef6c9
4 files changed
+490
-228
No files matched your search
@@ -1,58 +1,68 @@
|
||||
---
|
||||
name: arka-provider
|
||||
description: Manage the custom Arka-AI (arka-ai.ru) LLM provider in opencode config. Use when the user needs to add, refresh, or fix the arka-ai.ru provider, sync its model catalog, change the Arka-AI default model, or when arka models are missing from /models.
|
||||
description: Manage the custom Arka-AI (arka-ai.ru) LLM provider in opencode config (1.x and 2.x). Use when the user needs to add, refresh, or fix the arka-ai.ru provider, sync its model catalog, change the Arka-AI default model, or when arka models are missing from /models.
|
||||
---
|
||||
|
||||
# Arka-AI provider
|
||||
|
||||
arka-ai.ru is **not** in models.dev, so opencode ships no built-in config for it.
|
||||
It is wired up locally with a plugin + a static `provider` block in
|
||||
`~/.config/opencode/opencode.json`.
|
||||
It is wired up locally. **The mechanism depends on the opencode generation:**
|
||||
|
||||
## How it works
|
||||
| opencode | provider lives in | models |
|
||||
|----------|-------------------|--------|
|
||||
| **1.x** | plugin `~/.config/opencode/plugins/arka-ai.ts` (injects via the `config` hook) | dynamic (public catalog, cached 24h) |
|
||||
| **2.x** | static `providers["Arka-AI"]` block in `~/.config/opencode/opencode.jsonc` | static list (refresh by re-running the installer) |
|
||||
|
||||
- Plugin: `~/.config/opencode/plugins/arka-ai.ts`
|
||||
- On startup it loads the published chat catalog
|
||||
`https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/catalog.json`
|
||||
(no API key; refreshed daily at 05:00 Europe/Moscow).
|
||||
- If that fetch fails, it falls back to `https://api.arka-ai.ru/v1/models`
|
||||
and filters out non-chat models (TTS/ASR/image/video/OCR/embedding/reranker/…)
|
||||
via a heuristic regex so the `/models` picker stays clean.
|
||||
- Caches the result at `~/.cache/opencode/arka-ai-models.json` (TTL 24h).
|
||||
- Injects the provider into config via the `config` hook, layered over the
|
||||
static block in `opencode.json`.
|
||||
- Static block (`opencode.json` → `provider["Arka-AI"]`) holds
|
||||
`name`, `api`, `env`, and a small fallback `models` map that is used when the
|
||||
catalog is unreachable.
|
||||
- Inference uses `ARKA_API_KEY` (env) or `~/.config/opencode/.arka-api-key`
|
||||
(so OpenCode Desktop / Windows GUI works without a login shell).
|
||||
`opencode --version` prints `1.x.y` on 1.x and `opencode v2.x.y` on 2.x.
|
||||
The installer detects this and writes the right thing. (2.x changed the plugin
|
||||
API: a 1.x plugin no longer loads — it must export `{ id, setup }` — so the 1.x
|
||||
plugin is disabled and the static block is used instead.)
|
||||
|
||||
## Refresh the model list
|
||||
## 1.x — plugin (dynamic catalog)
|
||||
|
||||
Catalog ~216 raw models / ~116 chat; the public snapshot updates at 05:00
|
||||
Europe/Moscow. Changes land in opencode only after cache expiry + restart
|
||||
(config is not hot-reloaded).
|
||||
- Plugin `plugins/arka-ai.ts` loads the published chat catalog
|
||||
(`…/opencode/catalog.json`, no key, refreshed daily 05:00 Europe/Moscow), falls
|
||||
back to `/v1/models`, filters non-chat models, caches at
|
||||
`~/.cache/opencode/arka-ai-models.json` (TTL 24h), and injects the provider.
|
||||
- Key: `ARKA_API_KEY` env or `~/.config/opencode/.arka-api-key`.
|
||||
|
||||
1. `rm -f ~/.cache/opencode/arka-ai-models.json`
|
||||
2. Restart opencode (or run `opencode` again) — the plugin re-fetches on the
|
||||
next cold start.
|
||||
## 2.x — static config
|
||||
|
||||
Optionally inspect the live API (no key required for listing):
|
||||
|
||||
```bash
|
||||
curl -sS https://api.arka-ai.ru/v1/models | python3 -m json.tool
|
||||
curl -sS https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/catalog.json | python3 -m json.tool
|
||||
```
|
||||
- `opencode.jsonc` → `providers["Arka-AI"]`:
|
||||
```jsonc
|
||||
{
|
||||
"providers": {
|
||||
"Arka-AI": {
|
||||
"name": "Arka-AI",
|
||||
"package": "@opencode/ai/providers/openai-compatible",
|
||||
"env": ["ARKA_API_KEY"],
|
||||
"settings": { "baseURL": "https://api.arka-ai.ru/v1", "apiKey": "…" },
|
||||
"models": { "DeepSeek-V4-Pro": { "name": "DeepSeek-V4-Pro" } }
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
- The model list is static — refresh it after catalog changes:
|
||||
```bash
|
||||
bash install-arka-provider.sh --refresh
|
||||
```
|
||||
(re-fetches catalog.json and rewrites only `providers["Arka-AI"].models`).
|
||||
|
||||
## Change default model
|
||||
|
||||
Edit `opencode.json` → `"model": "Arka-AI/<model-id>"`. Use the IDs exactly as
|
||||
returned by the catalog (e.g. `Arka-AI/DeepSeek-V4-Pro`,
|
||||
`Arka-AI/qwen3.8-max`, `Arka-AI/kimi-k3`).
|
||||
`"model": "Arka-AI/<model-id>"` in the config file. Use IDs exactly as in the
|
||||
catalog (e.g. `Arka-AI/DeepSeek-V4-Pro`, `Arka-AI/qwen3.8-max`, `Arka-AI/kimi-k3`).
|
||||
|
||||
## Adjust filtering
|
||||
|
||||
Edit `NON_CHAT` (regex) or `FORCED_MODELS` in the plugin file **and** the same
|
||||
lists in `scripts/sync-catalog.py` in `arka/public`, then re-run the installer
|
||||
and restart. `FORCED_MODELS` keeps must-have chat models even if the heuristic
|
||||
would drop them.
|
||||
`NON_CHAT` / `FORCED_MODELS` live in **three** places kept in lockstep:
|
||||
`opencode/plugins/arka-ai.ts` (1.x), the installer's inline generator (2.x), and
|
||||
`opencode/scripts/sync-catalog.py` (which rebuilds `catalog.json`). Edit all
|
||||
three, re-run the installer, restart.
|
||||
|
||||
## Probing plan coverage
|
||||
|
||||
The public catalog lists every platform model, not your plan's allow-list.
|
||||
Out-of-plan calls return `400 … does not support using vendor "arka"`. The
|
||||
allow-list lives only in the admin console (`/admin/data/subscriptions/<id>/edit`).
|
||||
Optional curated picker: `ARKA_PLAN_MODELS="…"` (1.x plugin only).
|
||||
Reference in new issue
Block a user