mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-25 08:02:04 +00:00
perf(status): defer heavy startup loading
This commit is contained in:
@@ -71,6 +71,16 @@ function resolvePluginRegistryScope(commandPath: string[]): "channels" | "all" {
|
||||
return commandPath[0] === "status" || commandPath[0] === "health" ? "channels" : "all";
|
||||
}
|
||||
|
||||
function shouldLoadPluginsForCommand(commandPath: string[], argv: string[]): boolean {
|
||||
if (!PLUGIN_REQUIRED_COMMANDS.has(commandPath[0])) {
|
||||
return false;
|
||||
}
|
||||
if ((commandPath[0] === "status" || commandPath[0] === "health") && hasFlag(argv, "--json")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function getRootCommand(command: Command): Command {
|
||||
let current = command;
|
||||
while (current.parent) {
|
||||
@@ -138,7 +148,7 @@ export function registerPreActionHooks(program: Command, programVersion: string)
|
||||
...(suppressDoctorStdout ? { suppressDoctorStdout: true } : {}),
|
||||
});
|
||||
// Load plugins for commands that need channel access
|
||||
if (PLUGIN_REQUIRED_COMMANDS.has(commandPath[0])) {
|
||||
if (shouldLoadPluginsForCommand(commandPath, argv)) {
|
||||
const { ensurePluginRegistryLoaded } = await loadPluginRegistryModule();
|
||||
ensurePluginRegistryLoaded({ scope: resolvePluginRegistryScope(commandPath) });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user