
























@@ -47,8 +47,25 @@ const { registerPluginsCli, registerPluginCliCommandsFromValidatedConfig } = vi.
4747}),
4848registerPluginCliCommandsFromValidatedConfig: vi.fn(async () => null),
4949}));
50+const { addGatewayRunCommand, gatewayRunAction, registerGatewayCli } = vi.hoisted(() => {
51+const runAction = vi.fn();
52+return {
53+addGatewayRunCommand: vi.fn((command: Command) =>
54+command.option("--force", "force", false).action(runAction),
55+),
56+gatewayRunAction: runAction,
57+registerGatewayCli: vi.fn((program: Command) => {
58+program
59+.command("gateway")
60+.command("call")
61+.action(() => undefined);
62+}),
63+};
64+});
50655166vi.mock("../acp-cli.js", () => ({ registerAcpCli }));
67+vi.mock("../gateway-cli.js", () => ({ registerGatewayCli }));
68+vi.mock("../gateway-cli/run.js", () => ({ addGatewayRunCommand }));
5269vi.mock("../nodes-cli.js", () => ({ registerNodesCli }));
5370vi.mock("../capability-cli.js", () => ({ registerCapabilityCli }));
5471vi.mock("../plugins-cli.js", () => ({ registerPluginsCli }));
@@ -93,6 +110,9 @@ describe("registerSubCliCommands", () => {
93110inferAction.mockClear();
94111registerPluginsCli.mockClear();
95112registerPluginCliCommandsFromValidatedConfig.mockClear();
113+addGatewayRunCommand.mockClear();
114+gatewayRunAction.mockClear();
115+registerGatewayCli.mockClear();
96116});
9711798118afterEach(() => {
@@ -174,6 +194,30 @@ describe("registerSubCliCommands", () => {
174194expect(acpAction).toHaveBeenCalledTimes(1);
175195});
176196197+it("registers only the gateway run surface for gateway startup", async () => {
198+const argv = ["node", "openclaw", "gateway", "--force"];
199+process.argv = argv;
200+const program = new Command().name("openclaw");
201+202+await registerSubCliByName(program, "gateway", argv);
203+204+expect(addGatewayRunCommand).toHaveBeenCalledTimes(2);
205+expect(registerGatewayCli).not.toHaveBeenCalled();
206+await program.parseAsync(["gateway", "--force"], { from: "user" });
207+expect(gatewayRunAction).toHaveBeenCalledTimes(1);
208+});
209+210+it("keeps the full gateway CLI for non-run gateway subcommands", async () => {
211+const argv = ["node", "openclaw", "gateway", "call", "health"];
212+process.argv = argv;
213+const program = new Command().name("openclaw");
214+215+await registerSubCliByName(program, "gateway", argv);
216+217+expect(addGatewayRunCommand).not.toHaveBeenCalled();
218+expect(registerGatewayCli).toHaveBeenCalledTimes(1);
219+});
220+177221it.each([
178222["plugins update", ["plugins", "update", "lossless-claw"]],
179223["plugins update --all", ["plugins", "update", "--all"]],
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。