Summary
The global --json flag is advertised at root (extropy --help) and in docs as a per-command machine-output override, but most command handlers ignore it and only honor cli.mode=agent.
Repro
- Set human mode:
extropy config set cli.mode human
- Run inside a valid study:
cd examples/study-02
extropy --json results summary
- Observe output is human-formatted text, not JSON.
Additional behavior:
extropy results --json fails with No such option: --json (Click/Typer global option placement behavior).
- Some error paths (e.g., outside-study DB resolution in
query) print rich text errors even when --json is passed.
Expected
--json should force JSON output regardless of cli.mode.
- Error paths should also return structured JSON in JSON mode.
- Docs/UX should clearly reflect whether
--json must be root-level (extropy --json <cmd>) or accepted on subcommands.
Likely Root Cause
Most command modules derive output mode via is_agent_mode() only, instead of get_json_mode() or is_agent_mode().
Observed references:
extropy/cli/commands/{results,query,sample,network,scenario,persona,spec,simulate,chat}.py
extropy/cli/commands/validate.py already uses helper logic combining both modes.
Suggested Fix
- Introduce common helper (e.g.
_json_enabled()) in CLI layer: get_json_mode() or is_agent_mode().
- Replace command-local
agent_mode = is_agent_mode() with helper.
- Route early resolver failures (study detection, etc.) through
Output in JSON mode.
- Add regression tests:
cli.mode=human + root --json returns JSON for representative commands.
- outside-study errors return JSON when
--json passed.
- Update docs to clarify root option placement (
extropy --json <command>) and/or add per-command passthrough if desired.
Severity
Medium-high (automation contract regression). Not simulation-core blocking, but breaks non-interactive pipelines that depend on explicit --json overrides.
Summary
The global
--jsonflag is advertised at root (extropy --help) and in docs as a per-command machine-output override, but most command handlers ignore it and only honorcli.mode=agent.Repro
extropy config set cli.mode humancd examples/study-02 extropy --json results summaryAdditional behavior:
extropy results --jsonfails withNo such option: --json(Click/Typer global option placement behavior).query) print rich text errors even when--jsonis passed.Expected
--jsonshould force JSON output regardless ofcli.mode.--jsonmust be root-level (extropy --json <cmd>) or accepted on subcommands.Likely Root Cause
Most command modules derive output mode via
is_agent_mode()only, instead ofget_json_mode() or is_agent_mode().Observed references:
extropy/cli/commands/{results,query,sample,network,scenario,persona,spec,simulate,chat}.pyextropy/cli/commands/validate.pyalready uses helper logic combining both modes.Suggested Fix
_json_enabled()) in CLI layer:get_json_mode() or is_agent_mode().agent_mode = is_agent_mode()with helper.Outputin JSON mode.cli.mode=human+ root--jsonreturns JSON for representative commands.--jsonpassed.extropy --json <command>) and/or add per-command passthrough if desired.Severity
Medium-high (automation contract regression). Not simulation-core blocking, but breaks non-interactive pipelines that depend on explicit
--jsonoverrides.