ability-cli 0.1.0 → 0.2.1

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 (3) hide show
  1. package/README.md +26 -15
  2. package/dist/index.js +19 -5
  3. package/package.json +53 -47
package/README.md CHANGED
@@ -13,6 +13,18 @@
13
13
 
14
14
  ## 2. 安装
15
15
 
16
+ ### 从 npm 安装(推荐)
17
+
18
+ ```bash
19
+ npm install -g ability-cli
20
+ # 或
21
+ pnpm add -g ability-cli
22
+ ```
23
+
24
+ 安装完成后在终端执行 `ability-cli --help` 即可。若提示找不到命令,请确认 npm / pnpm 的全局 bin 目录已加入 `PATH`(可先执行一次 `pnpm setup` 配置 pnpm 的全局目录)。
25
+
26
+ ### 从源码安装
27
+
16
28
  ```bash
17
29
  # 克隆仓库
18
30
  git clone <repo-url>
@@ -24,11 +36,12 @@ pnpm install
24
36
  # 构建
25
37
  pnpm build
26
38
 
27
- # 全局链接(可选,Windows 推荐)
28
- npm link
39
+ # 全局链接(开发调试)
40
+ pnpm link --global
41
+ # 或 npm link
29
42
  ```
30
43
 
31
- 构建完成后,可通过 `ability-cli`(或 `node dist/index.js`)运行。若使用全局链接,请确保 `pnpm` 的全局 bin 目录在 `PATH` 中。
44
+ 构建完成后,可通过 `ability-cli`(或 `node dist/index.js`)运行。
32
45
 
33
46
  ---
34
47
 
@@ -41,8 +54,8 @@ ability-cli config set --app-id <your-app-id> --app-secret <your-secret>
41
54
  # 搜索能力
42
55
  ability-cli search "帮我导航回家" --device-id abc123
43
56
 
44
- # 查看能力详情
45
- ability-cli inspect --ability-id 20001
57
+ # 查看能力详情(端侧能力需带设备 ID,也可用 config 里的 defaults.deviceId)
58
+ ability-cli inspect --ability-id 20001 --device-id <device-id>
46
59
 
47
60
  # 生成参数模板
48
61
  ability-cli inspect --ability-id 20001 --gen-template > params.json
@@ -80,11 +93,11 @@ ability-cli doctor
80
93
 
81
94
  | 选项 | 说明 |
82
95
  |------|------|
83
- | `[query]` | 自然语言检索,映射为查询参数 `nl` |
96
+ | `[query]` | 自然语言检索;与 `--natural-lang` 二选一或组合(`--natural-lang` 优先) |
84
97
  | `--device-id <id>` | 设备 ID;未指定时使用配置文件 `defaults.deviceId` |
85
98
  | `--app-name <name>` | 应用名称 |
86
- | `--type <type>` | 能力二级分类 |
87
- | `--capability-type <ct>` | 能力三级分类 |
99
+ | `--category <category>` | 三级分类 |
100
+ | `--natural-lang <text>` | 自然语言(优先于 `[query]`) |
88
101
  | `--json` | 仅输出 JSON(`data` 部分) |
89
102
 
90
103
  #### `inspect`
@@ -94,6 +107,7 @@ ability-cli doctor
94
107
  | 选项 | 说明 |
95
108
  |------|------|
96
109
  | `--ability-id <id>` | **必填**,能力 ID |
110
+ | `--device-id <id>` | 设备 ID;**端侧能力**查询详情时通常必填;未指定时可使用 `defaults.deviceId` |
97
111
  | `--gen-template` | 根据 `inputSchema` 生成参数模板 JSON 并输出 |
98
112
  | `--json` | 仅输出 JSON(`data` 部分) |
99
113
 
@@ -126,9 +140,8 @@ GET 能力列表。
126
140
  |------|------|
127
141
  | `--device-id <id>` | 设备 ID |
128
142
  | `--app-name <name>` | 应用名称 |
129
- | `--type <type>` | 能力二级分类 |
130
- | `--capability-type <ct>` | 能力三级分类 |
131
- | `--nl <text>` | 自然语言筛选 |
143
+ | `--category <category>` | 三级分类 |
144
+ | `--natural-lang <text>` | 自然语言筛选 |
132
145
  | `--json` | JSON 输出 |
133
146
 
134
147
  #### `raw ability-record`
@@ -156,6 +169,7 @@ GET 能力详情。
156
169
  | 选项 | 说明 |
157
170
  |------|------|
158
171
  | `--ability-id <id>` | **必填**,能力 ID |
172
+ | `--device-id <id>` | 设备 ID;**端侧能力**时通常必填;未指定时可使用 `defaults.deviceId` |
159
173
  | `--json` | JSON 输出 |
160
174
 
161
175
  #### `raw call-tool`
@@ -290,10 +304,7 @@ pnpm test # 运行测试(Vitest)
290
304
 
291
305
  ### 首次发布
292
306
 
293
- 1. `package.json` 中把占位符替换为真实地址:
294
- - `repository.url`
295
- - `homepage`
296
- - `bugs.url`
307
+ 1. (可选)在 `package.json` 中填写真实仓库地址:`repository`、`homepage`、`bugs`。
297
308
  2. 登录 npm:
298
309
 
299
310
  ```bash
package/dist/index.js CHANGED
@@ -260,9 +260,13 @@ function registerRawCommand(program2) {
260
260
  const res = await apiGet(ctx, "/ability-service/api/v1/ability/appInfo", { packageName: opts.packageName });
261
261
  handleApiResponse(res, opts.json, (data) => printJson(data));
262
262
  });
263
- raw.command("ability-info").description("GET \u80FD\u529B\u8BE6\u60C5").requiredOption("--ability-id <id>", "\u80FD\u529BID").option("--json", "JSON \u8F93\u51FA").action(async (opts) => {
263
+ raw.command("ability-info").description("GET \u80FD\u529B\u8BE6\u60C5").requiredOption("--ability-id <id>", "\u80FD\u529BID").option("--device-id <id>", "\u8BBE\u5907 ID\uFF1B\u5F53\u80FD\u529B\u4E3A\u7AEF\u4FA7\u80FD\u529B\u65F6\u5FC5\u586B").option("--json", "JSON \u8F93\u51FA").action(async (opts) => {
264
264
  const ctx = buildContext(program2.opts());
265
- const res = await apiGet(ctx, "/ability-service/api/v1/ability/abilityInfo", { abilityId: opts.abilityId });
265
+ const defaults = getDefaults();
266
+ const params = { abilityId: opts.abilityId };
267
+ const deviceId = opts.deviceId ?? defaults.deviceId;
268
+ if (deviceId) params.deviceId = deviceId;
269
+ const res = await apiGet(ctx, "/ability-service/api/v1/ability/abilityInfo", params);
266
270
  handleApiResponse(res, opts.json, (data) => printJson(data));
267
271
  });
268
272
  raw.command("call-tool").description("POST \u6267\u884C\u80FD\u529B").requiredOption("--file <path>", "JSON \u6587\u4EF6\u8DEF\u5F84").option("--json", "JSON \u8F93\u51FA").action(async (opts) => {
@@ -271,6 +275,12 @@ function registerRawCommand(program2) {
271
275
  const res = await apiPost(ctx, "/ability-service/api/mcp/async/call-tool", data);
272
276
  handleApiResponse(res, opts.json, (data2) => printJson(data2));
273
277
  });
278
+ raw.command("ability-callback").description("POST \u4E0A\u62A5\u80FD\u529B\u6267\u884C\u7ED3\u679C").requiredOption("--file <path>", "JSON \u6587\u4EF6\u8DEF\u5F84\uFF0C\u9700\u5305\u542B requestId\uFF0Cbody \u53EF\u9009").option("--json", "JSON \u8F93\u51FA").action(async (opts) => {
279
+ const ctx = buildContext(program2.opts());
280
+ const data = JSON.parse(fs2.readFileSync(opts.file, "utf-8"));
281
+ const res = await apiPost(ctx, "/ability-service/api/v1/ability/callback", data);
282
+ handleApiResponse(res, opts.json, (data2) => printJson(data2));
283
+ });
274
284
  raw.command("category-list").description("GET \u5168\u91CF\u5206\u7C7B").option("--json", "JSON \u8F93\u51FA").action(async (opts) => {
275
285
  const ctx = buildContext(program2.opts());
276
286
  const res = await apiGet(ctx, "/ability-service/api/v1/ability/category");
@@ -330,9 +340,13 @@ function generateTemplate(schema) {
330
340
  return result;
331
341
  }
332
342
  function registerInspectCommand(program2) {
333
- program2.command("inspect").description("\u67E5\u770B\u80FD\u529B\u8BE6\u60C5\u4E0E inputSchema").requiredOption("--ability-id <id>", "\u80FD\u529BID").option("--gen-template", "\u751F\u6210\u53C2\u6570\u6A21\u677F JSON").option("--json", "JSON \u8F93\u51FA").action(async (opts) => {
343
+ program2.command("inspect").description("\u67E5\u770B\u80FD\u529B\u8BE6\u60C5\u4E0E inputSchema").requiredOption("--ability-id <id>", "\u80FD\u529BID").option("--device-id <id>", "\u8BBE\u5907 ID\uFF1B\u5F53\u80FD\u529B\u4E3A\u7AEF\u4FA7\u80FD\u529B\u65F6\u5FC5\u586B").option("--gen-template", "\u751F\u6210\u53C2\u6570\u6A21\u677F JSON").option("--json", "JSON \u8F93\u51FA").action(async (opts) => {
334
344
  const ctx = buildContext(program2.opts());
335
- const res = await apiGet(ctx, "/ability-service/api/v1/ability/abilityInfo", { abilityId: opts.abilityId });
345
+ const defaults = getDefaults();
346
+ const params = { abilityId: opts.abilityId };
347
+ const deviceId = opts.deviceId ?? defaults.deviceId;
348
+ if (deviceId) params.deviceId = deviceId;
349
+ const res = await apiGet(ctx, "/ability-service/api/v1/ability/abilityInfo", params);
336
350
  handleApiResponse(res, opts.json, (data) => {
337
351
  if (opts.genTemplate && data.inputSchema) {
338
352
  printJson(generateTemplate(data.inputSchema));
@@ -448,7 +462,7 @@ function registerDoctorCommand(program2) {
448
462
 
449
463
  // src/index.ts
450
464
  var program = new Command();
451
- program.name("ability-cli").description("\u539F\u5B50\u80FD\u529B\u5E73\u53F0 CLI \u5DE5\u5177").version("0.1.0").option("--env <env>", "\u73AF\u5883 (test/prod)").option("--app-id <id>", "zy-app-id").option("--app-secret <secret>", "appSecret").option("--auth-token <token>", "Authorization").option("--base-url <url>", "\u7F51\u5173\u5730\u5740").option("--magic-sign", "\u6D4B\u8BD5\u73AF\u5883\u8DF3\u8FC7\u9A8C\u7B7E").option("-v, --verbose", "\u8BE6\u7EC6\u8F93\u51FA");
465
+ program.name("ability-cli").description("\u539F\u5B50\u80FD\u529B\u5E73\u53F0 CLI \u5DE5\u5177").version("0.2.0").option("--env <env>", "\u73AF\u5883 (test/prod)").option("--app-id <id>", "zy-app-id").option("--app-secret <secret>", "appSecret").option("--auth-token <token>", "Authorization").option("--base-url <url>", "\u7F51\u5173\u5730\u5740").option("--magic-sign", "\u6D4B\u8BD5\u73AF\u5883\u8DF3\u8FC7\u9A8C\u7B7E").option("-v, --verbose", "\u8BE6\u7EC6\u8F93\u51FA");
452
466
  registerConfigCommand(program);
453
467
  registerRawCommand(program);
454
468
  registerSearchCommand(program);
package/package.json CHANGED
@@ -1,47 +1,53 @@
1
- {
2
- "name": "ability-cli",
3
- "version": "0.1.0",
4
- "description": "原子能力平台 CLI 工具",
5
- "repository": {
6
- "type": "git",
7
- "url": "<repo-url>"
8
- },
9
- "homepage": "<repo-url>",
10
- "bugs": {
11
- "url": "<repo-url>/issues"
12
- },
13
- "type": "module",
14
- "bin": {
15
- "ability-cli": "./dist/index.js"
16
- },
17
- "files": [
18
- "dist",
19
- "README.md",
20
- "LICENSE"
21
- ],
22
- "scripts": {
23
- "build": "tsup src/index.ts --format esm --dts --clean",
24
- "dev": "tsup src/index.ts --format esm --watch",
25
- "test": "vitest run",
26
- "test:watch": "vitest",
27
- "prepublishOnly": "pnpm build && pnpm test"
28
- },
29
- "keywords": [],
30
- "author": "",
31
- "license": "ISC",
32
- "packageManager": "pnpm@10.28.2",
33
- "dependencies": {
34
- "chalk": "^5.6.2",
35
- "cli-table3": "^0.6.5",
36
- "commander": "^14.0.3"
37
- },
38
- "pnpm": {
39
- "onlyBuiltDependencies": ["esbuild"]
40
- },
41
- "devDependencies": {
42
- "@types/node": "^25.5.2",
43
- "tsup": "^8.5.1",
44
- "typescript": "^6.0.2",
45
- "vitest": "^4.1.3"
46
- }
47
- }
1
+ {
2
+ "name": "ability-cli",
3
+ "version": "0.2.1",
4
+ "description": "原子能力平台 CLI 工具",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "<repo-url>"
8
+ },
9
+ "homepage": "<repo-url>",
10
+ "bugs": {
11
+ "url": "<repo-url>/issues"
12
+ },
13
+ "type": "module",
14
+ "bin": {
15
+ "ability-cli": "./dist/index.js"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsup src/index.ts --format esm --dts --clean",
24
+ "dev": "tsup src/index.ts --format esm --watch",
25
+ "test": "vitest run",
26
+ "test:watch": "vitest",
27
+ "prepublishOnly": "npm run build && npm test"
28
+ },
29
+ "keywords": [
30
+ "ability",
31
+ "cli",
32
+ "atomic-ability",
33
+ "mcp",
34
+ "zyql"
35
+ ],
36
+ "author": "",
37
+ "license": "ISC",
38
+ "packageManager": "pnpm@10.28.2",
39
+ "dependencies": {
40
+ "chalk": "^5.6.2",
41
+ "cli-table3": "^0.6.5",
42
+ "commander": "^14.0.3"
43
+ },
44
+ "pnpm": {
45
+ "onlyBuiltDependencies": ["esbuild"]
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^25.5.2",
49
+ "tsup": "^8.5.1",
50
+ "typescript": "^6.0.2",
51
+ "vitest": "^4.1.3"
52
+ }
53
+ }