fix(cli): fix session create JSON output data structure to match spec #6723

Merged
HAL9000 merged 6 commits from fix/issue-6441-session-create-json-output into master 2026-06-01 05:04:51 +00:00

6 Commits

Author SHA1 Message Date
cleveragents-auto c768d0844f chore: worker ruff auto-fix (pre-push lint gate)
CI / lint (pull_request) Successful in 41s
CI / typecheck (pull_request) Successful in 59s
CI / push-validation (pull_request) Successful in 22s
CI / helm (pull_request) Successful in 27s
CI / build (pull_request) Successful in 30s
CI / security (pull_request) Successful in 1m4s
CI / quality (pull_request) Successful in 53s
CI / unit_tests (pull_request) Successful in 7m23s
CI / docker (pull_request) Successful in 1m28s
CI / coverage (pull_request) Successful in 11m4s
CI / integration_tests (pull_request) Successful in 21m42s
CI / status-check (pull_request) Successful in 3s
2026-06-01 00:40:59 -04:00
HAL9000 c9b274a925 fix(cli): emit JSON envelope messages for session list/show/delete/export/import
The session create command already emitted a spec-compliant JSON envelope
with messages[].text populated, but list, show, delete, export, and
import did not — they either passed no `messages` to `format_output()`
(producing an envelope with an empty messages array) or short-circuited
to a Rich-styled `console.print(...)` line that breaks JSON parsing
entirely.

Failing scenarios in features/session_cli.feature (unit_tests gate)
asserted `messages[0].text == "<command-specific success>"`. Wire each
command's machine-readable path to emit a structured envelope with the
expected message:

- list (empty) → "0 sessions listed"
- list (populated) → "<N> sessions listed"
- show → "Session details loaded"
- delete --format json|yaml|plain → "Session deleted"
- export --output-format json|yaml|plain → "Export completed"
- import --format json|yaml|plain → "Import completed"

The export command gains a new `--output-format` flag distinct from the
existing `--format` (which selects export content format: json or md).
When the new flag is non-rich, the raw export content is suppressed from
stdout so the envelope remains the only thing emitted, and Rich panels
are skipped.

The import command gains a `--format` flag. The delete command already
had a `--format` option but its non-rich branch emitted Rich-styled text
instead of an envelope; that branch now splits cleanly: `--format color`
keeps the human-readable line, and json/yaml/plain emit an envelope.

Also addresses the `Session create initializes MCP logger` and
`Session list initializes MCP logger` scenarios in
features/session_cli_mcp_logger_simple_execution.feature, which inspect
the create()/list_sessions() source via inspect.getsource() and assert
the literal string `logging.getLogger(_MCP_LOGGER_NAME)` appears. Both
functions held the inlined literal `"cleveragents.mcp"` instead of the
module-level `_MCP_LOGGER_NAME` constant; substitute the constant
reference in both call sites.

CHANGELOG entry extended to document the envelope coverage across all
session commands.

ISSUES CLOSED: #6441
2026-06-01 00:40:59 -04:00
HAL9000 0c0101c368 fix(cli): add coverage for session create actor-details paths
Cover the two uncovered code paths introduced by the session create
JSON envelope fix:

1. `_resolve_actor_details(None)` → early `return None` (no actor bound)
2. Actor found in registry path (lines 271-297) — two scenarios:
   - Full config actor (options.temperature + direct context_window)
   - Graph descriptor actor (graph_descriptor.context_window)

Also remove dead redundant isinstance checks:
- `config_blob.get("options") if isinstance(config_blob, dict) else None`
  simplified to `config_blob.get("options")` since config_blob is always
  a dict (assigned on the previous line via ternary with {} fallback).
- Outer `if isinstance(config_blob, dict):` wrapper around context_window
  logic removed for the same reason.

ISSUES CLOSED: #6441
2026-06-01 00:40:59 -04:00
HAL9000 fba9cbf8d1 fix(cli): resolve session export test assertion and move get_container to top-level import
- Fix `security_template_coverage_boost.feature` assertion for "Session
  export to stdout outputs JSON": the export path outputs raw JSON with
  a `session_id` key, not a `data` envelope, so revert the erroneous
  `"data"` assertion back to `"session_id"`.
- Move all deferred `from cleveragents.application.container import
  get_container` imports in session.py to the module-level import
  block, consistent with every other CLI command file (action.py,
  actor.py, config.py, plan.py, etc.). No circular import exists.
- Update `session_cli_uncovered_branches_steps.py` to patch
  `cleveragents.cli.commands.session.get_container` directly (the
  correct target after a top-level import) instead of replacing
  `sys.modules["cleveragents.application.container"]`.
- Add CHANGELOG.md entry for the session create JSON envelope fix.

ISSUES CLOSED: #6441
2026-06-01 00:40:59 -04:00
implementation-worker 0e83ecc6cc fix(cli): update test assertions for new session create JSON structure
Update feature file assertions to match the new nested JSON structure
for session create output. Changed assertions from 'session_id:' to 'id:'
to reflect the new data.session.id structure per spec #6441.
2026-06-01 00:40:59 -04:00
HAL9000 e73150ab74 fix(cli): fix session create JSON output data structure to match spec (#6441)
ISSUES CLOSED: #6441
2026-06-01 00:40:59 -04:00