Skip to content

Commit 783e700

Browse files
authored
Merge pull request #11 from MaaXYZ/feat/skill-template-migration
feat(skills): add maafw-template-migration skill
2 parents f795b9c + 3b7e0fa commit 783e700

3 files changed

Lines changed: 115 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# MaaFW Template Migration
2+
3+
MaaFramework 老项目迁移到 create-maa-project 脚手架的指南 skill。
4+
5+
## 用途
6+
7+
当需要把一个旧的 MaaFW 项目(`assets/` + `deps/` 结构、`install*.py` 打包脚本)迁移到 CMP 模板(`maa-project.json` + `build-release.mjs` + `sync-runtime.mjs`)时使用。
8+
9+
## 内容
10+
11+
- `SKILL.md`: 迁移指南正文,包含结构映射、迁移步骤、常见坑
12+
- `maahub_meta.json`: MaaHub 网站元信息
13+
14+
## 适用场景
15+
16+
- 老项目从 assets/deps 结构迁移到 CMP 模板
17+
- 需要了解新旧目录结构的对应关系
18+
- 迁移过程中遇到 ocr.files 配置、logo.ico、macOS bash 兼容等问题时参考
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
name: maafw-template-migration
3+
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).
4+
---
5+
6+
# MaaFramework Project Template Migration
7+
8+
Guide for migrating legacy MaaFW projects to the create-maa-project (CMP) scaffold.
9+
10+
## When to use
11+
12+
- Old project has `assets/` (resource + interface.json), `deps/` (MaaFramework binaries), `install*.py` (packaging scripts, possibly under `tools/` or `tools/ci/`)
13+
- Moving to CMP's `maa-project.json` + `tools/build-release.mjs` + `tools/sync-runtime.mjs`
14+
15+
## Migration workflow
16+
17+
### 1. Scaffold a fresh CMP project
18+
19+
In a new directory, run CMP to generate a clean project skeleton:
20+
21+
```bash
22+
pnpm dlx create-maa-project@latest
23+
```
24+
25+
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.
26+
27+
### 2. Migrate old content into the scaffolded structure
28+
29+
Bring over only project-specific content from the old project:
30+
31+
| Old | New | Notes |
32+
|---|---|---|
33+
| `assets/resource/` | `resource/base/` | Drop `assets/`, rename `resource` to `base` |
34+
| `assets/resource_bilibili/` | `resource/bilibili/` | Same pattern for each variant |
35+
| `assets/interface.json` | `interface.json` (root) | Overwrite the CMP-generated one, but keep the `version` field CMP added |
36+
| `tasks/` | `tasks/` | Usually direct copy |
37+
| Old agent code | `agent/` | If using agent template; update hardcoded paths |
38+
39+
### 3. Configure maa-project.json
40+
41+
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.
42+
43+
### 4. Extract non-MaaFW-bundle content from resource
44+
45+
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.
46+
47+
### 5. Clean up obsolete paths
48+
49+
- `deps/` directory: MaaFramework runtime binaries are now downloaded by `sync:runtime``deps/` is not needed
50+
- Old `install*.py` scripts: replaced by `tools/build-release.mjs`
51+
- `assets/` wrapper: gone, content moved to root-level directories
52+
53+
## OCR models
54+
55+
If using MaaCommonAssets submodule for OCR, `resource/base/model/ocr/` is generated by `sync:runtime` and should be gitignored. If managing OCR models manually (committed files), do not gitignore.
56+
57+
## Agent code path updates
58+
59+
If the project has a Python agent, check for hardcoded paths after migration:
60+
61+
- Any `assets/` references in agent code need updating to new layout
62+
- If data moved out of `resource/`, update paths in `runtime_paths.py` or equivalent
63+
- `bootstrap.py` Python version check must match `pyproject.toml` `requires-python`
64+
65+
## interface.json
66+
67+
- Keep the `"version"` field (CMP adds it, build-release requires it)
68+
- CMP does not manage this file — controller/resource entries must match `maa-project.json` manually (lint warns but allows drift)
69+
70+
## Common pitfalls
71+
72+
1. **ocr.files key order**: CMP expects `{"destName": "srcRel"}` (destination filename to source path within submodule). Inverted = ENOENT on sync. Only relevant if `ocr.source = "submodule"`.
73+
2. **logo.ico not in git**: if the release workflow checks `hashFiles('logo.ico')`, the ico file must be committed — a generated or gitignored ico will cause the icon step to be silently skipped.
74+
3. **macOS bash 3.2**: GitHub macOS runners use bash 3.2 — no `${var^^}`, use `tr a-z A-Z` for uppercase in workflow scripts.
75+
4. **CMP version pinning**: `pnpm dlx create-maa-project@latest` may resolve to a stale version; pin in `pnpm-workspace.yaml` `minimumReleaseAgeExclude`.
76+
77+
## Backporting to create-maa-project
78+
79+
Generic fixes discovered during migration should be backported to CMP templates. Project-specific logic (private module downloads, specific mirrorchyan_rid values, manifest cache generation) stays in the project repo.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"id": "Windsland52/maafw-template-migration",
3+
"title": "MaaFW Template Migration",
4+
"description": "Guide for migrating legacy MaaFramework projects (assets/ + deps/ structure, install*.py CI) to the create-maa-project scaffold (maa-project.json, build-release.mjs, sync-runtime.mjs).",
5+
"author": "Windsland52",
6+
"source": "M9A",
7+
"sourceGithub": "https://github.com/MAA1999/M9A",
8+
"tags": ["migration", "create-maa-project", "template", "skill"],
9+
"createdAt": "2026-07-07",
10+
"updatedAt": "2026-07-07",
11+
"version": "0.1.0",
12+
"mfwVersion": "5.11.1",
13+
"entry": "SKILL.md",
14+
"readme": "./README.md",
15+
"status": "beta",
16+
"type": "skill",
17+
"category": "migration"
18+
}

0 commit comments

Comments
 (0)