hmdev-cli 1.0.2 → 1.0.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/README.md CHANGED
@@ -100,6 +100,20 @@ hmdev-cli build --project ./MyApp && hmdev-cli deploy --start --bundle com.examp
100
100
  hmdev-cli connect 192.168.1.100:41015 && hmdev-cli deploy --start --bundle com.example.app
101
101
  ```
102
102
 
103
+ ## AI 技能 (Skill)
104
+
105
+ hmdev-cli 提供配套的 AI 技能,让 Claude 等 AI 助手直接学会使用该工具:
106
+
107
+ ```bash
108
+ # 技能文件位于项目 hmdev-cli-skill/ 目录
109
+ hmdev-cli-skill/
110
+ ├── SKILL.md # 技能描述与使用指南
111
+ ├── scripts/ # 预留:自动化脚本
112
+ └── references/ # 预留:参考文档
113
+ ```
114
+
115
+ AI 加载该技能后,能自动完成文档查询、构建、部署等操作。
116
+
103
117
  ## 命令参考
104
118
 
105
119
  | 命令 | 说明 |
@@ -140,13 +154,11 @@ npm install -g hmdev-cli
140
154
  ## 开发
141
155
 
142
156
  ```bash
143
- git clone https://github.com/Johnson1662/huawei-docs-mcp.git
144
- cd huawei-docs-mcp
157
+ git clone https://github.com/Johnson1662/hmdev-cli.git
158
+ cd hmdev-cli
145
159
 
146
- # 安装依赖(自动创建 venv)
147
160
  npm install
148
161
 
149
- # 本地测试
150
162
  node bin/hmdev-cli.js index
151
163
  node bin/hmdev-cli.js search ArkUI
152
164
  node bin/hmdev-cli.js build --project /path/to/harmonyos-project
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hmdev-cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "HarmonyOS 开发 CLI 工具 — 文档查询、项目构建、设备部署",
5
5
  "keywords": [
6
6
  "harmonyos",
@@ -11,15 +11,15 @@
11
11
  "hdc",
12
12
  "huawei"
13
13
  ],
14
- "homepage": "https://github.com/Johnson1662/huawei-docs-mcp#readme",
14
+ "homepage": "https://github.com/Johnson1662/hmdev-cli#readme",
15
15
  "bugs": {
16
- "url": "https://github.com/Johnson1662/huawei-docs-mcp/issues"
16
+ "url": "https://github.com/Johnson1662/hmdev-cli/issues"
17
17
  },
18
18
  "license": "MIT",
19
19
  "author": "Johnson1662",
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "git+https://github.com/Johnson1662/huawei-docs-mcp.git"
22
+ "url": "git+https://github.com/Johnson1662/hmdev-cli.git"
23
23
  },
24
24
  "bin": {
25
25
  "hmdev-cli": "bin/hmdev-cli.js"
package/python/builder.py CHANGED
@@ -193,6 +193,10 @@ class HDCTool:
193
193
  )
194
194
  return subprocess.run([self._hdc_path] + args, capture_output=True, text=True, timeout=timeout)
195
195
 
196
+ @staticmethod
197
+ def succeeded(result: subprocess.CompletedProcess) -> bool:
198
+ return result.returncode == 0 and "[Fail]" not in result.stdout and "[Fail]" not in result.stderr
199
+
196
200
  def list_devices(self) -> list[dict]:
197
201
  result = self._run(["list", "targets"])
198
202
  devices = []
@@ -221,5 +225,5 @@ class HDCTool:
221
225
  args.extend(["shell", "aa", "start", "-a", ability, "-b", bundle])
222
226
  return self._run(args, timeout=30)
223
227
 
224
- def connect_wireless(self, ip_port: str, timeout: int = 10) -> subprocess.CompletedProcess:
228
+ def connect_wireless(self, ip_port: str, timeout: int = 30) -> subprocess.CompletedProcess:
225
229
  return self._run(["tconn", ip_port], timeout=timeout)
package/python/cli.py CHANGED
@@ -16,6 +16,8 @@ Usage:
16
16
  import asyncio
17
17
  import json
18
18
  import re
19
+ import shutil
20
+ import subprocess
19
21
  import subprocess
20
22
  import time
21
23
  from argparse import ArgumentParser, RawDescriptionHelpFormatter, SUPPRESS
@@ -477,7 +479,7 @@ async def cmd_deploy(args):
477
479
  if args.tconn:
478
480
  print(f"[hmdev] 无线连接: {args.tconn}")
479
481
  tr = hdc.connect_wireless(args.tconn)
480
- if tr.returncode != 0:
482
+ if not HDCTool.succeeded(tr):
481
483
  print(f"[hmdev] ❌ 无线连接失败: {tr.stderr.strip()}")
482
484
  return
483
485
  print(f"[hmdev] ✅ 无线连接成功")
@@ -493,7 +495,7 @@ async def cmd_deploy(args):
493
495
 
494
496
  print(f"[hmdev] 正在安装: {hap_path}")
495
497
  ir = hdc.install_hap(hap_path, device_id)
496
- if ir.returncode != 0:
498
+ if not HDCTool.succeeded(ir):
497
499
  err = ir.stderr.strip() or ir.stdout.strip()
498
500
  print(f"[hmdev] ❌ 安装失败: {err}")
499
501
  return
@@ -507,7 +509,7 @@ async def cmd_deploy(args):
507
509
  else:
508
510
  print(f"[hmdev] 正在启动: {bundle}")
509
511
  sr = hdc.start_app(bundle, args.ability, device_id)
510
- if sr.returncode != 0:
512
+ if not HDCTool.succeeded(sr):
511
513
  print(f"[hmdev] ❌ 启动失败: {sr.stderr.strip()}")
512
514
  else:
513
515
  print(f"[hmdev] ✅ 应用已启动")
@@ -668,6 +670,20 @@ async def cmd_config(args):
668
670
  print()
669
671
 
670
672
 
673
+ async def cmd_update(args):
674
+ npm = shutil.which("npm") or shutil.which("npm.cmd")
675
+ if not npm:
676
+ print("[hmdev] ❌ 未找到 npm。请确保 Node.js 已安装。")
677
+ return
678
+ print("[hmdev] 正在更新 hmdev-cli ...")
679
+ result = subprocess.run([npm, "update", "-g", "hmdev-cli"], capture_output=True, text=True)
680
+ if result.returncode == 0:
681
+ print("[hmdev] ✅ 更新成功")
682
+ else:
683
+ err = result.stderr.strip() or result.stdout.strip()
684
+ print(f"[hmdev] ❌ 更新失败: {err}")
685
+
686
+
671
687
  # ── CLI Registration ──────────────────────────────────────────────────────────
672
688
 
673
689
  CLI_COMMANDS = {
@@ -682,6 +698,7 @@ CLI_COMMANDS = {
682
698
  "run": cmd_run,
683
699
  "connect": cmd_connect,
684
700
  "config": cmd_config,
701
+ "update": cmd_update,
685
702
  }
686
703
 
687
704
 
@@ -765,6 +782,10 @@ def build_cli_parser():
765
782
  p.add_argument("--reset", metavar="KEY", help="重置配置项")
766
783
  p.add_argument("--json", action="store_true", dest="json", help=SUPPRESS)
767
784
 
785
+ # update
786
+ p = sub.add_parser("update", help="更新 hmdev-cli 到最新版本 (npm update -g)")
787
+ p.add_argument("--json", action="store_true", dest="json", help=SUPPRESS)
788
+
768
789
  return parser
769
790
 
770
791