Skip to content

feat: Discover OpenCLI subcommands progressively - #62

Draft
boblail wants to merge 1 commit into
lail/has-subcommandsfrom
lail/opencli-progressive-discovery
Draft

feat: Discover OpenCLI subcommands progressively#62
boblail wants to merge 1 commit into
lail/has-subcommandsfrom
lail/opencli-progressive-discovery

Conversation

@boblail

@boblail boblail commented Aug 19, 2026

Copy link
Copy Markdown
Member

Stacked on #63.

A large CLI shouldn't have to enumerate its entire command tree in one --help-opencli response. When a subcommand's entry in its parent's OpenCLI document lists no children but declares the option --help-opencli, Subcommands() now discovers its subcommands on demand by invoking it (e.g. tool sub --help-opencli), recursively and respecting WithMaxDepth. Summary() prefers a summary already known from the parent's document, so menus of a deferred subcommand's siblings stay free of exec calls.

Also fixes two latent bugs surfaced by deferral: describeOpenCLI's cache key collided between a root and its subcommands (keyed by path alone), and toCommands built sibling args on a shared backing array, corrupting args four levels deep. No behavioural changes for CLIs that don't declare --help-opencli on a subcommand.

🤖 Generated with Claude Code

@boblail
boblail changed the base branch from main to lail/has-subcommands August 19, 2026 00:19
A large CLI shouldn't have to enumerate its entire command tree in one
--help-opencli response. When a subcommand's entry in its parent's
document lists no children but declares the option --help-opencli,
Exoskeleton now defers discovery: Subcommands() invokes the subcommand
with --help-opencli (e.g. `tool sub --help-opencli`) and parses its
document, recursively and on demand.

Deferral surfaces two latent bugs, both fixed here:
- describeOpenCLI's cache key was the executable's path alone, so a
  subcommand's document would collide with its root's. The key now
  includes the subcommand's arguments.
- toCommands built sibling args with append() on a shared slice, so
  siblings four levels deep could overwrite each other's backing array.
  Args are now allocated exactly per command.

Summary() also no longer triggers discovery when the summary is already
known from the parent's document, so rendering a menu of a deferred
subcommand's siblings stays free of exec calls.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@boblail
boblail force-pushed the lail/opencli-progressive-discovery branch from 90fb134 to 3f18b0c Compare August 19, 2026 00:25
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