alibabacloud-ecs-code-deploy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Deploy to Alibaba Cloud ECS via aliyun appmanager

通过aliyun appmanager部署到阿里云ECS

Overview

概述

aliyun appmanager
is an Agent-friendly CLI tool for one-click deployment of applications (App) and AI Agents to Alibaba Cloud ECS. It supports non-interactive mode (
--non-interactive
), structured JSON output (
--output json
), and streaming NDJSON responses.
Default behavior: When user invokes
/alibabacloud-ecs-code-deploy
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
cd
into the cloned directory and proceed with deployment.
EXECUTION 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
是一款对Agent友好的CLI工具,可一键将应用程序(App)和AI Agent部署到阿里云ECS。它支持非交互模式(
--non-interactive
)、结构化JSON输出(
--output json
)以及流式NDJSON响应。
默认行为:当用户调用
/alibabacloud-ecs-code-deploy
但未指定项目路径或URL时,将当前工作目录的项目部署到阿里云ECS。如果用户提供了Git URL,则先将其克隆到当前目录,然后
cd
到克隆的目录中继续部署。
执行顺序: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
$SKILL_DIR/scripts/deploy_toolkit.py
(where
$SKILL_DIR
is 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
aliyun version
, 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.
❌ WRONG (Step 1): Run
aliyun version
→ check version → run
~/.aliyun/appmanager-venv/bin/python ...
→ check version → THEN run
deploy_toolkit.py check
✅ CORRECT (Step 1): Run
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" check
→ if exit 1, fix the issue it reports → if script file missing, THEN fall back to manual checks
Item 6 is NON-NEGOTIABLE. An Agent that skips log verification and directly outputs "deployment succeeded" has NOT completed this skill correctly. If
deploy_toolkit.py verify
exits 1 (failed), the Agent MUST fix the issue and re-deploy before proceeding to item 7.

在执行任何步骤之前,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
中有专用的工具包脚本(
$SKILL_DIR
在下方步骤0中解析——适用于Qoder、Claude Code及其他任何平台)。Agent必须直接运行相应的子命令作为该步骤的第一个且唯一的操作——绝不在脚本之前或替代脚本运行手动CLI命令(如
aliyun version
、版本检查、凭证检查)。脚本已在内部处理所有检查。仅当脚本文件本身不存在时,才允许使用手动命令作为备选方案。
❌ 错误示例(步骤1):运行
aliyun version
→ 检查版本 → 运行
~/.aliyun/appmanager-venv/bin/python ...
→ 检查版本 → 然后运行
deploy_toolkit.py check
✅ 正确示例(步骤1):运行
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" check
→ 如果退出码为1,修复其报告的问题 → 如果脚本文件缺失,再使用手动检查作为备选
第6项是不可协商的。跳过日志验证并直接输出“部署成功”的Agent未正确完成此技能。如果
deploy_toolkit.py verify
退出码为1(失败),Agent必须修复问题并重新部署,然后才能进行第7项。

Step 0 (MANDATORY): Resolve
$SKILL_DIR
— Cross-Platform Path

步骤0(强制要求):解析
$SKILL_DIR
——跨平台路径

The toolkit script lives at
<skill-root>/scripts/deploy_toolkit.py
. 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_DIR
appears below. Hardcoding any platform-specific path is FORBIDDEN.
See references/skill-dir-resolution.md for the full 10-candidate detection algorithm, the
export + test -f
verify snippet, and Pattern A / Pattern B / ⛔ Anti-pattern usage rules.
Quick recap (read the reference for details):
  • Pattern A (persistent shell):
    export SKILL_DIR="/abs/path"
    then later
    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:
    SKILL_DIR=/path python3 "$SKILL_DIR/..."
    — outer shell expands
    $SKILL_DIR
    BEFORE the prefix assignment, producing
    /scripts/deploy_toolkit.py
    and ENOENT. If you see
    python3: can't open file '/scripts/deploy_toolkit.py'
    , switch to Pattern A or B.

工具包脚本位于
<skill-root>/scripts/deploy_toolkit.py
。不同平台将技能安装到不同位置(Qoder/Claude Code/Qwen/...)。Agent必须在会话开始时一次性解析绝对技能根目录,并在所有出现
$SKILL_DIR
的地方重复使用它。禁止硬编码任何特定于平台的路径。
有关完整的10候选检测算法、
export + test -f
验证代码片段以及模式A/模式B/⛔反模式使用规则,请参阅references/skill-dir-resolution.md
快速回顾(详细内容请阅读参考文档):
  • 模式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>
  • 反模式
    SKILL_DIR=/path python3 "$SKILL_DIR/..."
    ——外部shell在前缀赋值之前展开
    $SKILL_DIR
    ,产生
    /scripts/deploy_toolkit.py
    并导致ENOENT错误。如果看到
    python3: can't open file '/scripts/deploy_toolkit.py'
    ,请切换到模式A或B。

Task 1: Install Alibaba Cloud CLI

任务1:安装阿里云CLI

Primary action: Run
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" check
— 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.
MUST — Handling unmet environment prerequisites: When
check
exits 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:
  1. CLI NOT installedAuto-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
    deploy_toolkit.py check
    to confirm.
  2. CLI already installedASK 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
      deploy_toolkit.py check
      to confirm.
    • On refusal — stop with the refusal as the reason. Do NOT continue with the older version (deployment will fail anyway).
The toolkit's
check
output already includes an
→ AGENT: DO NOT stop. ASK user ...
line for each fixable issue — follow it verbatim (except for the "not installed" case, which is auto-handled).
MUST — Upgrade method priority (avoid the "repeated upgrade" pitfall:
/usr/local/bin/
is often shadowed by earlier PATH entries like
/opt/homebrew/bin
):
  1. brew-managed (
    check
    prints "managed by Homebrew") ->
    brew upgrade aliyun-cli
    ; do NOT overwrite
    /usr/local/bin/
    again.
  2. sudo available -> overwrite into
    /usr/local/bin/
    , then verify:
    hash -r && which -a aliyun && aliyun version
    .
  3. No sudo -> install to
    ~/bin/
    , ask user to approve appending
    export PATH="$HOME/bin:$PATH"
    to
    ~/.zshrc
    /
    ~/.bashrc
    .
After install/upgrade, ALWAYS rerun
deploy_toolkit.py check
to confirm. If
which -a aliyun
still shows the old binary first, fix PATH order — DO NOT repeat the same overwrite.
主要操作:运行
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" check
——它会一次性检查CLI版本+appmanager-cli版本+凭证。仅当脚本文件缺失时,才使用references/init-and-credentials.md中的备选方案。
必须——处理未满足的环境先决条件:当
check
退出码为1,原因是aliyun CLI缺失或版本低于3.3.19(或appmanager-cli缺失/过时)时,Agent不得静默停止工作流。所需流程为:
  1. CLI未安装直接自动安装,无需询问用户——执行安装命令(请参阅下方代码片段或references/init-and-credentials.md获取对应架构的命令),然后重新运行
    deploy_toolkit.py check
    确认。
  2. 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 ...
行——请严格按照该行内容执行(“未安装”情况除外,该情况会自动处理)。
必须——升级方法优先级(避免“重复升级”陷阱:
/usr/local/bin/
通常被更早的PATH条目如
/opt/homebrew/bin
覆盖):
  1. brew管理(
    check
    输出“managed by Homebrew”)→
    brew upgrade aliyun-cli
    ;不得再次覆盖
    /usr/local/bin/
  2. 有sudo权限→覆盖安装到
    /usr/local/bin/
    ,然后验证:
    hash -r && which -a aliyun && aliyun version
  3. 无sudo权限→安装到
    ~/bin/
    ,请求用户批准将
    export PATH="$HOME/bin:$PATH"
    追加到
    ~/.zshrc
    /
    ~/.bashrc
安装/升级后,始终重新运行
deploy_toolkit.py check
确认。如果
which -a aliyun
仍显示旧二进制文件优先,请修复PATH顺序——不得重复相同的覆盖操作。

AI-Mode Configuration (MANDATORY after CLI install)

AI模式配置(安装CLI后强制要求)

⛔ MUST configure AI-Mode: Agent MUST ensure AI-Mode is properly configured before running any
aliyun appmanager
commands.
deploy_toolkit.py check
handles this internally; the commands below are for manual fallback only.
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必须确保在运行任何
aliyun appmanager
命令之前正确配置AI模式。
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
already validates credentials. Only if credentials are missing/invalid, see references/init-and-credentials.md for the default-credential-chain remediation flow.
⛔ 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:
bash
aliyun configure --mode OAuth --profile oauth
This is an interactive command that will:
  1. Open a browser with an authorization link — user clicks to authorize
  2. Prompt for region (e.g.
    cn-hangzhou
    ,
    cn-beijing
    ) — user enters their preferred region
  3. Prompt for language (e.g.
    zh
    ) — user enters their preferred language
After 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
~/.aliyun/config.json
). 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 sts get-caller-identity
. Full remediation flow → references/init-and-credentials.md.
CRITICAL PROHIBITION: NEVER run standalone
appmanager
or
aliyun appmanager login
.

