SuperAPI AI Directory

hap-cli-environments

Deployment & operations

View repository

Updated 10-16 06:48

About this skill

HAP Multi-Environment / Multi-Account Operating Rules

The user may have authorized multiple HAP environments and accounts at the same time, each already logged in and saved, each with a name (see hap auth accounts). "Which environment to execute in and which account to use" is as important as the command itself—choosing wrong may cause irreversible consequences in an environment that should not be touched.

Before each operation

  1. First check the current state:hap --json auth accounts, read out which one is currently in use (active), as well as each environment/account's name, login address, account, and organization.
  2. Match the user's wording to a certainenvironment/account: prioritize the name the user said; next, match by login address/platform (Mingdao SaaS, Nocoly, the private deployment domain given by the user) and account. If the match is not unique, go to "stop and ask".
  3. Switching: use hap auth use <名字>for the entire session; use hap --profile <名字> <命令>。

When you must stop and ask

  • The userhas not specified which environment/account to use, and the operation is destructive (deleting apps/worksheets/fields/records, publishing, changing role permissions, batch writing).
  • The user's words can match multiple environments/accounts, or none at all.

At this point, use a Q&A card to list the candidate environments/accounts for the user to choose,do not arbitrarily pick one to execute, and even more so do not default to the online/formal one.

During execution

  • Before running a command each time, point out in the echo "current environment / account / organization / login address" so the user can verify at a glance.
  • For destructive commands, add one more sentence confirming that the current one is not a mistakenly selected formal environment.

What should not be done

  • Do not log in or log out on behalf of the user (auth login / auth logout)—unless the user explicitly requests it.
  • Do not reuse one account's token across environments/accounts—always switch via auth use / --profile, and do not manually carry tokens over.

Command quick reference

hap auth accounts                 # 列出所有环境/账号,当前的带 *
hap --json auth accounts          # 同上,结构化输出供程序判断
hap auth use <名字>               # 切换当前使用的环境/账号
hap --profile <名字> <命令>       # 只让这一条命令临时用某个环境/账号
HAP_PROFILE=<名字> hap <命令>     # 整个终端会话默认用某个环境/账号
hap auth whoami                   # 确认当前用户 / 环境 / 组织

For specific command parameters, refer to hap auth <子命令> --help ; for operations such as logging in/logging out or creating apps, querying data, etc., go back to hap-cli and the dedicated skill it points to.