【实战篇】老板临时催包?人在外面没电脑,我的龙虾助理直接操办
引言
想象一下这个场景:
周五晚上你刚躺在沙发上,测试突然在群里喊:“老板,急需一个最新的 Debug 包测个 Bug!”
以前,你得爬起来打开电脑,启动 Android Studio,等待 Gradle 慢吞吞地转圈,打包完还得手动打开蒲公英网页上传,最后复制链接发群里……
现在,你只需要在飞书里发一句语音:“帮我把最新的代码打包传到蒲公英。”
剩下的事情,你的 AI 代理——小龙虾 (OpenClaw) 会全自动帮你搞定。本文将手把手教你如何搭建这就套“摸鱼神器”。
![]()
🛠️ 第一步:把“小龙虾”请回家 (环境安装)
OpenClaw(代号:小龙虾)是一个运行在你本地电脑上的 AI Agent 框架,它能操作你的终端、文件和浏览器。
1. 基础环境准备
OpenClaw 比较前卫,强制要求 Node.js v22+ 。
(如果你是 M1/M2/M3 芯片的 Mac,记得先搞定终端代理,不然下载依赖会很慢)
# 推荐用 nvm 快速安装
nvm install 22
nvm use 22
2. 一键安装
设置好 VPN 代理后,一行命令搞定安装:(所有初始化配置,推荐快速跳过)
export http_proxy=http://127.0.0.1:7890 # 替换你的代理端口
export https_proxy=http://127.0.0.1:7890
npm install -g openclaw@latest
安装完成后,你可以运行 openclaw --version 验证一下。
➜ ~ openclaw --version
OpenClaw 2026.3.13 (61d171a)
// 如果您能看到类似 `OpenClaw 2026.x.x` 的输出,则说明安装已完全成功!
3. 给它装个脑子 (配置模型)
运行 openclaw configure,把你的大模型 API Key(比如 OpenAI、Claude 或者火山引擎的 Key)填进去。这是它听懂人话的关键。
提示:在向导中,重点配置 model (输入您的 API Key)和 workspace (初始化代理的性格和记忆)。
我选用的是 Volcano Engine (火山)
◆ Model/auth provider
│ ○ OpenAI
│ ○ Anthropic
│ ○ Chutes
│ ○ MiniMax
│ ○ Moonshot AI (Kimi K2.5)
│ ○ Google
│ ○ xAI (Grok)
│ ○ Mistral AI
│ ● Volcano Engine (API key)
│ ○ BytePlus
│ ○ OpenRouter
│ ○ Kilo Gateway
│ ○ Qwen
│ ○ Z.AI
│ ○ Qianfan
│ ○ Alibaba Cloud Model Studio
│ ○ Copilot
│ ○ Vercel AI Gateway
│ ○ OpenCode
重新选择模型使用命令行:openclaw configure --section model
4. 启动与关闭网关服务 (Gateway)
配置完成后,需要启动它的核心服务,让它在后台监听请求。建议新开一个终端窗口运行:
openclaw gateway --port 18789
![]()
- 可以看到默认模型显示为已选的豆包模型
如何关闭服务?
如果您想修改配置并重启,或者想彻底关闭后台服务,请运行:
# 安全停止网关服务
openclaw gateway stop
# (如果上述命令无效,可尝试强杀:pkill -f "openclaw gateway")
5. 开始对话
网关启动后,您可以再开一个终端窗口,直接用命令行与它对话(需指定 session):
# 启动交互式终端 UI (推荐)
openclaw tui
或者,新起一个会话:openclaw tui --session chat3
![]()
🔗 第二步:打通“任督二脉” (关联飞书)
为了能远程指挥电脑,我们需要通过 WebSocket 长连接 把本地的小龙虾和飞书机器人连起来。这不仅不需要公网 IP,还非常稳定。
1. 飞书侧:先拿“身份证”
登录 飞书开放平台,创建一个企业自建应用:
- 创建应用:起个名字叫“龙虾助手1号”。
- 开启能力:在“应用能力”里把【机器人】勾上。(左侧导航:应用能力 → 添加能力 → 机器人)
- 获取凭证:在“凭证与基础信息”里,复制 App ID 和 App Secret。
![]()
![]()
2. 本地侧:建立连接
拿到凭证后,回到电脑终端,告诉小龙虾:
# 开启飞书渠道
openclaw config set channels.feishu.enabled true
# 填入你的凭证
openclaw config set channels.feishu.appId "cli_a933xxxxxx"
openclaw config set channels.feishu.appSecret "I4tJEyrxxxxxx"
# 开启配对模式(安全第一)
openclaw config set channels.feishu.dmPolicy "pairing"
关键一步:启动网关!
openclaw gateway --port 18789
此时盯着日志,当你看到 [feishu] connected 时,说明路通了!
3. 飞书端完成订阅与发布:
3.1 配置权限
回到飞书后台 -> 左侧导航 -> 权限管理:(逐个添加以下权限)
消息与群组相关:
● im:message (获取与发送单聊、群组消息)
● im:message:readonly (读取单聊、群组消息)
● im:message:send_as_bot (以应用的身份发送消息)
● im:chat (获取与更新群组信息)
● im:chat:readonly (读取群组信息)
通讯录相关:
● contact:user.base:readonly (读取用户基础信息)
3.2 订阅事件(接收消息)
回到飞书后台 -> 左侧导航 -> 事件与回调 -> 事件配置
1. 点击「订阅方式」右侧编辑图标(✏️)。
2. 选择:**使用长连接接收事件(WebSocket)**。
3. 关闭「消息加密」(个人场景简化配置)。
4. **点击「保存」**。
*(因为 OpenClaw 已经启动并连接,这里应该能顺利保存,不会报错)*
5. 在“已添加事件”区域 → 点击「添加事件」。
6. 搜索 `im.message.receive_v1`(接收消息 v1),勾选并确认。
7. 点击事件右侧「申请权限」,提交审批(自动通过)。
8. 刷新页面,确认事件状态为「已通过」。
发布应用:去“版本管理与发布”里发布一个版本,这样你在飞书里才能搜到它。
3.4 配对授权(如果未设置白名单)
OpenClaw 默认不回复陌生人:
- 发送消息后,机器人通常会回复一个配对码(例如:
配对码:123456),或者在 OpenClaw 的终端日志中会显示拦截提示并生成配对码。 - 回到您的电脑终端,执行授权命令:
openclaw pairing approve feishu 123456
(把 123456 换成实际生成的配对码)
- 授权成功后,再次在飞书中对机器人说
你好,它应该就能正常调用您配置的 AI 模型并回复您了。
![]()
🧠 第三步:传授“独门绝技” (自定义 Skill)
默认的小龙虾只会聊天,我们需要通过编写 Markdown 文件,教会它两个硬核技能:Gradle 打包 和 蒲公英上传。
技能 1:Android 自动打包 (android-build)
这个技能教它:当用户说“打包”时,去哪里找项目,执行什么命令。
创建文件:~/.openclaw/skills/android-build/SKILL.md
(复制以下完整代码)
---
name: "android-build"
description: "Build Android APK using Gradle. Invoke when user asks to build, compile, or package an Android project into an APK."
---
# Android Build Skill
This skill allows OpenClaw to automatically build an Android project using Gradle.
## Prerequisites
- The target machine must have Java (JDK) installed.
- The target machine must have Android SDK installed.
- The target project must use Gradle (`gradlew`).
## Instructions for OpenClaw
When the user asks you to build an Android project, follow these steps:
1. **Locate the Project**: Ask the user for the absolute path to the Android project directory if they haven't provided it.
2. **Verify Project**: Ensure there is a `gradlew` (or `gradlew.bat` for Windows) file in the specified directory.
3. **Execute Build**: Run the standard Android build command. Usually, this is:
```bash
cd <project_path> && ./gradlew assembleDebug
```
*(If the user specifies a different flavor like `assembleRelease`, use that instead).*
4. **Report Status**: Read the terminal output.
- If successful, find the path to the generated APK (usually under `app/build/outputs/apk/debug/`) and report it to the user.
- If it fails, summarize the Gradle build errors and suggest fixes.
技能 2:蒲公英光速上传 (pgyer-upload)
这个技能教它:拿到 APK 后,如何通过 API 传到蒲公英。我们使用蒲公英官方 v2 接口(COS 直传),速度极快。
创建文件:~/.openclaw/skills/pgyer-upload/SKILL.md
(请将代码中的 _api_key 替换为您自己的蒲公英 API Key)
---
name: "pgyer-upload"
description: "Upload APK/IPA to Pgyer (蒲公英) using the 3-step apiv2 process (getCOSToken, upload to COS, get buildInfo). Invoke when user asks to upload an app, apk, or distribute a build to Pgyer."
---
# Pgyer Upload Skill
This skill allows OpenClaw to automatically upload Android APKs or iOS IPAs to Pgyer (蒲公英) using their official v2 API (COS upload method).
## Prerequisites
- `curl` must be installed on the machine.
## Instructions for OpenClaw
When the user asks you to upload an app to Pgyer, follow these 3 steps precisely using terminal commands. Use the hardcoded `_api_key=34d58041e8xxxx` (Replace with your actual key).
**(Note: You do not need any User Key, only the `_api_key` is required for v2 API).**
### Step 1: Get COS Token
1. Find the absolute path to the APK/IPA file (`<file_path>`).
2. Determine the `buildType` (e.g., `android` for APK, `ios` for IPA).
3. Execute the following `curl` command to get the upload token and endpoint. Use `node -e` or `python` to parse the JSON if `jq` is not available:
```bash
curl -s -X POST https://www.pgyer.com/apiv2/app/getCOSToken \
-d "_api_key=34d58041e8xxxx" \
-d "buildType=<buildType>" > token_response.json
```
4. Read `token_response.json`. If `code` is not `0`, report the error and stop.
5. Extract the following from `data`:
- `endpoint` (the upload URL)
- `key` (the buildKey used in Step 3)
- `params` (an object containing multiple form fields like `signature`, `x-cos-security-token`, `key`, etc.)
### Step 2: Upload File to COS
Construct a `curl` command using the `endpoint` and all the key-value pairs inside the `params` object as `-F` form fields, and finally attach the file.
```bash
curl -s -X POST <endpoint> \
-F "key=<params.key>" \
-F "signature=<params.signature>" \
-F "x-cos-security-token=<params.x-cos-security-token>" \
-F "x-cos-meta-file-name=<params.x-cos-meta-file-name>" \
-F "file=@<file_path>" -i
```
*(Note: You must dynamically include all fields returned in the `params` object from Step 1. The HTTP status code returned should be 204 No Content).*
### Step 3: Get Build Info (Polling)
After a successful upload, wait 3 seconds, then query the build info using the `key` extracted in Step 1.
```bash
curl -s -G https://www.pgyer.com/apiv2/app/buildInfo \
-d "_api_key=34d58041e8xxxx" \
-d "buildKey=<key_from_step_1>" > build_info.json
```
1. Read `build_info.json`.
2. If `code` is `1247` (Processing), wait 3 seconds and repeat Step 3 (up to 3 times).
3. If `code` is `0`, extract `buildName`, `buildVersion`, `buildUpdated`, and `buildShortcutUrl`.
4. Report the success to the user with this format:
- **App Name**: <buildName> (v<buildVersion>)
- **Update Time**: <buildUpdated>
- **Download Link**: `https://www.pgyer.com/<buildShortcutUrl>`
5. Clean up temporary json files.
🎉 第四步:见证奇迹时刻
现在,打开你的飞书 App,找到你的机器人,发一条消息:
“帮我把桌面code文件夹内的项目打包,然后上传到蒲公英。”
接下来发生的事情会让你舒适极了:
-
意图识别:小龙虾识别到你需要
android-build。 - 执行命令:你的电脑风扇开始转,Gradle 开始编译(它会在后台默默执行)。
-
链式调用:编译完成后,它拿到 APK 路径,自动触发
pgyer-upload。 - 任务完成:几秒钟后,你的飞书收到一条回复:
![]()