feat(labels): consolidate 5 label tools into 2 CQRS tools#37
Conversation
- browse_labels (Query): list, get actions - manage_label (Command): create, update, delete actions Uses flat z.object() with .refine() pattern for Claude API compatibility. Added JSON content type for POST/PUT requests. Closes #8
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
📊 Test Coverage ReportOverall Coverage: 86.55% Coverage Details
Coverage Report: View detailed coverage report
|
There was a problem hiding this comment.
Pull request overview
This PR consolidates 5 separate label tools into 2 CQRS-aligned tools, simplifying the label management interface while maintaining full functionality. The consolidation follows the Command Query Responsibility Segregation (CQRS) pattern with clear separation between read and write operations.
Changes:
- Replaced 5 individual tools (list_labels, get_label, create_label, update_label, delete_label) with 2 CQRS tools
- Implemented flat object schemas with .refine() validation for Claude API compatibility instead of discriminated unions
- Updated request content type to JSON for POST/PUT operations
- Refactored 48 unit tests to test the new consolidated tools with all actions
- Updated integration tests to use the new tool names and action-based parameters
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/entities/labels/schema-readonly.ts | Implements BrowseLabelsSchema with "list" and "get" actions using flat object pattern with action-specific field validation |
| src/entities/labels/schema.ts | Implements ManageLabelSchema with "create", "update", and "delete" actions using flat object pattern with action-specific field validation |
| src/entities/labels/registry.ts | Consolidates 5 handlers into 2 CQRS handlers (browse_labels and manage_label) with switch statements for action routing |
| tests/unit/entities/labels/registry.test.ts | Refactors all unit tests to validate the 2 new CQRS tools across all 5 actions with comprehensive error handling tests |
| tests/integration/schemas/labels.test.ts | Updates integration tests to use new tool names and action-based parameters while maintaining coverage of all label operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Consolidates 5 label tools into 2 CQRS-aligned tools per Issue #8:
list,getactionscreate,update,deleteactionsChanges
schema-readonly.tswithBrowseLabelsSchemausing flat object pattern with.refine()schema.tswithManageLabelSchemausing flat object pattern with.refine()registry.tswith 2 consolidated CQRS handlersTechnical Details
Uses flat
z.object()with.refine()instead ofz.discriminatedUnion()for Claude API compatibility (nooneOf/allOf/anyOfat JSON Schema root level).Test plan
Closes #8