@lark-apaas/openclaw-scripts-diagnose-cli 0.1.18-alpha.5 → 0.1.18-alpha.6

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 +60 -45
  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.18-alpha.5";
55
+ return "0.1.18-alpha.6";
56
56
  }
57
57
  //#endregion
58
58
  //#region src/rule-engine/base.ts
@@ -3448,24 +3448,36 @@ function compareCalVer(a, b) {
3448
3448
  return semver.default.compare(coerceCalVer(a), coerceCalVer(b));
3449
3449
  }
3450
3450
  /**
3451
- * Infer the effective upper bound for a compat entry that has no explicit maxOpenclawVersion.
3451
+ * 该条目的有效上界——开区间(EXCLUSIVE):openclaw 此值即不兼容。
3452
+ * undefined = 最高档,无上界。
3452
3453
  *
3453
- * Scans toward higher plugin versions (lower indices in the descending table) and returns
3454
- * the first entry whose minOpenclawVersion differs from the current entry's.
3455
- * That minOpenclawVersion becomes an EXCLUSIVE upper bound — the openclaw version that
3456
- * starts a new incompatible range.
3454
+ * 上界一律为开区间,两种来源:
3455
+ * - 有显式 maxOpenclawVersion 直接用它(它本身就是「首个不兼容的 openclaw 版本」)。
3456
+ * - 无显式 max 向更高插件版本(表降序,index 更小)扫描,取首个「严格更高 min」的
3457
+ * minOpenclawVersion,即下一不兼容区间的起点。
3457
3458
  *
3458
- * Returns undefined for the topmost entry (no upper bound).
3459
+ * 只接受严格更高的 min(跳过相同 min 的同档;跳过更低 min 防止非单调表产生空区间
3460
+ * [min, max) 把本条目永久判为不兼容)。
3459
3461
  */
