Skip to content

refactor: improve CLI coverage structure#108

Merged
willkill07 merged 3 commits into
NVIDIA:release/0.2from
willkill07:wkk_refactor-cli-coverage
May 14, 2026
Merged

refactor: improve CLI coverage structure#108
willkill07 merged 3 commits into
NVIDIA:release/0.2from
willkill07:wkk_refactor-cli-coverage

Conversation

@willkill07
Copy link
Copy Markdown
Member

@willkill07 willkill07 commented May 14, 2026

Overview

Refactors the CLI coverage-heavy interactive setup/plugin editors so testable logic lives in focused helper modules, then adds coverage around the extracted behavior and related CLI paths.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

  • Split plugin config file handling and Observability editor state helpers out of plugins.rs into testable modules.
  • Split setup config/model/file helper logic out of setup.rs into setup/model.rs.
  • Added focused coverage for CLI setup, plugin editing models, doctor formatting/check helpers, completion install helpers, server gateway forwarding paths, and CLI smoke behavior.
  • Updated Codecov component reporting from Gateway Runtime to CLI, set the CLI target to 88%, and excluded only the remaining TTY prompt shells.
  • Added module guidance so future testable logic does not go back into the interactive prompt files.

Where should the reviewer start?

Start with crates/cli/src/plugins.rs and crates/cli/src/setup.rs to see the orchestration-only boundary, then review crates/cli/src/plugins/editor_model.rs, crates/cli/src/plugins/config_io.rs, and crates/cli/src/setup/model.rs for the extracted testable logic.

Validation run locally:

  • cargo fmt --all
  • cargo test -p nemo-flow-cli with isolated XDG_CONFIG_HOME
  • cargo clippy --workspace --all-targets -- -D warnings
  • just test-rust with isolated XDG_CONFIG_HOME
  • cargo llvm-cov --package nemo-flow-cli --summary-only ...
  • commit hook pre-commit checks, including cargo fmt, cargo clippy, and cargo check

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • Relates to: none

Summary by CodeRabbit

  • New Features

    • Plugin config preview, validation, and safer save/merge behavior; clearer scope selection and Hermes hook handling in setup.
  • Chores / Refactor

    • Reorganized CLI internals into smaller, testable modules to make interactive editors and the setup wizard more reliable.
  • Tests

    • Added extensive CLI unit and integration tests covering agents, doctor, completions, plugin editor TTY behavior, setup flows, and gateway/server forwarding.
  • Chores

    • Updated Codecov to include CLI coverage and exclude interactive prompt loops.

Review Change Stack

Signed-off-by: Will Killian <wkillian@nvidia.com>
@willkill07 willkill07 requested a review from a team as a code owner May 14, 2026 14:32
@github-actions github-actions Bot added size:XL PR is extra large Improvement improvement to existing functionality labels May 14, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Walkthrough

This PR extracts deterministic CLI logic into new testable modules: plugins/config_io.rs (plugins.toml I/O, pruning, preview, validation) and plugins/editor_model.rs (editor state/merge/display), plus setup/model.rs (agent detection, TOML build/merge, Hermes hooks). plugins.rs and setup.rs now focus on TTY/dialoguer orchestration. Tests and Codecov config were updated.

Changes

CLI Orchestration and Model Separation

