fix(cli): preload plugins for local agent runs

This commit is contained in:
Peter Steinberger
2026-04-04 08:59:23 +01:00
parent 12be79ac48
commit f9e9d4e357
2 changed files with 20 additions and 1 deletions

View File

@@ -118,6 +118,11 @@ describe("registerPreActionHooks", () => {
function buildProgram() {
const program = new Command().name("openclaw");
program
.command("agent")
.requiredOption("-m, --message <text>")
.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"],

View File

@@ -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",