Skip to content
This repository was archived by the owner on Jul 11, 2026. It is now read-only.
This repository was archived by the owner on Jul 11, 2026. It is now read-only.

[Refactoring] Split Large Services - impact-analyzer & memory-service #22

Description

@gloomcheng

Problem

Two services have grown too large:

  • src/core/mcp/services/impact-analyzer.ts (677 lines)
  • src/core/mcp/services/memory-service.ts (668 lines)

Impact

  • Hard to maintain
  • Multiple responsibilities
  • Difficult to test
  • Violates Single Responsibility Principle

Proposed Refactoring

impact-analyzer.ts → impact-analysis/

services/impact-analysis/
  dependency-graph-builder.ts (graph construction)
  impact-calculator.ts (impact analysis)
  breaking-change-detector.ts (breaking changes)
  index.ts (exports)

memory-service.ts → memory/

services/memory/
  memory-storage.ts (core memory CRUD)
  correction-tracker.ts (corrections)
  snapshot-manager.ts (project snapshots)
  index.ts (exports)

Benefits

✅ Single Responsibility: Each module focused
✅ Testability: Easier to test smaller modules
✅ Maintainability: Easier to find and modify
✅ Reusability: Components can be used independently

Acceptance Criteria

  • impact-analyzer.ts split into 3 files (<300 lines each)
  • memory-service.ts split into 3 files (<300 lines each)
  • All tests passing
  • Public API unchanged (backward compatible)
  • Documentation updated

Priority

Medium - Technical debt cleanup

Effort Estimate

2 days

Activity

  1. gloomcheng commented on Dec 25, 2025

    @gloomcheng
    ContributorAuthor

    Completed in commit 9e858a3.

    Changes

    • Split impact-analyzer.ts (691 lines) into impact-analysis/ directory with 4 modules
    • Split memory-service.ts (668 lines) into memory/ directory with 3 modules
    • Maintained backward compatibility via facade pattern
    • Updated all imports across handlers and services
    • Build and lint pass

    File Structure

    services/
    ├── impact-analysis/
    │   ├── dependency-graph-builder.ts (422 lines)
    │   ├── impact-calculator.ts (186 lines)
    │   ├── breaking-change-detector.ts (120 lines)
    │   └── index.ts (77 lines)
    └── memory/
        ├── memory-storage.ts (311 lines)
        ├── learning-extractor.ts (354 lines)
        └── index.ts (66 lines)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions