cypress-cloud-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Cypress Cloud CLI

Cypress Cloud CLI

Use
cy-cloud
directly to investigate Cypress Cloud. Execute the commands, inspect their JSON, and report conclusions supported by the returned data. Do not send the user to the Cloud UI when the CLI can answer the question.
直接使用
cy-cloud
来调查Cypress Cloud。执行命令、检查其JSON输出,并根据返回的数据得出结论。当CLI可以回答问题时,不要引导用户前往Cloud UI。

Start safely

安全启动

The published binary requires Node.js 22.21.0 or newer.
Run these checks only on first use, when the environment is unknown, or after an installation or authentication error. If
cy-cloud
already worked in this session, invoke the investigation command directly instead of spending another turn rechecking the setup.
bash
node --version
cy-cloud status
cy-cloud --help
Assume
cy-cloud
is already installed and available on
PATH
. Run it from the user's current workspace; do not locate, clone, build, or depend on the cloud-cli source repository. If the command is unavailable, stop and report the missing prerequisite. The user can install it with:
bash
npm install -g @cypress/cloud
If unauthenticated, ask the user to choose an authentication method:
bash
cy-cloud login                 # interactive OAuth
cy-cloud login --token "$PAT"  # persist a Personal Access Token
For CI or an existing environment,
CYPRESS_CLOUD_TOKEN
takes precedence over stored credentials and writes no credential file.
Never print, echo, read back, or commit tokens. Never inspect
~/.config/cy-cloud/auth.json
or
cypress.env.json
; use
cy-cloud status
.
The organization must have the Cypress Cloud CLI integration enabled. A response saying it is not enabled requires action from an organization administrator; it cannot be fixed with another CLI command.
已发布的二进制文件要求Node.js 22.21.0或更高版本。
仅在首次使用、环境未知或安装/认证出错时运行这些检查。如果当前会话中
cy-cloud
已正常工作,请直接调用调查命令,不要再次检查设置。
bash
node --version
cy-cloud status
cy-cloud --help
假设
cy-cloud
已安装并在
PATH
中可用。从用户当前工作区运行它;不要查找、克隆、构建或依赖cloud-cli源代码仓库。如果命令不可用,请停止并报告缺失的前置条件。用户可以通过以下命令安装:
bash
npm install -g @cypress/cloud
如果未认证,请让用户选择认证方式:
bash
cy-cloud login                 # 交互式OAuth
cy-cloud login --token "$PAT"  # 持久化个人访问令牌
对于CI或现有环境,
CYPRESS_CLOUD_TOKEN
优先级高于存储的凭据,且不会写入凭据文件。
切勿打印、回显、读取或提交令牌。切勿检查
~/.config/cy-cloud/auth.json
或
cypress.env.json
;请使用
cy-cloud status
。
组织必须启用Cypress Cloud CLI集成。如果返回未启用的响应,则需要组织管理员采取行动;无法通过其他CLI命令修复。

Discover instead of guessing

主动探索而非猜测

Every command supports:
bash
cy-cloud --help
cy-cloud <command> --help
cy-cloud <command> --schema
Treat
cy-cloud --help
as authoritative for available commands, per-command
--help
as authoritative for arguments, and
--schema
as the intended response contract. Use them before constructing a query when a command, flag, or field is uncertain. Do not memorize a command inventory from this skill; the installed CLI may be newer or older than these instructions. Validate the actual response too:
run get
can return a fractional
duration
, and
replay info.failedAt
can be a fractional epoch even when the schema declares an integer. Treat those values as numbers and report the schema mismatch if it matters; do not discard or round the data.
Successful data commands write JSON to stdout. Parse that JSON directly; do not install a JSON tool to run this skill. Replay download progress is written to stderr, so never combine stderr with stdout before parsing JSON:
bash
cy-cloud replay timeline --testId <uuid> --attempt <failedAttemptNumber> 2>/dev/null
If a command fails, rerun without suppressing stderr. Argument-validation errors can appear on stdout; command execution errors appear on stderr. Both exit with status 1.
Cloud-backed fetches may be blocked by security sandboxes even when local commands such as
status
succeed. Run Cloud data commands with network access allowed. If a fetch fails with a sandbox or network denial, retry that same command with broader network permission before diagnosing a CLI, authentication, or Cloud problem.
Replay downloads are cached on disk. Confirm the location with
cy-cloud cache info
(
.location
) and run Cloud commands so that directory can be written and still exists later in this session. An ephemeral sandbox that cannot persist it will re-download replay data or fail cache validation, including on otherwise local commands. Do not relocate the cache into the user's project.
Cloud API calls are rate limited per user. Prefer considered, methodical requests: reuse identifiers already in a URL or prior response, skip org and project discovery when an ID is known, and do not page further than the question requires. After the first replay download for a test,
replay info
and
replay timeline
run against the local cache and do not count against that limit, so those follow-up queries can be chatty. If a command reports an exceeded rate limit, stop issuing Cloud-backed requests and report the limit; do not retry in a tight loop.
每个命令都支持:
bash
cy-cloud --help
cy-cloud <command> --help
cy-cloud <command> --schema
将
cy-cloud --help
视为可用命令的权威来源,将每个命令的
--help
视为参数的权威来源,将
--schema
视为预期响应契约。当对命令、标志或字段不确定时,在构造查询前先使用这些命令。不要依赖本技能中的命令清单;已安装的CLI可能比本说明更新或更旧。同时也要验证实际响应:
run get
可能返回小数形式的
duration
,即使架构声明为整数,
replay info.failedAt
也可能是小数时间戳。将这些值视为数字,如果架构不匹配影响结果则报告该问题;不要丢弃或四舍五入数据。
成功的数据命令会将JSON写入标准输出。直接解析该JSON;无需安装JSON工具来运行本技能。Replay下载进度会写入标准错误,因此在解析JSON前切勿合并标准错误与标准输出:
bash
cy-cloud replay timeline --testId <uuid> --attempt <failedAttemptNumber> 2>/dev/null
如果命令失败,请重新运行且不抑制标准错误。参数验证错误可能出现在标准输出;命令执行错误出现在标准错误。两者都会以状态码1退出。
即使本地命令(如
status
)成功,安全沙箱也可能阻止基于Cloud的获取操作。运行允许网络访问的Cloud数据命令。如果获取操作因沙箱或网络拒绝而失败,请在诊断CLI、认证或Cloud问题前,使用更广泛的网络权限重试同一命令。
Replay下载会缓存到磁盘。使用
cy-cloud cache info
确认位置(
.location
),并运行Cloud命令以确保该目录可写入且在本次会话后期仍存在。无法持久化缓存的临时沙箱会重新下载Replay数据或缓存验证失败,即使是本地命令也会如此。不要将缓存迁移到用户的项目中。
Cloud API调用按用户限制速率。优先考虑深思熟虑、有条理的请求:重用URL或先前响应中已有的标识符,当已知ID时跳过组织和项目发现,不要超出问题所需的分页范围。在首次下载测试的Replay后,
replay info
和
replay timeline
会针对本地缓存运行,不计入速率限制,因此这些后续查询可以更频繁。如果命令报告速率限制超出,请停止发出基于Cloud的请求并报告限制;不要在循环中重试。

