@harmonyos-arkts/d2h 0.1.2 → 0.1.5

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 (71) hide show
  1. package/README.md +78 -44
  2. package/agents/android-to-hmos-00-orchestrator.md +34 -28
  3. package/agents/d2h.md +266 -95
  4. package/dist/bin/install-opencode.js +137 -43
  5. package/dist/src/install-opencode.js +44 -0
  6. package/dist/src/install-vscode.js +226 -0
  7. package/dist/src/toolchain.js +83 -0
  8. package/docs/environment-check.md +86 -0
  9. package/opencode/agents.json +1 -1
  10. package/opencode/vscode-d2h-package.json +7 -0
  11. package/opencode/vscode-d2h-plugin.mjs +29 -0
  12. package/package.json +6 -4
  13. package/schemas/task-envelope.schema.json +58 -4
  14. package/schemas/task-plan.schema.json +281 -63
  15. package/scripts/check-environment.mjs +321 -0
  16. package/skills/android2hmos_resources_convert/SKILL.md +37 -19
  17. package/skills/appgraph-rule-audit/SKILL.md +24 -5
  18. package/skills/d2h-hypium-forge/SKILL.md +252 -0
  19. package/skills/d2h-hypium-forge/references/functional-spec-template.md +140 -0
  20. package/skills/d2h-hypium-forge/references/official-api.md +135 -0
  21. package/skills/d2h-hypium-forge/references/pitfalls.md +98 -0
  22. package/skills/d2h-hypium-forge/references/testability-template.md +71 -0
  23. package/skills/d2h-hypium-forge/scripts/_common_template.py +614 -0
  24. package/skills/d2h-hypium-forge/scripts/analyze_results.py +156 -0
  25. package/skills/d2h-hypium-forge/scripts/assert_audit.py +107 -0
  26. package/skills/d2h-hypium-forge/scripts/collect_runtime_pages.py +169 -0
  27. package/skills/d2h-hypium-forge/scripts/forge_report.py +325 -0
  28. package/skills/d2h-hypium-forge/scripts/inject_resource_ids.py +114 -0
  29. package/skills/d2h-hypium-forge/scripts/lint_asserts.py +80 -0
  30. package/skills/d2h-hypium-forge/scripts/lint_locate.py +60 -0
  31. package/skills/d2h-hypium-forge/scripts/merge_appgraph.py +249 -0
  32. package/skills/d2h-hypium-forge/scripts/precondition.py +140 -0
  33. package/skills/d2h-hypium-forge/scripts/preinject_ids.py +232 -0
  34. package/skills/d2h-hypium-forge/scripts/run_direct.py +392 -0
  35. package/skills/d2h-hypium-forge/scripts/run_parallel.py +121 -0
  36. package/skills/d2h-hypium-forge/scripts/scan_features.py +255 -0
  37. package/skills/d2h-hypium-forge/scripts/upgrade_asserts.py +66 -0
  38. package/skills/d2h-hypium-forge/scripts/validate_scenarios.py +84 -0
  39. package/skills/d2h-utg-ai-generate/SKILL.md +128 -0
  40. package/skills/d2h-utg-ai-generate/references/click-paths-schema.json +76 -0
  41. package/skills/d2h-utg-ai-generate/references/extraction-guide.md +34 -0
  42. package/skills/d2h-utg-ai-generate/references/facts-contract.md +96 -0
  43. package/skills/d2h-utg-ai-generate/references/page-schema.json +61 -0
  44. package/skills/d2h-utg-ai-generate/references/utg-schema.json +89 -0
  45. package/skills/d2h-utg-ai-generate/scripts/build_page_json.py +314 -0
  46. package/skills/d2h-utg-ai-generate/scripts/build_utg.py +123 -0
  47. package/skills/d2h-utg-ai-generate/scripts/capture_from_page_json.ts +280 -0
  48. package/skills/d2h-utg-ai-generate/scripts/utg_common.py +524 -0
  49. package/skills/d2h-utg-ai-generate/scripts/utg_html.py +489 -0
  50. package/skills/d2h-utg-ai-generate/scripts/validate_utg.py +69 -0
  51. package/skills/d2h-utg-ai-generate/scripts/vendor/D3-LICENSE +13 -0
  52. package/skills/d2h-utg-ai-generate/scripts/vendor/d3-7.9.0.min.js +2 -0
  53. package/skills/d2h-utg-ai-generate/tests/test_pipeline.py +369 -0
  54. package/skills/d2h-utg-static-generate/SKILL.md +73 -0
  55. package/skills/d2h-utg-static-generate/references/discoveries.md +38 -0
  56. package/skills/d2h-utg-static-generate/scripts/generate.py +499 -0
  57. package/skills/d2h-utg-static-generate/tests/test_static.py +335 -0
  58. package/skills/d2h-utg-static-generate/tests/verify-offline-html.py +60 -0
  59. package/skills/d2h-utg-static-generate/tests/verify-produced-fixture.py +131 -0
  60. package/skills/harmonyos-migration-playbook/SKILL.md +30 -3
  61. package/skills/harmonyos-migration-playbook/references/lesson-lifecycle.md +4 -4
  62. package/skills/harmonyos-migration-playbook/references/ui-automation.md +4 -3
  63. package/skills/harmonyos-migration-playbook/references/windows-environment.md +2 -2
  64. package/skills/maintaining-migration-report/SKILL.md +88 -99
  65. package/skills/maintaining-migration-report/references/final-acceptance.md +48 -0
  66. package/skills/maintaining-migration-report/references/source-provenance.md +66 -0
  67. package/skills/managing-d2h-toolchain/SKILL.md +23 -0
  68. package/skills/managing-d2h-toolchain/environment-requirements.json +16 -0
  69. package/skills/managing-d2h-toolchain/toolchain.json +16 -0
  70. package/skills/preparing-migration-workspace/SKILL.md +76 -69
  71. package/skills/preparing-migration-workspace/toolchain.json +0 -43
@@ -0,0 +1,86 @@
1
+ # 迁移工具环境检查
2
+
3
+ 先手动安装 Node.js 22.5–24.x,确认 `node --version`。脚本只使用 Node 内置模块,无需 npm install,支持 Windows/macOS/Linux。
4
+
5
+ npx 集成入口(包含本次更新的包发布后可用):
6
+
7
+ ```sh
8
+ npx --yes @harmonyos-arkts/d2h@0.1.5 --check-env --output-dir ./environment-report
9
+ ```
10
+
11
+ 本地构建后:`node dist/bin/install-opencode.js --check-env`。检查参数在 --check-env 后传入;使用 --check-env --help 查看。检查模式不执行 Agent/Skill 安装;不能与 --force、--agent、--config-dir 等安装参数混用,误用时返回参数错误。npx 自身可能下载并缓存 npm 包。
12
+
13
+ ```powershell
14
+ node scripts/check-environment.mjs --output-dir D:/reports/hmos-environment
15
+ ```
16
+
17
+ ```sh
18
+ node scripts/check-environment.mjs --output-dir ~/reports/hmos-environment
19
+ ```
20
+
21
+ ## 当前检查项
22
+
23
+ | 项目 | 条件 |
24
+ | --- | --- |
25
+ | Node.js | 当前运行时为 24.x |
26
+ | Git | git --version 成功 |
27
+ | npm | npm --version 成功 |
28
+ | Java/JDK | java -version 成功,不固定 JDK 主版本 |
29
+ | Python | 找到 Python 3.10+,优先 PYTHON_BINARY |
30
+ | AppGraph | appgraph --version 成功且匹配 D2H 锁定的 0.0.10 |
31
+ | droid2hmos | droid2hmos --version 成功且匹配 D2H 锁定的 0.0.11 |
32
+ | DevEco 工具链目录 | 安装目录存在 |
33
+ | Hvigor | 版本命令成功 |
34
+ | ohpm | 版本命令成功 |
35
+ | DevEco CLI | devecocli --version 成功 |
36
+ | 开发者账号 | DevEco CLI 登录状态成功,报告不保留账号输出 |
37
+ | HarmonyOS SDK 目录 | 辅助诊断,不作为必需门禁 |
38
+
39
+ 按需检查:指定插件生产脚本导入 json5 时检查相同 Python 的 json5 模块;传入 --android-project 时检查源码 Gradle 配置标记;传入 --harmony-project 时枚举工程可用 SDK 版本。
40
+
41
+ SQLite/WASM 随 Node 提供,不单独检测。Android SDK/ADB/模拟器/构建、CLI capability/help、Agent 宿主、插件安装/启用/引用、所有设备发现和 Shell 检查均不执行。
42
+
43
+ ## 参数
44
+
45
+ 兼容组合以 `skills/managing-d2h-toolchain/toolchain.json` 为准;`skills/managing-d2h-toolchain/environment-requirements.json` 提供检查器的版本边界,构建检查确保 Node、AppGraph 与 droid2hmos 约束与兼容组合一致。默认 Node 为 `>=22.5.0 <25.0.0`,Python 为 `>=3.10.0`;其余未锁定的工具仅检查可用性。
46
+
47
+ 每项可配置 `minimum`(含下界)和 `maximumExclusive`(不含上界),支持 1–4 段纯数字版本,不能使用 latest、通配符、^ 或 ~。例如将 appgraph 改为 `{ "minimum": "0.0.8" }`,即可检测最低版本。保留全部工具键,无版本要求时使用 null。未知工具、无效边界或空区间会报错,不静默放宽约束。
48
+
49
+ 可使用自定义文件:
50
+
51
+ ```sh
52
+ npx --yes @harmonyos-arkts/d2h@0.1.5 --check-env --requirements ./environment-requirements.json
53
+ ```
54
+
55
+ 报告记录实际配置路径和约束;版本不符合时,命令行显示当前版本、要求和修复指导。此配置仅控制诊断命令,不修改 npm 包自身 engines 或 droid2hmos 的 preflight 规则。
56
+
57
+ - --plugin-root:用于判断插件生产 Python 脚本是否需要 json5,默认当前脚本所在仓库。
58
+ - --requirements:覆盖默认版本配置文件路径。
59
+ - --android-project:Android 源码目录,仅检查配置标记,不要求 Gradle Wrapper。
60
+ - --harmony-project:在该工程执行 DevEco CLI 的只读 SDK 版本枚举。
61
+ - --sdk-path:声明 SDK 根目录。
62
+ - --timeout:每条命令超时秒数,1–60,默认 15。
63
+ - --output-dir:报告目录,默认当前目录的 environment-report。
64
+ - --help:使用说明。
65
+
66
+ 不再提供 --host、--host-binary、--skip-devices 参数。
67
+
68
+ 工具环境变量:DEVECO_STUDIO_HOME、DEVECO_HOME、DROID2HMOS_HVIGOR、DROID2HMOS_OHPM、DEVECO_CLI_BINARY、PYTHON_BINARY、HARMONYOS_SDK_HOME、OHOS_SDK_HOME、DEVECO_SDK_HOME。macOS 包含 DevEco 默认 Contents 目录和常见 Python 安装路径。
69
+
70
+ ## 输出
71
+
72
+ 命令行先显示总体结果,然后逐项显示 `[通过]`、`[未通过]`、`[提醒]` 或 `[未检查]` 及版本/原因。未通过、提醒和未检查项下方直接显示修复指导,最后显示报告路径。完整明细、证据和修复指导保存在 environment.md/environment.json,重复执行覆盖。脚本只提供指导,不自动安装或修改环境。
73
+
74
+ 退出码:0=必需检查通过;1=必需失败或执行错误;2=必需项未检查或参数错误。SDK 辅助诊断 warning 不阻断通过。
75
+
76
+ 本报告仅确认上述主机依赖,不代表 CLI 分析能力、Agent 安装、项目构建、签名、SDK API 匹配、设备运行或端到端验收已通过。后续项目门禁仍由 droid2hmos preflight/test/device/complete 负责。脚本不自动安装、登录、构建或修改配置;被调用工具自身可能写缓存。
77
+
78
+ ## 源码依据
79
+
80
+ 2026-10-13 复核:AppGraph origin/dev c1d2ed1(仓库版本 0.0.8)、droid2hmos dev 0caabce(仓库版本 0.0.7)、插件 origin/skill 4a21758(仓库版本 0.1.3)。此前发现的插件 Agent 命名差异不属于当前环境检查范围。
81
+
82
+ 测试:
83
+
84
+ ```sh
85
+ node --test --test-concurrency=1 scripts/tests/environment.test.mjs
86
+ ```
@@ -1,5 +1,5 @@
1
1
  {
2
- "android-to-hmos-00-orchestrator": {
2
+ "d2h_v2": {
3
3
  "mode": "all",
4
4
  "hidden": false,
5
5
  "permissions": {
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "@harmonyos-arkts/d2h-vscode-plugin",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "main": "src/index.js"
7
+ }
@@ -0,0 +1,29 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
6
+ const agentFile = path.join(packageRoot, 'agents', 'd2h.md');
7
+ const skillsDirectory = path.join(packageRoot, 'skills');
8
+
9
+ export const plugin = async () => ({
10
+ config(config) {
11
+ config.agent ??= {};
12
+ const previous = config.agent.d2h ?? {};
13
+ config.agent.d2h = {
14
+ ...previous,
15
+ description: '安卓转鸿蒙',
16
+ mode: 'primary',
17
+ hidden: false,
18
+ prompt: fs.readFileSync(agentFile, 'utf8'),
19
+ tools: { ...previous.tools, question: true, task: true, read: true, write: true, edit: true },
20
+ permission: { ...previous.permission, read: 'allow', edit: 'allow' },
21
+ };
22
+ config.skills ??= {};
23
+ const paths = Array.isArray(config.skills.paths) ? config.skills.paths : [];
24
+ if (!paths.includes(skillsDirectory)) paths.push(skillsDirectory);
25
+ config.skills.paths = paths;
26
+ },
27
+ });
28
+
29
+ export default plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harmonyos-arkts/d2h",
3
- "version": "0.1.2",
3
+ "version": "0.1.5",
4
4
  "description": "Install Android-to-HarmonyOS migration agents and skills into OpenCode or DevEco Code",
5
5
  "type": "module",
6
6
  "bin": {
@@ -15,18 +15,20 @@
15
15
  "opencode/",
16
16
  ".claude-plugin/",
17
17
  "install-opencode.sh",
18
+ "scripts/check-environment.mjs",
19
+ "docs/environment-check.md",
18
20
  "README.md",
19
21
  "LICENSE"
20
22
  ],
21
23
  "scripts": {
22
24
  "build": "tsc -p tsconfig.json",
23
- "check": "tsc --noEmit && npm run build && node dist/scripts/check-skill-refs.js",
24
- "test": "npm run build && node --test dist/test/*.test.js",
25
+ "check": "tsc --noEmit && npm run build && node dist/scripts/check-skill-refs.js && node dist/scripts/check-toolchain.js",
26
+ "test": "npm run build && node --test dist/test/*.test.js scripts/tests/*.test.mjs",
25
27
  "prepack": "npm run build",
26
28
  "prepublishOnly": "npm run check && npm test"
27
29
  },
28
30
  "engines": {
29
- "node": ">=20 <25"
31
+ "node": ">=22.5.0 <25.0.0"
30
32
  },
31
33
  "repository": {
32
34
  "type": "git",
@@ -1,15 +1,44 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://harmonyos-ai.dev/schemas/task-envelope.schema.json",
4
- "title": "Android to HarmonyOS Task Envelope Page",
4
+ "title": "Android to HarmonyOS Model Input Envelope Page",
5
5
  "type": "object",
6
- "required": ["taskEnvelopeVersion", "taskPlanSha256", "task", "brief", "coreFacts", "sourceContext", "continuation"],
6
+ "required": ["taskEnvelopeVersion", "taskPlanSha256", "targetKind", "targetId", "task", "pageWorkPackage", "contract", "brief", "coreFacts", "dependencyInterfaces", "acceptance", "sourceContext", "continuation"],
7
7
  "properties": {
8
- "taskEnvelopeVersion": { "const": "1.0.0" },
8
+ "taskEnvelopeVersion": { "const": "3.0.0" },
9
9
  "taskPlanSha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
10
- "task": { "type": "object" },
10
+ "targetKind": { "enum": ["resolution-task", "page-work-package"] },
11
+ "targetId": { "type": "string", "pattern": "^(task|package):[a-f0-9]{16}$" },
12
+ "task": { "type": ["object", "null"] },
13
+ "pageWorkPackage": { "type": ["object", "null"] },
14
+ "contract": {
15
+ "oneOf": [
16
+ {
17
+ "type": "object",
18
+ "required": ["executionPlanSha256", "baseline", "task"],
19
+ "properties": {
20
+ "executionPlanSha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
21
+ "baseline": { "type": "object" },
22
+ "task": { "type": "object" }
23
+ },
24
+ "additionalProperties": false
25
+ },
26
+ {
27
+ "type": "object",
28
+ "required": ["executionPlanSha256", "baseline", "pageWorkPackage"],
29
+ "properties": {
30
+ "executionPlanSha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
31
+ "baseline": { "type": "object" },
32
+ "pageWorkPackage": { "type": "object" }
33
+ },
34
+ "additionalProperties": false
35
+ }
36
+ ]
37
+ },
11
38
  "brief": { "type": "string", "minLength": 1 },
12
39
  "coreFacts": { "type": "array" },
40
+ "dependencyInterfaces": { "type": "array", "items": { "type": "object" } },
41
+ "acceptance": { "type": "object" },
13
42
  "sourceContext": {
14
43
  "description": "Bounded source location indexes only. Source text/snippets are forbidden.",
15
44
  "type": "array",
@@ -26,6 +55,30 @@
26
55
  "additionalProperties": false
27
56
  }
28
57
  },
58
+ "allOf": [
59
+ {
60
+ "if": { "properties": { "targetKind": { "const": "resolution-task" } } },
61
+ "then": {
62
+ "properties": {
63
+ "targetId": { "pattern": "^task:[a-f0-9]{16}$" },
64
+ "task": { "type": "object" },
65
+ "pageWorkPackage": { "const": null },
66
+ "contract": { "required": ["task"] }
67
+ }
68
+ }
69
+ },
70
+ {
71
+ "if": { "properties": { "targetKind": { "const": "page-work-package" } } },
72
+ "then": {
73
+ "properties": {
74
+ "targetId": { "pattern": "^package:[a-f0-9]{16}$" },
75
+ "task": { "const": null },
76
+ "pageWorkPackage": { "type": "object" },
77
+ "contract": { "required": ["pageWorkPackage"] }
78
+ }
79
+ }
80
+ }
81
+ ],
29
82
  "$defs": {
30
83
  "sourceIndex": {
31
84
  "type": "object",
@@ -41,6 +94,7 @@
41
94
  "symbol": { "type": ["string", "null"] },
42
95
  "kind": { "type": "string" },
43
96
  "type": { "type": "string" },
97
+ "capabilityRef": { "type": "string" },
44
98
  "line": { "type": ["integer", "null"], "minimum": 1 },
45
99
  "startLine": { "type": "integer", "minimum": 1 },
46
100
  "endLine": { "type": ["integer", "null"], "minimum": 1 }