deploy_toolkit.py check
已验证凭证。仅当凭证缺失/无效时,请参阅references/init-and-credentials.md获取默认凭证链修复流程。
⛔ 优先选择OAuth而非AK:此技能应引导用户使用OAuth认证作为提供阿里云权限的主要方法。OAuth比AccessKey更安全、更便捷(无需长期存储密钥)。Agent必须在提及基于AK的方法之前,首先将OAuth作为第一个选项呈现。
OAuth登录指南:指导用户在终端中运行以下命令:
bash
aliyun configure --mode OAuth --profile oauth
这是一个交互式命令,将:
  1. 打开带有授权链接的浏览器——用户点击授权
  2. 提示输入区域(例如
    cn-hangzhou
    cn-beijing
    )——用户输入偏好的区域
  3. 提示输入语言(例如
    zh
    )——用户输入偏好的语言
OAuth设置完成后,使用以下命令验证:
aliyun sts get-caller-identity --profile oauth
⛔ SA-2.12 — 不得显式处理AK/SK:此技能必须依赖aliyun CLI/SDK的默认凭证链(OAuth/ECS RAM角色/环境变量/预先存在的
~/.aliyun/config.json
)。Agent绝不要求用户将AccessKey/Secret/STS-Token值粘贴到聊天中,绝不将原始AK/SK放入工具调用参数或脚本中,绝不回显凭证值。当凭证缺失时,指导用户在外部配置(自己的终端/shell配置文件/RAM角色),仅通过
aliyun sts get-caller-identity
重新验证。完整修复流程→references/init-and-credentials.md
严格禁止:绝不要运行独立的
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
README.md
(or
README
) in the project root. This is ALWAYS the first action in Task 3.
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
(或
README
)。这始终是任务3中的第一个操作。
从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:
PriorityMethod TypeAction
1 (HIGHEST)Native CLI / package manager install (
npm install -g
,
pip install
,
go install
)
Use directly
2Native build + run (
pip install && python main.py
,
npm install && npm start
)
Use, install runtime
3Script-based deploy (
bash deploy.sh
)
Must confirm non-interactive
4 (LOWEST)Docker / docker-composeOnly 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/包管理器安装
npm install -g
pip install
go install
直接使用
2原生构建+运行
pip install && python main.py
npm install && npm start
使用,安装运行时
3基于脚本的部署
bash deploy.sh
必须确认非交互性
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:确定项目类型

ConditionType
Project depends on
agentscope
agent
Everything else (langchain, mcp, autogen, web services, tools, etc.)
app
条件类型
项目依赖
agentscope
agent
其他所有情况(langchain、mcp、autogen、Web服务、工具等)
app

Determine
--name

确定
--name

Use 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
和ECS目标(必须询问用户)

Agent 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
appmanager init --region
, written into
config.yaml
common.deployment.regionId
, AND attached as
--region <REGION_ID>
to every subsequent
deploy_toolkit.py {price,deploy,verify}
invocation. Mismatch / omission triggers
InvalidParameter: DeployRegionId is invalid
from the OOS API.
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>
附加到后续每个
deploy_toolkit.py {price,deploy,verify}
调用中。不匹配/遗漏会触发OOS API返回
InvalidParameter: DeployRegionId is invalid
错误。

Determine
--port
(App type only, OPTIONAL)

确定
--port
(仅App类型可选)

Only specify when the project actually listens on HTTP. Skip for background services (bots, workers, CLI tools). If needed but unknown, default to
8080
. Agent type does NOT use
--port
.
仅当项目实际监听HTTP时指定。后台服务(机器人、工作进程、CLI工具)可跳过。如果需要但未知,默认使用
8080
。Agent类型不使用
--port

Non-interactive init

非交互式初始化

See references/init-and-credentials.md for all init flag combinations.
Creates
.appmanager/config.yaml
. Does NOT support
--overwrite
— delete
.appmanager/
first if exists.

有关所有初始化标志组合,请参阅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.yaml

Workflow

工作流

  1. Read README.md FIRST — follow Task 3 decision tree
  2. If README has no deploy info — scan project structure (Language Detection below)
  3. Docker accessibility check — if Docker path selected (see references/script-templates.md)
  4. Generate start & stop scripts — following rules below. Start script MUST ALWAYS include zip extraction sequence.
  5. Write to config.yaml — under
    common.scripts.start
    and
    common.scripts.stop
    (NEVER top-level
    scripts
    )
  1. 首先读取README.md——遵循任务3的决策树
  2. 如果README无部署信息——扫描项目结构(下方语言检测)
  3. Docker可访问性检查——如果选择Docker路径(请参阅references/script-templates.md
  4. 生成启动和停止脚本——遵循以下规则。启动脚本必须始终包含解压zip的步骤。
  5. 写入config.yaml——位于
    common.scripts.start
    common.scripts.stop
    下(绝不要放在顶级
    scripts
    中)

Language Detection Rules

语言检测规则

Indicator FilesLanguage
package.json
/
*.js
/
*.ts
Node.js
requirements.txt
/
pyproject.toml
/
*.py
Python
pom.xml
/
build.gradle
/
*.java
Java
go.mod
/
*.go
Go
composer.json
/
*.php
PHP
docker-compose.yml
/
Dockerfile
Docker
指示文件语言
package.json
/
*.js
/
*.ts
Node.js
requirements.txt
/
pyproject.toml
/
*.py
Python
pom.xml
/
build.gradle
/
*.java
Java
go.mod
/
*.go
Go
composer.json
/
*.php
PHP
docker-compose.yml
/
Dockerfile
Docker

Files to Read (MUST read content, not just detect presence)

必须读取的文件(必须读取内容,而非仅检测存在性)

LanguageMust ReadWhy
Python
pyproject.toml
,
requirements.txt
Entry point, deps
Node.js
package.json
scripts.start
,
main
field
Java
pom.xml
or
build.gradle
JAR name
Go
go.mod
Module → binary name
PHP
composer.json
Framework detection
Docker
docker-compose.yml
/
Dockerfile
Services, ports
语言必须读取原因
Python
pyproject.toml
requirements.txt
入口点、依赖
Node.js
package.json
scripts.start
main
字段
Java
pom.xml
build.gradle
JAR名称
Go
go.mod
模块→二进制名称
PHP
composer.json
框架检测
Docker
docker-compose.yml
/
Dockerfile
服务、端口

Entry Point Detection Order

入口点检测顺序

  • Python:
    [project.scripts]
    in pyproject.toml →
    main.py
    app.py
    manage.py
  • Node.js:
    scripts.start
    main
    field →
    index.js
    server.js
  • Java:
    find ... -name "*.jar" | head -1
    java -jar
  • Go: Pre-compiled binary:
    find ... -type f -perm /111
  • PHP:
    composer install --no-dev
    php artisan serve
    or
    php -S
  • Docker Compose:
    docker compose up -d
    /
    docker compose down
  • Python
    pyproject.toml
    中的
    [project.scripts]
    main.py
    app.py
    manage.py
  • Node.js
    scripts.start
    main
    字段 →
    index.js
    server.js
  • Java
    find ... -name "*.jar" | head -1
    java -jar
  • Go:预编译二进制文件:
    find ... -type f -perm /111
  • PHP
    composer install --no-dev
    php artisan serve
    php -S
  • Docker Compose
    docker compose up -d
    /
    docker compose down

General Script Rules

通用脚本规则

RuleRequirement
⛔ MANDATORY zip extractStart script MUST: find zip →
mkdir -p
unzip -o
cd
. Without this, project dir DOES NOT EXIST on ECS
Runtime installMUST install language runtime FIRST (ECS is bare)
Install unzip
command -v unzip &>/dev/null || $PKG_MGR install -y unzip
IdempotentSafe to run multiple times
⛔ Log file FIXED pathMUST be
/root/app.log
and
/root/app.pid
. verify script hardcodes these paths
Log appendAlways
>>
(never
>
)
PID file
echo $! > /root/app.pid
after
nohup ... &
Background run
nohup ... >> /root/app.log 2>&1 &
Stop old process
[ -f /root/app.pid ] && kill "$(cat /root/app.pid)" 2>/dev/null || true
App dir
/root/{app_name}
No heredocNEVER use
<< 'EOF'
inside scripts — breaks YAML. Use
printf
or
python3 -c
MANDATORY tail logEnd with
sleep 3 && cat /root/app.log
for verification capture
⛔ Stop script: NO exitMUST NOT contain
exit
. Deploy system concatenates stop+start — exit kills the entire process
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→
mkdir -p
unzip -o
cd
。没有此步骤,ECS上的项目目录不存在
安装运行时必须首先安装语言运行时(ECS是裸机)
安装unzip`command -v unzip &>/dev/null
幂等性可安全多次运行
⛔ 日志文件固定路径必须为
/root/app.log
/root/app.pid
。验证脚本硬编码这些路径
日志追加始终使用
>>
(绝不使用
>
PID文件
nohup ... &
后执行
echo $! > /root/app.pid
后台运行
nohup ... >> /root/app.log 2>&1 &
停止旧进程`[ -f /root/app.pid ] && kill "$(cat /root/app.pid)" 2>/dev/null
应用目录
/root/{app_name}
不使用heredoc绝不要在脚本中使用
<< 'EOF'
——会破坏YAML。使用
printf
python3 -c
必须查看日志尾部
sleep 3 && cat /root/app.log
结尾用于验证捕获
⛔ 停止脚本:不要exit不得包含
exit
。部署系统会拼接停止+启动脚本——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
deploy_toolkit.py price
. 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 running
deploy
.
bash
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" price --config .appmanager/config.yaml
  • Exit 0 +
    === AGENT_CONFIRM_REQUIRED ===
    : present the complete price + risk warning to the user, confirm item by item.
  • 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
.

强制要求:部署前运行
deploy_toolkit.py price
。脚本输出价格估算(含OSS额外计费提醒),并在适用时输出风险警告块。Agent必须向用户展示所有标记项,并在运行
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 json
STOP after deploy success
status: success
only means orchestration completed. Agent MUST run Task 6 verification before outputting results.
aliyun appmanager <agent|app> deploy --overwrite --output json
部署成功后停止——
status: success
仅表示编排完成。Agent必须运行任务6的验证,然后再输出结果。

Handling deployment failure

处理部署失败

MANDATORY FAILURE GATE: After ANY deploy failure (exit 1, timeout, or
ReleaseCancelled
), the Agent MUST run
deploy_toolkit.py verify
IMMEDIATELY — BEFORE any fix attempt, fallback to manual commands, or partial output. Skipping verify after a failure is FORBIDDEN and counts as skill failure.
Semantics of
ReleaseCancelled
: it means the start script on ECS failed or timed out. It does NOT mean "someone cancelled the deploy". The only correct next action: run
deploy_toolkit.py verify
-> read the log -> fix the script -> redeploy.
Known failure patterns: Before ad-hoc troubleshooting, check references/lessons-learned.md for previously identified deployment failure patterns and proven fixes.
Failure-handling flow:
  1. Run
    deploy_toolkit.py verify
    to fetch
    /root/app.log
    (DO NOT skip).
  2. Analyze the log to locate root cause.
  3. Fix scripts and redeploy (max 3 attempts).
  4. After 3 failures, stop — report the error, but still output console link + cost reminder + delete command.

强制失败处理门:任何部署失败后(退出码1、超时或
ReleaseCancelled
),Agent必须立即运行
deploy_toolkit.py verify
——在任何修复尝试、切换到手动命令或输出部分结果之前。部署失败后跳过验证是禁止的,并视为技能失败。
ReleaseCancelled
的含义
:表示ECS上的启动脚本失败或超时。它表示“有人取消了部署”。唯一正确的下一步操作:运行
deploy_toolkit.py verify
→读取日志→修复脚本→重新部署。
已知失败模式:在进行临时故障排除之前,请查看references/lessons-learned.md中已识别的部署失败模式和已验证的修复方法。
失败处理流程:
  1. 运行
    deploy_toolkit.py verify
    获取
    /root/app.log
    (不得跳过)。
  2. 分析日志定位根本原因。
  3. 修复脚本并重新部署(最多3次尝试)。
  4. 3次失败后停止——报告错误,但仍需输出控制台链接+费用提醒+删除命令。

Task 6: Post-deploy Verification (BLOCKING)

任务6:部署后验证(阻塞)

status: Deployed
does NOT mean the application is running. The Agent MUST run verify and semantically analyze the log.
  1. Run
    deploy_toolkit.py verify
    (auto-reads parameters from config.yaml).
  2. Agent semantically analyzes the log to decide whether the application actually started successfully.
  3. Not running -> diagnose -> fix -> redeploy + verify (max 3 attempts).
  4. Only when running is confirmed / user manual action required / 3 attempts failed should the Agent output the final result.

status: Deployed
并不意味着应用正在运行。Agent必须运行验证并对日志进行语义分析。
  1. 运行
    deploy_toolkit.py verify
    (自动从config.yaml读取参数)。
  2. Agent对日志进行语义分析,判断应用是否实际启动成功。
  3. 未运行→诊断→修复→重新部署+验证(最多3次尝试)。
  4. 仅当确认应用正在运行/需要用户手动操作/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
Deployment self-check report
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.
📘 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" ...

→ 模式B(每次调用使用新shell):内联绝对路径——
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/..."
——外部shell会在

BEFORE the prefix assignment, producing
/scripts/deploy_toolkit.py
and ENOENT.

前缀赋值之前展开$SKILL_DIR,产生
/scripts/deploy_toolkit.py
并导致ENOENT错误。

1. 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 "..."

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-venv
(下次运行aliyun

appmanager 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
会自动重新创建它。Agent必须使用此确切的字面路径——

auto-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
交互式)——绝不要

- 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

→ 如果用户拒绝任何修复:以该拒绝为理由停止——不得

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”

- 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"

→ 对于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
会删除现有部署配置。

→ If .appmanager/ already exists in the CURRENT project directory, ask user before removing.

删除前的必要防护:

⚠️ DESTRUCTIVE:
rm -rf .appmanager
deletes the existing deployment config.

a. 确认当前工作目录与预期项目目录匹配(
pwd
显示预期路径)

Required guard before deletion:

b. 确认目标是相对路径
.appmanager
(绝不要绝对路径,绝不要使用变量)

a. Confirm CWD matches the intended project directory (
pwd
shows expected path)

c. 告知用户“即将删除./.appmanager/下的现有部署配置。此操作不可逆。”并获得同意

b. Confirm target is the relative path
.appmanager
(NEVER absolute, NEVER with variables)

推荐更安全的替代方案:先备份

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
的估算(按订单计费的资源:ECS/EIP/带宽)+ 末尾的📦 OSS额外计费提醒

[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>
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" deploy
--type <agent|app> --name <APP_NAME> --group <GROUP_NAME> --region <REGION_ID>

⛔ FORBIDDEN: running
aliyun appmanager deploy
directly without this script

⛔ 禁止:不使用此脚本直接运行
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>
python3 "$SKILL_DIR/scripts/deploy_toolkit.py" verify
--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
+手动日志分析替代此脚本

→ Optional: --wait <seconds> for slow-starting apps (default 3s, Java/heavy use 15-30)

→ 可选:--wait <秒数>用于启动缓慢的应用(默认3秒,Java/重型应用使用15-30秒)

→ Dual-path: Cloud Assistant cat /root/app.log (preferred) → deployCommandOutput (fallback)

→ 双路径:Cloud Assistant读取/root/app.log(首选)→ deployCommandOutput(备选)

→ Exit 0: app running, proceed to step 8

→ 退出码0:应用正在运行,继续步骤8

→ Exit 1: app failed — fix start script, re-deploy (back to step 6)

→ 退出码1:应用失败——修复启动脚本,重新部署(回到步骤6)

→ Exit 2: inconclusive — retry with longer --wait or suggest SSH check

→ 退出码2:结果不确定——使用更长的--wait重试或建议SSH检查

7.5. Self-check summary (⛔ BLOCKING — skill fails if omitted)

7.5. 自检摘要(⛔ 阻塞——省略则技能失败)

MUST print the exact template below to the user — this is a completion criterion, NOT optional.

必须向用户打印以下确切模板——这是完成标准,而非可选内容。

---

---

✅ Deployment self-check report:

✅ 部署自检报告:

0. Path resolution — SKILL_DIR=___ (script exists ✅)

0. 路径解析——SKILL_DIR=___(脚本存在 ✅)

1. Environment pre-check — CLI v___ / appmanager-cli v___ / credentials valid ✅

1. 环境预检查——CLI版本___ / appmanager-cli版本___ / 凭证有效 ✅

2. Project obtained — (local / cloned) ✅

2. 项目获取——(本地/克隆)✅

3. Project identified — type: ___ / deploy method source: README.md ✅

3. 项目识别——类型:___ / 部署方法来源:README.md ✅

4. Deployment region — user choice: ___ ✅

4. 部署区域——用户选择:___ ✅

5. Init + scripts — config.yaml generated; start script: ___ (key command summary) ✅

5. 初始化 + 脚本——config.yaml已生成;启动脚本:___(关键命令摘要)✅

5.5. Pre-deploy price check — user confirmed price (CNY ___/hour, ~CNY ___/month) ✅

5.5. 部署前价格检查——用户已确认价格(___元/小时,约___元/月)✅

6. Deploy executed — deploy_toolkit.py deploy exit 0 ✅

6. 部署执行——deploy_toolkit.py deploy退出码0 ✅

7. Run verification — deploy_toolkit.py verify exit 0 / log keywords: ___ ✅

7. 运行验证——deploy_toolkit.py verify退出码0 / 日志关键词:___ ✅

---

---

If any item is ❌, fix it BEFORE step 8 — this is for the USER to see, proving the work is properly done.

如果任何项为❌,请在步骤8之前修复——这是给用户看的,证明工作已正确完成。

8. Output results (MANDATORY: console link + cost reminder + management commands)

8. 输出结果(强制要求:控制台链接 + 费用提醒 + 管理命令)

→ See references/deploy-output-and-management.md for full output format

→ 完整输出格式请参阅references/deploy-output-and-management.md