@lark-apaas/openclaw-scripts-diagnose-cli 0.1.14-alpha.2 → 0.1.14-alpha.4

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 +45 -15
  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.14-alpha.2";
55
+ return "0.1.14-alpha.4";
56
56
  }
57
57
  //#endregion
58
58
  //#region src/rule-engine/base.ts
@@ -3528,6 +3528,32 @@ function needsLarkUpgrade(ctx) {
3528
3528
  }
3529
3529
  //#endregion
3530
3530
  //#region src/channels-probe.ts
3531
+ const FEISHU_INVALID_CONFIG_MSG = "channels.feishu: invalid config: must NOT have additional properties";
3532
+ /**
3533
+ * Run `openclaw status` and check whether the output contains the feishu
3534
+ * channel config validation error. This error appears when openclaw.json
3535
+ * has extra fields that are no longer recognised by the new plugin schema.
3536
+ *
3537
+ * Returns false on any execution error so callers can safely treat it as
3538
+ * "error not present" rather than aborting.
3539
+ */
3540
+ function isFeishuChannelConfigInvalid(cwd, timeoutMs = 1e4) {
3541
+ try {
3542
+ return (0, node_child_process.execSync)("openclaw status", {
3543
+ encoding: "utf-8",
3544
+ timeout: timeoutMs,
3545
+ cwd,
3546
+ stdio: [
3547
+ "ignore",
3548
+ "pipe",
3549
+ "pipe"
3550
+ ]
3551
+ }).includes(FEISHU_INVALID_CONFIG_MSG);
3552
+ } catch (e) {
3553
+ const err = e;
3554
+ return ((err.stdout ?? "") + (err.stderr ?? "")).includes(FEISHU_INVALID_CONFIG_MSG);
3555
+ }
3556
+ }
3531
3557
  const CHANNEL_LINE_RE = /^-\s+Feishu\s+([^:]+):\s+(.+)$/;
3532
3558
  /**
3533
3559
  * Port of Python `_account_is_working` from the feishu-channel-success-rate skill.
@@ -3644,7 +3670,9 @@ function runChannelsProbe(timeoutMs = 6e4) {
3644
3670
  */
