@lark-apaas/openclaw-scripts-diagnose-cli 0.1.15-alpha.1 → 0.1.15-alpha.2

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/index.cjs +26 -16
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -52,7 +52,7 @@ node_assert = __toESM(node_assert);
52
52
  * it terse and parseable.
53
53
  */
54
54
  function getVersion() {
55
- return "0.1.15-alpha.1";
55
+ return "0.1.15-alpha.2";
56
56
  }
57
57
  //#endregion
58
58
  //#region src/rule-engine/base.ts
@@ -10581,7 +10581,7 @@ async function reportCliRun(opts) {
10581
10581
  //#region src/help.ts
10582
10582
  const BIN = "mclaw-diagnose";
10583
10583
  function versionBanner() {
10584
- return `v0.1.15-alpha.1`;
10584
+ return `v0.1.15-alpha.2`;
10585
10585
  }
10586
10586
  const COMMANDS = [
10587
10587
  {
@@ -10875,7 +10875,7 @@ EXIT CODES
10875
10875
  hidden: false,
10876
10876
  summary: "Upgrade the Feishu/Lark plugin via @larksuite/openclaw-lark-tools",
10877
10877
  help: `USAGE
10878
- ${BIN} upgrade-lark [--check-only] [--scene=<scene>] [--caller=<n>] [--trace-id=<id>]
10878
+ ${BIN} upgrade-lark [--check] [--scene=<scene>] [--caller=<n>] [--trace-id=<id>]
10879
10879
 
10880
10880
  DESCRIPTION
10881
10881
  Upgrades the Feishu/Lark plugin by running:
@@ -10903,12 +10903,12 @@ DESCRIPTION
10903
10903
  { "ok": false, "error": "...", "stderr": "...", "exitCode": 1,
10904
10904
  "rollbackOk": true, "validationError": "...", "logFile": "..." }
10905
10905
 
10906
- With --check-only:
10906
+ With --check:
10907
10907
  { "ok": true, "skipped": true, "upgradeNeeded": false, "logFile": "..." }
10908
10908
  { "ok": true, "skipped": true, "upgradeNeeded": true, "logFile": "..." } ← exit 1
10909
10909
 
10910
10910
  OPTIONS
10911
- --check-only Diagnose only: run the pre-check gate and report whether
10911
+ --check Diagnose only: run the pre-check gate and report whether
10912
10912
  upgrade is needed without installing. Exit 1 if needed.
10913
10913
  --scene=<scene> Telemetry label forwarded to Slardar only.
10914
10914
  Known values: PageUpgradeLark, etc. Custom strings accepted.
@@ -10919,7 +10919,7 @@ EXIT CODES
10919
10919
  0 Success: upgrade ran and all validations passed; or gate skipped upgrade.
10920
10920
  1 Failure: npx error, validation failed, or git commit failed.
10921
10921
  File rollback was attempted (see rollbackOk in the JSON output).
10922
- With --check-only: exit 1 means upgrade IS needed.
10922
+ With --check: exit 1 means upgrade IS needed.
10923
10923
  `
10924
10924
  },
10925
10925
  {
@@ -11162,10 +11162,18 @@ function reportDoctorRunToSlardar(opts) {
11162
11162
  }
11163
11163
  });
11164
11164
  }
11165
- /** 读取日志文件全文;文件不存在或读取失败时返回空字符串。 */
11166
- function readLogFile(filePath) {
11165
+ /**
11166
+ * 读取日志文件末尾最多 maxBytes 个字节。
11167
+ * 日志头部为固定 banner,有价值的内容(错误、探测结果、回滚状态)集中在末尾。
11168
+ * 从尾部截取保证 Slardar 字段限制内优先保留关键内容。
11169
+ */
11170
+ function readLogFileTail(filePath, maxBytes = 4e3) {
11167
11171
  try {
11168
- return node_fs.default.readFileSync(filePath, "utf-8");
11172
+ const buf = node_fs.default.readFileSync(filePath);
11173
+ if (buf.length <= maxBytes) return buf.toString("utf-8");
11174
+ let start = buf.length - maxBytes;
11175
+ while (start < buf.length && buf[start] !== 10) start++;
11176
+ return buf.subarray(start + 1).toString("utf-8");
11169
11177
  } catch {
11170
11178
  return "";
11171
11179
  }
@@ -11174,21 +11182,22 @@ function readLogFile(filePath) {
11174
11182
  * 向 Slardar 上报 upgrade-lark 运行结果(upgrade_lark_run 事件)。
11175
11183
  *
11176
11184
  * extraCategories 记录字符串维度:scene、exit_code、rollback_ok、
11177
- * validation_error、error_msg、log_content(日志文件全文)。
11185
+ * validation_error、error_msg、log_content(日志文件末尾 4000 字节,含关键结果)。
11178
11186
  *
11179
11187
  * extraMetrics 记录各阶段耗时(毫秒);未执行的阶段上报 -1 作为哨兵值,
11180
11188
  * 便于在 Slardar 查询时区分"未运行"和"运行了 0ms"。
11181
11189
  */
11182
11190
  function reportUpgradeLarkToSlardar(opts) {
11183
- console.error(`[slardar] upgrade_lark_run scene=${opts.scene ?? ""} success=${opts.success} exitCode=${opts.exitCode ?? ""} rollbackOk=${opts.rollbackOk ?? ""}`);
11191
+ console.error(`[slardar] upgrade_lark_run scene=${opts.scene ?? ""} checkOnly=${opts.checkOnly} success=${opts.success} exitCode=${opts.exitCode ?? ""} rollbackOk=${opts.rollbackOk ?? ""}`);
11184
11192
  const t = opts.timing ?? {};
11185
- const logContent = readLogFile(opts.logFile);
11193
+ const logContent = readLogFileTail(opts.logFile);
11186
11194
  reportTask({
11187
11195
  eventName: "upgrade_lark_run",
11188
11196
  durationMs: opts.durationMs,
11189
11197
  status: opts.success ? "success" : "failed",
11190
11198
  extraCategories: {
11191
11199
  scene: opts.scene ?? "",
11200
+ check_only: String(opts.checkOnly),
11192
11201
  exit_code: String(opts.exitCode ?? ""),
11193
11202
  rollback_ok: opts.rollbackOk != null ? String(opts.rollbackOk) : "",
11194
11203
  validation_error: opts.validationError ?? "",
@@ -11413,14 +11422,14 @@ function runUpgradeLark(opts) {
11413
11422
  }
11414
11423
  log(` PROCEED: requiresLarkUpgrade=true (version=${versionIncompatible}, feishuConfig=${feishuConfigInvalid}) AND channels not working → running upgrade`);
11415
11424
  if (opts.checkOnly) {
11416
- log(` check-only: upgrade IS needed returning without installing`);
11425
+ log(` --check 模式:需要升级不执行安装,直接返回`);
11417
11426
  log(`${"=".repeat(60)}`);
11418
- log("upgrade-lark check-only complete");
11427
+ log("upgrade-lark check complete");
11419
11428
  log(`${"=".repeat(60)}`);
11420
11429
  return {
11421
11430
  ok: true,
11422
11431
  skipped: true,
11423
- skipReason: "check-only",
11432
+ skipReason: "check",
11424
11433
  upgradeNeeded: true,
11425
11434
  timing,
11426
11435
  logFile
@@ -12050,7 +12059,7 @@ async function main() {
12050
12059
  break;
12051
12060
  }
12052
12061
  case "upgrade-lark": {
12053
- const checkOnly = args.includes("--check-only");
12062
+ const checkOnly = args.includes("--check");
12054
12063
  const result = runUpgradeLark({
12055
12064
  runId: rc.runId,
12056
12065
  scene,
@@ -12060,6 +12069,7 @@ async function main() {
12060
12069
  console.log(JSON.stringify(result));
12061
12070
  reportUpgradeLarkToSlardar({
12062
12071
  scene,
12072
+ checkOnly,
12063
12073
  durationMs: upgradeDurationMs,
12064
12074
  success: result.ok,
12065
12075
  logFile: result.logFile,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/openclaw-scripts-diagnose-cli",
3
- "version": "0.1.15-alpha.1",
3
+ "version": "0.1.15-alpha.2",
4
4
  "description": "CLI for OpenClaw config diagnose and repair with JSON5 support",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {