From e895e85f5488f85e007940b46829d779b04b29f7 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 3 Feb 2026 17:31:51 -0800 Subject: [PATCH] fix: improve build-info resolution for commit/version --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/infra/git-commit.ts | 19 +++++++++++++++---- src/version.ts | 14 ++++++++++++-- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa648116eb..11638619e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ Docs: https://docs.openclaw.ai +## 2026.2.2-2 + +### Fixes + +- CLI status: resolve build-info from bundled dist output (fixes "unknown" commit in npm builds). + ## 2026.2.2-1 ### Fixes diff --git a/package.json b/package.json index 0a84aec7c3..9904b1954b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openclaw", - "version": "2026.2.2-1", + "version": "2026.2.2-2", "description": "WhatsApp gateway CLI (Baileys web) with Pi RPC agent", "keywords": [], "license": "MIT", diff --git a/src/infra/git-commit.ts b/src/infra/git-commit.ts index 996f8dad1f..e2b1d07f9d 100644 --- a/src/infra/git-commit.ts +++ b/src/infra/git-commit.ts @@ -60,10 +60,21 @@ const readCommitFromPackageJson = () => { const readCommitFromBuildInfo = () => { try { const require = createRequire(import.meta.url); - const info = require("../build-info.json") as { - commit?: string | null; - }; - return formatCommit(info.commit ?? null); + const candidates = ["../build-info.json", "./build-info.json"]; + for (const candidate of candidates) { + try { + const info = require(candidate) as { + commit?: string | null; + }; + const formatted = formatCommit(info.commit ?? null); + if (formatted) { + return formatted; + } + } catch { + // ignore missing candidate + } + } + return null; } catch { return null; } diff --git a/src/version.ts b/src/version.ts index e6062633ca..04bb502042 100644 --- a/src/version.ts +++ b/src/version.ts @@ -15,8 +15,18 @@ function readVersionFromPackageJson(): string | null { function readVersionFromBuildInfo(): string | null { try { const require = createRequire(import.meta.url); - const info = require("../build-info.json") as { version?: string }; - return info.version ?? null; + const candidates = ["../build-info.json", "./build-info.json"]; + for (const candidate of candidates) { + try { + const info = require(candidate) as { version?: string }; + if (info.version) { + return info.version; + } + } catch { + // ignore missing candidate + } + } + return null; } catch { return null; }