Plugins/CLI: add descriptor-backed lazy root command registration (#57165)

Merged via squash.

Prepared head SHA: ad1dee32eb
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:
Gustavo Madeira Santana
2026-03-29 16:02:59 -04:00
committed by GitHub
parent d330782ed1
commit 9b4f26e70a
17 changed files with 413 additions and 71 deletions

View File

@@ -1603,6 +1603,14 @@ export type OpenClawPluginCliContext = {
export type OpenClawPluginCliRegistrar = (ctx: OpenClawPluginCliContext) => void | Promise<void>;
/**
* Top-level CLI metadata for plugin-owned commands.
*
* Descriptors are the parse-time contract for lazy plugin CLI registration.
* If you want OpenClaw to keep a plugin command lazy-loaded while still
* advertising it at the root CLI level, provide descriptors that cover every
* top-level command root registered by that plugin CLI surface.
*/
export type OpenClawPluginCliCommandDescriptor = {
name: string;
description: string;
@@ -1707,7 +1715,15 @@ export type OpenClawPluginApi = {
registerCli: (
registrar: OpenClawPluginCliRegistrar,
opts?: {
/** Explicit top-level command roots owned by this registrar. */
commands?: string[];
/**
* Parse-time command descriptors for lazy root CLI registration.
*
* When descriptors cover every top-level command root, OpenClaw can keep
* the plugin registrar lazy in the normal root CLI path. Command-only
* registrations stay on the eager compatibility path.
*/
descriptors?: OpenClawPluginCliCommandDescriptor[];
},
) => void;