alibabacloud-ecs-code-deploy
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDeploy to Alibaba Cloud ECS via aliyun appmanager
通过aliyun appmanager部署到阿里云ECS
Overview
概述
aliyun appmanager--non-interactive--output jsonDefault behavior: When user invokes without specifying a project path or URL, deploy the current working directory project to Alibaba Cloud ECS. If user provides a git URL, clone it to the current directory first, then into the cloned directory and proceed with deployment.
/alibabacloud-ecs-code-deploycdEXECUTION ORDER: The Agent MUST follow the "Complete Deployment Workflow" section at the bottom of this document for the correct execution sequence. The Task sections below are organized by topic for reference — their numbering does NOT imply execution order.
aliyun appmanager--non-interactive--output json默认行为:当用户调用但未指定项目路径或URL时,将当前工作目录的项目部署到阿里云ECS。如果用户提供了Git URL,则先将其克隆到当前目录,然后到克隆的目录中继续部署。
/alibabacloud-ecs-code-deploycd执行顺序:Agent必须遵循本文档底部的“完整部署工作流”部分执行正确的顺序。以下任务章节按主题组织供参考——其编号不代表执行顺序。
MANDATORY: Create Todo List Before Starting
强制要求:开始前创建待办事项列表
Before executing any step, the Agent MUST create a todo list with ALL of the following items. Do NOT omit any item. Do NOT start deployment until the todo list is created.
Todo list (Deploy to Alibaba Cloud ECS):
[ ] 0. Resolve $SKILL_DIR (cross-platform path — MUST run first; see "Step 0" below)
[ ] 1. Environment pre-check (MUST run deploy_toolkit.py check; manual commands FORBIDDEN as replacement)
[ ] 2. Obtain project (clone git URL here if needed; skip for local projects)
── Check whether .appmanager/config.yaml already exists (repeat-deploy shortcut) ──
│ Exists + new ECS (no instanceId) → skip 3-5, start from 5.5 (price check)
│ Exists + existing ECS (has instanceId) → skip 3-5.5, jump to 6 (deploy)
│ Does not exist → proceed normally from 3
───────────────────────────────────────────────────────────────────────────────
[ ] 3. Read project (README.md -> quick-deploy method) + identify type (agent / app)
[ ] 4. Ask user for deployment config (region + new ECS / existing ECS)
[ ] 5. Init + generate scripts (appmanager init -> write start/stop scripts to config.yaml)
[ ] 5.5. Pre-deploy price check + risk warning (MUST run deploy_toolkit.py price; confirm price / OSS billing / existing-ECS impact / group overwrite item by item)
[ ] 6. Deploy (MUST run deploy_toolkit.py deploy; manual deploy command FORBIDDEN as replacement)
[ ] 7. Verify (MUST run deploy_toolkit.py verify; manual status command FORBIDDEN as replacement)
[ ] 8. Output final result (console link + cost reminder + management commands)⛔ SCRIPT-FIRST RULE: Steps 1, 5, 6, 7 have a dedicated toolkit script at(where$SKILL_DIR/scripts/deploy_toolkit.pyis resolved in Step 0 below — works on Qoder, Claude Code, and any other platform). The Agent MUST run the corresponding subcommand DIRECTLY as the FIRST and ONLY action for that step — NEVER run manual CLI commands (like$SKILL_DIR, version checks, credential checks) BEFORE or INSTEAD of the script. The script already handles ALL checks internally. Manual commands are ONLY allowed as fallback if the script file itself does not exist.aliyun version❌ WRONG (Step 1): Run→ check version → runaliyun version→ check version → THEN run~/.aliyun/appmanager-venv/bin/python ...✅ CORRECT (Step 1): Rundeploy_toolkit.py check→ if exit 1, fix the issue it reports → if script file missing, THEN fall back to manual checkspython3 "$SKILL_DIR/scripts/deploy_toolkit.py" check
Item 6 is NON-NEGOTIABLE. An Agent that skips log verification and directly outputs "deployment succeeded" has NOT completed this skill correctly. Ifexits 1 (failed), the Agent MUST fix the issue and re-deploy before proceeding to item 7.deploy_toolkit.py verify
在执行任何步骤之前,Agent必须创建包含以下所有项的待办事项列表。不得遗漏任何项。在创建待办事项列表之前,不得开始部署。
待办事项列表(部署到阿里云ECS):
[ ] 0. 解析$SKILL_DIR(跨平台路径——必须首先执行;请参阅下方“步骤0”)
[ ] 1. 环境预检查(必须运行deploy_toolkit.py check;禁止使用手动命令替代)
[ ] 2. 获取项目(如有需要,在此克隆Git URL;本地项目可跳过)
── 检查.appmanager/config.yaml是否已存在(重复部署快捷方式) ──
│ 已存在 + 新ECS(无instanceId) → 跳过3-5,从5.5开始(价格检查)
│ 已存在 + 现有ECS(有instanceId) → 跳过3-5.5,跳至6(部署)
│ 不存在 → 正常从3开始
───────────────────────────────────────────────────────────────────────────────
[ ] 3. 读取项目(README.md -> 快速部署方法)+ 识别类型(agent / app)
[ ] 4. 向用户询问部署配置(区域 + 新ECS / 现有ECS)
[ ] 5. 初始化 + 生成脚本(appmanager init -> 将启动/停止脚本写入config.yaml)
[ ] 5.5. 部署前价格检查 + 风险提示(必须运行deploy_toolkit.py price;逐项确认价格/OSS计费/现有ECS影响/组覆盖)
[ ] 6. 部署(必须运行deploy_toolkit.py deploy;禁止使用手动部署命令替代)
[ ] 7. 验证(必须运行deploy_toolkit.py verify;禁止使用手动状态命令替代)
[ ] 8. 输出最终结果(控制台链接 + 费用提醒 + 管理命令)⛔ 脚本优先规则:步骤1、5、6、7在中有专用的工具包脚本($SKILL_DIR/scripts/deploy_toolkit.py在下方步骤0中解析——适用于Qoder、Claude Code及其他任何平台)。Agent必须直接运行相应的子命令作为该步骤的第一个且唯一的操作——绝不在脚本之前或替代脚本运行手动CLI命令(如$SKILL_DIR、版本检查、凭证检查)。脚本已在内部处理所有检查。仅当脚本文件本身不存在时,才允许使用手动命令作为备选方案。aliyun version❌ 错误示例(步骤1):运行→ 检查版本 → 运行aliyun version→ 检查版本 → 然后运行~/.aliyun/appmanager-venv/bin/python ...✅ 正确示例(步骤1):运行deploy_toolkit.py check→ 如果退出码为1,修复其报告的问题 → 如果脚本文件缺失,再使用手动检查作为备选python3 "$SKILL_DIR/scripts/deploy_toolkit.py" check
第6项是不可协商的。跳过日志验证并直接输出“部署成功”的Agent未正确完成此技能。如果退出码为1(失败),Agent必须修复问题并重新部署,然后才能进行第7项。deploy_toolkit.py verify
Step 0 (MANDATORY): Resolve $SKILL_DIR
— Cross-Platform Path
$SKILL_DIR步骤0(强制要求):解析$SKILL_DIR
——跨平台路径
$SKILL_DIRThe toolkit script lives at. Different platforms install skills to different locations (Qoder/Claude Code/Qwen/...). The Agent MUST resolve the absolute skill root once at session start and reuse it everywhere<skill-root>/scripts/deploy_toolkit.pyappears below. Hardcoding any platform-specific path is FORBIDDEN.$SKILL_DIR
See references/skill-dir-resolution.md for the full 10-candidate detection algorithm, the verify snippet, and Pattern A / Pattern B / ⛔ Anti-pattern usage rules.
export + test -fQuick recap (read the reference for details):
- ✅ Pattern A (persistent shell): then later
export SKILL_DIR="/abs/path"python3 "$SKILL_DIR/scripts/deploy_toolkit.py" <sub> - ✅ Pattern B (fresh shell per call): inline the absolute path —
python3 "/abs/path/scripts/deploy_toolkit.py" <sub> - ⛔ Anti-pattern: — outer shell expands
SKILL_DIR=/path python3 "$SKILL_DIR/..."BEFORE the prefix assignment, producing$SKILL_DIRand ENOENT. If you see/scripts/deploy_toolkit.py, switch to Pattern A or B.python3: can't open file '/scripts/deploy_toolkit.py'
工具包脚本位于。不同平台将技能安装到不同位置(Qoder/Claude Code/Qwen/...)。Agent必须在会话开始时一次性解析绝对技能根目录,并在所有出现<skill-root>/scripts/deploy_toolkit.py的地方重复使用它。禁止硬编码任何特定于平台的路径。$SKILL_DIR
有关完整的10候选检测算法、验证代码片段以及模式A/模式B/⛔反模式使用规则,请参阅references/skill-dir-resolution.md。
export + test -f快速回顾(详细内容请阅读参考文档):
- ✅ 模式A(持久化shell):,之后使用
export SKILL_DIR="/abs/path"python3 "$SKILL_DIR/scripts/deploy_toolkit.py" <sub> - ✅ 模式B(每次调用使用新shell):内联绝对路径——
python3 "/abs/path/scripts/deploy_toolkit.py" <sub> - ⛔ 反模式:——外部shell在前缀赋值之前展开
SKILL_DIR=/path python3 "$SKILL_DIR/...",产生$SKILL_DIR并导致ENOENT错误。如果看到/scripts/deploy_toolkit.py,请切换到模式A或B。python3: can't open file '/scripts/deploy_toolkit.py'
Task 1: Install Alibaba Cloud CLI
任务1:安装阿里云CLI
Primary action: Run — it checks CLI version + appmanager-cli version + credentials in one run. Only if the script file is missing, use the fallback in references/init-and-credentials.md.
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" checkMUST — Handling unmet environment prerequisites: Whenexits 1 because the aliyun CLI is missing or older than 3.3.19 (or appmanager-cli is missing/outdated), the Agent MUST NOT stop the workflow silently. The required flow is:check
- CLI NOT installed → Auto-install directly without asking user — execute the install command (see snippet below or references/init-and-credentials.md for the right arch), then re-run
to confirm.deploy_toolkit.py check- CLI already installed → ASK the user first — show the detected version + the required version + the upgrade command, and ask for explicit consent (e.g. "aliyun CLI 3.3.4 is already installed but below the required >= 3.3.19 for appmanager; approve upgrade (overwrite-install into /usr/local/bin, requires sudo)?"). Never assume yes; never paste credentials.
- On approval — execute the install/upgrade command, then re-run
to confirm.deploy_toolkit.py check- On refusal — stop with the refusal as the reason. Do NOT continue with the older version (deployment will fail anyway).
The toolkit'soutput already includes ancheckline for each fixable issue — follow it verbatim (except for the "not installed" case, which is auto-handled).→ AGENT: DO NOT stop. ASK user ...MUST — Upgrade method priority (avoid the "repeated upgrade" pitfall:is often shadowed by earlier PATH entries like/usr/local/bin/):/opt/homebrew/bin
- brew-managed (
prints "managed by Homebrew") ->check; do NOT overwritebrew upgrade aliyun-cliagain./usr/local/bin/- sudo available -> overwrite into
, then verify:/usr/local/bin/.hash -r && which -a aliyun && aliyun version- No sudo -> install to
, ask user to approve appending~/bin/toexport PATH="$HOME/bin:$PATH"/~/.zshrc.~/.bashrcAfter install/upgrade, ALWAYS rerunto confirm. Ifdeploy_toolkit.py checkstill shows the old binary first, fix PATH order — DO NOT repeat the same overwrite.which -a aliyun
主要操作:运行——它会一次性检查CLI版本+appmanager-cli版本+凭证。仅当脚本文件缺失时,才使用references/init-and-credentials.md中的备选方案。
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" check必须——处理未满足的环境先决条件:当退出码为1,原因是aliyun CLI缺失或版本低于3.3.19(或appmanager-cli缺失/过时)时,Agent不得静默停止工作流。所需流程为:check
- CLI未安装 → 直接自动安装,无需询问用户——执行安装命令(请参阅下方代码片段或references/init-and-credentials.md获取对应架构的命令),然后重新运行
确认。deploy_toolkit.py check- CLI已安装 → 先询问用户——显示检测到的版本+所需版本+升级命令,并请求明确同意(例如:“aliyun CLI 3.3.4已安装,但低于appmanager所需的>=3.3.19版本;是否批准升级(覆盖安装到/usr/local/bin,需要sudo权限)?”)。绝不要默认同意;绝不要粘贴凭证。
- 获得批准后——执行安装/升级命令,然后重新运行
确认。deploy_toolkit.py check- 被拒绝后——以拒绝为理由停止。不得继续使用旧版本(部署无论如何都会失败)。
工具包的输出已包含针对每个可修复问题的check行——请严格按照该行内容执行(“未安装”情况除外,该情况会自动处理)。→ AGENT: DO NOT stop. ASK user ...必须——升级方法优先级(避免“重复升级”陷阱:通常被更早的PATH条目如/usr/local/bin/覆盖):/opt/homebrew/bin
- brew管理(
输出“managed by Homebrew”)→check;不得再次覆盖brew upgrade aliyun-cli。/usr/local/bin/- 有sudo权限→覆盖安装到
,然后验证:/usr/local/bin/。hash -r && which -a aliyun && aliyun version- 无sudo权限→安装到
,请求用户批准将~/bin/追加到export PATH="$HOME/bin:$PATH"/~/.zshrc。~/.bashrc安装/升级后,始终重新运行确认。如果deploy_toolkit.py check仍显示旧二进制文件优先,请修复PATH顺序——不得重复相同的覆盖操作。which -a aliyun
AI-Mode Configuration (MANDATORY after CLI install)
AI模式配置(安装CLI后强制要求)
⛔ MUST configure AI-Mode: Agent MUST ensure AI-Mode is properly configured before running anycommands.aliyun appmanagerhandles this internally; the commands below are for manual fallback only.deploy_toolkit.py check
bash
aliyun configure ai-mode enable
aliyun configure ai-mode set-user-agent --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-ecs-code-deploy"
aliyun plugin update
aliyun configure ai-mode show # verify: enabled=true, user-agent set
aliyun configure ai-mode disable # only when troubleshooting⛔ 必须配置AI模式:Agent必须确保在运行任何命令之前正确配置AI模式。aliyun appmanager会在内部处理此操作;以下命令仅用于手动备选。deploy_toolkit.py check
bash
aliyun configure ai-mode enable
aliyun configure ai-mode set-user-agent --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-ecs-code-deploy"
aliyun plugin update
aliyun configure ai-mode show # 验证:enabled=true,user-agent已设置
aliyun configure ai-mode disable # 仅在排查问题时使用Task 2: Configure Credentials
任务2:配置凭证
deploy_toolkit.py check⛔ PREFER OAuth OVER AK: This skill SHOULD guide users to use OAuth authentication as the PRIMARY method for providing Alibaba Cloud permissions. OAuth is more secure and convenient than AccessKey (no long-term secret storage needed). The Agent MUST present OAuth as the first option before mentioning AK-based methods.OAuth Login Guide: Instruct the user to run the following command in their terminal:bashaliyun configure --mode OAuth --profile oauthThis is an interactive command that will:
- Open a browser with an authorization link — user clicks to authorize
- Prompt for region (e.g.
,cn-hangzhou) — user enters their preferred regioncn-beijing- Prompt for language (e.g.
) — user enters their preferred languagezhAfter OAuth setup completes, verify with:aliyun sts get-caller-identity --profile oauth⛔ SA-2.12 — DO NOT explicitly handle AK/SK: This skill MUST rely on the aliyun CLI/SDK default credential chain (OAuth / ECS RAM Role / env vars / pre-existing). The Agent NEVER asks the user to paste AccessKey/Secret/STS-Token values into the chat, NEVER puts raw AK/SK in tool-call arguments or scripts, and NEVER echoes credential values. When credentials are missing, instruct the user to configure them out-of-band (their own terminal/shell profile/RAM role) and only re-verify via~/.aliyun/config.json. Full remediation flow → references/init-and-credentials.md.aliyun sts get-caller-identityCRITICAL PROHIBITION: NEVER run standaloneorappmanager.aliyun appmanager login
deploy_toolkit.py check⛔ 优先选择OAuth而非AK:此技能应引导用户使用OAuth认证作为提供阿里云权限的主要方法。OAuth比AccessKey更安全、更便捷(无需长期存储密钥)。Agent必须在提及基于AK的方法之前,首先将OAuth作为第一个选项呈现。OAuth登录指南:指导用户在终端中运行以下命令:bashaliyun configure --mode OAuth --profile oauth这是一个交互式命令,将:
- 打开带有授权链接的浏览器——用户点击授权
- 提示输入区域(例如
、cn-hangzhou)——用户输入偏好的区域cn-beijing- 提示输入语言(例如
)——用户输入偏好的语言zhOAuth设置完成后,使用以下命令验证:aliyun sts get-caller-identity --profile oauth⛔ SA-2.12 — 不得显式处理AK/SK:此技能必须依赖aliyun CLI/SDK的默认凭证链(OAuth/ECS RAM角色/环境变量/预先存在的)。Agent绝不要求用户将AccessKey/Secret/STS-Token值粘贴到聊天中,绝不将原始AK/SK放入工具调用参数或脚本中,绝不回显凭证值。当凭证缺失时,指导用户在外部配置(自己的终端/shell配置文件/RAM角色),仅通过~/.aliyun/config.json重新验证。完整修复流程→references/init-and-credentials.md。aliyun sts get-caller-identity严格禁止:绝不要运行独立的或appmanager命令。aliyun appmanager login
Task 3: Initialize Project
任务3:初始化项目
Step 1 (MANDATORY): Read README.md FIRST
步骤1(强制要求):首先读取README.md
CRITICAL ORDERING RULE: Before scanning any project files, the Agent MUST read(orREADME.md) in the project root. This is ALWAYS the first action in Task 3.README
What to extract from README:
- Quick-start / deploy commands (e.g. ,
pip install -r requirements.txt && python main.py)npm install && npm start - Official build/run commands, Docker deploy methods, port number, required environment variables
关键顺序规则:在扫描任何项目文件之前,Agent必须读取项目根目录下的(或README.md)。这始终是任务3中的第一个操作。README
从README中提取的内容:
- 快速启动/部署命令(例如、
pip install -r requirements.txt && python main.py)npm install && npm start - 官方构建/运行命令、Docker部署方法、端口号、所需环境变量
MANDATORY: Present README Methods to User and Follow Decision Tree
强制要求:向用户展示README中的方法并遵循决策树
Step A: List what README provides to the user.
Step B: Select method by priority:
| Priority | Method Type | Action |
|---|---|---|
| 1 (HIGHEST) | Native CLI / package manager install ( | Use directly |
| 2 | Native build + run ( | Use, install runtime |
| 3 | Script-based deploy ( | Must confirm non-interactive |
| 4 (LOWEST) | Docker / docker-compose | Only when no higher priority exists; check China accessibility |
Step C: Execute based on scenario:
- README has native method (priority 1/2) → Use it directly as start script core. NEVER ignore README and build from scratch.
- README only has Docker → Check image accessibility (see references/script-templates.md "Docker Image Accessibility Check"). Warn user about China mirror risks.
- README has no deploy info / absent → Agent scans project files independently (only allowed case).
Why README first? Most projects document the exact build/run commands. Auto-detecting from files alone is error-prone.
步骤A:列出README提供的内容给用户。
步骤B:按优先级选择方法:
| 优先级 | 方法类型 | 操作 |
|---|---|---|
| 1(最高) | 原生CLI/包管理器安装( | 直接使用 |
| 2 | 原生构建+运行( | 使用,安装运行时 |
| 3 | 基于脚本的部署( | 必须确认非交互性 |
| 4(最低) | Docker/docker-compose | 仅当无更高优先级方法时使用;检查中国地区的可访问性 |
步骤C:根据场景执行:
- README有原生方法(优先级1/2) → 直接将其作为启动脚本核心。绝不要忽略README并从头构建。
- README只有Docker方法 → 检查镜像可访问性(请参阅references/script-templates.md中的“Docker镜像可访问性检查”)。向用户警告中国镜像风险。
- README无部署信息/不存在 → Agent独立扫描项目文件(仅允许此情况)。
**为什么先看README?**大多数项目都会记录确切的构建/运行命令。仅从文件自动检测容易出错。
Step 2: Determine project type
步骤2:确定项目类型
| Condition | Type |
|---|---|
Project depends on | |
| Everything else (langchain, mcp, autogen, web services, tools, etc.) | |
| 条件 | 类型 |
|---|---|
项目依赖 | |
| 其他所有情况(langchain、mcp、autogen、Web服务、工具等) | |
Determine --name
--name确定--name
--nameUse the project directory name (lowercased, hyphens). Inform user: .
Default app name uses the directory name <name>使用项目目录名称(小写,连字符分隔)。告知用户:。
默认应用名称使用目录名称<name>Determine --region
and ECS target (MUST ask user)
--region确定--region
和ECS目标(必须询问用户)
--regionAgent MUST ask both questions together in ONE message:
1. Which region do you want to deploy to?
- Shanghai (cn-shanghai) / Hangzhou (cn-hangzhou) / Beijing (cn-beijing) / Shenzhen (cn-shenzhen) / Guangzhou (cn-guangzhou) / Chengdu (cn-chengdu) / Nanjing (cn-nanjing) / Hong Kong (cn-hongkong)
2. New ECS or existing ECS?
- New ECS (auto-create instance, pay-as-you-go)
- Existing ECS (please provide the instance ID, e.g.
)i-bp1xxxxxxxx
NEVER use zone-based labels like "East China 1" / "North China 2". NEVER add descriptions. City names only.
⚠️ REGION PROPAGATION CHECK (MANDATORY): The chosen region MUST be passed verbatim to, written intoappmanager init --regionconfig.yaml, AND attached ascommon.deployment.regionIdto every subsequent--region <REGION_ID>invocation. Mismatch / omission triggersdeploy_toolkit.py {price,deploy,verify}from the OOS API.InvalidParameter: DeployRegionId is invalid
Agent必须在一条消息中同时提出这两个问题:
1. 您想部署到哪个区域?
- 上海(cn-shanghai)/杭州(cn-hangzhou)/北京(cn-beijing)/深圳(cn-shenzhen)/广州(cn-guangzhou)/成都(cn-chengdu)/南京(cn-nanjing)/香港(cn-hongkong)
2. 新ECS还是现有ECS?
- 新ECS(自动创建实例,按量付费)
- 现有ECS(请提供实例ID,例如
)i-bp1xxxxxxxx
绝不要使用“华东1”/“华北2”等基于可用区的标签。绝不要添加描述。仅使用城市名称。
⚠️ 区域传播检查(强制要求):所选区域必须原样传递给、写入appmanager init --region的config.yaml,并作为common.deployment.regionId附加到后续每个--region <REGION_ID>调用中。不匹配/遗漏会触发OOS API返回deploy_toolkit.py {price,deploy,verify}错误。InvalidParameter: DeployRegionId is invalid
Determine --port
(App type only, OPTIONAL)
--port确定--port
(仅App类型可选)
--portOnly specify when the project actually listens on HTTP. Skip for background services (bots, workers, CLI tools). If needed but unknown, default to . Agent type does NOT use .
8080--port仅当项目实际监听HTTP时指定。后台服务(机器人、工作进程、CLI工具)可跳过。如果需要但未知,默认使用。Agent类型不使用。
8080--portNon-interactive init
非交互式初始化
See references/init-and-credentials.md for all init flag combinations.
Creates . Does NOT support — delete first if exists.
.appmanager/config.yaml--overwrite.appmanager/有关所有初始化标志组合,请参阅references/init-and-credentials.md。
创建。不支持——如果存在,请先删除。
.appmanager/config.yaml--overwrite.appmanager/Task 4: Generate Deploy Scripts
任务4:生成部署脚本
For ALL project types, the Agent MUST generate deployment scripts and write them into .
.appmanager/config.yaml对于所有项目类型,Agent必须生成部署脚本并写入。
.appmanager/config.yamlWorkflow
工作流
- Read README.md FIRST — follow Task 3 decision tree
- If README has no deploy info — scan project structure (Language Detection below)
- Docker accessibility check — if Docker path selected (see references/script-templates.md)
- Generate start & stop scripts — following rules below. Start script MUST ALWAYS include zip extraction sequence.
- Write to config.yaml — under and
common.scripts.start(NEVER top-levelcommon.scripts.stop)scripts
- 首先读取README.md——遵循任务3的决策树
- 如果README无部署信息——扫描项目结构(下方语言检测)
- Docker可访问性检查——如果选择Docker路径(请参阅references/script-templates.md)
- 生成启动和停止脚本——遵循以下规则。启动脚本必须始终包含解压zip的步骤。
- 写入config.yaml——位于和
common.scripts.start下(绝不要放在顶级common.scripts.stop中)scripts
Language Detection Rules
语言检测规则
| Indicator Files | Language |
|---|---|
| Node.js |
| Python |
| Java |
| Go |
| PHP |
| Docker |
| 指示文件 | 语言 |
|---|---|
| Node.js |
| Python |
| Java |
| Go |
| PHP |
| Docker |
Files to Read (MUST read content, not just detect presence)
必须读取的文件(必须读取内容,而非仅检测存在性)
| Language | Must Read | Why |
|---|---|---|
| Python | | Entry point, deps |
| Node.js | | |
| Java | | JAR name |
| Go | | Module → binary name |
| PHP | | Framework detection |
| Docker | | Services, ports |
| 语言 | 必须读取 | 原因 |
|---|---|---|
| Python | | 入口点、依赖 |
| Node.js | | |
| Java | | JAR名称 |
| Go | | 模块→二进制名称 |
| PHP | | 框架检测 |
| Docker | | 服务、端口 |
Entry Point Detection Order
入口点检测顺序
- Python: in pyproject.toml →
[project.scripts]→main.py→app.pymanage.py - Node.js: →
scripts.startfield →main→index.jsserver.js - Java: →
find ... -name "*.jar" | head -1java -jar - Go: Pre-compiled binary:
find ... -type f -perm /111 - PHP: →
composer install --no-devorphp artisan servephp -S - Docker Compose: /
docker compose up -ddocker compose down
- Python:中的
pyproject.toml→[project.scripts]→main.py→app.pymanage.py - Node.js:→
scripts.start字段 →main→index.jsserver.js - Java:→
find ... -name "*.jar" | head -1java -jar - Go:预编译二进制文件:
find ... -type f -perm /111 - PHP:→
composer install --no-dev或php artisan servephp -S - Docker Compose:/
docker compose up -ddocker compose down
General Script Rules
通用脚本规则
| Rule | Requirement |
|---|---|
| ⛔ MANDATORY zip extract | Start script MUST: find zip → |
| Runtime install | MUST install language runtime FIRST (ECS is bare) |
| Install unzip | |
| Idempotent | Safe to run multiple times |
| ⛔ Log file FIXED path | MUST be |
| Log append | Always |
| PID file | |
| Background run | |
| Stop old process | |
| App dir | |
| No heredoc | NEVER use |
| MANDATORY tail log | End with |
| ⛔ Stop script: NO exit | MUST NOT contain |
ECS instances are bare Linux (typically Alibaba Cloud Linux, RHEL-based, uses/yum).dnf
For script templates, language install commands, and config.yaml writing method, see references/script-templates.md.
| 规则 | 要求 |
|---|---|
| ⛔ 必须解压zip | 启动脚本必须:找到zip→ |
| 安装运行时 | 必须首先安装语言运行时(ECS是裸机) |
| 安装unzip | `command -v unzip &>/dev/null |
| 幂等性 | 可安全多次运行 |
| ⛔ 日志文件固定路径 | 必须为 |
| 日志追加 | 始终使用 |
| PID文件 | |
| 后台运行 | |
| 停止旧进程 | `[ -f /root/app.pid ] && kill "$(cat /root/app.pid)" 2>/dev/null |
| 应用目录 | |
| 不使用heredoc | 绝不要在脚本中使用 |
| 必须查看日志尾部 | 以 |
| ⛔ 停止脚本:不要exit | 不得包含 |
ECS实例是裸机Linux(通常是阿里云Linux,基于RHEL,使用/yum)。dnf
有关脚本模板、语言安装命令和config.yaml写入方法,请参阅references/script-templates.md。
Task 4.5: Pre-deploy Price Check + Risk Warning
任务4.5:部署前价格检查 + 风险提示
MANDATORY: Before deploying, run. The script outputs the price estimate (with OSS extra-billing reminder) and, when applicable, a risk warning block. The Agent MUST present every flagged item to the user and obtain explicit confirmation BEFORE runningdeploy_toolkit.py price.deploy
bash
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" price --config .appmanager/config.yaml- Exit 0 + : present the complete price + risk warning to the user, confirm item by item.
=== AGENT_CONFIRM_REQUIRED === - Exit 1: price query failed; do NOT proceed to deploy.
The Agent MUST confirm up to 3 items (price + OSS fees / existing-ECS risk / group overwrite choice) — see references/deploy-output-and-management.md § "Pre-deploy Price Check: Confirmation Items" for detailed descriptions and example phrasing.
Until ALL applicable confirmations are complete, the Agent MUST NOT invoke.deploy_toolkit.py deploy
强制要求:部署前运行。脚本输出价格估算(含OSS额外计费提醒),并在适用时输出风险警告块。Agent必须向用户展示所有标记项,并在运行deploy_toolkit.py price之前获得明确确认。deploy
bash
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" price --config .appmanager/config.yaml- 退出码0 + :向用户展示完整的价格+风险警告,逐项确认。
=== AGENT_CONFIRM_REQUIRED === - 退出码1:价格查询失败;不得继续部署。
Agent必须确认最多3项(价格+OSS费用/现有ECS风险/组覆盖选择)——请参阅references/deploy-output-and-management.md §“部署前价格检查:确认项”获取详细说明和示例措辞。
在完成所有适用确认之前,Agent不得调用。deploy_toolkit.py deploy
Task 5: Deploy
任务5:部署
aliyun appmanager <agent|app> deploy --overwrite --output jsonSTOP after deploy success —only means orchestration completed. Agent MUST run Task 6 verification before outputting results.status: success
aliyun appmanager <agent|app> deploy --overwrite --output json部署成功后停止——仅表示编排完成。Agent必须运行任务6的验证,然后再输出结果。status: success
Handling deployment failure
处理部署失败
⛔ MANDATORY FAILURE GATE: After ANY deploy failure (exit 1, timeout, or), the Agent MUST runReleaseCancelledIMMEDIATELY — BEFORE any fix attempt, fallback to manual commands, or partial output. Skipping verify after a failure is FORBIDDEN and counts as skill failure.deploy_toolkit.py verify
Semantics of: it means the start script on ECS failed or timed out. It does NOT mean "someone cancelled the deploy". The only correct next action: runReleaseCancelled-> read the log -> fix the script -> redeploy.deploy_toolkit.py verify
Known failure patterns: Before ad-hoc troubleshooting, check references/lessons-learned.md for previously identified deployment failure patterns and proven fixes.
Failure-handling flow:
- Run to fetch
deploy_toolkit.py verify(DO NOT skip)./root/app.log - Analyze the log to locate root cause.
- Fix scripts and redeploy (max 3 attempts).
- After 3 failures, stop — report the error, but still output console link + cost reminder + delete command.
⛔ 强制失败处理门:任何部署失败后(退出码1、超时或),Agent必须立即运行ReleaseCancelled——在任何修复尝试、切换到手动命令或输出部分结果之前。部署失败后跳过验证是禁止的,并视为技能失败。deploy_toolkit.py verify
的含义:表示ECS上的启动脚本失败或超时。它不表示“有人取消了部署”。唯一正确的下一步操作:运行ReleaseCancelled→读取日志→修复脚本→重新部署。deploy_toolkit.py verify
已知失败模式:在进行临时故障排除之前,请查看references/lessons-learned.md中已识别的部署失败模式和已验证的修复方法。
失败处理流程:
- 运行获取
deploy_toolkit.py verify(不得跳过)。/root/app.log - 分析日志定位根本原因。
- 修复脚本并重新部署(最多3次尝试)。
- 3次失败后停止——报告错误,但仍需输出控制台链接+费用提醒+删除命令。
Task 6: Post-deploy Verification (BLOCKING)
任务6:部署后验证(阻塞)
does NOT mean the application is running. The Agent MUST run verify and semantically analyze the log.status: Deployed
- Run (auto-reads parameters from config.yaml).
deploy_toolkit.py verify - Agent semantically analyzes the log to decide whether the application actually started successfully.
- Not running -> diagnose -> fix -> redeploy + verify (max 3 attempts).
- Only when running is confirmed / user manual action required / 3 attempts failed should the Agent output the final result.
并不意味着应用正在运行。Agent必须运行验证并对日志进行语义分析。status: Deployed
- 运行(自动从config.yaml读取参数)。
deploy_toolkit.py verify - Agent对日志进行语义分析,判断应用是否实际启动成功。
- 未运行→诊断→修复→重新部署+验证(最多3次尝试)。
- 仅当确认应用正在运行/需要用户手动操作/3次尝试失败时,Agent才输出最终结果。
Task 7 & 8: List, Delete, Validate & Final Output
任务7 & 8:列出、删除、验证与最终输出
See references/deploy-output-and-management.md for:
- List/Delete commands
- Config validation
- Config template reference
- Critical notes & pitfalls
- MANDATORY post-deploy output format (console link, cost reminder, usage guide)
有关以下内容,请参阅references/deploy-output-and-management.md:
- 列出/删除命令
- 配置验证
- 配置模板参考
- 重要注意事项与陷阱
- 强制要求的部署后输出格式(控制台链接、费用提醒、使用指南)
Pre-output Gate — Self-check (⛔ BLOCKING)
输出前检查门(⛔ 阻塞)
Before outputting results, Agent MUST print the exact template (see Workflow Step 7.5). Skipping the report = skill failure (not an optional summary). If any item is ❌, fix it BEFORE outputting Step 8.
Deployment self-check report📘 Hands-on walk-through with concrete inputs/outputs and edge cases (Python Flask example): see references/tutorial-flask-app.md.
输出结果之前,Agent必须打印确切的模板(请参阅工作流步骤7.5)。跳过报告=技能失败(不是可选摘要)。如果任何项为❌,请在输出步骤8之前修复。
部署自检报告📘 包含具体输入/输出和边缘情况的实操演练(Python Flask示例):请参阅references/tutorial-flask-app.md。
Complete Deployment Workflow
完整部署工作流
⛔ MANDATORY EXECUTION RULE: The Agent MUST follow this sequence exactly. For steps that specify a script (steps 1, 5, 6), the Agent MUST run the script — NEVER manually replicate the script's logic with individual commands. The Task sections above are REFERENCE ONLY (for understanding what the scripts do internally or as fallback if scripts are missing).
⛔ 强制执行规则:Agent必须严格遵循此顺序。对于指定使用脚本的步骤(步骤1、5、6),Agent必须运行脚本——绝不要使用单个命令手动复制脚本的逻辑。以上任务章节仅作为参考(用于理解脚本内部的操作,或在脚本缺失时作为备选)。
0. Resolve $SKILL_DIR (MANDATORY — see "Step 0" section above for full algorithm)
0. 解析$SKILL_DIR(强制要求——请参阅上方“步骤0”获取完整算法)
→ Detect the absolute directory containing THIS SKILL.md (most accurate)
→ 检测包含此SKILL.md的绝对目录(最准确)
→ Or fall back to platform-specific candidates: ~/.qoder/skills/..., ~/.claude/skills/..., ~/.qwen/skills/..., $SKILLS_HOME/..., etc.
→ 或回退到特定于平台的候选路径:/.qoder/skills/...、/.claude/skills/...、~/.qwen/skills/...、$SKILLS_HOME/...等
→ Pattern A (persistent shell): export SKILL_DIR=<abs_path> ; verify $SKILL_DIR/scripts/deploy_toolkit.py exists ; reuse $SKILL_DIR everywhere
→ 模式A(持久化shell):export SKILL_DIR=<abs_path> ; 验证$SKILL_DIR/scripts/deploy_toolkit.py存在 ; 在所有地方重用$SKILL_DIR
→ Pattern B (fresh shell per command): inline the absolute path — python3 "/abs/path/scripts/deploy_toolkit.py" ...
python3 "/abs/path/scripts/deploy_toolkit.py" ...→ 模式B(每次调用使用新shell):内联绝对路径——python3 "/abs/path/scripts/deploy_toolkit.py" ...
python3 "/abs/path/scripts/deploy_toolkit.py" ...→ ⛔ NEVER use SKILL_DIR=/path python3 "$SKILL_DIR/..."
— outer shell expands $SKILL_DIR
SKILL_DIR=/path python3 "$SKILL_DIR/..."→ ⛔ 绝不要使用SKILL_DIR=/path python3 "$SKILL_DIR/..."
——外部shell会在
SKILL_DIR=/path python3 "$SKILL_DIR/..."BEFORE the prefix assignment, producing /scripts/deploy_toolkit.py
and ENOENT.
/scripts/deploy_toolkit.py前缀赋值之前展开$SKILL_DIR,产生/scripts/deploy_toolkit.py
并导致ENOENT错误。
/scripts/deploy_toolkit.py1. Environment check (MUST use deploy_toolkit.py check — DO NOT run manual commands)
1. 环境检查(必须使用deploy_toolkit.py check——不得运行手动命令)
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" check
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" check
⛔ FORBIDDEN: running aliyun version
, ~/.aliyun/appmanager-venv/bin/python -c "..."
,
aliyun version~/.aliyun/appmanager-venv/bin/python -c "..."⛔ 禁止:在运行此脚本之前或替代此脚本运行aliyun version
、~/.aliyun/appmanager-venv/bin/python -c "..."
、
aliyun version~/.aliyun/appmanager-venv/bin/python -c "..."credential checks, or ANY manual version-check commands before or instead of this script.
凭证检查或任何手动版本检查命令。
The script checks ALL of: CLI version + appmanager-cli version + credentials in one run.
该脚本会一次性检查所有内容:CLI版本+appmanager-cli版本+凭证。
Just run the script. Period.
只需运行脚本即可。仅此而已。
→ If exit 0: all checks passed, proceed to step 2
→ 如果退出码0:所有检查通过,继续步骤2
→ If exit 1, address the issue printed by the script:
→ 如果退出码1,处理脚本输出的问题:
⚠️ DO NOT stop silently. For every fixable ❌ line the script prints,
⚠️ 不得静默停止。对于脚本输出的每个可修复的❌行,
Agent MUST follow the flow below:
Agent必须遵循以下流程:
- aliyun CLI NOT installed: AUTO-INSTALL directly (no need to ask user)
- aliyun CLI未安装:直接自动安装(无需询问用户)
- aliyun CLI already installed but outdated: ASK user to approve upgrade
- aliyun CLI已安装但过时:询问用户是否批准升级
(covers to /usr/local/bin, needs sudo), then run the install command
(覆盖安装到/usr/local/bin,需要sudo权限),然后运行脚本输出的安装命令
printed by the script (see Task 1).
(请参阅任务1)。
- appmanager-cli < 1.1.1 or BROKEN venv: ASK user to approve
- appmanager-cli <1.1.1或venv损坏:询问用户是否批准
rm -rf ~/.aliyun/appmanager-venv
(auto-recreates on next aliyun
rm -rf ~/.aliyun/appmanager-venvrm -rf ~/.aliyun/appmanager-venv
(下次运行aliyun
rm -rf ~/.aliyun/appmanager-venvappmanager run).
appmanager时会自动重新创建)。
⚠️ This path is fixed at ~/.aliyun/appmanager-venv (the venv is self-managed
⚠️ 此路径固定为~/.aliyun/appmanager-venv(venv由aliyun CLI自行管理)。
by the aliyun CLI). After deletion, the next aliyun appmanager
run
aliyun appmanager删除后,下次运行aliyun appmanager
会自动重新创建它。Agent必须使用此确切的字面路径——
aliyun appmanagerauto-recreates it. The Agent MUST use this exact literal path —
绝不要用变量替换或通过拼接构建,以避免意外删除用户数据。
NEVER replace it with a variable or build it via concatenation,
- 凭证缺失/无效:向用户展示优先使用OAuth的修复方案
to avoid accidentally wiping user data.
(OAuth/RAM角色/环境变量/aliyun configure
交互式)——绝不要
aliyun configure- credentials missing/invalid: present OAuth-first remediation
在聊天中收集AK/SK。请参阅任务2 + references/init-and-credentials.md。
to the user (OAuth / RAM Role / env vars / aliyun configure
interactive) — NEVER
aliyun configure→ 如果用户拒绝任何修复:以该拒绝为理由停止——不得
collect AK/SK in chat. See Task 2 + references/init-and-credentials.md.
在损坏的环境中继续(部署无论如何都会失败)。
→ If user refuses any fix: stop with that refusal as the reason — DO NOT
→ 如果脚本文件未找到:仅在此情况下回退到手动检查(任务1 + 任务2)
continue with a broken environment (deployment will fail anyway).
2. 获取项目源代码(如有需要)
→ If script file not found: ONLY THEN fall back to manual checks (Task 1 + Task 2)
→ 如果提供了Git URL:克隆到当前工作目录,进入克隆目录
2. Obtain project source (if needed)
git clone <URL> && cd <cloned_dir>
→ If git URL provided: clone to CURRENT WORKING DIRECTORY, cd into cloned dir
→ 如果是本地路径/当前目录:跳过此步骤,直接使用
git clone <URL> && cd <cloned_dir>
🔀 重复部署快捷方式——步骤3之前检查
→ If local path / current directory: skip this step, use directly
→ 检查项目目录中是否已存在.appmanager/config.yaml
🔀 REPEAT DEPLOYMENT SHORTCUT — check BEFORE step 3
→ 如果存在(config.yaml已存在):
→ Check if .appmanager/config.yaml already exists in the project directory
读取文件并检查common.deployment.instanceId:
→ If YES (config.yaml exists):
- instanceId不存在(新ECS):跳过步骤3-5,跳至步骤5.5(价格检查)
Read the file and check for common.deployment.instanceId:
- instanceId存在(现有ECS):跳过步骤3-5.5,跳至步骤6(部署)
- instanceId ABSENT (new ECS): skip steps 3-5, jump to step 5.5 (price check)
两种情况都要告知用户:“检测到现有.appmanager/config.yaml;将重用现有配置并直接部署。”
- instanceId PRESENT (existing ECS): skip steps 3-5.5, jump to step 6 (deploy)
→ 如果不存在(config.yaml不存在):正常从步骤3开始
In both cases, inform user: "Existing .appmanager/config.yaml detected; will reuse the existing config and deploy directly."
3. 读取项目 + 识别类型(agent或app)
→ If NO (config.yaml does NOT exist): proceed normally from step 3
→ 首先读取README.md——部署方法的最高优先级来源:
3. Read project + identify type (agent or app)
- Agent必须向用户列出README中的方法并按优先级选择:
→ READ README.md FIRST — highest priority source for deployment method:
原生CLI安装 > 原生构建+运行 > 脚本部署 > Docker
- Agent MUST list README's methods to user and select by priority:
- ❌ 绝不要忽略README方法而扫描项目文件
Native CLI install > Native build+run > Script deploy > Docker
- ❌ 绝不要在有原生方法可用时优先选择Docker
- ❌ NEVER ignore README methods and scan project files instead
- Docker:仅当无原生方法时使用,必须向用户警告中国镜像风险
- ❌ NEVER prefer Docker when native methods are available
- 仅当README不存在/为空/无部署信息时,Agent才独立扫描项目文件
- Docker: ONLY when no native method exists, MUST warn user about China mirror risks
→ 仅当项目依赖agentscope
时才归类为“agent”;其他所有情况均为“app”
agentscope- Only if README absent/empty/no deploy info → Agent scans project files independently
→ 从目录名称确定--name,从项目配置/README确定--port
→ Only classify as "agent" if project depends on agentscope
; everything else is "app"
agentscope→ 对于Docker:检查中国地区的镜像可访问性(请参阅references/script-templates.md)
→ Determine --name from directory name, --port from project config/README
4. 向用户询问部署区域 + ECS目标(强制要求——在一个问题中同时询问)
→ For Docker: check image accessibility from China (see references/script-templates.md)
→ 问题1:“您想部署到哪个区域?上海(cn-shanghai)/杭州(cn-hangzhou)/北京(cn-beijing)/深圳(cn-shenzhen)/广州(cn-guangzhou)...”
4. Ask user for deployment region + ECS target (MANDATORY — ask together in one question)
→ 问题2:“新ECS还是现有ECS?”——如果是现有ECS,用户必须提供实例ID,例如i-bp1xxxxxxxx
→ Question 1: "Which region do you want to deploy to? Shanghai(cn-shanghai)/Hangzhou(cn-hangzhou)/Beijing(cn-beijing)/Shenzhen(cn-shenzhen)/Guangzhou(cn-guangzhou)..."
→ 绝不要使用“华东1”/“华北2”等基于可用区的标签——始终使用城市名称
→ Question 2: "New ECS or existing ECS?" — for existing, the user must provide the instance ID, e.g. i-bp1xxxxxxxx
→ 绝不要跳过ECS选择并默认创建新ECS
→ NEVER use zone-based labels like "East China 1" / "North China 2" — always use city names
→ ⚠️ 区域必须原样传递给:appmanager init --region、config.yaml的common.deployment.regionId,以及每个deploy_toolkit.py的--region。不匹配会触发OOS API返回InvalidParameter: DeployRegionId错误。
→ NEVER skip the ECS choice and default to creating new
5. 初始化 + 生成脚本(appmanager init → 将启动/停止脚本写入config.yaml)
→ ⚠️ Region MUST be propagated verbatim to: appmanager init --region, config.yaml common.deployment.regionId, AND every deploy_toolkit.py --region. Mismatch → InvalidParameter: DeployRegionId from OOS API.
→ 如果当前项目目录中已存在.appmanager/,请在删除前询问用户。
5. Init + generate scripts (appmanager init → write start/stop to config.yaml)
⚠️ 破坏性操作:rm -rf .appmanager
会删除现有部署配置。
rm -rf .appmanager→ If .appmanager/ already exists in the CURRENT project directory, ask user before removing.
删除前的必要防护:
⚠️ DESTRUCTIVE: rm -rf .appmanager
deletes the existing deployment config.
rm -rf .appmanagera. 确认当前工作目录与预期项目目录匹配(pwd
显示预期路径)
pwdRequired guard before deletion:
b. 确认目标是相对路径.appmanager
(绝不要绝对路径,绝不要使用变量)
.appmanagera. Confirm CWD matches the intended project directory (pwd
shows expected path)
pwdc. 告知用户“即将删除./.appmanager/下的现有部署配置。此操作不可逆。”并获得同意
b. Confirm target is the relative path .appmanager
(NEVER absolute, NEVER with variables)
.appmanager推荐更安全的替代方案:先备份
c. Inform the user "About to delete the existing deployment config under ./.appmanager/. This is irreversible." and obtain consent
mv .appmanager .appmanager.bak.$(date +%Y%m%d%H%M%S)
Recommended safer alternative: back up first
仅在获得用户明确同意后:rm -rf ./.appmanager
mv .appmanager .appmanager.bak.$(date +%Y%m%d%H%M%S)
→ 运行:aliyun appmanager init --non-interactive --name <DIR_NAME> --type <app|agent> --region <REGION> [--port <PORT>] [--ecs existing --instance-id <ID>] [--model qwen3.6-plus --api-key "$API_KEY"]
Only after explicit user consent: rm -rf ./.appmanager
(按类型划分的完整标志组合请参阅references/init-and-credentials.md)
→ Run: aliyun appmanager init --non-interactive --name <DIR_NAME> --type <app|agent> --region <REGION> [--port <PORT>] [--ecs existing --instance-id <ID>] [--model qwen3.6-plus --api-key "$API_KEY"]
→ 然后生成启动/停止脚本并写入config.yaml:
(See references/init-and-credentials.md for full flag combinations by type)
- 必须写入common.scripts.start和common.scripts.stop(绝不要放在顶级scripts键下)
→ Then generate start/stop scripts and write to config.yaml:
- 使用python3 yaml库:config['common']['scripts'] = {'start': ..., 'stop': ...}
- MUST write to common.scripts.start and common.scripts.stop (NEVER top-level scripts key)
- 优先级:README部署命令→直接使用;仅当README无相关内容时自动生成
- Use python3 yaml library: config['common']['scripts'] = {'start': ..., 'stop': ...}
- ⛔ 强制要求:启动脚本必须始终包含解压zip的步骤(mkdir + unzip + cd),
- PRIORITY: README deployment commands → use directly; only auto-generate when README has none
在任何构建/运行命令之前。appmanager会上传zip但不会解压。
- ⛔ MANDATORY: Start script MUST ALWAYS include zip extraction (mkdir + unzip + cd) BEFORE
5.5. 部署前价格检查 + 风险提示(必须运行deploy_toolkit.py price——Agent处理用户确认)
any build/run commands. appmanager uploads zip but does NOT extract it.
—
5.5. Pre-deploy price check + risk warning (MUST run deploy_toolkit.py price — Agent handles user confirmation)
—
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" price --config .appmanager/config.yaml
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" price --config .appmanager/config.yaml
→ Script output structure:
→ 脚本输出结构:
[Price table] estimate from appmanager price
(order-billed resources: ECS/EIP/bandwidth) + the trailing 📦 OSS extra-billing reminder
appmanager price[价格表] 来自appmanager price
的估算(按订单计费的资源:ECS/EIP/带宽)+ 末尾的📦 OSS额外计费提醒
appmanager price[Risk warning] only when detected: [Existing-ECS deployment risk] / [Group overwrite risk] / [Failure-leftover group]
[风险警告] 仅在检测到时显示:[现有ECS部署风险]/[组覆盖风险]/[失败残留组]
→ Script does NOT ask user for confirmation — that's the Agent's job
→ 脚本不会询问用户确认——这是Agent的工作
→ If exit 0: Agent MUST read the output, present the COMPLETE breakdown to user — including:
→ 如果退出码0:Agent必须读取输出,向用户展示完整的明细——包括:
1) Price estimate + OSS extra-billing reminder (OSS storage ~CNY 0.12/GB/month, public outbound ~CNY 0.50/GB only when cross-region, requests billed per 10k)
1) 价格估算 + OSS额外计费提醒(OSS存储约0.12元/GB/月,跨区域公网流出约0.50元/GB,请求按每10k次计费)
2) If output contains [Existing-ECS deployment risk] -> ask whether to deploy onto that existing ECS (may impact other apps on it)
2) 如果输出包含[现有ECS部署风险]→询问是否要部署到该现有ECS(可能影响其上的其他应用)
3) If output contains [Group overwrite risk] -> ask user to choose A (overwrite) or B (new group)
3) 如果输出包含[组覆盖风险]→询问用户选择A(覆盖)或B(新组)
Example: "Estimated cost: compute resources CNY X.XXX/hour (~CNY XXX.XX/month); public traffic billed by usage at CNY 0.80/GB;
示例:“估算费用:计算资源X.XXX元/小时(约XXX.XX元/月);公网流量按使用量计费,0.80元/GB;
the deployment also incurs minor OSS storage and request fees (intra-region pull is free of public outbound charges).
部署还会产生少量OSS存储和请求费用(同区域拉取免公网流出费用)。
Confirm to continue?"
确认继续?”
→ After ALL items confirmed by user: run the matching deploy command per item 3's choice (default overwrite / --force-new-group for new group)
→ 用户确认所有项后:根据第3项的选择运行匹配的部署命令(默认覆盖/--force-new-group创建新组)
→ If ANY item refused: STOP deployment
→ 如果任何项被拒绝:停止部署
→ If exit 1: price query failed, show error to user, do NOT proceed
→ 如果退出码1:价格查询失败,向用户显示错误,不得继续
6. Deploy (MUST use deploy_toolkit.py deploy — DO NOT run deploy manually)
6. 部署(必须使用deploy_toolkit.py deploy——不得手动运行deploy)
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" deploy
--type <agent|app> --name <APP_NAME> --group <GROUP_NAME> --region <REGION_ID>
--type <agent|app> --name <APP_NAME> --group <GROUP_NAME> --region <REGION_ID>
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" deploy
--type <agent|app> --name <APP_NAME> --group <GROUP_NAME> --region <REGION_ID>
--type <agent|app> --name <APP_NAME> --group <GROUP_NAME> --region <REGION_ID>
⛔ FORBIDDEN: running aliyun appmanager deploy
directly without this script
aliyun appmanager deploy⛔ 禁止:不使用此脚本直接运行aliyun appmanager deploy
aliyun appmanager deploy→ Handles: group status check → conflict auto-resolve → deploy
→ 处理:组状态检查→冲突自动解决→部署
→ Exit 0: deploy submitted, proceed to step 7
→ 退出码0:部署已提交,继续步骤7
→ Exit 1: ⛔ MUST run step 7 (verify) IMMEDIATELY to fetch /root/app.log;
→ 退出码1:⛔ 必须立即运行步骤7(验证)获取/root/app.log;
skipping to step 8, outputting partial results, or running manual
跳过步骤8、输出部分结果或运行手动命令替代是禁止的。然后根据日志修复脚本并重新部署
commands instead is FORBIDDEN. Then fix script per log and redeploy
(最多3次尝试)。
(max 3 attempts).
7. 验证(必须使用deploy_toolkit.py verify——不得手动检查状态)
7. Verify (MUST use deploy_toolkit.py verify — DO NOT check status manually)
—
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" verify
--type <agent|app> --name <APP_NAME> --group <GROUP_NAME> --region <REGION_ID>
--type <agent|app> --name <APP_NAME> --group <GROUP_NAME> --region <REGION_ID>
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" verify
--type <agent|app> --name <APP_NAME> --group <GROUP_NAME> --region <REGION_ID>
--type <agent|app> --name <APP_NAME> --group <GROUP_NAME> --region <REGION_ID>
⛔ FORBIDDEN: running aliyun appmanager status
+ manual log analysis instead of this script
aliyun appmanager status⛔ 禁止:运行aliyun appmanager status
+手动日志分析替代此脚本
aliyun appmanager status