Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ on:
- "**"
paths:
- ".github/workflows/check.yml"
- "assets/**"
- "**.py"
- "interface.json"
- "tasks/**"
- "resource/**"
- "agent/**"
- "tools/**"
pull_request:
branches:
- "**"
paths:
- ".github/workflows/check.yml"
- "assets/**"
- "**.py"
- "interface.json"
- "tasks/**"
- "resource/**"
- "agent/**"
- "tools/**"
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -43,4 +49,4 @@ jobs:
- name: Validate JSON Schema
run: |
python -m pip install jsonschema==4.26.0 referencing==0.37.0
python tools/validate_schema.py --schema-dir deps/tools --resource-dirs assets/resource --exclude-dirs assets/resource/announcement --interface-files assets/interface.json
python tools/validate_schema.py --exclude-dirs resource/base/announcement
20 changes: 13 additions & 7 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@ on:
- "**"
paths:
- ".github/workflows/install.yml"
- "assets/**"
- "**.py"
- "interface.json"
- "tasks/**"
- "resource/**"
- "agent/**"
- "tools/**"
pull_request:
branches:
- "**"
paths:
- ".github/workflows/install.yml"
- "assets/**"
- "**.py"
- "interface.json"
- "tasks/**"
- "resource/**"
- "agent/**"
- "tools/**"
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -176,17 +182,17 @@ jobs:
steps:
- uses: actions/download-artifact@v4
with:
path: assets
path: release-assets

- run: |
cd assets
cd release-assets
for f in *; do
(cd $f && zip -r ../$f-${{ needs.meta.outputs.tag }}.zip .)
done

- uses: softprops/action-gh-release@v2
with:
files: assets/*
files: release-assets/*
tag_name: ${{ needs.meta.outputs.tag }}
body: ${{ needs.changelog.outputs.release_body }}
draft: false
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/sync_schema_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,47 +39,47 @@ jobs:
echo "Current Date and Time (UTC): $(date -u '+%Y-%m-%d %H:%M:%S')"

# 确保目标目录存在
mkdir -p deps/tools
mkdir -p tools/schema

# 下载四个JSON schema文件
curl -s -o deps/tools/interface.schema.json https://raw.githubusercontent.com/MaaXYZ/MaaFramework/main/tools/interface.schema.json || echo "Failed to download interface.schema.json"
curl -s -o deps/tools/interface_config.schema.json https://raw.githubusercontent.com/MaaXYZ/MaaFramework/main/tools/interface_config.schema.json || echo "Failed to download interface_config.schema.json"
curl -s -o deps/tools/interface_import.schema.json https://raw.githubusercontent.com/MaaXYZ/MaaFramework/main/tools/interface_import.schema.json || echo "Failed to download interface_import.schema.json"
curl -s -o deps/tools/pipeline.schema.json https://raw.githubusercontent.com/MaaXYZ/MaaFramework/main/tools/pipeline.schema.json || echo "Failed to download pipeline.schema.json"
curl -s -o tools/schema/interface.schema.json https://raw.githubusercontent.com/MaaXYZ/MaaFramework/main/tools/interface.schema.json || echo "Failed to download interface.schema.json"
curl -s -o tools/schema/interface_config.schema.json https://raw.githubusercontent.com/MaaXYZ/MaaFramework/main/tools/interface_config.schema.json || echo "Failed to download interface_config.schema.json"
curl -s -o tools/schema/interface_import.schema.json https://raw.githubusercontent.com/MaaXYZ/MaaFramework/main/tools/interface_import.schema.json || echo "Failed to download interface_import.schema.json"
curl -s -o tools/schema/pipeline.schema.json https://raw.githubusercontent.com/MaaXYZ/MaaFramework/main/tools/pipeline.schema.json || echo "Failed to download pipeline.schema.json"

# 检查文件是否成功下载
echo "Checking downloaded files:"
ls -la deps/tools/*.schema.json
ls -la tools/schema/*.schema.json

- name: Check for changes with git status
id: check_status
run: |
# 确保git能看到未跟踪的文件
git add -N deps/tools/
git add -N tools/schema/

# 检查是否有任何更改(修改、新增、删除)
if [[ -n "$(git status --porcelain deps/tools/*.schema.json)" ]]; then
if [[ -n "$(git status --porcelain tools/schema/*.schema.json)" ]]; then
echo "Changes detected in JSON schema files"
git status --porcelain deps/tools/*.schema.json
git status --porcelain tools/schema/*.schema.json
echo "changes_detected=true" >> $GITHUB_OUTPUT

# 检查哪些文件发生了变化
if [[ -n "$(git status --porcelain deps/tools/interface.schema.json)" ]]; then
if [[ -n "$(git status --porcelain tools/schema/interface.schema.json)" ]]; then
echo "interface_changed=true" >> $GITHUB_OUTPUT
else
echo "interface_changed=false" >> $GITHUB_OUTPUT
fi
if [[ -n "$(git status --porcelain deps/tools/interface_config.schema.json)" ]]; then
if [[ -n "$(git status --porcelain tools/schema/interface_config.schema.json)" ]]; then
echo "interface_config_changed=true" >> $GITHUB_OUTPUT
else
echo "interface_config_changed=false" >> $GITHUB_OUTPUT
fi
if [[ -n "$(git status --porcelain deps/tools/interface_import.schema.json)" ]]; then
if [[ -n "$(git status --porcelain tools/schema/interface_import.schema.json)" ]]; then
echo "interface_import_changed=true" >> $GITHUB_OUTPUT
else
echo "interface_import_changed=false" >> $GITHUB_OUTPUT
fi
if [[ -n "$(git status --porcelain deps/tools/pipeline.schema.json)" ]]; then
if [[ -n "$(git status --porcelain tools/schema/pipeline.schema.json)" ]]; then
echo "pipeline_changed=true" >> $GITHUB_OUTPUT
else
echo "pipeline_changed=false" >> $GITHUB_OUTPUT
Expand All @@ -100,7 +100,7 @@ jobs:
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

git add deps/tools/*.schema.json
git add tools/schema/*.schema.json

if git diff-index --quiet HEAD --; then
echo "No changes to commit"
Expand Down
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,11 @@ enc_temp_folder/*

# Build
deps/*
!deps/tools/
deps/tools/*
!deps/tools/*.schema.json
build
install

# Tools
tools/ImageCropper/**/*.png

