mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-06 06:41:08 +00:00
refactor(plugins): separate activation from enablement (#59844)
* refactor(plugins): separate activation from enablement * fix(cli): sanitize verbose plugin activation reasons
This commit is contained in:
@@ -69,6 +69,28 @@ describe("plugins cli list", () => {
|
||||
expect(output).toContain("explicitly enabled: no");
|
||||
});
|
||||
|
||||
it("sanitizes activation reasons in verbose output", async () => {
|
||||
buildPluginSnapshotReport.mockReturnValue({
|
||||
plugins: [
|
||||
createPluginRecord({
|
||||
id: "demo",
|
||||
name: "Demo Plugin",
|
||||
activated: true,
|
||||
activationSource: "auto",
|
||||
activationReason: "\u001B[31mconfigured\nnext\tstep",
|
||||
}),
|
||||
],
|
||||
diagnostics: [],
|
||||
});
|
||||
|
||||
await runPluginsCommand(["plugins", "list", "--verbose"]);
|
||||
|
||||
const output = runtimeLogs.join("\n");
|
||||
expect(output).toContain("activation reason: configured\\nnext\\tstep");
|
||||
expect(output).not.toContain("\u001B[31m");
|
||||
expect(output.match(/activation reason:/g)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("keeps doctor on a module-loading snapshot", async () => {
|
||||
buildPluginDiagnosticsReport.mockReturnValue({
|
||||
plugins: [],
|
||||
|
||||
@@ -156,6 +156,13 @@ function formatPluginLine(plugin: PluginRecord, verbose = false): string {
|
||||
if (plugin.providerIds.length > 0) {
|
||||
parts.push(` providers: ${plugin.providerIds.join(", ")}`);
|
||||
}
|
||||
if (plugin.activated !== undefined || plugin.activationSource || plugin.activationReason) {
|
||||
const activationSummary =
|
||||
plugin.activated === false
|
||||
? "inactive"
|
||||
: (plugin.activationSource ?? (plugin.activated ? "active" : "inactive"));
|
||||
parts.push(` activation: ${activationSummary}`);
|
||||
}
|
||||
if (plugin.error) {
|
||||
parts.push(theme.error(` error: ${plugin.error}`));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user