@lark-apaas/openclaw-scripts-diagnose-cli 0.1.1-alpha.26 → 0.1.1-alpha.28

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 +75 -10
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -682,6 +682,27 @@ FeishuChannelRule = _FeishuChannelRule = __decorate([Rule({
682
682
  repairMode: "standard"
683
683
  })], FeishuChannelRule);
684
684
  //#endregion
685
+ //#region src/rules/feishu-default-account.ts
686
+ let FeishuDefaultAccountRule = class FeishuDefaultAccountRule extends DiagnoseRule {
687
+ validate(ctx) {
688
+ const feishu = getNestedMap(ctx.config, "channels", "feishu");
689
+ if (feishu && "defaultAccount" in feishu) return {
690
+ pass: false,
691
+ message: "channels.feishu.defaultAccount should be removed"
692
+ };
693
+ return { pass: true };
694
+ }
695
+ repair(ctx) {
696
+ const feishu = getNestedMap(ctx.config, "channels", "feishu");
697
+ if (feishu && "defaultAccount" in feishu) delete feishu.defaultAccount;
698
+ }
699
+ };
700
+ FeishuDefaultAccountRule = __decorate([Rule({
701
+ key: "feishu_default_account",
702
+ dependsOn: ["config_syntax_check"],
703
+ repairMode: "standard"
704
+ })], FeishuDefaultAccountRule);
705
+ //#endregion
685
706
  //#region src/rules/gateway.ts
686
707
  var _GatewayRule;
687
708
  let GatewayRule = class GatewayRule extends DiagnoseRule {
@@ -1410,7 +1431,32 @@ function moveSafe(src, dst) {
1410
1431
  node_fs.default.renameSync(src, dst);
1411
1432
  } catch (e) {
1412
1433
  if (e?.code !== "EXDEV") throw e;
1413
- (0, node_child_process.execSync)(`mv ${shellQuote(src)} ${shellQuote(dst)}`, { stdio: "ignore" });
1434
+ execCaptureErr(`mv ${shellQuote(src)} ${shellQuote(dst)}`);
1435
+ }
1436
+ }
1437
+ /**
1438
+ * Run a shell command, re-throwing with stderr attached on failure.
1439
+ *
1440
+ * Node's `execSync(..., { stdio: 'ignore' })` swallows stderr entirely —
1441
+ * callers only see "Command failed: <cmd>" with no hint of the real error
1442
+ * (ENOSPC, EROFS, "unrecognized option", etc.). Production debugging on
1443
+ * sandboxed boxes is painful without the underlying message, so we pipe
1444
+ * stderr, capture it, and embed it in the thrown Error. stdout stays
1445
+ * suppressed because the commands we run here (tar/mv) are silent on
1446
+ * success.
1447
+ */
1448
+ function execCaptureErr(cmd) {
1449
+ try {
1450
+ (0, node_child_process.execSync)(cmd, { stdio: [
1451
+ "ignore",
1452
+ "ignore",
1453
+ "pipe"
1454
+ ] });
1455
+ } catch (e) {
1456
+ const stderr = e?.stderr;
1457
+ const stderrStr = (typeof stderr === "string" ? stderr : stderr?.toString("utf8") ?? "").trim();
1458
+ const base = e?.message ?? "command failed";
1459
+ throw new Error(stderrStr ? `${base}\nstderr: ${stderrStr}` : base);
1414
1460
  }
1415
1461
  }
