Skip to content

feat(blend): add check and format commands - #25

Merged
houki-san[bot] merged 3 commits into
masterfrom
dev/blend-check-format
Jun 11, 2026
Merged

feat(blend): add check and format commands#25
houki-san[bot] merged 3 commits into
masterfrom
dev/blend-check-format

Conversation

@frantic1048

@frantic1048 frantic1048 commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • add blend check to evaluate/typecheck selected or all order.ncl files through the embedded Nickel evaluator
  • validate order semantics in blend check, including missing active from_file sources
  • add blend format / blend fmt with --check and dry-run support using the in-process Nickel formatter
  • dogfood both commands in scoped blend CI under the default sandbox policy after Rust fmt/clippy/test pass
  • split orders-only CI into a separate workflow that installs the latest blend release and runs blend check plus blend format --check
  • commit the current Nickel formatter baseline for existing orders separately as style: format orders
  • update docs and just check, and cover the new commands in E2E tests

Closes #22.

Verification

  • actionlint .github/workflows/blend-ci.yml .github/workflows/orders-ci.yml
  • cargo fmt -p blend --check
  • cargo test -p blend test_check_order
  • cargo test -p blend test_format
  • cargo test -p blend
  • HOME=/private/tmp/blend-ci-home-split-style cargo run -p blend -- check
  • HOME=/private/tmp/blend-ci-home-split-style cargo run -p blend -- format --check

@sourcery-ai

sourcery-ai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds first-class Nickel-based blend check and blend format/fmt commands (with --check and dry-run support), wires them into the CLI and CI, and commits a formatter baseline for existing orders plus E2E coverage and docs updates.

Sequence diagram for blend format --check command flow

sequenceDiagram
    actor User
    participant BlendCli as main
    participant CmdFormat as cmd_format
    participant Nickel as format_source
    participant FS as FileSystem
    participant Gen as generated

    User->>BlendCli: Commands::Format
    BlendCli->>CmdFormat: cmd_format(ctx, orders, check)
    CmdFormat->>Gen: assert_orders_ready(orders_dir)
    Gen-->>CmdFormat: Result
    CmdFormat->>CmdFormat: selected_orders(ctx, orders)
    loop each order_name
        CmdFormat->>FS: read_to_string(order.ncl)
        FS-->>CmdFormat: source
        CmdFormat->>Nickel: format_source(source)
        Nickel-->>CmdFormat: formatted
        alt formatted == source
            CmdFormat->>User: println("✓ path")
        else formatted != source
            alt check || ctx.dry_run
                CmdFormat->>User: println("would format path")
            else
                CmdFormat->>FS: write(path, formatted)
                FS-->>CmdFormat: Result
            end
        end
    end
    CmdFormat->>User: log::success(...) / log::info(...)
Loading

File-Level Changes

Change Details Files
Introduce Nickel-backed blend check command with semantic validation for orders.
  • Add Check variant to CLI commands to typecheck/evaluate order.ncl files, defaulting to all orders when none are specified.
  • Implement cmd_check to evaluate orders via NickelEvaluator, validate from_file sources exist when entries apply, and report per-order success/failure with a final summary.
  • Reuse order discovery logic to support both explicit and implicit (all) order selection, respecting context metadata like OS, arch, and hostname.
  • Export cmd_check from the commands module and hook it into main command dispatch.
  • Add E2E tests for successful checks and missing from_file failures, asserting the user-facing messages and exit codes.
blend/src/cli.rs
blend/src/commands.rs
blend/src/commands/check.rs
blend/src/main.rs
blend/tests/sync_e2e.rs
Introduce Nickel formatter-backed blend format/blend fmt command with --check and dry-run behavior.
  • Add Format CLI variant with alias fmt, order selection, and a --check flag for non-mutating validation.
  • Expose a format_source helper using nickel_lang_core's in-process formatter, handling I/O and UTF-8 issues.
  • Implement cmd_format to read order.ncl files, format them, optionally write changes or just report them in check/dry-run modes, and surface summary or failure when formatting is required.
  • Integrate cmd_format into command dispatch and export from the commands module.
  • Extend E2E tests to cover blend format --check success, formatting a compact Nickel file, and ensuring re-check passes after formatting.
blend/src/cli.rs
blend/src/nickel/loader.rs
blend/src/nickel.rs
blend/src/commands.rs
blend/src/commands/format.rs
blend/src/main.rs
blend/tests/sync_e2e.rs
blend/Cargo.toml
Wire new commands into CI, docs, and project automation, and update Nickel-related dependencies and order files formatting baseline.
  • Split the existing CI into blend-ci.yml focused on the crate (fmt, new check/format commands, clippy, tests) and a new orders-ci.yml workflow that installs the latest released blend and runs blend check and blend format --check when only orders/** change.
  • Update just check to use blend check instead of blend view --dry-run, and document the new commands in NEW_BLEND.md and CLAUDE.md (including commit/branch conventions and feature list cleanup).
  • Bump tree-sitter and add a nickel-lang-core dependency with the format feature to support in-process Nickel formatting.
  • Apply Nickel formatter-driven adjustments to existing orders/*/order.ncl files (e.g., comment spacing and whitespace cleanups) and update the neovim order comment spacing.
  • Rename the CI workflow file from ci.yml to blend-ci.yml in triggers and corresponding configuration.
  • Update Cargo.lock to reflect new/changed Rust dependencies.