3460
3462
  function inferEffectiveMax(index) {
3461
3463
  const cur = VERSION_COMPAT_MAP[index];
3462
- if (cur.maxOpenclawVersion != null) return {
3463
- max: cur.maxOpenclawVersion,
3464
- exclusive: false
3465
- };
3466
- for (let i = index - 1; i >= 0; i--) if (compareCalVer(VERSION_COMPAT_MAP[i].minOpenclawVersion, cur.minOpenclawVersion) > 0) return {
3467
- max: VERSION_COMPAT_MAP[i].minOpenclawVersion,
3468
- exclusive: true
3464
+ if (cur.maxOpenclawVersion != null) return cur.maxOpenclawVersion;
3465
+ for (let i = index - 1; i >= 0; i--) if (compareCalVer(VERSION_COMPAT_MAP[i].minOpenclawVersion, cur.minOpenclawVersion) > 0) return VERSION_COMPAT_MAP[i].minOpenclawVersion;
3466
+ }
3467
+ /**
3468
+ * 单一真相源:floor 匹配 + 有效上界,得到某插件版本的半开兼容区间 [min, max)(含命中条目)。
3469
+ * evaluateVersionRange / findClosestEntry / effectiveCompatRange 全部基于它,
3470
+ * 避免 floor 匹配与 inferEffectiveMax 在多处重复。max 一律为开区间上界(EXCLUSIVE);
3471
+ * 最高档 max 为 undefined(无上界)。undefined = 版本比全表都旧(无 floor 条目)。
3472
+ */
3473
+ function resolveRange(pluginVersion) {
3474
+ const index = VERSION_COMPAT_MAP.findIndex((e) => compareCalVer(e.openclawLarkVersion, pluginVersion) <= 0);
3475
+ if (index === -1) return void 0;
3476
+ const entry = VERSION_COMPAT_MAP[index];
3477
+ return {
3478
+ entry,
3479
+ min: entry.minOpenclawVersion,
3480
+ max: inferEffectiveMax(index)
3469
3481
  };
3470
3482
  }
3471
3483
  /**
@@ -3475,38 +3487,33 @@ function inferEffectiveMax(index) {
3475
3487
  *
3476
3488
  * - index === -1(插件版本比全表都旧,无 floor 条目)→ 无区间可判,视为插件过旧 → 'lark'
3477
3489
  * - oc < entry.minOpenclawVersion → 'openclaw'
3478
- * - oc ≥ 推断/显式上界 'lark'
3490
+ * - oc ≥ 有效上界(开区间)→ 'lark'
3479
3491
  * - 否则兼容
3480
3492
  *
3481
- * 上界语义:显式 maxOpenclawVersion INCLUSIVE;推断上界为 EXCLUSIVE
3493
+ * 区间统一为半开 [min, max):min 闭、max 开(显式与推断上界一律 EXCLUSIVE)。
3482
3494
  */
3483
3495
  function evaluateVersionRange(pluginVersion, openclawVersion) {
3484
- const index = VERSION_COMPAT_MAP.findIndex((e) => compareCalVer(e.openclawLarkVersion, pluginVersion) <= 0);
3485
- if (index === -1) return {
3496
+ const r = resolveRange(pluginVersion);
3497
+ if (!r) return {
3486
3498
  compatible: false,
3487
3499
  direction: "lark",
3488
3500
  entry: void 0
3489
3501
  };
3490
- const entry = VERSION_COMPAT_MAP[index];
3491
3502
  const oc = coerceCalVer(openclawVersion);
3492
- if (semver.default.lt(oc, coerceCalVer(entry.minOpenclawVersion))) return {
3503
+ if (semver.default.lt(oc, coerceCalVer(r.min))) return {
3493
3504
  compatible: false,
3494
3505
  direction: "openclaw",
3495
- entry
3506
+ entry: r.entry
3507
+ };
3508
+ if (r.max !== void 0 && semver.default.gte(oc, coerceCalVer(r.max))) return {
3509
+ compatible: false,
3510
+ direction: "lark",
3511
+ entry: r.entry
3496
3512
  };
3497
- const maxInfo = inferEffectiveMax(index);
3498
- if (maxInfo) {
3499
- const max = coerceCalVer(maxInfo.max);
3500
- if (maxInfo.exclusive ? !semver.default.lt(oc, max) : semver.default.gt(oc, max)) return {
3501
- compatible: false,
3502
- direction: "lark",
3503
- entry
3504
- };
3505
- }
3506
3513
  return {
3507
3514
  compatible: true,
3508
3515
  direction: null,
3509
- entry
3516
+ entry: r.entry
3510
3517
  };
3511
3518
  }
3512
3519
  /**
@@ -3522,15 +3529,16 @@ function evaluateVersionRange(pluginVersion, openclawVersion) {
3522
3529
  /** fork 对标的官方 openclaw-lark 版本(与 VERSION_COMPAT_MAP 强耦合,故留在此处)。 */
3523
3530
  const FORK_LARK_PLUGIN_PINNED_VERSION = "2026.4.1";
3524
3531
  /**
3525
- * Floor match: find the entry with the largest openclawLarkVersion that is
3526
- * pluginVersion ("closest lower-or-equal version").
3527
- *
3528
- * The table is sorted descending, so the first entry whose version ≤
3529
- * pluginVersion is the answer. Returns undefined only when pluginVersion
3530
- * is older than every entry in the table.
3532
+ * 返回某插件版本(floor 匹配后)的有效兼容区间 [min, max),含 evaluateVersionRange 所用的
3533
+ * (显式或推断的)开区间上界——区别于仅暴露显式 maxOpenclawVersion findClosestEntry。
3534
+ * undefined = 版本比全表都旧(无 floor 条目)。
3531
3535
  */
3532
- function findClosestEntry(pluginVersion) {
3533
- return VERSION_COMPAT_MAP.find((e) => compareCalVer(e.openclawLarkVersion, pluginVersion) <= 0);
3536
+ function effectiveCompatRange(pluginVersion) {
3537
+ const r = resolveRange(pluginVersion);
3538
+ return r ? {
3539
+ min: r.min,
3540
+ max: r.max
3541
+ } : void 0;
3534
3542
  }
3535
3543
  /** "@scope/name" → "name";无 scope 原样返回。 */
3536
3544
  function extractBaseName(name) {
@@ -3701,12 +3709,19 @@ function isLegacyPlugin(p) {
3701
3709
  function buildCompatPrefix(installed, ocCur, isLegacy) {
3702
3710
  const desc = describePlugin(installed);
3703
3711
  if (isLegacy) return `检测到已弃用的旧包 ${desc}(包名 "${installed.allowName}" 已停止维护,需替换为 "openclaw-lark")`;
3704
- return `飞书插件 ${desc} 与当前 openclaw@${ocCur} 不兼容(${describeCompatConstraint(installed.version ? findClosestEntry(installed.version) : void 0, installed.version)})`;
3712
+ return `飞书插件 ${desc} 与当前 openclaw@${ocCur} 不兼容(${describeCompatConstraint(installed.version)})`;
3705
3713
  }
3706
- function describeCompatConstraint(entry, pluginVersion) {
3707
- if (!entry) return `插件版本 ${pluginVersion ?? "未知"} 不在版本兼容表中`;
3708
- if (entry.maxOpenclawVersion) return `该插件版本要求 openclaw ∈ [${entry.minOpenclawVersion}, ${entry.maxOpenclawVersion}]`;
3709
- return `该插件版本要求 openclaw ${entry.minOpenclawVersion}`;
3714
+ /**
3715
+ * 兼容区间文案,体现上下界(半开 [min, max):下界闭、上界开)。用 effectiveCompatRange
3716
+ * 取「含推断/显式开区间上界」的区间,避免无显式 maxOpenclawVersion 的条目漏掉上限。
3717
+ * 有上界 openclaw [min, max)
3718
+ * 最高档无上界 → openclaw ≥ min
3719
+ */
3720
+ function describeCompatConstraint(pluginVersion) {
3721
+ if (!pluginVersion) return `插件版本未知,不在版本兼容表中`;
3722
+ const range = effectiveCompatRange(pluginVersion);
3723
+ if (!range) return `插件版本 ${pluginVersion} 不在版本兼容表中`;
3724
+ return range.max === void 0 ? `该插件版本要求 openclaw ≥ ${range.min}` : `该插件版本要求 openclaw ∈ [${range.min}, ${range.max})`;
3710
3725
  }
3711
3726
  function describePlugin(p) {
3712
3727
  return (p.fullName ?? p.allowName) + (p.version ? `@${p.version}` : "");
@@ -11221,7 +11236,7 @@ async function reportCliRun(opts) {
11221
11236
  //#region src/help.ts
11222
11237
  const BIN = "mclaw-diagnose";
11223
11238
  function versionBanner() {
11224
- return `v0.1.18-alpha.5`;
11239
+ return `v0.1.18-alpha.6`;
11225
11240
  }
11226
11241
  const COMMANDS = [
11227
11242
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/openclaw-scripts-diagnose-cli",
3
- "version": "0.1.18-alpha.5",
3
+ "version": "0.1.18-alpha.6",
4
4
  "description": "CLI for OpenClaw config diagnose and repair with JSON5 support",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {