From eab6cafb503652c1e6203a493cc3ea37faed4fe1 Mon Sep 17 00:00:00 2001 From: Craun718 <3653544699@qq.com> Date: Fri, 4 Sep 2026 18:32:40 +0800 Subject: [PATCH] feat: restructure project template layout Move interface, task, resource, and schema files to root-level template directories. Update tooling, workflows, docs, and custom agent imports for the new paths. Add TypeScript config and a typecheck script. --- .github/workflows/check.yml | 16 +++-- .github/workflows/install.yml | 20 +++--- .github/workflows/sync_schema_files.yml | 28 ++++----- .gitignore | 5 +- .prettierignore | 2 +- .vscode/settings.json | 22 ++++--- README.md | 10 +++ agent/custom/__init__.py | 15 +++++ agent/custom/action/__init__.py | 11 ++++ .../action/general.py} | 0 agent/custom/reco/__init__.py | 11 ++++ agent/{my_reco.py => custom/reco/general.py} | 0 agent/main.py | 7 +-- docs/zh_cn/develop/how_to_develop.md | 8 +-- docs/zh_cn/develop/pull_request_guidelines.md | 4 +- assets/interface.json => interface.json | 61 +++---------------- maatools.config.mts | 2 +- package-lock.json | 23 ++++++- package.json | 6 +- .../base}/image/empty.png | 0 .../base}/model/.gitignore | 0 .../base}/pipeline/my_task.json | 2 +- tasks/my_task.json | 50 +++++++++++++++ tools/configure.py | 14 ++--- tools/install.py | 9 ++- .../schema}/custom.action.schema.json | 0 .../schema}/custom.recognition.schema.json | 0 .../schema}/interface.schema.json | 0 .../schema}/interface_config.schema.json | 0 .../schema}/interface_import.schema.json | 0 .../schema}/pipeline.schema.json | 0 tools/validate_schema.py | 12 ++-- tsconfig.json | 12 ++++ 33 files changed, 230 insertions(+), 120 deletions(-) create mode 100644 agent/custom/__init__.py create mode 100644 agent/custom/action/__init__.py rename agent/{my_action.py => custom/action/general.py} (100%) create mode 100644 agent/custom/reco/__init__.py rename agent/{my_reco.py => custom/reco/general.py} (100%) rename assets/interface.json => interface.json (60%) rename {assets/resource => resource/base}/image/empty.png (100%) rename {assets/resource => resource/base}/model/.gitignore (100%) rename {assets/resource => resource/base}/pipeline/my_task.json (99%) create mode 100644 tasks/my_task.json rename {deps/tools => tools/schema}/custom.action.schema.json (100%) rename {deps/tools => tools/schema}/custom.recognition.schema.json (100%) rename {deps/tools => tools/schema}/interface.schema.json (100%) rename {deps/tools => tools/schema}/interface_config.schema.json (100%) rename {deps/tools => tools/schema}/interface_import.schema.json (100%) rename {deps/tools => tools/schema}/pipeline.schema.json (100%) create mode 100644 tsconfig.json diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index bdd3d656..22297aa5 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -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: @@ -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 diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index e8ae2930..98f25006 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -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: @@ -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 diff --git a/.github/workflows/sync_schema_files.yml b/.github/workflows/sync_schema_files.yml index 68835795..198dc142 100644 --- a/.github/workflows/sync_schema_files.yml +++ b/.github/workflows/sync_schema_files.yml @@ -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 @@ -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" diff --git a/.gitignore b/.gitignore index e4d51e33..34c67789 100644 --- a/.gitignore +++ b/.gitignore @@ -441,9 +441,6 @@ enc_temp_folder/* # Build deps/* -!deps/tools/ -deps/tools/* -!deps/tools/*.schema.json build install @@ -451,4 +448,4 @@ install tools/ImageCropper/**/*.png config -debug \ No newline at end of file +debug diff --git a/.prettierignore b/.prettierignore index 75ae29a8..9595b234 100644 --- a/.prettierignore +++ b/.prettierignore @@ -6,7 +6,7 @@ node_modules/ assets/MaaCommonAssets # 跳过 schema 目录,避免与 sync_schema_files 冲突 -deps/tools/ +tools/schema/ # 锁文件 pnpm-lock.yaml diff --git a/.vscode/settings.json b/.vscode/settings.json index c9e1bc86..e2c69671 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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, diff --git a/README.md b/README.md index 279e2c73..c3ab3b08 100644 --- a/README.md +++ b/README.md @@ -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)。 ## 生态共建 diff --git a/agent/custom/__init__.py b/agent/custom/__init__.py new file mode 100644 index 00000000..cfa04133 --- /dev/null +++ b/agent/custom/__init__.py @@ -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"] diff --git a/agent/custom/action/__init__.py b/agent/custom/action/__init__.py new file mode 100644 index 00000000..73aed36b --- /dev/null +++ b/agent/custom/action/__init__.py @@ -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"] diff --git a/agent/my_action.py b/agent/custom/action/general.py similarity index 100% rename from agent/my_action.py rename to agent/custom/action/general.py diff --git a/agent/custom/reco/__init__.py b/agent/custom/reco/__init__.py new file mode 100644 index 00000000..41978a27 --- /dev/null +++ b/agent/custom/reco/__init__.py @@ -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"] diff --git a/agent/my_reco.py b/agent/custom/reco/general.py similarity index 100% rename from agent/my_reco.py rename to agent/custom/reco/general.py diff --git a/agent/main.py b/agent/main.py index 63dbd14f..70d057a8 100644 --- a/agent/main.py +++ b/agent/main.py @@ -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("./") @@ -14,9 +12,10 @@ def main(): print("Usage: python main.py ") 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() diff --git a/docs/zh_cn/develop/how_to_develop.md b/docs/zh_cn/develop/how_to_develop.md index cb594a52..7a9a065d 100644 --- a/docs/zh_cn/develop/how_to_develop.md +++ b/docs/zh_cn/develop/how_to_develop.md @@ -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),使用方法请参考后续步骤。 diff --git a/docs/zh_cn/develop/pull_request_guidelines.md b/docs/zh_cn/develop/pull_request_guidelines.md index b58644cd..d4d24ed4 100644 --- a/docs/zh_cn/develop/pull_request_guidelines.md +++ b/docs/zh_cn/develop/pull_request_guidelines.md @@ -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] 检查文档链接可正常跳转 ``` @@ -99,7 +99,7 @@ PR 描述至少应包含以下信息: ### 模板资源改动 - 坐标、ROI、模板图片等资源应遵循 MaaFramework 的 720p 基准约定。 -- 新增任务或资源时,需要检查 `assets/interface.json`、`assets/resource` 与任务配置是否一致。 +- 新增任务或资源时,需要检查 `interface.json`、`tasks/`、`resource/base/` 与任务配置是否一致。 - 不要提交本地缓存、运行产物、调试截图或下载得到的大体积模型文件。 - 修改 schema、资源目录或工作流时,需要说明对基于模板创建项目的影响。 diff --git a/assets/interface.json b/interface.json similarity index 60% rename from assets/interface.json rename to interface.json index 85010847..09f2081b 100644 --- a/assets/interface.json +++ b/interface.json @@ -40,70 +40,25 @@ { "name": "官服", "path": [ - "./resource" + "./resource/base" ] }, { "name": "B 服", "path": [ - "./resource" - // "./resource_bilibili" + "./resource/base" + // "./resource/bilibili" ] } ], + "import": [ + "./tasks/my_task.json" + ] // 可选的 agent 示例 // "agent": { // "child_exec": "python", // "child_args": [ // "./agent/main.py" // ] - // }, - "task": [ - { - "name": "普通任务", - "entry": "MyTask1" - }, - { - "name": "选项任务", - "entry": "MyTask2", - "option": [ - "任务选项1" - ] - }, - { - "name": "参数任务", - "entry": "MyTask3", - "option": [ - "任务选项1" - ], - "pipeline_override": {} - }, - { - "name": "带Custom的任务", - "entry": "MyTask4" - } - ], - "option": { - "任务选项1": { - "type": "select", - "cases": [ - { - "name": "文本1", - "pipeline_override": { - "OcrTask": { - "text": "文本1" - } - } - }, - { - "name": "文本2", - "pipeline_override": { - "OcrTask": { - "text": "文本2" - } - } - } - ] - } - } -} \ No newline at end of file + // } +} diff --git a/maatools.config.mts b/maatools.config.mts index 9788e5f0..78dafb8b 100644 --- a/maatools.config.mts +++ b/maatools.config.mts @@ -3,7 +3,7 @@ import type { FullConfig } from '@nekosu/maa-tools' const config: FullConfig = { cwd: import.meta.dirname, maaVersion: 'latest', - interfacePath: 'assets/interface.json', + interfacePath: 'interface.json', check: { override: { // 忽略 mpe-config 带来的报错 diff --git a/package-lock.json b/package-lock.json index f0717484..85a1966d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,8 @@ "devDependencies": { "@nekosu/maa-tools": "1.0.23", "@types/node": "^25.5.2", - "prettier-plugin-multiline-arrays": "^3.0.6" + "prettier-plugin-multiline-arrays": "^3.0.6", + "typescript": "^5.9.3" } }, "node_modules/@actions/core": { @@ -1487,6 +1488,20 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://mirrors.tencent.com/npm/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/undici": { "version": "6.24.1", "resolved": "https://registry.npmjs.org/undici/-/undici-6.24.1.tgz", @@ -2603,6 +2618,12 @@ "integrity": "sha512-jXMwges/FVbFRe5lTMJZVEZCrO9kI9c8k0PA/z7nF3bo0JSCCLysvokFjNPIUK/itEMas10MQM+AiHoHt/T/XA==", "dev": true }, + "typescript": { + "version": "5.9.3", + "resolved": "https://mirrors.tencent.com/npm/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true + }, "undici": { "version": "6.24.1", "resolved": "https://registry.npmjs.org/undici/-/undici-6.24.1.tgz", diff --git a/package.json b/package.json index b95fe903..48d9f05c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,11 @@ { + "scripts": { + "typecheck": "tsc -p tsconfig.json --noEmit" + }, "devDependencies": { "@nekosu/maa-tools": "1.0.23", "@types/node": "^25.5.2", - "prettier-plugin-multiline-arrays": "^3.0.6" + "prettier-plugin-multiline-arrays": "^3.0.6", + "typescript": "^5.9.3" } } diff --git a/assets/resource/image/empty.png b/resource/base/image/empty.png similarity index 100% rename from assets/resource/image/empty.png rename to resource/base/image/empty.png diff --git a/assets/resource/model/.gitignore b/resource/base/model/.gitignore similarity index 100% rename from assets/resource/model/.gitignore rename to resource/base/model/.gitignore diff --git a/assets/resource/pipeline/my_task.json b/resource/base/pipeline/my_task.json similarity index 99% rename from assets/resource/pipeline/my_task.json rename to resource/base/pipeline/my_task.json index 54765ca5..d3c42edb 100644 --- a/assets/resource/pipeline/my_task.json +++ b/resource/base/pipeline/my_task.json @@ -9,4 +9,4 @@ "custom_action": "my_action_111" }, "OcrTask": {} -} \ No newline at end of file +} diff --git a/tasks/my_task.json b/tasks/my_task.json new file mode 100644 index 00000000..76a4d915 --- /dev/null +++ b/tasks/my_task.json @@ -0,0 +1,50 @@ +{ + "task": [ + { + "name": "普通任务", + "entry": "MyTask1" + }, + { + "name": "选项任务", + "entry": "MyTask2", + "option": [ + "任务选项1" + ] + }, + { + "name": "参数任务", + "entry": "MyTask3", + "option": [ + "任务选项1" + ], + "pipeline_override": {} + }, + { + "name": "带Custom的任务", + "entry": "MyTask4" + } + ], + "option": { + "任务选项1": { + "type": "select", + "cases": [ + { + "name": "文本1", + "pipeline_override": { + "OcrTask": { + "text": "文本1" + } + } + }, + { + "name": "文本2", + "pipeline_override": { + "OcrTask": { + "text": "文本2" + } + } + } + ] + } + } +} diff --git a/tools/configure.py b/tools/configure.py index 6ae517d5..6ae1e72d 100644 --- a/tools/configure.py +++ b/tools/configure.py @@ -2,19 +2,19 @@ import shutil -assets_dir = Path(__file__).parent.parent.resolve() / "assets" +project_root = Path(__file__).parent.parent.resolve() def configure_ocr_model(): - assets_ocr_dir = assets_dir / "MaaCommonAssets" / "OCR" - if not assets_ocr_dir.exists(): - print(f"File Not Found: {assets_ocr_dir}") + source_ocr_dir = project_root / "assets" / "MaaCommonAssets" / "OCR" + if not source_ocr_dir.exists(): + print(f"File Not Found: {source_ocr_dir}") exit(1) - ocr_dir = assets_dir / "resource" / "model" / "ocr" - if not ocr_dir.exists(): # copy default OCR model only if dir does not exist + ocr_dir = project_root / "resource" / "base" / "model" / "ocr" + if not ocr_dir.exists(): # copy default OCR model only if dir does not exist shutil.copytree( - assets_dir / "MaaCommonAssets" / "OCR" / "ppocr_v6" / "small", + source_ocr_dir / "ppocr_v6" / "small", ocr_dir, dirs_exist_ok=True, ) diff --git a/tools/install.py b/tools/install.py index 2a8399ae..d543d26a 100644 --- a/tools/install.py +++ b/tools/install.py @@ -104,12 +104,17 @@ def install_resource(): configure_ocr_model() shutil.copytree( - working_dir / "assets" / "resource", + working_dir / "resource", install_path / "resource", dirs_exist_ok=True, ) + shutil.copytree( + working_dir / "tasks", + install_path / "tasks", + dirs_exist_ok=True, + ) shutil.copy2( - working_dir / "assets" / "interface.json", + working_dir / "interface.json", install_path, ) diff --git a/deps/tools/custom.action.schema.json b/tools/schema/custom.action.schema.json similarity index 100% rename from deps/tools/custom.action.schema.json rename to tools/schema/custom.action.schema.json diff --git a/deps/tools/custom.recognition.schema.json b/tools/schema/custom.recognition.schema.json similarity index 100% rename from deps/tools/custom.recognition.schema.json rename to tools/schema/custom.recognition.schema.json diff --git a/deps/tools/interface.schema.json b/tools/schema/interface.schema.json similarity index 100% rename from deps/tools/interface.schema.json rename to tools/schema/interface.schema.json diff --git a/deps/tools/interface_config.schema.json b/tools/schema/interface_config.schema.json similarity index 100% rename from deps/tools/interface_config.schema.json rename to tools/schema/interface_config.schema.json diff --git a/deps/tools/interface_import.schema.json b/tools/schema/interface_import.schema.json similarity index 100% rename from deps/tools/interface_import.schema.json rename to tools/schema/interface_import.schema.json diff --git a/deps/tools/pipeline.schema.json b/tools/schema/pipeline.schema.json similarity index 100% rename from deps/tools/pipeline.schema.json rename to tools/schema/pipeline.schema.json diff --git a/tools/validate_schema.py b/tools/validate_schema.py index b1f6ab71..ebaaeeff 100644 --- a/tools/validate_schema.py +++ b/tools/validate_schema.py @@ -221,8 +221,8 @@ def main(): "--resource-dirs", type=str, nargs="+", - default=["assets/resource"], - help="Directories containing resource files to validate (default: assets/resource)", + default=["resource/base"], + help="Directories containing resource files to validate (default: resource/base)", ) parser.add_argument( "--exclude-dirs", @@ -235,15 +235,15 @@ def main(): "--interface-files", type=str, nargs="+", - default=["assets/interface.json"], - help="Path to interface.json files (default: assets/interface.json)", + default=["interface.json"], + help="Path to interface.json files (default: interface.json)", ) parser.add_argument( "--task-dirs", type=str, nargs="*", - default=[], - help="Directories containing task files to validate against interface_import.schema.json (default: none)", + default=["tasks"], + help="Directories containing task files to validate against interface_import.schema.json (default: tasks)", ) args = parser.parse_args() diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..7b2c00e6 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "strict": true, + "skipLibCheck": true, + "noEmit": true, + "types": ["node"] + }, + "include": ["maatools.config.mts"] +}