Skip to content

Comments

feat(examples): add CLI production smoke workflow ,black-box tests and also updating Readme #234

Merged
lijingrs merged 6 commits intomofa-org:mainfrom
Rahul-2k4:feature/cli-production-smoke-example
Feb 22, 2026
Merged

feat(examples): add CLI production smoke workflow ,black-box tests and also updating Readme #234
lijingrs merged 6 commits intomofa-org:mainfrom
Rahul-2k4:feature/cli-production-smoke-example

Conversation

@Rahul-2k4
Copy link
Contributor

@Rahul-2k4 Rahul-2k4 commented Feb 22, 2026

Delivers end-to-end CLI production readiness verification: a black-box smoke crate, legacy flag compatibility, safer agent stop semantics, and TDD-style test hardening. Resolves two clippy::collapsible_if warnings introduced in the feature commit.

follow up for #219 to fix the add CLI production smoke workflow and black-box tests and also adding suitable readme bilingually

📋 Summary

Adds examples/cli_production_smoke as a runnable, subprocess-based smoke suite for the mofa binary. Restores legacy --output/-o compatibility with normalization logic. Hardens mofa agent stop to require --force-persisted-stop when the runtime registry is absent. Fixes clippy::collapsible_if warnings in stop.rs and uninstall.rs.

🧠 Context

CLI commands run in separate processes, so the runtime registry is empty on fresh startup. Without an explicit guard, mofa agent stop could silently mutate persisted state in ambiguous situations. Legacy --output/-o flags were also at risk after introducing --output-format, which could break existing scripts.

🛠️ Changes

  • examples/cli_production_smoke: new workspace crate; lib.rs exposes 6 composable smoke steps; main.rs provides runnable reporting; tests/smoke.rs includes subprocess-based integration tests with isolated XDG_* dirs
  • crates/mofa-cli/src/main.rs: normalize_legacy_output_flags() rewrites legacy --output/-o <format> to --output-format before clap parsing
  • crates/mofa-cli/src/main.rs: intentionally excludes rewriting -o under session show and session export, because those are local subcommand flags
  • crates/mofa-cli/src/commands/agent/stop.rs: requires --force-persisted-stop to mark persisted state as Stopped when the agent is absent from runtime registry; otherwise returns actionable error
  • crates/mofa-cli/src/commands/agent/stop.rs and crates/mofa-cli/src/commands/plugin/uninstall.rs: collapsed nested if { if let } into let-chain form to satisfy clippy::collapsible_if
  • README.md and README_cn.md: added "CLI Production Smoke Example" section with coverage and run instructions

🧪 How you Tested

  1. cargo test -p mofa-cli
    50 unit + 4 integration tests passed.
  2. cargo clippy -p mofa-cli --no-deps -- -D warnings
    Zero warnings for the mofa-cli crate.
  3. cargo check --manifest-path examples/Cargo.toml -p cli_production_smoke
    Example crate compiles cleanly.
  4. cargo test --manifest-path examples/Cargo.toml -p cli_production_smoke --test smoke
    Smoke integration tests passed.

Logs (if applicable)

test result: ok. 50 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

⚠️ Breaking Changes

  • No breaking changes
  • Breaking change (describe below)

mofa agent stop <id> without --force-persisted-stop now errors when the agent exists only in persisted store (not runtime registry). Scripts relying on silent persisted-state mutation must add --force-persisted-stop.

🧹 Checklist

Code Quality

  • Code follows Rust idioms and project conventions
  • cargo fmt run
  • cargo clippy passes without warnings

Testing

  • Tests added/updated
  • cargo test passes locally without any error

Documentation

  • Public APIs documented
  • README / docs updated (if needed)

PR Hygiene

  • PR is small and focused (one logical change)
  • Branch is up to date with main
  • No unrelated commits
  • Commit messages explain why, not only what

🧩 Additional Notes for Reviewers

  • Smoke tests require the mofa binary to be prebuilt (cargo build -p mofa-cli) when MOFA_BIN is not provided.
  • normalize_legacy_output_flags intentionally does not rewrite -o under session show or session export because those flags are local aliases, not global output format.
  • Let-chain style (if x && let Some(y) = z) is used for clippy compliance; workspace edition is already 2024.

@Rahul-2k4
Copy link
Contributor Author

Rahul-2k4 commented Feb 22, 2026

hi @lijingrs been working on this pr as per the follow up for #219 i have done review and now assigned copilot for a last cross check lets if it finds something concerning which imight have left or missed out 🚀

@Rahul-2k4 Rahul-2k4 changed the title feat(examples): add CLI production smoke workflow and black-box tests feat(examples): add CLI production smoke workflow ,black-box tests and also updating Readme Feb 22, 2026
Copilot AI and others added 2 commits February 22, 2026 13:53
- normalize_legacy_output_flags: support --output=json equals-sign form (Fix 1)
- normalize_legacy_output_flags: add session subcommand awareness so
  session list -o json normalizes while show/export preserve their local -o (Fix 2)
- cli.rs session show --format: use hidden short_alias instead of visible_short_alias (Fix 3)
- extract_json_payload: use serde_json streaming Deserializer to tolerate trailing text (Fix 4)
- workspace_root(): scan upward for outermost [workspace] Cargo.toml; add MOFA_WORKSPACE_ROOT override (Fix 5)
- Extract is_output_format_value() helper to deduplicate format-value matching
- Add 9 new unit tests for the normalize fixes"

Co-authored-by: Rahul-2k4 <216878448+Rahul-2k4@users.noreply.github.com>
fix(cli): address 5 review findings from PR mofa-org#234 — legacy flag normalization gaps, hidden alias, robust JSON parsing, portable workspace root
@Rahul-2k4
Copy link
Contributor Author

hi @lijingrs now its all implemented and cross verified ready to be merged 🚀
thank you

@lijingrs lijingrs merged commit ab4f53a into mofa-org:main Feb 22, 2026
5 checks passed
@Rahul-2k4
Copy link
Contributor Author

hey @lijingrs , u got something in mind i can work upon rn ? or should i do it myself . would appreciate if u do ask me for something

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.

3 participants