##本篇续写 上一篇 - 针对OpenClaw版本升级 自动更新使用文档
OpenClaw 模型管理(官方指令简版)版本V2026.3.11
https://blog.csdn.net/i_k_o_x_s/article/details/158975421?spm=1001.2014.3001.5502
升级后快速巡检(自动)
bash
# 第一次使用:建立基线
bin/openclaw-cli-help-check.sh init
# OpenClaw 升级后执行:对比官方命令是否变化
bin/openclaw-cli-help-check.sh check
# 若 check 提示变化:
# 1) 修改本文件
# 2) 确认后刷新基线
bin/openclaw-cli-help-check.sh update
脚本代码片段(按需自研使用)
powershell
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SNAPSHOT_DIR="$ROOT_DIR/.cli-help-snapshots"
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT
MODE="${1:-check}"
CHECKS=(
"models_help|openclaw models --help"
"models_set_help|openclaw models set --help"
"models_fallbacks_help|openclaw models fallbacks --help"
"models_aliases_help|openclaw models aliases --help"
"models_auth_help|openclaw models auth --help"
"models_status_help|openclaw models status --help"
"models_list_help|openclaw models list --help"
"config_help|openclaw config --help"
"config_set_help|openclaw config set --help"
"config_unset_help|openclaw config unset --help"
"config_get_help|openclaw config get --help"
"config_validate_help|openclaw config validate --help"
"gateway_restart_help|openclaw gateway restart --help"
"gateway_status_help|openclaw gateway status --help"
)
normalize_output() {
awk '
{
line = $0
gsub(/\r/, "", line)
gsub(/\033\[[0-9;]*[[:alpha:]]/, "", line)
raw[++n] = line
if (start == 0 && line ~ /^Usage: /) {
start = n
}
}
END {
if (start > 0) {
for (i = start; i <= n; i++) {
sub(/[[:space:]]+$/, "", raw[i])
print raw[i]
}
} else {
for (i = 1; i <= n; i++) {
sub(/[[:space:]]+$/, "", raw[i])
print raw[i]
}
}
}
'
}
capture_one() {
local key="$1"
local cmd="$2"
local raw_file="$TMP_DIR/${key}.raw"
local out_file="$TMP_DIR/${key}.txt"
local rc=0
if ! bash -lc "$cmd" >"$raw_file" 2>&1; then
rc=$?
fi
{
printf '# command: %s\n' "$cmd"
printf '# exit_code: %s\n\n' "$rc"
normalize_output <"$raw_file"
} >"$out_file"
}
refresh_snapshots() {
mkdir -p "$SNAPSHOT_DIR"
for entry in "${CHECKS[@]}"; do
local key cmd
IFS='|' read -r key cmd <<<"$entry"
capture_one "$key" "$cmd"
cp "$TMP_DIR/${key}.txt" "$SNAPSHOT_DIR/${key}.txt"
done
}
run_check() {
local changed=0
local missing=0
if [[ ! -d "$SNAPSHOT_DIR" ]]; then
echo "Snapshot directory not found: $SNAPSHOT_DIR"
echo "Run: $0 init"
return 2
fi
for entry in "${CHECKS[@]}"; do
local key cmd
IFS='|' read -r key cmd <<<"$entry"
capture_one "$key" "$cmd"
local base_file="$SNAPSHOT_DIR/${key}.txt"
local now_file="$TMP_DIR/${key}.txt"
local diff_file="$TMP_DIR/${key}.diff"
if [[ ! -f "$base_file" ]]; then
echo "[MISSING] $base_file"
missing=1
continue
fi
if ! diff -u "$base_file" "$now_file" >"$diff_file"; then
changed=1
echo ""
echo "[CHANGED] $key"
cat "$diff_file"
fi
done
if [[ "$missing" -eq 1 ]]; then
echo ""
echo "Some snapshot files are missing. Run: $0 update"
return 2
fi
if [[ "$changed" -eq 1 ]]; then
echo ""
echo "CLI help changed. Review diffs, then:"
echo "1) Update MODEL_COMMANDS_QUICKSTART.md"
echo "2) If accepted, run: $0 update"
return 1
fi
echo "No command-help drift detected."
return 0
}
print_usage() {
cat <<EOF
Usage: $0 [check|init|update]
Modes:
check Compare current OpenClaw CLI help with local snapshots (default)
init Create snapshots for the first time
update Refresh snapshots after you confirm command changes
EOF
}
case "$MODE" in
init)
refresh_snapshots
echo "Initialized snapshots at: $SNAPSHOT_DIR"
;;
update)
refresh_snapshots
echo "Updated snapshots at: $SNAPSHOT_DIR"
;;
check)
run_check
;;
-h|--help|help)
print_usage
;;
*)
print_usage
exit 2
;;
esac