@deveco-test/deveco-cli-common 1.3.10-Test.1 → 1.3.10-Test.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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <div align="center">
1
+ <div align="center">
2
2
  <h1>DevEco CLI</h1>
3
3
  <p>一个面向 HarmonyOS 应用开发的统一命令行入口。</p>
4
4
  <p>
@@ -38,6 +38,8 @@ npm install -g @deveco/deveco-cli@latest
38
38
  devecocli update
39
39
  ```
40
40
 
41
+ `update` 除了更新 CLI 自身,还会将文档知识库同步到与 CLI 兼容的最新版本(仅当文档落后或缺失时才下载,包体积通常为几十 MB)。
42
+
41
43
  ### 最短工作流
42
44
 
43
45
  ```bash
@@ -51,7 +53,7 @@ devecocli log --level E
51
53
 
52
54
  ```bash
53
55
  devecocli docs search List
54
- devecocli docs read 开发指南/UI_Design_Kit_UI设计套件/UI_Design_Kit简介/ui-design-introduction
56
+ devecocli docs read guides/harmonyos-guides/指南/系统/网络/网络
55
57
  ```
56
58
 
57
59
  更多命令和参数可通过 `devecocli --help` 或各子命令的 `--help` 查看。
@@ -161,6 +163,7 @@ devecocli init --path D:\work\ARKTS\NewData
161
163
  | `devecocli docs update` | 更新 HarmonyOS 文档到最新兼容版本 |
162
164
  | `devecocli init` | 安装内置技能或配置 `MCP` |
163
165
  | `devecocli skills` | 管理 HarmonyOS 技能市场中的技能 |
166
+ | `devecocli plugin` | 管理白名单内的 AI 智能体插件(npm 包形式,装/卸/更新行为由插件定义) |
164
167
  | `devecocli signature generate` | 自动生成调试签名材料并配置到项目 |
165
168
  | `devecocli check compat` | 扫描源代码在两个 `SDK` 版本之间的 `API` 变更 |
166
169
 
@@ -305,7 +308,7 @@ devecocli docs read <documentId>
305
308
  **示例:**
306
309
 
307
310
  ```bash
308
- devecocli docs read 开发指南/UI_Design_Kit_UI设计套件/UI_Design_Kit简介/ui-design-introduction
311
+ devecocli docs read guides/harmonyos-guides/指南/系统/网络/网络
309
312
  ```
310
313
 
311
314
  ### `docs catalog`
@@ -1000,6 +1003,95 @@ devecocli device sqlite3 [--device <name|serial>] <db-path> [args...]
1000
1003
  devecocli device sqlite3 /data/app/el2/100/database/com.example.app/foo.db "select * from user limit 5" -json
1001
1004
  ```
1002
1005
 
1006
+ ### `device location`
1007
+
1008
+ 模拟设备位置或关闭位置模拟,基于 `testhelper`(系统版本 7.0+)。支持经纬度模式和 GPX 文件模式(互斥)。
1009
+
1010
+ **命令格式:**
1011
+
1012
+ ```bash
1013
+ devecocli device location set --latitude <degrees> --longitude <degrees> [--altitude <m>] [--speed <m/s>] [--direction <degrees>] [--interval <s>] [--device <name|serial>]
1014
+ devecocli device location set --gpx-file <path> [--interval <s>] [--device <name|serial>]
1015
+ devecocli device location enable [--device <name|serial>]
1016
+ devecocli device location disable [--device <name|serial>]
1017
+ ```
1018
+
1019
+ **示例:**
1020
+
1021
+ ```bash
1022
+ devecocli device location set --latitude 39.908 --longitude 116.40024
1023
+ devecocli device location set --gpx-file ./route.gpx --interval 2
1024
+ devecocli device location disable
1025
+ ```
1026
+
1027
+ **说明:**
1028
+
1029
+ - `--latitude`/`--longitude` 与 `--gpx-file` 互斥。`--altitude`/`--speed`/`--direction` 仅经纬度模式有效。
1030
+ - `--interval`(1-3600 秒,默认 1)两种模式均支持,作为 testhelper 命令参数传递,不修改 GPX 文件内容。
1031
+ - `set` 会自动启用位置模拟,无需单独 `enable`。
1032
+ - GPX 文件支持标准 GPX 1.1 格式,详见 [testhelper 官方文档](https://gitcode.com/openharmony/docs/blob/master/zh-cn/application-dev/application-test/testhelper-guidelines.md#testhelper-set-mocked-locations)。
1033
+ - 只有 debug 签名的应用才能获取到模拟位置信息,开启模拟后非 debug 应用将获取位置失败。
1034
+
1035
+ ### `device network-sim`
1036
+
1037
+ 基于 `netcopilot`(API 20+)模拟设备网络状况,用于弱网/断网/切换等测试场景。
1038
+
1039
+ **命令格式:**
1040
+
1041
+ ```bash
1042
+ devecocli device network-sim start --id <id> [--device <name|serial>]
1043
+ devecocli device network-sim start --name <name> --up-bandwidth <bps> --down-bandwidth <bps> --up-latency <ms> --down-latency <ms> --up-drop <rate> --down-drop <rate> [--device <name|serial>]
1044
+ devecocli device network-sim stop [--device <name|serial>]
1045
+ devecocli device network-sim list [--device <name|serial>]
1046
+ devecocli device network-sim status [--device <name|serial>]
1047
+ ```
1048
+
1049
+ **示例:**
1050
+
1051
+ ```bash
1052
+ devecocli device network-sim start --id 5
1053
+ devecocli device network-sim start --name weak-net --up-bandwidth 100000 --down-bandwidth 500000 --up-latency 200 --down-latency 200 --up-drop 0.05 --down-drop 0.01
1054
+ devecocli device network-sim stop
1055
+ devecocli device network-sim list
1056
+ ```
1057
+
1058
+ **说明:**
1059
+
1060
+ - `--id`(预置场景 1-8)与 `--name`+自定义网络参数互斥。
1061
+ - 预置场景 1-3 需同时连接 WLAN 和蜂窝网络;4-8 需 WLAN 或蜂窝网络之一。
1062
+ - `stop` 停止模拟、删除自定义场景、自动关闭 netcopilot,无参数、幂等。
1063
+
1064
+ ### `device playback`
1065
+
1066
+ 基于 `ohos-avsession-manager`(系统版本 6.1+)控制设备媒体播放中心。
1067
+
1068
+ **命令格式:**
1069
+
1070
+ ```bash
1071
+ devecocli device playback list [--device <name|serial>]
1072
+ devecocli device playback play [--id <id>] [--bundle <name>] [--device <name|serial>]
1073
+ devecocli device playback pause [--id <id>] [--bundle <name>] [--device <name|serial>]
1074
+ devecocli device playback next [--id <id>] [--bundle <name>] [--device <name|serial>]
1075
+ devecocli device playback previous [--id <id>] [--bundle <name>] [--device <name|serial>]
1076
+ devecocli device playback forward [--id <id>] [--bundle <name>] [--device <name|serial>]
1077
+ devecocli device playback rewind [--id <id>] [--bundle <name>] [--device <name|serial>]
1078
+ devecocli device playback seek --position <seconds> [--id <id>] [--bundle <name>] [--device <name|serial>]
1079
+ ```
1080
+
1081
+ **示例:**
1082
+
1083
+ ```bash
1084
+ devecocli device playback list
1085
+ devecocli device playback play --bundle com.example.music
1086
+ devecocli device playback seek --position 120 --bundle com.example.music
1087
+ ```
1088
+
1089
+ **说明:**
1090
+
1091
+ - 控制命令需要 `--id` 或 `--bundle`(至少提供一个)。`--bundle` 会自动解析会话 ID。
1092
+ - `forward`/`rewind` 步长由应用决定,不支持设置时间。
1093
+ - `seek --position` 跳转到指定位置(秒),非负数(支持整数和浮点数,如 `0`、`120`、`1.5`)。
1094
+
1003
1095
  ### `ui screenshot`
1004
1096
 
1005
1097
  对真机或模拟器执行 UI 截图。
@@ -1395,7 +1487,7 @@ devecocli run --module <m1> [m2...] --device <device> --product <product> --buil
1395
1487
  | --ability | 可选,待启动的 `Ability` ,默认:模块 `module.json5` 中的`mainElement` |
1396
1488
  | --uninstall | 可选,安装前先卸载已有应用 |
1397
1489
  | --skip-build | 可选,跳过构建操作,直接安装应用 。\*\*说明:\*\*使用该参数时,需确保对应模块已有构建产物 |
1398
- | --apply \<fileName\> | 可选,快速增量部署。仅重编改动文件并安装,比全量 `run` 快。`<fileName>` 为 `.hvigor/` 下的改动文件清单(每行一个相对工程根路径)。前提:DevEco Studio ≥6.1.1,且先跑过一次 `devecocli run`。注意:不要与活跃的 `--hotreload` 会话混用(两者共用模块级 `buildConfig.json`),先 `devecocli run --hotreload stop` 停止会话 |
1490
+ | --apply \<fileName\> | 可选,快速增量部署。仅重编改动文件并安装,比全量 `run` 快。`<fileName>` 为 `.hvigor/` 下的改动文件清单(每行一个相对工程根路径)。前提:DevEco Studio ≥6.1.1,且先跑过一次 `devecocli run`。普通 `run`/`build` 会清除冷重载补丁所需的符号表,之后首次含 ArkTS 变更的 `--apply` 会自动全量自举重建(可能耗时较长;纯资源变更跳过自举)。注意:不要与活跃的 `--hotreload` 会话混用(两者共用模块级 `buildConfig.json`),先 `devecocli run --hotreload stop` 停止会话 |
1399
1491
  | --hotreload [action] | 可选,使用热重载功能。使用热重载时,该命令需持续存活,以使热重载构建可以快速响应。当不需要时,执行 `devecocli run --hotreload stop` 去停止进程,释放资源。会话存活期间不要对该工程执行 `--apply` 或普通 `run`/`build`(会清掉会话依赖的 `buildConfig.json`),需要时先停止会话再重启 |
1400
1492
  | --hotreload-apply \<fileName\> | 可选,热重载(不重启应用即生效)。读取 `.hvigor/<fileName>` 改动清单,经编译安装使改动生效。前提:后台 `--hotreload` 进程在跑。范围:仅单个模块(`--module` 必填),且只支持 `.ets` 文件 |
1401
1493
 
@@ -1686,6 +1778,45 @@ devecocli skills remove --skill skillname # skillname需替换成实际的Skill
1686
1778
  devecocli skills remove --skill skillname --agent agentname # skillname需替换成实际的Skill名称
1687
1779
  ```
