Wizard: preserve prior profile until new config passes its test
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp
This commit is contained in:
+14
-2
@@ -50,15 +50,27 @@ if ! omarchy-cn-ai-secret get "$provider" > /dev/null 2>&1; then
|
|||||||
printf '%s' "$key" | omarchy-cn-ai-secret set "$provider"
|
printf '%s' "$key" | omarchy-cn-ai-secret set "$provider"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Keep any existing profile intact until the new config proves itself
|
||||||
|
profile_file="$CN_AI_PROFILE_DIR/$name.toml"
|
||||||
|
if [[ -f $profile_file ]]; then
|
||||||
|
cp "$profile_file" "$profile_file.omarchycn-prev"
|
||||||
|
fi
|
||||||
|
|
||||||
omarchy-cn-ai-profile-create "$name" "$harness" "$provider" "$model"
|
omarchy-cn-ai-profile-create "$name" "$harness" "$provider" "$model"
|
||||||
|
|
||||||
# Activate only after the test passes (or the user skips it)
|
|
||||||
if gum confirm "运行连接测试?"; then
|
if gum confirm "运行连接测试?"; then
|
||||||
if ! omarchy-cn-ai-test "$name"; then
|
if ! omarchy-cn-ai-test "$name"; then
|
||||||
echo "测试未通过,Profile $name 已创建但未设为默认;修复后运行: omarchycn ai profile use $name" >&2
|
if [[ -f $profile_file.omarchycn-prev ]]; then
|
||||||
|
mv "$profile_file.omarchycn-prev" "$profile_file"
|
||||||
|
echo "测试未通过,已恢复原 Profile $name" >&2
|
||||||
|
else
|
||||||
|
rm -f "$profile_file"
|
||||||
|
echo "测试未通过,Profile $name 未保留" >&2
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rm -f "$profile_file.omarchycn-prev"
|
||||||
omarchy-cn-ai-profile-use "$name"
|
omarchy-cn-ai-profile-use "$name"
|
||||||
echo "完成。启动: omarchycn ai launch"
|
echo "完成。启动: omarchycn ai launch"
|
||||||
|
|||||||
Reference in New Issue
Block a user