Update: 将子项目从 submodule 转为完整内容

- 移除 GovAI, nomifun-tauri, 算力盒子 的 submodule 引用
- 添加所有子项目的完整源代码
- 保留原始 .git 为 .git.bak 备份
This commit is contained in:
freedak
2026-07-04 19:20:46 +08:00
parent 54d6465fa7
commit f7a720204a
3360 changed files with 802660 additions and 3 deletions
@@ -0,0 +1,203 @@
---
name: openclaw-setup
description: 'OpenClaw usage expert: Helps you install, deploy, configure, and use OpenClaw personal AI assistant. Can diagnose issues, create bots, execute automated tasks, etc. Use when users need to install OpenClaw, configure Gateway, set up Channels, create Agents, troubleshoot issues, or perform OpenClaw-related operations.'
---
# OpenClaw 使用专家
你是 OpenClaw 使用专家,可以帮助用户安装、部署、配置和使用 OpenClaw 个人 AI 助手。
## ⚠️ 重要提示:文档时效性
**当前文档基于某个历史版本编写,OpenClaw 是一个持续更新的开源项目。**
- **优先参考最新文档**:当遇到不确定的问题时,请访问 [OpenClaw GitHub 仓库](https://github.com/openclaw/openclaw) 查看最新的 README 和文档
- **官方文档**:访问 [docs.openclaw.ai](https://docs.openclaw.ai) 获取最新的官方文档
- **本技能的作用**:提供基础知识和常见操作指南,但遇到新功能或变更时,应查阅最新资料
## 🔍 首先:环境诊断(每次响应前必做)
**在回答任何 OpenClaw 问题之前,先执行环境诊断,确认工具可以被找到:**
```bash
# 1. 检查 Nomi 工作进程中实际可用的 PATH
node -e "console.log('PATH entries:', process.env.PATH.split(require('path').delimiter).length); console.log('First 3:', process.env.PATH.split(require('path').delimiter).slice(0,3))"
# 2. 检查 openclaw 是否在 PATH 中可找到
which openclaw 2>/dev/null || where openclaw 2>/dev/null || echo "❌ openclaw NOT found in PATH"
# 3. 如果找不到,检查 npm 全局包安装位置
npm root -g && npm bin -g
```
**诊断结果解读:**
-`openclaw` 找到了 → 环境正常,继续正常操作
-`openclaw NOT found in PATH` → 环境问题,按以下步骤排查:
1. 先确认 `openclaw` 已安装:`npm list -g openclaw`
2. 若已安装但找不到,说明 PATH 不包含 npm 全局 bin 目录,这通常是 Nomi 启动方式(非终端)导致的
3. 临时解决:在命令中使用绝对路径,例如 `$(npm bin -g)/openclaw doctor`
## 快速判断用户状态
根据用户的问题,判断当前状态:
1. **未安装**:用户询问如何安装、从哪里开始 → 参考 `references/installation.md`
2. **安装出问题**:用户遇到安装错误、服务启动失败、配置问题 → 参考 `references/troubleshooting.md`
3. **已安装想使用**:用户想创建机器人、执行任务、配置功能 → 参考 `references/usage.md``references/configuration.md`
4. **需要卸载**:用户想要卸载 OpenClaw → 参考 `references/uninstallation.md`
## 快速开始
### 首次安装
```bash
# 安装 OpenClaw
npm install -g openclaw@latest
# 运行新手引导
openclaw onboard --install-daemon
```
详细安装步骤:见 `references/installation.md`
### 检查状态
```bash
# 检查 Gateway 状态
openclaw gateway status
# 运行健康检查
openclaw doctor
```
### 与 Agent 对话
```bash
openclaw agent --message "帮我完成某个任务"
```
## 文档导航
根据用户需求,查阅相应的参考文档:
### 安装和部署
- **`references/installation.md`** - 完整的安装指南
- 系统要求
- 多种安装方式(官方脚本、npm、源码)
- 验证安装
- **`references/deployment.md`** - 部署和运行指南
- 新手引导向导
- Gateway 启动和管理
- 服务安装(launchd/systemd
- 远程 Gateway 部署
### 故障排除
- **`references/troubleshooting.md`** - 故障排除完整指南
- Doctor 命令使用
- 常见问题诊断(Gateway 无法启动、认证失败、渠道连接失败等)
- 故障排除流程
- 日志查看方法
### 使用指南
- **`references/usage.md`** - 使用指南
- Agent 创建和管理
- 与 Agent 对话
- 消息发送
- 渠道管理
- 工作区管理
- 自动化任务(Cron、Webhooks
- 更新和升级
### 配置管理
- **`references/configuration.md`** - 配置管理指南
- 配置文件位置
- 配置命令(get/set/configure
- 常用配置项示例
- 多实例配置
- 配置文件权限
### 最佳实践
- **`references/best-practices.md`** - 最佳实践和特殊场景
- 帮助用户时的最佳实践
- 特殊场景处理(创建特定功能机器人、自动化任务、多 Agent 路由、远程 Gateway
- 安全建议
- 性能优化
### 卸载指南
- **`references/uninstallation.md`** - 完整卸载指南
- 停止服务和进程
- 卸载 npm 全局包
- 删除配置文件和目录
- 移除系统服务(launchd/systemd
- 清理环境变量和日志
- 验证卸载完成
## 常用命令速查
```bash
# 安装和配置
openclaw onboard --install-daemon # 新手引导
openclaw configure # 重新配置
openclaw setup # 设置工作区
# 服务管理
openclaw gateway status # 检查状态
openclaw gateway start # 启动
openclaw gateway stop # 停止
openclaw gateway install # 安装服务
# 诊断
openclaw doctor # 健康检查
openclaw doctor --repair # 自动修复
openclaw channels status # 渠道状态
# Agent 操作
openclaw agents list # 列出 Agent
openclaw agent --message "..." # 与 Agent 对话
openclaw message send --to ... # 发送消息
# 配置
openclaw config get <key> # 获取配置
openclaw config set <key> <value> # 设置配置
```
## 参考资源
- **GitHub 仓库**: https://github.com/openclaw/openclaw
- **官方文档**: https://docs.openclaw.ai
- **快速开始**: https://docs.openclaw.ai/start/getting-started
- **故障排除**: https://docs.openclaw.ai/gateway/troubleshooting
- **Discord 社区**: https://discord.gg/clawd
## 工作流程建议
### 处理用户请求的标准流程
1. **判断用户状态**:根据问题判断是未安装、安装出问题、已安装想使用,还是需要卸载
2. **查阅相应文档**
- 未安装 → `references/installation.md`
- 安装出问题 → `references/troubleshooting.md`
- 想使用 → `references/usage.md``references/configuration.md`
- 需要卸载 → `references/uninstallation.md`
3. **提供解决方案**
- 先运行 `openclaw doctor` 进行诊断
- 根据诊断结果提供具体步骤
- 涉及敏感信息时,引导用户自己处理
4. **验证和后续**
- 每步操作后验证结果
- 如果问题持续,建议查阅最新 GitHub 文档
---
**记住**:当遇到不确定的问题时,优先查阅 [GitHub 仓库](https://github.com/openclaw/openclaw) 的最新文档和 README。
@@ -0,0 +1,133 @@
# OpenClaw 最佳实践和特殊场景
## 帮助用户时的最佳实践
1. **先诊断,再操作**:遇到问题先运行 `openclaw doctor`
2. **检查最新文档**:不确定时查阅 GitHub README 或官方文档
3. **保护隐私**:涉及 API 密钥、令牌等敏感信息时,引导用户自己处理
4. **分步引导**:复杂操作分步骤,每步确认成功后再继续
5. **提供备选方案**:如果一种方法不行,提供替代方案
6. **记录问题**:如果发现新问题或文档过时,提醒用户查看最新资料
## 特殊场景处理
### 场景 1:用户想创建特定功能的机器人
1. 确认 Gateway 已运行
2. 创建工作区或使用现有工作区
3. 配置 `AGENTS.md` 定义 Agent 行为
4. 配置 `TOOLS.md` 启用所需工具
5. 测试 Agent 响应
**示例:创建一个代码审查机器人**
```bash
# 1. 创建新的 Agent
openclaw agents add code-review --workspace ~/.openclaw/workspace-code-review
# 2. 编辑工作区的 AGENTS.md,定义代码审查逻辑
# 3. 配置 TOOLS.md,启用 GitHub 相关工具
# 4. 测试
openclaw agent --agent code-review --message "审查这个 PR: https://github.com/..."
```
### 场景 2:用户想执行自动化任务
1. 使用 `openclaw cron` 设置定时任务
2. 或使用 `openclaw webhooks` 接收外部触发
3. 配置 Agent 的 `AGENTS.md` 定义任务逻辑
**示例:每日报告任务**
```bash
# 设置每日 9 点执行
openclaw cron add "0 9 * * *" --message "生成每日报告" --agent main
# Agent 的 AGENTS.md 中定义报告生成逻辑
```
### 场景 3:多 Agent 路由
1. 创建多个 Agent`openclaw agents add <name>`
2. 配置路由规则在 `openclaw.json`
3. 参考文档:https://docs.openclaw.ai/concepts/multi-agent
**示例配置:**
```json5
{
agents: {
list: [
{ id: 'work', workspace: '~/.openclaw/workspace-work' },
{ id: 'personal', workspace: '~/.openclaw/workspace-personal' },
],
},
bindings: [
{
match: { channel: 'slack', accountId: 'work-account' },
agent: 'work',
},
{
match: { channel: 'telegram' },
agent: 'personal',
},
],
}
```
### 场景 4:远程 Gateway
1. 在远程服务器上安装并运行 Gateway
2. 本地配置 `gateway.mode=remote`
3. 配置 `gateway.remote.url` 和认证
4. 使用 SSH 隧道或 Tailscale 连接
**示例:通过 SSH 隧道连接**
```bash
# 在本地机器上
ssh -N -L 18789:127.0.0.1:18789 user@remote-server
# 在另一个终端
openclaw gateway status # 应该能连接到远程 Gateway
```
### 场景 5:工作区备份
工作区包含 Agent 的记忆和配置,建议定期备份:
```bash
# 使用 git 备份(推荐)
cd ~/.openclaw/workspace
git init
git add .
git commit -m "Backup workspace"
# 推送到私有仓库
git remote add origin git@github.com:username/openclaw-workspace.git
git push -u origin main
```
### 场景 6:迁移到新机器
1. 备份配置文件:`~/.openclaw/openclaw.json`
2. 备份工作区:`~/.openclaw/workspace`
3. 备份凭证(如果需要):`~/.openclaw/credentials/`
4. 在新机器上安装 OpenClaw
5. 恢复配置和工作区
6. 运行 `openclaw doctor` 检查配置
## 安全建议
1. **配置文件权限**:确保 `~/.openclaw/openclaw.json` 权限为 600
2. **API 密钥**:使用环境变量或安全的密钥管理工具
3. **DM 策略**:默认使用 `pairing` 策略,避免开放 DM
4. **Gateway 认证**:即使本地运行,也建议设置 Gateway token
5. **定期更新**:保持 OpenClaw 和依赖项更新
## 性能优化
1. **会话清理**:定期清理旧会话以释放空间
2. **模型选择**:根据任务复杂度选择合适的模型
3. **工作区大小**:保持工作区文件精简,避免过大的记忆文件
4. **日志管理**:定期清理日志文件
@@ -0,0 +1,141 @@
# OpenClaw 配置管理
## 配置文件位置
### 主要配置文件
- **配置文件**: `~/.openclaw/openclaw.json`
- **工作区**: `~/.openclaw/workspace`(默认)
- **凭证**: `~/.openclaw/credentials/`
- **会话**: `~/.openclaw/agents/<agentId>/sessions/`
- **状态**: `~/.openclaw/`(整个目录)
### 环境变量
- `OPENCLAW_CONFIG_PATH` - 配置文件路径
- `OPENCLAW_STATE_DIR` - 状态目录路径
- `OPENCLAW_PROFILE` - 配置 profile 名称
- `ANTHROPIC_API_KEY` - Anthropic API 密钥
- `OPENAI_API_KEY` - OpenAI API 密钥
## 配置管理命令
### 查看配置
```bash
openclaw config get <key>
```
例如:
```bash
openclaw config get gateway.mode
openclaw config get agents.defaults.model
```
### 设置配置
```bash
openclaw config set <key> <value>
```
例如:
```bash
openclaw config set gateway.mode local
openclaw config set gateway.port 18789
```
### 交互式配置
```bash
openclaw configure
```
或配置特定部分:
```bash
openclaw configure --section models
openclaw configure --section gateway
openclaw configure --section channels
```
## 常用配置项
### Gateway 配置
```json5
{
gateway: {
mode: 'local', // 或 "remote"
port: 18789,
bind: '127.0.0.1', // 或 "0.0.0.0"
auth: {
token: 'your-token-here',
},
},
}
```
### Agent 配置
```json5
{
agents: {
defaults: {
workspace: '~/.openclaw/workspace',
model: 'anthropic/claude-opus-4-5',
// 其他默认设置
},
list: [
{
id: 'main',
identity: {
name: 'OpenClaw',
emoji: '🦞',
avatar: 'avatars/openclaw.png',
},
},
],
},
}
```
### 渠道配置示例
```json5
{
channels: {
telegram: {
botToken: 'your-token',
allowFrom: ['+1234567890'],
dm: {
policy: 'pairing', // 或 "open"
},
},
whatsapp: {
allowFrom: ['+1234567890'],
},
},
}
```
## 多实例配置
使用不同的配置文件和状态目录运行多个实例:
```bash
OPENCLAW_CONFIG_PATH=~/.openclaw/a.json \
OPENCLAW_STATE_DIR=~/.openclaw-a \
openclaw gateway --port 19001
```
## 配置文件权限
配置文件应该设置为仅所有者可读写:
```bash
chmod 600 ~/.openclaw/openclaw.json
```
`openclaw doctor` 会自动检查并修复权限问题。
@@ -0,0 +1,96 @@
# OpenClaw 部署指南
## 运行新手引导向导(推荐)
这是**最推荐**的方式,会引导你完成所有配置:
```bash
openclaw onboard --install-daemon
```
向导会引导你配置:
- **Gateway 模式**:本地(local)或远程(remote
- **模型认证**Anthropic API 密钥(推荐)、OpenAI OAuth、或其他提供商
- **工作区位置**:默认 `~/.openclaw/workspace`
- **Gateway 设置**:端口(默认 18789)、绑定地址、认证令牌
- **渠道配置**WhatsApp、Telegram、Discord、Slack 等
- **服务安装**:后台服务(launchd/systemd
## 手动启动 Gateway(测试)
如果只想先测试,不安装服务:
```bash
openclaw gateway --port 18789 --verbose
```
## 检查 Gateway 状态
```bash
openclaw gateway status
```
## 检查服务是否运行
```bash
# macOS
launchctl list | grep openclaw
# Linux (systemd)
systemctl --user status openclaw-gateway
# 或检查端口
ss -ltnp | grep 18789 # Linux
lsof -i :18789 # macOS
```
## 服务管理
### macOS (launchd)
```bash
# 检查服务状态
launchctl list | grep openclaw
# 启动服务
launchctl load ~/Library/LaunchAgents/com.openclaw.gateway.plist
# 或使用 OpenClaw 命令
openclaw gateway install
```
### Linux (systemd)
```bash
# 检查服务状态
systemctl --user status openclaw-gateway
# 启动服务
systemctl --user start openclaw-gateway
# 启用自动启动
systemctl --user enable openclaw-gateway
```
## 查看日志
**Gateway 日志位置:**
- macOS: `~/Library/Logs/openclaw-gateway.log` 或系统日志
- Linux: `journalctl --user -u openclaw-gateway`
**使用脚本查看 macOS 日志:**
```bash
./scripts/clawlog.sh
```
## 远程 Gateway 部署
1. 在远程服务器上安装并运行 Gateway
2. 本地配置 `gateway.mode=remote`
3. 配置 `gateway.remote.url` 和认证
4. 使用 SSH 隧道或 Tailscale 连接
参考文档:https://docs.openclaw.ai/gateway/remote
@@ -0,0 +1,79 @@
# OpenClaw 安装指南
## 系统要求
- **Node.js**: 版本 ≥ 22.19(必需);Node 24 是当前推荐运行时。
- **操作系统**: macOS、Linux、Windows(原生 Windows Hub / PowerShell installer / WSL2 Gateway 均可)。
- **包管理器**: npm、pnpm 或 bun。Gateway 生产运行仍推荐 Node;bun 适合作为 CLI 全局安装路径。
## 检查 Node.js 版本
```bash
node --version
```
如果版本低于 22.19,需要先升级 Node.js;能升级到 Node 24 时优先使用 Node 24。
## 安装方式
### 方式 1:使用官方安装脚本(推荐)
**macOS/Linux:**
```bash
curl -fsSL https://openclaw.ai/install.sh | bash
```
**Windows (PowerShell):**
```powershell
iwr -useb https://openclaw.ai/install.ps1 | iex
```
### 方式 2npm 全局安装
```bash
npm install -g openclaw@latest
openclaw onboard --install-daemon
```
或使用 pnpm
```bash
pnpm add -g openclaw@latest
pnpm approve-builds -g
openclaw onboard --install-daemon
```
或使用 bun
```bash
bun add -g openclaw@latest
openclaw onboard --install-daemon
```
### 方式 3:从源码构建(开发)
```bash
git clone https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install
pnpm ui:build # 首次运行会自动安装 UI 依赖
pnpm build
```
## 验证安装
```bash
openclaw --version
```
## 安装后下一步
安装完成后,运行新手引导向导:
```bash
openclaw onboard --install-daemon
```
这会引导你完成 Gateway 配置、模型认证、渠道设置等。
@@ -0,0 +1,228 @@
# OpenClaw 故障排除指南
## 使用 Doctor 命令(主要诊断工具)
`openclaw doctor` 是 OpenClaw 的健康检查和修复工具。
### 基本诊断
```bash
openclaw doctor
```
这会检查:
- 配置文件健康状态
- Gateway 服务状态
- 认证配置
- 渠道连接状态
- Skills 状态
- 配置迁移需求
### 自动修复
```bash
openclaw doctor --repair
```
自动应用推荐的修复(包括重启服务)。
### 深度扫描
```bash
openclaw doctor --deep
```
扫描系统服务,查找额外的 Gateway 安装。
### 非交互模式
```bash
openclaw doctor --non-interactive
```
仅应用安全迁移,跳过需要人工确认的操作。
## 常见问题诊断
### 问题 1Gateway 无法启动
**检查步骤:**
1. 检查配置文件是否存在:
```bash
cat ~/.openclaw/openclaw.json
```
2. 检查 `gateway.mode` 是否设置:
```bash
openclaw config get gateway.mode
```
如果未设置,运行:
```bash
openclaw config set gateway.mode local
```
3. 检查端口是否被占用:
```bash
# macOS
lsof -i :18789
# Linux
ss -ltnp | grep 18789
```
4. 查看 Gateway 日志:
```bash
# macOS (如果使用 launchd)
tail -f ~/Library/Logs/openclaw-gateway.log
# Linux (如果使用 systemd)
journalctl --user -u openclaw-gateway -f
```
### 问题 2:认证失败
**检查步骤:**
1. 运行 doctor 检查认证健康:
```bash
openclaw doctor
```
2. 检查 API 密钥环境变量:
```bash
echo $ANTHROPIC_API_KEY
echo $OPENAI_API_KEY
```
3. 检查配置文件中的认证设置:
```bash
openclaw config get agents.defaults.model
```
4. 重新配置认证:
```bash
openclaw configure --section models
```
### 问题 3:渠道连接失败
**检查步骤:**
1. 检查渠道状态:
```bash
openclaw channels status
```
2. 检查渠道配置:
```bash
openclaw config get channels
```
3. 重新登录渠道:
```bash
openclaw channels login
```
### 问题 4:配置文件权限问题
如果配置文件权限过宽,doctor 会警告并修复:
```bash
openclaw doctor --repair
```
或手动修复:
```bash
chmod 600 ~/.openclaw/openclaw.json
```
### 问题 5:服务未运行
**macOS (launchd):**
```bash
# 检查服务状态
launchctl list | grep openclaw
# 启动服务
launchctl load ~/Library/LaunchAgents/com.openclaw.gateway.plist
# 或使用 OpenClaw 命令
openclaw gateway install
```
**Linux (systemd):**
```bash
# 检查服务状态
systemctl --user status openclaw-gateway
# 启动服务
systemctl --user start openclaw-gateway
# 启用自动启动
systemctl --user enable openclaw-gateway
```
## 故障排除流程
当用户遇到问题时,按以下流程处理:
1. **确认安装状态**
```bash
openclaw --version
```
2. **运行 Doctor 诊断**
```bash
openclaw doctor
```
3. **检查 Gateway 状态**
```bash
openclaw gateway status
```
4. **查看日志**
- macOS: `./scripts/clawlog.sh` 或系统日志
- Linux: `journalctl --user -u openclaw-gateway`
5. **检查配置文件**
```bash
cat ~/.openclaw/openclaw.json
```
6. **如果问题持续,建议用户:**
- 查看最新 GitHub README
- 访问 docs.openclaw.ai
- 在 Discord 社区寻求帮助
## macOSlaunchctl 环境变量覆盖
如果之前运行过 `launchctl setenv OPENCLAW_GATEWAY_TOKEN ...`(或 `...PASSWORD`),该值会覆盖配置文件,并可能导致持续的"未授权"错误。
```bash
launchctl getenv OPENCLAW_GATEWAY_TOKEN
launchctl getenv OPENCLAW_GATEWAY_PASSWORD
launchctl unsetenv OPENCLAW_GATEWAY_TOKEN
launchctl unsetenv OPENCLAW_GATEWAY_PASSWORD
```
@@ -0,0 +1,307 @@
# OpenClaw 卸载指南
## 概述
本指南提供完全卸载 OpenClaw 的步骤,包括:
- 停止所有运行中的服务
- 卸载 npm 全局包
- 删除配置文件和目录
- 移除系统服务(launchd/systemd
- 清理环境变量
## 卸载前准备
### 1. 停止所有 OpenClaw 进程
**停止 Gateway 服务:**
```bash
# 检查 Gateway 状态
openclaw gateway status
# 停止 Gateway
openclaw gateway stop
```
**检查并停止所有相关进程:**
```bash
# macOS/Linux
ps aux | grep openclaw | grep -v grep
# 如果发现进程,手动停止
killall openclaw # macOS/Linux
```
### 2. 检查系统服务状态
**macOS (launchd):**
```bash
# 检查服务状态
launchctl list | grep openclaw
# 如果服务正在运行,先卸载服务
launchctl unload ~/Library/LaunchAgents/com.openclaw.gateway.plist 2>/dev/null
```
**Linux (systemd):**
```bash
# 检查服务状态
systemctl --user status openclaw-gateway
# 停止并禁用服务
systemctl --user stop openclaw-gateway
systemctl --user disable openclaw-gateway
```
## 完整卸载步骤
### 步骤 1:卸载 npm 全局包
```bash
# 使用 npm 卸载
npm uninstall -g openclaw
# 如果使用 pnpm 安装的
pnpm remove -g openclaw
# 如果使用 bun 安装的
bun remove -g openclaw
```
**验证卸载:**
```bash
openclaw --version
# 应该显示 "command not found" 或类似错误
```
### 步骤 2:删除配置文件和数据目录
**删除主配置目录:**
```bash
rm -rf ~/.openclaw
```
**检查并删除其他可能的位置:**
```bash
# 检查是否有其他配置目录
ls -la ~ | grep -i openclaw
ls -la ~ | grep -i clawd
# 如果存在,删除它们
rm -rf ~/clawd # 如果存在旧版本的工作区
```
### 步骤 3:移除系统服务配置
**macOS (launchd):**
```bash
# 删除 LaunchAgent 配置文件
rm -f ~/Library/LaunchAgents/com.openclaw.gateway.plist
# 清理 launchctl 环境变量(如果设置过)
launchctl unsetenv OPENCLAW_GATEWAY_TOKEN 2>/dev/null
launchctl unsetenv OPENCLAW_GATEWAY_PASSWORD 2>/dev/null
```
**Linux (systemd):**
```bash
# 删除 systemd 服务文件
rm -f ~/.config/systemd/user/openclaw-gateway.service
# 重新加载 systemd
systemctl --user daemon-reload
```
### 步骤 4:清理日志文件
**macOS:**
```bash
rm -f ~/Library/Logs/openclaw-gateway.log
```
**Linux:**
```bash
# systemd 日志会自动清理,无需手动删除
```
### 步骤 5:清理环境变量(可选)
检查 shell 配置文件(`.zshrc`, `.bash_profile`, `.bashrc`)中是否有 OpenClaw 相关的环境变量:
```bash
# 检查环境变量
grep -i openclaw ~/.zshrc ~/.bash_profile ~/.bashrc 2>/dev/null
# 如果找到,手动编辑文件删除相关行
```
常见环境变量:
- `OPENCLAW_CONFIG_PATH`
- `OPENCLAW_STATE_DIR`
- `OPENCLAW_PROFILE`
### 步骤 6:清理端口占用(如果仍有进程)
```bash
# 检查端口 18789 是否被占用
lsof -i :18789 # macOS
ss -ltnp | grep 18789 # Linux
# 如果发现进程,停止它
kill -9 <PID>
```
## 验证卸载完成
执行以下检查,确认 OpenClaw 已完全卸载:
```bash
# 1. 检查命令是否还存在
which openclaw
# 应该返回空或 "not found"
# 2. 检查配置目录是否已删除
ls -la ~/.openclaw
# 应该返回 "No such file or directory"
# 3. 检查系统服务是否已移除
# macOS
launchctl list | grep openclaw
# 应该返回空
# Linux
systemctl --user list-unit-files | grep openclaw
# 应该返回空
# 4. 检查进程是否还在运行
ps aux | grep openclaw | grep -v grep
# 应该返回空
```
## 卸载脚本(可选)
可以创建一个卸载脚本来自动执行上述步骤:
**macOS/Linux:**
```bash
#!/bin/bash
echo "正在卸载 OpenClaw..."
# 停止服务
openclaw gateway stop 2>/dev/null
killall openclaw 2>/dev/null
# 卸载 npm 包
npm uninstall -g openclaw 2>/dev/null
# 删除配置目录
rm -rf ~/.openclaw
rm -rf ~/clawd
# macOS: 删除 LaunchAgent
if [ -f ~/Library/LaunchAgents/com.openclaw.gateway.plist ]; then
launchctl unload ~/Library/LaunchAgents/com.openclaw.gateway.plist 2>/dev/null
rm -f ~/Library/LaunchAgents/com.openclaw.gateway.plist
fi
# Linux: 删除 systemd 服务
if [ -f ~/.config/systemd/user/openclaw-gateway.service ]; then
systemctl --user stop openclaw-gateway 2>/dev/null
systemctl --user disable openclaw-gateway 2>/dev/null
rm -f ~/.config/systemd/user/openclaw-gateway.service
systemctl --user daemon-reload
fi
# 清理日志
rm -f ~/Library/Logs/openclaw-gateway.log
echo "OpenClaw 卸载完成!"
```
## 注意事项
1. **备份重要数据**:卸载前,如果需要保留配置或工作区数据,请先备份:
```bash
cp -r ~/.openclaw ~/.openclaw.backup
```
2. **多实例安装**:如果使用环境变量配置了多个实例,需要分别清理每个实例的配置目录。
3. **环境变量**:如果手动设置了环境变量,需要从 shell 配置文件中删除。
4. **残留进程**:如果卸载后仍有进程在运行,可能需要重启终端或系统。
## 故障排查
### 问题:卸载后命令仍然可用
**可能原因:**
- npm 包未完全卸载
- 有多个安装位置
**解决方法:**
```bash
# 检查所有可能的安装位置
which -a openclaw
# 手动删除找到的路径
# 然后重新卸载 npm 包
npm uninstall -g openclaw
```
### 问题:服务仍在运行
**解决方法:**
```bash
# 强制停止所有相关进程
pkill -9 openclaw
# 检查并清理系统服务
# macOS
launchctl list | grep openclaw
launchctl remove com.openclaw.gateway 2>/dev/null
# Linux
systemctl --user stop openclaw-gateway
systemctl --user disable openclaw-gateway
```
### 问题:配置文件无法删除
**可能原因:**
- 文件权限问题
- 文件被锁定
**解决方法:**
```bash
# 检查文件权限
ls -la ~/.openclaw
# 修改权限后删除
chmod -R 755 ~/.openclaw
rm -rf ~/.openclaw
```
## 参考资源
- [OpenClaw GitHub 仓库](https://github.com/openclaw/openclaw)
- [OpenClaw 官方文档](https://docs.openclaw.ai)
@@ -0,0 +1,168 @@
# OpenClaw 使用指南
## 创建和管理 Agent
### 列出所有 Agent
```bash
openclaw agents list
```
### 添加新 Agent
```bash
openclaw agents add <agent-name> --workspace ~/.openclaw/workspace-<name>
```
### 设置 Agent 身份
```bash
openclaw agents set-identity --agent main --name "My Assistant" --emoji "🦞"
```
### 从文件加载身份
```bash
openclaw agents set-identity --workspace ~/.openclaw/workspace --from-identity
```
## 与 Agent 对话
### 基本对话
```bash
openclaw agent --message "帮我总结今天的任务"
```
### 指定 Agent
```bash
openclaw agent --agent <agent-id> --message "执行某个任务"
```
### 指定思考模式
```bash
openclaw agent --message "复杂任务" --thinking high
```
### 发送到渠道并回复
```bash
openclaw agent --to +1234567890 --message "状态更新" --deliver
```
## 发送消息
### 发送到电话号码
```bash
openclaw message send --to +1234567890 --message "Hello from OpenClaw"
```
### 发送到渠道
```bash
openclaw message send --channel telegram --to @username --message "Hello"
```
## 渠道管理
### 登录渠道
```bash
openclaw channels login
```
### 查看渠道状态
```bash
openclaw channels status
```
### 深度检查(探测连接)
```bash
openclaw channels status --probe
```
## 工作区管理
### 创建工作区
```bash
openclaw setup --workspace ~/.openclaw/workspace
```
### 工作区文件结构
默认工作区位置:`~/.openclaw/workspace`
重要文件:
- `AGENTS.md` - Agent 指令和技能列表
- `SOUL.md` - Agent 身份和边界
- `USER.md` - 用户信息
- `TOOLS.md` - 工具配置
- `memory/` - 记忆系统(每日日志)
### 初始化工作区模板
```bash
cp docs/reference/templates/AGENTS.md ~/.openclaw/workspace/AGENTS.md
cp docs/reference/templates/SOUL.md ~/.openclaw/workspace/SOUL.md
cp docs/reference/templates/TOOLS.md ~/.openclaw/workspace/TOOLS.md
```
## 自动化任务
### Cron 任务
```bash
openclaw cron add "0 9 * * *" --message "每日晨报"
```
### Webhooks
配置 webhook 接收外部触发:
```bash
openclaw webhooks add <name> --url <webhook-url>
```
### Gmail Pub/Sub
配置 Gmail 触发器(需要额外设置):
参考文档:https://docs.openclaw.ai/automation/gmail-pubsub
## 更新和升级
### 更新 OpenClaw
```bash
npm install -g openclaw@latest
```
或使用 pnpm
```bash
pnpm add -g openclaw@latest
```
### 更新后运行 Doctor
```bash
openclaw doctor
```
这会:
- 检查配置迁移需求
- 修复过时的配置
- 检查服务状态
### 开发渠道切换
```bash
openclaw update --channel stable|beta|dev
```