1688
1780
 
1781
+ ### `plugin`
1782
+
1783
+ 管理白名单内的 AI 智能体插件。插件以 npm 包形式分发,版本取白名单 `npmPackage` 坐标上可选 `@tag` 后缀指定的 dist-tag(如 `@scope/pkg@cli` 用 `cli` 标签;未写后缀默认 `latest`),CLI 负责白名单校验、包下载与完整性校验、契约加载和生命周期编排;安装、卸载、更新的具体行为完全由各插件的 `install` / `uninstall` / `update` hook 定义。
1784
+
1785
+ **CLI 不保存任何安装状态**:`<数据目录>/plugins/store/<插件名>/<版本>/` 中的包缓存是唯一状态,`plugin list` 通过扫描这些目录判定"已下载"。install/update 每次都会重新执行 hook(幂等性由插件保证);`plugin uninstall` 不会删除包缓存(`<数据目录>/plugins/store/<插件名>/`)与插件私有数据(`<数据目录>/plugins/data/<插件名>/`),需要清理时请手动删除。
1786
+
1787
+ - `plugin list [-l|--long]`:以表格列出白名单插件及本地已下载版本(列 `Name / Version / Status`,每个版本一行、升序,无版本显示 `not installed`);`--long` 追加 `NpmPackage` 与 `Desc` 列。
1788
+ - `plugin install <name> [--agent <a,b…>] [--project <path>] [-f|--force]`:下载最新包后,对"检测到的智能体 ∩ 插件支持的智能体"逐个执行 `install` hook;`--force` 先用本地最高旧版本执行 `uninstall` hook。目标全部失败时回滚删除本次新建的版本目录。显式 `--agent` + `--project` 时与 `init --project --agent` 一致——缺失的目标 skills 目录(含 `.<agent>` 根目录)会在 hook 前自动创建。
1789
+ - `plugin update <name> [--agent <a,b…>] [--project <path>]`:拉取最新版本并执行 `update` hook(携带 `from`/`to`,`from` 为下载前快照的最高版本;`from === to` 表示无本地版本或最新版已缓存,按修复/补装处理,不要求本地已有版本);显式 `--agent` + `--project` 时与 install 一致,缺失的目标 skills 目录(含 `.<agent>` 根目录)会在 hook 前自动创建。
1790
+ - `plugin uninstall <name> [--agent <a,b…>] [--project <path>]`:以本地最高可加载版本执行 `uninstall` hook。
1791
+
1792
+ 白名单之外的插件名一律拒绝安装。汇总按目标计 `Success / Skipped / Failed`:不受插件支持的智能体记为 skipped(不执行 hook;显式 `--agent` 指定不支持项时直接报错,install/update/uninstall 报错一致);`--project` 作用域传给 hook 的目标 `skillsDir`:只要 agent 配置了 `legacySkillsDirs` 就直接使用第一个 legacy 目录(如 opencode 的 `.opencode/skills`),不要求目录已存在、不存在也不回退;未配置的 agent 使用配置入口(如 `.agents/skills`)。未显式指定 `--agent` 时隐式目标按解析目录判定:解析到共享 `.agents/skills` 的智能体直通;解析到自有目录(legacy 或专属入口)的智能体要求项目内已存在对应根目录(如 `.opencode`),否则记为 skipped(`agent-project-root-missing`,不执行 hook、不新建目录);显式 `--agent` 不做此判定,缺失的解析目录会被自动创建。该解析与判定仅作用于 plugin install/update/uninstall,`init`、`skills add` 等仍使用配置入口。任一目标失败时以非零状态退出。hook 单次执行上限默认 120 秒,可用环境变量 `DEVECO_CLI_PLUGIN_HOOK_TIMEOUT_MS` 调整。操作完成后需重启智能体以加载插件。
1793
+
1794
+ **命令格式:**
1795
+
1796
+ ```bash
1797
+ devecocli plugin list --long
1798
+ devecocli plugin install <name> --agent <agents> --project <path> --force
1799
+ devecocli plugin update <name> --agent <agents> --project <path>
1800
+ devecocli plugin uninstall <name> --agent <agents> --project <path>
1801
+ ```
1802
+
1803
+ **参数:**
1804
+
1805
+ | 参数名 | 说明 |
1806
+ | --------- | -------------------------------------------------------- |
1807
+ | name | 必选(install/update/uninstall),白名单内的插件名 |
1808
+ | --agent | 可选,智能体名称,多个以英文逗号分隔;缺省时对检测到的全部智能体中受支持者执行 |
1809
+ | --project | 可选,工程根目录,切换到项目作用域;相对路径按当前目录解析 |
1810
+ | --force | 可选(仅 install),先执行旧版本的 uninstall hook 再安装 |
1811
+ | --long | 可选(仅 list),显示插件描述与 npm 包坐标 |
1812
+
1813
+ **示例:**
1814
+
1815
+ ```bash
1816
+ devecocli plugin list
1817
+ devecocli plugin install example-plugin --agent opencode --project ./my-app
1818
+ ```
1819
+
1689
1820
  ### `serve mcp`