Layer / File(s) Summary
Plugin Configuration I/O Module
crates/cli/src/plugins/config_io.rs, crates/cli/tests/coverage/plugins_tests.rs
TargetScope and target path resolution; read/write plugins.toml via JSON intermediate, prune defaults, convert/render pretty TOML, preview, and validate plugin config. Tests cover missing/invalid files, pruning, round-trip read/write, and validation diagnostics.
Plugin Editor State Management Module
crates/cli/src/plugins/editor_model.rs
Schema-aware editor helpers for the observability plugin: ensure/toggle component, section/field state and resets, typed JSON getters/setters, schema-aware merge of edited maps, display helpers, and summary generation.
Plugin Editor Orchestration
crates/cli/src/plugins.rs, crates/cli/tests/coverage/plugins_tests.rs
plugins.rs reduced to interactive TTY/dialoguer orchestration; delegates config I/O and editor-model operations to new modules. Tests assert TTY enforcement and exercise editor behaviors and index/offset logic.
Setup Wizard Model Module
crates/cli/src/setup/model.rs, crates/cli/tests/coverage/setup_tests.rs
ConfigScope/SetupAnswers, agent detection by scanning $PATH, TOML document construction, save_config with write-or-merge semantics, Hermes hook path/installation, defaults parsing, and preview path helpers. Tests verify merge resilience, reset behavior, and preview/hook paths.
Setup Wizard Orchestration
crates/cli/src/setup.rs, crates/cli/tests/coverage/setup_tests.rs
setup.rs reduced to interactive TTY/dialoguer orchestration; run delegates deterministic work to setup::model. Tests cover orchestration and model-backed outcomes.
Tests and CI Coverage
codecov.yml, crates/cli/tests/cli_tests.rs, crates/cli/tests/coverage/*
Added Codecov CLI component entry (88% project target) and ignored TTY-only files; added integration tests (agents --json, doctor --json, completions zsh, plugins edit TTY check), expanded unit/integration coverage (env/cwd guards, Anthropic upstream test), and test helpers for env/cwd isolation.

Sequence Diagram

sequenceDiagram
  participant User
  participant Orchestration as setup.rs / plugins.rs
  participant Model as setup::model / plugins::config_io / plugins::editor_model
  participant FS as Filesystem
  User->>Orchestration: invoke command / answer prompts
  Orchestration->>Model: detect_installed_agents() / target_scope() / build_config()
  Model->>FS: read / parse existing config.toml / read plugins.toml
  Model->>Model: build/merge DocumentMut / prune defaults / validate
  Model->>FS: write merged config.toml / write plugins.toml / install .hermes/config.yaml
  Model-->>Orchestration: return preview paths / written paths / validation diagnostics
  Orchestration-->>User: print preview, confirm, report saved paths
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • NVIDIA/NeMo-Flow#98: Works on the same plugins edit observability-plugin editing workflow; related prior changes to plugins.rs.
  • NVIDIA/NeMo-Flow#91: Related refactor of setup wizard config generation; overlaps with setup/model.rs responsibilities.
  • NVIDIA/NeMo-Flow#89: Introduced observability plugin component types used by the editor and config helpers.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 68.03% 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
Title check ✅ Passed Title follows Conventional Commits format (refactor type, lowercase, imperative), is under 72 characters (40 chars), and accurately describes the main refactoring objective of improving CLI coverage structure by extracting testable logic.
Description check ✅ Passed Description includes all required sections: Overview with confirmations, Details with concrete changes, Where to start guidance, and Related Issues. All sections are complete and substantive.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@github-actions github-actions Bot added the lang:rust PR changes/introduces Rust code label May 14, 2026
@willkill07 willkill07 self-assigned this May 14, 2026
@willkill07 willkill07 added this to the 0.2 milestone May 14, 2026
Signed-off-by: Will Killian <wkillian@nvidia.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@crates/cli/src/setup.rs`:
- Around line 109-113: The code currently calls home_dir() unconditionally and
errors via CliError::Config if missing, which aborts project-only setup; change
hermes hooks path resolution to only call home_dir() when required (e.g., when
answers.scope is ConfigScope::Global or when any of answers.agents requires
Hermes hook installation) by checking answers.scope and answers.agents first,
and only then compute let home = home_dir().ok_or_else(...) and set
answers.hermes_hooks_path = hermes_hooks_path_for_scope(&answers.agents,
answers.scope, &cwd, &home); otherwise set answers.hermes_hooks_path to a
project-local path (or None) without invoking home_dir().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: ee8d83a2-993f-4692-8ee3-2ec4503ca46b

📥 Commits

Reviewing files that changed from the base of the PR and between 9cb248a and ed3823e.

📒 Files selected for processing (1)
  • crates/cli/src/setup.rs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (6)
**/*.rs

📄 CodeRabbit inference engine (.agents/skills/test-ffi-surface/SKILL.md)

**/*.rs: Run cargo fmt --all for FFI work as it is Rust work
Run just test-rust for FFI validation
Run cargo clippy --workspace --all-targets -- -D warnings to enforce warnings-as-errors linting

**/*.rs: Run cargo fmt --all for Rust code formatting
Run cargo clippy --workspace --all-targets -- -D warnings to enforce Rust linting with no warnings
Run just test-rust as the shared-runtime build/test wrapper for Rust changes

Use Rust snake_case naming convention for Rust code

**/*.rs: Any Rust change must run just test-rust
Any Rust change must run cargo fmt --all
Any Rust change must run cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all for Rust code formatting when Node changes touch Rust files
Run cargo clippy --workspace --all-targets -- -D warnings to enforce strict linting when Rust files changed as part of Node work

**/*.rs: Always run just test-rust when any Rust code changes
Always run cargo fmt --all when any Rust code changes
Always run cargo clippy --workspace --all-targets -- -D warnings when any Rust code changes

Files:

  • crates/cli/src/setup.rs
