Skip to content

feat(mrs): consolidate 20 MR tools into 5 CQRS tools (#15)#23

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

feat(mrs): consolidate 20 MR tools into 5 CQRS tools (#15)#23
polaz merged 4 commits intomainfrom
refactor/#15-mrs-cqrs-consolidation

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Jan 19, 2026

Summary

  • Consolidate 20 individual MR tools into 5 CQRS action-based tools
  • Reduces tool count from 85 to 61 while maintaining all functionality
  • Uses browse_* for queries, manage_* for commands

CQRS Tools

Tool Actions
browse_merge_requests list, get, diffs, compare
browse_mr_discussions list, drafts, draft
manage_merge_request create, update, merge
manage_mr_discussion comment, thread, reply, update
manage_draft_notes create, update, publish, publish_all, delete

Changes

  • Refactored registry.ts to use gitlab helper for proper typing
  • Updated schemas with Zod discriminated unions
  • 56 unit tests covering all CQRS tools
  • Updated README.md with migration guide

Test plan

  • yarn lint - 0 errors
  • yarn test:unit - 1420/1420 passing
  • yarn build - success

BREAKING CHANGE: Individual MR tools replaced with action-based CQRS tools

CQRS CONSOLIDATION:
- browse_merge_requests: list, get, diffs, compare actions
- browse_mr_discussions: list, drafts, draft actions
- manage_merge_request: create, update, merge actions
- manage_mr_discussion: comment, thread, reply, update actions
- manage_draft_notes: create, update, publish, publish_all, delete actions

IMPLEMENTATION:
- Refactored registry.ts to use gitlab helper for proper typing
- Updated schemas with Zod discriminated unions for action-based validation
- Complete test coverage with 56 unit tests for all CQRS tools

DOCUMENTATION:
- Updated README.md tool counts (85 → 61 tools)
- Added v5.0 migration guide for CQRS consolidation
- Updated USE_MRS and USE_FILES env var descriptions

BREAKING CHANGE: Individual MR tools replaced with action-based CQRS tools
Copilot AI review requested due to automatic review settings January 19, 2026 12:17
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 19, 2026

📊 Test Coverage Report

Overall Coverage: 84.86%

Coverage Details

Metric Percentage
Statements $(cat coverage/lcov-report/index.html
Branches $(cat coverage/lcov-report/index.html
Functions $(cat coverage/lcov-report/index.html
Lines $(cat coverage/lcov-report/index.html

📈 Coverage Report: View detailed coverage report

This report was generated automatically from your PR changes.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 91.03774% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/entities/mrs/registry.ts 88.51% 6 Missing and 11 partials ⚠️
src/entities/mrs/schema.ts 95.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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 20 individual merge request tools into 5 CQRS (Command Query Responsibility Segregation) action-based tools, reducing the total tool count from 85 to 61 while maintaining all functionality. The refactoring introduces a cleaner architecture with browse_* tools for queries and manage_* tools for commands, using Zod discriminated unions for type-safe action dispatching.

Changes:

  • Refactored MR tools from 20 individual tools to 5 CQRS tools with action-based dispatching
  • Updated schemas to use discriminated unions with action fields
  • Migrated from enhancedFetch to new gitlab helper for better type safety
  • Added 56 comprehensive unit tests covering all CQRS tool actions
  • Updated documentation with migration guide for users

Reviewed changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
yarn.lock Added [email protected] dependency
package.json Added conventional changelog dependency for semantic versioning
.releaserc.json Enhanced semantic-release configuration with conventionalcommits preset
.gitignore Added CLAUDE.md to exclusions
src/entities/mrs/schema.ts New CQRS command schemas with discriminated unions for manage_* tools
src/entities/mrs/schema-readonly.ts New CQRS query schemas with discriminated unions for browse_* tools
src/entities/mrs/registry.ts Consolidated 20 tools into 5 CQRS tools with action-based handlers
tests/unit/entities/mrs/registry.test.ts Updated tests for CQRS tools with comprehensive action coverage
README.md Updated documentation with tool consolidation details and migration guide

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

PR REVIEW FIXES:
- README.md: Fix tool count "17 tools → 20 tools" to reflect actual count
- registry.ts: Pass include_diverged_commits_count and include_rebase_in_progress
  to "get" and "diffs" actions (fields were defined but unused)
- registry.test.ts: Clarify toQuery mock comment to explain it mirrors real
  implementation, clarify resetAllMocks comment about preserving mock implementation

TEST IMPROVEMENTS:
- Add test for "get MR by IID with include flags"
- Add test for "get MR diffs with include flags"
- Update existing test expectations for undefined query params

Coverage: 90.35% statements, 84.21% branches, 100% functions, 97.05% lines
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

Copilot reviewed 7 out of 9 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

README FIXES:
- Clarify migration guide heading: "v5.0" → "v5.x → v6.0"
- Update summary heading: "Consolidated Tools in v5.0" → "CQRS Tools Introduced in v6.0"
- Fix Core/Projects count: "8 tools → CQRS" → "13 tools → 5 CQRS tools"

TEST IMPROVEMENTS (coverage 90.35% → 92.1%):
- Add test for create draft note with in_reply_to_discussion_id
- Add test for update MR with array parameters (assignee_ids, reviewer_ids)
- Statements: 92.1%, Branches: 86.84%, Functions: 100%, Lines: 99.01%

Note: Copilot review incorrectly flagged Files/Core CQRS tools as
non-existent, but they DO exist from previous PRs (#12, #19, #20).
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

Copilot reviewed 7 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

No existing users to migrate - remove unnecessary documentation:
- Remove 'Migration Guide (v5.x → v6.0)' section with CQRS consolidation details
- Remove 'Migration from v2.0' section with Work Items migration details
- Remove stray 'Version 5.0.0' heading at end of file

Also add clarifying comment in schema-readonly.ts explaining why
project_id is optional in BrowseMRsListSchema (cross-project search).
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

Copilot reviewed 7 out of 9 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@polaz polaz merged commit f41a505 into main Jan 19, 2026
23 checks passed
sw-release-bot bot pushed a commit that referenced this pull request Jan 19, 2026
## [6.1.0](v6.0.0...v6.1.0) (2026-01-19)

### ⚠ BREAKING CHANGES

* **mrs:** Individual MR tools replaced with action-based CQRS tools

### Features

* **mrs:** consolidate 20 MR tools into 5 CQRS tools ([#15](#15)) ([ec06fae](ec06fae))

### Bug Fixes

* **mrs:** address PR [#23](#23) review comments and increase coverage ([0e6410b](0e6410b)), closes [#12](#12) [#19](#19) [#20](#20)
* **mrs:** address PR review comments from Copilot ([#23](#23)) ([1905ac4](1905ac4))
@polaz polaz deleted the refactor/#15-mrs-cqrs-consolidation branch January 19, 2026 14:56
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.

2 participants