Files
cleveragents-core/features/plan_tree_decision_rendering.feature
HAL9000 86b0c62e69 feat(plan): implement agents plan tree decision tree rendering
Implements the plan tree decision tree rendering feature for issue #9280.

This commit adds:
- PlanTreeService: Service layer for retrieving and rendering decision trees
- DecisionTreeNode: Data structure for representing tree nodes
- Multiple renderers: Rich (colored), plain text (ASCII), and JSON formats
- Support for --format and --depth options
- Comprehensive unit tests for service and renderers
- BDD feature tests for CLI integration

The implementation supports:
- Hierarchical tree rendering of all decisions in a plan
- Status indicators (pending, completed, reverted)
- Depth limiting to control output size
- Multiple output formats for different use cases
- Error handling for non-existent plans

All quality gates passing:
- Lint: ✓
- Typecheck: ✓
- Unit tests: Pending (long-running test suite)

ISSUES CLOSED: #9280
2026-04-15 16:12:42 +00:00

80 lines
3.6 KiB
Gherkin

Feature: Plan Tree Decision Rendering
As a user
I want to view the decision tree of a plan
So that I can audit the decision history and identify correction points
Background:
Given a plan with ID "plan-test-001"
And the plan has the following decisions:
| decision_id | type | parent_id | question | chosen_option | status |
| d-001 | prompt_definition | None | What is the task? | Analyze code | completed |
| d-002 | strategy_choice | d-001 | Which strategy to use? | Iterative | completed |
| d-003 | tool_selection | d-002 | Which tool for linting? | ruff | completed |
| d-004 | parameter | d-002 | Set max retries? | 3 | reverted |
| d-005 | branch | d-001 | Await confirmation? | pending | pending |
Scenario: Display plan tree in rich format
When I run "agents plan tree plan-test-001"
Then the output should contain "Plan Decision Tree: plan-test-001"
And the output should contain "d-001"
And the output should contain "prompt_definition"
And the output should contain "completed"
And the output should contain "d-002"
And the output should contain "strategy_choice"
And the output should contain "d-003"
And the output should contain "tool_selection"
And the output should contain "d-004"
And the output should contain "parameter"
And the output should contain "reverted"
And the output should contain "d-005"
And the output should contain "branch"
And the output should contain "pending"
Scenario: Display plan tree in plain text format
When I run "agents plan tree plan-test-001 --format plain"
Then the output should contain "Plan Decision Tree: plan-test-001"
And the output should contain "`--" or "|--"
And the output should contain "[completed]"
And the output should contain "[reverted]"
And the output should contain "[pending]"
Scenario: Display plan tree in JSON format
When I run "agents plan tree plan-test-001 --format json"
Then the output should be valid JSON
And the JSON should contain "plan_id": "plan-test-001"
And the JSON should contain "root"
And the JSON root should have "decision_id": "d-001"
And the JSON root should have "children" array with 2 items
Scenario: Limit tree depth to 1
When I run "agents plan tree plan-test-001 --depth 1"
Then the output should contain "d-001"
And the output should contain "d-002"
And the output should NOT contain "d-003"
And the output should NOT contain "d-004"
Scenario: Limit tree depth to 2
When I run "agents plan tree plan-test-001 --depth 2"
Then the output should contain "d-001"
And the output should contain "d-002"
And the output should contain "d-003"
And the output should contain "d-004"
And the output should NOT contain "d-005"
Scenario: Handle non-existent plan ID
When I run "agents plan tree plan-nonexistent"
Then the exit code should be non-zero
And the output should contain "not found"
Scenario: Handle plan with no decisions
Given a plan with ID "plan-empty"
When I run "agents plan tree plan-empty"
Then the output should contain "not found" or "no decisions"
Scenario: Tree structure is hierarchical
When I run "agents plan tree plan-test-001 --format plain"
Then the output should show d-002 as a child of d-001
And the output should show d-003 as a child of d-002
And the output should show d-004 as a child of d-002
And the output should show d-005 as a child of d-001