@buaa_smat/hometrans 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,213 +1,229 @@
1
- # hometrans
2
-
3
- > Skill + agent installer for the **HomeTrans** Android-to-HarmonyOS conversion toolkit. One command (`ht init`) distributes **7 skills**, **9 subagents** (with a script bundle + on-device test tooling), and an **MCP server** into Claude Code, Cursor, OpenCode, and Codex.
4
-
5
- ---
6
-
7
- ## Install
8
-
9
- Global install — exposes both `hometrans` and the short alias `ht` on `PATH`:
10
-
11
- ```bash
12
- npm install -g @buaa_smat/hometrans
13
- ht init
14
- ```
15
-
16
- Requires Node.js **>= 18**.
17
-
18
- ---
19
-
20
- ## Setup Guide
21
-
22
- After running `ht init`, follow these steps to complete the installation:
23
-
24
- ### Step 1: Choose your target editor
25
-
26
- `ht init` automatically detects supported editors (Claude Code, Cursor, OpenCode, Codex) and presents an interactive selection prompt. Use **Space** to toggle and **Enter** to confirm.
27
-
28
- ![Choose target editor](resource/choose_editor.png)
29
-
30
- ### Step 2: Finish initialization
31
-
32
- After confirming your editor selection, HomeTrans installs all bundled **skills**, **agents**, and the **MCP server** into each selected editor's configuration directory. The installation is idempotent — re-running `ht init` overwrites only bundled content.
33
-
34
- ![Finish initialization](resource/finish_init.png)
35
-
36
- > **Tip:** Run `ht init --all` to skip the editor prompt and install to every detected editor automatically.
37
-
38
- ---
39
-
40
- ## Dependencies
41
-
42
- Install GitNexus (code knowledge graph dependency required by the migration agents):
43
-
44
- ```bash
45
- npm install -g gitnexus
46
- gitnexus setup
47
- ```
48
-
49
- For more details, see the official GitNexus repository: <https://github.com/abhigyanpatwari/GitNexus>
50
-
51
- ---
52
-
53
- ## HarmonyOS Migration Guide
54
-
55
- 鸿蒙软件迁移指导,提供完整的 Android 到 HarmonyOS 迁移流程:
56
-
57
- ### Step 1: Resource Conversion (资源转换)
58
-
59
- > `hmos-batch-ui-align` 内部会自动调用资源转换;如果是批量UI迁移场景则可跳过此步骤。
60
-
61
- 将 Android 资源文件(图片、字符串、颜色、尺寸等)转换为 HarmonyOS 格式。
62
-
63
- ```
64
- /hmos-resources-convert android-project-path=<安卓项目路径> harmonyos-project-path=<鸿蒙项目路径> resource_mapping_path=<资源映射文档路径>
65
- ```
66
-
67
- | 参数 | 类型 | 说明 |
68
- |------|------|------|
69
- | `android-project-path` | **必选** | Android 项目根目录路径(含 `build.gradle` 或 `build.gradle.kts`) |
70
- | `harmonyos-project-path` | **必选** | HarmonyOS 项目输出路径 |
71
- | `resource_mapping_path` | **必选** | Android ↔ HarmonyOS 资源映射文档的完整输出路径(`.md`) |
72
- | `apk-path` | 可选 | Android APK 文件路径;提供后跳过 Gradle 构建和 apktool 解包步骤,直接从 APK 提取资源 |
73
-
74
- ### Step 2: UI Migration (UI迁移)
75
-
76
- 运行以下命令之一完成 Android UI 的全量或增量迁移。
77
-
78
- #### 全量迁移 — `hmos-batch-ui-align`
79
-
80
- ```
81
- /hmos-batch-ui-align android_project_dir=<安卓项目路径> harmony_project_dir=<鸿蒙项目路径> ui_info_root=<页面快照目录>
82
- ```
83
-
84
- | 参数 | 类型 | 说明 |
85
- |------|------|------|
86
- | `android_project_dir` | **必选** | Android 项目根目录路径 |
87
- | `harmony_project_dir` | **必选** | HarmonyOS 项目输出路径 |
88
- | `ui_info_root` | 可选 | 包含 `page_NNNN_ActivityName` 格式子目录的父目录路径(每子目录含 `meta.json` + `view.xml` + 可选 `screenshot.png`);不提供时 skill 自动通过 ADB 抓取 |
89
- | `pages` | 可选 | 显式列出的页面子集(如不提供则处理所有页面) |
90
-
91
- #### 增量迁移 — `hmos-incremental-ui-align`
92
-
93
- 项目路径通过 `config.json` 文件配置(参考 skill 目录下的 `config-example.json`),对齐目标在消息中描述(如 "帮我对齐设置页面的关于页面")。
94
-
95
- ```
96
- /hmos-incremental-ui-align config-path=<config.json路径>
97
- ```
98
-
99
- | 参数 | 类型 | 说明 |
100
- |------|------|------|
101
- | `config-path` | **必选** | `config.json` 文件路径,包含 `android.project_dir`, `harmony.project_dir`, `hmos_sdk_dir`, `glm_api_key`, `capture_output_dir` 等字段 |
102
-
103
- ### Step 3: Generate Spec (生成需求规格)
104
-
105
- 运行 `hmos-spec-generate` 从原始需求描述 `.txt` 文件生成原子场景需求规格文档。
106
-
107
- ```
108
- /hmos-spec-generate requirement-description-file=<需求描述文件路径> android-project-path=<安卓项目路径> spec-output-dir=<规格输出目录>
109
- ```
110
-
111
- | 参数 | 类型 | 说明 |
112
- |------|------|------|
113
- | `requirement-description-file` | **必选** | 需求描述 `.txt` 文件路径(每段以 `REQ` 开头,空行分隔) |
114
- | `android-project-path` | **必选** | Android 项目根目录路径(必须位于 Git 仓库内) |
115
- | `spec-output-dir` | **必选** | 规格文档输出目录(自动创建;每个 REQ 生成 `<feature>-SPEC.md` + `.trace/<feature>.md`) |
116
-
117
- ### Step 4: Convert Pipeline (逻辑代码开发)
118
-
119
- 运行 `hmos-convert-pipeline` 完成后续的逻辑代码开发、代码检视、集成测试流程。
120
-
121
- ```
122
- /hmos-convert-pipeline android-project-path=<安卓项目路径> harmonyos-project-path=<鸿蒙项目路径> assets-output-path=<输出报告目录>
123
- ```
124
-
125
- | 参数 | 类型 | 说明 |
126
- |------|------|------|
127
- | `android-project-path` | **必选** | Android 项目根目录路径 |
128
- | `harmonyos-project-path` | **必选** | HarmonyOS 项目根目录路径 |
129
- | `assets-output-path` | **必选** | 输出/报告文件的存放目录(需包含 `plan.md` 需求规格文件) |
130
- | `max-rounds-review` | 可选 | 代码检视循环最大轮数(正整数 `>= 1`,默认 `2`) |
131
- | `max-rounds-test` | 可选 | 自测循环最大轮数(正整数 `>= 1`,默认 `2`) |
132
- | `skip-test` | 可选 | `true` 跳过集成测试阶段(无真机验证环境时需要设置为true,默认 `false`) |
133
-
134
- ---
135
-
136
- ## Commands
137
-
138
- | Command | Description |
139
- |---------|-------------|
140
- | `ht init` | Interactive setup: detect installed editors, prompt for SDK paths + test API key, copy skills/agents to target directories, seed/refresh autotest `config.yaml`, register MCP server |
141
- | `ht mcp` | Start the HomeTrans MCP server (stdio mode), exposing the `extract_commit_context` tool |
142
- | `ht config` | Display `~/.hometrans/config.json` path, parameters (with masked API key), and full content (read-only; edit the file directly, then re-run `ht init`) |
143
- | `ht uninstall` | Remove all skills, agents, and MCP entries installed by `ht init` from configured editors |
144
- | `ht --version` | Show installed version |
145
- | `ht --help` | List all commands |
146
-
147
- > `hometrans` and `ht` are fully equivalent — both point to the same CLI entry.
148
-
149
- ---
150
-
151
- ## What `ht init` does
152
-
153
- 1. **Detects** each supported editor by checking whether its standard config directory exists under `$HOME`, then lets you select which ones to configure (detected editors are pre-checked). Use `ht init --all` to skip the prompt and select every editor.
154
- 2. **Prompts for user parameters** and stores them in `~/.hometrans/config.json` (press Enter to keep the current value or leave empty):
155
- - `OHOS_SDK_PATH` OpenHarmony SDK ETS path
156
- - `HMS_SDK_PATH` — HMS SDK ETS path
157
- - `TEST_API_KEY`API key written into the autotest `config.yaml`
158
- These are stored under a single `env` object in `~/.hometrans/config.json` (alongside `TOOL_PATH`, set in the next step).
159
- 3. **Installs bundled tools** to `~/.hometrans/tools` (the AutoTest toolchain lives at `~/.hometrans/tools/test-tools/autotest`) and records the destination as `env.TOOL_PATH` in `~/.hometrans/config.json`. Agents/skills resolve the AutoTest dir from `env.TOOL_PATH`.
160
- 4. **Seeds/refreshes the autotest config**: if `<TOOL_PATH>/test-tools/autotest/config.yaml` is missing it is created from `config.yaml.example`, and every `api_key:` line is filled with the supplied `TEST_API_KEY`.
161
- 5. For every selected editor, **copies**:
162
- - every skill folder under `skills/` (those containing a `SKILL.md`) → `<editor>/skills/<skill-name>/` (recursive — preserves subdirectory structure)
163
- - every agent under `agents/``<editor>/agents/` (recursive preserves `<agent>/scripts/` subtrees)
164
- 6. **Registers the MCP server** (auto-adapts to editor config format: jsonc-object / jsonc-command-array / codex-cli / toml-section).
165
- 7. Editors whose marker directory is missing are reported as **`skipped`** — nothing is written for them.
166
- 8. The install is **idempotent** — re-running overwrites bundled content only. It never touches files under `<editor>/skills/` or `<editor>/agents/` that don't share a name with a bundled item.
167
-
168
- ### Target directories
169
-
170
- | Editor | Marker | Skills target | Agents target |
171
- |--------|--------|---------------|---------------|
172
- | Claude Code | `~/.claude/` | `~/.claude/skills/` | `~/.claude/agents/` |
173
- | Cursor | `~/.cursor/` | `~/.cursor/skills/` | `~/.cursor/agents/` |
174
- | OpenCode | `~/.config/opencode/` | `~/.config/opencode/skills/` | `~/.config/opencode/agents/` |
175
- | Codex | `~/.codex/` | `~/.agents/skills/` | `~/.codex/agents/` |
176
-
177
- ---
178
-
179
- ## Skills
180
-
181
- | Skill | Trigger phrases | Description | Prerequisites | Arguments | Example |
182
- |-------|-----------------|-------------|---------------|-----------|--------|
183
- | `hmos-convert-pipeline` | "full Android-to-HarmonyOS pipeline", "run the conversion pipeline end-to-end", "hmos-convert-pipeline" | Runs all conversion agents in sequence with progress tracking, duration stats, and defect recording. 4 stages: Logic Development (Context Builder) → Logic Coding → Build → Code Review/Fix/Rebuild loop → Self-Test/Fix/Rebuild loop | `assets-output-path` 下需存在 `plan.md` 需求规格文件 | `android-project-path` (required), `harmonyos-project-path` (required), `assets-output-path` (required), `max-rounds-review` (optional, default 2), `max-rounds-test` (optional, default 2), `skip-test` (optional, default false) | `"/hmos-convert-pipeline android-project-path=D:/path/to/android harmonyos-project-path=D:/path/to/harmonyos assets-output-path=D:/path/to/output"` |
184
- | `hmos-spec-generate` | "spec generation", "generate spec", "requirement to spec", "atomic scenarios", "scenario decomposition", "req to spec" | Generates atomic-scenario requirement specs from raw `.txt` requirement batches. Reads REQ blocks, explores the Android code graph via GitNexus, writes per-REQ trace files, then synthesizes specs from the trace | 需求描述文件 (`.txt`),每段以 `REQ` 开头 | `requirement-description-file` (required), `android-project-path` (required), `spec-output-dir` (required) | `"/hmos-spec-generate requirement-description-file=D:/path/to/req.txt android-project-path=D:/path/to/android spec-output-dir=D:/path/to/specs"` |
185
- | `hmos-resources-convert` | "Android resources to HarmonyOS", "migrate Android res", "convert drawables/strings/colors" | Converts Android project resources (strings, colors, dimensions, images, drawables, icons) into HarmonyOS resources, including qualifier directories and XML→JSON format conversion | Android 项目中需包含 `res/` 资源目录 | `android-project-path` (required), `harmonyos-project-path` (required), `resource_mapping_path` (required), `apk-path` (optional) | `"/hmos-resources-convert android-project-path=D:/path/to/android harmonyos-project-path=D:/path/to/harmonyos resource_mapping_path=D:/path/to/resource_mapping.md"` |
186
- | `hmos-incremental-ui-align` | "UI对齐", "页面对齐", "和安卓对齐", "鸿蒙页面修复", "UI增量开发", "align HarmonyOS with Android" | Automated HarmonyOS-Android UI alignment: navigates to target pages on both devices, captures view trees + screenshots, then aligns HarmonyOS code to match Android | 需连接 Android 设备进行 UI 对比;`config-path` 指向的 `config.json` 中需配置项目路径、SDK 路径、API key | `config-path` (required) | `"/hmos-incremental-ui-align config-path=D:/path/to/config.json 帮我对齐设置页面的关于页面"` |
187
- | `hmos-batch-ui-align` | "把安卓页面迁移到鸿蒙", "Android UI 转鸿蒙", "批量转 ArkTS" | Batch-converts multiple Android Activity UI snapshots (`page_NNNN_ActivityName`) to HarmonyOS ArkUI (ArkTS) pages | `ui_info_root` 下需包含 `page_NNNN_ActivityName` 格式的页面快照子目录 | `android_project_dir` (required), `harmony_project_dir` (required), `ui_info_root` (optional), `pages` (optional) | `"/hmos-batch-ui-align android_project_dir=D:/path/to/android harmony_project_dir=D:/path/to/harmonyos ui_info_root=D:/path/to/pages"` |
188
- | `hmos-integration-test` | "跑自测", "运行自测", "自动测试", "设备测试", "self test", "run autotest" | Runs on-device self-test for a HarmonyOS app: parses `test_case.md`, installs the HAP, executes AutoTest, and produces a verification report — optionally entering a test-and-fix loop | 需存在 `test_case.md` 测试用例文件,设备需安装待测 HAP | `test-case-path` (required), `hap-path` (required), `output-path` (optional), `pre-test-case-path` (optional), `android-project-path` (optional), `max-rounds` (optional, default 3) | `"/hmos-integration-test test-case-path=D:/path/to/test_case.md hap-path=D:/path/to/app-signed.hap"` |
189
- | `hmos-fix-build-errors` | "build HarmonyOS project", "fix compile errors", "auto build and fix", "hmos-fix-build-errors" | Builds a HarmonyOS NEXT project from the command line, parses compile errors, fixes them, and retries in a loop until the build succeeds. Default produces an unsigned HAP; `--signed` produces a signed HAP | 有效的 HarmonyOS 项目(含 `build-profile.json5`、`entry/src`、`oh-package.json5`)+ DevEco Studio 安装目录;`--signed` 时签名配置须已存在于 `build-profile.json5` | `harmonyos-project-path` (required), `deveco-studio-path` (required), `--signed` (optional) | `"/hmos-fix-build-errors D:/MyHmosApp \"D:/DevEco Studio\" --signed"` |
190
-
191
- ---
192
-
193
- ## Agents
194
-
195
- | Agent | Description |
196
- |-------|-------------|
197
- | `logic-context-builder` | Constrains HarmonyOS ArkTS app changes into an executable decision contract |
198
- | `logic-coder` | Executes HarmonyOS ArkTS code implementation from the decision contract (ships with `scripts/platform_context_query.py`) |
199
- | `build-fixer` | Automatically builds a HarmonyOS project, parses compile errors, fixes them, and retries in a loop until the build succeeds |
200
- | `code-reviewer` | Reviews HarmonyOS code against user scenarios to validate functional coverage |
201
- | `review-fixer` | Fixes issues from code review reports — verifies each issue before fixing, references Android source, uses cautious per-scenario fix strategies |
202
- | `spec-generator` | Generates requirement spec documents for each requirement description file in a folder by exploring the Android codebase and decomposing into atomic user scenarios |
203
- | `self-tester` | Unified self-test agent — parses `test_case.md` into `testcases.json`, runs on-device AutoTest verification, and produces a report. A `setup` boolean controls whether the parse phase runs (skip on round-2+ to reuse prior artifacts) |
204
- | `self-test-fixer` | Fixes issues identified by self-testing — reads the self-test report, white-box verifies failures, plans and executes fixes in order |
205
-
206
- ---
207
-
208
-
209
-
210
- <p align="center">
211
- <a href="https://gitcode.com/SMAT/HomeTrans">Official Repository</a> •
212
- <a href="https://gitcode.com/SMAT/HomeTrans/blob/main/LICENSE">MIT License</a>
213
- </p>
1
+ # 安卓应用迁移鸿蒙指导
2
+
3
+ 本文档为完整的 Android HarmonyOS 迁移流程指导。
4
+
5
+ ---
6
+
7
+ ## 步骤 0:安装依赖
8
+
9
+ ### 0.1 安装依赖并连接设备
10
+
11
+ 按以下顺序安装(`ht init` 会逐项检测,并提示缺失项对各 skill 的影响):
12
+
13
+ 1. **安装 DevEco Studio** — 下载地址:<https://developer.huawei.com/consumer/cn/download/>。安装完成后,配置以下 **PATH 环境变量**(`<DevEco安装目录>` 指 DevEco Studio 的安装根目录):
14
+
15
+ | 工具 | PATH 中加入的目录 |
16
+ |------|------------------|
17
+ | node / npm / npx | `<DevEco安装目录>\tools\node` |
18
+ | java | `<DevEco安装目录>\jbr\bin` |
19
+ | hdc | `<DevEco安装目录>\sdk\default\openharmony\toolchains` |
20
+
21
+ 验证方式:执行 `node -v`、`java -version`、`hdc -v` 均返回正常
22
+
23
+ 被依赖:
24
+ - 步骤 1 资源转换(java 可选,缺失时回退读取源码 `res/`)
25
+ - 步骤 2.2 增量 UI 迁移(必需)
26
+ - 步骤 6 逻辑代码转换流水线(必需,构建/评审修复)
27
+ - 步骤 7 自测回归(必需,真机调试)
28
+ 2. **安装 Android Studio** — 下载地址:<https://developer.android.com/studio>,并在 **SDK Manager** 中安装 SDK。
29
+
30
+ 验证方式:执行 `adb version` 返回正常
31
+
32
+ 被依赖:
33
+ - 步骤 2.1 全量 UI 迁移(可选,仅自动抓取页面快照时需要)
34
+ - 步骤 2.2 增量 UI 迁移(必需)
35
+
36
+ 3. **安装 uv** 安装指引:<https://docs.astral.sh/uv/getting-started/installation/>。
37
+
38
+ 验证方式:执行 `uv --version` 返回正常
39
+
40
+ 被依赖:
41
+ - 步骤 6 逻辑代码转换流水线的自测阶段(可经 `skip-test` 跳过)
42
+ - 步骤 7 自测回归(必需,AutoTest uv 下运行)
43
+
44
+ 4. **安装 python** — 安装指引:<https://www.python.org/downloads/>,要求 ≥ 3.10。
45
+
46
+ 验证方式:执行 `python --version` 返回正常
47
+
48
+ 被依赖:
49
+ - 步骤 2.1 全量 UI 迁移(必需,页面快照解析脚本)
50
+ - 步骤 2.2 增量 UI 迁移(必需,双端页面采集脚本)
51
+
52
+ 5. **安装 [GitNexus](https://github.com/abhigyanpatwari/GitNexus)** — 执行 `npm install -g gitnexus && gitnexus setup`
53
+
54
+ 验证方式:执行 `gitnexus --version` 返回正常
55
+
56
+ 被依赖:
57
+ - 步骤 4 生成需求规格(必需)
58
+
59
+ 6. **连接设备** — 连接安卓和鸿蒙真机,或启动模拟器
60
+
61
+ 被依赖:
62
+ - 安卓真机/模拟器 — 步骤 2 UI 迁移
63
+ - 鸿蒙真机/模拟器 — 步骤 2.2 增量 UI 迁移、步骤 6 流水线自测阶段、步骤 7 自测回归
64
+
65
+ ### 0.2 安装 hometrans
66
+
67
+ 执行 `npm install -g @buaa_smat/hometrans`。
68
+
69
+ 验证方式:执行 `hometrans --version` 或 `ht --version` 返回正常
70
+
71
+ 然后执行 `hometrans init` `ht init`,配置 `DEVECO_SDK_HOME`、`TEST_API_KEY`、`GLM_API_KEY`。
72
+
73
+ > 如果在 PowerShell 下运行,命令需要加上 `.cmd` 后缀,如 `hometrans.cmd --version`、`ht.cmd init`。
74
+
75
+ 选择本地 editor:
76
+
77
+ ![选择本地 editor](resource/choose_editor.png)
78
+
79
+ 参数配置:
80
+
81
+ ![参数配置](resource/hometrans_config.png)
82
+
83
+ - `DEVECO_SDK_HOME` — DevEco Studio 的 sdk 目录(唯一输入),其余路径由它派生并校验存在,示例:
84
+
85
+ ```text
86
+ + DEVECO_SDK_HOME : <DevEco安装目录>\sdk
87
+ + DEVECO_PATH : <DevEco安装目录>
88
+ + OHOS_SDK_PATH : <DevEco安装目录>\sdk\default\openharmony\ets
89
+ + HMS_SDK_PATH : <DevEco安装目录>\sdk\default\hms\ets
90
+ ```
91
+
92
+ - `TEST_API_KEY` — 集成测试 agent 执行测试用例所用的 LLM API key
93
+ - `GLM_API_KEY` UI对齐中过程中GLM phone agent 所用的 LLM API key
94
+
95
+ ### 0.3 准备项目
96
+
97
+ 准备 **Android 源项目** 与 **HarmonyOS 目标项目目录**。
98
+
99
+ ---
100
+
101
+ ## 步骤 1:资源转换(`hmos-resources-convert`)
102
+
103
+ Android 资源(图片、字符串、颜色、尺寸等)转换为 HarmonyOS 资源格式,产出 `resources/` + 资源映射文档 + 转换报告。
104
+
105
+ > ⚠️ 提示:如果步骤 2 的 UI 迁移采用**全量迁移**(`hmos-batch-ui-align`),则跳过当前步骤(全量UI迁移内部已包含资源转换)。
106
+
107
+ ```
108
+ /hmos-resources-convert android-project-path=<安卓项目路径> harmonyos-project-path=<鸿蒙项目路径> resource_mapping_path=<资源映射文档路径>
109
+ ```
110
+
111
+ | 参数 | 类型 | 说明 |
112
+ |------|------|------|
113
+ | `android-project-path` | **必选** | Android 项目根目录路径(含 `build.gradle` `build.gradle.kts`) |
114
+ | `harmonyos-project-path` | **必选** | HarmonyOS 项目输出路径 |
115
+ | `resource_mapping_path` | **必选** | Android HarmonyOS 资源映射文档的完整输出路径(`.md`) |
116
+ | `apk-path` | 可选 | Android APK 文件路径;提供后跳过 Gradle 构建和 apktool 解包,直接从 APK 提取资源 |
117
+
118
+ ---
119
+
120
+ ## 步骤 2:UI 迁移
121
+
122
+ 按场景选择全量或增量方式之一。
123
+
124
+ ### 2.1 全量迁移(`hmos-batch-ui-align`)
125
+
126
+ 遍历采集页面快照 → 批量生成 ArkTS 页面 → 统一编译修复。
127
+
128
+ ```
129
+ /hmos-batch-ui-align android_project_dir=<安卓项目路径> harmony_project_dir=<鸿蒙项目路径> ui_info_root=<页面快照目录>
130
+ ```
131
+
132
+ | 参数 | 类型 | 说明 |
133
+ |------|------|-------------------------------------------------------------------------------------------------------------|
134
+ | `android_project_dir` | **必选** | Android 项目根目录路径 |
135
+ | `harmony_project_dir` | **必选** | HarmonyOS 项目输出路径 |
136
+ | `ui_info_root` | 可选 | 包含 `page_NNNN_ActivityName` 格式子目录的父目录(每子目录含 `meta.json` + `view.xml` + 可选 `screenshot.png`);不提供时自动通过 adb 抓取 |
137
+ | `pages` | 可选 | 显式列出的页面子集(不提供则处理所有页面) |
138
+
139
+ ### 2.2 增量迁移(`hmos-incremental-ui-align`,按需)
140
+
141
+ 双端采集指定页面 差异分析 对齐修复。
142
+
143
+ > 👤 前置:需用户预先配置好 `config.json`(双端 app 包名/工程路径等,参考 skill 目录下 `config-example.json`;`ht init` 已预置并填充 `glm_api_key` / `hmos_sdk_dir`)。对齐目标在消息中描述,如 "帮我对齐设置页面的关于页面"。
144
+
145
+ ```
146
+ /hmos-incremental-ui-align config-path=<config.json路径>
147
+ ```
148
+
149
+ | 参数 | 类型 | 说明 |
150
+ |------|------|------|
151
+ | `config-path` | 可选 | `config.json` 路径,含 `android.project_dir`、`harmony.project_dir`、`hmos_sdk_dir`、`glm_api_key`、`capture_output_dir` 等字段;|
152
+
153
+ ---
154
+
155
+ ## 步骤 3:编写原始需求文件(👤 用户介入)
156
+
157
+ 编写 REQ `.txt` 文件:每段一个需求、空行分隔 这是下一步规格生成的输入来源。
158
+
159
+ ---
160
+
161
+ ## 步骤 4:生成需求规格(`hmos-spec-generate`)
162
+
163
+ REQ 文本 GitNexus 代码图谱探索代码 Trace 原子场景规格(`*-SPEC.md`)
164
+
165
+ ```
166
+ /hmos-spec-generate requirement-description-file=<需求描述文件路径> android-project-path=<安卓项目路径> spec-output-dir=<规格输出目录>
167
+ ```
168
+
169
+ | 参数 | 类型 | 说明 |
170
+ |------|------|------|
171
+ | `requirement-description-file` | **必选** | 需求描述 `.txt` 文件路径(每段以 `REQ` 开头,空行分隔) |
172
+ | `android-project-path` | **必选** | Android 项目根目录路径(必须位于 Git 仓库内) |
173
+ | `spec-output-dir` | **必选** | 规格文档输出目录(自动创建;每个 REQ 生成 `<feature>-SPEC.md` + `.trace/<feature>.md`) |
174
+
175
+ ---
176
+
177
+ ## 步骤 5:流水线前置准备(👤 用户介入)
178
+
179
+ 1. **编写测试用例文档**(自测阶段的依据),路径经可选参数 `test-case-path` 传入(默认读输出目录下 `test_case.md`;前置用例同理 `pre-test-case-path`)。
180
+ 2. 连接 HarmonyOS 真机,在 DevEco Studio 中[**配置签名**](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/networkboost-preparations#%E9%85%8D%E7%BD%AE%E7%AD%BE%E5%90%8D)。
181
+
182
+ ---
183
+
184
+ ## 步骤 6:逻辑代码转换流水线(`hmos-convert-pipeline`)
185
+
186
+ 逻辑开发 编码 构建 评审修复循环 自测修复循环 签名 HAP + `pipeline-manifest.md`。内部复用 `hmos-fix-build-errors` `hmos-integration-test`(自测内核)。
187
+
188
+ ```
189
+ /hmos-convert-pipeline android-project-path=<安卓项目路径> harmonyos-project-path=<鸿蒙项目路径> spec-file-path=<需求规格文档路径>
190
+ ```
191
+
192
+ | 参数 | 类型 | 说明 |
193
+ |------|------|------|
194
+ | `android-project-path` | **必选** | Android 项目根目录路径 |
195
+ | `harmonyos-project-path` | **必选** | HarmonyOS 项目根目录路径 |
196
+ | `spec-file-path` | **必选** | 需求规格文档路径(各阶段直接读取,无需复制到输出目录) |
197
+ | `assets-output-path` | 可选 | 输出/报告文件存放目录(默认鸿蒙工程下 `.hometrans_output`,自动创建) |
198
+ | `test-case-path` | 可选 | 自测用例文件路径(默认读输出目录下 `test_case.md`;不存在则跳过自测循环) |
199
+ | `pre-test-case-path` | 可选 | 前置用例文件路径(默认读输出目录下 `pre_test_case.md`;存在才传给自测) |
200
+ | `max-rounds-review` | 可选 | 代码检视循环最大轮数(正整数 `>= 1`,默认 `2`) |
201
+ | `max-rounds-test` | 可选 | 自测循环最大轮数(正整数 `>= 1`,默认 `2`) |
202
+ | `skip-test` | 可选 | `true` 跳过集成测试阶段(无真机验证环境时设为 `true`,默认 `false`) |
203
+
204
+ > 参数按位置传递:要传某个可选参数,需先显式给出它前面的所有可选参数。
205
+
206
+ ---
207
+
208
+ ## 步骤 7:自测回归(`hmos-integration-test`,可反复执行)
209
+
210
+ 对任意签名 HAP 跑真机自测,可进入 测试 → 修复 → 重编 → 重测 循环。
211
+
212
+ ```
213
+ /hmos-integration-test test-case-path=<测试用例路径> hap-path=<签名HAP路径>
214
+ ```
215
+
216
+ | 参数 | 类型 | 说明 |
217
+ |------|------|------|
218
+ | `test-case-path` | **必选** | `test_case.md` 测试用例文件路径 |
219
+ | `hap-path` | **必选** | 已签名的 HAP 文件路径 |
220
+ | `output-path` | 可选 | 报告输出目录 |
221
+ | `pre-test-case-path` | 可选 | 前置用例文件路径 |
222
+ | `android-project-path` | 可选 | Android 项目路径(修复时参考) |
223
+ | `max-rounds` | 可选 | 测试-修复循环最大轮数(默认 `3`) |
224
+
225
+ ---
226
+
227
+ ## 步骤 8:人工验收(👤 用户介入)
228
+
229
+ 通读 `pipeline-manifest.md` 与自测报告,真机走查核心场景,处理报告中的遗留缺陷/TODO 后发布。
@@ -37,21 +37,28 @@ Read the config file written by `ht init` at `~/.hometrans/config.json` (`$HOME/
37
37
  {
38
38
  "editors": [ /* ... */ ],
39
39
  "env": {
40
- "OHOS_SDK_PATH": "...", // OpenHarmony SDK ETS path, e.g. "D:/DevEco Studio/sdk/default/openharmony/ets"
41
- "HMS_SDK_PATH": "...", // HMS SDK ETS path, e.g. "D:/DevEco Studio/sdk/default/hms/ets"
40
+ "DEVECO_SDK_HOME": "...", // DevEco sdk dir, e.g. "D:/DevEco Studio/sdk" — single source of truth
41
+ "DEVECO_PATH": "...", // DevEco install root, e.g. "D:/DevEco Studio" (derived from DEVECO_SDK_HOME)
42
+ "OHOS_SDK_PATH": "...", // <DEVECO_SDK_HOME>/default/openharmony/ets (derived)
43
+ "HMS_SDK_PATH": "...", // <DEVECO_SDK_HOME>/default/hms/ets (derived)
42
44
  "TEST_API_KEY": "...",
43
45
  "TOOL_PATH": "..." // HomeTrans tools dir, e.g. "C:/Users/<you>/.hometrans/tools"
44
46
  }
45
47
  }
46
48
  ```
47
49
 
48
- Read `env.OHOS_SDK_PATH` from this file.
50
+ ### 0b. Resolve the DevEco root `<deveco>` — config first, then env vars, then ask
49
51
 
50
- ### 0b. Derive the DevEco Studio root and tool paths
52
+ Stop at the **first** source that yields a path:
51
53
 
52
- The DevEco Studio installation root is the part of `OHOS_SDK_PATH` before the SDK suffix. Strip the trailing `/sdk/default/openharmony/ets` (or `\sdk\default\openharmony\ets`) from `OHOS_SDK_PATH` to get `<deveco>`.
54
+ 1. **Config file** (`~/.hometrans/config.json`):
55
+ - `env.DEVECO_PATH` if non-empty → that is `<deveco>`.
56
+ - else `env.DEVECO_SDK_HOME` → `<deveco>` is its **parent directory**.
57
+ - else (legacy configs) strip the trailing `/sdk/default/openharmony/ets` from `env.OHOS_SDK_PATH` (or `/sdk/default/hms/ets` from `env.HMS_SDK_PATH`) to get `<deveco>`.
58
+ 2. **Environment variables** (same precedence): `DEVECO_PATH` → `DEVECO_SDK_HOME` (parent dir) → `OHOS_SDK_PATH` / `HMS_SDK_PATH` (strip suffix as above).
59
+ 3. **Auto-detect** (0c below). If that also fails, **ask the user** for the DevEco Studio install path.
53
60
 
54
- > Example: `OHOS_SDK_PATH = D:/DevEco Studio/sdk/default/openharmony/ets` → `<deveco> = D:/DevEco Studio`.
61
+ > Example: `DEVECO_SDK_HOME = D:/DevEco Studio/sdk` → `<deveco> = D:/DevEco Studio`.
55
62
 
56
63
  From `<deveco>`, derive:
57
64
  - **Node executable**: `<deveco>/tools/node/node.exe`
@@ -59,11 +66,11 @@ From `<deveco>`, derive:
59
66
  - **ohpm**: `<deveco>/tools/ohpm/bin/ohpm`
60
67
  - **SDK directory**: `<deveco>/sdk`
61
68
 
62
- Verify these files exist. If they do, use them and skip auto-detection. (Fall back to `env.HMS_SDK_PATH` stripping `/sdk/default/hms/ets` if `OHOS_SDK_PATH` is absent but `HMS_SDK_PATH` is present.)
69
+ Verify these files exist. If they do, use them and skip auto-detection. If a config-sourced path does **not** exist on disk, treat that source as invalid and continue down the resolution order.
63
70
 
64
- ### 0c. Auto-detect if config is missing or invalid
71
+ ### 0c. Auto-detect if config and env vars are missing or invalid
65
72
 
66
- If `~/.hometrans/config.json` is missing, has empty `env.OHOS_SDK_PATH`/`HMS_SDK_PATH`, or the derived paths don't point to real files, auto-detect:
73
+ If neither the config file nor environment variables yield a valid install, auto-detect:
67
74
 
68
75
  1. **Find DevEco Studio installation**:
69
76
  - Search common locations: `D:\DevEco Studio`, `C:\DevEco Studio`, `C:\Program Files\DevEco Studio`
@@ -74,7 +81,7 @@ If `~/.hometrans/config.json` is missing, has empty `env.OHOS_SDK_PATH`/`HMS_SDK
74
81
  - `where node` (Windows) or `which node` (Unix)
75
82
  - Verify it runs: `node --version`
76
83
 
77
- If auto-detection fails for any critical path, **stop and report clearly** what is missing so the user can run `ht init` to configure it.
84
+ If auto-detection fails for any critical path, **ask the user directly** for the DevEco Studio install path (and suggest running `ht init` to persist it for next time).
78
85
 
79
86
  ### 0d. Store resolved paths
80
87
 
@@ -33,8 +33,10 @@ Before starting the review, extract the code context for the commit via the `ext
33
33
  - `projectPath`: `<harmonyos-project-path>` (absolute path to the HarmonyOS project root containing the `.git` directory)
34
34
  - `commitId`: `<commit-id>` (the git commit to analyze — diffs against its first parent)
35
35
  - `mode`: `"default"` (builds full call graph for call-chain context)
36
- - `ohosSdkPath`: the OpenHarmony SDK ETS directory path if known (e.g. `D:/DevEco Studio/sdk/default/openharmony/ets`); omit to let the tool read `OHOS_SDK_PATH` from the environment
37
- - `hmsSdkPath`: the HMS SDK ETS directory path if known (e.g. `D:/DevEco Studio/sdk/default/hms/ets`); omit to let the tool read `HMS_SDK_PATH` from the environment
36
+ - `ohosSdkPath` / `hmsSdkPath`: the OpenHarmony / HMS SDK ETS directory paths. Resolve each in this order, stop at the first hit:
37
+ 1. `env.OHOS_SDK_PATH` / `env.HMS_SDK_PATH` from `~/.hometrans/config.json` (on Windows `%USERPROFILE%\.hometrans\config.json`); if those are empty but `env.DEVECO_SDK_HOME` is set, derive them as `<DEVECO_SDK_HOME>/default/openharmony/ets` and `<DEVECO_SDK_HOME>/default/hms/ets`.
38
+ 2. Omit the parameter to let the tool read `OHOS_SDK_PATH` / `HMS_SDK_PATH` from the environment variables.
39
+ 3. If neither config nor environment provides a path that exists on disk, **ask the user** for the DevEco `sdk` directory (and suggest `ht init` to persist it).
38
40
 
39
41
  2. **On success** — the tool returns the affected code context (diffs, call graphs, impacted files). Treat this response as the **code context** for the review.
40
42