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

@@ -93,6 +93,9 @@ export default defineChannelPluginEntry({
(typically via `createPluginRuntimeStore`).
- `registerFull` only runs when `api.registrationMode === "full"`. It is skipped
during setup-only loading.
- For plugin-owned root CLI commands, prefer `api.registerCli(..., { descriptors: [...] })`
when you want the command to stay lazy-loaded without disappearing from the
root CLI parse tree.
## `defineSetupPluginEntry`
@@ -135,6 +138,14 @@ register(api) {
}
```
For CLI registrars specifically:
- use `descriptors` when the registrar owns one or more root commands and you
want OpenClaw to lazy-load the real CLI module on first invocation
- make sure those descriptors cover every top-level command root exposed by the
registrar
- use `commands` alone only for eager compatibility paths
## Plugin shapes
OpenClaw classifies loaded plugins by their registration behavior: