Skip to content

perf(cli): defer bootstrap command tree - #11684

Merged
jdx merged 1 commit into
mainfrom
agent/bootstrap-deferred-cli
Aug 4, 2026
Merged

perf(cli): defer bootstrap command tree#11684
jdx merged 1 commit into
mainfrom
agent/bootstrap-deferred-cli

Conversation

@jdx

@jdx jdx commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • defer construction of the nested bootstrap command tree until mise bootstrap is selected
  • preserve complete command introspection for usage generation, command effects, and tests
  • keep bootstrap-local --dry-run and --yes behavior unchanged

Validation

  • cargo test cli::tests::test_bootstrap_command_tree_is_deferred_until_parsing
  • cargo test cli::tests::test_subcommands_are_sorted
  • cargo test cli::tests::test_config_target_options_accept_both_names
  • cargo test cli::command_effects::tests
  • mise run render:usage (no generated changes)
  • cargo clippy --workspace --all-features --all-targets -- -D warnings

AI-assisted — Tool: Codex; model: openai/gpt-5; version: unavailable.

Summary by CodeRabbit

  • New Features

    • Improved CLI startup by loading Bootstrap subcommands only when needed.
    • Preserved support for --dry-run and --yes options during command parsing and execution.
  • Bug Fixes

    • Ensured help output, command discovery, validation, and usage specifications include all available subcommands.
    • Prevented automatically generated help subcommands from appearing in usage specifications.
    • Improved consistency between displayed command information and available CLI functionality.

Note

Low Risk
Startup-only CLI wiring with explicit tests for deferred parsing, flag preservation, and expanded introspection; bootstrap runtime behavior is delegated unchanged to the existing Bootstrap implementation.

Overview
Defers building the large nested bootstrap CLI until the user actually runs mise bootstrap (or bs), so normal mise startup no longer pays the cost of registering every bootstrap subcommand up front.

A DeferredBootstrap wrapper uses clap’s deferred parser for the full Bootstrap tree while deferred_flags still exposes top-level --dry-run / --yes (and the bs alias) on the outer command; those flags are merged into the inner Bootstrap struct during FromArgMatches because they’re marked #[clap(skip)] on Bootstrap itself.

Full-tree introspection is unchanged via expand_deferred_subcommands, which swaps in bootstrap::full_command() for usage generation, command-effect validation, rendered help, and tests that need the complete subcommand tree.

Reviewed by Cursor Bugbot for commit b587636. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The CLI now defers construction of the bootstrap command tree during normal parsing. It expands the tree for execution, validation, help rendering, usage generation, and command-effect tests while preserving bootstrap flags.

Changes

Deferred bootstrap command

Layer / File(s) Summary
Deferred bootstrap wrapper
src/cli/bootstrap.rs
DeferredBootstrap delegates nested parsing and execution to Bootstrap while preserving --dry-run and --yes. Shared flag definitions and full_command build the complete command tree. Tests verify flag preservation.
Command tree wiring
src/cli/mod.rs
Commands::Bootstrap uses DeferredBootstrap. expand_deferred_subcommands restores the full bootstrap tree for validation and tests.
Command tree consumers
src/cli/command_effects.rs, src/cli/render_help.rs, src/cli/usage.rs
Command discovery, effect annotation, help rendering, and usage generation expand deferred subcommands before inspection. Generated help subcommands are disabled where required.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant DeferredBootstrap
  participant Bootstrap
  participant CommandTreeInspector
  CLI->>DeferredBootstrap: parse bootstrap arguments
  DeferredBootstrap->>Bootstrap: delegate nested arguments
  DeferredBootstrap->>Bootstrap: preserve dry_run and yes
  DeferredBootstrap->>Bootstrap: run command
  CommandTreeInspector->>CLI: request command tree
  CLI->>CommandTreeInspector: expand deferred bootstrap
  CommandTreeInspector->>CLI: inspect full bootstrap tree
Loading

Possibly related PRs

  • jdx/mise#11436: Both changes modify the bootstrap command tree in src/cli/bootstrap.rs.
  • jdx/mise#11669: Both changes modify deferred bootstrap command construction and expansion.

Poem

A rabbit keeps flags in a neat little row,
dry-run and yes wait until they must go.
The bootstrap tree stays small at the start,
Then expands as parsing and checks do their part,
While command paths hop where they need to go.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes deferring the bootstrap command tree, which is the main change.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jdx jdx changed the title agent/bootstrap deferred cli perf(cli): defer bootstrap command tree Aug 3, 2026
@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Defers construction of the nested bootstrap command tree during ordinary CLI startup while explicitly expanding it for full-tree introspection.

  • Adds a deferred bootstrap wrapper that preserves bootstrap-local --dry-run and --yes parsing.
  • Expands bootstrap commands for usage generation, rendered command metadata, effect validation, and command-tree tests.
  • Adds tests covering deferred construction, alias parsing, and flag preservation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/cli/bootstrap.rs Introduces the deferred bootstrap wrapper, full-tree reconstruction, local flag extraction, and focused parsing tests.
src/cli/mod.rs Registers the deferred wrapper and provides the centralized expansion helper used by introspection paths.
src/cli/usage.rs Expands the deferred bootstrap tree before generating the usage specification and suppresses generated help subcommands.
src/cli/render_help.rs Expands deferred commands before generating command metadata for documentation.
src/cli/command_effects.rs Updates command-effect validation tests to inspect the complete expanded command tree.

Reviews (4): Last reviewed commit: "perf(cli): defer bootstrap command tree" | Re-trigger Greptile

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
src/cli/bootstrap.rs (1)

40-80: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add direct test coverage for dry_run/yes propagation through DeferredBootstrap.

The FromArgMatches impl is hand-written, not derived, and it carries the flag-preservation logic that this PR is centered on. The existing test test_bootstrap_command_tree_is_deferred_until_parsing in src/cli/mod.rs only checks that mise bootstrap status --json parses without error. It does not assert that DeferredBootstrap::from_arg_matches (or update_from_arg_matches) actually sets dry_run/yes to true when --dry-run/--yes are passed. A regression in the manual |= merge logic (for example, reading the wrong matches, or an inverted flag) would not be caught by any visible test.

Add a test that parses mise bootstrap --dry-run --yes status --json (or similar) and asserts the resulting Bootstrap/DeferredBootstrap fields.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli/bootstrap.rs` around lines 40 - 80, Add direct test coverage for the
hand-written DeferredBootstrap::from_arg_matches and, if applicable,
update_from_arg_matches paths by parsing a bootstrap command with both --dry-run
and --yes, then asserting the resulting Bootstrap fields are true. Extend the
existing bootstrap parsing tests near
test_bootstrap_command_tree_is_deferred_until_parsing while preserving their
current coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/cli/bootstrap.rs`:
- Around line 40-80: Add direct test coverage for the hand-written
DeferredBootstrap::from_arg_matches and, if applicable, update_from_arg_matches
paths by parsing a bootstrap command with both --dry-run and --yes, then
asserting the resulting Bootstrap fields are true. Extend the existing bootstrap
parsing tests near test_bootstrap_command_tree_is_deferred_until_parsing while
preserving their current coverage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 20ac801b-ff74-4489-ab24-0097f7f3da85

📥 Commits

Reviewing files that changed from the base of the PR and between d32c027 and 94a1f2d.

📒 Files selected for processing (5)
  • src/cli/bootstrap.rs
  • src/cli/command_effects.rs
  • src/cli/mod.rs
  • src/cli/render_help.rs
  • src/cli/usage.rs

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Instruction counts

benchmark trend instructions Δ wall (min) Δ
env █▅▇▇██▇▇█▇▇▇▁ 80,147,500 → 79,668,640 -0.60% 18.93 → 17.58ms -7.11%
hook-env █▆█▇██▇█▇▇▇█▁ 82,316,397 → 81,778,386 -0.65% 19.56 → 18.35ms -6.21%
ls █▅█▇██▇▆▇▆▇▇▁ 73,100,065 → 72,641,393 -0.63% 17.50 → 16.39ms -6.35%
registry ▅▆███▆▅▅▇▅▆▆▁ 49,153,102 → 48,680,604 -0.96% 13.82 → 11.95ms -13.56%
startup ▆▇▇▇▇▇▆▆█▆▆▇▁ 15,796,331 → 15,413,574 -2.42% 9.74 → 9.40ms -3.41%

No instruction-count regression above 1%.

Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run.

Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes.

b587636a1b54 vs 6f213790a223 · measured on the runner, not pushed to the history.

@jdx
jdx force-pushed the agent/bootstrap-deferred-cli branch from 94a1f2d to c64a550 Compare August 4, 2026 01:08

jdx commented Aug 4, 2026

Copy link
Copy Markdown
Owner Author

Addressed the latest review suggestion in c64a550: added direct coverage for both initial parsing and update parsing of the hand-written deferred --dry-run/--yes propagation.\n\nAI-assisted — Tool: Codex; model: openai/gpt-5; version: unavailable.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c64a550. Configure here.

Comment thread src/cli/bootstrap.rs
@jdx
jdx force-pushed the agent/bootstrap-deferred-cli branch from c64a550 to 5a1a973 Compare August 4, 2026 01:32
@jdx
jdx force-pushed the agent/bootstrap-deferred-cli branch from 5a1a973 to b587636 Compare August 4, 2026 05:55
@jdx
jdx merged commit a5cebb1 into main Aug 4, 2026
30 checks passed
@jdx
jdx deleted the agent/bootstrap-deferred-cli branch August 4, 2026 13:23
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