Skip to content

feat(labels): consolidate 5 label tools into 2 CQRS tools#37

Merged
polaz merged 4 commits intomainfrom
refactor/#8-labels-cqrs-consolidation
Jan 19, 2026
Merged

feat(labels): consolidate 5 label tools into 2 CQRS tools#37
polaz merged 4 commits intomainfrom
refactor/#8-labels-cqrs-consolidation

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Jan 19, 2026

Summary

Consolidates 5 label tools into 2 CQRS-aligned tools per Issue #8:

  • browse_labels (Query): list, get actions
  • manage_label (Command): create, update, delete actions

Changes

  • Updated schema-readonly.ts with BrowseLabelsSchema using flat object pattern with .refine()
  • Updated schema.ts with ManageLabelSchema using flat object pattern with .refine()
  • Updated registry.ts with 2 consolidated CQRS handlers
  • Added JSON content type for POST/PUT requests
  • Updated unit tests (48 tests passing)
  • Updated integration tests with new CQRS tool names

Technical Details

Uses flat z.object() with .refine() instead of z.discriminatedUnion() for Claude API compatibility (no oneOf/allOf/anyOf at JSON Schema root level).

Test plan

  • All 1429 unit tests pass
  • Build successful
  • Lint passes

Closes #8

- 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
Copilot AI review requested due to automatic review settings January 19, 2026 18:12
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 98.30508% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/entities/labels/registry.ts 97.82% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 19, 2026

📊 Test Coverage Report

Overall Coverage: 86.55%

Coverage Details

Metric Percentage
Statements 86.55%
Branches 81.28%
Functions 75.52%
Lines 87%

Coverage Report: View detailed coverage report

This report was generated automatically from your PR changes.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@polaz polaz merged commit c54243f into main Jan 19, 2026
12 checks passed
@polaz polaz deleted the refactor/#8-labels-cqrs-consolidation branch January 19, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(labels): CQRS consolidation - 5 tools → 2 tools

2 participants