@buaa_smat/hometrans 0.1.0 → 0.1.2

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 (136) hide show
  1. package/README.md +141 -124
  2. package/agents/build-fixer.md +1 -0
  3. package/agents/code-review-fix.md +1 -0
  4. package/agents/code-reviewer.md +1 -0
  5. package/agents/logic-coding.md +1 -0
  6. package/agents/logic-context-builder.md +1 -0
  7. package/agents/review-fixer.md +1 -0
  8. package/agents/self-test-fixer.md +1 -0
  9. package/agents/self-tester.md +260 -233
  10. package/agents/spec-generator.md +1 -0
  11. package/agents/test-tools/autotest/README.md +223 -0
  12. package/agents/test-tools/autotest/config.yaml.example +58 -0
  13. package/agents/test-tools/autotest/pyproject.toml +16 -0
  14. package/agents/test-tools/autotest/report_tool.py +759 -0
  15. package/agents/test-tools/autotest/self_test_runner.py +773 -0
  16. package/agents/test-tools/autotest/testcases_schema.md +143 -0
  17. package/agents/test-tools/autotest/testcases_tool.py +215 -0
  18. package/agents/test-tools/autotest/uv.lock +3156 -0
  19. package/agents/test-tools/harmony_autotest-0.1.0-py3-none-any.whl +0 -0
  20. package/agents/test-tools/hypium-6.1.0.210-py3-none-any.whl +0 -0
  21. package/agents/test-tools/hypium_mcp-0.6.5-py3-none-any.whl +0 -0
  22. package/agents/test-tools/xdevice-6.1.0.210-py3-none-any.whl +0 -0
  23. package/agents/test-tools/xdevice_devicetest-6.1.0.210-py3-none-any.whl +0 -0
  24. package/agents/test-tools/xdevice_ohos-6.1.0.210-py3-none-any.whl +0 -0
  25. package/dist/cli/config-store.js +27 -2
  26. package/dist/cli/config.js +17 -6
  27. package/dist/cli/index.js +3 -2
  28. package/dist/cli/init.js +135 -22
  29. package/dist/cli/mcp.js +2 -2
  30. package/dist/context/index.js +165 -69
  31. package/package.json +59 -60
  32. package/skills/code-dev-review-fix/SKILL.md +279 -0
  33. package/skills/code-dev-review-fix-workspace/evals/evals.json +56 -0
  34. package/skills/code-dev-review-fix-workspace/iteration-1/routing-results.md +23 -0
  35. package/skills/convert_pipeline/SKILL.md +423 -439
  36. package/skills/hmos-resources-convert/SKILL.md +623 -0
  37. package/skills/hmos-resources-convert/evals/evals.json +171 -0
  38. package/skills/hmos-resources-convert/references/conversion-rules.md +663 -0
  39. package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +388 -0
  40. package/skills/hmos-resources-convert/references/resource-mapping-rules.md +457 -0
  41. package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +513 -0
  42. package/skills/hmos-resources-convert/template/AppScope/app.json5 +10 -0
  43. package/skills/hmos-resources-convert/template/AppScope/resources/base/element/string.json +8 -0
  44. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/background.png +0 -0
  45. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/foreground.png +0 -0
  46. package/skills/hmos-resources-convert/template/AppScope/resources/base/media/layered_image.json +7 -0
  47. package/skills/hmos-resources-convert/template/build-profile.json5 +42 -0
  48. package/skills/hmos-resources-convert/template/code-linter.json5 +32 -0
  49. package/skills/hmos-resources-convert/template/entry/build-profile.json5 +33 -0
  50. package/skills/hmos-resources-convert/template/entry/hvigorfile.ts +6 -0
  51. package/skills/hmos-resources-convert/template/entry/obfuscation-rules.txt +23 -0
  52. package/skills/hmos-resources-convert/template/entry/oh-package.json5 +10 -0
  53. package/skills/hmos-resources-convert/template/entry/src/main/ets/entryability/EntryAbility.ets +48 -0
  54. package/skills/hmos-resources-convert/template/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +16 -0
  55. package/skills/hmos-resources-convert/template/entry/src/main/ets/pages/Index.ets +23 -0
  56. package/skills/hmos-resources-convert/template/entry/src/main/module.json5 +55 -0
  57. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/color.json +8 -0
  58. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/float.json +8 -0
  59. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/element/string.json +16 -0
  60. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/background.png +0 -0
  61. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/foreground.png +0 -0
  62. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/layered_image.json +7 -0
  63. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/media/startIcon.png +0 -0
  64. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/backup_config.json +3 -0
  65. package/skills/hmos-resources-convert/template/entry/src/main/resources/base/profile/main_pages.json +5 -0
  66. package/skills/hmos-resources-convert/template/entry/src/main/resources/dark/element/color.json +8 -0
  67. package/skills/hmos-resources-convert/template/entry/src/mock/mock-config.json5 +2 -0
  68. package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/Ability.test.ets +35 -0
  69. package/skills/hmos-resources-convert/template/entry/src/ohosTest/ets/test/List.test.ets +5 -0
  70. package/skills/hmos-resources-convert/template/entry/src/ohosTest/module.json5 +16 -0
  71. package/skills/hmos-resources-convert/template/entry/src/test/List.test.ets +5 -0
  72. package/skills/hmos-resources-convert/template/entry/src/test/LocalUnit.test.ets +33 -0
  73. package/skills/hmos-resources-convert/template/hvigor/hvigor-config.json5 +23 -0
  74. package/skills/hmos-resources-convert/template/hvigorfile.ts +6 -0
  75. package/skills/hmos-resources-convert/template/oh-package-lock.json5 +28 -0
  76. package/skills/hmos-resources-convert/template/oh-package.json5 +10 -0
  77. package/skills/hmos-resources-convert/tools/apktool.bat +85 -0
  78. package/skills/hmos-resources-convert/tools/apktool_3.0.1.jar +0 -0
  79. package/skills/hmos-ui-align/SKILL.md +182 -0
  80. package/skills/hmos-ui-align/config-example.json +11 -0
  81. package/skills/hmos-ui-align/config.json +11 -0
  82. package/skills/hmos-ui-align/diff_analysis.md +53 -0
  83. package/skills/hmos-ui-align/page_align.md +62 -0
  84. package/skills/hmos-ui-align/readme.md +231 -0
  85. package/skills/hmos-ui-align/references/Comparison_Template.md +2 -0
  86. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -0
  87. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2089 -0
  88. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -0
  89. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -0
  90. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -0
  91. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -0
  92. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -0
  93. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +903 -0
  94. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -0
  95. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -0
  96. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217V1.md +911 -0
  97. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -0
  98. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +355 -0
  99. package/skills/hmos-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -0
  100. package/skills/hmos-ui-align/references/UI_Analysis_Template.md +4 -0
  101. package/skills/hmos-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2535 -0
  102. package/skills/hmos-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -0
  103. package/skills/hmos-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -0
  104. package/skills/hmos-ui-align/scripts/app_feature_verify.py +443 -0
  105. package/skills/hmos-ui-align/scripts/navigation-capure.md +37 -0
  106. package/skills/hmos-ui-align/scripts/page_capture.py +592 -0
  107. package/skills/hmos-ui-align-batch/SKILL.md +99 -0
  108. package/skills/hmos-ui-align-batch/references/conversion-procedure.md +180 -0
  109. package/skills/hmos-ui-align-batch/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2535 -0
  110. package/skills/hmos-ui-align-batch/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -0
  111. package/skills/hmos-ui-align-batch/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -0
  112. package/skills/hmos-ui-align-batch/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -0
  113. package/skills/hmos-ui-align-batch/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2089 -0
  114. package/skills/hmos-ui-align-batch/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -0
  115. package/skills/hmos-ui-align-batch/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -0
  116. package/skills/hmos-ui-align-batch/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -0
  117. package/skills/hmos-ui-align-batch/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -0
  118. package/skills/hmos-ui-align-batch/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -0
  119. package/skills/hmos-ui-align-batch/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +903 -0
  120. package/skills/hmos-ui-align-batch/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -0
  121. package/skills/hmos-ui-align-batch/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -0
  122. package/skills/hmos-ui-align-batch/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -0
  123. package/skills/hmos-ui-align-batch/references/mvvm/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +355 -0
  124. package/skills/hmos-ui-align-batch/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -0
  125. package/skills/hmos-ui-align-batch/scripts/android_parse_fast.py +1606 -0
  126. package/skills/self-test/SKILL.md +369 -0
  127. package/skills/self-test/readme.md +309 -0
  128. package/skills/spec-generator-skill/SKILL.md +332 -0
  129. package/skills/spec-generator-skill/references/android-platform-tokens.md +105 -0
  130. package/skills/spec-generator-skill/references/spec-sample-1.md +78 -0
  131. package/skills/spec-generator-skill/references/spec-sample-2.md +58 -0
  132. package/skills/spec-generator-skill/references/spec-sample-3.md +116 -0
  133. package/skills/spec-generator-skill/references/step4-report-template.md +33 -0
  134. package/agents/self-test-setup.md +0 -165
  135. package/dist/context/resources/sdkConfig.json +0 -24
  136. package/src/context/resources/sdkConfig.json +0 -24
