feat(opencode): support opencode 2.x + generation-aware installer
opencode 2.x changed the plugin API (a plugin must export { id, setup }), so
the 1.x plugin (plugins/arka-ai.ts) no longer loads there and the Arka-AI
provider disappeared ('failed to load plugin').
- install-arka-provider.sh / .ps1 now detect the generation (opencode --version:
'1.x.y' vs 'opencode v2.x.y'; --gen / -Gen override):
* 1.x -> install the plugin (dynamic catalog), as before;
* 2.x -> write a static providers["Arka-AI"] block
(package @opencode/ai/providers/openai-compatible, settings.baseURL,
settings.apiKey, models from catalog.json) and disable any stale 1.x plugin.
- --refresh / -Refresh regenerates the 2.x model list (infers generation 2 from
the installed config); 1.x still clears the cache.
- README + companion skill updated with the 1.x/2.x table, detection, and the
providers schema.
Verified: gen detection, gen1 plugin write, gen2 providers write (117 models),
merge preserves unrelated keys, stale plugin disabled, refresh keeps the key.
This commit is contained in:
1 parent
1d3b2499cc
commit
ed34998cb7
4 files changed
+490
-228
No files matched your search
+272
-112
@@ -3,39 +3,49 @@
|
||||
# install-arka-provider.sh — one-shot installer for the arka-ai.ru LLM provider
|
||||
# in a fresh opencode install.
|
||||
#
|
||||
# It is fully self-contained: it embeds the provider plugin and the companion
|
||||
# skill, writes them into ~/.config/opencode, and persists ARKA_API_KEY.
|
||||
# Works with BOTH opencode generations, detected automatically:
|
||||
# * opencode 1.x -> installs a plugin (plugins/arka-ai.ts) that injects the
|
||||
# provider + catalog dynamically via the `config` hook.
|
||||
# * opencode 2.x -> writes a static `providers["Arka-AI"]` block into the
|
||||
# config (package openai-compatible + baseURL + models).
|
||||
# opencode 2.x changed the plugin API, so the 1.x plugin
|
||||
# no longer loads there; the static block needs no plugin.
|
||||
#
|
||||
# Usage:
|
||||
# bash install-arka-provider.sh # prompt for API key
|
||||
# ARKA_API_KEY=xxx bash install-arka-provider.sh # key from env (no prompt)
|
||||
# bash install-arka-provider.sh --key xxx --set-default DeepSeek-V4-Pro
|
||||
# bash install-arka-provider.sh --refresh # refresh the model list
|
||||
# bash install-arka-provider.sh --gen 2 # force generation (1|2)
|
||||
#
|
||||
# Options:
|
||||
# --key KEY ARKA_API_KEY to persist (default: $ARKA_API_KEY, else prompt)
|
||||
# --set-default MODEL also set "model": "Arka-AI/<MODEL>" in opencode.json
|
||||
# --set-default MODEL also set "model": "Arka-AI/<MODEL>"
|
||||
# --gen {1|2} force opencode generation (default: detect)
|
||||
# --refresh only refresh the model list, keep everything else
|
||||
# -h, --help show this help
|
||||
#
|
||||
# Idempotent: safe to run multiple times. Overwrites plugin/skill with the
|
||||
# embedded versions; never clobbers an existing opencode.json (only upserts the
|
||||
# requested default model). Makes no network calls.
|
||||
# Idempotent: safe to run multiple times. Never clobbers unrelated config keys.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
sed -n '2,21p' "$0"
|
||||
}
|
||||
usage() { sed -n '2,30p' "$0"; }
|
||||
|
||||
KEY=""
|
||||
MODEL=""
|
||||
GEN=""
|
||||
REFRESH=0
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--key) KEY="$2"; shift 2 ;;
|
||||
--key=*) KEY="${1#*=}"; shift ;;
|
||||
--set-default) MODEL="$2"; shift 2 ;;
|
||||
--key) KEY="$2"; shift 2 ;;
|
||||
--key=*) KEY="${1#*=}"; shift ;;
|
||||
--set-default) MODEL="$2"; shift 2 ;;
|
||||
--set-default=*) MODEL="${1#*=}"; shift ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
--gen) GEN="$2"; shift 2 ;;
|
||||
--gen=*) GEN="${1#*=}"; shift ;;
|
||||
--refresh) REFRESH=1; shift ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) printf 'unknown option: %s\n' "$1" >&2; usage; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
@@ -43,11 +53,134 @@ done
|
||||
CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/opencode"
|
||||
PLUGIN_DIR="$CONF_DIR/plugins"
|
||||
SKILL_DIR="$CONF_DIR/skills/arka-provider"
|
||||
CATALOG_URL="https://git.arka-ai.ru/arka/public/raw/branch/main/opencode/catalog.json"
|
||||
API_URL="https://api.arka-ai.ru/v1"
|
||||
|
||||
mkdir -p "$PLUGIN_DIR" "$SKILL_DIR" "$HOME"
|
||||
|
||||
echo "==> writing provider plugin to $PLUGIN_DIR/arka-ai.ts"
|
||||
cat > "$PLUGIN_DIR/arka-ai.ts" <<'PLUGIN'
|
||||
# --- detect the opencode generation ------------------------------------
|
||||
detect_gen() {
|
||||
local v major
|
||||
if [ -n "${OPENCODE_GEN:-}" ]; then echo "$OPENCODE_GEN"; return; fi
|
||||
v="$(opencode --version 2>/dev/null | head -1 || true)"
|
||||
major="$(printf '%s' "$v" | grep -oE '[0-9]+' | head -1 || true)"
|
||||
if [ -z "$major" ]; then echo ""; return; fi
|
||||
if [ "$major" -ge 2 ] 2>/dev/null; then echo 2; else echo 1; fi
|
||||
}
|
||||
|
||||
# On --refresh, trust what is actually installed over a possibly-absent/other
|
||||
# `opencode` binary on PATH.
|
||||
if [ -z "$GEN" ] && [ "$REFRESH" -eq 1 ]; then
|
||||
for f in "$CONF_DIR/opencode.jsonc" "$CONF_DIR/opencode.json"; do
|
||||
if [ -f "$f" ] && grep -q '"Arka-AI"' "$f" 2>/dev/null; then GEN=2; break; fi
|
||||
done
|
||||
[ -z "$GEN" ] && [ -f "$PLUGIN_DIR/arka-ai.ts" ] && GEN=1
|
||||
fi
|
||||
|
||||
if [ -z "$GEN" ]; then GEN="$(detect_gen)"; fi
|
||||
if [ -z "$GEN" ]; then
|
||||
printf '!! could not detect opencode version (is `opencode` on PATH?)\n' >&2
|
||||
printf '!! defaulting to generation 2; pass --gen 1 for opencode 1.x\n' >&2
|
||||
GEN=2
|
||||
fi
|
||||
case "$GEN" in 1|2) ;; *) printf 'invalid --gen %s (want 1 or 2)\n' "$GEN" >&2; exit 1 ;; esac
|
||||
echo "==> opencode generation: $GEN"
|
||||
|
||||
# --- companion skill (shared by both generations) ----------------------
|
||||
write_skill() {
|
||||
echo "==> writing companion skill to $SKILL_DIR/SKILL.md"
|
||||
cat > "$SKILL_DIR/SKILL.md" <<'SKILL'
|
||||
---
|
||||
name: arka-provider
|
||||
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. **The mechanism depends on the opencode generation:**
|
||||
|
||||
| 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) |
|
||||
|
||||
`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.)
|
||||
|
||||
## 1.x — plugin (dynamic catalog)
|
||||
|
||||
- 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`.
|
||||
|
||||
## 2.x — static config
|
||||
|
||||
- `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
|
||||
|
||||
`"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
|
||||
|
||||
`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).
|
||||
SKILL
|
||||
}
|
||||
write_skill
|
||||
|
||||
# --- refresh-only mode -------------------------------------------------
|
||||
if [ "$REFRESH" -eq 1 ]; then
|
||||
if [ "$GEN" = 1 ]; then
|
||||
rm -f "${XDG_CACHE_HOME:-$HOME/.cache}/opencode/arka-ai-models.json" 2>/dev/null || true
|
||||
echo "==> cleared arka-ai-models.json cache; restart opencode to refetch."
|
||||
exit 0
|
||||
fi
|
||||
# generation 2: regenerate the static models block in place
|
||||
echo "==> refreshing Arka-AI models (generation 2)"
|
||||
MODEL="__KEEP__"
|
||||
# fall through to the generation-2 config writer below
|
||||
fi
|
||||
|
||||
# =======================================================================
|
||||
# Generation 1 — plugin
|
||||
# =======================================================================
|
||||
if [ "$GEN" = 1 ] && [ "$REFRESH" -eq 0 ]; then
|
||||
echo "==> writing provider plugin to $PLUGIN_DIR/arka-ai.ts"
|
||||
cat > "$PLUGIN_DIR/arka-ai.ts" <<'PLUGIN'
|
||||
import { homedir } from "node:os"
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"
|
||||
import { join } from "node:path"
|
||||
@@ -97,7 +230,7 @@ const FORCED_MODELS = [
|
||||
|
||||
// Heuristic: drop non-chat models (TTS/ASR/image/video/OCR/embeddings/rerankers…)
|
||||
// from the catalog so they don't clutter the /models picker.
|
||||
// Keep in sync with scripts/sync-catalog.py
|
||||
// Keep in sync with scripts/sync-catalog.py and the installer's 2.x generator.
|
||||
const NON_CHAT = new RegExp(
|
||||
[
|
||||
"tts", "asr", "audio", "speech", "voice", "whisper", "sensevoice",
|
||||
@@ -218,125 +351,152 @@ export default async function ArkaAIProviderPlugin() {
|
||||
}
|
||||
}
|
||||
PLUGIN
|
||||
fi
|
||||
|
||||
echo "==> writing companion skill to $SKILL_DIR/SKILL.md"
|
||||
cat > "$SKILL_DIR/SKILL.md" <<'SKILL'
|
||||
---
|
||||
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.
|
||||
---
|
||||
# =======================================================================
|
||||
# Generation 2 — static providers block
|
||||
# =======================================================================
|
||||
if [ "$GEN" = 2 ] || [ "$REFRESH" -eq 1 ]; then
|
||||
# Disable a stale 1.x plugin so 2.x doesn't spam load errors.
|
||||
if [ -f "$PLUGIN_DIR/arka-ai.ts" ]; then
|
||||
echo "==> disabling stale 1.x plugin (opencode 2.x cannot load it)"
|
||||
mv "$PLUGIN_DIR/arka-ai.ts" "$PLUGIN_DIR/arka-ai.ts.disabled"
|
||||
fi
|
||||
|
||||
# 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`.
|
||||
|
||||
## How it works
|
||||
|
||||
- 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).
|
||||
|
||||
## Refresh the model list
|
||||
|
||||
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).
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
## 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`).
|
||||
|
||||
## 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.
|
||||
SKILL
|
||||
CATALOG_TMP="$(mktemp)"; trap 'rm -f "$CATALOG_TMP"' EXIT
|
||||
echo "==> fetching chat catalog $CATALOG_URL"
|
||||
if ! curl -fsSL "$CATALOG_URL" -o "$CATALOG_TMP" 2>/dev/null || [ ! -s "$CATALOG_TMP" ]; then
|
||||
echo "==> catalog fetch failed; falling back to $API_URL/models"
|
||||
curl -fsSL "$API_URL/models" -o "$CATALOG_TMP" 2>/dev/null || : > "$CATALOG_TMP"
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- API key -----------------------------------------------------------
|
||||
|
||||
if [ -z "$KEY" ]; then
|
||||
read -rsp "ARKA_API_KEY (leave blank to skip): " KEY || true
|
||||
echo
|
||||
fi
|
||||
|
||||
if [ -n "$KEY" ]; then
|
||||
RC=""
|
||||
for f in "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.profile"; do
|
||||
if [ -f "$f" ]; then RC="$f"; break; fi
|
||||
done
|
||||
RC="${RC:-$HOME/.bashrc}"
|
||||
touch "$RC"
|
||||
if grep -q 'ARKA_API_KEY' "$RC"; then
|
||||
echo "==> ARKA_API_KEY already present in $RC (skipped)"
|
||||
if [ "$REFRESH" -eq 0 ]; then
|
||||
if [ -z "$KEY" ]; then
|
||||
read -rsp "ARKA_API_KEY (leave blank to skip): " KEY || true
|
||||
echo
|
||||
fi
|
||||
if [ -n "$KEY" ]; then
|
||||
RC=""
|
||||
for f in "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.profile"; do
|
||||
if [ -f "$f" ]; then RC="$f"; break; fi
|
||||
done
|
||||
RC="${RC:-$HOME/.bashrc}"
|
||||
touch "$RC"
|
||||
if grep -q 'ARKA_API_KEY' "$RC"; then
|
||||
echo "==> ARKA_API_KEY already present in $RC (skipped)"
|
||||
else
|
||||
printf '\n# opencode Arka-AI provider\nexport ARKA_API_KEY="%s"\n' "$KEY" >> "$RC"
|
||||
echo "==> wrote ARKA_API_KEY to $RC"
|
||||
fi
|
||||
export ARKA_API_KEY="$KEY"
|
||||
printf '%s\n' "$KEY" > "$CONF_DIR/.arka-api-key"
|
||||
chmod 600 "$CONF_DIR/.arka-api-key" 2>/dev/null || true
|
||||
echo "==> wrote API key to $CONF_DIR/.arka-api-key"
|
||||
else
|
||||
printf '\n# opencode Arka-AI provider\nexport ARKA_API_KEY="%s"\n' "$KEY" >> "$RC"
|
||||
echo "==> wrote ARKA_API_KEY to $RC"
|
||||
echo "==> warning: no ARKA_API_KEY set; export it (or re-run with --key) so requests authenticate" >&2
|
||||
fi
|
||||
export ARKA_API_KEY="$KEY"
|
||||
KEY_FILE="$CONF_DIR/.arka-api-key"
|
||||
printf '%s\n' "$KEY" > "$KEY_FILE"
|
||||
chmod 600 "$KEY_FILE" 2>/dev/null || true
|
||||
echo "==> wrote API key to $KEY_FILE (CLI + Desktop)"
|
||||
else
|
||||
echo "==> warning: no ARKA_API_KEY set; export it in your shell before starting opencode" >&2
|
||||
fi
|
||||
|
||||
# --- default model (optional) ------------------------------------------
|
||||
# --- generation 2: write/refresh the providers block -------------------
|
||||
if [ "$GEN" = 2 ]; then
|
||||
CONF=""
|
||||
for f in "$CONF_DIR/opencode.jsonc" "$CONF_DIR/opencode.json"; do
|
||||
[ -f "$f" ] && { CONF="$f"; break; }
|
||||
done
|
||||
CONF="${CONF:-$CONF_DIR/opencode.jsonc}"
|
||||
|
||||
if [ -n "$MODEL" ]; then
|
||||
echo "==> writing providers[\"Arka-AI\"] to $CONF"
|
||||
KEY_PRESENT="$([ -n "${KEY:-}" ] && echo 1 || echo 0)"
|
||||
# If --refresh without --key, reuse the stored key file.
|
||||
if [ "$KEY_PRESENT" = 0 ] && [ -s "$CONF_DIR/.arka-api-key" ]; then
|
||||
KEY="$(cat "$CONF_DIR/.arka-api-key")"; KEY_PRESENT=1
|
||||
fi
|
||||
python3 - "$CONF" "$CATALOG_TMP" "${MODEL:-}" "$KEY_PRESENT" "${KEY:-}" <<'PY'
|
||||
import json, os, re, sys
|
||||
|
||||
path, catalog, model, have_key, key = sys.argv[1:6]
|
||||
data = {}
|
||||
if os.path.exists(path):
|
||||
txt = open(path, encoding="utf-8").read()
|
||||
try:
|
||||
data = json.loads(re.sub(r"(?m)//.*$", "", txt))
|
||||
except Exception:
|
||||
data = {}
|
||||
if not isinstance(data, dict):
|
||||
data = {}
|
||||
|
||||
data.setdefault("$schema", "https://opencode.ai/config.json")
|
||||
|
||||
ids = []
|
||||
try:
|
||||
payload = json.load(open(catalog, encoding="utf-8"))
|
||||
ids = [m["id"] for m in payload.get("data", []) if m.get("id")]
|
||||
except Exception:
|
||||
ids = []
|
||||
|
||||
prov = data.setdefault("providers", {}).setdefault("Arka-AI", {})
|
||||
prov["name"] = "Arka-AI"
|
||||
prov["package"] = "@opencode/ai/providers/openai-compatible"
|
||||
prov["env"] = ["ARKA_API_KEY"]
|
||||
settings = prov.setdefault("settings", {})
|
||||
settings["baseURL"] = "https://api.arka-ai.ru/v1"
|
||||
if have_key == "1" and key:
|
||||
settings["apiKey"] = key
|
||||
if ids:
|
||||
prov["models"] = {i: {"name": i} for i in ids}
|
||||
|
||||
if model and model != "__KEEP__":
|
||||
data["model"] = model
|
||||
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=2)
|
||||
f.write("\n")
|
||||
os.chmod(path, 0o600)
|
||||
print("models:", len(prov.get("models", {})), "key:", "yes" if settings.get("apiKey") else "no")
|
||||
PY
|
||||
fi
|
||||
|
||||
# --- generation 1: optional default model ------------------------------
|
||||
if [ "$GEN" = 1 ] && [ -n "$MODEL" ]; then
|
||||
CONF="$CONF_DIR/opencode.json"
|
||||
echo "==> setting default model Arka-AI/$MODEL in $CONF"
|
||||
python3 - "$CONF" "Arka-AI/$MODEL" <<'PY'
|
||||
import json, os, sys
|
||||
|
||||
path, model = sys.argv[1], sys.argv[2]
|
||||
data = {}
|
||||
if os.path.exists(path):
|
||||
with open(path) as f:
|
||||
data = json.load(f)
|
||||
try:
|
||||
data = json.load(open(path))
|
||||
except Exception:
|
||||
data = {}
|
||||
data.setdefault("$schema", "https://opencode.ai/config.json")
|
||||
data["model"] = model
|
||||
with open(path, "w") as f:
|
||||
json.dump(data, f, indent=2)
|
||||
f.write("\n")
|
||||
json.dump(data, f, indent=2); f.write("\n")
|
||||
PY
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Done."
|
||||
echo " - provider plugin: $PLUGIN_DIR/arka-ai.ts"
|
||||
if [ "$REFRESH" -eq 1 ]; then
|
||||
echo "Done. Model list refreshed. Restart opencode to pick it up."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Done (opencode generation $GEN)."
|
||||
if [ "$GEN" = 1 ]; then
|
||||
echo " - provider plugin: $PLUGIN_DIR/arka-ai.ts"
|
||||
else
|
||||
echo " - provider config: $CONF (providers[\"Arka-AI\"])"
|
||||
fi
|
||||
echo " - skill: $SKILL_DIR/SKILL.md"
|
||||
echo
|
||||
echo "Next steps:"
|
||||
echo " 1. Fully quit and restart OpenCode (CLI or Desktop). Plugins load only at startup."
|
||||
echo " 2. Run /models — the Arka-AI catalog (~116 chat models) loads on first start."
|
||||
echo " 3. Optional: refresh catalog later with: rm -f ~/.cache/opencode/arka-ai-models.json"
|
||||
echo " 1. Fully quit and restart OpenCode (CLI or Desktop) — config/plugins load at startup."
|
||||
echo " 2. /models → provider Arka-AI."
|
||||
if [ "$GEN" = 2 ]; then
|
||||
echo " 3. After catalog changes: bash install-arka-provider.sh --refresh"
|
||||
else
|
||||
echo " 3. After catalog changes: rm -f ~/.cache/opencode/arka-ai-models.json"
|
||||
fi
|
||||
Reference in new issue
Block a user