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 小时前
【iOS】3G-Share仿写总结
macos·ios·cocoa
2501_916007473 小时前
iOS和macOS应用程序性能分析和优化工具使用综合指南
android·macos·ios·小程序·uni-app·iphone·webview
寒水馨1 天前
macOS下载、安装openclaw-v2026.7.1(附安装包OpenClaw-2026.7.1.dmg)
macos·大模型·github·开源软件·ai助手·openclaw·gpt-5.6
AC赳赳老秦1 天前
招投标公开数据自动化采集实战:基于 OpenClaw 的定时抓取与业务关键词精准推送
运维·服务器·数据库·自动化·测试用例·deepseek·openclaw
白玉cfc1 天前
【iOS】MRC和ARC
macos·ios·cocoa
飞雪金灵1 天前
mac电脑 Maven下载安装和配置环境变量
macos·maven·maven下载安装·mac电脑环境
雨声不在1 天前
macos 12使用docker
macos·docker·容器
一叶龙洲1 天前
ubuntu26.04 xfce美化成mac
服务器·ubuntu·macos
寒水馨1 天前
Windows 11下载、安装openclaw-v2026.7.1(附安装包OpenClawCompanion-Setup-x64.exe)
windows·大模型·开源软件·ai助手·openclaw·个人ai·中文版
李小白杂货铺2 天前
Oh My Zsh 简记
macos·macbook·zsh·主题·插件·oh my zsh·omz