fix(cli): keep status usage on fast path

This commit is contained in:
Peter Steinberger
2026-04-29 13:20:40 +01:00
parent 4e4f9204d7
commit cf43b92fc9
11 changed files with 143 additions and 15 deletions

View File

@@ -14,6 +14,8 @@ import {
resolveCliNetworkProxyPolicy,
} from "./command-path-policy.js";
const ROOT_HELP_ALIASES = new Set(["tools"]);
export function rewriteUpdateFlagArgv(argv: string[]): string[] {
const index = argv.indexOf("--update");
if (index === -1) {
@@ -41,6 +43,9 @@ export function shouldUseRootHelpFastPath(
return (
env.OPENCLAW_DISABLE_CLI_STARTUP_HELP_FAST_PATH !== "1" &&
(invocation.isRootHelpInvocation ||
(invocation.commandPath.length === 1 &&
ROOT_HELP_ALIASES.has(invocation.commandPath[0] ?? "") &&
invocation.hasHelpOrVersion) ||
(invocation.commandPath.length === 1 &&
invocation.commandPath[0] === "help" &&
invocation.hasHelpOrVersion))

View File

@@ -156,6 +156,7 @@ describe("shouldUseRootHelpFastPath", () => {
expect(shouldUseRootHelpFastPath(["node", "openclaw", "--help"])).toBe(true);
expect(shouldUseRootHelpFastPath(["node", "openclaw", "--profile", "work", "-h"])).toBe(true);
expect(shouldUseRootHelpFastPath(["node", "openclaw", "help", "--help"])).toBe(true);
expect(shouldUseRootHelpFastPath(["node", "openclaw", "tools", "--help"])).toBe(true);
expect(shouldUseRootHelpFastPath(["node", "openclaw", "status", "--help"])).toBe(false);
expect(shouldUseRootHelpFastPath(["node", "openclaw", "--help", "status"])).toBe(false);
expect(shouldUseRootHelpFastPath(["node", "openclaw", "help", "gateway"])).toBe(false);