npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

openclaw-rollback

v1.0.0

Published

OpenClaw 智能配置回滚系统 - 基于配置影响图谱与故障根因定位

Readme

OpenClaw Rollback

智能配置回滚系统 —— 基于配置影响图谱与故障根因定位

npm version

核心定位

不同于传统的"定时备份+全量回滚",OpenClaw Rollback 是首个将知识图谱与根因定位引入个人 AI 助手配置管理的系统。

三大核心能力:

  1. 🔍 故障根因定位 —— Gateway 挂了,精准定位是哪个配置项导致的,不再盲目全量回滚
  2. 🕸️ 配置影响图谱 —— 可视化展示配置项之间的依赖关系,改了 A 会波及哪些 B/C/D 一目了然
  3. 🛡️ 智能自动回滚 —— 基于健康状态的双向策略(健康时备份,异常时回滚),专为无人值守场景设计

安装

npm install -g openclaw-rollback

快速开始

# 查看帮助
ocr help

# 立即创建备份
ocr backup

# 查看配置影响图谱
ocr graph

# 分析某个配置项的影响范围
ocr impact gateway.port

# 故障根因定位
ocr root-cause port_unreachable "Connection refused"

# 查看配置变更历史
ocr changes

# 启动 Web UI
ocr webui

CLI 命令

| 命令 | 说明 | |------|------| | ocr backup | 立即创建备份 | | ocr restore <id> | 回滚到指定备份 | | ocr list | 列出所有备份 | | ocr delete <id> | 删除指定备份 | | ocr graph | 生成配置影响图谱 | | ocr impact <node> | 分析配置变更影响 | | ocr root-cause <type> <detail> | 故障根因定位 | | ocr changes | 查看配置变更历史 | | ocr status | 查看 Gateway 健康状态 | | ocr travel-mode [on\|off] | 开启/关闭出行模式 | | ocr webui | 启动 Web UI (端口 3739) | | ocr config | 显示当前配置 | | ocr daemon | 启动守护进程 |


核心功能

1. 配置影响图谱

自动扫描 ~/.openclaw/ 下的所有配置文件,构建知识图谱:

  • 节点:每个配置项(如 gateway.port, auth.token
  • :配置项之间的依赖/影响/冲突关系
  • 可视化:WebUI 力导向图展示,点击节点查看影响分析
ocr graph
# 输出:
# 📊 配置影响图谱 (23 节点, 15 关系)
# 🟦 节点:
#   gateway.port [gateway] 端口号
#   auth.token [auth] API认证令牌
#   ...
# ➡️  关系:
#   gateway.port --[influences]--> network.listen (强度:1.0)
#   auth.token --[depends_on]--> gateway.auth (强度:1.0)
#   ...

2. 变更影响分析

修改某个配置项前,先看看会影响什么:

ocr impact gateway.port
# 输出:
# 🔍 变更影响分析: gateway.port
# 📊 风险评分: 85/100
# ⚠️ 警告: 修改端口号可能导致服务无法访问
# 📌 直接影响: network.listen, network.proxy
# 🔗 间接影响: gateway.workers
# 📁 可能受影响的文件: openclaw.json

3. 故障根因定位

Gateway 挂了,精准定位根因:

ocr root-cause port_unreachable "Connection refused"
# 输出:
# 🚨 故障根因定位报告
# 🎯 最可能根因: gateway.port
# 置信度: 87.5%
# 📋 证据链:
#   1. 故障模式识别: 端口不可达
#   2. 该配置在故障前180秒被修改,时间非常接近
#   3. 该配置项(gateway)与故障模式(端口配置或网络问题)高度相关
#   4. 该配置属于系统关键配置
# 💡 修复建议: 检查 gateway.port 的值是否正确...

4. 配置变更追踪

自动记录每次配置变更的 diff:

ocr changes
# 输出:
# 📋 最近 10 条配置变更:
#   1. [2026-06-12 10:30:00] openclaw.json
#      gateway.port: 3000 → 3001
#   2. [2026-06-12 09:15:00] openclaw.json
#      auth.token: "abc123" → "xyz789"

5. 出行模式 (Travel Mode)

专为无人值守/出差/黑盒子场景设计:

  • 定时检测 Gateway 健康(10分钟/2小时/8小时可选)
  • 健康 → 自动创建 "known-good" 备份
  • 异常 → 自动回滚到最后 "known-good" 备份
  • 双重确认机制:回滚前等待3秒二次检测,避免误判
ocr travel-mode on
ocr travel-interval 120    # 每2小时检查一次

技术架构

| 模块 | 文件 | 功能 | |------|------|------| | 配置图谱 | src/config-graph.ts | 知识图谱构建、影响分析、根因定位 | | 核心引擎 | src/core.ts | 备份扫描、文件复制、回滚逻辑、配置读写 | | 守护进程 | src/daemon.ts | node-cron 定时备份+出行模式检测 | | Web 服务 | src/webui.ts | Express HTTP 服务器 + REST API | | CLI 接口 | src/cli.ts / bin/cli.js | 命令行交互 | | 前端 | webui/index.html | 单页面 Web UI(Tab 导航) |


Web UI

启动:ocr webui → 访问 http://localhost:3739

四个独立页面:

  1. 📊 主控台 — 系统状态、备份列表、出行模式管理
  2. 🕸️ 影响图谱 — 可视化配置关系图,点击节点查看影响分析
  3. 🎯 根因定位 — 选择故障类型,一键分析根因
  4. 📝 变更历史 — 所有配置变更的时间线

故障-配置映射

系统内置 8 种故障模式的知识库:

| 故障模式 | 可能根因配置 | 检测方式 | |----------|-------------|----------| | 端口不可达 | gateway.port, network.* | TCP 连接检测 | | 认证失败(401) | auth.token, auth.* | HTTP 401/403 检测 | | 权限不足(403) | auth.permissions | HTTP 403 检测 | | 进程崩溃 | plugins.*, memory.* | 进程存活检测 | | 配置解析错误 | 任意配置文件 | JSON/YAML 语法检测 | | 插件加载失败 | plugins.* | 模块加载检测 | | Agent 连接失败 | agents.* | Agent 心跳检测 | | Skill 执行错误 | skills.* | 工具调用检测 |


配置

配置文件位置:~/.openclaw/extensions/openclaw-rollback/config.json

{
  "autoBackup": true,
  "maxBackups": 10,
  "webUIPort": 3739,
  "backupItems": [],
  "travelMode": false,
  "travelModeInterval": 120,
  "travelModeMaxBackups": 20
}

版本历史

| 版本 | 日期 | 说明 | |------|------|------| | 1.0.0 | 2026-06-12 | 初始版本:配置影响图谱 + 故障根因定位 + 智能回滚 + 变更追踪 |


License

MIT