/everything-maa:maa-pipeline-guidefrom everything-maa
Guides writing, modifying, and reviewing MaaFramework Pipeline JSON for automation tasks. Covers node flow design, TemplateMatch/OCR/Custom recognition, Click/Swipe actions, and custom logging or notifications on node events.
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.
本指南中的 Pipeline 约定是工作经验和社区规范,不能替代 pinned 版本的官方协议、schema 或源码。当字段语义、默认值、版本差异或 API 行为存在疑问时,通过 $maa-wiki 定位 MaaLLMWiki catalog 中的原始来源,再以官方文档、tools/pipeline.schema.json 或 MaaFramework 源码为准。
如果用户提出的是尚未定义起始状态、安全边界和验收条件的端到端自动化目标,先交给 $maa-workflow-build 建立任务契约与状态机;已有契约时,再用本 skill 处理 Pipeline 设计、修改或审查。
用户说“识别到了就提示我”或“这个节点失败时在运行窗口弹一句”,将需求定位到节点 focus,通过 $maa-wiki 核对目标版本的事件键、模板和客户端支持。用户要由 Python 在任务或节点事件发生后执行代码时,通过 $maa-wiki 查 Event Sink。用户要变更执行路径时,按 next、on_error 等流程机制设计。
开始广泛扫描仓库前,先在目标项目根目录查找 basic_info.md:
maa-project-init 生成的上下文缓存;待修改节点必须回到当前 JSON/Python 核实,设备相关结论必须用当前截图或识别结果核实。$maa-project-init,只有用户明确要求初始化或刷新时才调用。interface.json、Pipeline 或 Agent 文件晚于 basic_info.md 时,将缓存视为可能过期并以当前源码为准;不得自动刷新或覆盖已有非空文件。next 列表,覆盖当前操作后所有可能画面,力争一次截图命中。delay 掩盖问题;但启动、动画、结算、加载稳定等场景可以使用短的 pre_delay / post_delay / timeout / *_wait_freezes。当确实不需要等待时,要在节点上显式将 rate_limit / pre_delay / post_delay 设为 0(协议默认 rate_limit=1000ms、pre_delay/post_delay=200ms,省略字段会引入隐式等待)。不要假设仓库存在自动补默认值脚本,使用前先发现真实工具。target 默认 true)。不要用 DirectHit + 硬编码 target 跳过识别,也不要在识别命中后用写死的 target_offset 把点击挪到未被识别的控件上——模拟器分辨率、缩放与 UI 版本差异会让这类坐标静默点错位置。.prettierrc(4 空格缩进,数组元素换行)。需要完整字段速查时读取 references/field-reference.md,不要把整份字段表重复加载到日常任务上下文。编写或审查带点击动作的节点时读取 references/coordinate-hygiene.md,其中有两种坐标坏味、OCR/TemplateMatch 点击的推荐写法和允许偏移的例外条件。
这些规则来自 MaaGumballs 与 M9A 的 Pipeline 历史审查,优先级高于早期经验里的绝对化表述:
next + [JumpBack]。当逻辑需要运行时数据、事件库、动态目标选择、跨节点计数、复杂 OCR/图像后处理、pipeline_override 计算或失败策略时,使用 CustomAction/CustomRecognition。action: Custom,M9A 同时大量使用 custom_action、custom_recognition、tasker_sink。设计新流程时先判断问题属于“控制流/动作决策”还是“识别/列表解析/图像后处理”。next 放“当前页面可能出现的下一批状态”;临时弹窗、加载、确认框用 [JumpBack];高风险分支(战斗、购买、消耗、结算继续)要和普通调查/领取/返回分开。delay 掩盖状态识别问题;但启动、切页动画、结算、加载后稳定画面等场景可以使用短的 post_delay、rate_limit 或 *_wait_freezes,并配套下一屏识别验证。run_task() 结果判断都正确。Custom 映射和关键链路需要单独检查。next 后再让 Python 猜。next 顺序表达优先级:先放最确定、最安全的稳定状态,再放可恢复分支,最后放异常/弹窗 [JumpBack]。[JumpBack]X 是“执行 X 后回到父节点继续识别”,不是普通跳转;适合关闭弹窗、处理加载、补一次确认、滑动列表后回到父识别。next 里造成死循环。override_pipeline()、多步任务编排、失败后是否继续的策略。next、enabled、expected 或 roi,优先 pure pipeline_override。MaaFramework 协议推荐 v2 object 形态,但本仓库不少历史 pipeline 仍使用平铺字段:
{
"AutoSky_CheckExplorationInfo": {
"recognition": "OCR",
"expected": "探索信息",
"roi": [32, 964, 214, 103],
"action": "DoNothing"
}
}
编辑既有文件时优先沿用该文件已有风格,避免在同一个局部把 v1 平铺与 v2 object 混得过碎。若要新增 UI 选项或 Python 读取配置,先确认 context.get_node_data() 返回结构和当前代码读取路径。
enabled 与 enable协议字段是 enabled;部分项目/历史节点可能使用 enable 作为自定义开关字段。新增开关时:
enabled。enable 或已有辅助函数兼容 enable/enabled,沿用该功能已有字段。interface.json 的 pipeline_override 必须覆盖代码实际读取的字段;不要 UI 写 enabled,Python 却读 enable。context.run_task() 返回的 result.nodes 可能包含已经尝试过但识别失败的节点。调试面板里的红叉节点也可能出现在列表中,所以不要用 if result.nodes 或"节点名出现过"当作命中。
可靠判断顺序:
context.run_recognition("Node", img).hit 判断当前截图。run_task() 结果时,检查目标 node 的 completed 或 node.recognition.hit。AutoSky_CheckExplorationInfo),避免已经回到页面后又误跑危险兜底动作。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
不要把"战斗"、"调查"、"开启神殿"、"领奖"等语义不同的节点全塞进一个宽泛 EventDetection.next 后再由 Python 统一当战斗处理。高风险分支应在 Python 或上层状态机里先做分类:
这能避免"空雷达/调查事件被误判成战斗结算"一类问题。
__ 开头(如 __ScenePrivateXXX),不对外暴露。ResellMain、DailyProtocolPassInMenu、RealTimeAutoFightEntry。Universal pipeline 使用 v2 格式,recognition 和 action 放入二级字典:
{
"MyNode": {
"recognition": {
"type": "TemplateMatch",
"param": {
"template": "MyTask/button.png",
"roi": [100, 200, 300, 100],
"threshold": 0.7,
},
},
"action": {
"type": "Click",
},
"next": ["NextNode"],
},
}
"recognition": {
"type": "TemplateMatch",
"param": {
"template": "path/to/image.png", // 相对 image 文件夹
"roi": [x, y, w, h], // 720p 坐标,缩小搜索范围
"threshold": 0.7 // 默认 0.7,按需调整
}
}
green_mask: true 可遮蔽不参与匹配的区域(用 RGB(0,255,0) 涂色)。"recognition": {
"type": "OCR",
"param": {
"roi": [x, y, w, h],
"expected": ["完整文本"]
}
}
0/\d+)是合法设计,适合动态数值、状态栏、干扰多的 ROI;使用时要在测试记录里说明原因,并按项目 i18n 规则处理跳过/翻译。tools/i18n;先发现目标仓库的 i18n 工具与约定。"recognition": {
"type": "ColorMatch",
"param": {
"roi": [x, y, w, h],
"method": 40, // HSV 空间(推荐)
"lower": [h_low, s_low, v_low],
"upper": [h_high, s_high, v_high],
"count": 100
}
}
// And:全部子识别都成功才算命中
"recognition": {
"type": "And",
"param": {
"all_of": ["NodeA", "NodeB"], // 可引用节点名或内联 object
"box_index": 0
}
}
// Or:任一子识别成功即命中
"recognition": {
"type": "Or",
"param": {
"any_of": ["NodeA", "NodeB"]
}
}
调用 AgentServer 注册的自定义识别器。适合把“识别后的判断”放到 Python:OCR 后处理、列表扫描、动态 box、颜色/模板组合、复杂图像判断等。
"recognition": {
"type": "Custom",
"param": {
"custom_recognition": "ExpressionRecognition",
"custom_recognition_param": {
"expression": "{CreditOCR}<300"
}
}
}
自定义动作使用 action: Custom 或 v5 object-form 的 action.type = "Custom",适合把“执行策略”放到 Python:动态分支、事件库、计数器、运行时 override_pipeline()、多步子任务、失败是否继续等。
"action": {
"type": "Custom",
"param": {
"custom_action": "NodeOverride",
"custom_action_param": {
"SomeNode": { "enabled": false }
}
}
}
| 动作 | 用途 | 关键字段 |
|---|---|---|
Click | 点击 | target, target_offset |
LongPress | 长按 | target, duration |
Swipe | 滑动 | begin, end, duration |
Scroll | 滚轮(仅Win32) | target, dx, dy |
ClickKey | 按键 | key(虚拟键码) |
InputText | 输入文本 | input_text |
StartApp / StopApp | 启停应用 | package |
StopTask | 停止当前任务链 | 无 |
Custom | 自定义动作 | custom_action, custom_action_param |
DoNothing | 不执行(默认) | 无 |
target 支持:true(当前识别结果)、节点名字符串、[x, y]、[x, y, w, h]。
按序识别,首个命中的节点执行其 action 后成为当前节点。next 为空或全部超时则任务结束。
识别超时或动作失败时执行的节点列表。
[JumpBack]:命中后执行完该节点链,自动返回父节点继续识别 next。适用于处理弹窗、加载等中断场景。
"next": [
"BusinessNode",
"[JumpBack]HandlePopup",
"[JumpBack]WaitLoading"
]
[Anchor]:动态引用锚点,运行时解析为最后设置该锚点的节点。
只在必须时使用 pre_wait_freezes / post_wait_freezes 等待画面静止,不要为了执行稳定而使用延迟:
"post_wait_freezes": {
"time": 200,
"target": [0, 0, 0, 0] // 全屏
}
避免对同一按钮重复点击——第二次点击可能作用于下一界面的其他元素。
限制节点最大命中次数,超过后自动跳过:
"max_hit": 3
编写前先检查是否已有可复用节点,避免重复造轮子。
Common/Button/)| 节点 | 说明 |
|---|---|
WhiteConfirmButtonType1 | 白底圆环确认 |
WhiteConfirmButtonType2 | 白底对号确认 |
YellowConfirmButtonType1 | 黄底圆环确认 |
YellowConfirmButtonType2 | 黄底对号确认 |
CancelButton | 白底 X 取消 |
CloseButtonType1 | 右上角 X(不兼容 ESC 菜单) |
CloseButtonType2 | 右上角 X(兼容 ESC 菜单,推荐) |
TeleportButton | 右下角传送按钮 |
CloseRewardsButton | 奖励界面对号关闭 |
SubTask:顺序执行子任务列表。ResetCount / ClearHitCount:清除节点命中计数;具体名称以目标项目注册函数为准。NodeOverride / DisableNode:运行时覆盖或禁用节点;适合动态状态,不适合替代简单 UI option。ExpressionRecognition / CustomRecognition:计算布尔表达式或做复杂识别后处理;具体名称以目标项目注册函数为准。docs/zh_cn/1.3-Custom&Agent.md。{
"MyTaskEntry": {
"next": [
"MyTaskMainStep",
"[JumpBack]SceneDialogConfirm",
"[JumpBack]SceneWaitLoadingExit",
"[JumpBack]SceneAnyEnterWorld",
],
},
}
当一个任务涉及多个页面跳转(如:大地图 → 活动入口 → 难度选择 → 队伍配置 → 战斗),用 MaaFramework 的 next + [JumpBack] 机制串接各页面节点。不要写 Python orchestration(自己 for/while 调 run_task 模拟状态机)。
{
"MyActivity_Start": {
"next": [
"MyActivity_TeamReady", // 已在队伍配置页
"[JumpBack]MyActivity_Difficulty_Select", // 在难度选择页
"[JumpBack]MyActivity_Enter" // 在大地图
],
"timeout": 10000
},
"MyActivity_Enter": {
"next": [
"MyActivity_Enter_Click", // 找到图标
"[JumpBack]BigMap_Activity_Resident", // 切"常驻"tab
"[JumpBack]BigMap_Activity" // 打开活动页
],
"timeout": 10000
},
"MyActivity_EnterBattle": {
"recognition": { "type": "OCR", "param": { "expected": ["进入战斗"], "roi": [...] } },
"action": { "type": "Click" },
"next": [
"MyActivity_FightStart", // 战斗开始
"[JumpBack]MyActivity_TravelSelect_Boat", // 乘船
"[JumpBack]MyActivity_TravelSelect_Walk" // 步行
]
}
}
关键设计要点:
[JumpBack] 是状态回退原语:命中后执行完节点链,自动返回父节点的 next 继续识别。target_offset 偏移(如 target_offset: [270, 0, 0, 0]),并记录偏移量的实测来源。写死坐标的坏味与例外条件见 references/coordinate-hygiene.md。pipeline/*.json,跨文件引用 OK。但 run_pipeline 测试工具只加载单文件,集成测试需用 GUI/CLI。实战决策流程:
要实现一个跨页面流程
│
├─ 流程可枚举为有限页面状态(A→B→C→D)?
│ └─ ✅ 优先用纯 JSON 状态机(next + [JumpBack])
│ 示例:成长试炼、相亲、英雄副本
│
└─ 流程涉及复杂的运行时分支或 Python 侧业务逻辑?
└─ 用 Flag 节点 + Python CustomAction
示例:跳过整个 handle_sailing_festival 函数
详细反模式参见 maa-pipeline-option anti-patterns。
{
"ClickConfirm": {
"recognition": { "type": "TemplateMatch", "param": { "template": "confirm.png", "roi": [...] } },
"action": { "type": "Click" },
"post_wait_freezes": { "time": 200, "target": [0, 0, 0, 0] },
"next": ["VerifyNextScreen", "[JumpBack]ClickConfirm"]
}
}
{
"MyButton": {
"recognition": {
"type": "And",
"param": {
"all_of": ["ButtonBackground", "ButtonIcon"],
"box_index": 0,
},
},
"action": {"type": "Click"},
},
}
pre_delay / post_delay / timeoutnext 列表覆盖所有可能画面,含弹窗/加载/异常DirectHit + 硬编码 target,也没有无锚点的硬编码 target_offset.prettierrclocales/ 已添加新增任务的多语言文本expected 写完整文本post_wait_freezes__ScenePrivate* 内部节点docs/zh_cn/3.1-任务流水线协议.mddocs/zh_cn/1.3-Custom&Agent.mddocs/zh_cn/3.3-ProjectInterfaceV2协议.mddocs/zh_cn/1.2-术语解释.mdWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
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