feat(examples): add CLI production smoke workflow ,black-box tests and also updating Readme #234
Merged
lijingrs merged 6 commits intomofa-org:mainfrom Feb 22, 2026
Conversation
Co-authored-by: Rahul-2k4 <216878448+Rahul-2k4@users.noreply.github.com>
12 tasks
Contributor
Author
- 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
Contributor
Author
|
hi @lijingrs now its all implemented and cross verified ready to be merged 🚀 |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_ifwarnings 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_smokeas a runnable, subprocess-based smoke suite for themofabinary. Restores legacy--output/-ocompatibility with normalization logic. Hardensmofa agent stopto require--force-persisted-stopwhen the runtime registry is absent. Fixesclippy::collapsible_ifwarnings instop.rsanduninstall.rs.🧠 Context
CLI commands run in separate processes, so the runtime registry is empty on fresh startup. Without an explicit guard,
mofa agent stopcould silently mutate persisted state in ambiguous situations. Legacy--output/-oflags were also at risk after introducing--output-format, which could break existing scripts.🛠️ Changes
examples/cli_production_smoke: new workspace crate;lib.rsexposes 6 composable smoke steps;main.rsprovides runnable reporting;tests/smoke.rsincludes subprocess-based integration tests with isolatedXDG_*dirscrates/mofa-cli/src/main.rs:normalize_legacy_output_flags()rewrites legacy--output/-o <format>to--output-formatbefore clap parsingcrates/mofa-cli/src/main.rs: intentionally excludes rewriting-oundersession showandsession export, because those are local subcommand flagscrates/mofa-cli/src/commands/agent/stop.rs: requires--force-persisted-stopto mark persisted state asStoppedwhen the agent is absent from runtime registry; otherwise returns actionable errorcrates/mofa-cli/src/commands/agent/stop.rsandcrates/mofa-cli/src/commands/plugin/uninstall.rs: collapsed nestedif { if let }into let-chain form to satisfyclippy::collapsible_ifREADME.mdandREADME_cn.md: added "CLI Production Smoke Example" section with coverage and run instructions🧪 How you Tested
cargo test -p mofa-cli50unit +4integration tests passed.cargo clippy -p mofa-cli --no-deps -- -D warningsZero warnings for the
mofa-clicrate.cargo check --manifest-path examples/Cargo.toml -p cli_production_smokeExample crate compiles cleanly.
cargo test --manifest-path examples/Cargo.toml -p cli_production_smoke --test smokeSmoke integration tests passed.
Logs (if applicable)
mofa agent stop <id>without--force-persisted-stopnow 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
cargo fmtruncargo clippypasses without warningsTesting
cargo testpasses locally without any errorDocumentation
PR Hygiene
main🧩 Additional Notes for Reviewers
mofabinary to be prebuilt (cargo build -p mofa-cli) whenMOFA_BINis not provided.normalize_legacy_output_flagsintentionally does not rewrite-oundersession showorsession exportbecause those flags are local aliases, not global output format.if x && let Some(y) = z) is used for clippy compliance; workspace edition is already2024.