Entry: fast-path root version command

This commit is contained in:
Vincent Koc 2026-03-01 12:06:27 -08:00
parent 86a91cc01a
commit 153adc4c8f
1 changed files with 23 additions and 0 deletions

View File

@ -2,6 +2,7 @@
import { spawn } from "node:child_process";
import process from "node:process";
import { fileURLToPath } from "node:url";
import { isRootVersionInvocation } from "./cli/argv.js";
import { applyCliProfileEnv, parseCliProfileArgs } from "./cli/profile.js";
import { shouldSkipRespawnForArgv } from "./cli/respawn-policy.js";
import { normalizeWindowsArgv } from "./cli/windows-argv.js";
@ -114,6 +115,24 @@ if (
return true;
}
function tryHandleRootVersionFastPath(argv: string[]): boolean {
if (!isRootVersionInvocation(argv)) {
return false;
}
import("./version.js")
.then(({ VERSION }) => {
console.log(VERSION);
})
.catch((error) => {
console.error(
"[openclaw] Failed to resolve version:",
error instanceof Error ? (error.stack ?? error.message) : error,
);
process.exitCode = 1;
});
return true;
}
process.argv = normalizeWindowsArgv(process.argv);
if (!ensureExperimentalWarningSuppressed()) {
@ -130,6 +149,10 @@ if (
process.argv = parsed.argv;
}
if (tryHandleRootVersionFastPath(process.argv)) {
return;
}
import("./cli/run-main.js")
.then(({ runCli }) => runCli(process.argv))
.catch((error) => {