mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 01:51:35 +00:00
perf(cli): reduce read-only startup overhead
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
rewriteUpdateFlagArgv,
|
||||
shouldEnsureCliPath,
|
||||
shouldRegisterPrimarySubcommand,
|
||||
shouldSkipPluginCommandRegistration,
|
||||
} from "./run-main.js";
|
||||
@@ -71,6 +72,16 @@ describe("shouldSkipPluginCommandRegistration", () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("skips plugin registration for builtin command runs", () => {
|
||||
expect(
|
||||
shouldSkipPluginCommandRegistration({
|
||||
argv: ["node", "openclaw", "sessions", "--json"],
|
||||
primary: "sessions",
|
||||
hasBuiltinPrimary: true,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps plugin registration for non-builtin help", () => {
|
||||
expect(
|
||||
shouldSkipPluginCommandRegistration({
|
||||
@@ -80,4 +91,33 @@ describe("shouldSkipPluginCommandRegistration", () => {
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps plugin registration for non-builtin command runs", () => {
|
||||
expect(
|
||||
shouldSkipPluginCommandRegistration({
|
||||
argv: ["node", "openclaw", "voicecall", "status"],
|
||||
primary: "voicecall",
|
||||
hasBuiltinPrimary: false,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldEnsureCliPath", () => {
|
||||
it("skips path bootstrap for help/version invocations", () => {
|
||||
expect(shouldEnsureCliPath(["node", "openclaw", "--help"])).toBe(false);
|
||||
expect(shouldEnsureCliPath(["node", "openclaw", "-V"])).toBe(false);
|
||||
});
|
||||
|
||||
it("skips path bootstrap for read-only fast paths", () => {
|
||||
expect(shouldEnsureCliPath(["node", "openclaw", "status"])).toBe(false);
|
||||
expect(shouldEnsureCliPath(["node", "openclaw", "sessions", "--json"])).toBe(false);
|
||||
expect(shouldEnsureCliPath(["node", "openclaw", "config", "get", "update"])).toBe(false);
|
||||
expect(shouldEnsureCliPath(["node", "openclaw", "models", "status", "--json"])).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps path bootstrap for mutating or unknown commands", () => {
|
||||
expect(shouldEnsureCliPath(["node", "openclaw", "message", "send"])).toBe(true);
|
||||
expect(shouldEnsureCliPath(["node", "openclaw", "voicecall", "status"])).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user