@aliyunrds/ctxdb 0.0.8-beta.5 → 0.0.8

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/main.js +19 -6
  2. package/package.json +1 -1
package/dist/cli/main.js CHANGED
@@ -1489,12 +1489,18 @@ import { fileURLToPath as fileURLToPath2 } from "url";
1489
1489
  import { dirname as dirname2 } from "path";
1490
1490
  var PACKAGE_NAME = "@aliyunrds/ctxdb";
1491
1491
  var NPM_VIEW_TIMEOUT_MS = 1e4;
1492
+ function npmCommand(platform = process.platform) {
1493
+ return platform === "win32" ? "npm.cmd" : "npm";
1494
+ }
1495
+ function ctxdbCommand(platform = process.platform) {
1496
+ return platform === "win32" ? "ctxdb.cmd" : "ctxdb";
1497
+ }
1492
1498
  function detectInstallMethod() {
1493
1499
  const dir = dirname2(fileURLToPath2(import.meta.url));
1494
1500
  return dir.includes("/node_modules/") || dir.includes("\\node_modules\\") ? "npm" : "unknown";
1495
1501
  }
1496
1502
  function checkLatestVersion(currentVersion) {
1497
- const result = spawnSync("npm", ["view", PACKAGE_NAME, "version"], {
1503
+ const result = spawnSync(npmCommand(), ["view", PACKAGE_NAME, "version"], {
1498
1504
  encoding: "utf-8",
1499
1505
  timeout: NPM_VIEW_TIMEOUT_MS,
1500
1506
  stdio: ["ignore", "pipe", "pipe"]
@@ -1504,7 +1510,7 @@ function checkLatestVersion(currentVersion) {
1504
1510
  latest: null,
1505
1511
  current: currentVersion,
1506
1512
  isNewer: false,
1507
- error: result.stderr?.trim() || `npm view exited with code ${result.status}`
1513
+ error: spawnFailureMessage(result, "npm view")
1508
1514
  };
1509
1515
  }
1510
1516
  const latest = result.stdout.trim();
@@ -1514,6 +1520,13 @@ function checkLatestVersion(currentVersion) {
1514
1520
  isNewer: isNewerVersion(latest, currentVersion)
1515
1521
  };
1516
1522
  }
1523
+ function spawnFailureMessage(result, commandLabel) {
1524
+ const stderr = result.stderr?.toString().trim();
1525
+ if (stderr) return stderr;
1526
+ if (result.error) return `${commandLabel} failed: ${result.error.message}`;
1527
+ if (result.signal) return `${commandLabel} terminated by signal ${result.signal}`;
1528
+ return `${commandLabel} exited with code ${result.status}`;
1529
+ }
1517
1530
  function isNewerVersion(candidate, current) {
1518
1531
  const parse = (v) => v.replace(/^v/, "").split(".").map(Number);
1519
1532
  const [cMaj = 0, cMin = 0, cPat = 0] = parse(candidate);
@@ -1545,7 +1558,7 @@ function runSelfUpdate(currentVersion, passthroughArgs = []) {
1545
1558
  }
1546
1559
  process.stderr.write(`ctxdb: updating ${PACKAGE_NAME} v${currentVersion} \u2192 v${check.latest}...
1547
1560
  `);
1548
- const install = spawnSync("npm", ["install", "-g", `${PACKAGE_NAME}@${check.latest}`], {
1561
+ const install = spawnSync(npmCommand(), ["install", "-g", `${PACKAGE_NAME}@${check.latest}`], {
1549
1562
  stdio: "inherit",
1550
1563
  encoding: "utf-8"
1551
1564
  });
@@ -1554,13 +1567,13 @@ function runSelfUpdate(currentVersion, passthroughArgs = []) {
1554
1567
  ok: false,
1555
1568
  updated: false,
1556
1569
  fromVersion: currentVersion,
1557
- error: `npm install -g failed with exit code ${install.status}`
1570
+ error: spawnFailureMessage(install, "npm install -g")
1558
1571
  };
1559
1572
  }
1560
1573
  process.stderr.write(`ctxdb: package updated to v${check.latest}, refreshing skills/hooks...
1561
1574
  `);
1562
1575
  const upgradeArgs = ["upgrade", ...passthroughArgs];
1563
- const refresh = spawnSync("ctxdb", upgradeArgs, {
1576
+ const refresh = spawnSync(ctxdbCommand(), upgradeArgs, {
1564
1577
  stdio: "inherit",
1565
1578
  encoding: "utf-8"
1566
1579
  });
@@ -1569,7 +1582,7 @@ function runSelfUpdate(currentVersion, passthroughArgs = []) {
1569
1582
  updated: true,
1570
1583
  fromVersion: currentVersion,
1571
1584
  toVersion: check.latest,
1572
- error: refresh.status !== 0 ? `ctxdb upgrade exited with code ${refresh.status}` : void 0
1585
+ error: refresh.status !== 0 ? spawnFailureMessage(refresh, "ctxdb upgrade") : void 0
1573
1586
  };
1574
1587
  }
1575
1588
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliyunrds/ctxdb",
3
- "version": "0.0.8-beta.5",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "description": "Unified access layer for RDS ContextDatabase: `ctxdb` CLI (memory + KB ops), one-shot `setup --agent <qoder|codex|claude>` installer, per-agent config, hooks, and SKILL.md.",
6
6
  "license": "Apache-2.0",