/everything-maa:maa-pipeline-testingfrom everything-maa
Tests and validates MaaFramework Pipeline JSON including recognition nodes, action nodes, CustomAction/CustomRecognition wiring, resource loading, and end-to-end task behavior.
Ships in everything-maa. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
测试命令、schema 字段或 MaaFramework API 行为以原始官方来源为准。涉及版本差异、binding 兼容性或语义变化时,通过 $maa-wiki 定位官方文档、schema 与源码后再下结论;测试通过不能替代对官方契约的核对。
如果用户要求验收一个尚未定义目标状态和完成条件的端到端自动化需求,先交给 $maa-workflow-build 建立任务契约;已有契约时,再用本 skill 为其中的验收条件收集测试证据。
本 skill 的测试证据已经能定位责任方时,直接把证据交回对应 skill:识别或动作节点问题回 $maa-pipeline-generate,option 与 override 接线问题回 $maa-pipeline-option,状态模型或集成问题回 $maa-workflow-build。不要因为聚焦识别失败就触发 $maa-diagnose 的广义诊断流水线。只有失败已经发生、且聚焦测试仍无法归属责任方(原因可能同时落在运行日志、静态定义、环境或 harness)时,才由 $maa-workflow-build 的 RECOVER 请求 $maa-diagnose 收集只读证据。
测试前先查目标项目根目录的 basic_info.md。存在且包含第 0 节时,读取“0. Maa Skills 接力协议”和第 2/5/7/8/9/10 节,用 task/resource、公共返回节点、OCR/模板/ROI 和风险清单规划测试;随后以当前截图、当前源码和 TaskDetail 为准。优先把公共 Click 节点复制成临时 DoNothing 探针做初始化 smoke test,完成后调用 stop_pipeline 并删除临时文件。文件缺失或没有第 0 节时按本 skill 直接发现测试所需上下文;不得自动调用 $maa-project-init,只有用户明确要求初始化或刷新时才调用。源码更新更晚时视为缓存可能过期并以源码为准,不自动刷新或覆盖。
从主 interface.json / interface.jsonc 读取 task entry、import[] 和 resource[].path。import[] 与资源路径都相对主 Interface 目录解析;测试只针对声明资源根内的 Pipeline、图片和项目声明的 agent 入口。assets/... 是常见打包布局示例,但不是可以脱离 Interface 声明猜测的协议默认值。
测试 MaaFramework Pipeline JSON 中的 node,验证识别和操作是否正常工作。
pnpm check)能证明声明和资源包可加载,但不能证明 CustomAction/CustomRecognition 名称存在、参数路径正确、run_task() 分支判断正确。action: Custom / action.type = Custom 的 custom_action 都要能映射到 @AgentServer.custom_action(...);所有 recognition.type = Custom 的 custom_recognition 都要能映射到 @AgentServer.custom_recognition(...)。enable/enabled 设为 false 时,Python 必须先短路,不能再调用该节点的 run_recognition()/run_task();同时验证关闭可选分支后,同级战斗/调查分支仍会继续识别。target / target_offset 的节点必须在点击后再截一次图确认落点,否则写死的坐标会在换设备后静默点错。审查写法见 coordinate-hygiene。当前 MaaMCP 的 run_pipeline 没有「只截 ROI 区域验证」的参数,整屏 OCR 扫描慢且容易触发超时。在工具侧支持之前,用以下方式压缩验证成本,不要因为验证慢就跳过验证:
roi 上收敛识别范围,再跑单节点;ROI 越准,单次识别越快。start_agent=False + 指定 entry 只测识别,不拉起 CustomAction 链。ocr() 读全屏拿 box,不要用 run_pipeline 反复试探未成形的节点。screencap 看实际画面,再改 roi/expected。工具本身的增强(ROI 限定的 run_pipeline、轻量 explore 工具)属于 MaaMCP 上游,不在本仓库范围内。
rg -n '"Custom"|custom_action|custom_recognition' <declared-resource-root> -g '*.json'
rg -n '@AgentServer\.custom_action|@AgentServer\.custom_recognition' agent -g '*.py'
人工对照时按名字精确匹配。资源检查通过但这里缺注册,运行时仍会失败。
# 1. 连接设备
find_adb_device_list()
controller_id = connect_adb_device(device_name="xxx")
# 或
controller_id = connect_window(window_name="xxx")
# 2. 加载 pipeline
load_pipeline(pipeline_path="<declared-pipeline-json>")
RESOURCE_PATH = "<declared-resource-root>"
# 3. 逐个测试
for node_name in pipeline_nodes:
result = run_pipeline(
controller_id=controller_id,
pipeline_path=pipeline_path,
entry=node_name,
resource_path=RESOURCE_PATH
)
# succeeded + all_results 有内容 = 识别成功
# 详见下方"结果判断"小节
| status | all_results | 含义 |
|---|---|---|
succeeded | 有内容 | ✅ 识别成功 |
succeeded | 空 | ❌ 识别失败 |
failed | — | ❌ 节点未触发 / 识别超时 |
返回结构:
{
"status": "succeeded",
"nodes": [{
"name": "node_name",
"recognition": {
"all_results": [{"box": [x, y, w, h], "score": 0.99, "text": "..."}]
}
}]
}
run_task() 结果判断 ⚠️MCP 的 run_pipeline 单节点结果和 Python CustomAction 里的 context.run_task() 结果不是同一个使用场景。context.run_task() 的 result.nodes 可能包含:
next 列表里被尝试过但失败的节点因此不要写:
# ❌ 错:有 nodes 不代表目标节点命中
result = context.run_task("AutoSky_CloneDied")
if result and result.nodes:
handle_clone_loss()
应该检查节点是否真的完成或识别命中:
def task_result_has_hit(result, names: set[str]) -> bool:
if not result or not result.nodes:
return False
for node in result.nodes:
if getattr(node, "name", None) not in names:
continue
if getattr(node, "completed", False):
return True
recognition = getattr(node, "recognition", None)
if recognition and getattr(recognition, "hit", False):
return True
return False
实战信号:调试面板里目标节点是红叉,但日志却进入了成功分支,基本就是把"节点出现过"误当成"节点命中"。
对于会回到稳定页面的流程,建议先检测稳定状态:
if task_result_has_hit(result, {"AutoSky_CheckExplorationInfo"}):
return "done"
再跑危险兜底动作(取消结算、购买确认、继续挑战等),避免页面已经回稳后误触发。
Click 节点会让页面跳转,破坏后续测试初始状态。必须用 BackButton_500ms 返回:
# 测试节点
run_pipeline(..., entry="NodeA", ...)
# 必须返回!不要 click_key(4) 模拟 ESC(可能进错页面)
run_pipeline(..., entry="BackButton_500ms", ...)
# 测下一个
run_pipeline(..., entry="NodeB", ...)
以下示例中的 BackButton_500ms 来自某个历史项目的 main_ui.json;实际测试应使用当前项目 Interface / Pipeline 图中确认存在的安全返回节点。
OCR 失败时不要换 TemplateMatch!先用 sweep 找 sweet spot。
操作流程:
expected 必须匹配当前资源实际显示文本;在 MaaGumballs 中文资源里是 ["角色"],不是英文 key ["Role"]run_pipeline 逐个跑,记录 scoregenerate_node.py --expand X --overwrite 正式写入实战矩阵(5 节点实测):
| 节点 | e0 | e20 | e50 | 最佳 |
|---|---|---|---|---|
| 角色 | ✅ | ✅ 0.9997 | ✅ | e20 |
| 编队 | ✅ | ✅ 0.998 | ✅ | e20 |
| 城堡 | ✅ | ❌ | — | e3(仅 0-15) |
| 佣兵团 | ❌ | ✅ | ✅ | e20 |
| 前往群岛 | ✅ | ✅ | ✅ | e20 |
观察:
timeout: 2000 期间 OCR 会重试多次,所以单次失败不一定是真失败测试时绝对不要点击这些按钮(消耗资源):
误入后处理:尝试 BackButton_500ms 或 ESC → 切换 tab 刷新。
| 现象 | 排查 |
|---|---|
| 节点超时失败 | 截屏看实际界面 → 调整 expected 文本或 roi |
| OCR 拆分多字(如"角色"→"电"+"色") | 缩小 ROI 避开干扰 |
| 误识别相邻文字 | 缩小 ROI 限制范围 |
| 点击位置不准 | 实际点击取 box 中心点:x + w/2, y + h/2 |
| 可滚动 UI 单视图测不全 | 一个截图里只能看到 5-6 个元素,需要 swipe 多次分别测;详见下方 |
| Click + BackButton 跳错页面 | Click 子页后按 BackButton 可能回到大地图/外层 UI,不是预期父页面;需主动 navigate 回来 |
| 部分可见元素识别 | 边界处只露 25px 也能 OCR 找到(score 偏低 0.8x),用大 ROI 覆盖即可 |
单次截图只能测当前可见的 5-6 个元素。要测全列表(如城堡 10 个建筑)必须多次 swipe:
1. 进入目标页(如城堡顶部)
2. run_pipeline 测当前可见的 N 个节点
3. 每个 click 后 BackButton 返回
4. swipe 滚动一屏
5. 再 run_pipeline 测新可见的节点
6. 重复直到列表测完
典型案例:城堡建筑(10 节点)
关键:所有节点共用同一大 ROI [x, top_y, w, full_h],不要给每个节点算不同 ROI(滚动后位置变了,原 ROI 失效)。
症状:节点超时、OCR 找不到、行为异常、识别 score 突然下降
解决:调 screencap(controller_id) 看实际屏幕状态:
配合 ocr() 看识别结果交叉验证。不要盲调 ROI/expected,先看实际屏幕。
Click 节点会让页面跳转,破坏后续测试初始状态。必须用 BackButton_500ms 返回:
# 测试节点
run_pipeline(..., entry="NodeA", ...)
# 必须返回!不要 click_key(4) 模拟 ESC(可能进错页面)
run_pipeline(..., entry="BackButton_500ms", ...)
注意:BackButton 不一定回到你期望的父页面!
测试前先确认 BackButton 路径,或者用 ocr() 检查当前页面状态再继续。
start_agent=true 失败时的 Fallback 方案症状:run_pipeline(..., start_agent=true) 报
Agent 启动失败: Agent 启动失败 (identifier=12345): connect() 返回 False
根因(常见):
MaaAgentServerStartUpMaaAgentServerNotImpl(这个错误明确说"用 MaaFramework,不要用 MaaAgentServer")Fallback 1:单节点测试(推荐):
用 start_agent=false + 指定 entry 测单个节点(只测 OCR/Template 识别,跳过 CustomAction 链):
# 不开 agent,直接测某个节点
result = run_pipeline(
controller_id=cid,
pipeline_path="<project-root>/<declared-resource-root>/pipeline/example.json",
entry="AutoSky_BagConfig", # 任意节点名
resource_path="<project-root>/<declared-resource-root>",
start_agent=False, # ← 关键:false
)
适用场景:测 OCR / TemplateMatch / ColorMatch 等识别节点的 ROI 和 expected 文本是否正确。
Fallback 2:手动启动 agent 后 MCP 通过 socket 连接:
如果单节点测试不够(需测完整任务链),手动跑 agent 进程,然后用 connect_adb_device / connect_window 让 MCP 复用。
# 步骤 1:手动启动 agent
import subprocess
agent_proc = subprocess.Popen(
["python", "agent/main.py", "test_socket"],
cwd=".",
)
# 步骤 2:让 MCP 连接(需要 MCP 内部 socket ID 匹配)
# 实际中,MCP 启动 agent 会自动起 socket,如果手动起需要 MCP 端配对
# 通常这一步是 MCP 内部行为,我们无法直接控制
Fallback 3:放弃 MCP,直接用 MaaFramework Python API:
import sys
sys.path.insert(0, "<project-root>")
from maa.agent.agent_server import AgentServer
from maa.toolkit import Toolkit
from maa.resource import Resource
from maa.controller import AdbController
from maa.tasker import Tasker
Toolkit.init_option("./")
res = Resource(); res.post_bundle("./<declared-resource-root>").wait()
ctrl = AdbController(adb_path="adb", address="127.0.0.1:16384"); ctrl.post_connection().wait()
tasker = Tasker(); tasker.bind(res, ctrl)
import action.sky
autosky = action.sky.AutoSky()
result = autosky.run(tasker.context, type('X', (), {'custom_action_param': '{}'})())
何时用哪种:
## <文件名> 测试记录
日期: 2026-06-05
设备: xxx
controller_id: xxx
### Node 列表
- [ ] node_name_1
- [ ] node_name_2
### 测试进度
| Node | 结果 | 备注 |
|------|------|------|
| xxx | ✅ | score=0.999 |
| xxx | ❌ | 原因xxx |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub khazixw2/everything-maa --plugin everything-maa13 skills in this plugin
/maa-cli-operateOperate MaaFramework devices and Pipeline resources through the maafw-cli command line with strict JSON output. Use for low-context, repeatable or scripted device discovery, ADB/Win32/PlayCover/wlroots connections, OCR and recognition, screenshots and guarded actions, named sessions, Pipeline validation or execution, resource checks, and CI-friendly Maa automation; route persistent exploratory debugging to MaaMCP instead./maa-diagnoseDiagnose unexplained MaaFramework failures by driving the externally managed latest MaaEvidenceKit diagnostic runtime (formerly MaaDiagnosticExpert) read-only over local logs, project sources, and run-state context. Use when a run, task, or test already failed and the owner of the defect is still unknown, including maafw.log, timestamped maafw.bak logs, or other maafw.*.log files - resource or schema load failures, environment or dependency problems, device errors, runtime timeouts, wrong branches, Custom exceptions, or large MaaFramework logs that need timeline and node correlation. Produces normalized findings, evidence, artifacts, and one bounded failure owner, and never applies a repair. Route project scaffold health checks to $maa-project-create doctor and focused recognition retuning to $maa-pipeline-generate.Other plugins' skills for the same job