@@ -1,9 +1,7 @@
1
1
  import { createRequire as _htCreateRequire } from 'module'; const require = _htCreateRequire(import.meta.url);
2
2
 
3
3
  // src/context/index.ts
4
- import fs3 from "node:fs";
5
- import path3 from "node:path";
6
- import { fileURLToPath } from "node:url";
4
+ import path4 from "node:path";
7
5
  import {
8
6
  CallGraph as CallGraph2,
9
7
  CallGraphBuilder,
@@ -11,6 +9,124 @@ import {
11
9
  SceneConfig
12
10
  } from "arkanalyzer";
13
11
 
12
+ // src/cli/config-store.ts
13
+ import fs from "node:fs/promises";
14
+ import path from "node:path";
15
+ import os from "node:os";
16
+ function getConfigDir() {
17
+ return path.join(os.homedir(), ".hometrans");
18
+ }
19
+ function getConfigPath() {
20
+ return path.join(getConfigDir(), "config.json");
21
+ }
22
+ function expandHome(p) {
23
+ if (!p) return p;
24
+ if (p === "~") return os.homedir();
25
+ if (p.startsWith("~/") || p.startsWith("~\\")) {
26
+ return path.join(os.homedir(), p.slice(2));
27
+ }
28
+ return p;
29
+ }
30
+ function defaultEditors() {
31
+ return [
32
+ {
33
+ name: "Claude Code",
34
+ markerDir: "~/.claude",
35
+ skillsDir: "~/.claude/skills",
36
+ agentsDir: "~/.claude/agents",
37
+ mcp: {
38
+ format: "jsonc-object",
39
+ path: "~/.claude.json",
40
+ keyPath: ["mcpServers", "hometrans"]
41
+ }
42
+ },
43
+ {
44
+ name: "Cursor",
45
+ markerDir: "~/.cursor",
46
+ skillsDir: "~/.cursor/skills",
47
+ agentsDir: "~/.cursor/agents",
48
+ mcp: {
49
+ format: "jsonc-object",
50
+ path: "~/.cursor/mcp.json",
51
+ keyPath: ["mcpServers", "hometrans"]
52
+ }
53
+ },
54
+ {
55
+ name: "OpenCode",
56
+ markerDir: "~/.config/opencode",
57
+ skillsDir: "~/.config/opencode/skills",
58
+ agentsDir: "~/.config/opencode/agents",
59
+ mcp: {
60
+ format: "jsonc-command-array",
61
+ path: "~/.config/opencode/opencode.json",
62
+ keyPath: ["mcp", "hometrans"]
63
+ }
64
+ },
65
+ {
66
+ name: "Codex",
67
+ markerDir: "~/.codex",
68
+ // Codex 复用 Agent Skills 公共目录,agent 定义独立。
69
+ skillsDir: "~/.agents/skills",
70
+ agentsDir: "~/.codex/agents",
71
+ mcp: {
72
+ format: "codex-cli",
73
+ path: "~/.codex/config.toml",
74
+ section: "mcp_servers.hometrans"
75
+ }
76
+ }
77
+ ];
78
+ }
79
+ async function fileExists(p) {
80
+ try {
81
+ await fs.access(p);
82
+ return true;
83
+ } catch {
84
+ return false;
85
+ }
86
+ }
87
+ function defaultUserParams() {
88
+ return {
89
+ OHOS_SDK_PATH: "",
90
+ HMS_SDK_PATH: "",
91
+ TEST_API_KEY: ""
92
+ };
93
+ }
94
+ async function loadHomeTransConfig() {
95
+ const configPath = getConfigPath();
96
+ if (!await fileExists(configPath)) {
97
+ const config2 = {
98
+ editors: defaultEditors(),
99
+ params: defaultUserParams()
100
+ };
101
+ await fs.mkdir(getConfigDir(), { recursive: true });
102
+ await fs.writeFile(configPath, JSON.stringify(config2, null, 2) + "\n", "utf-8");
103
+ return config2;
104
+ }
105
+ const raw = await fs.readFile(configPath, "utf-8");
106
+ let parsed;
107
+ try {
108
+ parsed = JSON.parse(raw);
109
+ } catch (err) {
110
+ throw new Error(
111
+ `Failed to parse ${configPath}: ${err.message}. Fix the JSON or delete the file to restore defaults.`
112
+ );
113
+ }
114
+ if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.editors)) {
115
+ throw new Error(
116
+ `Invalid config.json shape at ${configPath}: top-level must be { "editors": [...] }.`
117
+ );
118
+ }
119
+ const config = parsed;
120
+ const legacy = parsed.sdkPaths;
121
+ if (!config.params) {
122
+ config.params = { ...defaultUserParams(), ...legacy ?? {} };
123
+ } else {
124
+ config.params = { ...defaultUserParams(), ...config.params };
125
+ }
126
+ delete config.sdkPaths;
127
+ return config;
128
+ }
129
+
14
130
  // src/context/analysis/ArkTsGitInfoAnalysis.ts
15
131
  import {
16
132
  AbstractInvokeExpr,
@@ -21,13 +137,13 @@ import {
21
137
  FunctionType,
22
138
  parseJsonText
23
139
  } from "arkanalyzer";
24
- import path2 from "path";
25
- import fs2 from "fs";
140
+ import path3 from "path";
141
+ import fs3 from "fs";
26
142
 
27
143
  // src/context/utils/util.ts
28
144
  import LoggerMod, { LOG_MODULE_TYPE } from "arkanalyzer/lib/utils/logger.js";
29
- import path from "path";
30
- import fs from "fs";
145
+ import path2 from "path";
146
+ import fs2 from "fs";
31
147
  var Logger = LoggerMod.default ?? LoggerMod;
32
148
  var logger = Logger.getLogger(LOG_MODULE_TYPE.DEFAULT, "util");
33
149
  function safePush(target, source, maxBatchSize = 1e4) {
@@ -37,21 +153,21 @@ function safePush(target, source, maxBatchSize = 1e4) {
37
153
  }
38
154
  }
39
155
  function getAllFiles(dirPath, exts, filenameArr = [], visited = /* @__PURE__ */ new Set()) {
40
- if (!fs.existsSync(dirPath)) {
156
+ if (!fs2.existsSync(dirPath)) {
41
157
  logger.error(`'${dirPath}' is not exist, please check!`);
42
158
  return filenameArr;
43
159
  }
44
- const realSrc = fs.realpathSync(dirPath);
160
+ const realSrc = fs2.realpathSync(dirPath);
45
161
  if (visited.has(realSrc)) {
46
162
  return filenameArr;
47
163
  }
48
164
  visited.add(realSrc);
49
- fs.readdirSync(realSrc).forEach((fileName) => {
165
+ fs2.readdirSync(realSrc).forEach((fileName) => {
50
166
  if (shouldSkipFile(fileName)) {
51
167
  return;
52
168
  }
53
- const realFile = path.resolve(realSrc, fileName);
54
- if (fs.statSync(realFile).isDirectory()) {
169
+ const realFile = path2.resolve(realSrc, fileName);
170
+ if (fs2.statSync(realFile).isDirectory()) {
55
171
  getAllFiles(realFile, exts, filenameArr, visited);
56
172
  } else {
57
173
  if (exts.length === 0) {
@@ -70,11 +186,14 @@ function shouldAddFile(filePath, exts) {
70
186
  if (exts.length === 0) {
71
187
  return true;
72
188
  }
73
- const ext = path.extname(filePath).toLowerCase();
189
+ const ext = path2.extname(filePath).toLowerCase();
74
190
  return exts.includes(ext);
75
191
  }
76
192
  function getFilePath(parts) {
77
- return path.join(...parts);
193
+ return path2.join(...parts);
194
+ }
195
+ function toUnixPath(p) {
196
+ return p.replace(/\\/g, "/");
78
197
  }
79
198
 
80
199
  // src/context/analysis/ArkTsGitInfoAnalysis.ts
@@ -106,7 +225,7 @@ var ArkTsGitInfoAnalysis = class {
106
225
  gitItem;
107
226
  moduleDependencies;
108
227
  modulePathDependenciesMap = /* @__PURE__ */ new Map();
109
- maxCallDepth = 4;
228
+ maxCallDepth = 2;
110
229
  analysis = (arkFile, gitItem, callGraph, mode) => {
111
230
  this.callGraph = callGraph;
112
231
  this.mode = mode;
@@ -137,7 +256,7 @@ var ArkTsGitInfoAnalysis = class {
137
256
  return this.dependencyFileDict;
138
257
  };
139
258
  getModuleDependency(modulePath) {
140
- let OhPkgFilePath = path2.join(modulePath, "oh-package.json5");
259
+ let OhPkgFilePath = path3.join(modulePath, "oh-package.json5");
141
260
  console.log(`modulePath ${modulePath} OhPkgFilePath ${OhPkgFilePath}`);
142
261
  let libOhPkgContent = fetchDependenciesFromFile(OhPkgFilePath);
143
262
  let dependencies = libOhPkgContent.dependencies;
@@ -147,9 +266,9 @@ var ArkTsGitInfoAnalysis = class {
147
266
  }
148
267
  Object.entries(dependencies).forEach(([key, value]) => {
149
268
  if (key.startsWith("@ohos") && value.startsWith("file:")) {
150
- const targetModulePath = path2.resolve(modulePath, value.replace("file:", ""));
269
+ const targetModulePath = path3.resolve(modulePath, value.replace("file:", ""));
151
270
  if (!this.moduleDependencies.has(targetModulePath)) {
152
- const targetModuleResourcePath = path2.join(targetModulePath, "src", "main", "resources");
271
+ const targetModuleResourcePath = path3.join(targetModulePath, "src", "main", "resources");
153
272
  const moduleDependency = new ModuleDependency();
154
273
  moduleDependency.moduleName = key.replace("@ohos/", "");
155
274
  moduleDependency.modulePath = targetModulePath;
@@ -243,7 +362,7 @@ var ArkTsGitInfoAnalysis = class {
243
362
  const jsonItems = [];
244
363
  const results = getAllFiles(resourcePath, [fileName]);
245
364
  for (const result of results) {
246
- const configText = fs2.readFileSync(result, "utf8");
365
+ const configText = fs3.readFileSync(result, "utf8");
247
366
  const json = parseJsonText(configText);
248
367
  jsonItems.push({ path: result, content: json });
249
368
  }
@@ -256,9 +375,7 @@ var ArkTsGitInfoAnalysis = class {
256
375
  return !(method.getName() === "constructor" && method.getCode() === "") && method.getLine() !== -1 && method.getCode() !== void 0;
257
376
  }
258
377
  analysisFileStructureTree(arkFile) {
259
- arkFile.getModuleScene().getModulePath();
260
378
  let arkClasses = arkFile.getClasses().filter((cls) => cls.getName() === "%dflt" || !cls.getName().startsWith("%"));
261
- let classNames = arkClasses.map((cls) => cls.getName());
262
379
  for (const arkClass of arkClasses) {
263
380
  if (arkClass.getName() === "%dflt") {
264
381
  this.analysisClassStructureTree(arkClass);
@@ -382,15 +499,17 @@ var ArkTsGitInfoAnalysis = class {
382
499
  }
383
500
  }
384
501
  let setEdges = callgraph.getCallGraphNodeByMethod(arkMethod.getSignature()).getOutgoingEdges();
385
- setEdges.forEach((edge) => {
386
- let dst = edge.getDstNode();
387
- if (dst instanceof CallGraphNode && !dst.isSdkMethod()) {
388
- let dstMethodSignature = dst.getMethod();
389
- let dstMethod = this.scene.getMethod(dstMethodSignature);
390
- console.log(`[callee] ${arkMethod.getSignature()} calls ${dstMethodSignature} in ${dstMethod.getDeclaringArkClass().getDeclaringArkFile().getName()}`);
391
- this.analysisCallArkFile(dstMethod, 1);
392
- }
393
- });
502
+ if (setEdges) {
503
+ setEdges.forEach((edge) => {
504
+ let dst = edge.getDstNode();
505
+ if (dst instanceof CallGraphNode && !dst.isSdkMethod()) {
506
+ let dstMethodSignature = dst.getMethod();
507
+ let dstMethod = this.scene.getMethod(dstMethodSignature);
508
+ console.log(`[callee] ${arkMethod.getSignature()} calls ${dstMethodSignature} in ${dstMethod.getDeclaringArkClass().getDeclaringArkFile().getName()}`);
509
+ this.analysisCallArkFile(dstMethod, 1);
510
+ }
511
+ });
512
+ }
394
513
  }
395
514
  }
396
515
  }
@@ -554,8 +673,6 @@ async function extractCommitDiff(repoPath, commitId) {
554
673
  }
555
674
 
556
675
  // src/context/index.ts
557
- var __filename = fileURLToPath(import.meta.url);
558
- var __dirname = path3.dirname(__filename);
559
676
  function linesToRanges(lines) {
560
677
  const ranges = [];
561
678
  let start = -1;
@@ -573,37 +690,22 @@ function linesToRanges(lines) {
573
690
  }
574
691
  return ranges;
575
692
  }
576
- function resolveSdkConfigPath() {
577
- return path3.resolve(__dirname, "resources", "sdkConfig.json");
578
- }
579
- function resolveResourcesRoot() {
580
- return path3.resolve(__dirname, "resources");
581
- }
582
693
  function loadSdks(ohosSdkPath, hmsSdkPath) {
583
- const sdkConfigPath = resolveSdkConfigPath();
584
- if (!fs3.existsSync(sdkConfigPath)) {
585
- throw new Error(`HomeTrans context: sdkConfig.json not found at ${sdkConfigPath}`);
586
- }
587
- const configurations = JSON.parse(fs3.readFileSync(sdkConfigPath, "utf-8"));
588
- const sdks = configurations.sdks ?? [];
589
- const resourcesRoot = resolveResourcesRoot();
590
- sdks.forEach((sdk) => {
591
- if (sdk.name === "ohosSdk") {
592
- sdk.path = ohosSdkPath;
593
- } else if (sdk.name === "hmsSdk") {
594
- sdk.path = hmsSdkPath;
595
- } else {
596
- const stripped = sdk.path.replace(/^\.\/?resources[\\/]?/, "");
597
- sdk.path = path3.join(resourcesRoot, stripped);
598
- }
599
- });
600
- return sdks;
694
+ return [
695
+ { name: "ohosSdk", path: ohosSdkPath, moduleName: "" },
696
+ { name: "hmsSdk", path: hmsSdkPath, moduleName: "" }
697
+ ];
601
698
  }
602
699
  async function extractCommitContext(input) {
603
700
  const { projectPath, commitId } = input;
604
701
  const mode = input.mode ?? "default";
605
- const ohosSdkPath = input.ohosSdkPath ?? process.env.HOMETRANS_OHOS_SDK_PATH ?? "";
606
- const hmsSdkPath = input.hmsSdkPath ?? process.env.HOMETRANS_HMS_SDK_PATH ?? "";
702
+ const config = await loadHomeTransConfig();
703
+ const ohosSdkPath = expandHome(
704
+ input.ohosSdkPath ?? config.params.OHOS_SDK_PATH ?? process.env.OHOS_SDK_PATH ?? ""
705
+ );
706
+ const hmsSdkPath = expandHome(
707
+ input.hmsSdkPath ?? config.params.HMS_SDK_PATH ?? process.env.HMS_SDK_PATH ?? ""
708
+ );
607
709
  if (!projectPath) {
608
710
  throw new Error("extractCommitContext: projectPath is required");
609
711
  }
@@ -612,7 +714,7 @@ async function extractCommitContext(input) {
612
714
  }
613
715
  if (!ohosSdkPath && !hmsSdkPath) {
614
716
  throw new Error(
615
- "extractCommitContext: ohosSdkPath/hmsSdkPath not provided. Pass them as tool input or set HOMETRANS_OHOS_SDK_PATH / HOMETRANS_HMS_SDK_PATH env vars (e.g. D:\\DevEco Studio\\sdk\\default\\openharmony\\ets)."
717
+ "extractCommitContext: ohosSdkPath/hmsSdkPath not provided. Set params.OHOS_SDK_PATH / params.HMS_SDK_PATH in ~/.hometrans/config.json (view with `ht config`), pass them as tool input, or set OHOS_SDK_PATH / HMS_SDK_PATH env vars (e.g. D:\\DevEco Studio\\sdk\\default\\openharmony\\ets)."
616
718
  );
617
719
  }
618
720
  console.error(
@@ -642,22 +744,16 @@ async function extractCommitContext(input) {
642
744
  const gitAnalysis = new ArkTsGitInfoAnalysis();
643
745
  for (const gitItem of gitItems) {
644
746
  for (const arkFile of arkFiles) {
645
- let paths = gitItem.path.split("/");
646
- if (gitItem.path.startsWith("NewPhotos")) {
647
- paths = paths.slice(1);
648
- paths.unshift(arkFile.getProjectDir());
649
- } else {
650
- paths.unshift(arkFile.getProjectDir());
651
- }
652
- const gitFilePath = getFilePath(paths);
653
- if (arkFile.getFilePath() === gitFilePath) {
747
+ const segments = gitItem.path.split(/[\\/]+/).filter(Boolean);
748
+ const gitFilePath = getFilePath([arkFile.getProjectDir(), ...segments]);
749
+ if (toUnixPath(arkFile.getFilePath()) === toUnixPath(gitFilePath)) {
654
750
  gitAnalysis.analysis(arkFile, gitItem, callGraph, mode);
655
751
  }
656
752
  }
657
753
  }
658
754
  const dependencyResourceMap = gitAnalysis.dependencyResourceMap;
659
755
  dependencyResourceMap.forEach((resource, filePath) => {
660
- const base = path3.basename(filePath);
756
+ const base = path4.basename(filePath);
661
757
  if (base === "string.json" || base === "plural.json" || base === "strarray.json") {
662
758
  analysisResult.push({
663
759
  path: filePath,
package/package.json CHANGED
@@ -1,60 +1,59 @@
1
- {
2
- "name": "@buaa_smat/hometrans",
3
- "version": "0.1.0",
4
- "description": "HomeTrans (Android-to-HarmonyOS) skill + agent installer. Run `ht init` to distribute conversion skills and subagents into AI editors.",
5
- "license": "MIT",
6
- "type": "module",
7
- "bin": {
8
- "hometrans": "dist/cli/index.js",
9
- "ht": "dist/cli/index.js"
10
- },
11
- "files": [
12
- "dist",
13
- "skills",
14
- "agents",
15
- "src/context/resources"
16
- ],
17
- "scripts": {
18
- "build": "node scripts/build.js",
19
- "dev": "tsx src/cli/index.ts",
20
- "prepare": "node scripts/build.js",
21
- "prepack": "node scripts/build.js"
22
- },
23
- "dependencies": {
24
- "@modelcontextprotocol/sdk": "^1.0.4",
25
- "arkanalyzer": "^1.0.19",
26
- "chalk": "^5.6.2",
27
- "commander": "^14.0.0",
28
- "figlet": "^1.11.0",
29
- "fs-extra": "11.3.0",
30
- "inquirer": "^14.0.0",
31
- "jsonc-parser": "^3.3.1",
32
- "simple-git": "^3.25.0"
33
- },
34
- "devDependencies": {
35
- "@types/figlet": "^1.7.0",
36
- "@types/fs-extra": "^9.0.13",
37
- "@types/inquirer": "^9.0.9",
38
- "@types/node": "^22.0.0",
39
- "esbuild": "^0.28.0",
40
- "tsx": "^4.0.0",
41
- "typescript": "^5.4.5"
42
- },
43
- "publishConfig": {
44
- "access": "public"
45
- },
46
- "engines": {
47
- "node": ">=18.0.0"
48
- },
49
- "keywords": [
50
- "hometrans",
51
- "harmonyos",
52
- "android",
53
- "skill",
54
- "claude-code",
55
- "cursor",
56
- "opencode",
57
- "codex",
58
- "mcp"
59
- ]
60
- }
1
+ {
2
+ "name": "@buaa_smat/hometrans",
3
+ "version": "0.1.2",
4
+ "description": "HomeTrans (Android-to-HarmonyOS) skill + agent installer. Run `ht init` to distribute conversion skills and subagents into AI editors.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "hometrans": "dist/cli/index.js",
9
+ "ht": "dist/cli/index.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "skills",
14
+ "agents"
15
+ ],
16
+ "scripts": {
17
+ "build": "node scripts/build.js",
18
+ "dev": "tsx src/cli/index.ts",
19
+ "prepare": "node scripts/build.js",
20
+ "prepack": "node scripts/build.js"
21
+ },
22
+ "dependencies": {
23
+ "@modelcontextprotocol/sdk": "^1.0.4",
24
+ "arkanalyzer": "^1.0.19",
25
+ "chalk": "^5.6.2",
26
+ "commander": "^14.0.0",
27
+ "figlet": "^1.11.0",
28
+ "fs-extra": "11.3.0",
29
+ "inquirer": "^14.0.0",
30
+ "jsonc-parser": "^3.3.1",
31
+ "simple-git": "^3.25.0"
32
+ },
33
+ "devDependencies": {
34
+ "@types/figlet": "^1.7.0",
35
+ "@types/fs-extra": "^9.0.13",
36
+ "@types/inquirer": "^9.0.9",
37
+ "@types/node": "^22.0.0",
38
+ "esbuild": "^0.28.0",
39
+ "tsx": "^4.0.0",
40
+ "typescript": "^5.4.5"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "engines": {
46
+ "node": ">=18.0.0"
47
+ },
48
+ "keywords": [
49
+ "hometrans",
50
+ "harmonyos",
51
+ "android",
52
+ "skill",
53
+ "claude-code",
54
+ "cursor",
55
+ "opencode",
56
+ "codex",
57
+ "mcp"
58
+ ]
59
+ }