fix: reserve auth CLI root from plugin allowlist gating

This commit is contained in:
Peter Steinberger
2026-05-02 23:07:08 +01:00
parent 2a7d6f6f13
commit 7f83ba8ddf
5 changed files with 18 additions and 7 deletions

View File

@@ -50,6 +50,13 @@ describe("command-registration-policy", () => {
hasBuiltinPrimary: false,
}),
).toBe(false);
expect(
shouldSkipPluginCommandRegistration({
argv: ["node", "openclaw", "auth", "login"],
primary: "auth",
hasBuiltinPrimary: false,
}),
).toBe(true);
expect(
shouldSkipPluginCommandRegistration({
argv: ["node", "openclaw", "tool", "image_generate"],

View File

@@ -1,7 +1,7 @@
import { isTruthyEnvValue } from "../infra/env.js";
import { resolveCliArgvInvocation } from "./argv-invocation.js";
const RESERVED_NON_PLUGIN_COMMAND_ROOTS = new Set(["tool", "tools"]);
const RESERVED_NON_PLUGIN_COMMAND_ROOTS = new Set(["auth", "tool", "tools"]);
export function isReservedNonPluginCommandRoot(primary: string | null | undefined): boolean {
return typeof primary === "string" && RESERVED_NON_PLUGIN_COMMAND_ROOTS.has(primary);

View File

@@ -400,6 +400,7 @@ describe("runCli exit behavior", () => {
});
it.each([
["auth", ["node", "openclaw", "auth", "--help"]],
["tool", ["node", "openclaw", "tool", "image_generate"]],
["tools", ["node", "openclaw", "tools", "effective"]],
])("keeps reserved %s command roots out of plugin command discovery", async (_name, argv) => {

View File

@@ -214,12 +214,14 @@ describe("resolveMissingPluginCommandMessage", () => {
});
it("does not classify reserved non-plugin command roots as plugin allowlist misses", () => {
const message = resolveMissingPluginCommandMessage("tool", {
plugins: {
allow: ["browser"],
},
});
expect(message).toBeNull();
for (const root of ["auth", "tool"]) {
const message = resolveMissingPluginCommandMessage(root, {
plugins: {
allow: ["browser"],
},
});
expect(message).toBeNull();
}
});
it("explains that dreaming is a runtime slash command, not a CLI command", () => {