---
name: build-protolua
description: >-
  Updates and rebuilds ProtoLua protobuf bindings by running svn update,
  buildproto.bat, then copyLua.bat under D:\proj\protobuf\ProtoLua in strict
  sequence. Use when the user asks to update proto (e.g. 「请帮我更新一下proto可以吗？」
  「更新proto」「同步proto」), build proto, update ProtoLua, run buildproto/copyLua,
  sync protobuf Lua, or refresh pb_lua generated files.
---

# Build ProtoLua

在 `D:\proj\protobuf\ProtoLua` 按固定顺序执行三步。必须前一步成功结束后再跑下一步；任一步失败则停止并报告，不得继续。

## 工作目录

```
D:\proj\protobuf\ProtoLua
```

## 执行步骤（严格串行）

用 Shell，通过 `working_directory` 设为上述路径。三步分别调用，**禁止**并行或一条命令里无条件链式忽略错误。

### 1. SVN 更新

```powershell
svn update
```

- 等命令结束；检查退出码。
- 非 0：停止，把 stdout/stderr 摘要给用户。

### 2. 生成协议

```powershell
cmd /c buildproto.bat
```

- 仅在步骤 1 成功后执行。
- `buildproto.bat` 可能较久：`block_until_ms` 建议至少 `120000`；若超时仍在跑，继续等待直至结束，不要启动步骤 3。
- 非 0：停止并报告。

### 3. 拷贝 Lua

```powershell
cmd /c copyLua.bat
```

- 仅在步骤 2 成功后执行。
- `block_until_ms` 建议至少 `60000`。
- 非 0：停止并报告。

## 完成标准

三步均成功后，向用户简要说明：

1. `svn update` 结果摘要（有无冲突/更新）
2. `buildproto.bat` 成功
3. `copyLua.bat` 成功

不要改 ProtoLua 目录外的文件，除非用户另行要求核对拷贝目标。

## 注意

- Windows 下用 `cmd /c xxx.bat` 跑批处理，保证 bat 内相对路径正确。
- 不要跳过 `svn update`。
- 不要在失败后自动 `svn revert` 或强行重跑，除非用户明确要求。
