alibabacloud-wxz-website-builder
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCategory: service
Category: service
AI Staff Website Builder (零号员工建站)
AI Staff 网站构建工具(零号员工建站)
Validation
验证
bash
mkdir -p output/alibabacloud-wxz-website-builder
for f in skills/ai/service/alibabacloud-wxz-website-builder/scripts/*.py; do
python3 -m py_compile "$f"
done
echo "py_compile_ok" > output/alibabacloud-wxz-website-builder/validate.txtPass criteria: command exits 0 and is generated.
output/alibabacloud-wxz-website-builder/validate.txtbash
mkdir -p output/alibabacloud-wxz-website-builder
for f in skills/ai/service/alibabacloud-wxz-website-builder/scripts/*.py; do
python3 -m py_compile "$f"
done
echo "py_compile_ok" > output/alibabacloud-wxz-website-builder/validate.txt通过标准:命令执行退出码为0,且生成文件。
output/alibabacloud-wxz-website-builder/validate.txtOutput And Evidence
输出与证据
- Save list/summarize outputs under .
output/alibabacloud-wxz-website-builder/ - Keep conversation IDs and event summaries in each evidence file.
- 将输出列表/摘要保存至目录下。
output/alibabacloud-wxz-website-builder/ - 在每个证据文件中保留对话ID和事件摘要。
Prerequisites
前置依赖
bash
pip install alibabacloud_tea_openapi>=0.4.4 alibabacloud_tea_util>=0.3.14- Credentials are resolved via the default credential chain (no explicit AK/SK needed).
bash
pip install alibabacloud_tea_openapi>=0.4.4 alibabacloud_tea_util>=0.3.14- 通过默认凭证链解析凭证(无需显式配置AK/SK)。
Authentication
认证
This skill relies on the Alibaba Cloud default credential chain. Do NOT set AK/SK explicitly. The SDK automatically resolves credentials in the following order:
- Environment variables: /
ALIBABACLOUD_ACCESS_KEY_IDALIBABACLOUD_ACCESS_KEY_SECRET - Shared config file:
~/.alibabacloud/credentials - RAM role / ECS metadata service (when running on Alibaba Cloud instances)
Region: defaults to .
ALIBABACLOUD_REGION_IDcn-hangzhou本技能依赖阿里云默认凭证链。请勿显式设置AK/SK。SDK会按以下顺序自动解析凭证:
- 环境变量:/
ALIBABACLOUD_ACCESS_KEY_IDALIBABACLOUD_ACCESS_KEY_SECRET - 共享配置文件:
~/.alibabacloud/credentials - RAM角色/ECS元数据服务(当运行在阿里云实例上时)
地域:默认值为。
ALIBABACLOUD_REGION_IDcn-hangzhouHow to obtain AccessKey (if user doesn't have one)
如何获取AccessKey(若用户尚未拥有)
If the user has no AccessKey yet, guide them through these steps (see for full details):
references/ak-setup-guide.md- Login: Open https://www.aliyun.com and log in (or register)
- Create RAM user: Go to https://ram.console.aliyun.com/users → "Create User" → check "OpenAPI Access" → save the AK/SK immediately (Secret is only shown once!)
- Grant permissions: Add a custom policy with the following Actions (least-privilege):
zero2staff:CreateAIStaffConversationzero2staff:CreateAIStaffChatzero2staff:ListAIStaffChatEventszero2staff:ListAIStaffChatMessages
- Configure: Write to or set environment variables
~/.alibabacloud/credentials
CRITICAL: When guiding the user, remind them:
- Do NOT use root account AccessKey — always use RAM sub-user
- Save the AccessKey Secret immediately — it's only shown once during creation
- Never commit AccessKey to git
If the user encounters auth errors, refer to the troubleshooting table in .
references/ak-setup-guide.md如果用户尚未拥有AccessKey,请引导他们完成以下步骤(完整细节请查看):
references/ak-setup-guide.md- 登录:打开https://www.aliyun.com并登录(或注册)
- 创建RAM用户:访问https://ram.console.aliyun.com/users → "创建用户" → 勾选"OpenAPI调用访问" → 立即保存AK/SK(Secret仅会显示一次!)
- 授予权限:添加包含以下操作的自定义策略(最小权限原则):
zero2staff:CreateAIStaffConversationzero2staff:CreateAIStaffChatzero2staff:ListAIStaffChatEventszero2staff:ListAIStaffChatMessages
- 配置:写入文件或设置环境变量
~/.alibabacloud/credentials
重要提示:引导用户时,请提醒他们:
- 请勿使用根账号AccessKey — 务必使用RAM子用户
- 立即保存AccessKey Secret — 它仅在创建时显示一次
- 切勿将AccessKey提交至git仓库
如果用户遇到认证错误,请参考中的故障排查表。
references/ak-setup-guide.mdApplication Lifecycle
应用生命周期
The complete flow has 3 phases. Follow them sequentially.
IMPORTANT — Agent-driven polling: The command fires the request and returns immediately. The agent then drives the polling loop via the command. Between each poll, the agent MUST show the user a progress message so they know what's happening (use for rich messages).
chatpollprogressDetailPhase 1: Create Conversation
↓
Phase 2: Fire requirement chat → poll → HITL → Fire resume → poll → ... → PRD ready
↓
Phase 3: Fire code generation → Show link → poll loop with progress → Site ready完整流程分为3个阶段,请按顺序执行。
重要说明 — 由Agent驱动的轮询:命令发送请求后立即返回。随后由Agent通过命令驱动轮询循环。每次轮询之间,Agent必须向用户显示进度消息,让用户了解当前状态(使用生成丰富的消息内容)。
chatpollprogressDetail阶段1:创建对话
↓
阶段2:触发需求聊天 → 轮询 → HITL人工介入 → 触发恢复 → 轮询 → ... → PRD生成完成
↓
阶段3:触发代码生成 → 展示链接 → 带进度的轮询循环 → 网站就绪Phase 0: Auth Setup
阶段0:认证配置
Ensure Alibaba Cloud credentials are configured via the default credential chain (see Authentication section above).
确保已通过默认凭证链配置阿里云凭证(请查看上文的认证部分)。
Phase 1: Create Conversation
阶段1:创建对话
MUST create a conversation before any chat operation:
bash
CONV=$(python scripts/aistaff_api.py create-conversation --text "做个popmart首页")
CONV_ID=$(echo $CONV | jq -r '.ConversationId')
CHAT_ID=$(echo $CONV | jq -r '.ChatId')
SITE_ID=$(echo $CONV | jq -r '.SiteId')Returns flat JSON: .
{ConversationId, SiteId, ChatId, SectionId, BotId, Title}必须在执行任何聊天操作前创建对话:
bash
CONV=$(python scripts/aistaff_api.py create-conversation --text "做个popmart首页")
CONV_ID=$(echo $CONV | jq -r '.ConversationId')
CHAT_ID=$(echo $CONV | jq -r '.ChatId')
SITE_ID=$(echo $CONV | jq -r '.SiteId')返回扁平JSON格式:。
{ConversationId, SiteId, ChatId, SectionId, BotId, Title}Phase 2: Requirement Collection + PRD
阶段2:需求收集 + PRD生成
This phase collects requirements and generates a PRD. The platform may ask multiple HITL rounds (basic info → features → language, etc.). To keep things fast:
- Only the first HITL round should be shown to the user (basic project info).
- All subsequent HITL rounds must be auto-filled with the form's default/pre-selected values and resumed immediately — do NOT ask the user.
本阶段用于收集需求并生成PRD。平台可能会发起多轮HITL人工介入(基础信息 → 功能 → 语言等)。为提升效率:
- 仅第一轮HITL需要展示给用户(基础项目信息)。
- 后续所有HITL轮次必须自动填充表单的默认/预选值并立即恢复流程 — 请勿询问用户。
Step 1: Fire requirement collection
步骤1:触发需求收集
bash
python scripts/aistaff_api.py chat \
--text "做个popmart首页" \
--conversation-id $CONV_ID \
--biz-id $SITE_IDTell user: "正在分析您的需求,请稍候..."
bash
python scripts/aistaff_api.py chat \
--text "做个popmart首页" \
--conversation-id $CONV_ID \
--biz-id $SITE_ID告知用户:"正在分析您的需求,请稍候..."
Step 2: Poll until first HITL form arrives
步骤2:轮询直至第一轮HITL表单出现
Call every 5 seconds until is :
pollphasewaiting_for_inputbash
python scripts/aistaff_api.py poll \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--last-event-id 0Between each poll, show the user a progress message based on :
phase- → "需求分析进行中..."
processing - → "正在获取参考网站信息..."
fetching_reference - → First HITL form arrived, proceed to Step 3.
waiting_for_input
每5秒调用一次,直到变为:
pollphasewaiting_for_inputbash
python scripts/aistaff_api.py poll \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--last-event-id 0每次轮询之间,根据向用户显示进度消息:
phase- → "需求分析进行中..."
processing - → "正在获取参考网站信息..."
fetching_reference - → 第一轮HITL表单已到达,进入步骤3。
waiting_for_input
Step 3: First HITL — collect answers from user
步骤3:第一轮HITL — 收集用户回答
Extract from the of the event where . Present these questions to the user via the AskUserQuestion tool (typically: app name, business description, target users, reference site).
questionsmetaData.argumentsmessage.toolname: "AskUserQuestion"从事件的中提取(该事件的为"AskUserQuestion")。通过AskUserQuestion工具将这些问题展示给用户(通常包括:应用名称、业务描述、目标用户、参考网站)。
message.toolmetaData.argumentsquestionsnameStep 4: Fire resume with --phase generate_prd
--phase generate_prd步骤4:触发恢复并传入--phase generate_prd
--phase generate_prdCRITICAL: On the first HITL resume, always pass .
--phase generate_prd --user-navigation generate_prdbash
python scripts/aistaff_api.py chat \
--text '{"应用名称": "POP MART 官网", "主营服务": "潮流玩具", "目标用户": "Z世代潮流青年", "参考网站": "无"}' \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--chat-id $CHAT_ID \
--chat-status interrupt \
--phase generate_prd \
--user-navigation generate_prd \
--hidden --without-referThe JSON keys MUST match the values from the form.
--textheaderTell user: "已收到您的需求,正在生成产品方案..."
关键要求:在第一轮HITL恢复时,必须传入。
--phase generate_prd --user-navigation generate_prdbash
python scripts/aistaff_api.py chat \
--text '{"应用名称": "POP MART 官网", "主营服务": "潮流玩具", "目标用户": "Z世代潮流青年", "参考网站": "无"}' \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--chat-id $CHAT_ID \
--chat-status interrupt \
--phase generate_prd \
--user-navigation generate_prd \
--hidden --without-refer--textheader告知用户:"已收到您的需求,正在生成产品方案..."
Step 5: Poll loop — auto-fill subsequent HITL rounds until PRD is ready
步骤5:轮询循环 — 自动填充后续HITL轮次直至PRD生成完成
Poll every 5 seconds. Based on / , take action:
phasesummary- (another HITL question) → Auto-fill immediately using the
phase == "waiting_for_input"field from theanswersevent, then fire resume again. Tell user: "正在完善需求细节..."AskUserQuestion - → Tell user: "PRD 方案生成中,请稍候..."
phase == "generating_prd" - → Tell user: "正在获取参考资料..."
phase == "fetching_reference" - +
summary.chatStatus == "success"→ PRD ready, proceed to Phase 3.summary.hasPrd == true - → Ask user whether to retry.
summary.chatStatus == "fail"
bash
undefined每5秒轮询一次。根据 / 执行对应操作:
phasesummary- (又一轮HITL问题)→ 立即自动填充使用AskUserQuestion事件中的
phase == "waiting_for_input"字段,然后再次触发恢复。告知用户:"正在完善需求细节..."answers - → 告知用户:"PRD 方案生成中,请稍候..."
phase == "generating_prd" - → 告知用户:"正在获取参考资料..."
phase == "fetching_reference" - +
summary.chatStatus == "success"→ PRD生成完成,进入阶段3。summary.hasPrd == true - → 询问用户是否重试。
summary.chatStatus == "fail"
bash
undefinedPoll example:
轮询示例:
python scripts/aistaff_api.py poll
--conversation-id $CONV_ID
--biz-id $SITE_ID
--last-event-id $LAST_EVENT_ID
--conversation-id $CONV_ID
--biz-id $SITE_ID
--last-event-id $LAST_EVENT_ID
python scripts/aistaff_api.py poll
--conversation-id $CONV_ID
--biz-id $SITE_ID
--last-event-id $LAST_EVENT_ID
--conversation-id $CONV_ID
--biz-id $SITE_ID
--last-event-id $LAST_EVENT_ID
Auto-fill example (use the "answers" field from the AskUserQuestion event):
自动填充示例(使用AskUserQuestion事件中的"answers"字段):
python scripts/aistaff_api.py chat
--text '{"核心功能": ["商品展示", "品牌故事", "新闻资讯"]}'
--conversation-id $CONV_ID
--biz-id $SITE_ID
--chat-id $CHAT_ID
--chat-status interrupt
--phase generate_prd
--user-navigation generate_prd
--hidden --without-refer
--text '{"核心功能": ["商品展示", "品牌故事", "新闻资讯"]}'
--conversation-id $CONV_ID
--biz-id $SITE_ID
--chat-id $CHAT_ID
--chat-status interrupt
--phase generate_prd
--user-navigation generate_prd
--hidden --without-refer
**Key rule**: The platform's `AskUserQuestion` event always includes an `answers` field with sensible defaults. For rounds after the first, always use these defaults directly instead of prompting the user.python scripts/aistaff_api.py chat
--text '{"核心功能": ["商品展示", "品牌故事", "新闻资讯"]}'
--conversation-id $CONV_ID
--biz-id $SITE_ID
--chat-id $CHAT_ID
--chat-status interrupt
--phase generate_prd
--user-navigation generate_prd
--hidden --without-refer
--text '{"核心功能": ["商品展示", "品牌故事", "新闻资讯"]}'
--conversation-id $CONV_ID
--biz-id $SITE_ID
--chat-id $CHAT_ID
--chat-status interrupt
--phase generate_prd
--user-navigation generate_prd
--hidden --without-refer
**核心规则**:平台的AskUserQuestion事件始终包含带有合理默认值的`answers`字段。对于第一轮之后的轮次,请直接使用这些默认值,无需提示用户。Phase 3: Code Generation
阶段3:代码生成
When PRD is ready:
当PRD生成完成后:
Step 1: Fire code generation
步骤1:触发代码生成
bash
python scripts/aistaff_api.py chat \
--text "确认生成应用" \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--phase generate_code \
--without-referbash
python scripts/aistaff_api.py chat \
--text "确认生成应用" \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--phase generate_code \
--without-referStep 2: Show site link immediately
步骤2:立即展示网站链接
MUST show before and after code generation:
https://wanwang.aliyun.com/webdesign/home#/ai/manage/prd?conversationId=<CONV_ID>Tell user: "代码生成已启动,通常需要 2-5 分钟。您可以先通过上面的链接查看项目,我会持续跟踪进度..."
必须在代码生成前后都展示:
https://wanwang.aliyun.com/webdesign/home#/ai/manage/prd?conversationId=<CONV_ID>告知用户:"代码生成已启动,通常需要 2-5 分钟。您可以先通过上面的链接查看项目,我会持续跟踪进度..."
Step 3: Poll loop with progress updates
步骤3:带进度更新的轮询循环
Poll every 10 seconds. Show the user progress between each poll:
bash
python scripts/aistaff_api.py poll \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--last-event-id $LAST_EVENT_IDProgress messages to show (use for rich messages):
progressDetail- +
phase == "processing"exists → "代码生成中...正在写入: {latestFile.semantic}(已生成 {filesWrittenCount} 个文件)"progressDetail.latestFile - + no
phase == "processing"→ "代码生成中...已处理 N 个事件"latestFile - +
phase == "processing"exists → Also show the assistant's latest message as contextprogressDetail.lastMessage - → Site is ready! Show link again.
phase == "success" - → Ask user whether to retry.
phase == "fail"
每10秒轮询一次。每次轮询之间向用户展示进度:
bash
python scripts/aistaff_api.py poll \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--last-event-id $LAST_EVENT_ID需展示的进度消息(使用生成丰富内容):
progressDetail- +
phase == "processing"存在 → "代码生成中...正在写入: {latestFile.semantic}(已生成 {filesWrittenCount} 个文件)"progressDetail.latestFile - + 无
phase == "processing"→ "代码生成中...已处理 N 个事件"latestFile - +
phase == "processing"存在 → 同时展示助手的最新消息作为上下文progressDetail.lastMessage - → 网站就绪!再次展示链接。
phase == "success" - → 询问用户是否重试。
phase == "fail"
Step 4: Handle completion
步骤4:处理完成状态
- → Site is ready. Show site link again.
summary.chatStatus == "success" - or
summary.chatStatus == "fail"→ Ask user whether to retry. Do NOT auto-retry.summary.hasError == true
- → 网站就绪。再次展示网站链接。
summary.chatStatus == "success" - 或
summary.chatStatus == "fail"→ 询问用户是否重试。请勿自动重试。summary.hasError == true
After Initial Generation
初始生成后操作
- Use with
chatto modify the site.--conversation-id - Each modification uses the same chat + poll pattern.
- Show the site link again after each modification.
- 使用带有参数的
--conversation-id命令修改网站。chat - 每次修改都遵循相同的聊天+轮询模式。
- 每次修改后再次展示网站链接。
Decision Table
决策表
| | Phase | Action |
|---|---|---|---|
| — | 2 (first round) | Parse AskUserQuestion, collect answers from user, resume with |
| — | 2 (subsequent) | Auto-fill with default |
| | 2 | PRD ready → proceed to Phase 3 |
| | 3 | Site is ready → show link |
| — | any | Ask user whether to retry |
| — | any | Poll timed out → use |
| | 阶段 | 操作 |
|---|---|---|---|
| — | 2(第一轮) | 解析AskUserQuestion,从用户处收集答案,传入 |
| — | 2(后续轮次) | 自动填充AskUserQuestion事件中的默认 |
| | 2 | PRD生成完成 → 进入阶段3 |
| | 3 | 网站就绪 → 展示链接 |
| — | 任意 | 询问用户是否重试 |
| — | 任意 | 轮询超时 → 使用 |
Available Commands
可用命令
create-conversation
create-conversation
bash
python scripts/aistaff_api.py create-conversation --text "用户问题"Returns flat JSON: .
{ConversationId, SiteId, ChatId, SectionId, BotId, Title}bash
python scripts/aistaff_api.py create-conversation --text "用户问题"返回扁平JSON格式:.
{ConversationId, SiteId, ChatId, SectionId, BotId, Title}chat
chat
Fire an async chat message and return immediately. Automatically drains old SSE events before firing. Use afterwards to track progress.
pollbash
python scripts/aistaff_api.py chat --text "description" --conversation-id <ID> --biz-id <ID> [options]Key parameters:
- : Message text or form answers JSON (required)
--text TEXT - /
--conversation-id ID: Required identifiers--biz-id ID - +
--chat-id ID: For HITL resume--chat-status interrupt - : Phase to enter
--phase {requirement_collect,generate_prd,generate_code} - : Navigation target (use
--user-navigation TARGETwithgenerate_prd)--phase generate_prd - /
--hidden: Hide message / skip reference context--without-refer - : Show debug info
--verbose
Returns JSON:
json
{
"conversationId": "conv-xxx",
"chatId": "chat-xxx",
"status": "fired",
"error": null
}发送异步聊天消息并立即返回。发送前会自动清空旧的SSE事件。之后使用跟踪进度。
pollbash
python scripts/aistaff_api.py chat --text "description" --conversation-id <ID> --biz-id <ID> [options]核心参数:
- : 消息文本或表单答案JSON(必填)
--text TEXT - /
--conversation-id ID: 必填标识符--biz-id ID - +
--chat-id ID: 用于HITL恢复--chat-status interrupt - : 要进入的阶段
--phase {requirement_collect,generate_prd,generate_code} - : 导航目标(与
--user-navigation TARGET一起使用时传入--phase generate_prd)generate_prd - /
--hidden: 隐藏消息 / 跳过参考上下文--without-refer - : 显示调试信息
--verbose
返回JSON:
json
{
"conversationId": "conv-xxx",
"chatId": "chat-xxx",
"status": "fired",
"error": null
}poll
poll
Single-shot status check — fetches new events once + checks message status, then returns immediately. Designed for agent-driven polling loops where the agent controls the pace and shows progress to the user between calls.
bash
python scripts/aistaff_api.py poll --conversation-id <ID> --biz-id <ID> [--last-event-id N]Key parameters:
- : Cursor from previous poll (default: 0). Pass the
--last-event-id Nfrom the previouslastEventIdresult to get only new events.poll - : Limit events in output (default: 10, 0=unlimited)
--max-output-events N
Returns JSON:
json
{
"conversationId": "conv-xxx",
"lastEventId": 45,
"newEvents": 3,
"phase": "generating_prd",
"summary": {
"chatStatus": "processing",
"hasError": false,
"errorMsg": "",
"hasPrd": false,
"toolsCalled": ["FetchWebsiteInfo"]
},
"progressDetail": {
"filesWrittenCount": 5,
"activeTools": ["Write"],
"latestFile": {
"path": "/home/wuying/workspace/src/components/Hero.tsx",
"semantic": "首页 Hero 轮播组件",
"status": "wait"
},
"allFiles": [
{"path": "/home/wuying/workspace/src/types/order.ts", "semantic": "订单类型定义"},
{"path": "/home/wuying/workspace/src/components/Hero.tsx", "semantic": "首页 Hero 轮播组件"}
],
"lastMessage": "好的,正在为您生成首页组件...",
"toolProgress": [
{"name": "Write", "status": "done", "semantic": "订单类型定义"},
{"name": "Write", "status": "wait", "semantic": "首页 Hero 轮播组件"}
]
},
"events": ["(last 10 events)"]
}progressDetail- : Total number of files generated so far.
filesWrittenCount - : Tools currently in progress (status=
activeTools). Empty when all tools have completed.wait - : The most recent file being written — show
latestFileto the user (e.g. "正在生成: 首页 Hero 轮播组件").semantic - : Complete list of files written, each with
allFilesandpath.semantic - : Latest assistant text message (truncated to 200 chars).
lastMessage - : Per-tool status list with
toolProgress,name(status/wait), anddone.semantic
Suggested progress messages based on :
progressDetail- If has
latestFile: "正在生成: {latestFile.semantic}..."status == "wait" - If has
latestFileandstatus == "done"is empty: "已完成 {filesWrittenCount} 个文件,等待下一步..."activeTools - If and
filesWrittenCount > 0is not empty: "代码生成中...已生成 {filesWrittenCount} 个文件,正在写入: {latestFile.semantic}"activeTools - If is not empty: Show it as additional context.
lastMessage
phase| Phase | Meaning | Suggested user message |
|---|---|---|
| General processing | "处理中..." |
| Fetching reference site | "正在获取参考网站信息..." |
| HITL form ready | (parse form and handle) |
| PRD generation in progress | "PRD 方案生成中..." |
| Completed successfully | "完成!" |
| Failed | (ask user whether to retry) |
单次状态检查 — 获取一次新事件并检查消息状态,然后立即返回。专为Agent驱动的轮询循环设计,由Agent控制轮询节奏,并在调用之间向用户展示进度。
bash
python scripts/aistaff_api.py poll --conversation-id <ID> --biz-id <ID> [--last-event-id N]核心参数:
- : 上一次轮询的游标(默认值:0)。传入上一次
--last-event-id N结果中的poll以仅获取新事件。lastEventId - : 限制输出事件数量(默认值:10,0=无限制)
--max-output-events N
返回JSON:
json
{
"conversationId": "conv-xxx",
"lastEventId": 45,
"newEvents": 3,
"phase": "generating_prd",
"summary": {
"chatStatus": "processing",
"hasError": false,
"errorMsg": "",
"hasPrd": false,
"toolsCalled": ["FetchWebsiteInfo"]
},
"progressDetail": {
"filesWrittenCount": 5,
"activeTools": ["Write"],
"latestFile": {
"path": "/home/wuying/workspace/src/components/Hero.tsx",
"semantic": "首页 Hero 轮播组件",
"status": "wait"
},
"allFiles": [
{"path": "/home/wuying/workspace/src/types/order.ts", "semantic": "订单类型定义"},
{"path": "/home/wuying/workspace/src/components/Hero.tsx", "semantic": "首页 Hero 轮播组件"}
],
"lastMessage": "好的,正在为您生成首页组件...",
"toolProgress": [
{"name": "Write", "status": "done", "semantic": "订单类型定义"},
{"name": "Write", "status": "wait", "semantic": "首页 Hero 轮播组件"}
]
},
"events": ["(last 10 events)"]
}progressDetail- : 截至目前已生成的文件总数。
filesWrittenCount - : 当前正在执行的工具(status=
activeTools)。所有工具完成后为空。wait - : 最近正在写入的文件 — 向用户展示
latestFile(例如:"正在生成: 首页 Hero 轮播组件")。semantic - : 已写入文件的完整列表,每个文件包含
allFiles和path。semantic - : 助手的最新文本消息(截断至200字符)。
lastMessage - : 按工具分类的状态列表,包含
toolProgress、name(status/wait)和done。semantic
基于的建议进度消息:
progressDetail- 如果的
latestFile: "正在生成: {latestFile.semantic}..."status == "wait" - 如果的
latestFile且status == "done"为空: "已完成 {filesWrittenCount} 个文件,等待下一步..."activeTools - 如果且
filesWrittenCount > 0不为空: "代码生成中...已生成 {filesWrittenCount} 个文件,正在写入: {latestFile.semantic}"activeTools - 如果不为空: 将其作为附加上下文展示。
lastMessage
phase| 阶段 | 含义 | 建议用户消息 |
|---|---|---|
| 通用处理中 | "处理中..." |
| 获取参考网站中 | "正在获取参考网站信息..." |
| HITL表单就绪 | (解析表单并处理) |
| PRD方案生成中 | "PRD 方案生成中..." |
| 处理成功完成 | "完成!" |
| 处理失败 | (询问用户是否重试) |
list-messages
list-messages
Query the latest chat messages. Returns the last N messages (default: 10).
bash
python scripts/aistaff_api.py list-messages --conversation-id <ID> [--tail 10]Key usage: Use this to check of the last message when poll shows no progress.
ChatStatus查询最新的聊天消息。返回最后N条消息(默认值:10)。
bash
python scripts/aistaff_api.py list-messages --conversation-id <ID> [--tail 10]核心用途: 当轮询无进度时,使用此命令检查最后一条消息的。
ChatStatusSSE Event Constraints
SSE事件约束
- Each new chat round may wipe previous SSE events. The command automatically drains old events before firing.
chat - When using , pass the
pollfrom the previous poll result to avoid re-processing events.lastEventId - During code generation, the platform may auto-trigger multiple "magic fix" rounds. The command detects this via event summary.
poll
- 每一轮新的聊天可能会清除之前的SSE事件。命令会自动清空旧事件后再发送请求。
chat - 使用时,传入上一次轮询结果中的
poll以避免重复处理事件。lastEventId - 代码生成期间,平台可能会自动触发多轮"魔法修复"。命令会通过事件摘要检测到这一点。
poll
Error Handling
错误处理
| Error | Action |
|---|---|
| Auth error | Ensure credentials are configured via default credential chain (env vars, config file, or RAM role) |
| Ask user whether to retry. Do NOT auto-retry |
| Poll shows no progress for 5+ minutes | Use |
| 错误 | 操作 |
|---|---|
| 认证错误 | 确保已通过默认凭证链配置凭证(环境变量、配置文件或RAM角色) |
| 询问用户是否重试。请勿自动重试 |
| 轮询5分钟以上无进度 | 使用 |
Complete Workflow Example
完整工作流示例
bash
cd skills/ai/service/alibabacloud-wxz-website-builderbash
cd skills/ai/service/alibabacloud-wxz-website-builderPhase 1: Create conversation
阶段1:创建对话
CONV=$(python scripts/aistaff_api.py create-conversation --text "做个popmart首页")
CONV_ID=$(echo $CONV | jq -r '.ConversationId')
CHAT_ID=$(echo $CONV | jq -r '.ChatId')
SITE_ID=$(echo $CONV | jq -r '.SiteId')
CONV=$(python scripts/aistaff_api.py create-conversation --text "做个popmart首页")
CONV_ID=$(echo $CONV | jq -r '.ConversationId')
CHAT_ID=$(echo $CONV | jq -r '.ChatId')
SITE_ID=$(echo $CONV | jq -r '.SiteId')
Phase 2 Step 1: Fire requirement collection
阶段2 步骤1:触发需求收集
python scripts/aistaff_api.py chat
--text "做个popmart首页"
--conversation-id $CONV_ID
--biz-id $SITE_ID
--text "做个popmart首页"
--conversation-id $CONV_ID
--biz-id $SITE_ID
python scripts/aistaff_api.py chat
--text "做个popmart首页"
--conversation-id $CONV_ID
--biz-id $SITE_ID
--text "做个popmart首页"
--conversation-id $CONV_ID
--biz-id $SITE_ID
→ Tell user: "正在分析您的需求,请稍候..."
→ 告知用户: "正在分析您的需求,请稍候..."
Phase 2 Step 2: Poll until first HITL form arrives
阶段2 步骤2:轮询直至第一轮HITL表单出现
(agent calls this every ~5s, shows progress between calls)
(Agent每约5秒调用一次,调用之间展示进度)
python scripts/aistaff_api.py poll
--conversation-id $CONV_ID
--biz-id $SITE_ID
--last-event-id 0
--conversation-id $CONV_ID
--biz-id $SITE_ID
--last-event-id 0
python scripts/aistaff_api.py poll
--conversation-id $CONV_ID
--biz-id $SITE_ID
--last-event-id 0
--conversation-id $CONV_ID
--biz-id $SITE_ID
--last-event-id 0
→ Check phase: "waiting_for_input" means form is ready
→ 检查phase: "waiting_for_input"表示表单已就绪
Phase 2 Step 3: Parse AskUserQuestion → collect from user (FIRST round only)
阶段2 步骤3:解析AskUserQuestion → 从用户处收集答案(仅第一轮)
Phase 2 Step 4: Fire resume with user answers
阶段2 步骤4:传入用户答案触发恢复
python scripts/aistaff_api.py chat
--text '{"应用名称": "POP MART 官网", "主营服务": "潮流玩具", "目标用户": "Z世代潮流青年", "参考网站": "无"}'
--conversation-id $CONV_ID
--biz-id $SITE_ID
--chat-id $CHAT_ID
--chat-status interrupt
--phase generate_prd
--user-navigation generate_prd
--hidden --without-refer
--text '{"应用名称": "POP MART 官网", "主营服务": "潮流玩具", "目标用户": "Z世代潮流青年", "参考网站": "无"}'
--conversation-id $CONV_ID
--biz-id $SITE_ID
--chat-id $CHAT_ID
--chat-status interrupt
--phase generate_prd
--user-navigation generate_prd
--hidden --without-refer
python scripts/aistaff_api.py chat
--text '{"应用名称": "POP MART 官网", "主营服务": "潮流玩具", "目标用户": "Z世代潮流青年", "参考网站": "无"}'
--conversation-id $CONV_ID
--biz-id $SITE_ID
--chat-id $CHAT_ID
--chat-status interrupt
--phase generate_prd
--user-navigation generate_prd
--hidden --without-refer
--text '{"应用名称": "POP MART 官网", "主营服务": "潮流玩具", "目标用户": "Z世代潮流青年", "参考网站": "无"}'
--conversation-id $CONV_ID
--biz-id $SITE_ID
--chat-id $CHAT_ID
--chat-status interrupt
--phase generate_prd
--user-navigation generate_prd
--hidden --without-refer
→ Tell user: "已收到您的需求,正在生成产品方案..."
→ 告知用户: "已收到您的需求,正在生成产品方案..."
Phase 2 Step 5: Poll loop (agent-driven, ~5s interval)
阶段2 步骤5:轮询循环(Agent驱动,约5秒间隔)
- phase="waiting_for_input" → auto-fill with defaults, fire resume
- phase="waiting_for_input" → 使用默认值自动填充,触发恢复
→ Tell user: "正在完善需求细节..."
→ 告知用户: "正在完善需求细节..."
- phase="generating_prd" → Tell user: "PRD 方案生成中..."
- phase="generating_prd" → 告知用户: "PRD 方案生成中..."
- summary.chatStatus="success" + summary.hasPrd=true → PRD ready, proceed
- summary.chatStatus="success" + summary.hasPrd=true → PRD生成完成,进入下一阶段
Phase 3 Step 1: Fire code generation
阶段3 步骤1:触发代码生成
python scripts/aistaff_api.py chat
--text "确认生成应用"
--conversation-id $CONV_ID
--biz-id $SITE_ID
--phase generate_code
--without-refer
--text "确认生成应用"
--conversation-id $CONV_ID
--biz-id $SITE_ID
--phase generate_code
--without-refer
python scripts/aistaff_api.py chat
--text "确认生成应用"
--conversation-id $CONV_ID
--biz-id $SITE_ID
--phase generate_code
--without-refer
--text "确认生成应用"
--conversation-id $CONV_ID
--biz-id $SITE_ID
--phase generate_code
--without-refer
Phase 3 Step 2: Show link immediately
阶段3 步骤2:立即展示链接
→ Tell user: "代码生成已启动,通常需要 2-5 分钟..."
→ 告知用户: "代码生成已启动,通常需要 2-5 分钟..."
Phase 3 Step 3: Poll loop with progress (~10s interval)
阶段3 步骤3:带进度的轮询循环(约10秒间隔)
python scripts/aistaff_api.py poll
--conversation-id $CONV_ID
--biz-id $SITE_ID
--last-event-id $LAST_EVENT_ID
--conversation-id $CONV_ID
--biz-id $SITE_ID
--last-event-id $LAST_EVENT_ID
python scripts/aistaff_api.py poll
--conversation-id $CONV_ID
--biz-id $SITE_ID
--last-event-id $LAST_EVENT_ID
--conversation-id $CONV_ID
--biz-id $SITE_ID
--last-event-id $LAST_EVENT_ID
→ Use progressDetail.latestFile.semantic for rich messages
→ 使用progressDetail.latestFile.semantic生成丰富消息
→ phase="success" → show link again, done!
→ phase="success" → 再次展示链接,完成!
Modify site (optional, same chat+poll pattern)
修改网站(可选,遵循相同的聊天+轮询模式)
python scripts/aistaff_api.py chat
--text "首页title改下"
--conversation-id $CONV_ID
--biz-id $SITE_ID
--text "首页title改下"
--conversation-id $CONV_ID
--biz-id $SITE_ID
python scripts/aistaff_api.py chat
--text "首页title改下"
--conversation-id $CONV_ID
--biz-id $SITE_ID
--text "首页title改下"
--conversation-id $CONV_ID
--biz-id $SITE_ID
→ poll loop...
→ 轮询循环...
undefinedundefined