chore: 调整 schema (#13554)

* chore: 调整 schema

* chore: required

* chore: 同步 en 版本

* chore: 移除 template 默认值

* chore: Auto update by pre-commit hooks [skip changelog]

* chore: $schema require draft-07

* style: 格式化

* style: 格式化

* chore: 统一格式

* chore: 根据 schema 修改 tasks

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
uye
2025-08-06 18:37:08 +08:00
committed by GitHub
parent 01fd697276
commit 577e23d961
3 changed files with 252 additions and 93 deletions

View File

@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "maa task config",
"patternProperties": {
"^(?!\\$)": {
@@ -32,7 +32,7 @@
"ParamsArray": {
"type": "array",
"items": {
"type": "number"
"type": "integer"
}
},
"TaskNameList": {
@@ -44,9 +44,15 @@
},
"BaseTask": {
"properties": {
"baseTask": {
"type": "string",
"description": "可选项,以其他任务为模板生成任务"
},
"algorithm": {
"type": "string",
"description": "算法类型"
"pattern": "JustReturn|MatchTemplate|OcrDetect|FeatureMatch",
"default": "MatchTemplate",
"description": "可选项,表示识别算法的类型, 默认为 MatchTemplate"
},
"action": {
"type": "string",
@@ -56,6 +62,7 @@
},
"inputText": {
"type": "string",
"default": "",
"description": "可选项,当 action 为 Input 时有效,表示要输入的文本"
},
"sub": {
@@ -114,51 +121,100 @@
},
"specificRect": {
"$ref": "#/definitions/Rectangle",
"description": "当 action 为 ClickRect 时有效且必选,表示指定的点击位置(范围内随机一点),以 1280 * 720 为基准自动缩放\n当 action 为 Swipe 时有效且必,表示滑动起点"
"description": "当 action 为 ClickRect 时有效且必选,表示指定的点击位置(范围内随机一点),以 1280 * 720 为基准自动缩放\n当 action 为 Swipe 时有效且必,表示滑动起点"
},
"specialParams": {
"$ref": "#/definitions/ParamsArray",
"description": "某些任务使用的特殊参数(大部分是手写阈值"
"description": "某些任务使用的特殊参数(大部分是手写阈值给插件用的std::vector<int>"
},
"highResolutionSwipeFix": {
"type": "boolean",
"default": false,
"description": "可选项,是否启用高分辨率滑动修复,现阶段应该只有关卡导航未使用 unity 滑动方式所以需要开启,默认为 false"
}
}
},
"allOf": [
{
"if": {
"required": ["action"],
"properties": {
"action": {
"enum": ["ClickRect"]
}
}
},
"then": {
"required": ["specificRect"]
}
},
{
"if": {
"required": ["action"],
"properties": {
"action": {
"enum": ["Swipe"]
}
}
},
"then": {
"required": ["specificRect", "rectMove"]
}
},
{
"if": {
"required": ["algorithm", "action"],
"properties": {
"algorithm": {
"const": "JustReturn"
},
"action": {
"const": "Input"
}
}
},
"then": {
"required": ["inputText"]
}
}
]
},
"JustReturnTask": {
"allOf": [
{
"$ref": "#/definitions/BaseTask"
},
{
"properties": {
"algorithm": {
"type": "string",
"pattern": "JustReturn"
}
},
"required": ["algorithm"]
}
],
"properties": {
"algorithm": {
"type": "string",
"pattern": "JustReturn"
}
},
"description": "不进行识别,直接执行 action",
"required": ["algorithm"]
"description": "不进行识别,直接执行 action"
},
"MatchTemplateTask": {
"allOf": [
{
"$ref": "#/definitions/BaseTask"
},
{
"properties": {
"algorithm": {
"type": "string",
"pattern": "MatchTemplate"
}
}
}
],
"properties": {
"algorithm": {
"type": "string",
"pattern": "MatchTemplate"
},
"template": {
"type": ["array", "string"],
"items": {
"type": "string"
},
"default": "",
"description": "可选项,要匹配的图片文件名\n不填时写默认 \"任务名.png\""
},
"templThreshold": {
@@ -167,17 +223,40 @@
"type": "number"
},
"default": 0.8,
"description": "可选项,图片模板匹配得分的阈值,超过阈值才认为识别到了。\n默认 0.8, 可根据日志查看实际得分是多少"
"description": "可选项,图片模板匹配得分的阈值,超过阈值才认为识别到了。\n默认 0.8, 可根据日志查看实际得分是多少\n多模板时阈值数量需与模板数量一致"
},
"maskRange": {
"type": "array",
"maxItems": 2,
"minimum": 2,
"minItems": 2,
"items": {
"type": "number"
"type": "integer"
},
"default": [1, 255],
"description": "可选项,灰度掩码范围。例如将图片不需要识别的部分涂成黑色(灰度值为 0然后设置 [ 1, 255 ], 匹配的时候即刻忽略涂黑的部分"
},
"colorScales": {
"type": "array",
"description": "当 method 为 HSVCount 或 RGBCount 时有效且必选,数色掩码范围。",
"items": {
"type": "array",
"minItems": 2,
"maxItems": 2
}
},
"colorWithClose": {
"type": "boolean",
"default": true,
"description": "可选项,当 method 为 HSVCount 或 RGBCount 时有效,默认为 true\n数色时是否先用闭运算处理掩码范围。\n闭运算可以填补小黑点一般会提高数色匹配效果但若图片中包含文字建议设为 false"
},
"method": {
"type": ["string", "array"],
"items": {
"type": "string"
},
"default": "Ccoeff",
"enum": ["Ccoeff", "RGBCount", "HSVCount"],
"description": "可选项,模板匹配算法,可以是列表\n不填写时默认为 Ccoeff\n - Ccoeff: 对颜色不敏感的模板匹配算法,对应 cv::TM_CCOEFF_NORMED\n - RGBCount: 对颜色敏感的模板匹配算法,先将待匹配区域和模板图片依据 colorScales 二值化,以 F1-score 为指标计算 RGB 颜色空间内的相似度,再将结果与 Ccoeff 的结果点积\n - HSVCount: 类似 RGBCount颜色空间换为 HSV"
}
},
"description": "匹配图片"
@@ -186,13 +265,17 @@
"allOf": [
{
"$ref": "#/definitions/BaseTask"
},
{
"properties": {
"algorithm": {
"type": "string",
"pattern": "OcrDetect"
}
}
}
],
"properties": {
"algorithm": {
"type": "string",
"pattern": "OcrDetect"
},
"text": {
"type": "array",
"items": {
@@ -203,12 +286,12 @@
"fullMatch": {
"type": "boolean",
"default": false,
"description": "可选项,文字识别是否需要全字匹配(不能多字),默认为 false\nfalse 时只要是子串即可:例如 text: [ \"开始\" ],实际识别到了 \"开始行动\",也算识别成功;\ntrue 时则必须识别到了 \"开始\",多一个字都不行"
"description": "可选项,文字识别是否需要全字匹配(不能多字),默认为 false\nfalse 时只要是子串即可:例如 text: [ \"开始\"],实际识别到了 \"开始行动\",也算识别成功;\ntrue 时则必须识别到了 \"开始\",多一个字都不行"
},
"useRaw": {
"isAscii": {
"type": "boolean",
"default": true,
"description": "可选项,是否使用原图匹配\n不填写默认 truefalse 时为灰度匹配"
"default": false,
"description": "可选项,要识别的文字内容是否为 ASCII 码字符\n不填写默认 false"
},
"ocrReplace": {
"type": "array",
@@ -222,34 +305,48 @@
},
"description": "可选项,针对常见识别错的文字进行替换(支持正则)"
},
"withoutDet": {
"type": "boolean",
"default": false,
"description": "可选项,是否不使用检测模型\n不填写默认 false"
},
"useRaw": {
"type": "boolean",
"default": true,
"description": "可选项,是否使用原图匹配\n不填写默认 truefalse 时为灰度匹配\n仅当 algorithm 为 OcrDetect 且 withoutDet 为 false 时生效。"
},
"binThresholdLower": {
"type": "integer",
"default": 140,
"description": "可选项,二值化灰度下阈值(默认 140\n灰度值小于该值的像素将被视为背景排除在文字区域之外"
"description": "可选项,二值化灰度下阈值(默认 140\n灰度值小于该值的像素将被视为背景排除在文字区域之外\n仅当 algorithm 为 OcrDetect 且 withoutDet 为 false 时生效。"
},
"binThresholdUpper": {
"type": "integer",
"default": 255,
"description": "可选项,二值化灰度上阈值(默认 255\n灰度值大于该值的像素将被视为背景排除在文字区域之外\n最终保留 [lower, upper] 区间的像素作为文字前景"
"description": "可选项,二值化灰度上阈值(默认 255\n灰度值大于该值的像素将被视为背景排除在文字区域之外\n最终保留 [lower, upper] 区间的像素作为文字前景\n仅当 algorithm 为 OcrDetect 且 withoutDet 为 false 时生效。"
}
},
"description": "文字识别",
"required": ["algorithm", "text"]
"required": ["algorithm", "text"],
"description": "文字识别"
},
"FeatureMatchTask": {
"allOf": [
{
"$ref": "#/definitions/BaseTask"
},
{
"properties": {
"algorithm": {
"type": "string",
"pattern": "FeatureMatch"
}
},
"required": ["algorithm"]
}
],
"properties": {
"algorithm": {
"type": "string",
"pattern": "FeatureMatch"
},
"template": {
"type": "string",
"default": "",
"description": "可选项,要匹配的图片文件名\n不填时默认为 \"任务名.png\""
},
"count": {
@@ -272,8 +369,7 @@
"description": "特征点检测器。默认值为 SIFT。可选SIFT, ORB, BRISK, KAZE, AKAZE, SURF"
}
},
"description": "使用特征点算法进行图像匹配",
"required": ["algorithm"]
"description": "使用特征点算法进行图像匹配"
}
}
}

View File

@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "maa task config english",
"patternProperties": {
"^(?!\\$)": {
@@ -44,9 +44,15 @@
},
"BaseTask": {
"properties": {
"baseTask": {
"type": "string",
"description": "Optional, generates tasks based on other tasks as templates"
},
"algorithm": {
"type": "string",
"description": "Algorithm type"
"pattern": "JustReturn|MatchTemplate|OcrDetect|FeatureMatch",
"default": "MatchTemplate",
"description": "Optional, indicates the type of recognition algorithm, defaults to MatchTemplate"
},
"action": {
"type": "string",
@@ -56,6 +62,7 @@
},
"inputText": {
"type": "string",
"default": "",
"description": "Optional, valid when action is Input, indicating the text to be entered"
},
"sub": {
@@ -125,40 +132,89 @@
"default": false,
"description": "Optional, whether to enable high-resolution swipe fix, currently only needed for stage navigation which doesn't use unity swipe method, default is false"
}
}
},
"allOf": [
{
"if": {
"required": ["action"],
"properties": {
"action": {
"enum": ["ClickRect"]
}
}
},
"then": {
"required": ["specificRect"]
}
},
{
"if": {
"required": ["action"],
"properties": {
"action": {
"enum": ["Swipe"]
}
}
},
"then": {
"required": ["specificRect", "rectMove"]
}
},
{
"if": {
"properties": {
"algorithm": {
"const": "JustReturn"
},
"action": {
"const": "Input"
}
},
"required": ["algorithm", "action"]
},
"then": {
"required": ["inputText"]
}
}
]
},
"JustReturnTask": {
"allOf": [
{
"$ref": "#/definitions/BaseTask"
},
{
"properties": {
"algorithm": {
"type": "string",
"pattern": "JustReturn"
}
},
"required": ["algorithm"]
}
],
"properties": {
"algorithm": {
"type": "string",
"pattern": "JustReturn"
}
},
"description": "Execute the action without recognition",
"required": ["algorithm"]
"description": "Execute the action without recognition"
},
"MatchTemplateTask": {
"allOf": [
{
"$ref": "#/definitions/BaseTask"
},
{
"properties": {
"algorithm": {
"type": "string",
"pattern": "MatchTemplate"
}
}
}
],
"properties": {
"algorithm": {
"type": "string",
"pattern": "MatchTemplate"
},
"template": {
"type": ["array", "string"],
"items": {
"type": "string"
},
"default": "",
"description": "Optional, the file name of the image to be matched\nDefaults to \"task name.png\" if not filled"
},
"templThreshold": {
@@ -181,13 +237,12 @@
},
"colorScales": {
"type": "array",
"description": "Required when method is HSVCount or RGBCount, color mask ranges\nStructure is [[lower1, upper1], [lower2, upper2], ...]\nInner layer is int for grayscale, or array<int, 3> for three-channel color (RGB or HSV based on method)\nMiddle layer is color (or grayscale) lower and upper limits\nOuter layer represents different color ranges, recognition area is their union on template image",
"items": {
"type": "array",
"items": {
"type": "array"
}
},
"description": "Required when method is HSVCount or RGBCount, color mask ranges\nStructure is [[lower1, upper1], [lower2, upper2], ...]\nInner layer is int for grayscale, or array<int, 3> for three-channel color (RGB or HSV based on method)\nMiddle layer is color (or grayscale) lower and upper limits\nOuter layer represents different color ranges, recognition area is their union on template image"
"minItems": 2,
"maxItems": 2
}
},
"colorWithClose": {
"type": "boolean",
@@ -200,6 +255,7 @@
"type": "string"
},
"default": "Ccoeff",
"enum": ["Ccoeff", "RGBCount", "HSVCount"],
"description": "Optional, template matching algorithm, can be list\nDefault is Ccoeff when not specified\n- Ccoeff: Color-insensitive template matching, corresponds to cv::TM_CCOEFF_NORMED\n- RGBCount: Color-sensitive template matching, binary thresholds target area and template using colorScales, calculates similarity using F1-score in RGB color space, then dot products result with Ccoeff result\n- HSVCount: Similar to RGBCount, but uses HSV color space"
}
},
@@ -209,13 +265,17 @@
"allOf": [
{
"$ref": "#/definitions/BaseTask"
},
{
"properties": {
"algorithm": {
"type": "string",
"pattern": "OcrDetect"
}
}
}
],
"properties": {
"algorithm": {
"type": "string",
"pattern": "OcrDetect"
},
"text": {
"type": "array",
"items": {
@@ -228,10 +288,10 @@
"default": false,
"description": "Optional, whether the text recognition needs to match all the words (can't match more than one word), the default is false\nfalse, as long as a substring can be found: for example, text: [\"Start\"], the actual recognition of \"Start action\" is also considered successful;\ntrue, it must recognise \"Start\", not one word more"
},
"useRaw": {
"isAscii": {
"type": "boolean",
"default": true,
"description": "Optional, whether to use the original image for matching.\nDefault is true. If false, grayscale image matching will be used."
"default": false,
"description": "Optional, whether text content is ASCII characters\nDefault false"
},
"ocrReplace": {
"type": "array",
@@ -245,25 +305,25 @@
},
"description": "Optional, replacement of commonly misrecognised text (supports regex)"
},
"binThresholdLower": {
"type": "integer",
"default": 140,
"description": "Optional, lower threshold for grayscale binarisation (default 140).\nPixels with a grayscale value lower than this will be considered background and excluded from the text region."
},
"binThresholdUpper": {
"type": "integer",
"default": 255,
"description": "Optional, upper threshold for grayscale binarisation (default 255).\nPixels with a grayscale value higher than this will be considered background and excluded from the text region.\nOnly pixels within the [lower, upper] range will be kept as text foreground."
},
"isAscii": {
"type": "boolean",
"default": false,
"description": "Optional, whether text content is ASCII characters\nDefault false"
},
"withoutDet": {
"type": "boolean",
"default": false,
"description": "Optional, whether to skip detection model\nDefault false"
},
"useRaw": {
"type": "boolean",
"default": true,
"description": "Optional, whether to use the original image for matching.\nDefault is true. If false, grayscale image matching will be used.\nThis is only effective when algorithm is OcrDetect and withoutDet is false."
},
"binThresholdLower": {
"type": "integer",
"default": 140,
"description": "Optional, lower threshold for grayscale binarisation (default 140).\nPixels with a grayscale value lower than this will be considered background and excluded from the text region.\nThis is only effective when algorithm is OcrDetect and withoutDet is false."
},
"binThresholdUpper": {
"type": "integer",
"default": 255,
"description": "Optional, upper threshold for grayscale binarisation (default 255).\nPixels with a grayscale value higher than this will be considered background and excluded from the text region.\nOnly pixels within the [lower, upper] range will be kept as text foreground.\nThis is only effective when algorithm is OcrDetect and withoutDet is false."
}
},
"description": "Text recognition",
@@ -273,16 +333,20 @@
"allOf": [
{
"$ref": "#/definitions/BaseTask"
},
{
"properties": {
"algorithm": {
"type": "string",
"pattern": "FeatureMatch"
}
},
"required": ["algorithm"]
}
],
"properties": {
"algorithm": {
"type": "string",
"pattern": "FeatureMatch"
},
"template": {
"type": "string",
"default": "",
"description": "Optional, the file name of the image to be matched\nDefaults to \"task name.png\" if not filled"
},
"count": {
@@ -305,8 +369,7 @@
"description": "Feature point detector type. Default is SIFT. Options: SIFT, ORB, BRISK, KAZE, AKAZE, SURF\nSIFT: High computational complexity, has scale and rotation invariance. Best effect.\nORB: Very fast computation, has rotation invariance but no scale invariance.\nBRISK: Very fast computation, has scale and rotation invariance.\nKAZE: Suitable for 2D and 3D images, has scale and rotation invariance.\nAKAZE: Fast computation, has scale and rotation invariance."
}
},
"description": "Use feature point algorithm for image matching",
"required": ["algorithm"]
"description": "Use feature point algorithm for image matching"
}
}
}

View File

@@ -188,7 +188,7 @@
},
"RoguelikeRecruitOperListSwipeToTheLeft": {
"baseTask": "RoguelikeRecruitOperListSlowlySwipeToTheLeft",
"specialParams": [150, 0, 0.5]
"specialParams": [150, 0, 0, 0]
},
"RoguelikeRecruitSupportElite": {
"Doc": "base_task",
@@ -1525,7 +1525,7 @@
},
"Roguelike@StageTraderRefreshWithDiceConfirm": {
"action": "ClickSelf",
"template": ["Roguelike@StageTraderRefreshWithDiceConfirm", "Roguelike@StageTraderRefreshConfirmNew"],
"template": ["Roguelike@StageTraderRefreshWithDiceConfirm.png", "Roguelike@StageTraderRefreshConfirmNew.png"],
"roi": [580, 375, 700, 230],
"next": ["Roguelike@StageTraderRefreshWithDiceConfirm", "Roguelike@StageTraderRefreshWithDiceDoubleConfirm"]
},