Skip to content

perf(plugin): let command plugins declare their commands in the manifest - #454

Open
Stoufiler wants to merge 1 commit into
rest-sh:mainfrom
Stoufiler:perf/cache-command-plugin-discovery
Open

Stoufiler wants to merge 1 commit into
rest-sh:mainfrom
Stoufiler:perf/cache-command-plugin-discovery

Conversation

@Stoufiler

Copy link
Copy Markdown

Summary

Restish started every command plugin with --rsh-plugin-commands on each invocation, to list its commands. That is a subprocess before anything else, even for restish --version or a shell completion.

 addCommandPlugins
+  if the (cached) manifest declares Commands -> use them, no subprocess
   else run the plugin with --rsh-plugin-commands (unchanged)
  • New optional field Manifest.Commands. Manifests are already cached per plugin binary (path, mtime, size), so the host builds the commands without starting the plugin.
  • Plugins whose command list depends on the environment leave it empty and keep the discovery call.
  • Older hosts ignore the field, so plugins keep answering --rsh-plugin-commands with the same list. plugin.Run and HandleStartupFlags already do.
  • restish-mcp and restish-bulk declare their commands in their manifest.
  • docs/plugin-quickstart.md and design doc 020 are updated.

Evidence

  • restish --version with restish-mcp installed: 39 ms before, 26 ms after; 24 ms without any plugin.
  • New integration test TestCommandPluginManifestCommandsSkipDiscovery. Its test plugin exits with an error when asked for --rsh-plugin-commands. Without the host change, the test fails with that discovery error; with it, greet is listed and runs.
  • go test ./... and go test -tags integration ./... pass.

Merge Danger

Door: two-way

The field is additive and optional.

Blast Radius: command plugins

A plugin declaring manifest commands that differ from its discovery answer would show the manifest ones.

Restish started every command plugin with --rsh-plugin-commands on each
invocation, to list its commands: a subprocess before anything else,
even for `restish --version` or a shell completion. With restish-mcp
installed it cost ~13 ms per invocation (39 ms -> 26 ms for --version).

A plugin whose command list does not change between runs can now also
declare it in its manifest (Manifest.Commands). Manifests are already
cached per plugin binary (path, mtime, size), so the host uses these
commands without starting the plugin. Plugins that leave it empty keep
the discovery call, and older hosts ignore the field, so plugins keep
answering --rsh-plugin-commands with the same list.

restish-mcp and restish-bulk declare their commands in their manifest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant