bfi-cli 0.1.64 → 0.1.67

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/dist/cli.mjs +57 -10
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -7517,7 +7517,7 @@ function showHelp$2() {
7517
7517
  console.log(` publish <path> Publish a plugin to SkillHub`);
7518
7518
  console.log(` list, ls List plugins on SkillHub`);
7519
7519
  console.log(` info <id> Show plugin details`);
7520
- console.log(` install <ref> Install a plugin (SkillHub id or local .zip)`);
7520
+ console.log(` install <ref> Install a plugin (slug, plugin id, or local .zip)`);
7521
7521
  console.log();
7522
7522
  }
7523
7523
  async function createScaffold(args) {
@@ -7692,7 +7692,7 @@ async function info$1(args, globalOpts) {
7692
7692
  async function install(args, globalOpts) {
7693
7693
  const ref = args[0];
7694
7694
  if (!ref) {
7695
- console.error("用法:bfi plugin install <pluginId|./plugin.zip>");
7695
+ console.error("用法:bfi plugin install <slug|插件ID|./plugin.zip>");
7696
7696
  process.exit(1);
7697
7697
  }
7698
7698
  const homeSkills = path$1.join(os$1.homedir(), ".claude", "skills");
@@ -7706,7 +7706,17 @@ async function install(args, globalOpts) {
7706
7706
  }
7707
7707
  const { registry, token } = resolveConfig(globalOpts);
7708
7708
  const api = new SkillHubAPI(registry, token);
7709
- const plugin = await api.getPlugin(Number(ref));
7709
+ let plugin;
7710
+ if (/^\d+$/.test(ref)) plugin = await api.getPlugin(Number(ref));
7711
+ else {
7712
+ const list = await api.listPlugins();
7713
+ const match = (Array.isArray(list) ? list : list?.content ?? list?.data ?? []).find((p) => p.slug === ref || p.displayName === ref);
7714
+ if (!match) {
7715
+ console.error(`未找到插件:${ref}(支持传 slug 或插件 ID)`);
7716
+ process.exit(1);
7717
+ }
7718
+ plugin = await api.getPlugin(match.id);
7719
+ }
7710
7720
  const slug = plugin.slug ?? `plugin-${plugin.id}`;
7711
7721
  if (!plugin.latestVersionId) {
7712
7722
  console.error(`插件 ${slug} 尚无已发布版本,无法安装`);
@@ -8206,7 +8216,8 @@ async function runYmc(args, globalOpts) {
8206
8216
  }
8207
8217
  emit(await api.call("trace", {
8208
8218
  trace_id: id,
8209
- ...requireEnv(rest)
8219
+ ...requireEnv(rest),
8220
+ ...opt(rest, "--ts") ? { ts: Number(opt(rest, "--ts")) } : {}
8210
8221
  }), jsonMode, (data) => {
8211
8222
  const d = data;
8212
8223
  const lines = [];
@@ -8244,7 +8255,8 @@ async function runYmc(args, globalOpts) {
8244
8255
  }
8245
8256
  emit(await api.call("chain", {
8246
8257
  trace_id: id,
8247
- ...requireEnv(rest)
8258
+ ...requireEnv(rest),
8259
+ ...opt(rest, "--ts") ? { ts: Number(opt(rest, "--ts")) } : {}
8248
8260
  }), jsonMode, (data) => {
8249
8261
  const d = data;
8250
8262
  return `✓ 链路查询: ts=${d.ts}(${d.ts_source})chain=${d.warning_chain ? "有" : "无"}`;
@@ -8267,7 +8279,21 @@ async function runYmc(args, globalOpts) {
8267
8279
  ...opt(rest, "--days") ? { days: Number(opt(rest, "--days")) } : {},
8268
8280
  ...opt(rest, "--line") ? { line: Number(opt(rest, "--line")) } : {}
8269
8281
  };
8270
- emit(await api.call("sls/raw", body), jsonMode, rowsSummary("SLS 原始查询"));
8282
+ emit(await api.call("sls/raw", body), jsonMode, (data) => {
8283
+ const d = data;
8284
+ const rows = Array.isArray(d) ? d : d.rows ?? d.data ?? [];
8285
+ const n = rows.length;
8286
+ if (!n) return "✓ SLS 原始查询: 0 行";
8287
+ const times = rows.map((x) => Number(x.__time__)).filter(Boolean);
8288
+ const fmt = (t) => (/* @__PURE__ */ new Date(t * 1e3)).toLocaleString("zh-CN", { hour12: false });
8289
+ const span = times.length ? `时间范围 ${fmt(Math.min(...times))} ~ ${fmt(Math.max(...times))}` : "";
8290
+ const keys = Object.keys(rows[0]).slice(0, 8).join(",");
8291
+ return [
8292
+ `✓ SLS 原始查询: ${n} 行 ${span}`,
8293
+ `字段: ${keys}`,
8294
+ `样本: ${JSON.stringify(rows[0]).slice(0, 200)}`
8295
+ ].join("\n");
8296
+ });
8271
8297
  break;
8272
8298
  }
8273
8299
  case "sls-grep": {
@@ -8297,7 +8323,8 @@ async function runYmc(args, globalOpts) {
8297
8323
  }
8298
8324
  emit(await api.call("sls/logs", {
8299
8325
  trace_id: id,
8300
- ...requireEnv(rest)
8326
+ ...requireEnv(rest),
8327
+ ...opt(rest, "--ts") ? { ts: Number(opt(rest, "--ts")) } : {}
8301
8328
  }), jsonMode, rowsSummary("SLS 日志"));
8302
8329
  break;
8303
8330
  }
@@ -8318,7 +8345,19 @@ async function runYmc(args, globalOpts) {
8318
8345
  const v = opt(rest, name);
8319
8346
  if (v) body[k] = v;
8320
8347
  }
8321
- emit(await api.call("ymc/warningSql", body), jsonMode, rowsSummary("慢 SQL"));
8348
+ emit(await api.call("ymc/warningSql", body), jsonMode, (data) => {
8349
+ const d = data;
8350
+ const rows = Array.isArray(d) ? d : d.rows ?? d.data ?? [];
8351
+ const n = rows.length;
8352
+ const lines = [`✓ 慢 SQL: ${n} 条(耗时降序)`];
8353
+ for (const x of rows.slice(0, 5)) {
8354
+ const sql = String(x.sqlStr ?? "").replace(/\s+/g, " ").slice(0, 120);
8355
+ const stack1 = String(x.sqlStack ?? "").split("\n")[0]?.slice(0, 80) ?? "";
8356
+ lines.push(`- ${x.curAppCode} ${x.costTime}ms rows=${x.rowCount ?? "?"} md5=${String(x.md5Sql ?? "").slice(0, 8)} trace=${x.traceId ?? "?"}\n ${sql}\n stack: ${stack1}`);
8357
+ }
8358
+ if (n > 5) lines.push(`… 其余 ${n - 5} 条用 --json 获取`);
8359
+ return lines.join("\n");
8360
+ });
8322
8361
  break;
8323
8362
  }
8324
8363
  case "slowcall": {
@@ -8339,7 +8378,15 @@ async function runYmc(args, globalOpts) {
8339
8378
  }
8340
8379
  const cost = opt(rest, "--min-cost");
8341
8380
  if (cost) body.costTime = [Number(cost), 999999];
8342
- emit(await api.call("ymc/warningCall", body), jsonMode, rowsSummary("慢调用"));
8381
+ emit(await api.call("ymc/warningCall", body), jsonMode, (data) => {
8382
+ const d = data;
8383
+ const rows = Array.isArray(d) ? d : d.rows ?? d.data ?? [];
8384
+ const n = rows.length;
8385
+ const lines = [`✓ 慢调用: ${n} 条(耗时降序)`];
8386
+ for (const x of rows.slice(0, 5)) lines.push(`- ${x.curAppCode} ${x.costTime}ms (sql${x.sqlCostTime ?? 0}/rpc${x.rpcCostTime ?? 0}/redis${x.redisCostTime ?? 0})\n ${x.remoteCallMethod ?? "?"} trace=${x.traceId ?? "?"} pod=${x.podId ?? "?"}`);
8387
+ if (n > 5) lines.push(`… 其余 ${n - 5} 条用 --json 获取`);
8388
+ return lines.join("\n");
8389
+ });
8343
8390
  break;
8344
8391
  }
8345
8392
  case "exceptions": {
@@ -8809,7 +8856,7 @@ ${BOLD}━━━ 插件管理 ━━━${RESET}
8809
8856
  plugin publish <dir|zip|tgz> 发布插件到 SkillHub
8810
8857
  plugin list 列出插件
8811
8858
  plugin info <id> 查看插件详情
8812
- plugin install <id|file.zip> 安装插件(SkillHub id 或本地 zip)
8859
+ plugin install <slug|id|file.zip> 安装插件(名称 / ID / 本地压缩包)
8813
8860
 
8814
8861
  ${BOLD}━━━ MCP 服务器 ━━━${RESET}
8815
8862
  mcp list 列出 MCP 服务器
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bfi-cli",
3
- "version": "0.1.64",
3
+ "version": "0.1.67",
4
4
  "description": "用友大业财BFI统一命令行工具,支持技能,技能包,元数据,UI元数据等",
5
5
  "type": "module",
6
6
  "bin": {