fix(cli): skip plugin preload for json agent runs

This commit is contained in:
Peter Steinberger
2026-04-29 01:17:33 +01:00
parent 3286e99bc2
commit 45f3074ee6
3 changed files with 33 additions and 6 deletions

View File

@@ -145,6 +145,10 @@ describe("registerPreActionHooks", () => {
program.command("onboard").action(() => {});
const channels = program.command("channels");
channels.command("add").action(() => {});
channels
.command("send")
.option("--json")
.action(() => {});
program
.command("plugins")
.command("install")
@@ -229,7 +233,7 @@ describe("registerPreActionHooks", () => {
processTitleSetSpy.mockRestore();
});
it("loads plugins for local agent runs", async () => {
it("loads plugins for text local agent runs", async () => {
await runPreAction({
parseArgv: ["agent"],
processArgv: ["node", "openclaw", "agent", "--local", "--message", "hi"],
@@ -242,6 +246,20 @@ describe("registerPreActionHooks", () => {
expect(ensurePluginRegistryLoadedMock).toHaveBeenCalledWith({ scope: "all" });
});
it("skips broad plugin preload for json local agent runs", async () => {
await runPreAction({
parseArgv: ["agent"],
processArgv: ["node", "openclaw", "agent", "--local", "--message", "hi", "--json"],
});
expect(ensureConfigReadyMock).toHaveBeenCalledWith({
runtime: runtimeMock,
commandPath: ["agent", "hi"],
suppressDoctorStdout: true,
});
expect(ensurePluginRegistryLoadedMock).not.toHaveBeenCalled();
});
it("keeps setup alias and channels add manifest-first", async () => {
await runPreAction({
parseArgv: ["onboard"],
@@ -394,8 +412,8 @@ describe("registerPreActionHooks", () => {
it("routes logs to stderr in --json mode so stdout stays clean", async () => {
await runPreAction({
parseArgv: ["agent"],
processArgv: ["node", "openclaw", "agent", "--message", "hi", "--json"],
parseArgv: ["channels", "send"],
processArgv: ["node", "openclaw", "channels", "send", "--json"],
});
expect(routeLogsToStderrMock).toHaveBeenCalledOnce();
@@ -484,8 +502,8 @@ describe("registerPreActionHooks", () => {
});
await runPreAction({
parseArgv: ["agent"],
processArgv: ["node", "openclaw", "agent", "--local", "--message", "hi", "--json"],
parseArgv: ["channels", "send"],
processArgv: ["node", "openclaw", "channels", "send", "--json"],
});
expect(ensurePluginRegistryLoadedMock).toHaveBeenCalled();