refactor: centralize plugin install config policy

This commit is contained in:
Peter Steinberger
2026-03-23 23:05:19 -07:00
parent c3744fbfc4
commit fd0fa97952
9 changed files with 502 additions and 59 deletions

View File

@@ -129,6 +129,12 @@ describe("registerPreActionHooks", () => {
program.command("onboard").action(() => {});
const channels = program.command("channels");
channels.command("add").action(() => {});
program
.command("plugins")
.command("install")
.argument("<spec>")
.option("--marketplace <marketplace>")
.action(() => {});
program
.command("update")
.command("status")
@@ -229,6 +235,61 @@ describe("registerPreActionHooks", () => {
expect(ensurePluginRegistryLoadedMock).not.toHaveBeenCalled();
});
it("only allows invalid config for explicit Matrix reinstall requests", async () => {
await runPreAction({
parseArgv: ["plugins", "install", "@openclaw/matrix"],
processArgv: ["node", "openclaw", "plugins", "install", "@openclaw/matrix"],
});
expect(ensureConfigReadyMock).toHaveBeenCalledWith({
runtime: runtimeMock,
commandPath: ["plugins", "install"],
allowInvalid: true,
});
vi.clearAllMocks();
await runPreAction({
parseArgv: ["plugins", "install", "alpha"],
processArgv: ["node", "openclaw", "plugins", "install", "alpha"],
});
expect(ensureConfigReadyMock).toHaveBeenCalledWith({
runtime: runtimeMock,
commandPath: ["plugins", "install"],
});
vi.clearAllMocks();
await runPreAction({
parseArgv: ["plugins", "install", "./extensions/matrix"],
processArgv: ["node", "openclaw", "plugins", "install", "./extensions/matrix"],
});
expect(ensureConfigReadyMock).toHaveBeenCalledWith({
runtime: runtimeMock,
commandPath: ["plugins", "install"],
allowInvalid: true,
});
vi.clearAllMocks();
await runPreAction({
parseArgv: ["plugins", "install", "@openclaw/matrix", "--marketplace", "local/repo"],
processArgv: [
"node",
"openclaw",
"plugins",
"install",
"@openclaw/matrix",
"--marketplace",
"local/repo",
],
});
expect(ensureConfigReadyMock).toHaveBeenCalledWith({
runtime: runtimeMock,
commandPath: ["plugins", "install"],
});
});
it("skips help/version preaction and respects banner opt-out", async () => {
await runPreAction({
parseArgv: ["status"],