mo-qa

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Run QA with Mo

使用Mo执行QA测试

Mo is Momentic's autonomous QA engineer. It runs in a hosted sandbox, where it can test web applications with a browser, inspect network traffic, run code and shell commands, delegate exploration, and report test cases and product bugs. Treat its filesystem and environment as remote, not as the user's machine.
Mo是Momentic的自主QA工程师。它运行在托管沙箱(sandbox)中,可通过浏览器测试Web应用、检查网络流量、运行代码和shell命令、委托探索任务,并报告测试用例和产品缺陷。请将其文件系统和环境视为远程环境,而非用户本地机器。

Install and authenticate

安装与身份验证

bash
curl -fsSL https://cli.momentic.ai/mo | sh   # installs to $HOME/.local/bin/mo
mo --version
Every command needs an API key. Set
MOMENTIC_API_KEY
in the environment; prefer this in CI. For an interactive login, use:
bash
npx @momentic/wizard@latest login
This writes
~/.momentic/auth.json
. Do not pass API keys as command arguments, print them, paste them into a session message, or commit them.
bash
curl -fsSL https://cli.momentic.ai/mo | sh   # installs to $HOME/.local/bin/mo
mo --version
每个命令都需要API密钥。在环境变量中设置
MOMENTIC_API_KEY
;在CI环境中推荐使用这种方式。如需交互式登录,请使用:
bash
npx @momentic/wizard@latest login
此命令会将登录信息写入
~/.momentic/auth.json
。请勿将API密钥作为命令参数传递、打印、粘贴到会话消息中或提交到代码仓库。

Write the QA brief first

先编写QA测试说明

Treat the brief as the whole input. A vague brief produces a vague bug bash. Mo's browser runs outside the developer machine, so the target must be reachable from the public internet: use a deployed environment or preview URL, never
localhost
.
State in the brief:
  1. Target URL: Include the exact path and query the change affects.
  2. Expected behavior: Explain what changed and what it should now do in product terms.
  3. Sign-in instructions: Name the login method and test account to use.
  4. Test data rules: State what Mo may create and what it must not touch.
  5. Out-of-bounds actions: Call out deletions, payments, emails, production data, bulk operations, and any other destructive action. Mo may take destructive actions if the brief invites them.
  6. Acceptance criteria: List the checks that decide pass or fail.
Ask the user for any missing item before starting Mo. Do not invent scope, credentials, test data permissions, or acceptance criteria.
请将测试说明作为完整输入内容。模糊的说明会导致模糊的漏洞排查结果。Mo的浏览器运行在开发者机器之外,因此测试目标必须能从公网访问:请使用已部署的环境或预览URL,切勿使用
localhost
测试说明中需包含:
  1. 目标URL:包含变更影响的精确路径和查询参数。
  2. 预期行为:从产品角度说明变更内容以及现在应实现的功能。
  3. 登录说明:指定登录方式和要使用的测试账号。
  4. 测试数据规则:说明Mo可以创建哪些数据,以及绝对不能触碰哪些数据。
  5. 禁止操作:明确标注删除、支付、发送邮件、操作生产数据、批量操作等任何破坏性操作。如果测试说明允许,Mo可能会执行这些破坏性操作。
  6. 验收标准:列出判定测试通过或失败的检查项。
在启动Mo之前,请向用户确认任何缺失的信息。请勿自行设定测试范围、凭据、测试数据权限或验收标准。

Run a session

启动会话

