Add AI test, doctor, and interactive setup wizard

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp
This commit is contained in:
2026-08-24 20:45:47 -04:00
co-authored by Claude Fable 5
parent 3760ac46e2
commit 870ee40c7a
3 changed files with 175 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
#!/bin/bash
# omarchy:summary=Interactive wizard: pick harness, provider, model, store key, test
# omarchy:examples=omarchycn ai setup
set -euo pipefail
source "$OMARCHY_PATH/cn/lib/ai.sh"
if [[ ! -t 0 ]]; then
echo "omarchycn ai setup 需要交互终端;非交互场景用 omarchycn ai profile create" >&2
exit 1
fi
harness=$(cn_ai_harness_ids | gum choose --header "选择 Harness")
mapfile -t providers < <(jq -r --arg h "$harness" '.combos[$h] | keys[]' "$CN_AI_COMPAT")
if (( ${#providers[@]} == 0 )); then
echo "兼容矩阵中没有 $harness 的 Provider 组合" >&2
exit 1
fi
provider=$(printf '%s\n' "${providers[@]}" | gum choose --header "选择 Provider(兼容级别见 docs")
allowlist=$(cn_ai_combo_models "$harness" "$provider")
if [[ -n $allowlist ]]; then
model=$(gum choose --header "选择模型" <<<"$allowlist")
else
model=$(cn_ai_models "$provider" | gum choose --header "选择模型")
fi
default_name="$harness-$provider"
name=$(gum input --header "Profile 名称" --value "$default_name")
if ! omarchy-cn-ai-secret get "$provider" > /dev/null 2>&1; then
key=$(gum input --password --header "$provider API Key(获取: $(jq -r --arg p "$provider" '.providers[$p].key_url' "$CN_AI_PROVIDERS")")
printf '%s' "$key" | omarchy-cn-ai-secret set "$provider"
fi
omarchy-cn-ai-profile-create "$name" "$harness" "$provider" "$model"
omarchy-cn-ai-profile-use "$name"
proto=$(cn_ai_harness_field "$harness" protocol)
if [[ $proto != "native" ]] && gum confirm "运行连接测试?"; then
omarchy-cn-ai-test "$name"
fi
echo "完成。启动: omarchycn ai launch"