1416
1462
  /** POSIX single-quote shell escape. Paths with embedded quotes are rare but
@@ -1536,29 +1582,48 @@ async function installOpenclaw(openclawTag, ossFileMap, opts = {}) {
1536
1582
  if (!pkg) throw new Error("install-openclaw: role=cli,name=openclaw not found in manifest");
1537
1583
  const targetDir = opts.targetDir ?? node_path.default.join(homeBase, pkg.installPath);
1538
1584
  const bakDir = targetDir + ".bak";
1585
+ const stagingDir = targetDir + ".new";
1539
1586
  const tarball = await downloadWithCache(pkg, ossFileMap, opts);
1540
1587
  console.error(`[install-openclaw] tag=${openclawTag} shasum=${pkg.shasum.slice(0, 12)}...`);
1588
+ if (node_fs.default.existsSync(stagingDir)) node_fs.default.rmSync(stagingDir, {
1589
+ recursive: true,
1590
+ force: true
1591
+ });
1541
1592
  if (node_fs.default.existsSync(bakDir)) node_fs.default.rmSync(bakDir, {
1542
1593
  recursive: true,
1543
1594
  force: true
1544
1595
  });
1596
+ node_fs.default.mkdirSync(node_path.default.dirname(targetDir), { recursive: true });
1597
+ node_fs.default.mkdirSync(stagingDir);
1598
+ try {
1599
+ execCaptureErr(`tar -xzf '${tarball}' -C '${stagingDir}' --strip-components=1`);
1600
+ if (!node_fs.default.existsSync(node_path.default.join(stagingDir, "package.json"))) throw new Error("extracted tarball missing package.json");
1601
+ } catch (e) {
1602
+ try {
1603
+ node_fs.default.rmSync(stagingDir, {
1604
+ recursive: true,
1605
+ force: true
1606
+ });
1607
+ } catch {}
1608
+ throw e;
1609
+ }
1545
1610
  const hadExisting = node_fs.default.existsSync(targetDir);
1546
- if (hadExisting) moveSafe(targetDir, bakDir);
1547
1611
  try {
1548
- node_fs.default.mkdirSync(targetDir, { recursive: true });
1549
- (0, node_child_process.execSync)(`tar -xzf '${tarball}' -C '${targetDir}' --strip-components=1`, { stdio: "ignore" });
1550
- if (!node_fs.default.existsSync(node_path.default.join(targetDir, "package.json"))) throw new Error("extracted tarball missing package.json");
1612
+ if (hadExisting) moveSafe(targetDir, bakDir);
1613
+ moveSafe(stagingDir, targetDir);
1551
1614
  } catch (e) {
1615
+ if (hadExisting && !node_fs.default.existsSync(targetDir) && node_fs.default.existsSync(bakDir)) try {
1616
+ moveSafe(bakDir, targetDir);
1617
+ } catch {}
1552
1618
  try {
1553
- node_fs.default.rmSync(targetDir, {
1619
+ node_fs.default.rmSync(stagingDir, {
1554
1620
  recursive: true,
1555
1621
  force: true
1556
1622
  });
1557
1623
  } catch {}
1558
- if (hadExisting && node_fs.default.existsSync(bakDir)) moveSafe(bakDir, targetDir);
1559
1624
  throw e;
1560
1625
  }
1561
- if (node_fs.default.existsSync(bakDir)) node_fs.default.rmSync(bakDir, {
1626
+ if (hadExisting && node_fs.default.existsSync(bakDir)) node_fs.default.rmSync(bakDir, {
1562
1627
  recursive: true,
1563
1628
  force: true
1564
1629
  });
@@ -1644,7 +1709,7 @@ function installOne(pkg, tarball, homeBase) {
1644
1709
  });
1645
1710
  node_fs.default.mkdirSync(stagingDir);
1646
1711
  try {
1647
- (0, node_child_process.execSync)(`tar -xzf '${tarball}' -C '${stagingDir}' --strip-components=1`, { stdio: "ignore" });
1712
+ execCaptureErr(`tar -xzf '${tarball}' -C '${stagingDir}' --strip-components=1`);
1648
1713
  if (!node_fs.default.existsSync(node_path.default.join(stagingDir, "package.json"))) throw new Error(`extension tarball missing package.json: ${pkg.name}`);
1649
1714
  } catch (e) {
1650
1715
  try {
@@ -1682,7 +1747,7 @@ async function downloadResource(tag, ossFileMap, opts) {
1682
1747
  const format = (pkg.format ?? "").toLowerCase();
1683
1748
  const lower = pkg.ossKey.toLowerCase();
1684
1749
  if (format === "tgz" || lower.endsWith(".tgz") || lower.endsWith(".tar.gz")) {
1685
- (0, node_child_process.execSync)(`tar -xzf '${file}' -C '${extractDir}'`, { stdio: "ignore" });
1750
+ execCaptureErr(`tar -xzf '${file}' -C '${extractDir}'`);
1686
1751
  console.error(`[download-resource] ${opts.role}/${opts.name}: extracted to ${extractDir}`);
1687
1752
  } else {
1688
1753
  const basename = node_path.default.posix.basename(pkg.ossKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/openclaw-scripts-diagnose-cli",
3
- "version": "0.1.1-alpha.26",
3
+ "version": "0.1.1-alpha.28",
4
4
  "description": "CLI for OpenClaw config diagnose and repair with JSON5 support",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {