Add plugin completion protocol#1487
Draft
mnorth-stripe wants to merge 1 commit intosentinel-block-managementfrom
Draft
Add plugin completion protocol#1487mnorth-stripe wants to merge 1 commit intosentinel-block-managementfrom
mnorth-stripe wants to merge 1 commit intosentinel-block-managementfrom
Conversation
This was referenced Mar 15, 2026
Contributor
Author
|
PR stack (2 of 3)
|
501737d to
abe6b80
Compare
abe6b80 to
c62925c
Compare
e0e74b6 to
7a1b460
Compare
c62925c to
cd92117
Compare
Enables dynamic shell completion for plugin subcommands by invoking the plugin binary with Cobra's __complete protocol and parsing the response. When a user presses tab on a plugin command, the host CLI delegates completion to the plugin process. - GetPluginCompletions: invokes plugin binary with __complete args, parses Cobra-format output (completions + directive) - parseCompletionOutput: parses the tab-separated completion format - resolvePluginBinary / buildPluginCommand: locate and construct the plugin invocation, including Node.js runtime detection - Wires ValidArgsFunction into plugin template commands Committed-By-Agent: claude
7a1b460 to
463ba73
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables dynamic shell completion for plugin subcommands by invoking the plugin binary with Cobra's
__completeprotocol and parsing the response. When a user presses tab on a plugin command, the host CLI delegates completion to the plugin process.Depends on #1485 (sentinel block management).
How it works
stripe apps <TAB>)__complete+ the current argsKey functions
GetPluginCompletions: Entry point — looks up the plugin, builds the command, invokes with timeout (3s), parses outputparseCompletionOutput: Parses Cobra's__completeoutput format (completions +:directive)resolvePluginBinary/buildPluginCommand: Locate the plugin binary and construct the invocation, including Node.js runtime detectionValidArgsFunction: Wired into plugin template commands to enable Cobra's completion systemRelationship to
--map(#1481)This PR and the
--mapflag (#1481) solve different aspects of plugin discoverability through complementary mechanisms:--mapuses static registration: plugins declare their command tree in the manifest ([[Plugin.Command]]), and the host CLI creates cobra.Command stubs from that metadata. This works well for structural discoverability because the command tree is stable between plugin install/update cycles.This PR uses runtime invocation: at tab-press time, the host CLI invokes the plugin binary with
__completeargs and parses the response. This is necessary because completions need to be dynamic (e.g., completing service names from an on-disk catalog cache), context-sensitive (dependent on current subcommand, flags, and positional arg position), and up-to-date (valid values can change between any two tab presses).Anything cached at the host CLI layer and only refreshed on plugin lifecycle events is inherently limited to structural (Tier 1) information — commands, subcommands, flag names. Dynamic argument values (Tier 2) require invoking the plugin, since only the plugin knows what values are valid for a given argument at a given moment. The
__completeprotocol provides exactly this: a standardized way to ask the plugin "what are the valid completions right now?"The two approaches are not competing —
--mapgives users structural awareness without launching plugins;__completegives the shell real-time, context-aware completions by asking the plugin directly.Test plan
PR stack
stripe completion --installAdd sentinel block management for shell config files #1485 — sentinel block management (base:fish-completion)stripe completion --installAdd sentinel block management for shell config files #1485)--install/--uninstall(base: this PR)