diff --git a/docs/shared/bootstrap-onboarding.md b/docs/shared/bootstrap-onboarding.md new file mode 100644 index 0000000..22b91f9 --- /dev/null +++ b/docs/shared/bootstrap-onboarding.md @@ -0,0 +1,177 @@ +# 一行命令 Bootstrap 新设备 + +> **理念**:人类只做最少特权操作,buddy agent 接管后续。 + +## 概述 + +这套方法论解决了一个经典问题:如何让一台全新的设备快速接入 Agent 生态,同时把人类需要手动操作的步骤压缩到最低? + +核心思路: + +1. 人类在新设备上执行一条 bootstrap 命令 +2. 脚本自动安装必要组件,建立公网 SSH 隧道 +3. 客户端 buddy agent 通过隧道 SSH 进入新设备 +4. buddy agent 完成剩余所有配置 + +**人类只需要:** 运行一行命令,然后把隧道地址告诉 agent。 + +脚本仓库:[https://github.com/shazhou-ww/oc-bootstrap](https://github.com/shazhou-ww/oc-bootstrap) + +--- + +## 流程图 + +```mermaid +sequenceDiagram + participant H as 人类(新设备) + participant S as Bootstrap 脚本 + participant CF as Cloudflare Quick Tunnel + participant A as Buddy Agent(客户端) + + H->>S: bash <(curl -fsSL ) + S->>S: 安装依赖(cloudflared、OpenClaw 等) + S->>CF: cloudflared tunnel --url tcp://localhost:22 + CF-->>S: 返回隧道域名 xxx.trycloudflare.com + S->>H: 显示隧道地址,等待 agent 接管 + H->>A: 把隧道地址发给 agent + A->>CF: cloudflared access tcp --hostname xxx.trycloudflare.com --url localhost:2222 + A->>A: ssh -p 2222 user@localhost + A->>A: 执行剩余配置(复制公钥、配置 OpenClaw 等) +``` + +--- + +## 技术方案 + +### Bootstrap 脚本执行方式 + +```bash +bash <(curl -fsSL https://raw.githubusercontent.com/shazhou-ww/oc-bootstrap/main/bootstrap.sh) +``` + +!!! warning "为什么不用 `curl | bash`" + `curl | bash` 会把 curl 的 stdout 接到 bash 的 stdin,导致脚本内的 `read` 命令无法从终端读取用户输入。即使加 `