Identifiers and pagination

标识符与分页

For
projectId
, use the project identifier already present in a Cloud URL; both the short slug and the project UUID are accepted by project/run lookups and run-scoped spec/test lists. Do not perform organization and project discovery merely to replace a UUID with a slug.
runNumber
is the per-project run number.
specId
and
testId
are UUIDs. Attempt numbers are 1-indexed, matching Cypress Cloud.
Cloud list responses have
.pagination
; request more pages when the question is not limited to the first page.
对于
projectId
,使用Cloud URL中已有的项目标识符;短别名和项目UUID都可用于项目/运行查询以及运行范围内的测试用例/测试列表。不要仅仅为了将UUID替换为别名而执行组织和项目发现。
runNumber
是每个项目的运行编号。
specId
和
testId
是UUID。尝试编号从1开始,与Cypress Cloud一致。
Cloud列表响应包含
.pagination
;当问题不限于第一页时,请求更多页面。

Route by task

按任务路由

Read only the references required for the current task:
  • Find orgs, projects, runs, specs, or tests, or open a Cloud URL: read investigation.md.
  • Inspect attempts, flakes, or failure screenshots: read investigation.md.
  • Query Test Replay: read investigation.md and test-replay.md.
  • Diagnose why a recorded test failed: read investigation.md, test-replay.md, and diagnosis.md.
仅阅读当前任务所需的参考资料:
  • 查找组织、项目、运行记录、测试用例或测试,或打开Cloud URL: 阅读investigation.md。
  • 检查尝试记录、不稳定测试或失败截图: 阅读investigation.md。
  • 查询Test Replay: 阅读investigation.md和test-replay.md。
  • 诊断录制测试失败的原因: 阅读investigation.md、test-replay.md和diagnosis.md。

Cache and common recovery

缓存与常见恢复方法

bash
cy-cloud cache info
cy-cloud cache cleanup
cy-cloud cache clear
Use
cache cleanup
for normal maintenance. Use
cache clear
only when replay resolution appears stale or corrupted because it forces future replay downloads. If replay re-downloads every command, the cache directory is not persisting; retry with a sandbox that can write to the location reported by
cache info
.
Common outcomes:
  • Missing expected fields: inspect that command's
    --schema
    .
  • JSON parse failure: ensure stderr was not merged into stdout.
  • Cache validation or write errors from the sandbox: retry so the cache directory is writable and persistent; do not copy the cache into the project.
  • cy-cloud version
    reporting
    "status": "Unknown"
    does not by itself mean the installation is broken or outdated. Compare
    version
    and
    latestVersion
    ; upgrade only when those values or an explicit compatibility error indicate it.
  • Exceeded rate limit: stop Cloud-backed requests and report the limit; do not retry in a loop. Cached replay queries are exempt once the download has succeeded.
  • Replay-specific errors: read test-replay.md.
bash
cy-cloud cache info
cy-cloud cache cleanup
cy-cloud cache clear
使用
cache cleanup
进行常规维护。仅当Replay解析结果看起来过时或损坏时才使用
cache clear
,因为它会强制未来重新下载Replay数据。如果每次命令都重新下载Replay,则缓存目录未被持久化;请使用可写入
cache info
报告位置的沙箱重试。
常见问题及处理:
  • 缺少预期字段:检查该命令的
    --schema
    。
  • JSON解析失败:确保未将标准错误合并到标准输出中。
  • 沙箱导致的缓存验证或写入错误:重试以确保缓存目录可写入且持久;不要将缓存复制到项目中。
  • cy-cloud version
    报告
    "status": "Unknown"
    本身并不意味着安装损坏或过时。比较
    version
    和
    latestVersion
    ;仅当这些值或明确的兼容性错误表明需要升级时才进行升级。
  • 超出速率限制:停止基于Cloud的请求并报告限制;不要在循环中重试。缓存的Replay查询在下载成功后不受限制。
  • Replay特定错误:阅读test-replay.md。