fix(cli): load plugin registry for message/channels commands
Fixes #1327 - 'clawdbot message --channel telegram' fails with 'Unknown channel: telegram' because plugins weren't loaded. The Commander code path (non-route-first) calls ensureConfigReady() in preAction but doesn't load the plugin registry. Channel plugins like telegram are registered during plugin loading, so getChannelPlugin() returns undefined without it. This adds ensurePluginRegistryLoaded() call for commands that need channel plugin access: message, channels, directory.
This commit is contained in:
@@ -3,6 +3,7 @@ import { defaultRuntime } from "../../runtime.js";
|
|||||||
import { emitCliBanner } from "../banner.js";
|
import { emitCliBanner } from "../banner.js";
|
||||||
import { getCommandPath, hasHelpOrVersion } from "../argv.js";
|
import { getCommandPath, hasHelpOrVersion } from "../argv.js";
|
||||||
import { ensureConfigReady } from "./config-guard.js";
|
import { ensureConfigReady } from "./config-guard.js";
|
||||||
|
import { ensurePluginRegistryLoaded } from "../plugin-registry.js";
|
||||||
|
|
||||||
function setProcessTitleForCommand(actionCommand: Command) {
|
function setProcessTitleForCommand(actionCommand: Command) {
|
||||||
let current: Command = actionCommand;
|
let current: Command = actionCommand;
|
||||||
@@ -14,6 +15,9 @@ function setProcessTitleForCommand(actionCommand: Command) {
|
|||||||
process.title = `clawdbot-${name}`;
|
process.title = `clawdbot-${name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Commands that need channel plugins loaded
|
||||||
|
const PLUGIN_REQUIRED_COMMANDS = new Set(["message", "channels", "directory"]);
|
||||||
|
|
||||||
export function registerPreActionHooks(program: Command, programVersion: string) {
|
export function registerPreActionHooks(program: Command, programVersion: string) {
|
||||||
program.hook("preAction", async (_thisCommand, actionCommand) => {
|
program.hook("preAction", async (_thisCommand, actionCommand) => {
|
||||||
setProcessTitleForCommand(actionCommand);
|
setProcessTitleForCommand(actionCommand);
|
||||||
@@ -23,5 +27,9 @@ export function registerPreActionHooks(program: Command, programVersion: string)
|
|||||||
const commandPath = getCommandPath(argv, 2);
|
const commandPath = getCommandPath(argv, 2);
|
||||||
if (commandPath[0] === "doctor") return;
|
if (commandPath[0] === "doctor") return;
|
||||||
await ensureConfigReady({ runtime: defaultRuntime, commandPath });
|
await ensureConfigReady({ runtime: defaultRuntime, commandPath });
|
||||||
|
// Load plugins for commands that need channel access
|
||||||
|
if (PLUGIN_REQUIRED_COMMANDS.has(commandPath[0])) {
|
||||||
|
ensurePluginRegistryLoaded();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user