3645
3671
  let UpgradeLarkNeededRule = class UpgradeLarkNeededRule extends DiagnoseRule {
3646
3672
  validate(ctx) {
3647
- if (!needsLarkUpgrade(ctx)) return { pass: true };
3673
+ const versionIncompatible = needsLarkUpgrade(ctx);
3674
+ const feishuConfigInvalid = !versionIncompatible && isFeishuChannelConfigInvalid(node_path.default.dirname(ctx.configPath));
3675
+ if (!(versionIncompatible || feishuConfigInvalid)) return { pass: true };
3648
3676
  let anyAccountWorking = false;
3649
3677
  try {
3650
3678
  anyAccountWorking = runChannelsProbe(3e4).anyAccountWorking;
@@ -3655,14 +3683,13 @@ let UpgradeLarkNeededRule = class UpgradeLarkNeededRule extends DiagnoseRule {
3655
3683
  return {
3656
3684
  pass: false,
3657
3685
  action: "upgrade_lark",
3658
- message: "飞书插件版本不兼容且 channels 不可用,建议执行 upgrade-lark 命令升级飞书插件"
3686
+ message: `飞书插件需要升级且 channels 不可用(版本不兼容=${versionIncompatible}, feishu配置无效=${feishuConfigInvalid}),建议执行 upgrade-lark 命令升级飞书插件`
3659
3687
  };
3660
3688
  }
3661
3689
  };
3662
3690
  UpgradeLarkNeededRule = __decorate([Rule({
3663
3691
  key: "upgrade_lark_needed",
3664
3692
  description: "检测飞书插件版本不兼容且 channels 不可用,判断是否需要执行 upgrade-lark 升级",
3665
- dependsOn: ["feishu_plugin_version_compat_lark"],
3666
3693
  repairMode: "check-only",
3667
3694
  level: "silent",
3668
3695
  profile: "experimental",
@@ -10366,7 +10393,7 @@ async function reportCliRun(opts) {
10366
10393
  //#region src/help.ts
10367
10394
  const BIN = "mclaw-diagnose";
10368
10395
  function versionBanner() {
10369
- return `v0.1.14-alpha.2`;
10396
+ return `v0.1.14-alpha.4`;
10370
10397
  }
10371
10398
  const COMMANDS = [
10372
10399
  {
@@ -11140,11 +11167,11 @@ function runUpgradeLark(opts) {
11140
11167
  log("── [Pre-check A] channels probe(升级前)────────────────");
11141
11168
  const beforeChannels = probeChannels("before", log, 3e4);
11142
11169
  log("");
11143
- log("── [Pre-check B] 版本兼容预检 ───────────────────────────");
11144
- let versionNeedsUpgrade = false;
11170
+ log("── [Pre-check B] 版本兼容预检 + feishu config 错误检测 ──");
11171
+ let versionIncompatible = false;
11145
11172
  try {
11146
11173
  const rawConfig = node_fs.default.readFileSync(configPath, "utf-8");
11147
- versionNeedsUpgrade = needsLarkUpgrade({
11174
+ versionIncompatible = needsLarkUpgrade({
11148
11175
  config: loadJSON5().parse(rawConfig),
11149
11176
  configPath,
11150
11177
  vars: {},
@@ -11153,17 +11180,20 @@ function runUpgradeLark(opts) {
11153
11180
  usesMiaodaSecretProvider: false
11154
11181
  }
11155
11182
  });
11156
- log(` version-compat pre-check: ${versionNeedsUpgrade ? "NEEDS_UPGRADE" : "ok"}`);
11183
+ log(` version-compat pre-check: ${versionIncompatible ? "NEEDS_UPGRADE" : "ok"}`);
11157
11184
  } catch (e) {
11158
11185
  log(` version-compat pre-check error: ${e.message} — treating as needs-upgrade`);
11159
- versionNeedsUpgrade = true;
11186
+ versionIncompatible = true;
11160
11187
  }
11188
+ const feishuConfigInvalid = !versionIncompatible && isFeishuChannelConfigInvalid(cwd);
11189
+ log(` feishu config invalid : ${feishuConfigInvalid}`);
11161
11190
  log("");
11162
11191
  log("── [Gate] 升级前置条件检查 ───────────────────────────────");
11163
- log(` version needs upgrade : ${versionNeedsUpgrade}`);
11192
+ log(` versionIncompatible : ${versionIncompatible}`);
11193
+ log(` feishuConfigInvalid : ${feishuConfigInvalid}`);
11164
11194
  log(` channels working before: ${beforeChannels.anyAccountWorking}`);
11165
- if (!versionNeedsUpgrade) {
11166
- const reason = "version already compatible — upgrade not needed";
11195
+ if (!(versionIncompatible || feishuConfigInvalid)) {
11196
+ const reason = "version compatible and feishu channel config valid — upgrade not needed";
11167
11197
  log(` SKIP: ${reason}`);
11168
11198
  log(`${"=".repeat(60)}`);
11169
11199
  log("upgrade-lark skipped (pre-check gate)");
@@ -11176,7 +11206,7 @@ function runUpgradeLark(opts) {
11176
11206
  };
11177
11207
  }
11178
11208
  if (beforeChannels.anyAccountWorking) {
11179
- const reason = "channels are working — upgrade not needed (version mismatch but system is functional)";
11209
+ const reason = "channels are working — upgrade not needed (issue detected but system is functional)";
11180
11210
  log(` SKIP: ${reason}`);
11181
11211
  log(`${"=".repeat(60)}`);
11182
11212
  log("upgrade-lark skipped (pre-check gate)");
@@ -11188,7 +11218,7 @@ function runUpgradeLark(opts) {
11188
11218
  logFile
11189
11219
  };
11190
11220
  }
11191
- log(" PROCEED: version incompatible AND channels not working → running upgrade");
11221
+ log(` PROCEED: requiresLarkUpgrade=true (version=${versionIncompatible}, feishuConfig=${feishuConfigInvalid}) AND channels not working → running upgrade`);
11192
11222
  log("");
11193
11223
  log("── [1/6] 文件备份 ────────────────────────────────────────");
11194
11224
  log(`before-state: botCount=${countFeishuBots(configPath)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/openclaw-scripts-diagnose-cli",
3
- "version": "0.1.14-alpha.2",
3
+ "version": "0.1.14-alpha.4",
4
4
  "description": "CLI for OpenClaw config diagnose and repair with JSON5 support",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {