@zshuangmu/agenthub 0.4.2 → 0.4.3

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +25 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zshuangmu/agenthub",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "AI Agent 打包与分发平台 - 一句话打包上传,一键下载获得能力",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/cli.js CHANGED
@@ -158,23 +158,28 @@ agenthub search - 搜索 Agent
158
158
 
159
159
  选项:
160
160
  --registry <dir> Registry 目录 (必需)
161
+ --json JSON 格式输出
161
162
 
162
163
  示例:
163
164
  agenthub search "code review" --registry ./.registry
164
165
  agenthub search "" --registry ./.registry # 列出所有
166
+ agenthub search "code" --registry ./.registry --json
165
167
  `,
166
168
  list: `
167
169
  agenthub list - 列出已安装 Agent
168
170
 
169
171
  用法:
170
- agenthub list [--target-workspace <dir>]
172
+ agenthub list [--target-workspace <dir>] [--json]
171
173
 
172
174
  选项:
173
175
  --target-workspace <dir> 指定工作区目录(可选)
176
+ --json JSON 格式输出
174
177
 
175
178
  示例:
176
179
  agenthub list
177
180
  agenthub list --target-workspace ./my-workspace
181
+ agenthub list --json
182
+ agenthub list --target-workspace ./my-workspace
178
183
  `,
179
184
  verify: `
180
185
  agenthub verify - 校验已安装 Agent
@@ -363,7 +368,9 @@ async function main() {
363
368
 
364
369
  case "search": {
365
370
  const results = await searchCommand(rest[0] || "", options);
366
- if (results.length === 0) {
371
+ if (options.json) {
372
+ console.log(JSON.stringify({ agents: results, count: results.length, query: rest[0] || "" }, null, 2));
373
+ } else if (results.length === 0) {
367
374
  console.log(warning("未找到匹配的 Agent"));
368
375
  } else {
369
376
  console.log(`\n${infoColor(`找到 ${results.length} 个 Agent:`)}\n`);
@@ -377,14 +384,18 @@ async function main() {
377
384
  case "info": {
378
385
  if (!requireArg(rest[0], "错误: 需要指定 agent slug")) return;
379
386
  const result = await infoCommand(rest[0], options);
380
- console.log(`\n${highlight("📦")} ${result.name} (${result.slug}@${result.version})`);
381
- console.log(` ${result.description}`);
382
- console.log(` ${muted("Runtime:")} ${result.runtime?.type || "openclaw"} ${result.runtime?.version || ""}`);
383
- const mem = result.includes?.memory || {};
384
- if (mem.count > 0) {
385
- console.log(` ${muted("Memory:")} ${mem.count} (public: ${mem.public}, portable: ${mem.portable})`);
387
+ if (options.json) {
388
+ console.log(JSON.stringify(result, null, 2));
389
+ } else {
390
+ console.log(`\n${highlight("📦")} ${result.name} (${result.slug}@${result.version})`);
391
+ console.log(` ${result.description}`);
392
+ console.log(` ${muted("Runtime:")} ${result.runtime?.type || "openclaw"} ${result.runtime?.version || ""}`);
393
+ const mem = result.includes?.memory || {};
394
+ if (mem.count > 0) {
395
+ console.log(` ${muted("Memory:")} ${mem.count} 条 (public: ${mem.public}, portable: ${mem.portable})`);
396
+ }
397
+ console.log(`\n ${infoColor("安装命令:")} agenthub install ${result.slug}`);
386
398
  }
387
- console.log(`\n ${infoColor("安装命令:")} agenthub install ${result.slug}`);
388
399
  return;
389
400
  }
390
401
 
@@ -399,7 +410,11 @@ async function main() {
399
410
 
400
411
  case "list": {
401
412
  const list = await listCommand(options);
402
- console.log(formatListOutput(list));
413
+ if (options.json) {
414
+ console.log(JSON.stringify({ agents: list, count: list.length }, null, 2));
415
+ } else {
416
+ console.log(formatListOutput(list));
417
+ }
403
418
  return;
404
419
  }
405
420