From f9e9d4e357ef978b0f2caf94c579e633c5a5dd69 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 4 Apr 2026 08:59:23 +0100 Subject: [PATCH] fix(cli): preload plugins for local agent runs --- src/cli/program/preaction.test.ts | 18 ++++++++++++++++++ src/cli/program/preaction.ts | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/cli/program/preaction.test.ts b/src/cli/program/preaction.test.ts index 1a26ae8693a..aef0353c700 100644 --- a/src/cli/program/preaction.test.ts +++ b/src/cli/program/preaction.test.ts @@ -118,6 +118,11 @@ describe("registerPreActionHooks", () => { function buildProgram() { const program = new Command().name("openclaw"); + program + .command("agent") + .requiredOption("-m, --message ") + .option("--local") + .action(() => {}); program .command("status") .option("--json") @@ -223,6 +228,19 @@ describe("registerPreActionHooks", () => { processTitleSetSpy.mockRestore(); }); + it("loads plugins for local agent runs", async () => { + await runPreAction({ + parseArgv: ["agent"], + processArgv: ["node", "openclaw", "agent", "--local", "--message", "hi"], + }); + + expect(ensureConfigReadyMock).toHaveBeenCalledWith({ + runtime: runtimeMock, + commandPath: ["agent"], + }); + expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledWith({ scope: "all" }); + }); + it("keeps setup alias and channels add manifest-first", async () => { await runPreAction({ parseArgv: ["onboard"], diff --git a/src/cli/program/preaction.ts b/src/cli/program/preaction.ts index 462b684a878..8a6c7781195 100644 --- a/src/cli/program/preaction.ts +++ b/src/cli/program/preaction.ts @@ -27,8 +27,9 @@ function setProcessTitleForCommand(actionCommand: Command) { process.title = `${cliName}-${name}`; } -// Commands that need channel plugins loaded +// Commands that need plugins loaded before execution. const PLUGIN_REQUIRED_COMMANDS = new Set([ + "agent", "message", "channels", "directory",