bfi-cli 0.1.94 → 0.1.95

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 +78 -2
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -7162,6 +7162,7 @@ async function handleInstall(args, api, globalOpts) {
7162
7162
  console.error(`${RED$1}获取包信息失败:${error.message}${RESET$3}`);
7163
7163
  process.exit(1);
7164
7164
  }
7165
+ if (pkgInfo.kind === "PLUGIN") throw new Error("这是完整插件,不是技能组合;请使用 --as plugin --agent <目标Agent> 安装,插件可能包含 MCP 和 Hooks。");
7165
7166
  const skills = pkgInfo.skills || [];
7166
7167
  if (skills.length === 0) {
7167
7168
  console.log(`${YELLOW$1}包中没有可独立安装的技能。${RESET$3}`);
@@ -7484,7 +7485,9 @@ async function handleUpdate(args, api, globalOpts) {
7484
7485
  console.log(`${DIM$3}正在更新 ${packagesToUpdate.length} 个包...${RESET$3}`);
7485
7486
  for (const pkg of packagesToUpdate) try {
7486
7487
  const pkgInfo = await api.getPackage(pkg.namespace, pkg.slug);
7487
- const skills = (pkgInfo.data || pkgInfo).skills || [];
7488
+ const info = pkgInfo.data || pkgInfo;
7489
+ if (info.kind === "PLUGIN") throw new Error("这是完整插件,请使用 --as plugin --agent <目标Agent> 更新;不会按技能组合安装。");
7490
+ const skills = info.skills || [];
7488
7491
  console.log(` ${DIM$3}更新 @${pkg.namespace}/${pkg.slug}(${skills.length} 个技能)...${RESET$3}`);
7489
7492
  for (const skill of skills) {
7490
7493
  const skillRef = skill.namespace ? `@${skill.namespace}/${skill.slug}` : skill.slug;
@@ -8891,7 +8894,9 @@ const HELP = {
8891
8894
  chain: `bfi ymc chain <trace_id> -e <env> [--ts <毫秒>] [--json]
8892
8895
  原子源:warningChain 全量 Span 链路(耗时分解/调用树)。trace 三源合一的链路通道单独调用。`,
8893
8896
  "sls-logs": `bfi ymc sls-logs <trace_id> -e <env> [--ts <毫秒>] [--json]
8894
- 原子源:SLS 业务日志(异常全文/堆栈)。按 traceid 索引检索。`,
8897
+ 原子源:SLS 业务日志(异常全文/堆栈)。按 traceid 索引检索。
8898
+ --json 结构:data 为对象(非数组)——日志行在 data.rows,计数在 data.count。
8899
+ 直接把 data 当数组迭代会得到 0 条(2026-10-16 实战教训)。`,
8895
8900
  "sls-raw": `bfi ymc sls-raw "<查询>" -e <env> [-t <time> | --start-time <s> --end-time <e> | --days N] [--line N] [--json]
8896
8901
  SLS 原始查询(阿里云 SLS 完整语法透传:索引检索 + | SELECT 分析语句)。
8897
8902
  参数:
@@ -9086,6 +9091,9 @@ function printHelp$2() {
9086
9091
  bfi event stat <dc> <date> [metric_type] [--page N] [--size N]
9087
9092
  date: yyyy-MM-dd 单日;metric_type: enter|fail|response_time_4s_|response_time_2s_4s|body_size_512k_1m|body_size_1m_
9088
9093
  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]
9094
+ bfi event dc-scan <date> [--event-type ET] [--node-code N]
9095
+ 全 DC 矩阵扫描:C1-C4 逐数据中心查 fail 统计,本事件命中高亮。
9096
+ ⚠️ monitor fail(不带 DC)存在数据中心盲区(实测漏 C3)——失败现场定位必须用本命令
9089
9097
  bfi event content <dc> <date> --event-id E --ds-code DS --tenant-code T
9090
9098
  bfi event dclist <dc>
9091
9099
  bfi event analyze-alert <dc> <date> --event-type ET --node-code N [--source-id S] [--tenant-code T]
@@ -9149,6 +9157,74 @@ async function runEvent(args, globalOpts) {
9149
9157
  });
9150
9158
  return;
9151
9159
  }
9160
+ if (sub === "dc-scan") {
9161
+ const date = reqs[0] ?? missing("<date>");
9162
+ const eventType = str("--event-type") ?? "";
9163
+ const nodeCode = str("--node-code") ?? "";
9164
+ const dcs = [
9165
+ "core1",
9166
+ "core2",
9167
+ "core3",
9168
+ "core4"
9169
+ ];
9170
+ const statOnce = async (dc) => {
9171
+ return (await api.call("event/stat", {
9172
+ dc,
9173
+ date,
9174
+ metric_type: "fail",
9175
+ page: 0,
9176
+ size: 1e3
9177
+ }))?.data?.data?.content ?? [];
9178
+ };
9179
+ const results = await Promise.all(dcs.map(async (dc) => {
9180
+ try {
9181
+ let content = await statOnce(dc);
9182
+ if (!content.length) content = await statOnce(dc);
9183
+ const hit = eventType ? content.filter((x) => x.eventType === eventType && (!nodeCode || x.nodeCode === nodeCode)) : content;
9184
+ return {
9185
+ dc,
9186
+ rows: hit,
9187
+ failNum: hit.reduce((acc, x) => acc + Number(x.num ?? 0), 0),
9188
+ total: content.length
9189
+ };
9190
+ } catch (e) {
9191
+ return {
9192
+ dc,
9193
+ rows: [],
9194
+ failNum: 0,
9195
+ total: 0,
9196
+ error: e instanceof Error ? e.message : String(e)
9197
+ };
9198
+ }
9199
+ }));
9200
+ if (jsonMode) {
9201
+ console.log(JSON.stringify({
9202
+ code: 0,
9203
+ msg: "success",
9204
+ data: {
9205
+ date,
9206
+ event_type: eventType,
9207
+ node_code: nodeCode,
9208
+ results
9209
+ }
9210
+ }, null, 2));
9211
+ return;
9212
+ }
9213
+ const lines = [`全 DC fail 矩阵(${date}${eventType ? ` · ${eventType}${nodeCode ? ` / ${nodeCode}` : ""}` : ""}):`, "DC 失败数 失败率 判定"];
9214
+ for (const r of results) {
9215
+ if (r.error) {
9216
+ lines.push(`${r.dc.padEnd(8)} 通道错误:${r.error}`);
9217
+ continue;
9218
+ }
9219
+ const rate = r.rows.length ? String(r.rows[0].failRate ?? "-") : "-";
9220
+ const verdict = r.total === 0 ? "✓ 无记录(排除证据)" : r.failNum === 0 ? "✓ 有流量零失败" : `🔴 失败现场(${r.rows.length} 个监听行)`;
9221
+ lines.push(`${r.dc.padEnd(8)} ${String(r.failNum).padEnd(8)} ${rate.padEnd(11)} ${verdict}`);
9222
+ }
9223
+ const hot = results.filter((r) => r.failNum > 0).map((r) => r.dc);
9224
+ lines.push(hot.length ? `→ 失败现场:${hot.join(" / ")}(对命中 DC 逐一 event analyze-alert;零命中 DC 是报告的排除证据)` : "→ 全 DC 无失败记录");
9225
+ console.log(lines.join("\n"));
9226
+ return;
9227
+ }
9152
9228
  if (sub === "monitor") {
9153
9229
  const metric = reqs[0];
9154
9230
  if (!metric || !METRICS.includes(metric)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bfi-cli",
3
- "version": "0.1.94",
3
+ "version": "0.1.95",
4
4
  "description": "用友大业财BFI统一命令行工具,支持技能,技能包,元数据,UI元数据等",
5
5
  "type": "module",
6
6
  "bin": {