.github/workflows/blend-ci.yml
.github/workflows/orders-ci.yml
justfile
NEW_BLEND.md
CLAUDE.md
blend/Cargo.toml
orders/neovim/order.ncl
orders/X/order.ncl
orders/alsa/order.ncl
orders/bat/order.ncl
orders/bin/order.ncl
orders/color/order.ncl
orders/elvish/order.ncl
orders/fastfetch/order.ncl
orders/fcitx/order.ncl
orders/fontconfig/order.ncl
orders/ghostty/order.ncl
orders/gpg/order.ncl
orders/i3wm/order.ncl
orders/macos-hushlogin/order.ncl
orders/makepkg/order.ncl
orders/mako/order.ncl
orders/mise/order.ncl
orders/nano/order.ncl
orders/ncdu/order.ncl
orders/neofetch/order.ncl
orders/npm/order.ncl
orders/pam_env/order.ncl
orders/picom/order.ncl
orders/pipewire/order.ncl
orders/proto/order.ncl
orders/pueue/order.ncl
orders/pulseaudio/order.ncl
orders/rofi/order.ncl
orders/sakura/order.ncl
orders/sketchybar/order.ncl
orders/skhd/order.ncl
orders/sway/order.ncl
orders/swayshot/order.ncl
orders/sxiv/order.ncl
orders/tealdeer/order.ncl
orders/tint2/order.ncl
orders/waybar/order.ncl
orders/wezterm/order.ncl
orders/yabai/order.ncl
orders/zellij/order.ncl
Cargo.lock

Assessment against linked issues

Issue Objective Addressed Explanation
#22 Add a fmt/format subcommand to the blend CLI that formats configuration order.ncl files (i.e., supports formatting via the Nickel formatter).

Possibly linked issues

  • #: PR adds the requested blend format/fmt subcommand, including --check support, tests, docs, and CI integration

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai 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.

Hey - I've found 1 issue, and left some high level feedback:

  • Both cmd_check and cmd_format define an identical selected_orders helper; consider pulling this into a shared function (e.g., in commands::helpers) to avoid duplication and keep order-selection behavior consistent in one place.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Both `cmd_check` and `cmd_format` define an identical `selected_orders` helper; consider pulling this into a shared function (e.g., in `commands::helpers`) to avoid duplication and keep order-selection behavior consistent in one place.

## Individual Comments

### Comment 1
<location path="blend/tests/sync_e2e.rs" line_range="150" />
<code_context>
+#[test]
+fn test_check_order_success() {
</code_context>
<issue_to_address>
**suggestion (testing):** Add an e2e test for `blend check` with a non-existent order name

Current tests cover the success path and the `from_file` missing case, but not when a user passes an unknown order name (handled in `cmd_check` as `Order '{order_name}' not found`). Please add an e2e test (e.g., `test_check_order_fails_when_order_missing`) that runs `blend --sandbox never check some-nonexistent-order`, asserts a non-zero exit code, and verifies that stderr includes the "Order '…' not found" message.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread blend/tests/sync_e2e.rs
@@ -149,6 +149,109 @@ fn test_sandbox_force_exec_probe() {
);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (testing): Add an e2e test for blend check with a non-existent order name

Current tests cover the success path and the from_file missing case, but not when a user passes an unknown order name (handled in cmd_check as Order '{order_name}' not found). Please add an e2e test (e.g., test_check_order_fails_when_order_missing) that runs blend --sandbox never check some-nonexistent-order, asserts a non-zero exit code, and verifies that stderr includes the "Order '…' not found" message.

@frantic1048
frantic1048 force-pushed the dev/blend-check-format branch 3 times, most recently from 57b9db4 to 90005ef Compare June 11, 2026 17:17
@frantic1048
frantic1048 force-pushed the dev/blend-check-format branch from 90005ef to beb5c24 Compare June 11, 2026 17:28

@houki-san houki-san 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.

LGTM 👍

select_orders dedup into helpers is clean. CI split, semantic validation, and test coverage all look solid.

@houki-san
houki-san Bot merged commit acab62f into master Jun 11, 2026
3 of 4 checks passed
@houki-san
houki-san Bot deleted the dev/blend-check-format branch June 11, 2026 17:36
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.

Support fmt subcommand for blend cli

1 participant