-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Overview
Add optional builder patterns for complex message types in the UserOutput module. This proposal introduces builders that provide a fluent API for constructing complex messages while maintaining backward compatibility with simple direct construction.
Specification
See detailed specification: docs/issues/139-builder-pattern-for-complex-messages.md
Goals
- Create builder pattern for
StepsMessagewith fluent API - Create builder pattern for
InfoBlockMessagewith fluent API - Maintain backward compatibility with simple constructors
- Enable future extensibility with optional parameters
- Provide ergonomic API for common use cases
- Document when to use builders vs simple constructors
Implementation Plan
Phase 1: StepsMessageBuilder Implementation (1 hour)
- Create
StepsMessageBuilderstruct - Implement
new(),add(), andbuild()methods - Add
StepsMessage::builder()convenience method - Keep existing
StepsMessage::new()constructor
Phase 2: InfoBlockMessageBuilder Implementation (1 hour)
- Create
InfoBlockMessageBuilderstruct - Implement
new(),add_line(), andbuild()methods - Add
InfoBlockMessage::builder()convenience method
Phase 3: Testing (1.5 hours)
- Add tests for fluent API usage
- Add tests for direct construction (ensure backward compatibility)
- Add tests for empty builders
- Add integration tests showing formatting with builders
Phase 4: Documentation and Quality (30 minutes)
- Update module documentation with builder examples
- Document when to use builders vs simple constructors
- Run
./scripts/pre-commit.shand fix any issues
Total Estimated Time: 4 hours
Acceptance Criteria
Functional Requirements
-
StepsMessageBuilderprovides fluent API for step messages -
InfoBlockMessageBuilderprovides fluent API for info blocks - Simple constructors remain available and unchanged
- Builders integrate seamlessly with
OutputMessagetrait - Builder pattern is consuming (not mutating)
API Design Requirements
- Builder API is ergonomic and intuitive
- Method names are clear and follow Rust conventions
-
builder()andnew()methods coexist for different use cases
Testing Requirements
- Unit tests cover fluent API construction
- Tests verify backward compatibility with simple constructors
- Tests cover edge cases (empty builders, single item, many items)
Quality Requirements
- Pre-commit checks pass:
./scripts/pre-commit.sh - Builder pattern follows Rust idioms
- No clippy warnings for builder implementation
Related
- Parent Epic: [EPIC] User Output Architecture Improvements #102 - User Output Architecture Improvements
- Refactoring Plan: docs/refactors/plans/user-output-architecture-improvements.md
- Depends On: Use Message Trait for Extensibility #127 - Use Message Trait for Extensibility
Labels
enhancement, phase-2, user-output, P2
Priority
P2 (Phase 2 - Polish & Extensions)
Estimated Effort
4 hours
Copilot
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request