diff --git a/Storage/skills/Windsland52/maafw-template-migration/README.md b/Storage/skills/Windsland52/maafw-template-migration/README.md index 4c679bb..8335813 100644 --- a/Storage/skills/Windsland52/maafw-template-migration/README.md +++ b/Storage/skills/Windsland52/maafw-template-migration/README.md @@ -1,18 +1,25 @@ # MaaFW Template Migration -MaaFramework 老项目迁移到 create-maa-project 脚手架的指南 skill。 +MaaFramework 老项目迁移到 create-maa-project(CMP)脚手架的指南 skill。 ## 用途 -当需要把一个旧的 MaaFW 项目(`assets/` + `deps/` 结构、`install*.py` 打包脚本)迁移到 CMP 模板(`maa-project.json` + `build-release.mjs` + `sync-runtime.mjs`)时使用。 +当需要把一个旧的 MaaFW 项目(`assets/` + `deps/` 结构、`install*.py` 打包脚本、手写 `interface.json`)迁移到 CMP 模板(`maa-project.json` + `interface.json` + `resource/base/` + `tasks/`),或把早前迁移过的项目同步到当前 CMP(add-on、schema v2、自带 Python 运行时的发布包)时使用。 ## 内容 -- `SKILL.md`: 迁移指南正文,包含结构映射、迁移步骤、常见坑 +- `SKILL.md`: 迁移指南正文,包含 CMP 当前的文件构成(base 与各 add-on)、结构映射、迁移步骤、OCR 两种供应方式、Agent 项目变更、迁移中真实踩到的坑 - `maahub_meta.json`: MaaHub 网站元信息 ## 适用场景 - 老项目从 assets/deps 结构迁移到 CMP 模板 - 需要了解新旧目录结构的对应关系 -- 迁移过程中遇到 ocr.files 配置、logo.ico、macOS bash 兼容等问题时参考 +- 迁移过程中遇到 `ocr.files` 方向、`logo.ico` 未提交、macOS bash 3.2 语法、schema v1 迁移等问题时参考 +- 判断 `interface.json` 该交给 `--sync` 维护,还是用 `project.interfaceUnmanaged` 自己管 + +## 校验基准 + +内容核对至 create-maa-project 3.5.1 与 MaaFramework 5.13.0,迁移案例取自 M9A。CMP 迭代较快(3.3.0 引入 add-on 体系、3.5.0 移除 `agent/bootstrap.py`),更早的迁移笔记可能已失效。 + +日常维护(新建项目、加 add-on、`--doctor`、`--update`)请用 CMP 自带的 `create-maa-project` skill 或 MCP 模式,本 skill 只覆盖迁移本身。 diff --git a/Storage/skills/Windsland52/maafw-template-migration/SKILL.md b/Storage/skills/Windsland52/maafw-template-migration/SKILL.md index 6437335..4795c2e 100644 --- a/Storage/skills/Windsland52/maafw-template-migration/SKILL.md +++ b/Storage/skills/Windsland52/maafw-template-migration/SKILL.md @@ -1,79 +1,184 @@ --- name: maafw-template-migration -description: Migrate a legacy MaaFramework project to the create-maa-project scaffold. Use when moving an old MAA-style project with assets/ + deps/ structure and install_*.py CI scripts to the CMP template (maa-project.json, build-release.mjs, sync-runtime.mjs). +description: Migrate a legacy MaaFramework project (assets/ + deps/ layout, install_*.py packaging CI, hand-written interface.json) onto the create-maa-project (CMP) scaffold, and re-sync a project that was migrated against an older CMP. Use when moving an old MAA-style project to maa-project.json + add-on managed templates, when enabling add-ons (dev-tools, github, agent, resource-pack) on an existing project, or when a migrated project needs --doctor / --sync / --update. Trigger even when the user just says "迁移到新模板", "换成 create-maa-project 结构", or "CMP 项目升级". --- # MaaFramework Project Template Migration -Guide for migrating legacy MaaFW projects to the create-maa-project (CMP) scaffold. +Guide for moving legacy MaaFW projects onto the [create-maa-project](https://github.com/Windsland52/create-maa-project) +(CMP) scaffold, and for re-syncing a project that was migrated against an older CMP. + +Verified against CMP 3.5.1 and MaaFramework 5.13.0. CMP has restructured repeatedly (add-ons in 3.3.0, +bundled Python runtime in 3.5.0), so treat any migration note older than this file as suspect. ## When to use -- Old project has `assets/` (resource + interface.json), `deps/` (MaaFramework binaries), `install*.py` (packaging scripts, possibly under `tools/` or `tools/ci/`) -- Moving to CMP's `maa-project.json` + `tools/build-release.mjs` + `tools/sync-runtime.mjs` +- Old project has `assets/` (resource + interface.json), `deps/` (MaaFramework binaries), `install*.py` + packaging scripts, and a hand-written `interface.json` +- Target is CMP's layout: `maa-project.json` + `interface.json` + `resource/base/` + `tasks/`, maintained + by `--add` / `--sync` / `--update` / `--doctor` +- A previously migrated project needs to be brought up to the current CMP (add-ons, Python runtime, schema v2) + +## What CMP generates now + +CMP writes a small always-on **base** plus opt-in **add-ons**. Know which is which before copying files: +`managed` files are refreshed by `--update`/`--sync`; `once` files are written at creation and then belong +to the project. + +| Layer | Files | +|---|---| +| base (always) | `maa-project.json`, `interface.json`, `tasks/`, `resource/base/` (`default_pipeline.json`, `pipeline/`, `image/`, `model/ocr/`), `maatools.config.mts`, `.editorconfig`, `.gitattributes`, `.gitignore`, `README*`, `LICENSE` | +| `dev-tools` | `package.json`, `pnpm-workspace.yaml`, `.node-version`, `.prettierrc.mjs`, `.prettierignore`, `tools/validate-schema.mjs`, `tools/schema/*` | +| `vscode` | `.vscode/settings.json`, `extensions.json`, `tasks.json` (+ `launch.json` for agent projects) | +| `github` | `.github/workflows/{release,check,package-smoke}.yml`, `tools/build-release.mjs`, `tools/sync-runtime.mjs`; adds `release:dry-run`, `sync:runtime` scripts | +| `agent` | `agent/` (`main.py`, `agent_runtime.py`, `custom/`, `utils/`), `pyproject.toml`, `requirements.in`, `requirements.txt`, `uv.lock` | +| `resource-pack` | `resource//` plus the `resources` entry in `maa-project.json` and `interface.json` | +| optional | `git-cliff`, `auto-format`, `optimize-images`, `community`, `dependabot`, `schema-sync` | + +Add-on dependencies resolve automatically: `vscode`, `github`, `agent` require `dev-tools`; `agent` also +requires `vscode`; `git-cliff`, `auto-format`, `optimize-images`, `community`, `dependabot`, `schema-sync` +require `github`. Since 3.3.0 `--add dev-tools` no longer writes `.vscode/` — ask for `--add vscode`. ## Migration workflow -### 1. Scaffold a fresh CMP project +### 1. Scaffold explicitly -In a new directory, run CMP to generate a clean project skeleton: +CMP requires Node >= 22.13 (`npm i -g create-maa-project`, or `npx create-maa-project@latest`). Run with +explicit flags — never rely on interactive prompts, and never let an agent drive the TUI: ```bash -pnpm dlx create-maa-project@latest +npx create-maa-project@latest ./my-project --template agent \ + --slug my-project --name "我的项目" --controller Adb,Win32 \ + --add dev-tools --add github --yes --no-interactive ``` -Select template (agent or pipeline-only), GUI types, OCR source, etc. This generates `maa-project.json`, `interface.json`, `tools/build-release.mjs`, `tools/sync-runtime.mjs`, `.github/workflows/release.yml`, `package.json`, `.gitignore`, and other boilerplate. Keep these generated files as the base — do not overwrite them with old project files. +- Replace these values with your own project's identity; `--slug` is the ASCII project ID written to + `project.slug` and to `interface.json` `name`, while `--name` is only the display label. +- `--template pipeline|agent`; `--controller` kinds are `Adb`, `Win32`, `MacOS`, `PlayCover`, `Gamepad`, `Linux`. +- Set `CREATE_MAA_PROJECT_OCR_SOURCE=submodule|download` explicitly. Otherwise the OCR layout depends on + whether Git is available in the creation directory, so the same command builds different projects on + different machines. +- Add `--report` on maintenance commands and parse stdout as JSON (`pending`, `suggestedCommands`, `written`, + `doctor.checks`, `backupId`). +- CMP ships its own agent skill and an MCP mode (`--mcp --root `). Install the skill for day-to-day + maintenance instead of recreating its guidance here; this skill only covers the migration itself. -### 2. Migrate old content into the scaffolded structure - -Bring over only project-specific content from the old project: +### 2. Map old content into the scaffold | Old | New | Notes | |---|---|---| -| `assets/resource/` | `resource/base/` | Drop `assets/`, rename `resource` to `base` | -| `assets/resource_bilibili/` | `resource/bilibili/` | Same pattern for each variant | -| `assets/interface.json` | `interface.json` (root) | Overwrite the CMP-generated one, but keep the `version` field CMP added | -| `tasks/` | `tasks/` | Usually direct copy | -| Old agent code | `agent/` | If using agent template; update hardcoded paths | - -### 3. Configure maa-project.json - -Fill in project-specific settings: GUI types and channels, resource packs, controllers, OCR source, Python version. CMP generates a template but it needs real values. - -### 4. Extract non-MaaFW-bundle content from resource - -Old projects often keep everything under `resource/` — images, pipeline JSON, AND hot-update data. In the new structure, anything that is not part of the MaaFW bundle (images, models, pipeline) should be pulled out of `resource/`. For example, if old `resource/data/` contains hot-update data, it moves to top-level `data/`. Whether this data involves manifest caching depends on the project — CMP does not assume either way. +| `assets/resource/` | `resource/base/` | Drop the `assets/` wrapper | +| `assets/resource_/` | `resource//` | Declare with `--add resource-pack --label "