Write the brief before invoking the CLI, then pass it as one quoted argument:
bash
brief=$(cat <<'EOF'
Target URL: https://preview.example.com/checkout?variant=express
Expected behavior: Express checkout now keeps the selected shipping method when the customer returns from payment.
Sign-in: Use the staging QA buyer account already provisioned for Mo.
Test data: Create test carts and orders only. Do not modify shared catalog data.
Out of bounds: Do not submit payment, send emails, delete data, or run bulk operations.
Acceptance criteria:
- The selected shipping method remains selected after returning from payment.
- The order total does not change.
- Standard checkout still works.
EOF
)
session_json=$(mo start "$brief")
session_id=$(jq -r .sessionId <<<"$session_json")
web_url=$(jq -r .webUrl <<<"$session_json")
Starting returns before Mo finishes. Preserve both values: every later command needs
session_id
, and the user can watch or join through
web_url
.
在调用CLI之前先编写测试说明,然后将其作为一个带引号的参数传入:
bash
brief=$(cat <<'EOF'
Target URL: https://preview.example.com/checkout?variant=express
Expected behavior: Express checkout now keeps the selected shipping method when the customer returns from payment.
Sign-in: Use the staging QA buyer account already provisioned for Mo.
Test data: Create test carts and orders only. Do not modify shared catalog data.
Out of bounds: Do not submit payment, send emails, delete data, or run bulk operations.
Acceptance criteria:
- The selected shipping method remains selected after returning from payment.
- The order total does not change.
- Standard checkout still works.
EOF
)
session_json=$(mo start "$brief")
session_id=$(jq -r .sessionId <<<"$session_json")
web_url=$(jq -r .webUrl <<<"$session_json")
启动命令会在Mo完成前返回结果。请保留两个返回值:后续所有命令都需要
session_id
,用户可以通过
web_url
查看或加入会话。

Follow the turn reliably

可靠跟进会话进度

Poll the active session with
status
:
bash
mo status "$session_id"
It returns the current run state, latest visible message, web URL, and structured QA findings. Always inspect
findings.testCases
,
findings.bugs
,
findings.controls
, and
findings.verdicts
; they contain more evidence than Mo's closing prose.
Use
read
when waiting for output or retrieving the transcript and pending input. Prefer bounded 30-60 second reads so the caller stays responsive:
bash
mo read "$session_id" --from start --timeout 45s --json
Use
--from start
for reliable polling. It replays the visible transcript, so deduplicate messages when automating. Repeat until the expected assistant reply appears and
state
is
idle
,
waitingOnUser
, or
stopped
. A
timedOut: true
response means Mo is still working. If
pendingInput
is present, answer it with
send
.
Do not rely on
--from latest
after
start
or
send
: it only captures output produced after the read begins, so a fast turn can finish and return no messages. A timeout accepts
0
, milliseconds, seconds, or minutes such as
500ms
,
45s
, or
4m
, up to
290s
.
status.state
reports the backend run state, while
read.state
reports the visible turn state.
使用
status
命令轮询活跃会话:
bash
mo status "$session_id"
该命令会返回当前运行状态、最新可见消息、Web URL以及结构化的QA测试结果。请务必查看
findings.testCases
findings.bugs
findings.controls
findings.verdicts
;这些内容包含比Mo的总结性文字更详细的证据。
等待输出或获取会话记录和待回复内容时,请使用
read
命令。推荐设置30-60秒的有限超时时间,以便调用方保持响应性:
bash
mo read "$session_id" --from start --timeout 45s --json
使用
--from start
进行可靠轮询。该参数会重播可见的会话记录,因此在自动化时需要对消息进行去重。重复执行该命令,直到出现预期的助手回复且
state
idle
waitingOnUser
stopped
。如果返回
timedOut: true
,说明Mo仍在运行。如果存在
pendingInput
,请使用
send
命令回复。
start
send
之后,请勿依赖
--from latest
参数:它仅捕获读取开始后产生的输出,因此快速完成的会话可能不会返回任何消息。超时时间可以设置为
0
、毫秒、秒或分钟,例如
500ms
45s
4m
,最长不超过
290s
status.state
报告后端运行状态,而
read.state
报告可见的会话回合状态。

Continue or stop a session

继续或停止会话

Send a follow-up or answer:
bash
mo send --session-id "$session_id" 'Use the staging account and continue'
mo read "$session_id" --from start --timeout 45s --json
If Mo is working,
send
steers the live turn at its next tool-step boundary. Otherwise it starts a new turn in the same session. A successful
send
only means the message was accepted; confirm that the transcript advances to a new assistant reply. After a stopped turn, a new
send
can resume the session, but an immediate read may briefly show the previous stopped state.
Stop only the active turn:
bash
mo stop "$session_id"
Allow a few seconds for propagation, then verify with
read --from start --timeout 0 --json
that the state is
stopped
. Stopping does not delete the session, and already-running sub-agents may finish independently.
发送后续指令或回复:
bash
mo send --session-id "$session_id" 'Use the staging account and continue'
mo read "$session_id" --from start --timeout 45s --json
如果Mo正在运行,
send
会在其下一个工具步骤边界处引导当前会话回合。否则,它会在同一会话中启动新的回合。
send
成功仅表示消息已被接收;请确认会话记录已更新至新的助手回复。在会话回合停止后,新的
send
可以恢复会话,但立即执行
read
可能会短暂显示之前的停止状态。
仅停止当前活跃的会话回合:
bash
mo stop "$session_id"
请等待几秒以确保状态同步,然后使用
read --from start --timeout 0 --json
验证状态是否为
stopped
。停止操作不会删除会话,已运行的子Agent可能会独立完成任务。

Transfer files

文件传输

upload
needs an existing session and prints the authoritative sandbox path. Send that returned path to Mo; a local path is meaningless inside its hosted machine.
bash
remote_path=$(mo upload --session-id "$session_id" ./fixture.csv fixture.csv)
mo send --session-id "$session_id" "Use the sandbox file at $remote_path."

mkdir -p .momentic-artifacts
mo download --session-id "$session_id" --output .momentic-artifacts "$remote_path"
If
--output
names a directory, create it first. A nonexistent output path is treated as a target filename. Without
--output
, downloads use
MOMENTIC_ARTIFACTS_DIR
, then
<current-directory>/.momentic-artifacts
.
upload
命令需要已存在的会话,并会打印沙箱中的权威路径。请将返回的路径发送给Mo;本地路径在其托管机器中没有意义。
bash
remote_path=$(mo upload --session-id "$session_id" ./fixture.csv fixture.csv)
mo send --session-id "$session_id" "Use the sandbox file at $remote_path."

mkdir -p .momentic-artifacts
mo download --session-id "$session_id" --output .momentic-artifacts "$remote_path"
如果
--output
指定的是目录,请先创建该目录。不存在的输出路径会被视为目标文件名。如果未指定
--output
,下载文件会保存到
MOMENTIC_ARTIFACTS_DIR
,其次是
<当前目录>/.momentic-artifacts

Command reference

命令参考

CommandPurpose and important arguments
mo start <message>
Create a cloud session and begin its first turn; return
sessionId
and
webUrl
as JSON.
mo read <session-id>
Read transcript and turn state; prefer
--from start --timeout <duration> --json
.
mo status <session-id>
Return the latest message, web URL, backend run state, and structured QA findings.
mo send --session-id <id> <message>
Steer active work or start the session's next turn.
mo stop <session-id>
Stop the active turn without deleting the session.
mo upload --session-id <id> <local-source> [destination]
Upload one local file and print its remote sandbox path. The optional destination is a remote filename.
mo download --session-id <id> <remote-source>
Download a sandbox path or durable artifact and print the local path. Use
--output <path>
for a target file or existing directory.
命令用途及重要参数
mo start <message>
创建云端会话并开始第一个回合;以JSON格式返回
sessionId
webUrl
mo read <session-id>
读取会话记录和回合状态;推荐使用
--from start --timeout <duration> --json
参数。
mo status <session-id>
返回最新消息、Web URL、后端运行状态以及结构化的QA测试结果。
mo send --session-id <id> <message>
引导正在进行的任务或启动会话的下一个回合。
mo stop <session-id>
停止当前活跃的会话回合,但不删除会话。
mo upload --session-id <id> <local-source> [destination]
上传一个本地文件并打印其在远程沙箱中的路径。可选的destination参数为远程文件名。
mo download --session-id <id> <remote-source>
下载沙箱中的文件或持久化工件并打印本地路径。使用
--output <path>
指定目标文件或已存在的目录。