Skip to content

feat(files)!: CQRS consolidation - 5 tools to 2 tools#20

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

feat(files)!: CQRS consolidation - 5 tools to 2 tools#20
polaz merged 4 commits intomainfrom
refactor/#12-cqrs-files-consolidation

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Jan 19, 2026

Summary

Consolidates 5 file tools into 2 CQRS-aligned tools for better MCP client compatibility and cleaner read/write separation.

BREAKING CHANGE: Tool names have changed. See migration guide below.

Before (5 tools)

  • get_repository_tree - List files/folders
  • get_file_contents - Read file content
  • create_or_update_file - Single file commit
  • push_files - Batch file commit
  • upload_markdown - Upload attachment

After (2 tools)

  • browse_files - Query operations (tree/content actions)
  • manage_files - Command operations (single/batch/upload actions)

Migration Guide

Old Tool New Tool Action
get_repository_tree browse_files action: "tree"
get_file_contents browse_files action: "content"
create_or_update_file manage_files action: "single"
push_files manage_files action: "batch"
upload_markdown manage_files action: "upload"

Changes

  • Add BrowseFilesSchema with discriminated union pattern
  • Add ManageFilesSchema with discriminated union pattern
  • Replace filesToolRegistry with 2 consolidated tools
  • Update read-only tools list (only browse_files allowed)
  • Update unit tests for new structure

Test Plan

  • All 1436 tests pass
  • Lint passes
  • Build succeeds
  • Unit tests cover all actions for both tools

Closes #12

BREAKING CHANGE: Replace 5 individual file tools with 2 CQRS-aligned tools

Migration guide:
- get_repository_tree → browse_files with action: "tree"
- get_file_contents → browse_files with action: "content"
- create_or_update_file → manage_files with action: "single"
- push_files → manage_files with action: "batch"
- upload_markdown → manage_files with action: "upload"

Changes:
- Add BrowseFilesSchema with discriminated union (tree/content actions)
- Add ManageFilesSchema with discriminated union (single/batch/upload actions)
- Replace filesToolRegistry with 2 consolidated tools
- Update read-only tools list to only include browse_files
- Update unit tests for new tool structure

Closes #12
Copilot AI review requested due to automatic review settings January 19, 2026 07:33
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 19, 2026

📊 Test Coverage Report

Overall Coverage: 80.35%

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 95.45455% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/entities/files/registry.ts 94.73% 0 Missing and 3 partials ⚠️

📢 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 5 individual file operation tools into 2 CQRS-aligned tools to improve MCP client compatibility and provide cleaner separation between read (query) and write (command) operations.

Changes:

  • Introduces browse_files tool with discriminated union for "tree" and "content" actions
  • Introduces manage_files tool with discriminated union for "single", "batch", and "upload" actions
  • Updates test suite to cover all new tool actions with comprehensive test cases

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/entities/files/schema-readonly.ts Adds BrowseFilesSchema discriminated union for read-only file operations
src/entities/files/schema.ts Adds ManageFilesSchema discriminated union for write file operations
src/entities/files/registry.ts Implements consolidated tools with action-based routing, replacing 5 individual tool handlers
tests/unit/entities/files/registry.test.ts Updates all test cases to use new tool structure with action discriminators

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

polaz added 3 commits January 19, 2026 09:43
Add comprehensive tests for files entity index.ts exports:
- Test GITLAB_READONLY environment variable handling
- Test conditional tool filtering (read-only vs read-write mode)
- Test schema re-exports from schema.ts and schema-readonly.ts
- Test registry re-exports

Add istanbul ignore comments to TypeScript exhaustive check default
branches in registry.ts - these are unreachable at runtime since
Zod validates input before the switch statements.

Coverage improvement: files entity now at 100% statement coverage.
Address review feedback: content field in BatchFileActionSchema
should be required, not optional. This matches the original
PushFilesSchema behavior and GitLab's repository commits API
requirement for create actions.
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 5 out of 5 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 8e6f6eb into main Jan 19, 2026
26 checks passed
polaz added a commit that referenced this pull request Jan 19, 2026
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).
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/#12-cqrs-files-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.

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

2 participants