OpenClaw 版本升级 自动更新指令文档

##本篇续写 上一篇 - 针对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
相关推荐
研究点啥好呢2 小时前
每日GitHub热门项目推荐 | 2026年3月9日
人工智能·ai·自动化·github·openclaw
燃于AC之乐2 小时前
OpenClaw“小龙虾”深度解析:60天碾压Linux的AI智能体,从原理到搞定本地部署【Windows系统 + 接入飞书】
linux·人工智能·飞书·openclaw·小龙虾
wal13145202 小时前
OpenClaw教程补充内容——如何进行飞书Bot的配置
人工智能·飞书·openclaw
悟纤2 小时前
OpenClaw 安装与运行教程 | OpenClaw教程 | 第2篇
人工智能·ai agent·openclaw
脱脱克克2 小时前
OpenClaw 安装与配置全教程(Ubuntu 全新虚拟机版)
ubuntu·环境配置·openclaw
程序大视界4 小时前
Mac电脑详细养小龙虾教程
人工智能·ai·openclaw
MintonLee复现侠4 小时前
保姆级教程:Win+openclaw+阿里百炼大模型+飞书
飞书·openclaw·百炼大模型
每天都在健身的程序员4 小时前
OpenClaw 部署 + 飞书对接完整教程【防踩坑版】
python·openclaw
AryShaw4 小时前
macOS 上搭建 RK3568 交叉编译环境
linux·macos