1690
1821
 
1691
1822
  启动本地 `MCP` 服务。智能体配置 `MCP` 服务后,可通过 `MCP` 协议调用下方列出的代码分析与语言特性工具。不同智能体平台配置 `MCP` 服务的界面不一样,一个智能体平台的配置示例如下。
@@ -0,0 +1,46 @@
1
+ This file was generated with the generate-license-file npm package!
2
+ https://www.npmjs.com/package/generate-license-file
3
+
4
+ The following npm packages may be included in this product:
5
+
6
+ - @deveco-test/deveco-cli-knowledgebase@1.3.10-Test.2
7
+ - @deveco-test/deveco-cli@1.3.10-Test.2
8
+
9
+ These packages each contain the following license:
10
+
11
+ MIT
12
+
13
+ -----------
14
+
15
+ The following npm package may be included in this product:
16
+
17
+ - @deveco-test/deveco-cli-common@1.3.10-Test.2
18
+
19
+ This package contains the following license:
20
+
21
+ MIT License
22
+
23
+ Copyright (c) 2026 Huawei Device Co., Ltd.
24
+
25
+ Permission is hereby granted, free of charge, to any person obtaining a copy
26
+ of this software and associated documentation files (the "Software"), to deal
27
+ in the Software without restriction, including without limitation the rights
28
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29
+ copies of the Software, and to permit persons to whom the Software is
30
+ furnished to do so, subject to the following conditions:
31
+
32
+ The above copyright notice and this permission notice shall be included in all
33
+ copies or substantial portions of the Software.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41
+ SOFTWARE.
42
+
43
+ -----------
44
+
45
+ This file was generated with the generate-license-file npm package!
46
+ https://www.npmjs.com/package/generate-license-file