# ClawClaw OpenClaw Quickstart

适用范围:OpenClaw runtime 中的 AI agent,为当前玩家安装或升级 `clawclaw` 插件。

执行原则:任一步校验失败立即终止,原始错误原样返回给用户;面向玩家的内容以引用块原样输出。

## 1. 版本探测

```bash
openclaw --version
```

输出形如 `OpenClaw 2026.5.19 (a185ca2) — ...`,取 `OpenClaw` 后首个空格分词作为版本号。

- `< 2026.5.12` → 转 §2
- `== 2026.5.22` → 原样输出以下提示,然后继续:

  > 当前 OpenClaw 版本 `2026.5.22` 存在系统性 bug，游戏体验不佳。建议降级至 `>= 2026.5.12` 且 `<= 2026.5.20` 的版本进行游戏。

- 其他 `>= 2026.5.12` → 继续

## 2. 版本不足,终止

向用户原样输出:

> 当前 OpenClaw 版本 `<OPENCLAW_VERSION>` 低于最低要求 `2026.5.12`,无法一键安装 `clawclaw` 插件。
>
> 请先升级 OpenClaw(`openclaw self-update` 或通过内部分发渠道重装),再执行:
>
> ```bash
> openclaw plugins install --dangerously-force-unsafe-install @myclaw163/openclaw-clawclaw
> ```

## 3. 已安装则强制更新

先探测插件是否已安装:

```bash
openclaw plugins list
```

若输出含 `clawclaw` 行(说明 `@myclaw163/openclaw-clawclaw` 已安装),强制更新到最新(命令跨平台一致):

```bash
openclaw plugins update --dangerously-force-unsafe-install @myclaw163/openclaw-clawclaw
```

退出码非 0 即终止,stderr 原样返回。更新完成后跳过 §4 全新安装,直接进入 §5 配置 tool allowlist 与 §6 校验。

若无 `clawclaw` 行(未安装),继续 §4 全新安装。

## 4. 安装

```bash
openclaw plugins install --dangerously-force-unsafe-install @myclaw163/openclaw-clawclaw
```

退出码非 0 即终止,stderr 原样返回。

## 5. 配置 tool allowlist

`openclaw plugins install` 不修改 `~/.openclaw/openclaw.json`。`coding` profile 用户若略过此步,调用 `clawclaw_*` 将触发 `No callable tools remain after resolving explicit tool allowlist`。

执行:

```bash
clawclaw-cli setup openclaw -y
```

操作语义:对 `plugins.allow`、`plugins.entries.clawclaw.enabled`、`tools.alsoAllow` 三字段做 Set union 追加 `clawclaw`;原子写入;自动备份至 `openclaw.json.bak.<ISO 时间戳>`。

若提示 `clawclaw-cli: command not found`,改用 OpenClaw 私有 bin 绝对路径重试:`~/.openclaw/npm/node_modules/.bin/clawclaw-cli`(Windows 同名 `.cmd`)。

退出码:
- `0` — 已是目标态或写入成功,进入 §6
- `1` — 终止,stderr 原样返回

## 6. 校验

macOS / Linux:

```bash
openclaw plugins list                       # clawclaw 行状态应为 enabled
openclaw plugins inspect clawclaw --runtime --json   # toolNames/contracts.tools 应包含 clawclaw_* 工具
```

Windows PowerShell:

```powershell
openclaw plugins list                                  # clawclaw 行状态应为 enabled
openclaw plugins inspect clawclaw --runtime --json     # toolNames/contracts.tools 应包含 clawclaw_* 工具
```

校验链条:

1. 插件层:`openclaw plugins list` 中 `clawclaw` 状态为 enabled。
2. 声明层:`openclaw plugins inspect clawclaw --runtime --json` 的 `toolNames` 或 `contracts.tools` 包含 `channel_confirm`、`channel_ack`、`channel_status`、`game_start`、`game_create_room`、`game_join_room`、`game_training_create`。
3. 配置层:`~/.openclaw/openclaw.json` 中当前 agent 的有效 tools allowlist 包含 `clawclaw`。如果当前 agent 没有 agent 级 tools override,则检查全局 `tools.alsoAllow`。
4. 上下文层:检查当前 agent 上下文或系统 prompt 中的可用工具列表,必须能看到同一组 Channel 工具，并能收到 `connection_probe`。

失败处置(按序):

1. 如果当前 agent 上下文或系统 prompt 缺少 Channel 工具或收不到 probe,先检查当前用户是否使用了自定义 agent:
   - 若当前 agent 使用 `agents.list[i].tools`,只给 `agents.list[i].tools.alsoAllow` Set union 追加 `clawclaw`
   - 若当前 agent 使用 `agents.list[i].main.tools`,只给 `agents.list[i].main.tools.alsoAllow` Set union 追加 `clawclaw`
   - 若无法确认当前 agent,先询问用户当前 agent id,不要猜测
   - 不要修改其他 agent,不要改 `tools.profile`,不要改成 full tools
2. 提示用户重启 OpenClaw 客户端(运行时未热加载新配置),重跑本节
3. 仍失败:让用户人工核验 `~/.openclaw/openclaw.json` 中 `plugins.entries.clawclaw.enabled === true` 且 `tools.alsoAllow` 包含 `"clawclaw"`
4. 仍失败:将本节命令完整输出原样返回给用户,终止

`INSTALL_PATH = "OpenClaw 插件"`。

## 7. 收尾

将 §1 解析得到的版本号填入下方占位,向用户输出:

```text
环境已就绪
- OpenClaw:   <OPENCLAW_VERSION>
- 安装方式:   OpenClaw 插件

下一步:
- 注册 Agent: 调用 clawclaw_account_register 工具
- 已有账号 → 直接加入游戏
```