config
debug
debug
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ node_modules/
assets/MaaCommonAssets

# 跳过 schema 目录,避免与 sync_schema_files 冲突
deps/tools/
tools/schema/

# 锁文件
pnpm-lock.yaml
Expand Down
22 changes: 15 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,37 @@
"json.schemas": [
{
"fileMatch": [
"/assets/resource/**/*.json",
"/resource/**/*.json",
"/install/resource/**/*.json",
"/assets/resource/**/*.jsonc",
"/resource/**/*.jsonc",
"/install/resource/**/*.jsonc"
],
"url": "/deps/tools/pipeline.schema.json"
"url": "/tools/schema/pipeline.schema.json"
},
{
"fileMatch": [
"/assets/interface.json",
"/interface.json",
"/install/interface.json"
],
"url": "/deps/tools/interface.schema.json"
"url": "/tools/schema/interface.schema.json"
},
{
"fileMatch": [
"/tasks/**/*.json",
"/install/tasks/**/*.json"
],
"url": "/tools/schema/interface_import.schema.json"
},
{
"fileMatch": [
"/install/config/maa_pi_config.json"
],
"url": "/deps/tools/interface_config.schema.json"
"url": "/tools/schema/interface_config.schema.json"
}
],
"files.associations": {
"**/assets/**/*.json": "jsonc"
"/interface.json": "jsonc",
"/resource/**/*.json": "jsonc"
},
"[json][jsonc]": {
"editor.formatOnSave": true,
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@

请阅读 [如何开发](./docs/zh_cn/develop/how_to_develop.md)。

## 项目布局

```text
├── interface.json
├── tasks/
├── resource/base/
├── agent/
└── tools/schema/
```

向本模板仓库提交改动前,请阅读 [PR 规范](./docs/zh_cn/develop/pull_request_guidelines.md)。

## 生态共建
Expand Down
15 changes: 15 additions & 0 deletions agent/custom/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sys

from . import action, reco

sys.modules.setdefault("custom", sys.modules[__name__])
sys.modules.setdefault("custom.action", action)
sys.modules.setdefault("custom.reco", reco)


def register_all() -> None:
action.register_all()
reco.register_all()


__all__ = ["register_all"]
11 changes: 11 additions & 0 deletions agent/custom/action/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from importlib import import_module

ACTION_MODULES = ("general",)


def register_all() -> None:
for module_name in ACTION_MODULES:
import_module(f"custom.action.{module_name}")


__all__ = ["register_all"]
File renamed without changes.
11 changes: 11 additions & 0 deletions agent/custom/reco/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from importlib import import_module

RECO_MODULES = ("general",)


def register_all() -> None:
for module_name in RECO_MODULES:
import_module(f"custom.reco.{module_name}")


__all__ = ["register_all"]
File renamed without changes.
7 changes: 3 additions & 4 deletions agent/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
from maa.agent.agent_server import AgentServer
from maa.toolkit import Toolkit

import my_action
import my_reco

import custom

def main():
Toolkit.init_option("./")
Expand All @@ -14,9 +12,10 @@ def main():
print("Usage: python main.py <socket_id>")
print("socket_id is provided by AgentIdentifier.")
sys.exit(1)

socket_id = sys.argv[-1]

custom.register_all()
AgentServer.start_up(socket_id)
AgentServer.join()
AgentServer.shut_down()
Expand Down
8 changes: 4 additions & 4 deletions docs/zh_cn/develop/how_to_develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@
git clone https://github.com/<你的用户名>/<你的项目名称>.git
```

2. 下载 OCR(文字识别)资源文件 [ppocr_v6.zip](https://download.maafw.xyz/MaaCommonAssets/OCR/ppocr_v6/ppocr_v6-small.zip) 解压到 `assets/resource/model/ocr/` 目录下,确保路径如下:
2. 下载 OCR(文字识别)资源文件 [ppocr_v6.zip](https://download.maafw.xyz/MaaCommonAssets/OCR/ppocr_v6/ppocr_v6-small.zip) 解压到 `resource/base/model/ocr/` 目录下,确保路径如下:

```tree
assets/resource/model/ocr/
resource/base/model/ocr/
├── det.onnx
├── keys.txt
└── rec.onnx
```

> [!WARNING]
> 请注意,您不需要将 OCR 资源文件上传到您的代码仓库中。`.gitignore` 已经忽略了 `assets/resource/model/ocr/` 目录,且 GitHub workflow 在发布版本时会自动配置这些资源文件。
> 请注意,您不需要将 OCR 资源文件上传到您的代码仓库中。`resource/base/model/.gitignore` 已经忽略了 `ocr/` 目录,且 GitHub workflow 在发布版本时会自动配置这些资源文件。

_如果希望使用其他版本的模型,可以参考 [这个说明](https://github.com/MaaXYZ/MaaCommonAssets/tree/main/OCR)。_

3. 进行开发工作。请参考 [MaaFramework 相关文档](https://maafw.com/docs/1.1-QuickStarted),并按您的业务需求修改 `assets` 目录下的 `resource` 资源文件以及 `interface.json` 文件,然后使用 [开发工具](https://maafw.com/docs/1.1-QuickStarted#%E8%B0%83%E8%AF%95) 进行调试。
3. 进行开发工作。请参考 [MaaFramework 相关文档](https://maafw.com/docs/1.1-QuickStarted),并按您的业务需求修改根目录 `interface.json`、`tasks/` 中的任务配置以及 `resource/base/` 中的资源文件,然后使用 [开发工具](https://maafw.com/docs/1.1-QuickStarted#%E8%B0%83%E8%AF%95) 进行调试。

通常来说,您**不需要**为您的项目单独开发一套 UI,本模板附带了自动配置 _通用 UI_ 的持续集成(CI),使用方法请参考后续步骤。

Expand Down
4 changes: 2 additions & 2 deletions docs/zh_cn/develop/pull_request_guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ PR 描述至少应包含以下信息:
## 验证

- [x] 执行 `npm ci && npx @nekosu/maa-tools check`
- [x] 执行 `python tools/validate_schema.py --schema-dir deps/tools --resource-dirs assets/resource --exclude-dirs assets/resource/announcement --interface-files assets/interface.json`
- [x] 执行 `python tools/validate_schema.py --exclude-dirs resource/base/announcement`
- [x] 检查文档链接可正常跳转
```

Expand All @@ -99,7 +99,7 @@ PR 描述至少应包含以下信息:
### 模板资源改动

- 坐标、ROI、模板图片等资源应遵循 MaaFramework 的 720p 基准约定。
- 新增任务或资源时,需要检查 `assets/interface.json`、`assets/resource` 与任务配置是否一致。
- 新增任务或资源时,需要检查 `interface.json`、`tasks/`、`resource/base/` 与任务配置是否一致。
- 不要提交本地缓存、运行产物、调试截图或下载得到的大体积模型文件。
- 修改 schema、资源目录或工作流时,需要说明对基于模板创建项目的影响。

Expand Down
Loading
Loading