mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-10 16:51:13 +00:00
CLI: keep root help plugin descriptors non-activating (#57294)
Merged via squash.
Prepared head SHA: c8da48f689
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
committed by
GitHub
parent
1efef8205c
commit
e5dac0c39e
@@ -6,7 +6,11 @@ import type { OpenClawConfig } from "../config/config.js";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { loadOpenClawPlugins, type PluginLoadOptions } from "./loader.js";
|
||||
import {
|
||||
loadOpenClawPluginCliRegistry,
|
||||
loadOpenClawPlugins,
|
||||
type PluginLoadOptions,
|
||||
} from "./loader.js";
|
||||
import type { OpenClawPluginCliCommandDescriptor } from "./types.js";
|
||||
import type { PluginLogger } from "./types.js";
|
||||
|
||||
@@ -30,11 +34,7 @@ function canRegisterPluginCliLazily(entry: {
|
||||
return entry.commands.every((command) => descriptorNames.has(command));
|
||||
}
|
||||
|
||||
function loadPluginCliRegistry(
|
||||
cfg?: OpenClawConfig,
|
||||
env?: NodeJS.ProcessEnv,
|
||||
loaderOptions?: Pick<PluginLoadOptions, "pluginSdkResolution">,
|
||||
) {
|
||||
function resolvePluginCliLoadContext(cfg?: OpenClawConfig, env?: NodeJS.ProcessEnv) {
|
||||
const config = cfg ?? loadConfig();
|
||||
const resolvedConfig = applyPluginAutoEnable({ config, env: env ?? process.env }).config;
|
||||
const workspaceDir = resolveAgentWorkspaceDir(
|
||||
@@ -51,22 +51,51 @@ function loadPluginCliRegistry(
|
||||
config: resolvedConfig,
|
||||
workspaceDir,
|
||||
logger,
|
||||
registry: loadOpenClawPlugins({
|
||||
config: resolvedConfig,
|
||||
workspaceDir,
|
||||
};
|
||||
}
|
||||
|
||||
async function loadPluginCliMetadataRegistry(
|
||||
cfg?: OpenClawConfig,
|
||||
env?: NodeJS.ProcessEnv,
|
||||
loaderOptions?: Pick<PluginLoadOptions, "pluginSdkResolution">,
|
||||
) {
|
||||
const context = resolvePluginCliLoadContext(cfg, env);
|
||||
return {
|
||||
...context,
|
||||
registry: await loadOpenClawPluginCliRegistry({
|
||||
config: context.config,
|
||||
workspaceDir: context.workspaceDir,
|
||||
env,
|
||||
logger,
|
||||
logger: context.logger,
|
||||
...loaderOptions,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
export function getPluginCliCommandDescriptors(
|
||||
function loadPluginCliCommandRegistry(
|
||||
cfg?: OpenClawConfig,
|
||||
env?: NodeJS.ProcessEnv,
|
||||
): OpenClawPluginCliCommandDescriptor[] {
|
||||
loaderOptions?: Pick<PluginLoadOptions, "pluginSdkResolution">,
|
||||
) {
|
||||
const context = resolvePluginCliLoadContext(cfg, env);
|
||||
return {
|
||||
...context,
|
||||
registry: loadOpenClawPlugins({
|
||||
config: context.config,
|
||||
workspaceDir: context.workspaceDir,
|
||||
env,
|
||||
logger: context.logger,
|
||||
...loaderOptions,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
export async function getPluginCliCommandDescriptors(
|
||||
cfg?: OpenClawConfig,
|
||||
env?: NodeJS.ProcessEnv,
|
||||
): Promise<OpenClawPluginCliCommandDescriptor[]> {
|
||||
try {
|
||||
const { registry } = loadPluginCliRegistry(cfg, env);
|
||||
const { registry } = await loadPluginCliMetadataRegistry(cfg, env);
|
||||
const seen = new Set<string>();
|
||||
const descriptors: OpenClawPluginCliCommandDescriptor[] = [];
|
||||
for (const entry of registry.cliRegistrars) {
|
||||
@@ -91,7 +120,11 @@ export async function registerPluginCliCommands(
|
||||
loaderOptions?: Pick<PluginLoadOptions, "pluginSdkResolution">,
|
||||
options?: RegisterPluginCliOptions,
|
||||
) {
|
||||
const { config, workspaceDir, logger, registry } = loadPluginCliRegistry(cfg, env, loaderOptions);
|
||||
const { config, workspaceDir, logger, registry } = loadPluginCliCommandRegistry(
|
||||
cfg,
|
||||
env,
|
||||
loaderOptions,
|
||||
);
|
||||
const mode = options?.mode ?? "eager";
|
||||
const primary = options?.primary ?? null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user