bfi-cli 0.1.85 → 0.1.87

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 +101 -7
  2. package/package.json +2 -2
package/dist/cli.mjs CHANGED
@@ -8307,12 +8307,12 @@ async function runYmc(args, globalOpts) {
8307
8307
  const token = globalOpts.token;
8308
8308
  const api = new YmcApi(token ?? null, void 0, dryRun);
8309
8309
  if (!sub || sub === "--help" || sub === "-h") {
8310
- printHelp$2();
8310
+ printHelp$3();
8311
8311
  return;
8312
8312
  }
8313
8313
  if (sub === "help") {
8314
8314
  if (!rest[0]) {
8315
- printHelp$2();
8315
+ printHelp$3();
8316
8316
  return;
8317
8317
  }
8318
8318
  printCommandHelp(rest[0]);
@@ -8888,7 +8888,7 @@ async function runYmc(args, globalOpts) {
8888
8888
  }
8889
8889
  default:
8890
8890
  console.error(`未知子命令:${sub}`);
8891
- printHelp$2();
8891
+ printHelp$3();
8892
8892
  process.exit(1);
8893
8893
  }
8894
8894
  }
@@ -9023,11 +9023,11 @@ function printCommandHelp(cmd) {
9023
9023
  if (h) console.log(h);
9024
9024
  else {
9025
9025
  console.error(`未知子命令:${cmd}`);
9026
- printHelp$2();
9026
+ printHelp$3();
9027
9027
  process.exit(1);
9028
9028
  }
9029
9029
  }
