Skip to content

feat(inspect): list hub commands and let the inspector execute them#127

Merged
antfu merged 2 commits into
mainfrom
feat/inspect-list-commands
Jul 22, 2026
Merged

feat(inspect): list hub commands and let the inspector execute them#127
antfu merged 2 commits into
mainfrom
feat/inspect-list-commands

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Summary

Adds a Commands tab to the devframe inspector, alongside Functions / State / Agent / History, backed by two new RPC functions:

  • devframes:plugin:inspect:list-commands — enumerates commands registered on the hub's commands host (id, title, description, icon, category, hasHandler, children), query/snapshot so it also works in build/spa mode.
  • devframes:plugin:inspect:execute-command — runs a command by id and returns the same InvokeResult envelope the existing invoke function uses.

Commands are a @devframes/hub feature, but the inspector plugin is deliberately hub-agnostic (no build/runtime dependency on @devframes/hub). Both functions read ctx.commands by duck-typing — the same pattern already established in plugins/terminals/src/node/manager.ts and plugins/code-server/src/node/supervisor.ts — so the plugin still builds and runs standalone: outside a hub, list-commands returns an empty list and execute-command throws a new diagnostic (DP_INSPECT_0003).

Unlike the existing generic invoke RPC, execute-command isn't gated to read-only types — running a command is the whole point of a command (unlike an arbitrary RPC action, which the inspector otherwise refuses to fire unprompted).

UI

  • New CommandsSmartCommandsViewCommandRow component chain, mirroring the existing FunctionsSmart/FunctionsView/FunctionRow pattern (search box, category counts, expandable rows, ActionButton "Run", JSON result view with ok/fail + duration).
  • Commands support up to two levels of nesting (parent → children per the hub's DevframeCommandBase); CommandRow renders children recursively, indented, with their own independent Run actions. Group-only commands (no handler) render without a Run action.
  • Added a matching CommandsView.stories.ts.

Tests

  • @devframes/hub added as a devDependency (test-only) to boot a real hub context (createHubContext) alongside the existing plain-context boot, mirroring plugins/messages' test setup.
  • New dev-server tests cover: empty list / thrown diagnostic outside a hub; listing a registered command, a group command with children, and their hasHandler flags inside a hub; executing a command with args, a nested child command, and error envelopes for a group-only command and an unregistered id.
  • Extended the static-build test to assert list-commands bakes into the snapshot dump.

This PR was created with the help of an agent.

Adds a Commands tab to the inspector, backed by two new RPC functions:
devframes:plugin:inspect:list-commands and
devframes:plugin:inspect:execute-command. Both duck-type ctx.commands
(the hub's commands host) so the plugin keeps no build/runtime
dependency on @devframes/hub and degrades gracefully outside a hub
(empty list / thrown diagnostic).
@netlify

netlify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit e685a69
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a607636d8616b0008215833
😎 Deploy Preview https://deploy-preview-127--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@antfu
antfu merged commit 6ee61dd into main Jul 22, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants