@harmonyos-arkts/d2h 0.1.11 → 0.1.13

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.
Files changed (126) hide show
  1. package/.claude-plugin/marketplace.json +15 -13
  2. package/.claude-plugin/plugin.json +13 -7
  3. package/AGENTS.md +5 -5
  4. package/README.md +212 -212
  5. package/agents/android-to-hmos-00-orchestrator.md +318 -318
  6. package/agents/d2h.md +157 -157
  7. package/dist/bin/install-opencode.js +30 -30
  8. package/docs/environment-check.md +86 -86
  9. package/install-opencode.sh +160 -160
  10. package/opencode/agents.json +16 -16
  11. package/opencode/vscode-d2h-package.json +7 -7
  12. package/opencode/vscode-d2h-plugin.mjs +29 -29
  13. package/package.json +54 -54
  14. package/schemas/android-source-manifest.schema.json +25 -25
  15. package/schemas/checkpoint-provenance.schema.json +67 -67
  16. package/schemas/final-acceptance.schema.json +29 -29
  17. package/schemas/managed-evidence-index.schema.json +15 -15
  18. package/schemas/managed-evidence.schema.json +114 -114
  19. package/schemas/migration-config.schema.json +51 -51
  20. package/schemas/migration-report-index.schema.json +39 -39
  21. package/schemas/migration-report-item.schema.json +51 -51
  22. package/schemas/migration-report-summary.schema.json +25 -25
  23. package/schemas/migration-status.schema.json +202 -202
  24. package/schemas/preflight.schema.json +60 -60
  25. package/schemas/source-order-audit.schema.json +16 -16
  26. package/schemas/source-provenance-event.schema.json +19 -19
  27. package/schemas/spec-app-shard.schema.json +45 -45
  28. package/schemas/spec-fact-corrections-shard.schema.json +13 -13
  29. package/schemas/spec-features-shard.schema.json +43 -43
  30. package/schemas/spec-index.schema.json +26 -26
  31. package/schemas/spec-interactions-shard.schema.json +40 -40
  32. package/schemas/spec-page.schema.json +98 -98
  33. package/schemas/spec-pages-index.schema.json +1 -1
  34. package/schemas/spec-unresolved-shard.schema.json +1 -1
  35. package/schemas/task-envelope.schema.json +109 -109
  36. package/schemas/task-plan.schema.json +341 -341
  37. package/scripts/check-environment.mjs +320 -320
  38. package/skills/android2hmos_resources_convert/SKILL.md +180 -180
  39. package/skills/android2hmos_resources_convert/references/image-conversion-rules.md +230 -230
  40. package/skills/android2hmos_resources_convert/references/svg-fix-patterns.md +175 -175
  41. package/skills/android2hmos_resources_convert/references/xml-drawable-to-svg-rules.md +513 -513
  42. package/skills/arkts-app-identity/SKILL.md +238 -238
  43. package/skills/arkts-i18n/SKILL.md +496 -496
  44. package/skills/arkts-i18n/evals/evals.json +84 -84
  45. package/skills/arkts-i18n/references/code-examples.md +302 -302
  46. package/skills/arkts-i18n/references/common-pitfalls.md +391 -391
  47. package/skills/arkts-i18n/references/dynamic-language-switch.md +604 -604
  48. package/skills/arkts-i18n/references/hardcoded-string-scanner.md +348 -348
  49. package/skills/arkts-i18n/references/language-codes.md +104 -104
  50. package/skills/arkts-i18n/references/resource-file-structure.md +775 -775
  51. package/skills/arkts-i18n/references/static-vs-dynamic.md +242 -242
  52. package/skills/arkts-i18n/references/v1-compat.md +244 -244
  53. package/skills/arkts-i18n/scripts/audit_i18n_completeness.sh +174 -174
  54. package/skills/arkts-icon-sizing/SKILL.md +211 -211
  55. package/skills/arkts-icon-sizing/scripts/icon_audit.py +131 -131
  56. package/skills/arkts-icon-sizing/scripts/icon_autofix.py +88 -88
  57. package/skills/arkts-icon-sizing/scripts/icon_dims.py +179 -179
  58. package/skills/arkts-icon-sizing/scripts/icon_fix.py +119 -119
  59. package/skills/arkts-mvvm-architecture/SKILL.md +613 -613
  60. package/skills/d2h-hypium-forge/SKILL.md +309 -309
  61. package/skills/d2h-hypium-forge/references/functional-spec-template.md +140 -140
  62. package/skills/d2h-hypium-forge/references/official-api.md +135 -135
  63. package/skills/d2h-hypium-forge/references/pitfalls.md +98 -98
  64. package/skills/d2h-hypium-forge/references/testability-template.md +71 -71
  65. package/skills/d2h-hypium-forge/scripts/_common_template.py +659 -659
  66. package/skills/d2h-hypium-forge/scripts/analyze_results.py +165 -165
  67. package/skills/d2h-hypium-forge/scripts/assert_audit.py +107 -107
  68. package/skills/d2h-hypium-forge/scripts/collect_runtime_pages.py +169 -169
  69. package/skills/d2h-hypium-forge/scripts/forge_report.py +325 -325
  70. package/skills/d2h-hypium-forge/scripts/inject_resource_ids.py +114 -114
  71. package/skills/d2h-hypium-forge/scripts/lint_asserts.py +80 -80
  72. package/skills/d2h-hypium-forge/scripts/lint_locate.py +60 -60
  73. package/skills/d2h-hypium-forge/scripts/merge_appgraph.py +249 -249
  74. package/skills/d2h-hypium-forge/scripts/precondition.py +140 -140
  75. package/skills/d2h-hypium-forge/scripts/preinject_ids.py +232 -232
  76. package/skills/d2h-hypium-forge/scripts/probe.py +197 -197
  77. package/skills/d2h-hypium-forge/scripts/run_direct.py +823 -823
  78. package/skills/d2h-hypium-forge/scripts/run_parallel.py +121 -121
  79. package/skills/d2h-hypium-forge/scripts/scan_features.py +255 -255
  80. package/skills/d2h-hypium-forge/scripts/upgrade_asserts.py +66 -66
  81. package/skills/d2h-hypium-forge/scripts/validate_scenarios.py +84 -84
  82. package/skills/d2h-page-develop/SKILL.md +112 -112
  83. package/skills/d2h-page-develop/agents/openai.yaml +7 -7
  84. package/skills/d2h-page-spec-generate/SKILL.md +206 -206
  85. package/skills/d2h-page-spec-generate/scripts/build_batch_report.py +227 -227
  86. package/skills/d2h-utg-ai-generate/SKILL.md +128 -128
  87. package/skills/d2h-utg-ai-generate/references/click-paths-schema.json +76 -76
  88. package/skills/d2h-utg-ai-generate/references/extraction-guide.md +34 -34
  89. package/skills/d2h-utg-ai-generate/references/facts-contract.md +96 -96
  90. package/skills/d2h-utg-ai-generate/references/page-schema.json +61 -61
  91. package/skills/d2h-utg-ai-generate/references/utg-schema.json +89 -89
  92. package/skills/d2h-utg-ai-generate/scripts/build_page_json.py +314 -314
  93. package/skills/d2h-utg-ai-generate/scripts/build_utg.py +123 -123
  94. package/skills/d2h-utg-ai-generate/scripts/capture_from_page_json.ts +280 -280
  95. package/skills/d2h-utg-ai-generate/scripts/utg_common.py +524 -524
  96. package/skills/d2h-utg-ai-generate/scripts/utg_html.py +489 -489
  97. package/skills/d2h-utg-ai-generate/scripts/validate_utg.py +69 -69
  98. package/skills/d2h-utg-ai-generate/scripts/vendor/D3-LICENSE +13 -13
  99. package/skills/d2h-utg-ai-generate/scripts/vendor/d3-7.9.0.min.js +2 -2
  100. package/skills/d2h-utg-ai-generate/tests/test_pipeline.py +369 -369
  101. package/skills/d2h-utg-static-generate/SKILL.md +73 -73
  102. package/skills/d2h-utg-static-generate/references/discoveries.md +38 -38
  103. package/skills/d2h-utg-static-generate/scripts/generate.py +499 -499
  104. package/skills/d2h-utg-static-generate/tests/test_static.py +335 -335
  105. package/skills/d2h-utg-static-generate/tests/verify-offline-html.py +60 -60
  106. package/skills/d2h-utg-static-generate/tests/verify-produced-fixture.py +131 -131
  107. package/skills/harmonyos-migration-playbook/SKILL.md +83 -83
  108. package/skills/harmonyos-migration-playbook/agents/openai.yaml +7 -7
  109. package/skills/harmonyos-migration-playbook/references/arkts-compile.md +24 -24
  110. package/skills/harmonyos-migration-playbook/references/harmony-runtime.md +53 -53
  111. package/skills/harmonyos-migration-playbook/references/lesson-lifecycle.md +45 -45
  112. package/skills/harmonyos-migration-playbook/references/protocol-e2e.md +23 -23
  113. package/skills/harmonyos-migration-playbook/references/ui-automation.md +53 -53
  114. package/skills/harmonyos-migration-playbook/references/windows-environment.md +38 -38
  115. package/skills/maintaining-migration-report/SKILL.md +144 -144
  116. package/skills/maintaining-migration-report/references/final-acceptance.md +48 -48
  117. package/skills/maintaining-migration-report/references/source-provenance.md +66 -66
  118. package/skills/managing-d2h-toolchain/SKILL.md +24 -24
  119. package/skills/managing-d2h-toolchain/environment-requirements.json +16 -16
  120. package/skills/managing-d2h-toolchain/scripts/manage-toolchain.mjs +98 -98
  121. package/skills/managing-d2h-toolchain/toolchain.json +16 -16
  122. package/skills/native-library-substitution/SKILL.md +384 -384
  123. package/skills/native-library-substitution/references/native-library-substitution.json +56905 -56905
  124. package/skills/native-library-substitution/references/native-library-substitution.md +163 -163
  125. package/skills/preparing-migration-workspace/SKILL.md +131 -131
  126. package/skills/reviewing-migration-process/SKILL.md +62 -62
@@ -1,206 +1,206 @@
1
- ---
2
- name: d2h-page-spec-generate
3
- description: Generate an AI-authored pages.json plan and page-scoped Android-to-HarmonyOS spec.md files from migration Facts, `.migration/utg/page.json`, source code, and existing HarmonyOS implementation, then build batch_report.md with the bundled renderer. Use when pages, dialogs, sheets, or page modes need evidence-backed development specifications and ordered execution records without copied UI artifacts.
4
- ---
5
-
6
- # Page Spec generation
7
-
8
- Generate one implementation-ready `spec.md` for every Android page, dialog, sheet, and behaviorally distinct page mode. The AI determines page boundaries, evidence mapping, dependencies, and development order by reading the actual migration workspace and source code.
9
-
10
- Do not invoke task-planning, graph-generation, migration, or page-validation scripts. Do not modify Android source, HarmonyOS source, `.migration/spec/`, `.migration/utg/`, `.migration/tasks/`, or the migration report.
11
-
12
- ## Inputs
13
-
14
- Resolve these paths before writing:
15
-
16
- - `migration_root`: workspace containing `.migration/`.
17
- - `spec_root`: `<migration_root>/.migration/spec`; require `index.json` and `facts/`.
18
- - `page_plan`: require `<migration_root>/.migration/utg/page.json`; this is the source-derived page and navigation plan produced by the UTG stage.
19
- - `android_root`: `.migration/config.json.androidProject`, unless explicitly supplied.
20
- - `harmony_root`: `.migration/config.json.harmonyProject`, resolved relative to `migration_root` when not absolute, unless explicitly supplied.
21
- - `legacy_tasks_root`: optional `<migration_root>/.migration/tasks`; use existing briefs, core facts, source context, and acceptance files only as read-only evidence from an older flow.
22
- - `output_root`: default `<migration_root>/.migration/page-specs`.
23
-
24
- Facts and legacy Task artifacts are indexes, not substitutes for Android source. Existing HarmonyOS files and tests are implementation evidence, not proof that a behavior is complete.
25
-
26
- ## Output contract
27
-
28
- Each page unit contains only `spec.md`. `pages.json` and `batch_report.md` live at the output root:
29
-
30
- ```text
31
- .migration/page-specs/
32
- ├── pages.json
33
- ├── batch_report.md
34
- ├── page_0001_<name>-<id>/
35
- │ └── spec.md
36
- ├── page_0002_<name>-<id>/
37
- │ └── spec.md
38
- └── ...
39
- ```
40
-
41
- Directory names encode the AI-selected development order. Use a four-digit sequence and a stable unique suffix derived from the strongest page identity already present in Facts or `page.json`. Re-running against unchanged evidence must preserve existing directory names and order unless the evidence proves the previous boundary or dependency order was wrong.
42
-
43
- ## Workflow
44
-
45
- ### 1. Read the complete evidence index
46
-
47
- 1. Read `.migration/spec/index.json`, `facts/app.json`, all `facts/pages/*.json`, `facts/interactions.json`, and `facts/unresolved.json`.
48
- 2. Read `.migration/utg/page.json` completely. Use `pages[]` as the page/navigation index and consume each node's `node_id`, `kind`, `label`, `declared_at`, `required_state`, `expected`, `reachable`, `depth`, `ui_sequence`, `path_text`, `steps`, and `skip_reason` when present.
49
- 3. Treat `page.json.source.utg` and `page.json.source.click_paths` as provenance links. Read those referenced UTG artifacts only when page boundaries, transitions, guards, or selectors need clarification.
50
- 4. If legacy `.migration/tasks/` exists, read its package briefs and associated `core-facts.json`, `source-context.json`, and `acceptance.json` only to recover behavior refs and source closure. Never inherit its package boundary blindly and never execute its task commands.
51
- 5. Read the current migration report to understand existing mappings and unresolved items, without treating report status as proof of implementation.
52
- 6. Inspect HarmonyOS route registration, `.ets`/`.ts` components, shared state, resources, and tests to distinguish existing implementation from planned work.
53
-
54
- ### 2. Determine page units with AI reasoning
55
-
56
- 1. Start from `page.json.pages[]`, then join each page node to Facts surfaces, entries, controls, and interactions by stable ref, declared source, transition, and source behavior.
57
- 2. Treat independently reachable pages, dialogs, sheets, and behaviorally distinct add/edit or selection modes as separate units when they have their own user-visible lifecycle or acceptance flow.
58
- 3. Prefer exact ref or normalized identity matches between `page.json.pages[].node_id` and Facts surfaces. Then use labels, `declared_at`, parent relations, navigation steps, source symbols, controls, and Android source behavior.
59
- 4. Never assign behavior from name similarity alone. Record ambiguous mappings in the owning Spec under “未决项与平台差异”.
60
- 5. `capture=false`, an empty `expected`, or a `skip_reason` does not remove a source-proven page. Use those fields as evidence limitations and verify the page through Facts and Android source.
61
- 6. Do not create a fake page for background-only capabilities. Assign startup, notification, widget, receiver, persistence, or other shared responsibilities to the earliest real page that requires them and list downstream consumers.
62
- 7. Legacy page work packages may contain many unrelated surfaces. Split them by actual page lifecycle and behavior ownership rather than retaining the old aggregate.
63
-
64
- ### 3. Decide development order
65
-
66
- Rate each dimension using an integer from 0 to 5, then calculate the score using the following formula:
67
-
68
- `page_score = enablement × 9 + ordinary_reachability × 6 + shallowness × 5`(满分 100,分数越高越优先)。
69
-
70
- - **Enablement (45%)** — use the highest evidence-backed enablement rating among the page's REQs. `5`: difficult to mock or bound, ambiguous in data ownership, and correctness-relevant across many features. `3`: reused across several features but cleanly isolatable. `1`: page-local. Repeated persistence keys, storage operations, data-flow hops, and consumers are evidence; a feature name is not.
71
- - **Ordinary reachability (30%)** — `5`: reachable in normal app state. `3`: needs a common business state such as existing data, login, or permission. `0`: first-launch only or reachable only after clearing/resetting app-global state. Use intermediate ratings where evidence supports them.
72
- - **Shallowness (25%)** — `5`: launch/main page; `4`: one page navigation; `3`: two; `2`: three; `1`: four or more. Derive depth from page boundaries in `page-path`, not click count. `__shared_capability__` uses neutral `3`.
73
-
74
- When ordering, first satisfy evidence-backed prerequisites so that data or state providers precede their consumers. Sort all remaining pages by page_score in descending order, breaking ties by the normalized stable page_id in ascending order. Finally, assign consecutive order values starting from 1. Prerequisites may override score-based ordering; no other arbitrary reordering is allowed.
75
-
76
- Write the ordered decisions to `<output_root>/pages.json` before creating page directories. Also write the ordinal, dependencies, and concise rationale into each Spec.
77
-
78
- Use schema `d2h-page-plan/v1`. Every `pages[]` item must contain:
79
-
80
- - consecutive one-based `order`;
81
- - stable `page_id`, `kind`, `package`, and `page_path`;
82
- - `spec_refs` and `req_refs` backed by Facts/source evidence;
83
- - integer `page_score`;
84
- - `decision_ledger.enablement.rating`, `ordinary_reachability.rating`, and `shallowness.rating`, with evidence and a concise calculation/rationale.
85
-
86
- `package` must exactly match `page_NNNN_<name>-<id>`. Every `page.json` node must be represented by a page item or by an explicit exclusion/unmatched entry with a reason. The AI authors and checks this plan; do not use it as a substitute for reading source.
87
-
88
- ### 4. Verify source before writing
89
-
90
- 1. Open every cited Android `sourceEvidence.file` at the cited symbol or line.
91
- 2. Follow handlers, repositories, state transitions, navigation, persistence, error paths, and platform side effects far enough to establish the observable result.
92
- 3. Use `page.json` navigation steps, selectors, guards, expected-arrival rules, required state, and depth to reconstruct the semantic arrival path. Source-derived reachability is planning evidence, not runtime confirmation.
93
- 4. Translate selectors into semantic control names only when Facts, resources, or Android source support the mapping. Keep missing or ambiguous selectors explicitly unresolved.
94
- 5. Verify every listed Android path exists under `android_root`. Verify every HarmonyOS path marked `existing` exists under `harmony_root`; otherwise mark it `planned`.
95
-
96
- ### 5. Write only `spec.md`
97
-
98
- Use these headings in every page Spec:
99
-
100
- ```markdown
101
- # <页面名称> 迁移 Spec
102
-
103
- ## 页面范围
104
-
105
- - 页面标识:<稳定标识>
106
- - 页面类型:<page | dialog | sheet | mode | other>
107
- - Android 到达路径:<从真实入口开始的语义路径>
108
- - 负责范围:<本 Spec 负责的状态和行为>
109
- - 排除范围:<相邻但属于其他 Spec 的责任>
110
-
111
- ## 开发顺序
112
-
113
- - 顺序:<NNNN>
114
- - 前置依赖:<无或其他页面标识/共享能力>
115
- - 排序理由:<基于前置依赖和页面评分的说明>
116
-
117
- ## 页面功能
118
-
119
- - F-001:<用户动作及其可观察结果。>
120
-
121
- ## UI 操作与验收
122
-
123
- ### F-001
124
-
125
- 1. <从真实应用入口进入当前页面。>
126
- 2. <定位并操作具有语义名称的控件。>
127
- 3. <断言可见状态、导航、数据效果或错误结果。>
128
-
129
- ## Android 证据
130
-
131
- | 证据 | 路径 / Ref | 支持的结论 |
132
- |---|---|---|
133
- | Facts | <surface/entry/control/interaction ref> | <范围或行为> |
134
- | Android 源码 | <android_root 相对路径及符号/行> | <触发、分支和结果> |
135
- | UTG Page | `.migration/utg/page.json` 中的 <node_id> | <到达路径、深度、前置状态、导航步骤与证据限制> |
136
-
137
- ## HarmonyOS 实现范围
138
-
139
- | 路径 | 状态 | 预期职责 / 校验点 |
140
- |---|---|---|
141
- | <harmony_root 相对路径> | existing 或 planned | <页面实现、共享影响和验收点> |
142
-
143
- ## 未决项与平台差异
144
-
145
- - <没有时明确写“无”。>
146
- ```
147
-
148
- When a page has no independent interaction, write one display/reachability feature and acceptance sequence instead of leaving the feature sections empty.
149
-
150
- ### 6. Generate `batch_report.md`
151
-
152
- After all page Specs are complete, generate `<output_root>/batch_report.md` from `pages.json` with the bundled renderer:
153
-
154
- ```bash
155
- python scripts/build_batch_report.py \
156
- --pages-plan <output_root>/pages.json \
157
- --output-root <output_root>
158
- ```
159
-
160
- The script requires every planned package to contain `spec.md`, never requires `ui-design.md`, and refuses to overwrite an existing report.
161
-
162
- The report must contain:
163
-
164
- - the source `pages.json` path and SHA-256;
165
- - generation timestamp and ordered page count;
166
- - one queue row per page with stable task ID `PAGE-NNNN`, page identity, relative `spec.md` link, development status, build status, validation status, and blocker;
167
- - one detail section per task with dependencies, implementation files, test files, implementation commit or source snapshot, build evidence, test evidence, last update, blocker, and chronological execution notes;
168
- - summary counts that exactly match the queue and detail sections.
169
-
170
- Use these status values:
171
-
172
- - development: `pending | in_progress | implemented | blocked`;
173
- - build: `not_run | passed | failed | blocked`;
174
- - validation: `not_run | passed | failed | blocked`.
175
-
176
- Initial generation uses `pending`, `not_run`, and `not_run`, with empty implementation, test, evidence, commit/snapshot, timestamp, and blocker fields. Do not infer completion from existing HarmonyOS files or local test artifacts.
177
-
178
- Once development has started, never rerun the renderer or overwrite `batch_report.md`. Update the existing queue row, detail section, counts, and notes in place while preserving execution history. If `pages.json`, the Spec set, or order no longer matches an existing report, stop and report the mismatch for AI reconciliation instead of silently resetting statuses.
179
-
180
- ## Quality gates
181
-
182
- - Every known source-proven page, dialog, sheet, and behaviorally distinct mode has exactly one `spec.md`, or its ownership is explicitly assigned to another Spec.
183
- - Every distinct interaction has a unique `F-xxx`, and feature IDs match UI operation/acceptance sections one-to-one.
184
- - Each feature states a user action and observable result, not an implementation instruction.
185
- - Navigation, state changes, persistence, destructive confirmation, external intents, cancellation, dismissal, and error behavior remain explicit.
186
- - Facts refs, `page.json` node IDs, Android source paths, and HarmonyOS paths are real and correctly classified.
187
- - Existing HarmonyOS code or tests never cause a feature to be marked complete without current build and executed test evidence.
188
- - Uncertainty remains explicit. Do not invent control names, outcomes, source mappings, runtime captures, or implementation status.
189
- - Each `page_NNNN_<name>-<id>/` directory contains exactly one file named `spec.md`.
190
- - `output_root` contains only `pages.json`, `batch_report.md`, and page directories; it contains no copied UI evidence, UI design, or generated validation artifact.
191
- - Every page directory has exactly one queue row and one detail section in `batch_report.md`; task IDs, order, links, statuses, and counts agree.
192
- - A task is complete only when development is `implemented` and both build and validation are `passed` with current evidence.
193
-
194
- ## Result
195
-
196
- Return:
197
-
198
- - the ordered page directory list and ordering rationale;
199
- - the number of generated, updated, and unchanged Specs;
200
- - the absolute `pages.json` path;
201
- - unreachable pages, capture-disabled nodes, and pages with incomplete arrival rules in `page.json`;
202
- - ambiguous mappings and unmatched Facts;
203
- - unresolved selector steps;
204
- - legacy aggregate packages that were split;
205
- - the absolute `batch_report.md` path;
206
- - the absolute `output_root`.
1
+ ---
2
+ name: d2h-page-spec-generate
3
+ description: Generate an AI-authored pages.json plan and page-scoped Android-to-HarmonyOS spec.md files from migration Facts, `.migration/utg/page.json`, source code, and existing HarmonyOS implementation, then build batch_report.md with the bundled renderer. Use when pages, dialogs, sheets, or page modes need evidence-backed development specifications and ordered execution records without copied UI artifacts.
4
+ ---
5
+
6
+ # Page Spec generation
7
+
8
+ Generate one implementation-ready `spec.md` for every Android page, dialog, sheet, and behaviorally distinct page mode. The AI determines page boundaries, evidence mapping, dependencies, and development order by reading the actual migration workspace and source code.
9
+
10
+ Do not invoke task-planning, graph-generation, migration, or page-validation scripts. Do not modify Android source, HarmonyOS source, `.migration/spec/`, `.migration/utg/`, `.migration/tasks/`, or the migration report.
11
+
12
+ ## Inputs
13
+
14
+ Resolve these paths before writing:
15
+
16
+ - `migration_root`: workspace containing `.migration/`.
17
+ - `spec_root`: `<migration_root>/.migration/spec`; require `index.json` and `facts/`.
18
+ - `page_plan`: require `<migration_root>/.migration/utg/page.json`; this is the source-derived page and navigation plan produced by the UTG stage.
19
+ - `android_root`: `.migration/config.json.androidProject`, unless explicitly supplied.
20
+ - `harmony_root`: `.migration/config.json.harmonyProject`, resolved relative to `migration_root` when not absolute, unless explicitly supplied.
21
+ - `legacy_tasks_root`: optional `<migration_root>/.migration/tasks`; use existing briefs, core facts, source context, and acceptance files only as read-only evidence from an older flow.
22
+ - `output_root`: default `<migration_root>/.migration/page-specs`.
23
+
24
+ Facts and legacy Task artifacts are indexes, not substitutes for Android source. Existing HarmonyOS files and tests are implementation evidence, not proof that a behavior is complete.
25
+
26
+ ## Output contract
27
+
28
+ Each page unit contains only `spec.md`. `pages.json` and `batch_report.md` live at the output root:
29
+
30
+ ```text
31
+ .migration/page-specs/
32
+ ├── pages.json
33
+ ├── batch_report.md
34
+ ├── page_0001_<name>-<id>/
35
+ │ └── spec.md
36
+ ├── page_0002_<name>-<id>/
37
+ │ └── spec.md
38
+ └── ...
39
+ ```
40
+
41
+ Directory names encode the AI-selected development order. Use a four-digit sequence and a stable unique suffix derived from the strongest page identity already present in Facts or `page.json`. Re-running against unchanged evidence must preserve existing directory names and order unless the evidence proves the previous boundary or dependency order was wrong.
42
+
43
+ ## Workflow
44
+
45
+ ### 1. Read the complete evidence index
46
+
47
+ 1. Read `.migration/spec/index.json`, `facts/app.json`, all `facts/pages/*.json`, `facts/interactions.json`, and `facts/unresolved.json`.
48
+ 2. Read `.migration/utg/page.json` completely. Use `pages[]` as the page/navigation index and consume each node's `node_id`, `kind`, `label`, `declared_at`, `required_state`, `expected`, `reachable`, `depth`, `ui_sequence`, `path_text`, `steps`, and `skip_reason` when present.
49
+ 3. Treat `page.json.source.utg` and `page.json.source.click_paths` as provenance links. Read those referenced UTG artifacts only when page boundaries, transitions, guards, or selectors need clarification.
50
+ 4. If legacy `.migration/tasks/` exists, read its package briefs and associated `core-facts.json`, `source-context.json`, and `acceptance.json` only to recover behavior refs and source closure. Never inherit its package boundary blindly and never execute its task commands.
51
+ 5. Read the current migration report to understand existing mappings and unresolved items, without treating report status as proof of implementation.
52
+ 6. Inspect HarmonyOS route registration, `.ets`/`.ts` components, shared state, resources, and tests to distinguish existing implementation from planned work.
53
+
54
+ ### 2. Determine page units with AI reasoning
55
+
56
+ 1. Start from `page.json.pages[]`, then join each page node to Facts surfaces, entries, controls, and interactions by stable ref, declared source, transition, and source behavior.
57
+ 2. Treat independently reachable pages, dialogs, sheets, and behaviorally distinct add/edit or selection modes as separate units when they have their own user-visible lifecycle or acceptance flow.
58
+ 3. Prefer exact ref or normalized identity matches between `page.json.pages[].node_id` and Facts surfaces. Then use labels, `declared_at`, parent relations, navigation steps, source symbols, controls, and Android source behavior.
59
+ 4. Never assign behavior from name similarity alone. Record ambiguous mappings in the owning Spec under “未决项与平台差异”.
60
+ 5. `capture=false`, an empty `expected`, or a `skip_reason` does not remove a source-proven page. Use those fields as evidence limitations and verify the page through Facts and Android source.
61
+ 6. Do not create a fake page for background-only capabilities. Assign startup, notification, widget, receiver, persistence, or other shared responsibilities to the earliest real page that requires them and list downstream consumers.
62
+ 7. Legacy page work packages may contain many unrelated surfaces. Split them by actual page lifecycle and behavior ownership rather than retaining the old aggregate.
63
+
64
+ ### 3. Decide development order
65
+
66
+ Rate each dimension using an integer from 0 to 5, then calculate the score using the following formula:
67
+
68
+ `page_score = enablement × 9 + ordinary_reachability × 6 + shallowness × 5`(满分 100,分数越高越优先)。
69
+
70
+ - **Enablement (45%)** — use the highest evidence-backed enablement rating among the page's REQs. `5`: difficult to mock or bound, ambiguous in data ownership, and correctness-relevant across many features. `3`: reused across several features but cleanly isolatable. `1`: page-local. Repeated persistence keys, storage operations, data-flow hops, and consumers are evidence; a feature name is not.
71
+ - **Ordinary reachability (30%)** — `5`: reachable in normal app state. `3`: needs a common business state such as existing data, login, or permission. `0`: first-launch only or reachable only after clearing/resetting app-global state. Use intermediate ratings where evidence supports them.
72
+ - **Shallowness (25%)** — `5`: launch/main page; `4`: one page navigation; `3`: two; `2`: three; `1`: four or more. Derive depth from page boundaries in `page-path`, not click count. `__shared_capability__` uses neutral `3`.
73
+
74
+ When ordering, first satisfy evidence-backed prerequisites so that data or state providers precede their consumers. Sort all remaining pages by page_score in descending order, breaking ties by the normalized stable page_id in ascending order. Finally, assign consecutive order values starting from 1. Prerequisites may override score-based ordering; no other arbitrary reordering is allowed.
75
+
76
+ Write the ordered decisions to `<output_root>/pages.json` before creating page directories. Also write the ordinal, dependencies, and concise rationale into each Spec.
77
+
78
+ Use schema `d2h-page-plan/v1`. Every `pages[]` item must contain:
79
+
80
+ - consecutive one-based `order`;
81
+ - stable `page_id`, `kind`, `package`, and `page_path`;
82
+ - `spec_refs` and `req_refs` backed by Facts/source evidence;
83
+ - integer `page_score`;
84
+ - `decision_ledger.enablement.rating`, `ordinary_reachability.rating`, and `shallowness.rating`, with evidence and a concise calculation/rationale.
85
+
86
+ `package` must exactly match `page_NNNN_<name>-<id>`. Every `page.json` node must be represented by a page item or by an explicit exclusion/unmatched entry with a reason. The AI authors and checks this plan; do not use it as a substitute for reading source.
87
+
88
+ ### 4. Verify source before writing
89
+
90
+ 1. Open every cited Android `sourceEvidence.file` at the cited symbol or line.
91
+ 2. Follow handlers, repositories, state transitions, navigation, persistence, error paths, and platform side effects far enough to establish the observable result.
92
+ 3. Use `page.json` navigation steps, selectors, guards, expected-arrival rules, required state, and depth to reconstruct the semantic arrival path. Source-derived reachability is planning evidence, not runtime confirmation.
93
+ 4. Translate selectors into semantic control names only when Facts, resources, or Android source support the mapping. Keep missing or ambiguous selectors explicitly unresolved.
94
+ 5. Verify every listed Android path exists under `android_root`. Verify every HarmonyOS path marked `existing` exists under `harmony_root`; otherwise mark it `planned`.
95
+
96
+ ### 5. Write only `spec.md`
97
+
98
+ Use these headings in every page Spec:
99
+
100
+ ```markdown
101
+ # <页面名称> 迁移 Spec
102
+
103
+ ## 页面范围
104
+
105
+ - 页面标识:<稳定标识>
106
+ - 页面类型:<page | dialog | sheet | mode | other>
107
+ - Android 到达路径:<从真实入口开始的语义路径>
108
+ - 负责范围:<本 Spec 负责的状态和行为>
109
+ - 排除范围:<相邻但属于其他 Spec 的责任>
110
+
111
+ ## 开发顺序
112
+
113
+ - 顺序:<NNNN>
114
+ - 前置依赖:<无或其他页面标识/共享能力>
115
+ - 排序理由:<基于前置依赖和页面评分的说明>
116
+
117
+ ## 页面功能
118
+
119
+ - F-001:<用户动作及其可观察结果。>
120
+
121
+ ## UI 操作与验收
122
+
123
+ ### F-001
124
+
125
+ 1. <从真实应用入口进入当前页面。>
126
+ 2. <定位并操作具有语义名称的控件。>
127
+ 3. <断言可见状态、导航、数据效果或错误结果。>
128
+
129
+ ## Android 证据
130
+
131
+ | 证据 | 路径 / Ref | 支持的结论 |
132
+ |---|---|---|
133
+ | Facts | <surface/entry/control/interaction ref> | <范围或行为> |
134
+ | Android 源码 | <android_root 相对路径及符号/行> | <触发、分支和结果> |
135
+ | UTG Page | `.migration/utg/page.json` 中的 <node_id> | <到达路径、深度、前置状态、导航步骤与证据限制> |
136
+
137
+ ## HarmonyOS 实现范围
138
+
139
+ | 路径 | 状态 | 预期职责 / 校验点 |
140
+ |---|---|---|
141
+ | <harmony_root 相对路径> | existing 或 planned | <页面实现、共享影响和验收点> |
142
+
143
+ ## 未决项与平台差异
144
+
145
+ - <没有时明确写“无”。>
146
+ ```
147
+
148
+ When a page has no independent interaction, write one display/reachability feature and acceptance sequence instead of leaving the feature sections empty.
149
+
150
+ ### 6. Generate `batch_report.md`
151
+
152
+ After all page Specs are complete, generate `<output_root>/batch_report.md` from `pages.json` with the bundled renderer:
153
+
154
+ ```bash
155
+ python scripts/build_batch_report.py \
156
+ --pages-plan <output_root>/pages.json \
157
+ --output-root <output_root>
158
+ ```
159
+
160
+ The script requires every planned package to contain `spec.md`, never requires `ui-design.md`, and refuses to overwrite an existing report.
161
+
162
+ The report must contain:
163
+
164
+ - the source `pages.json` path and SHA-256;
165
+ - generation timestamp and ordered page count;
166
+ - one queue row per page with stable task ID `PAGE-NNNN`, page identity, relative `spec.md` link, development status, build status, validation status, and blocker;
167
+ - one detail section per task with dependencies, implementation files, test files, implementation commit or source snapshot, build evidence, test evidence, last update, blocker, and chronological execution notes;
168
+ - summary counts that exactly match the queue and detail sections.
169
+
170
+ Use these status values:
171
+
172
+ - development: `pending | in_progress | implemented | blocked`;
173
+ - build: `not_run | passed | failed | blocked`;
174
+ - validation: `not_run | passed | failed | blocked`.
175
+
176
+ Initial generation uses `pending`, `not_run`, and `not_run`, with empty implementation, test, evidence, commit/snapshot, timestamp, and blocker fields. Do not infer completion from existing HarmonyOS files or local test artifacts.
177
+
178
+ Once development has started, never rerun the renderer or overwrite `batch_report.md`. Update the existing queue row, detail section, counts, and notes in place while preserving execution history. If `pages.json`, the Spec set, or order no longer matches an existing report, stop and report the mismatch for AI reconciliation instead of silently resetting statuses.
179
+
180
+ ## Quality gates
181
+
182
+ - Every known source-proven page, dialog, sheet, and behaviorally distinct mode has exactly one `spec.md`, or its ownership is explicitly assigned to another Spec.
183
+ - Every distinct interaction has a unique `F-xxx`, and feature IDs match UI operation/acceptance sections one-to-one.
184
+ - Each feature states a user action and observable result, not an implementation instruction.
185
+ - Navigation, state changes, persistence, destructive confirmation, external intents, cancellation, dismissal, and error behavior remain explicit.
186
+ - Facts refs, `page.json` node IDs, Android source paths, and HarmonyOS paths are real and correctly classified.
187
+ - Existing HarmonyOS code or tests never cause a feature to be marked complete without current build and executed test evidence.
188
+ - Uncertainty remains explicit. Do not invent control names, outcomes, source mappings, runtime captures, or implementation status.
189
+ - Each `page_NNNN_<name>-<id>/` directory contains exactly one file named `spec.md`.
190
+ - `output_root` contains only `pages.json`, `batch_report.md`, and page directories; it contains no copied UI evidence, UI design, or generated validation artifact.
191
+ - Every page directory has exactly one queue row and one detail section in `batch_report.md`; task IDs, order, links, statuses, and counts agree.
192
+ - A task is complete only when development is `implemented` and both build and validation are `passed` with current evidence.
193
+
194
+ ## Result
195
+
196
+ Return:
197
+
198
+ - the ordered page directory list and ordering rationale;
199
+ - the number of generated, updated, and unchanged Specs;
200
+ - the absolute `pages.json` path;
201
+ - unreachable pages, capture-disabled nodes, and pages with incomplete arrival rules in `page.json`;
202
+ - ambiguous mappings and unmatched Facts;
203
+ - unresolved selector steps;
204
+ - legacy aggregate packages that were split;
205
+ - the absolute `batch_report.md` path;
206
+ - the absolute `output_root`.