9030
- function printHelp$2() {
9030
+ function printHelp$3() {
9031
9031
  console.log(`
9032
9032
  bfi ymc — 观测查询(v2 API:YMC/Kibana/SLS/trace)
9033
9033
 
@@ -9082,7 +9082,7 @@ const RESOURCES = [
9082
9082
  "type-info",
9083
9083
  "listener-doc"
9084
9084
  ];
9085
- function printHelp$1() {
9085
+ function printHelp$2() {
9086
9086
  console.log(`bfi event — YonBIP 事件中心取数(诊断编排见 bfi-diagnose-event 技能)
9087
9087
 
9088
9088
  用法:
@@ -9099,6 +9099,10 @@ function printHelp$1() {
9099
9099
  bfi event record <dc> <date> --source-id S --event-type ET --node-code N --ds-code DS [--record-status fail] [--record-id ID] [--tenant-code T] [--size ≤20]
9100
9100
  bfi event content <dc> <date> --event-id E --ds-code DS --tenant-code T
9101
9101
  bfi event dclist <dc>
9102
+ bfi event analyze-alert <dc> <date> --event-type ET --node-code N [--source-id S] [--tenant-code T]
9103
+ 告警编排分析(一次调用:主数据→分库明细→去重采样→traceId→链路→结构化证据包)
9104
+ bfi event slow-consume <dc> [--days ≤7] [--event-type ET] [--node-code N] [--tenant-id T]
9105
+ 慢消费分析(一次调用:SLS 慢日志→事件提取→租户聚合→链路→结构化汇总)
9102
9106
  全局: --json / --dry-run / --token <tok>
9103
9107
 
9104
9108
  示例:
@@ -9115,7 +9119,7 @@ async function runEvent(args, globalOpts) {
9115
9119
  const sub = args[0];
9116
9120
  const rest = args.slice(1);
9117
9121
  if (!sub || sub === "--help" || sub === "-h" || flag(rest, "--help") || flag(rest, "-h")) {
9118
- printHelp$1();
9122
+ printHelp$2();
9119
9123
  return;
9120
9124
  }
9121
9125
  const jsonMode = flag(rest, "--json");
@@ -9129,6 +9133,33 @@ async function runEvent(args, globalOpts) {
9129
9133
  const call = async (path, body) => emit(await api.call(path, body), jsonMode);
9130
9134
  const num = (name, dflt) => Number(opt(rest, name) ?? dflt);
9131
9135
  const str = (name) => opt(rest, name);
9136
+ if (sub === "analyze-alert") {
9137
+ const dc = reqs[0] ?? missing("<dc>");
9138
+ const date = reqs[1] ?? missing("<date>");
9139
+ const eventType = str("--event-type");
9140
+ const nodeCode = str("--node-code");
9141
+ if (!eventType) missing("--event-type");
9142
+ if (!nodeCode) missing("--node-code");
9143
+ await call("event/analyze-alert", {
9144
+ dc,
9145
+ date,
9146
+ event_type: eventType,
9147
+ node_code: nodeCode,
9148
+ source_id: str("--source-id") ?? "",
9149
+ tenant_code: str("--tenant-code") ?? ""
9150
+ });
9151
+ return;
9152
+ }
9153
+ if (sub === "slow-consume") {
9154
+ await call("event/slow-consume", {
9155
+ dc: reqs[0] ?? missing("<dc>"),
9156
+ days: num("--days", 7),
9157
+ event_type: str("--event-type") ?? "",
9158
+ node_code: str("--node-code") ?? "",
9159
+ tenant_id: str("--tenant-id") ?? ""
9160
+ });
9161
+ return;
9162
+ }
9132
9163
  if (sub === "monitor") {
9133
9164
  const metric = reqs[0];
9134
9165
  if (!metric || !METRICS.includes(metric)) {
@@ -9259,6 +9290,66 @@ async function runEvent(args, globalOpts) {
9259
9290
  console.error(`未知子命令: ${sub}。运行 bfi event --help`);
9260
9291
  process.exit(1);
9261
9292
  }
9293
+ function printHelp$1() {
9294
+ console.log(`bfi ms — 微服务→仓库映射(诊断中把微服务编码可靠地转换为仓库列表)
9295
+
9296
+ 用法:
9297
+ bfi ms <微服务编码> # 精确/模糊查询(精确匹配行排前)
9298
+ bfi ms --keyword <名称关键词> # 按微服务中文名模糊查询
9299
+ 全局: --json / --dry-run / --token <tok>
9300
+
9301
+ 输出: 每个微服务的 code/名称/类型/部门/负责人/Jira 项目 + repos 列表
9302
+ (repo 字段可直接作为 bfi-code-search context 的 repo 参数;
9303
+ 与 BCS list_repos 名单核对,个别仓为 org__repo 形态时用备选值)
9304
+
9305
+ 示例:
9306
+ bfi ms yonbip-scm-stock
9307
+ bfi ms --keyword 库存
9308
+
9309
+ 提示: 事件监听的 microServiceCode 字段 / 异常栈的包名线索都可用本命令反查仓库。`);
9310
+ }
9311
+ async function runMs(args, globalOpts) {
9312
+ const rest = args;
9313
+ if (!args[0] || flag(rest, "--help") || flag(rest, "-h")) {
9314
+ printHelp$1();
9315
+ return;
9316
+ }
9317
+ const jsonMode = flag(rest, "--json");
9318
+ const dryRun = flag(rest, "--dry-run");
9319
+ const api = new YmcApi(globalOpts.token ?? null, void 0, dryRun);
9320
+ if (!dryRun && !api.token) {
9321
+ console.error("未认证。先运行:bfi auth login --token <sk-token>(或传 --token)");
9322
+ process.exit(1);
9323
+ }
9324
+ const keyword = opt(rest, "--keyword");
9325
+ const code = keyword ? "" : positionals(rest)[0] ?? "";
9326
+ if (!code && !keyword) {
9327
+ console.error("缺少微服务编码或 --keyword。运行 bfi ms --help 查看用法。");
9328
+ process.exit(1);
9329
+ }
9330
+ const body = {
9331
+ code,
9332
+ name: keyword ?? "",
9333
+ use_status: opt(rest, "--use-status") ?? "1",
9334
+ page: Number(opt(rest, "--page") ?? 1),
9335
+ size: Number(opt(rest, "--size") ?? 20)
9336
+ };
9337
+ emit(await api.call("code/microservice", body), jsonMode, (data) => {
9338
+ const d = data;
9339
+ const rows = d.rows ?? [];
9340
+ if (!rows.length) return `无匹配微服务(total=${d.total ?? 0})`;
9341
+ return rows.map((r) => {
9342
+ const repos = r.repos ?? [];
9343
+ const repoLines = repos.map((x) => ` - ${x.repo}${x.repo_qualified && x.repo_qualified !== x.repo ? ` (备选: ${x.repo_qualified})` : ""} (${x.git_url}${x.branch ? ` @${x.branch}` : ""})`).join("\n");
9344
+ return [
9345
+ `${r.code} ${r.name} [${r.type || "-"}]`,
9346
+ ` 部门: ${r.department || "-"} | 开发: ${r.developer_name || "-"} | 架构: ${r.architect_name || "-"} | Jira: ${r.jira_project_name || "-"}`,
9347
+ ` 仓库(${repos.length}):`,
9348
+ repoLines || " (无 git 地址)"
9349
+ ].join("\n");
9350
+ }).join("\n\n");
9351
+ });
9352
+ }
9262
9353
  async function runDb(args, globalOpts) {
9263
9354
  const sub = args[0];
9264
9355
  const rest = args.slice(1);
@@ -9988,6 +10079,9 @@ async function main() {
9988
10079
  case "event":
9989
10080
  await runEvent(restArgs, globalOpts);
9990
10081
  break;
10082
+ case "ms":
10083
+ await runMs(restArgs, globalOpts);
10084
+ break;
9991
10085
  case "db":
9992
10086
  await runDb(restArgs, globalOpts);
9993
10087
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bfi-cli",
3
- "version": "0.1.85",
3
+ "version": "0.1.87",
4
4
  "description": "用友大业财BFI统一命令行工具,支持技能,技能包,元数据,UI元数据等",
5
5
  "type": "module",
6
6
  "bin": {
@@ -55,4 +55,4 @@
55
55
  "yaml": "^2.8.3",
56
56
  "zod": "^3.25.0"
57
57
  }
58
- }
58
+ }