C.R.A.B Deploy Agent
2026-03-27
新闻来源:网淘吧
围观:14
电脑广告
手机广告
部署代理
通过多步骤工作流部署全栈应用程序,每个阶段均需人工审批。
快速开始
# Install via ClawdHub
clawdhub install deploy-agent
# Initialize a new deployment
deploy-agent init my-app
# Check status
deploy-agent status my-app
# Continue through steps
deploy-agent continue my-app
工作流步骤
| 步骤 | 命令 | 描述 | 需要审批 |
|---|---|---|---|
| 1 | deploy-agent init <名称> | 启动部署 | ✅ 设计阶段 |
| 2 | deploy-agent build <名称> | 构建应用 | ✅ 测试前 |
| 3 | deploy-agent test <名称> | 本地测试 | ✅ 推送到 GitHub 前 |
| 4 | deploy-agent push <名称> | 推送到 GitHub | ✅ 部署到 Cloudflare 前 |
| 5 | deploy-agent deploy <名称> | 部署到 Cloudflare | ✅ 完成 |
命令
初始化部署
deploy-agent init my-app
创建一个新的部署状态并等待设计输入。
检查状态
deploy-agent status my-app
显示当前步骤、审批和部署信息。
继续
deploy-agent continue my-app
获取关于在当前步骤中下一步操作的指导。
构建 (步骤 2)
deploy-agent build my-app
使用 C.R.A.B 设计后,运行此命令以构建应用。
测试 (步骤 3)
deploy-agent test my-app
在推送前验证应用是否在本地运行。
推送到 GitHub (步骤 4)
deploy-agent push my-app [repo-name]
创建 GitHub 仓库并推送代码。默认仓库名称 = 应用名称。
部署到 Cloudflare (步骤 5)
deploy-agent deploy my-app [custom-domain]
部署到 Cloudflare Pages。默认域名:{名称}.sheraj.org
取消
deploy-agent cancel my-app
中止并清理部署。
列表
deploy-agent list
显示所有活跃的部署。
示例会话
# Start new deployment
$ deploy-agent init my-blog
🚀 Deployment initialized: my-blog
Step 1: Design your app with C.R.A.B
# ... design phase with C.R.A.B ...
$ deploy-agent build my-blog
🚀 Build complete! Step 2: Local Testing
Start dev server: cd my-blog && npm run dev
# ... test locally ...
$ deploy-agent push my-blog
🚀 GitHub repository ready!
Say 'deploy-agent deploy my-blog' to deploy to Cloudflare
$ deploy-agent deploy my-blog my-blog.sheraj.org
🎉 Deployment complete!
App live at: https://my-blog.sheraj.org
状态管理
状态存储于:~/.clawdbot/skills/deploy-agent/state/{部署名称}.json
{
"name": "my-blog",
"step": 5,
"status": "deployed",
"created_at": "2026-01-18T08:00:00Z",
"repo_url": "https://github.com/user/my-blog",
"domain": "https://my-blog.sheraj.org"
}
要求
| 工具 | 用途 |
|---|---|
gh | GitHub 仓库创建与管理 |
wrangler | Cloudflare Pages 部署 |
git | 版本控制 |
jq | JSON 解析(用于状态管理) |
配置
Cloudflare 令牌应配置在~/.wrangler.toml:
[account]
api_token = "your-cloudflare-token"
备注
- 每个部署都是独立的
- 状态在会话间持续存在
- 每个主要步骤都需要人工批准
- 随时可使用 "cancel" 中止
Next.js + Cloudflare D1 部署指南
本节涵盖在 Cloudflare Pages 上使用 D1 部署 Next.js 应用程序时的常见陷阱和修复方法。
部署前检查清单
| 检查项 | 命令 | 若失败则修复 |
|---|---|---|
| Next.js 版本 | npm list next | npm install next@15.5.2 |
| 包锁定文件同步 | rm -rf node_modules package-lock.json && npm install | 提交锁定文件 |
| Cloudflare 适配器 | npm list @cloudflare/next-on-pages | npm install -D @cloudflare/next-on-pages |
| wrangler 已安装 | npm list wrangler | npm install -D wrangler |
必需配置
1. package.json
{
"dependencies": {
"next": "15.5.2",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@cloudflare/next-on-pages": "^1.13.16",
"wrangler": "^4.x"
}
}
2. wrangler.toml
name = "my-app"
compatibility_date = "2026-01-18"
compatibility_flags = ["nodejs_compat"]
[[d1_databases]]
binding = "DB"
database_name = "my-db"
database_id = "your-db-id"
3. API 路由(每个文件)
import { getRequestContext } from '@cloudflare/next-on-pages';
export const runtime = 'edge';
export async function GET() {
const { env } = getRequestContext();
const { results } = await env.DB.prepare("SELECT * FROM tasks").all();
return Response.json({ data: results });
}
Cloudflare Pages 构建设置
| 设置项 | 值 |
|---|---|
| 构建命令 | npx @cloudflare/next-on-pages |
| 输出目录 | .vercel/output/static |
| 函数 | 启用(针对 D1 API 路由) |
常见问题与修复
| 问题 | 错误 | 修复方法 |
|---|---|---|
| 锁文件不匹配 | npm ci 仅在 package.json 和 package-lock.json 同步时才能安装包 | rm -rf node_modules package-lock.json && npm install && git add package-lock.json |
| Next.js 版本 | peer next@">=14.3.0 && <=15.5.2"来自 @cloudflare/next-on-pages | 降级至next: "15.5.2" |
| API 路由未启用边缘运行时 | 以下路由未配置为在边缘运行时中运行 | 添加export const runtime = 'edge'; |
| D1 访问模式 | 使用context.env.DB | 使用getRequestContext().env.DB |
| 缺少类型定义 | D1 绑定的 TypeScript 错误 | 创建env.d.ts并包含 CloudflareEnv 接口 |
CSS 修复(滚动条闪烁问题)
html {
overflow-x: hidden;
scrollbar-gutter: stable;
}
body {
overflow-x: hidden;
}
部署后
- Cloudflare 仪表板 → 设置 → 函数
- 添加 D1 绑定:变量名称
DB→ 选择您的数据库
参考文档
- 完整指南:
docs/issues/nextjs-cloudflare-d1-deployment.md - Cloudflare 文档:https://developers.cloudflare.com/pages/framework-guides/nextjs/
文章底部电脑广告
手机广告位-内容正文底部
上一篇:Humanize
下一篇:Token Saver


微信扫一扫,打赏作者吧~