2 Commits

Author SHA1 Message Date
HAL9000 bbe8d830d5 fix(cli): correct _apply_output_dict data fields to match spec
Fix the spec-required data structure for `agents plan apply --format json`:
- artifacts: [] -> 0 (integer count per spec)
- changes: [] -> {"insertions": 0, "deletions": 0} (dict per spec)
- validation: rename "test" -> "tests" with nested dict structure, restructure
  "lint" and "type_check" as nested dicts, rename "duration" -> "duration_s" (float)
- lifecycle.child_plans: [] -> 0 (integer count per spec)
- timing.applied_at key renamed to timing.started per spec

Update BDD tests to match corrected implementation:
- plan_apply_json_envelope.feature: check "tests" not "test" in validation
- plan_cli_coverage_boost.feature: remove non-spec "namespaced_name" assertion
- plan_cli_coverage_boost_steps.py: check flat string messages per spec,
  not {"level", "text"} objects

ISSUES CLOSED: #9449
2026-06-17 06:49:43 -04:00
HAL9000 b4a7f26d7c bug(cli): plan apply --format json returns raw plan dict instead of spec-required JSON envelope
The `agents plan apply --format json` command was returning a raw
plan dictionary instead of the spec-required JSON envelope. This fix
introduces a dedicated `_apply_output_dict()` helper that wraps the
non-rich format output in the proper envelope structure with
`command`, `status`, `exit_code`, `data`, `timing`, and `messages`
fields.

The `data` field contains structured information about artifacts,
changes, project, applied_at, validation (test/lint/type_check),
sandbox_cleanup, and lifecycle metrics. Other commands (plan status,
plan cancel, plan use) remain unaffected — they continue using
`_plan_spec_dict`.

Tests: 16 Behave scenarios + 15 Robot Framework integration tests
added covering envelope structure, field presence, sandbox cleanup
state derivation from actual plan state, legacy fallback, cost
metadata, and command isolation.

ISSUES CLOSED: #9449
2026-06-14 21:07:19 -04:00