Skip to content

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

Merged
gumadeiras merged 2 commits into
openclaw:mainfrom
gumadeiras:codex/matrix-cli-registration-pr
Mar 29, 2026
Merged

gumadeiras merged 2 commits into
openclaw:mainfrom
gumadeiras:codex/matrix-cli-registration-pr

Conversation

@gumadeiras

@gumadeiras gumadeiras commented Mar 29, 2026 •

Copy link
Copy Markdown
Member

Summary

  • add shared descriptor-backed lazy plugin CLI registration so plugin-owned root commands can stay lazy-loaded without disappearing from parse-time routing
  • eagerly register the selected plugin primary during root CLI startup so openclaw <plugin> --help and dispatch see the real command tree
  • load plugin descriptors through a non-activating snapshot path for root help, and keep overlap/compatibility guards in place

Root cause

A March 28 refactor changed the Matrix plugin CLI registrar to async, but plugin CLI registration during root CLI startup still assumed registration happened synchronously enough for parse-time command discovery. That let the Matrix plugin load while leaving the matrix command missing from the root command tree.

Implementation

  • extracted the placeholder-and-reparse flow into a shared helper used by core commands, sub-CLIs, and plugin CLI registration
  • taught src/plugins/cli.ts to lazily install descriptor-backed plugin commands at the root CLI level while eagerly loading the selected plugin primary
  • kept mixed or command-only registrars on the eager compatibility path, and preserved overlap guards before eager primary registration
  • updated root help to include plugin descriptors without activating the plugin registry by using a non-cached snapshot load
  • updated Matrix to advertise a descriptor-backed lazy CLI registrar and added regression coverage for the plugin entry, root help, and plugin CLI loading behavior
  • documented the registerCli(..., { descriptors }) contract in the plugin SDK docs and examples

Verification

  • pnpm check
  • pnpm build
  • attempted targeted and full pnpm test, but local Vitest still hangs immediately after the startup banners on this machine, so full test confirmation should come from CI

Copilot AI review requested due to automatic review settings March 29, 2026 16:42
@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix size: XS maintainer Maintainer-authored PR labels Mar 29, 2026
@gumadeiras gumadeiras self-assigned this Mar 29, 2026
@greptile-apps

greptile-apps Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR is a targeted fix that restores synchronous Matrix CLI registration, which was inadvertently broken by a March 28 refactor that made the registerCli callback async. Because plugin CLI registration happens synchronously at startup, the await import(...) inside the async callback deferred registerMatrixCli to a microtask, leaving the matrix command absent from the parsed command tree.

Key changes:

  • extensions/matrix/index.ts: Promotes registerMatrixCli to a static top-level import and removes the async keyword from the registerCli callback — ensuring the command is registered before CLI parse time.
  • extensions/matrix/index.test.ts (new): Regression test that asserts registerCli is called synchronously, the registrar itself returns undefined (not a Promise), and registerMatrixCli is invoked with the correct argument.
  • The crypto bootstrap (plugin-entry.runtime.js) remains correctly lazy-loaded via void import(...) in registerFull, so the heavier WASM crypto module is not eagerly loaded.

The fix is minimal, well-scoped, and directly addresses the stated root cause. The regression test is well-structured and would have caught the original bug.

Confidence Score: 5/5

Safe to merge — the change is minimal, targeted, and correct, with a solid regression test.

No P0 or P1 issues found. The fix precisely reverts the async→sync regression, the static import is correct, the crypto bootstrap remains lazy-loaded, and the new test directly covers the failure mode.

No files require special attention.

Important Files Changed

Filename Overview
extensions/matrix/index.ts Moved registerMatrixCli to a static import and made the registerCli callback synchronous. Crypto bootstrap remains lazy via void import(...). Fix is correct and minimal.
extensions/matrix/index.test.ts New regression test correctly verifies synchronous CLI registration: checks registerCli is called with a plain function and that invoking the registrar returns undefined (not a Promise).

Reviews (1): Last reviewed commit: "Matrix: restore synchronous CLI registra..." | Re-trigger Greptile

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores synchronous registration of the Matrix CLI so the matrix command is available at CLI parse time, while keeping heavier initialization lazy where possible.

Changes:

  • Register Matrix CLI synchronously by using a static import and non-async registrar callback
  • Add a Vitest regression test ensuring the registrar is synchronous and invoked correctly

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
extensions/matrix/index.ts Switches Matrix CLI registration back to a synchronous registrar callback.
extensions/matrix/index.test.ts Adds a regression test verifying synchronous CLI registration behavior.

Comment thread extensions/matrix/index.test.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85e8bea059

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread extensions/matrix/index.ts Resolved
@gumadeiras
gumadeiras force-pushed the codex/matrix-cli-registration-pr branch from 85e8bea to 473ef56 Compare March 29, 2026 18:15
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: M and removed size: XS labels Mar 29, 2026
@gumadeiras
gumadeiras force-pushed the codex/matrix-cli-registration-pr branch from 473ef56 to 105167b Compare March 29, 2026 18:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 105167b25b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/run-main.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 50b43cf057

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/plugins/cli.ts Resolved
@gumadeiras gumadeiras changed the title Matrix: restore synchronous CLI registration Plugins/CLI: add descriptor-backed lazy root command registration Mar 29, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e91405576d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/plugins/cli.ts Resolved
@gumadeiras
gumadeiras force-pushed the codex/matrix-cli-registration-pr branch from e914055 to 50b43cf Compare March 29, 2026 19:49
@gumadeiras
gumadeiras force-pushed the codex/matrix-cli-registration-pr branch from 50b43cf to 9251a4b Compare March 29, 2026 20:01
@gumadeiras
gumadeiras force-pushed the codex/matrix-cli-registration-pr branch from 9251a4b to ad1dee3 Compare March 29, 2026 20:02
@gumadeiras
gumadeiras merged commit 9b4f26e into openclaw:main Mar 29, 2026
17 of 20 checks passed
@gumadeiras

Copy link
Copy Markdown
Member Author

Merged via squash.

Thanks @gumadeiras!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad1dee32eb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/program/root-help.ts Resolved
Alix-007 pushed a commit to Alix-007/openclaw that referenced this pull request Mar 30, 2026
…enclaw#57165)

Merged via squash.

Prepared head SHA: ad1dee3
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
alexjiang1 pushed a commit to alexjiang1/openclaw that referenced this pull request Mar 31, 2026
…enclaw#57165)

Merged via squash.

Prepared head SHA: ad1dee3
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
pgondhi987 pushed a commit to pgondhi987/openclaw that referenced this pull request Mar 31, 2026
…enclaw#57165)

Merged via squash.

Prepared head SHA: ad1dee3
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…enclaw#57165)

Merged via squash.

Prepared head SHA: ad1dee3
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
Tardisyuan pushed a commit to Tardisyuan/openclaw that referenced this pull request Apr 30, 2026
…enclaw#57165)

Merged via squash.

Prepared head SHA: ad1dee3
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
…enclaw#57165)

Merged via squash.

Prepared head SHA: ad1dee3
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…enclaw#57165)

Merged via squash.

Prepared head SHA: ad1dee3
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
…enclaw#57165)

Merged via squash.

Prepared head SHA: ad1dee3
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
…enclaw#57165)

Merged via squash.

Prepared head SHA: ad1dee3
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
…enclaw#57165)

Merged via squash.

Prepared head SHA: ad1dee3
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
…enclaw#57165)

Merged via squash.

Prepared head SHA: ad1dee3
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants