bug(cli): plan status --format json returns raw plan dict instead of spec-required JSON envelope #9450

Open
opened 2026-04-14 18:01:45 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit Message: bug(cli): plan status --format json returns raw plan dict instead of spec-required JSON envelope
  • Branch: fix/plan-status-json-envelope

Background and Context

The agents plan status --format json command returns a raw plan dictionary instead of the spec-required JSON envelope structure. This was discovered during UAT testing of the Plan Lifecycle feature area.

In src/cleveragents/cli/commands/plan.py, the plan_status function (line ~2733) for non-rich formats does:

data = _plan_spec_dict(plan)
console.print(format_output(data, fmt))

This returns the internal plan representation instead of the spec-required envelope with command: "plan status", data.action, data.project, data.automation, data.attempt, data.progress, data.timing, data.execution, data.cost fields.

Spec Reference: docs/specification.md §agents plan status (lines ~13660-13703)

Files Affected: src/cleveragents/cli/commands/plan.pyplan_status function (lines ~2733-2735)

Current Behavior

agents plan status <PLAN_ID> --format json outputs:

{
  "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J",
  "namespaced_name": "local/my-plan",
  "phase": "execute",
  "processing_state": "processing",
  "state": "processing",
  "project_links": [...],
  ...
}

Expected Behavior

Per spec §agents plan status, the command must return a structured JSON envelope:

{
  "command": "plan status",
  "status": "ok",
  "exit_code": 0,
  "data": {
    "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J",
    "phase": "execute",
    "state": "processing",
    "action": "local/code-coverage",
    "project": "local/api-service",
    "automation": "review",
    "attempt": 1,
    "progress": [
      { "step": "Strategize", "status": "done" },
      { "step": "Execute", "status": "running" },
      { "step": "Apply", "status": "queued" }
    ],
    "timing": {
      "started": "12:57:01",
      "elapsed": "00:01:12",
      "eta": "00:03:45"
    },
    "execution": {
      "sandbox": "git_worktree",
      "tool_calls": 8,
      "files_modified": 3,
      "child_plans": "1/2 complete",
      "checkpoints": 2
    },
    "cost": {
      "tokens_used": 12420,
      "cost_so_far": 0.041,
      "estimated": 0.085
    }
  },
  "timing": {
    "started": "2026-02-08T12:57:01Z",
    "duration_ms": 120
  },
  "messages": ["Status refreshed"]
}

Acceptance Criteria

  • agents plan status <PLAN_ID> --format json returns a spec-compliant JSON envelope with command: "plan status", status: "ok", exit_code: 0
  • data.action contains the action name
  • data.project contains the first project link name
  • data.automation contains the profile name
  • data.attempt is present
  • data.progress contains Strategize/Execute/Apply steps with their statuses
  • data.timing contains started, elapsed, eta
  • data.execution contains sandbox, tool_calls, files_modified, child_plans, checkpoints
  • data.cost contains tokens_used, cost_so_far, estimated
  • timing envelope field is present with started and duration_ms
  • messages contains ["Status refreshed"]
  • Behave BDD test scenario verifies the JSON envelope structure
  • No regressions in existing tests
  • Coverage ≥97%

Impact

  • Downstream automation scripts using agents --format json plan status will receive incorrect JSON structure
  • The spec explicitly shows agents --format json plan status "$PLAN_ID" | jq -r '.state' as a scripting pattern — this works with the current output but the full envelope structure is wrong
  • The data.progress, data.timing, data.execution, data.cost fields are all missing

Subtasks

  • Build spec-compliant JSON envelope builder for plan status output
  • Include command: "plan status", status: "ok", exit_code: 0 envelope fields
  • Include data.action (action name), data.project (first project link), data.automation (profile name), data.attempt
  • Include data.progress array with Strategize/Execute/Apply steps and their statuses
  • Include data.timing with started, elapsed, eta
  • Include data.execution with sandbox, tool_calls, files_modified, child_plans, checkpoints
  • Include data.cost with tokens_used, cost_so_far, estimated
  • Include timing and messages: ["Status refreshed"] envelope fields
  • Add Behave BDD test scenario verifying JSON envelope structure for plan status --format json
  • Verify coverage remains ≥97%

Definition of Done

This issue is complete when:

  • agents plan status <PLAN_ID> --format json returns spec-required envelope with command: "plan status", status: "ok", exit_code: 0
  • data.progress contains Strategize/Execute/Apply steps with statuses
  • data.action and data.project are present
  • messages contains ["Status refreshed"]
  • Behave BDD test covers the JSON envelope structure
  • No regressions in existing tests
  • Coverage ≥97%
  • All subtasks above are completed and checked off
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done

Automated by CleverAgents Bot
Agent: new-issue-creator

## Metadata - **Commit Message**: `bug(cli): plan status --format json returns raw plan dict instead of spec-required JSON envelope` - **Branch**: `fix/plan-status-json-envelope` ## Background and Context The `agents plan status --format json` command returns a raw plan dictionary instead of the spec-required JSON envelope structure. This was discovered during UAT testing of the Plan Lifecycle feature area. In `src/cleveragents/cli/commands/plan.py`, the `plan_status` function (line ~2733) for non-rich formats does: ```python data = _plan_spec_dict(plan) console.print(format_output(data, fmt)) ``` This returns the internal plan representation instead of the spec-required envelope with `command: "plan status"`, `data.action`, `data.project`, `data.automation`, `data.attempt`, `data.progress`, `data.timing`, `data.execution`, `data.cost` fields. **Spec Reference**: `docs/specification.md` §agents plan status (lines ~13660-13703) **Files Affected**: `src/cleveragents/cli/commands/plan.py` — `plan_status` function (lines ~2733-2735) ## Current Behavior `agents plan status <PLAN_ID> --format json` outputs: ```json { "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J", "namespaced_name": "local/my-plan", "phase": "execute", "processing_state": "processing", "state": "processing", "project_links": [...], ... } ``` ## Expected Behavior Per spec §agents plan status, the command must return a structured JSON envelope: ```json { "command": "plan status", "status": "ok", "exit_code": 0, "data": { "plan_id": "01HXM8C2ZK4Q7C2B3F2R4VYV6J", "phase": "execute", "state": "processing", "action": "local/code-coverage", "project": "local/api-service", "automation": "review", "attempt": 1, "progress": [ { "step": "Strategize", "status": "done" }, { "step": "Execute", "status": "running" }, { "step": "Apply", "status": "queued" } ], "timing": { "started": "12:57:01", "elapsed": "00:01:12", "eta": "00:03:45" }, "execution": { "sandbox": "git_worktree", "tool_calls": 8, "files_modified": 3, "child_plans": "1/2 complete", "checkpoints": 2 }, "cost": { "tokens_used": 12420, "cost_so_far": 0.041, "estimated": 0.085 } }, "timing": { "started": "2026-02-08T12:57:01Z", "duration_ms": 120 }, "messages": ["Status refreshed"] } ``` ## Acceptance Criteria - [ ] `agents plan status <PLAN_ID> --format json` returns a spec-compliant JSON envelope with `command: "plan status"`, `status: "ok"`, `exit_code: 0` - [ ] `data.action` contains the action name - [ ] `data.project` contains the first project link name - [ ] `data.automation` contains the profile name - [ ] `data.attempt` is present - [ ] `data.progress` contains Strategize/Execute/Apply steps with their statuses - [ ] `data.timing` contains started, elapsed, eta - [ ] `data.execution` contains sandbox, tool_calls, files_modified, child_plans, checkpoints - [ ] `data.cost` contains tokens_used, cost_so_far, estimated - [ ] `timing` envelope field is present with started and duration_ms - [ ] `messages` contains `["Status refreshed"]` - [ ] Behave BDD test scenario verifies the JSON envelope structure - [ ] No regressions in existing tests - [ ] Coverage ≥97% ## Impact - Downstream automation scripts using `agents --format json plan status` will receive incorrect JSON structure - The spec explicitly shows `agents --format json plan status "$PLAN_ID" | jq -r '.state'` as a scripting pattern — this works with the current output but the full envelope structure is wrong - The `data.progress`, `data.timing`, `data.execution`, `data.cost` fields are all missing ## Subtasks - [ ] Build spec-compliant JSON envelope builder for `plan status` output - [ ] Include `command: "plan status"`, `status: "ok"`, `exit_code: 0` envelope fields - [ ] Include `data.action` (action name), `data.project` (first project link), `data.automation` (profile name), `data.attempt` - [ ] Include `data.progress` array with Strategize/Execute/Apply steps and their statuses - [ ] Include `data.timing` with started, elapsed, eta - [ ] Include `data.execution` with sandbox, tool_calls, files_modified, child_plans, checkpoints - [ ] Include `data.cost` with tokens_used, cost_so_far, estimated - [ ] Include `timing` and `messages: ["Status refreshed"]` envelope fields - [ ] Add Behave BDD test scenario verifying JSON envelope structure for `plan status --format json` - [ ] Verify coverage remains ≥97% ## Definition of Done This issue is complete when: - [ ] `agents plan status <PLAN_ID> --format json` returns spec-required envelope with `command: "plan status"`, `status: "ok"`, `exit_code: 0` - [ ] `data.progress` contains Strategize/Execute/Apply steps with statuses - [ ] `data.action` and `data.project` are present - [ ] `messages` contains `["Status refreshed"]` - [ ] Behave BDD test covers the JSON envelope structure - [ ] No regressions in existing tests - [ ] Coverage ≥97% - [ ] All subtasks above are completed and checked off - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation - [ ] The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly - [ ] The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done --- **Automated by CleverAgents Bot** Agent: new-issue-creator
HAL9000 added this to the v3.2.0 milestone 2026-04-14 18:13:01 +00:00
Author
Owner

Triage Decision [AUTO-OWNR-3]: Verified as a spec compliance bug. The plan status --format json returns a raw plan dict instead of the spec-required JSON envelope. Should Have for v3.2.0 — part of the broader JSON envelope compliance pattern.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Triage Decision [AUTO-OWNR-3]**: Verified as a spec compliance bug. The `plan status --format json` returns a raw plan dict instead of the spec-required JSON envelope. `Should Have` for v3.2.0 — part of the broader JSON envelope compliance pattern. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#9450
No description provided.