Skip to content

Unify CLI output and wrapper-owned help - #4243

Closed
codeshaunted wants to merge 1 commit into
canaryfrom
codex/unify-cli-shell
Closed

Unify CLI output and wrapper-owned help#4243
codeshaunted wants to merge 1 commit into
canaryfrom
codex/unify-cli-shell

Conversation

@codeshaunted

@codeshaunted codeshaunted commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Changes

  • add a shared Cargo-style baml_shell::Shell for diagnostics, statuses, color policy, Clap styling, and root-help rendering
  • add the versioned hidden __baml-root-help-v1 metadata command to baml-cli
  • let the wrapper render one root help menu by merging selected-toolchain metadata with toolchain and self-update
  • fall back to delegated help for older, malformed, or unsupported toolchain metadata
  • keep wrapper-owned help available before a toolchain is installed
  • migrate existing generic warnings, errors, notes, telemetry output, and status output to the shared theme

Testing

  • wrapper unit and end-to-end tests
  • baml_cli unit tests (412 passed)
  • no-self-update feature tests
  • strict Clippy for all affected targets
  • rustdoc with warnings denied
  • workspace stow validation
  • formatting and diff checks

Tested on macOS.

Summary by CodeRabbit

  • New Features

    • Added consistent, color-aware formatting for statuses, errors, warnings, and notes across CLI commands.
    • Improved root help by combining wrapper commands with toolchain-provided commands and options.
    • Added fallback help when toolchain metadata is unavailable, invalid, or no toolchain is installed.
    • Added structured help support for CLI integrations.
  • Bug Fixes

    • Improved error and warning routing for authentication, feedback, search, testing, telemetry, and toolchain operations.
    • Preserved subcommand help output when delegating to the underlying CLI.

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview, Comment Jul 28, 2026 8:05pm
promptfiddle Ready Ready Preview, Comment Jul 28, 2026 8:05pm
promptfiddle2 Ready Ready Preview, Comment Jul 28, 2026 8:05pm

Request Review

@vercel
vercel Bot temporarily deployed to Preview – beps July 28, 2026 19:44 Inactive
@github-actions

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds the shared baml_shell crate, migrates CLI diagnostics and styled output to it, and introduces a JSON root-help protocol allowing the wrapper to merge toolchain metadata with wrapper commands while retaining fallback help paths.

Changes

Shell and CLI integration

Layer / File(s) Summary
Shared Shell foundation
baml_language/Cargo.toml, baml_language/crates/baml_shell/*, baml_language/crates/baml_exec/*
Adds Shell, color choices, themed diagnostics, root-help schemas, rendering helpers, validation, tests, and shared clap styling.
Diagnostic and command output migration
baml_language/crates/baml_cli/src/{reporter.rs,output.rs,*_command.rs}, baml_language/crates/baml_exec/src/diag_print.rs, baml_language/crates/baml_pack_host/src/main.rs
Routes errors, warnings, notes, telemetry, listings, and status messages through the shared shell and reporter.
Root-help protocol and delegation
baml_language/crates/baml/src/main.rs, baml_language/crates/baml_cli/src/{commands.rs,lib.rs,main.rs}, baml_language/crates/baml/tests/freshness_e2e.rs
Adds RootHelpV1 generation and serialization, wrapper-command merging, toolchain delegation, fallback help, and end-to-end coverage.
Toolchain and self-update output
baml_language/crates/baml/src/main.rs, baml_language/crates/baml/tests/no_self_update_e2e.rs
Passes Shell through toolchain operations and updates installation, status, warnings, listing, and self-update output.
Configuration alignment
baml_language/stow.toml
Updates the baml namespace configuration line without changing its approved prefix values.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Baml as baml wrapper
  participant CLI as baml-cli
  participant Shell as baml_shell::Shell
  User->>Baml: request root help
  Baml->>CLI: request RootHelpV1 metadata
  CLI-->>Baml: return serialized help metadata
  Baml->>Baml: add toolchain and self-update commands
  Baml->>Shell: render merged help
  Shell-->>User: print root help
Loading

Possibly related PRs

Suggested reviewers: rossirpaulo, atx24, hellovai

Poem

A rabbit hops through styled light,
Shells turn warnings crisp and bright.
Help rows merge, commands align,
Toolchains speak in one design.
Root help blooms from JSON air—
Bouncy output everywhere!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.42% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main themes of the PR: unified CLI output and wrapper-owned help handling.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/unify-cli-shell
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch codex/unify-cli-shell

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.

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 28, 2026 19:52 Inactive
@github-actions

Copy link
Copy Markdown

Binary size checks passed

7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
baml-cli Linux 🔒 27.3 MB 11.6 MB file 27.3 MB +28.2 KB (+0.1%) OK
packed-program Linux 🔒 17.7 MB 7.3 MB file 17.7 MB -4.1 KB (-0.0%) OK
baml-cli macOS 🔒 21.2 MB 10.2 MB file 21.2 MB +16.6 KB (+0.1%) OK
packed-program macOS 🔒 13.8 MB 6.4 MB file 13.9 MB -16.5 KB (-0.1%) OK
baml-cli Windows 🔒 22.9 MB 10.4 MB file 22.9 MB +24.1 KB (+0.1%) OK
packed-program Windows 🔒 14.8 MB 6.5 MB file 14.8 MB -2.0 KB (-0.0%) OK
bridge_wasm WASM 16.6 MB 🔒 4.5 MB gzip 4.5 MB -1 B (-0.0%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 28, 2026 20:05 Inactive

@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)
baml_language/crates/baml/src/main.rs (1)

406-435: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider logging the discarded root-help fallback reason.

toolchain_root_help's failure (spawn error, non-zero exit, JSON parse error, or validate() failure) is discarded via Err(_) before falling back to pass_through_resolved. If a future baml-cli regresses its root-help metadata, this fails silently every time with no diagnostic trail. The file already has a convention for this (crate::bytecode_cache::cache_debug in run_command.rs) — consider a similar low-noise debug log here.

♻️ Example
-        Err(_) => pass_through_resolved(shell, original_args, resolved),
+        Err(err) => {
+            // Low-noise breadcrumb; doesn't affect user-visible fallback behavior.
+            crate::debug_log(format_args!("root-help metadata rejected: {err:#}"));
+            pass_through_resolved(shell, original_args, resolved)
+        }
🤖 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 `@baml_language/crates/baml/src/main.rs` around lines 406 - 435, Update the
Err(_) branch in root_help to capture the toolchain_root_help failure and emit a
low-noise debug diagnostic using the existing crate::bytecode_cache::cache_debug
convention before calling pass_through_resolved. Preserve the fallback behavior
and original arguments unchanged, while including enough error context to
identify why root-help metadata was unavailable.
🤖 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 `@baml_language/crates/baml/src/main.rs`:
- Around line 406-435: Update the Err(_) branch in root_help to capture the
toolchain_root_help failure and emit a low-noise debug diagnostic using the
existing crate::bytecode_cache::cache_debug convention before calling
pass_through_resolved. Preserve the fallback behavior and original arguments
unchanged, while including enough error context to identify why root-help
metadata was unavailable.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 891c4484-bef6-4a21-b371-0006d3ba8954

📥 Commits

Reviewing files that changed from the base of the PR and between d0dbf79 and 0bcf651.

⛔ Files ignored due to path filters (1)
  • baml_language/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (27)
  • baml_language/Cargo.toml
  • baml_language/crates/baml/Cargo.toml
  • baml_language/crates/baml/src/main.rs
  • baml_language/crates/baml/tests/freshness_e2e.rs
  • baml_language/crates/baml/tests/no_self_update_e2e.rs
  • baml_language/crates/baml_cli/Cargo.toml
  • baml_language/crates/baml_cli/src/auth.rs
  • baml_language/crates/baml_cli/src/commands.rs
  • baml_language/crates/baml_cli/src/describe_command.rs
  • baml_language/crates/baml_cli/src/feedback_command.rs
  • baml_language/crates/baml_cli/src/grep_command.rs
  • baml_language/crates/baml_cli/src/lib.rs
  • baml_language/crates/baml_cli/src/main.rs
  • baml_language/crates/baml_cli/src/output.rs
  • baml_language/crates/baml_cli/src/reporter.rs
  • baml_language/crates/baml_cli/src/run_command.rs
  • baml_language/crates/baml_cli/src/telemetry/storage.rs
  • baml_language/crates/baml_cli/src/telemetry_command.rs
  • baml_language/crates/baml_cli/src/test_command.rs
  • baml_language/crates/baml_exec/Cargo.toml
  • baml_language/crates/baml_exec/src/clap_target.rs
  • baml_language/crates/baml_exec/src/diag_print.rs
  • baml_language/crates/baml_exec/src/lib.rs
  • baml_language/crates/baml_pack_host/src/main.rs
  • baml_language/crates/baml_shell/Cargo.toml
  • baml_language/crates/baml_shell/src/lib.rs
  • baml_language/stow.toml

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