**/*.{rs,go,js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Include SPDX license headers in all Rust, Go, JavaScript, and TypeScript source files using C-style comment syntax

Files:

  • crates/cli/src/setup.rs
**/*.{rs,py,go,js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Use SONAR_IGNORE_START / SONAR_IGNORE_END markers only for documented false positives that cannot be resolved in code; keep ignored blocks small, add explanatory comments, and require reviewer sign-off

Files:

  • crates/cli/src/setup.rs
**/*.{js,ts,tsx,jsx,py,rs,go,java,c,cpp,h,cc,cxx,cs,rb,php,swift,kt}

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Changed files must be formatted with the language-native formatter

Files:

  • crates/cli/src/setup.rs
**/*.{py,js,ts,tsx,go,rs,md}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Format changed files with the language-native formatter before the final lint/test pass

Files:

  • crates/cli/src/setup.rs
**/*.{rs,py,js,ts,tsx,go}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

During iteration, prefer uv run pre-commit run --files <changed files...> for targeted validation

Files:

  • crates/cli/src/setup.rs
🔇 Additional comments (2)
crates/cli/src/setup.rs (2)

9-37: LGTM!


98-108: LGTM!

Also applies to: 115-138

Comment thread crates/cli/src/setup.rs
AjayThorve
AjayThorve previously approved these changes May 14, 2026
Copy link
Copy Markdown
Contributor

@AjayThorve AjayThorve left a comment

Choose a reason for hiding this comment

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

Reviewed and tested the CLI behavior for regressions. The change looks behavior-preserving: interactive setup/plugin flows remain in the CLI entry modules, while the testable config/model logic was split out and covered with focused tests.

…-cli-coverage

Signed-off-by: Will Killian <wkillian@nvidia.com>

# Conflicts:
#	crates/cli/src/plugins.rs
@willkill07 willkill07 force-pushed the wkk_refactor-cli-coverage branch from ba8da19 to fd53de3 Compare May 14, 2026 19:00
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/cli/tests/coverage/completions_install_tests.rs (1)

83-127: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Unsafe environment mutation is correctly guarded but could use SAFETY comments.

The install_writes_detected_shell_completion test properly serializes environment access via ENV_LOCK, and restore_env correctly handles both Some and None cases. However, the unsafe blocks lack SAFETY documentation explaining why the mutation is sound (single-threaded test context with mutex protection).

📝 Add SAFETY comments
 fn restore_env(key: &str, value: Option<OsString>) {
+    // SAFETY: Called only from tests holding ENV_LOCK, ensuring serialized access.
     unsafe {
         match value {
🤖 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 `@crates/cli/tests/coverage/completions_install_tests.rs` around lines 83 -
127, Add brief SAFETY comments to the unsafe blocks in the test
install_writes_detected_shell_completion and the helper restore_env explaining
why the unsafe env mutations are sound: state that ENV_LOCK serializes access so
only one thread mutates environment at a time during the test, and that values
passed to std::env::set_var/remove_var are valid for the duration of the call;
reference the ENV_LOCK mutex, the install_writes_detected_shell_completion test
function, and the restore_env function in the comment so reviewers can locate
the rationale quickly.
♻️ Duplicate comments (1)
crates/cli/src/setup.rs (1)

98-139: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Verify home directory requirement for project-only non-Hermes setup.

Line 109-111 makes $HOME/%USERPROFILE% mandatory for every run() invocation. According to model.rs line 286, hermes_hooks_path_for_scope returns None when Hermes isn't selected, and ConfigScope::Project uses cwd not home. This means a user running nemo-flow config to set up only Codex at project scope should succeed without $HOME, but currently fails.

Consider deferring home_dir() resolution until it's actually needed:

let cwd = std::env::current_dir()?;
let home = if matches!(answers.scope, ConfigScope::Global | ConfigScope::Both)
    || answers.agents.contains(&CodingAgent::Hermes)
{
    Some(home_dir().ok_or_else(|| {
        CliError::Config("cannot determine home directory (set $HOME or $USERPROFILE)".into())
    })?)
} else {
    None
};

Then pass home.as_deref() to functions that accept Option<&Path>.

Verify whether save_config, preview_paths, and hermes_hook_targets can operate without home for ConfigScope::Project:

#!/bin/bash
# Check function signatures and usage of home parameter in model.rs
rg -nP 'fn (save_config|preview_paths|hermes_hook_targets|hermes_hooks_path_for_scope)' crates/cli/src/setup/model.rs -A5
🤖 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 `@crates/cli/src/setup.rs` around lines 98 - 139, The run function currently
forces home_dir() for all invocations which breaks project-scoped non-Hermes
setups; change run to compute cwd as before but only resolve home_dir() into an
Option<PathBuf> when needed (when answers.scope is Global or Both or
answers.agents contains CodingAgent::Hermes), then pass home.as_deref()
(Option<&Path>) into hermes_hooks_path_for_scope, preview_paths,
hermes_hook_targets, save_config and install_hermes_hooks so project-only flows
don't require $HOME; if any of those functions (hermes_hooks_path_for_scope,
preview_paths, hermes_hook_targets, save_config, install_hermes_hooks) have
non-Option home parameters update their signatures/usage to accept Option<&Path>
accordingly.
🤖 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.

Inline comments:
In `@crates/cli/src/plugins/editor_model.rs`:
- Around line 76-95: The calls to set_struct_field and set_section_field in
ensure_section, toggle_section, and reset_section are currently discarding
Result errors with `let _ = ...`; change these to handle errors instead—either
propagate the Result by updating the function signatures of ensure_section,
toggle_section, and reset_section to return Result<(), E> (forwarding the error
from set_struct_field/set_section_field), or at minimum log failures using the
project's logging (e.g., tracing::error!) including context like the
section.name and the error; if you choose to keep panics-free invariants, add a
clear comment on why the Err case is unreachable and use .expect(...) with an
explanatory message. Ensure you update callers if you propagate errors and
reference the set_struct_field and set_section_field calls inside those three
functions when making the change.

In `@crates/cli/tests/coverage/server_tests.rs`:
- Around line 724-727: The test currently only asserts the constant path/header
and a returned constant, so update the upstream stub used in
crates/cli/tests/coverage/server_tests.rs to echo back the incoming request JSON
(instead of returning a fixed constant) and then add assertions that the request
payload fields are passed through unchanged (e.g., assert body["model"],
body["messages"] and other expected payload keys like "input_tokens" or "model"
exist and match the inputs you send in the test). Locate the handler that
returns the constant (the stub around where body["path"] and body["x_api_key"]
are asserted) and change it to return the received JSON, then extend the test
assertions to verify payload passthrough for both the primary case and the
similar block around the other assertion range mentioned.

---

Outside diff comments:
In `@crates/cli/tests/coverage/completions_install_tests.rs`:
- Around line 83-127: Add brief SAFETY comments to the unsafe blocks in the test
install_writes_detected_shell_completion and the helper restore_env explaining
why the unsafe env mutations are sound: state that ENV_LOCK serializes access so
only one thread mutates environment at a time during the test, and that values
passed to std::env::set_var/remove_var are valid for the duration of the call;
reference the ENV_LOCK mutex, the install_writes_detected_shell_completion test
function, and the restore_env function in the comment so reviewers can locate
the rationale quickly.

---

Duplicate comments:
In `@crates/cli/src/setup.rs`:
- Around line 98-139: The run function currently forces home_dir() for all
invocations which breaks project-scoped non-Hermes setups; change run to compute
cwd as before but only resolve home_dir() into an Option<PathBuf> when needed
(when answers.scope is Global or Both or answers.agents contains
CodingAgent::Hermes), then pass home.as_deref() (Option<&Path>) into
hermes_hooks_path_for_scope, preview_paths, hermes_hook_targets, save_config and
install_hermes_hooks so project-only flows don't require $HOME; if any of those
functions (hermes_hooks_path_for_scope, preview_paths, hermes_hook_targets,
save_config, install_hermes_hooks) have non-Option home parameters update their
signatures/usage to accept Option<&Path> accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: b889938e-158b-4600-9691-2e2ed33bc09e

📥 Commits

Reviewing files that changed from the base of the PR and between ba8da19 and fd53de3.

📒 Files selected for processing (12)
  • codecov.yml
  • crates/cli/src/plugins.rs
  • crates/cli/src/plugins/config_io.rs
  • crates/cli/src/plugins/editor_model.rs
  • crates/cli/src/setup.rs
  • crates/cli/src/setup/model.rs
  • crates/cli/tests/cli_tests.rs
  • crates/cli/tests/coverage/completions_install_tests.rs
  • crates/cli/tests/coverage/doctor_tests.rs
  • crates/cli/tests/coverage/plugins_tests.rs
  • crates/cli/tests/coverage/server_tests.rs
  • crates/cli/tests/coverage/setup_tests.rs
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Check / Run
🧰 Additional context used
📓 Path-based instructions (7)
**/*.rs

📄 CodeRabbit inference engine (.agents/skills/test-ffi-surface/SKILL.md)

**/*.rs: Run cargo fmt --all for FFI work as it is Rust work
Run just test-rust for FFI validation
Run cargo clippy --workspace --all-targets -- -D warnings to enforce warnings-as-errors linting

**/*.rs: Run cargo fmt --all for Rust code formatting
Run cargo clippy --workspace --all-targets -- -D warnings to enforce Rust linting with no warnings
Run just test-rust as the shared-runtime build/test wrapper for Rust changes

Use Rust snake_case naming convention for Rust code

**/*.rs: Any Rust change must run just test-rust
Any Rust change must run cargo fmt --all
Any Rust change must run cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all for Rust code formatting when Node changes touch Rust files
Run cargo clippy --workspace --all-targets -- -D warnings to enforce strict linting when Rust files changed as part of Node work

**/*.rs: Always run just test-rust when any Rust code changes
Always run cargo fmt --all when any Rust code changes
Always run cargo clippy --workspace --all-targets -- -D warnings when any Rust code changes

Files:

  • crates/cli/tests/coverage/server_tests.rs
  • crates/cli/tests/coverage/completions_install_tests.rs
  • crates/cli/tests/coverage/setup_tests.rs
  • crates/cli/tests/cli_tests.rs
  • crates/cli/tests/coverage/plugins_tests.rs
  • crates/cli/tests/coverage/doctor_tests.rs
  • crates/cli/src/setup.rs
  • crates/cli/src/plugins.rs
  • crates/cli/src/plugins/config_io.rs
  • crates/cli/src/setup/model.rs
  • crates/cli/src/plugins/editor_model.rs
**/*.{rs,go,js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Include SPDX license headers in all Rust, Go, JavaScript, and TypeScript source files using C-style comment syntax

Files:

  • crates/cli/tests/coverage/server_tests.rs
  • crates/cli/tests/coverage/completions_install_tests.rs
  • crates/cli/tests/coverage/setup_tests.rs
  • crates/cli/tests/cli_tests.rs
  • crates/cli/tests/coverage/plugins_tests.rs
  • crates/cli/tests/coverage/doctor_tests.rs
  • crates/cli/src/setup.rs
  • crates/cli/src/plugins.rs
  • crates/cli/src/plugins/config_io.rs
  • crates/cli/src/setup/model.rs
  • crates/cli/src/plugins/editor_model.rs
**/*.{rs,py,go,js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Use SONAR_IGNORE_START / SONAR_IGNORE_END markers only for documented false positives that cannot be resolved in code; keep ignored blocks small, add explanatory comments, and require reviewer sign-off

Files:

  • crates/cli/tests/coverage/server_tests.rs
  • crates/cli/tests/coverage/completions_install_tests.rs
  • crates/cli/tests/coverage/setup_tests.rs
  • crates/cli/tests/cli_tests.rs
  • crates/cli/tests/coverage/plugins_tests.rs
  • crates/cli/tests/coverage/doctor_tests.rs
  • crates/cli/src/setup.rs
  • crates/cli/src/plugins.rs
  • crates/cli/src/plugins/config_io.rs
  • crates/cli/src/setup/model.rs
  • crates/cli/src/plugins/editor_model.rs
**/*.{js,ts,tsx,jsx,py,rs,go,java,c,cpp,h,cc,cxx,cs,rb,php,swift,kt}

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Changed files must be formatted with the language-native formatter

Files:

  • crates/cli/tests/coverage/server_tests.rs
  • crates/cli/tests/coverage/completions_install_tests.rs
  • crates/cli/tests/coverage/setup_tests.rs
  • crates/cli/tests/cli_tests.rs
  • crates/cli/tests/coverage/plugins_tests.rs
  • crates/cli/tests/coverage/doctor_tests.rs
  • crates/cli/src/setup.rs
  • crates/cli/src/plugins.rs
  • crates/cli/src/plugins/config_io.rs
  • crates/cli/src/setup/model.rs
  • crates/cli/src/plugins/editor_model.rs
**/*.{py,js,ts,tsx,go,rs,md}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Format changed files with the language-native formatter before the final lint/test pass

Files:

  • crates/cli/tests/coverage/server_tests.rs
  • crates/cli/tests/coverage/completions_install_tests.rs
  • crates/cli/tests/coverage/setup_tests.rs
  • crates/cli/tests/cli_tests.rs
  • crates/cli/tests/coverage/plugins_tests.rs
  • crates/cli/tests/coverage/doctor_tests.rs
  • crates/cli/src/setup.rs
  • crates/cli/src/plugins.rs
  • crates/cli/src/plugins/config_io.rs
  • crates/cli/src/setup/model.rs
  • crates/cli/src/plugins/editor_model.rs
**/*.{rs,py,js,ts,tsx,go}

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

During iteration, prefer uv run pre-commit run --files <changed files...> for targeted validation

Files:

  • crates/cli/tests/coverage/server_tests.rs
  • crates/cli/tests/coverage/completions_install_tests.rs
  • crates/cli/tests/coverage/setup_tests.rs
  • crates/cli/tests/cli_tests.rs
  • crates/cli/tests/coverage/plugins_tests.rs
  • crates/cli/tests/coverage/doctor_tests.rs
  • crates/cli/src/setup.rs
  • crates/cli/src/plugins.rs
  • crates/cli/src/plugins/config_io.rs
  • crates/cli/src/setup/model.rs
  • crates/cli/src/plugins/editor_model.rs
{crates/**/tests/**,python/tests/**,go/nemo_flow/**/*_test.go}

⚙️ CodeRabbit configuration file

{crates/**/tests/**,python/tests/**,go/nemo_flow/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.

Files:

  • crates/cli/tests/coverage/server_tests.rs
  • crates/cli/tests/coverage/completions_install_tests.rs
  • crates/cli/tests/coverage/setup_tests.rs
  • crates/cli/tests/cli_tests.rs
  • crates/cli/tests/coverage/plugins_tests.rs
  • crates/cli/tests/coverage/doctor_tests.rs
🔇 Additional comments (39)
codecov.yml (2)

57-66: LGTM!


126-129: LGTM!

crates/cli/tests/coverage/doctor_tests.rs (2)

11-44: LGTM!


277-413: LGTM!

crates/cli/src/setup/model.rs (5)

148-156: XDG_CONFIG_HOME precedence matches spec.

The global_config_dir function correctly implements XDG Base Directory Specification: prefer $XDG_CONFIG_HOME/nemo-flow, fall back to ~/.config/nemo-flow. This ensures hermetic test behavior when tests provide a temp home without setting XDG_CONFIG_HOME.


161-184: LGTM!


195-218: Defensive recovery from malformed agents value prevents panic.

Lines 208-212 correctly handle the case where existing config has agents = "literal" or agents = [...] instead of a table. The defensive check replaces non-table values with a fresh table, degrading gracefully to overwrite rather than panicking. The expect on line 216 is safe due to the guard above.


226-273: LGTM!


296-317: Idempotent hook installation handles missing files correctly.

Lines 304-308 properly distinguish ENOENT (file missing, use empty string) from other I/O errors (propagate). The merge preserves existing hooks while appending NeMo Flow hooks only when missing, ensuring idempotent setup.

crates/cli/tests/coverage/setup_tests.rs (4)

51-72: LGTM!


268-316: LGTM!


318-351: LGTM!


380-460: LGTM!

crates/cli/tests/coverage/plugins_tests.rs (2)

9-40: LGTM!


196-356: LGTM!

crates/cli/tests/cli_tests.rs (1)

35-98: LGTM!

crates/cli/src/plugins/editor_model.rs (11)

263-304: Let-chains usage requires Rust 1.76+.

Lines 286-292 use let-chains. Same verification applies as noted in config_io.rs.


1-13: LGTM!


15-42: LGTM!


44-74: LGTM!


97-131: LGTM!


133-160: LGTM!


162-182: LGTM!


184-226: LGTM!


228-261: LGTM!


263-321: LGTM!


323-385: LGTM!

crates/cli/src/plugins.rs (3)

5-8: LGTM!

Also applies to: 11-11, 17-18, 20-20, 23-27


424-430: LGTM!


610-612: LGTM!

crates/cli/src/plugins/config_io.rs (9)

1-16: LGTM!


18-42: LGTM!


44-57: LGTM!


59-78: LGTM!


80-94: LGTM!


96-115: LGTM!


117-132: LGTM!


154-174: LGTM!


134-152: No verification needed—code is valid for the configured edition.

The project uses edition 2024 (defined in workspace Cargo.toml), which has native support for let-chains without requiring any feature gate. The let-chains syntax at lines 145–146 is correct and supported.

			> Likely an incorrect or invalid review comment.

Comment thread crates/cli/src/plugins/editor_model.rs
Comment thread crates/cli/tests/coverage/server_tests.rs
@willkill07 willkill07 merged commit 8a291f1 into NVIDIA:release/0.2 May 14, 2026
57 of 59 checks passed
@willkill07 willkill07 deleted the wkk_refactor-cli-coverage branch May 14, 2026 19:17
willkill07 added a commit that referenced this pull request May 15, 2026
* fix: address outstanding sonar issues (#104)

#### Overview

Addresses the open Sonar maintainability findings reported on `release/0.2` by reducing Rust cognitive complexity and replacing duplicated Go test literals.

- [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does not duplicate existing work.

#### Details

- Split observability doctor and plugin editor control-flow into smaller helper functions.
- Split OpenAI Responses request encoding overlays into focused helper functions.
- Added constants for duplicated Go observability test literals.

#### Where should the reviewer start?

Start with `crates/core/src/codec/openai_responses.rs`, then review the smaller CLI refactors in `crates/cli/src/doctor.rs` and `crates/cli/src/plugins.rs`.

#### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

- Relates to: none




## Summary by CodeRabbit

* **Refactor**
  * Enhanced code organization in observability component checking, plugin configuration editing, and OpenAI response encoding for improved internal structure and maintainability.

* **Tests**
  * Standardized error message formatting in observability plugin tests for improved consistency and clearer diagnostic output during test failures.



[![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/NVIDIA/NeMo-Flow/pull/104)

Authors:
  - Will Killian (https://github.com/willkill07)

Approvers:
  - Ajay Thorve (https://github.com/AjayThorve)

URL: #104

* test: isolate CLI config override tests (#105)

#### Overview

Isolates CLI config override unit tests from developer-level NeMo Flow configuration discovered through the normal user config path.

- [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does not duplicate existing work.

#### Details

- Adds a temp-scoped explicit config path helper for config tests that require no implicit user or project config discovery.
- Updates the affected override tests to use that explicit path instead of relying on ambient process configuration.

#### Where should the reviewer start?

Start with `crates/cli/tests/coverage/config_tests.rs`, especially the tests around CLI plugin config overrides.

#### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

- Relates to: none




## Summary by CodeRabbit

* **Tests**
  * Enhanced test infrastructure for configuration resolution by improving test isolation and setup processes.



[![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/NVIDIA/NeMo-Flow/pull/105)

Authors:
  - Will Killian (https://github.com/willkill07)

Approvers:
  - Ajay Thorve (https://github.com/AjayThorve)

URL: #105

* chore: keep OpenClaw dependency in lockstep (#107)

#### Overview

Keep the OpenClaw plugin package dependency on `nemo-flow-node` aligned with the package version emitted by repository versioning and packaging workflows.

- [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does not duplicate existing work.

#### Details

- Change `nemo-flow-openclaw` to depend on the exact checked-in `nemo-flow-node` version.
- Add a `justfile` helper that updates package dependency versions in both `package.json` and `package-lock.json`.
- Wire the dependency update into `set-version`, `package-node`, and `package-openclaw` so prerelease package builds keep the Node and OpenClaw versions together.
- Align OpenClaw non-tag CI package version suffixing with the Node package workflow.

Validation run:

- `just set-version 0.2.0-alpha.20260514`, verified OpenClaw's `nemo-flow-node` dependency updated without dependency success logs, then restored with `just set-version 0.2.0`.
- `npm install --workspace=nemo-flow-node --ignore-scripts`
- `npm install --workspace=nemo-flow-openclaw --ignore-scripts`
- `npm run typecheck --workspace=nemo-flow-openclaw`
- `npm run pack:check --workspace=nemo-flow-openclaw`
- `just --list`
- `git diff --check`
- Commit-time pre-commit hooks passed for the staged files.

#### Where should the reviewer start?

Start with `justfile`, especially the new package dependency version helper and its calls from `set_node_package_versions`, `package-node`, and `package-openclaw`.

#### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

- Relates to: none




## Summary by CodeRabbit

## Release Notes

* **Chores**
  * Refined OpenClaw package versioning format for improved clarity
  * Pinned nemo-flow-node dependency to a stable version for enhanced reliability
  * Improved build and packaging tooling to ensure consistent dependency alignment



[![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/NVIDIA/NeMo-Flow/pull/107)

Authors:
  - Will Killian (https://github.com/willkill07)

Approvers:
  - https://github.com/Salonijain27

URL: #107

* refactor: improve CLI coverage structure (#108)

#### Overview

Refactors the CLI coverage-heavy interactive setup/plugin editors so testable logic lives in focused helper modules, then adds coverage around the extracted behavior and related CLI paths.

- [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does not duplicate existing work.

#### Details

- Split plugin config file handling and Observability editor state helpers out of `plugins.rs` into testable modules.
- Split setup config/model/file helper logic out of `setup.rs` into `setup/model.rs`.
- Added focused coverage for CLI setup, plugin editing models, doctor formatting/check helpers, completion install helpers, server gateway forwarding paths, and CLI smoke behavior.
- Updated Codecov component reporting from Gateway Runtime to CLI, set the CLI target to 88%, and excluded only the remaining TTY prompt shells.
- Added module guidance so future testable logic does not go back into the interactive prompt files.

#### Where should the reviewer start?

Start with `crates/cli/src/plugins.rs` and `crates/cli/src/setup.rs` to see the orchestration-only boundary, then review `crates/cli/src/plugins/editor_model.rs`, `crates/cli/src/plugins/config_io.rs`, and `crates/cli/src/setup/model.rs` for the extracted testable logic.

Validation run locally:

- `cargo fmt --all`
- `cargo test -p nemo-flow-cli` with isolated `XDG_CONFIG_HOME`
- `cargo clippy --workspace --all-targets -- -D warnings`
- `just test-rust` with isolated `XDG_CONFIG_HOME`
- `cargo llvm-cov --package nemo-flow-cli --summary-only ...`
- commit hook pre-commit checks, including cargo fmt, cargo clippy, and cargo check

#### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

- Relates to: none


## Summary by CodeRabbit

* **New Features**
  * Plugin config preview, validation, and safer save/merge behavior; clearer scope selection and Hermes hook handling in setup.

* **Chores / Refactor**
  * Reorganized CLI internals into smaller, testable modules to make interactive editors and the setup wizard more reliable.

* **Tests**
  * Added extensive CLI unit and integration tests covering agents, doctor, completions, plugin editor TTY behavior, setup flows, and gateway/server forwarding.

* **Chores**
  * Updated Codecov to include CLI coverage and exclude interactive prompt loops.

Signed-off-by: Will Killian <wkillian@nvidia.com>

* ci: fold OpenClaw checks into Node workflow (#106)

#### Overview

Fold OpenClaw validation into the existing Node.js CI workflow as a conditional step, and make `just test-openclaw` run the live smoke coverage path.

- [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does not duplicate existing work.

#### Details

- Add a `run_openclaw` input to the reusable Node.js workflow.
- Run OpenClaw integration checks as a conditional step across the full Node test matrix.
- Remove the separate OpenClaw workflow call and workflow file.
- Keep OpenClaw package artifact creation inside the existing Node package job while leaving Node package steps gated by `run_package`.
- Add the live smoke test path to `just test-openclaw` and document the target in contributor testing guidance.

#### Where should the reviewer start?

Start with `.github/workflows/ci_node.yml`, especially the conditional OpenClaw test step in the Node test job and the package-job gating.

#### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

- Relates to: none


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **Tests**
  * Added live-run OpenClaw smoke tests and a helper script to run them.
  * OpenClaw integration checks now run conditionally inside the Node.js test flow.
  * Test suites updated to use compiled test artifacts and adjusted import paths.

* **Chores**
  * Removed standalone OpenClaw CI job; its checks and optional packaging were folded into the Node.js workflow and gated by inputs.
  * OpenClaw packaging and artifact upload are now conditional.

* **Documentation**
  * Testing guide and integration README updated with live-test target and artifact locations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

* feat: update OpenClaw patch to use new config shape (#111)

#### Overview

This PR updates the OpenClaw patch to be aligned with `main`

- [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does not duplicate existing work.

#### Details

<!-- Describe the changes made in this PR. -->

#### Where should the reviewer start?

<!-- Point to the most important file, test, or design decision. -->

#### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

- Closes #

* feat: Add Deep Agents integration (#90)

#### Overview
* Primary entry point for end-users is the `add_nemo_flow_integration` method, which adds NeMo Flow middleware to the agent and subagents (if any).
* Emit a mark when skills are loaded and HITL events
* `langgraph` is promoted from a transitive dep to a direct-dep in the `langchain` extra since `python/nemo_flow/integrations/langchain/_serialization.py` now imports from `langgraph`
* Adds work-around for installing OpenSSL on Windows-Arm CI runners

- [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does not duplicate existing work.

#### Details



#### Where should the reviewer start?



#### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

- Closes #



## Summary by CodeRabbit

* **New Features**
  * Deep Agents integration: observability for agent runs, tool calls, filesystem/sandbox operations, human-in-the-loop events, backend instrumentation, and middleware marks.

* **Documentation**
  * Added Deep Agents integration README with setup, usage, and observed-event examples.

* **Tests**
  * New integration and end-to-end tests covering middleware, backend instrumentation, sandbox behavior, and HITL flows; added shared test fixture.

* **Chores**
  * Added optional Deep Agents dependency group and regenerated third‑party attributions/licenses.

* **CI**
  * Updated CI and dev sync steps to include Deep Agents extras and platform-specific setup.



[![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/NVIDIA/NeMo-Flow/pull/90)

Authors:
  - David Gardner (https://github.com/dagardner-nv)

Approvers:
  - Will Killian (https://github.com/willkill07)
  - https://github.com/Salonijain27

URL: #90

* chore: refresh dependency locks (#112)

#### Overview

Refresh dependency locks and runtime compatibility wiring for the `release/0.2` branch.

- [x] I confirm this contribution is my own work, or I have the right to submit it under this project license.
- [x] I searched existing issues and open pull requests, and this does not duplicate existing work.

#### Details

- Updates Python optional integration constraints and lockfile entries for the release branch.
- Updates OpenClaw peer compatibility to `2026.5.12` and syncs the local hook type mirror with the current session end reasons.
- Adjusts Rust reqwest/rustls provider configuration and OTLP HTTP client selection so TLS and exporter initialization remain stable while unused optional transport packages stay out of the lockfile.
- Makes Node attribution generation lockfile-driven so platform-gated optional packages are listed consistently across CI and local machines.
- Pulls Node license text from integrity-checked locked npm artifacts when packages are not installed on the current platform.
- Regenerates Python and Node attribution files from the refreshed lockfiles.

Validation run:
- `cargo test -p nemo-flow-cli`
- `cargo check -p nemo-flow --features otel`
- `cargo check -p nemo-flow --features otel,openinference`
- `cargo test -p nemo-flow http_config_exports_scope_push_pop_and_marks_without_tokio_runtime -- --nocapture`
- `npm test --workspace integrations/openclaw`
- `uv run --extra langgraph --extra langchain-nvidia pytest python/tests/integrations/langchain python/tests/integrations/langgraph third_party/langgraph_tests`
- `npm audit --ignore-scripts`
- `cargo fmt --all --check`
- `pre-commit run --files scripts/licensing/attributions_lockfile_md.py ATTRIBUTIONS-Node.md package-lock.json`
- signed commit pre-commit suite

#### Where should the reviewer start?

Start with `scripts/licensing/attributions_lockfile_md.py`, `crates/cli/src/tls.rs`, `crates/core/Cargo.toml`, and `integrations/openclaw/package.json` to review the generator, runtime, and integration compatibility changes before the regenerated lockfile and attribution diffs.

#### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

- Relates to: none


## Summary by CodeRabbit

* **Dependencies**
  * Bumped several Python packages (langchain, langchain-core, langgraph, langgraph-*, urllib3) and raised OpenClaw compatibility to 2026.5.12.
* **New Features**
  * Added "shutdown" and "restart" as session termination reasons.
* **Chores**
  * Ensure TLS/crypto provider is initialized before network operations across CLI and services.
* **Documentation**
  * Refreshed third‑party attributions and improved license extraction for Node/Python packages.



[![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/NVIDIA/NeMo-Flow/pull/112)

Authors:
  - Will Killian (https://github.com/willkill07)

Approvers:
  - David Gardner (https://github.com/dagardner-nv)
  - https://github.com/Salonijain27

URL: #112

* fix: support Cursor CLI hook config (#109)

#### Overview

Fix Cursor CLI hook configuration so current `cursor-agent` builds can execute NeMo Flow hook commands, and document the remaining Cursor CLI hook coverage limits.

- [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does not duplicate existing work.

#### Details

- Generate Cursor `.cursor/hooks.json` entries as direct command entries with top-level `"version": 1`.
- Preserve that Cursor-compatible shape when `nemo-flow run -- cursor-agent` temporarily patches project hooks.
- Update `nemo-flow doctor cursor` to reject nested Cursor hook groups and missing or non-`1` top-level version fields.
- Trim nullable fields from Cursor permission responses.
- Update Cursor integration docs and packaged hooks to state the CLI limitation plainly: current Cursor CLI hook coverage is narrower than Cursor IDE hook coverage.

#### Where should the reviewer start?

Start with `crates/cli/src/installer.rs` for the hook-shape change, then `crates/cli/src/doctor.rs` for validation of user-managed Cursor hook files.

#### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

- Closes https://linear.app/nvidia/issue/NMF-122/fix-cursor-cli-hook-config-and-document-stream-json-limitation



## Summary by CodeRabbit

* **Refactor**
  * Standardized Cursor hook JSON to require a top-level version (1) and direct command entries; merged/generated hook files now enforce this shape.

* **New Features**
  * Added stricter validation for Cursor hook files with clear, actionable status messages and test coverage.

* **Bug Fixes**
  * Cursor hook responses/endpoints no longer include legacy message fields.

* **Documentation**
  * Expanded Cursor integration and troubleshooting guidance, plus CLI verification steps.



[![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/NVIDIA/NeMo-Flow/pull/109)

Authors:
  - Ajay Thorve (https://github.com/AjayThorve)

Approvers:
  - Will Killian (https://github.com/willkill07)

URL: #109

---------

Signed-off-by: Will Killian <wkillian@nvidia.com>
Co-authored-by: Will Killian <2007799+willkill07@users.noreply.github.com>
Co-authored-by: David Gardner <96306125+dagardner-nv@users.noreply.github.com>
Co-authored-by: Ajay Thorve <AjayThorve@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Improvement improvement to existing functionality lang:rust PR changes/introduces Rust code size:XL PR is extra large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants