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
+47
View File
@@ -0,0 +1,47 @@
#!/bin/bash
# omarchy:summary=Check AI harness installation, credentials, and endpoint health
# omarchy:examples=omarchycn ai doctor
set -euo pipefail
source "$OMARCHY_PATH/cn/lib/ai.sh"
failures=0
profile=$(cn_ai_current_profile 2>/dev/null || true)
if [[ -z $profile ]]; then
echo "INFO ai: 未设置默认 Profile (omarchycn ai profile use <name>)"
exit 0
fi
echo "INFO ai: current profile $profile"
harness=$(cn_ai_profile_field "$profile" harness)
provider=$(cn_ai_profile_field "$profile" provider)
command=$(cn_ai_harness_field "$harness" command)
proto=$(cn_ai_harness_field "$harness" protocol)
if command -v "$command" > /dev/null 2>&1; then
echo "PASS ai: harness $harness installed ($command)"
else
echo "WARN ai: harness $harness 未安装,首次 launch 时自动安装"
fi
if omarchy-cn-ai-secret get "$provider" > /dev/null 2>&1; then
echo "PASS ai: $provider API Key stored"
else
echo "FAIL ai: $provider API Key 未存储 (omarchycn ai secret set $provider)"
failures=$((failures + 1))
fi
if [[ $proto != "native" ]]; then
base=$(cn_ai_endpoint "$provider" "$proto")
host=$(sed -E 's|https?://([^/]+).*|\1|' <<<"$base")
if getent hosts "$host" > /dev/null 2>&1; then
echo "PASS ai: endpoint DNS resolves ($host)"
else
echo "FAIL ai: endpoint DNS 无法解析 ($host)"
failures=$((failures + 1))
fi
fi
exit $((failures > 0 ? 1 : 0))