@buaa_smat/hometrans 0.1.2 → 0.1.4
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/agents/build-fixer.md +22 -17
- package/agents/code-review-fix.md +4 -4
- package/dist/cli/config-store.js +8 -0
- package/dist/cli/config.js +1 -0
- package/dist/cli/init.js +30 -1
- package/dist/context/index.js +5 -1
- package/package.json +3 -2
- /package/{agents → tools}/test-tools/autotest/README.md +0 -0
- /package/{agents → tools}/test-tools/autotest/config.yaml.example +0 -0
- /package/{agents → tools}/test-tools/autotest/pyproject.toml +0 -0
- /package/{agents → tools}/test-tools/autotest/report_tool.py +0 -0
- /package/{agents → tools}/test-tools/autotest/self_test_runner.py +0 -0
- /package/{agents → tools}/test-tools/autotest/testcases_schema.md +0 -0
- /package/{agents → tools}/test-tools/autotest/testcases_tool.py +0 -0
- /package/{agents → tools}/test-tools/autotest/uv.lock +0 -0
- /package/{agents → tools}/test-tools/harmony_autotest-0.1.0-py3-none-any.whl +0 -0
- /package/{agents → tools}/test-tools/hypium-6.1.0.210-py3-none-any.whl +0 -0
- /package/{agents → tools}/test-tools/hypium_mcp-0.6.5-py3-none-any.whl +0 -0
- /package/{agents → tools}/test-tools/xdevice-6.1.0.210-py3-none-any.whl +0 -0
- /package/{agents → tools}/test-tools/xdevice_devicetest-6.1.0.210-py3-none-any.whl +0 -0
- /package/{agents → tools}/test-tools/xdevice_ohos-6.1.0.210-py3-none-any.whl +0 -0
package/agents/build-fixer.md
CHANGED
|
@@ -29,35 +29,40 @@ Execute a build-fix loop: resolve environment → validate project → build →
|
|
|
29
29
|
|
|
30
30
|
The build requires the **DevEco Studio installation path**, from which Node.js, hvigor, and ohpm are derived.
|
|
31
31
|
|
|
32
|
-
### 0a. Read the
|
|
32
|
+
### 0a. Read the HomeTrans config
|
|
33
33
|
|
|
34
|
-
Read the config file at
|
|
34
|
+
Read the config file written by `ht init` at `~/.hometrans/config.json` (`$HOME/.hometrans/config.json`; on Windows `%USERPROFILE%\.hometrans\config.json`). Its shape is:
|
|
35
35
|
|
|
36
36
|
```jsonc
|
|
37
37
|
{
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
"editors": [ /* ... */ ],
|
|
39
|
+
"params": {
|
|
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"
|
|
42
|
+
"TEST_API_KEY": "..."
|
|
43
|
+
}
|
|
43
44
|
}
|
|
44
45
|
```
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
Read `params.OHOS_SDK_PATH` from this file.
|
|
47
48
|
|
|
48
|
-
### 0b. Derive
|
|
49
|
+
### 0b. Derive the DevEco Studio root and tool paths
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
- **Node executable**: `<deveco_studio_path>/tools/node/node.exe`
|
|
52
|
-
- **Hvigor script**: `<deveco_studio_path>/tools/hvigor/bin/hvigorw.js`
|
|
53
|
-
- **ohpm**: `<deveco_studio_path>/tools/ohpm/bin/ohpm`
|
|
54
|
-
- **SDK directory**: `<deveco_studio_path>/sdk`
|
|
51
|
+
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>`.
|
|
55
52
|
|
|
56
|
-
|
|
53
|
+
> Example: `OHOS_SDK_PATH = D:/DevEco Studio/sdk/default/openharmony/ets` → `<deveco> = D:/DevEco Studio`.
|
|
54
|
+
|
|
55
|
+
From `<deveco>`, derive:
|
|
56
|
+
- **Node executable**: `<deveco>/tools/node/node.exe`
|
|
57
|
+
- **Hvigor script**: `<deveco>/tools/hvigor/bin/hvigorw.js`
|
|
58
|
+
- **ohpm**: `<deveco>/tools/ohpm/bin/ohpm`
|
|
59
|
+
- **SDK directory**: `<deveco>/sdk`
|
|
60
|
+
|
|
61
|
+
Verify these files exist. If they do, use them and skip auto-detection. (Fall back to `params.HMS_SDK_PATH` — stripping `/sdk/default/hms/ets` — if `OHOS_SDK_PATH` is absent but `HMS_SDK_PATH` is present.)
|
|
57
62
|
|
|
58
63
|
### 0c. Auto-detect if config is missing or invalid
|
|
59
64
|
|
|
60
|
-
If
|
|
65
|
+
If `~/.hometrans/config.json` is missing, has empty `params.OHOS_SDK_PATH`/`HMS_SDK_PATH`, or the derived paths don't point to real files, auto-detect:
|
|
61
66
|
|
|
62
67
|
1. **Find DevEco Studio installation**:
|
|
63
68
|
- Search common locations: `D:\DevEco Studio`, `C:\DevEco Studio`, `C:\Program Files\DevEco Studio`
|
|
@@ -68,7 +73,7 @@ If the config file is empty, missing, or the paths don't point to real files, au
|
|
|
68
73
|
- `where node` (Windows) or `which node` (Unix)
|
|
69
74
|
- Verify it runs: `node --version`
|
|
70
75
|
|
|
71
|
-
If auto-detection fails for any critical path, **stop and report clearly** what is missing so the user can run
|
|
76
|
+
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.
|
|
72
77
|
|
|
73
78
|
### 0d. Store resolved paths
|
|
74
79
|
|
|
@@ -41,7 +41,7 @@ If `commit-id` is provided and is not `none`:
|
|
|
41
41
|
- `projectPath`: `<harmonyos-project-path>`
|
|
42
42
|
- `commitId`: `<commit-id>`
|
|
43
43
|
- `mode`: `"default"`
|
|
44
|
-
- `ohosSdkPath` / `hmsSdkPath`: from
|
|
44
|
+
- `ohosSdkPath` / `hmsSdkPath`: omit to let the tool read `params.OHOS_SDK_PATH` / `params.HMS_SDK_PATH` from the `ht init` config (`~/.hometrans/config.json`), falling back to the `OHOS_SDK_PATH` / `HMS_SDK_PATH` env vars
|
|
45
45
|
|
|
46
46
|
2. **On failure**, fall back to:
|
|
47
47
|
```bash
|
|
@@ -231,16 +231,16 @@ Classify: **CONFIRMED** (fix) | **FALSE_POSITIVE** (skip, record reason) | **UNC
|
|
|
231
231
|
|
|
232
232
|
### Step 3.0: Resolve Build Environment
|
|
233
233
|
|
|
234
|
-
1. Read `
|
|
234
|
+
1. Read the `ht init` config at `~/.hometrans/config.json` (Windows: `%USERPROFILE%\.hometrans\config.json`). Take `params.OHOS_SDK_PATH` (e.g. `D:/DevEco Studio/sdk/default/openharmony/ets`) and strip the trailing `/sdk/default/openharmony/ets` to get the DevEco Studio root `<deveco>`. Fall back to `params.HMS_SDK_PATH` (strip `/sdk/default/hms/ets`) if needed.
|
|
235
235
|
|
|
236
236
|
2. Derive tool paths:
|
|
237
237
|
- `NODE_EXE`: `<deveco>/tools/node/node.exe`
|
|
238
238
|
- `HVIGORW_JS`: `<deveco>/tools/hvigor/bin/hvigorw.js`
|
|
239
239
|
- `OHPM`: `<deveco>/tools/ohpm/bin/ohpm`
|
|
240
240
|
|
|
241
|
-
3. If config missing, auto-detect: search `D:\DevEco Studio`, `C:\DevEco Studio`, `C:\Program Files\DevEco Studio` for `tools/hvigor/bin/hvigorw.js`.
|
|
241
|
+
3. If the config is missing or `params.OHOS_SDK_PATH`/`HMS_SDK_PATH` are empty, auto-detect: search `D:\DevEco Studio`, `C:\DevEco Studio`, `C:\Program Files\DevEco Studio` for `tools/hvigor/bin/hvigorw.js`.
|
|
242
242
|
|
|
243
|
-
4. If detection fails, stop and report clearly what is missing.
|
|
243
|
+
4. If detection fails, stop and report clearly what is missing so the user can run `ht init` to configure it.
|
|
244
244
|
|
|
245
245
|
### Step 3.1: Setup Project
|
|
246
246
|
|
package/dist/cli/config-store.js
CHANGED
|
@@ -14,6 +14,10 @@ export function getConfigDir() {
|
|
|
14
14
|
export function getConfigPath() {
|
|
15
15
|
return path.join(getConfigDir(), 'config.json');
|
|
16
16
|
}
|
|
17
|
+
/** 工具目录:~/.hometrans/tools,`ht init` 把打包的 tools/ 拷贝到此。 */
|
|
18
|
+
export function getToolsDir() {
|
|
19
|
+
return path.join(getConfigDir(), 'tools');
|
|
20
|
+
}
|
|
17
21
|
/** 把 ~/foo 展开为 $HOME/foo;非 ~ 开头原样返回。 */
|
|
18
22
|
export function expandHome(p) {
|
|
19
23
|
if (!p)
|
|
@@ -100,6 +104,7 @@ export async function loadHomeTransConfig() {
|
|
|
100
104
|
const config = {
|
|
101
105
|
editors: defaultEditors(),
|
|
102
106
|
params: defaultUserParams(),
|
|
107
|
+
tool_path: '',
|
|
103
108
|
};
|
|
104
109
|
await fs.mkdir(getConfigDir(), { recursive: true });
|
|
105
110
|
await fs.writeFile(configPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
|
|
@@ -125,6 +130,9 @@ export async function loadHomeTransConfig() {
|
|
|
125
130
|
else {
|
|
126
131
|
config.params = { ...defaultUserParams(), ...config.params };
|
|
127
132
|
}
|
|
133
|
+
if (typeof config.tool_path !== 'string') {
|
|
134
|
+
config.tool_path = '';
|
|
135
|
+
}
|
|
128
136
|
delete config.sdkPaths;
|
|
129
137
|
return config;
|
|
130
138
|
}
|
package/dist/cli/config.js
CHANGED
|
@@ -26,6 +26,7 @@ export async function configCommand() {
|
|
|
26
26
|
console.log(` OHOS_SDK_PATH : ${config.params.OHOS_SDK_PATH || '(not set)'}`);
|
|
27
27
|
console.log(` HMS_SDK_PATH : ${config.params.HMS_SDK_PATH || '(not set)'}`);
|
|
28
28
|
console.log(` TEST_API_KEY : ${maskedKey}`);
|
|
29
|
+
console.log(` tool_path : ${config.tool_path || '(not set)'}`);
|
|
29
30
|
console.log('');
|
|
30
31
|
// Full config content
|
|
31
32
|
console.log(' Full Content:');
|
package/dist/cli/init.js
CHANGED
|
@@ -13,7 +13,7 @@ import chalk from 'chalk';
|
|
|
13
13
|
import figlet from 'figlet';
|
|
14
14
|
import inquirer from 'inquirer';
|
|
15
15
|
import { setupMcpForAllEditors } from './mcp-setup.js';
|
|
16
|
-
import { expandHome, loadHomeTransConfig, saveHomeTransConfig, } from './config-store.js';
|
|
16
|
+
import { expandHome, getConfigPath, getToolsDir, loadHomeTransConfig, saveHomeTransConfig, } from './config-store.js';
|
|
17
17
|
function ensureChalkColor() {
|
|
18
18
|
if (process.stdout.isTTY && chalk.level === 0) {
|
|
19
19
|
chalk.level = 1;
|
|
@@ -50,6 +50,23 @@ function resolveSkillsRoot() {
|
|
|
50
50
|
function resolveAgentsRoot() {
|
|
51
51
|
return path.resolve(__dirname, '..', '..', 'agents');
|
|
52
52
|
}
|
|
53
|
+
function resolveToolsRoot() {
|
|
54
|
+
return path.resolve(__dirname, '..', '..', 'tools');
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Copy the bundled `tools/` folder into ~/.hometrans/tools and record the
|
|
58
|
+
* destination in config.tool_path. Returns the destination path, or null if
|
|
59
|
+
* the package ships no tools/ folder.
|
|
60
|
+
*/
|
|
61
|
+
async function installTools(toolsRoot, config) {
|
|
62
|
+
if (!(await dirExists(toolsRoot)))
|
|
63
|
+
return null;
|
|
64
|
+
const toolsDest = getToolsDir();
|
|
65
|
+
await copyDirRecursive(toolsRoot, toolsDest);
|
|
66
|
+
config.tool_path = toolsDest;
|
|
67
|
+
await saveHomeTransConfig(config);
|
|
68
|
+
return toolsDest;
|
|
69
|
+
}
|
|
53
70
|
function resolveAutotestDir(agentsRoot) {
|
|
54
71
|
return path.join(agentsRoot, 'test-tools', 'autotest');
|
|
55
72
|
}
|
|
@@ -198,6 +215,7 @@ export async function initCommand(options = {}) {
|
|
|
198
215
|
console.log(chalk.gray('\n Android-to-HarmonyOS skill & agent installer for AI editors\n'));
|
|
199
216
|
const skillsRoot = resolveSkillsRoot();
|
|
200
217
|
const agentsRoot = resolveAgentsRoot();
|
|
218
|
+
const toolsRoot = resolveToolsRoot();
|
|
201
219
|
const hasSkills = await dirExists(skillsRoot);
|
|
202
220
|
const hasAgents = await dirExists(agentsRoot);
|
|
203
221
|
if (!hasSkills && !hasAgents) {
|
|
@@ -296,6 +314,17 @@ export async function initCommand(options = {}) {
|
|
|
296
314
|
catch (err) {
|
|
297
315
|
console.log(chalk.red(` ! autotest config.yaml: ${err.message}`));
|
|
298
316
|
}
|
|
317
|
+
// Copy bundled tools/ into ~/.hometrans/tools and record tool_path.
|
|
318
|
+
try {
|
|
319
|
+
const toolsDest = await installTools(toolsRoot, config);
|
|
320
|
+
if (toolsDest) {
|
|
321
|
+
console.log(chalk.green(` + tools copied -> ${prettyHome(toolsDest)}`));
|
|
322
|
+
console.log(chalk.gray(` tool_path set in ${prettyHome(getConfigPath())}`));
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
catch (err) {
|
|
326
|
+
console.log(chalk.red(` ! tools copy: ${err.message}`));
|
|
327
|
+
}
|
|
299
328
|
console.log('');
|
|
300
329
|
const editorsToSetup = editors.filter((e) => selectedEditors.includes(e.name));
|
|
301
330
|
const result = { configured: [], skipped: [], errors: [] };
|
package/dist/context/index.js
CHANGED
|
@@ -96,7 +96,8 @@ async function loadHomeTransConfig() {
|
|
|
96
96
|
if (!await fileExists(configPath)) {
|
|
97
97
|
const config2 = {
|
|
98
98
|
editors: defaultEditors(),
|
|
99
|
-
params: defaultUserParams()
|
|
99
|
+
params: defaultUserParams(),
|
|
100
|
+
tool_path: ""
|
|
100
101
|
};
|
|
101
102
|
await fs.mkdir(getConfigDir(), { recursive: true });
|
|
102
103
|
await fs.writeFile(configPath, JSON.stringify(config2, null, 2) + "\n", "utf-8");
|
|
@@ -123,6 +124,9 @@ async function loadHomeTransConfig() {
|
|
|
123
124
|
} else {
|
|
124
125
|
config.params = { ...defaultUserParams(), ...config.params };
|
|
125
126
|
}
|
|
127
|
+
if (typeof config.tool_path !== "string") {
|
|
128
|
+
config.tool_path = "";
|
|
129
|
+
}
|
|
126
130
|
delete config.sdkPaths;
|
|
127
131
|
return config;
|
|
128
132
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buaa_smat/hometrans",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "HomeTrans (Android-to-HarmonyOS) skill + agent installer. Run `ht init` to distribute conversion skills and subagents into AI editors.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|
|
13
13
|
"skills",
|
|
14
|
-
"agents"
|
|
14
|
+
"agents",
|
|
15
|
+
"tools"
|
|
15
16
|
],
|
|
16
17
|
"scripts": {
|
|
17
18
|
"build": "node scripts/build.js",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|