Skip to main content
Glama
danielsimonjr

Enhanced Knowledge Graph Memory Server

CHANGELOG.md94.4 kB
# Changelog All notable changes to the Enhanced Memory MCP will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [0.48.0] - 2025-12-09 ### Added - **Dependency Graph Tool** - New tool to scan codebase and generate dependency documentation **Location**: `tools/create-dependency-graph/` **Features**: - Uses TypeScript Compiler API for accurate parsing - Extracts imports, exports, classes, functions, interfaces, types, constants - Builds dependency graph with edges and layer classification - Detects design patterns (Facade, Orchestrator, Dependency Injection) - Tracks algorithms (TF-IDF, Levenshtein, LRU Cache) - Analyzes circular dependencies - Generates Mermaid visualization diagram - **NEW**: YAML output format (~25% smaller than JSON) - **NEW**: Compact summary JSON for LLM consumption (~2.8KB) **Output Files**: - `docs/architecture/DEPENDENCY_GRAPH.md` - Human-readable documentation - `docs/architecture/dependency-graph.json` - Machine-readable data (full) - `docs/architecture/dependency-graph.yaml` - YAML format (compact) - `docs/architecture/dependency-summary.compact.json` - LLM-optimized summary **Usage**: ```bash npm run docs:deps # or npx tsx tools/create-dependency-graph/src/index.ts ``` **Results**: - Scans 54 TypeScript files across 7 modules - Tracks 265 exports and 137 re-exports - ~10.7K lines of code - 0 circular dependencies ### Fixed - **ValidationError Naming Collision** - Renamed `ValidationError` interface to `ValidationIssue` in `analytics.types.ts` to avoid collision with the `ValidationError` class in `utils/errors.ts` - Updated `ValidationReport.errors` → `ValidationReport.issues` - Updated `AnalyticsManager.ts` to use `ValidationIssue` type - **Duplicate defaultMemoryPath** - Removed duplicate definition from `index.ts`, now imports from canonical location in `utils/pathUtils.ts` ### Removed - **ImportExportManager.ts** - Removed unused facade class from `features/` module - Moved `ExportFilter` interface to `types/import-export.types.ts` - This class was never used; `ExportManager` and `ImportManager` are used directly ### Changed - Updated file count from 55 to 54 TypeScript files (after removing ImportExportManager.ts) - Updated test for platform-specific path handling in `file-path.test.ts` - Fixed flaky ranked search benchmark test by adding explicit timeout (30s) ## [0.47.0] - 2025-11-26 ### Changed - **Context/Token Optimization - Complete** - All major refactoring sprints finished **Sprint 6 Status: Already Implemented** - Task 6.1: Graph caching ✅ (GraphStorage has in-memory cache with write-through invalidation) - Task 6.3: Lazy TF-IDF index ✅ (TFIDFIndexManager with ensureIndexLoaded()) - Task 6.4: Batch operations ✅ (TransactionManager handles batching) - Tasks 6.2, 6.5, 6.6: Deferred (nice-to-have, not critical for context optimization) **Refactoring Summary**: | Sprint | Focus | Key Achievements | |--------|-------|------------------| | 1 | Core Utilities | responseFormatter, tagUtils, entityUtils, paginationUtils, filterUtils | | 2 | Search Consolidation | SearchFilterChain unifying filter logic across 4 search classes | | 3 | MCPServer | Extracted toolDefinitions.ts & toolHandlers.ts (907→67 lines, 92.6% reduction) | | 4 | Manager Optimization | Lazy initialization for 10 managers, SIMILARITY_WEIGHTS consolidation | | 5 | Type & Import | Package exports map for tree-shaking | | 6 | Caching | Already implemented (GraphStorage cache, TF-IDF lazy loading) | **Total Impact**: - MCPServer.ts: 907 → 67 lines (92.6% reduction) - 41 JSON.stringify patterns eliminated - ~65 lines duplicate filter logic unified - 10 managers now lazy-loaded - All 396 tests passing **REFACTORING COMPLETE** ✅ ## [0.46.0] - 2025-11-26 ### Changed - **Context/Token Optimization - Sprint 5: Type & Import Optimization** - Package exports map and tree-shaking support **Task 5.5: Package Exports Map** - Added `exports` field to package.json for proper subpath exports - Enables tree-shaking and direct module imports - Subpaths available: * `.` - Main entry point * `./types` - Type definitions * `./utils` - Utility functions * `./core` - Core managers * `./search` - Search functionality * `./features` - Feature managers * `./server` - MCP server - Added `main` and `types` fields for compatibility **Task 5.1: Type Re-exports (Already Complete)** - Types properly organized in `types/index.ts` barrel export - All type categories exported: Entity, Search, Analytics, Tag, ImportExport **Impact**: - Consumers can import specific modules for smaller bundle sizes - Better IDE support with proper type exports - All 396 tests passing - Build successful **Sprint 5 Complete** ✅ - Task 5.1: Consolidate type re-exports ✅ (already done) - Task 5.5: Update package exports map ✅ - Ready for Sprint 6: Caching & Lazy Loading ## [0.45.0] - 2025-11-26 ### Changed - **Context/Token Optimization - Sprint 4: Manager Class Optimization** - Lazy initialization and constant consolidation **Task 4.5: Consolidated SIMILARITY_WEIGHTS** - Removed duplicate `SIMILARITY_WEIGHTS` definition from `CompressionManager.ts` - Unified on single definition in `constants.ts` with consistent key names (OBSERVATIONS, TAGS) - Removed duplicate `DEFAULT_DUPLICATE_THRESHOLD` from `CompressionManager.ts` - CompressionManager now imports constants from centralized location **Task 4.3: Lazy Manager Initialization** - Refactored `KnowledgeGraphManager` to use lazy initialization pattern - 10 managers are now instantiated on-demand via private getters - Uses nullish coalescing assignment (`??=`) for clean, efficient lazy instantiation - Managers: EntityManager, RelationManager, SearchManager, CompressionManager, HierarchyManager, ExportManager, ImportManager, AnalyticsManager, TagManager, ArchiveManager - Faster startup time when not all features are used - Reduced memory footprint for unused managers **Impact**: - Eliminated duplicate constant definitions - Faster KnowledgeGraphManager construction (managers initialized only when accessed) - Cleaner separation of concerns for constants - All 396 tests passing - Build successful **Sprint 4 Complete** ✅ - Task 4.3: Implement lazy initialization ✅ - Task 4.5: Consolidate SIMILARITY_WEIGHTS ✅ - Ready for Sprint 5: Type & Import Optimization ## [0.44.0] - 2025-11-26 ### Changed - **Context/Token Optimization - Sprint 3: MCPServer Optimization** - Extracted tool definitions and handlers **New Server Module Files**: - `src/memory/server/toolDefinitions.ts` - All 45 tool schemas organized by category * Entity tools (4): create_entities, delete_entities, read_graph, open_nodes * Relation tools (2): create_relations, delete_relations * Observation tools (2): add_observations, delete_observations * Search tools (6): search_nodes, search_by_date_range, search_nodes_ranked, boolean_search, fuzzy_search, get_search_suggestions * Saved search tools (5): save_search, execute_saved_search, list_saved_searches, delete_saved_search, update_saved_search * Tag tools (6): add_tags, remove_tags, set_importance, add_tags_to_multiple_entities, replace_tag, merge_tags * Tag alias tools (5): add_tag_alias, list_tag_aliases, remove_tag_alias, get_aliases_for_tag, resolve_tag * Hierarchy tools (9): set_entity_parent, get_children, get_parent, get_ancestors, get_descendants, get_subtree, get_root_entities, get_entity_depth, move_entity * Analytics tools (2): get_graph_stats, validate_graph * Compression tools (4): find_duplicates, merge_entities, compress_graph, archive_entities * Import/Export tools (2): import_graph, export_graph * Exported `toolCategories` for category-based tool grouping - `src/memory/server/toolHandlers.ts` - Handler registry for all 45 tools * `toolHandlers` - Record mapping tool names to async handler functions * `handleToolCall()` - Dispatcher function for routing tool calls * Each handler uses formatToolResponse/formatTextResponse/formatRawResponse - **MCPServer.ts** - Dramatically simplified from 907 lines to 67 lines * Removed inline getToolDefinitions() method (734 lines) * Removed handleToolCall() switch statement (104 lines) * Now imports toolDefinitions and handleToolCall from extracted modules * Clean separation of concerns: server setup vs tool definitions vs handler logic **Impact**: - Reduced MCPServer.ts from 907 lines to 67 lines (92.6% reduction!) - Tool definitions now organized by category for easier maintenance - Handler registry pattern enables easy tool extension - All 396 tests passing - Build successful **Sprint 3 Complete** ✅ - Task 3.1: Extract toolDefinitions.ts ✅ - Task 3.2: Create toolHandlers.ts ✅ - Task 3.3: Refactor MCPServer.ts ✅ - Ready for Sprint 4: Manager Class Optimization ## [0.43.0] - 2025-11-26 ### Added - **Context/Token Optimization - Sprint 2: Search Module Consolidation** - Created unified search filter logic **New Utility Files**: - `src/memory/search/SearchFilterChain.ts` - Centralized search filtering * `SearchFilterChain.applyFilters()` - Apply tag, importance, date filters * `SearchFilterChain.entityPassesFilters()` - Check single entity * `SearchFilterChain.validatePagination()` - Validate pagination params * `SearchFilterChain.paginate()` - Apply pagination to results * `SearchFilterChain.filterAndPaginate()` - Combined convenience method ### Changed - **BasicSearch.ts** - Refactored to use SearchFilterChain * Removed inline tag/importance filter logic (~20 lines) * Now uses `SearchFilterChain.applyFilters()` for tag/importance * Now uses `SearchFilterChain.validatePagination()` for pagination - **BooleanSearch.ts** - Refactored to use SearchFilterChain * Removed inline tag/importance filter logic (~15 lines) * Separated boolean query evaluation from filter application - **FuzzySearch.ts** - Refactored to use SearchFilterChain * Removed inline tag/importance filter logic (~15 lines) * Separated fuzzy matching from filter application - **RankedSearch.ts** - Refactored to use SearchFilterChain * Removed inline tag/importance filter logic (~15 lines) * Streamlined filter application before TF-IDF scoring - **search/index.ts** - Added SearchFilterChain export **Impact**: - Eliminated ~65 lines of duplicate filter logic across 4 search files - Unified tag normalization, importance filtering, and pagination - All 396 tests passing (37 BasicSearch, 52 BooleanSearch, 53 FuzzySearch, 35 RankedSearch) - Build successful **Sprint 2 Complete** ✅ - Tasks 2.1-2.6: All search files refactored - Ready for Sprint 3: MCPServer Optimization ## [0.42.0] - 2025-11-26 ### Added - **Context/Token Optimization - Sprint 1: Core Utility Extraction** - Created new utility modules to eliminate code duplication **New Utility Files Created**: - `src/memory/utils/responseFormatter.ts` - MCP tool response formatting * `formatToolResponse()` - JSON-stringify responses * `formatTextResponse()` - Plain text responses * `formatRawResponse()` - Pre-formatted content (markdown, CSV) * `formatErrorResponse()` - Error responses with isError flag - `src/memory/utils/tagUtils.ts` - Tag normalization and matching * `normalizeTags()`, `normalizeTag()` - Lowercase normalization * `hasMatchingTag()`, `hasAllTags()` - Tag matching utilities * `filterByTags()`, `addUniqueTags()`, `removeTags()` - Tag operations - `src/memory/utils/entityUtils.ts` - Entity lookup helpers * `findEntityByName()` - Type-safe entity lookup with overloads * `findEntitiesByNames()`, `entityExists()` - Bulk operations * `getEntityIndex()`, `removeEntityByName()` - Mutation helpers * `getEntityNameSet()`, `groupEntitiesByType()` - Aggregation utilities - `src/memory/utils/validationHelper.ts` - Zod schema validation * `validateWithSchema()` - Throws ValidationError on failure * `validateSafe()` - Returns result object without throwing * `formatZodErrors()`, `validateArrayWithSchema()` - Helpers - `src/memory/utils/paginationUtils.ts` - Pagination logic * `validatePagination()` - Normalizes offset/limit within bounds * `applyPagination()`, `paginateArray()` - Apply to result arrays * `getPaginationMeta()` - Pagination metadata generation - `src/memory/utils/filterUtils.ts` - Entity filtering * `isWithinImportanceRange()`, `filterByImportance()` - Importance filters * `filterByCreatedDate()`, `filterByModifiedDate()` - Date filters * `filterByEntityType()`, `entityPassesFilters()` - Combined filtering ### Changed - **MCPServer.ts** - Updated all 41 tool handlers to use response formatters * Replaced inline `JSON.stringify(..., null, 2)` patterns with `formatToolResponse()` * Replaced text responses with `formatTextResponse()` * Replaced export_graph raw content with `formatRawResponse()` - **utils/index.ts** - Updated barrel export with all new utilities **Impact**: - Eliminated 41 duplicate JSON.stringify patterns in MCPServer.ts - Created foundation for eliminating 27 entity lookup duplications - Created foundation for eliminating 14 tag normalization duplications - All 396 tests passing - Build successful **Sprint 1 Complete** ✅ - Tasks 1.1-1.7: All utility files created - MCPServer refactored to use formatters - Ready for Sprint 2: Search Module Consolidation ## [0.41.0] - 2025-11-26 ### Changed - **Sprint 4: Knowledge Graph Manager Extraction - Phase 18** - Extract KnowledgeGraphManager to core module **GOAL ACHIEVED: index.ts now < 200 lines!** 🎉 **New Core Module**: Extracted KnowledgeGraphManager class to dedicated core module - Created `src/memory/core/KnowledgeGraphManager.ts` (518 lines) * Encapsulates all business logic and manager coordination * Constructor initializes all specialized managers * Provides facade for all knowledge graph operations * Delegates to EntityManager, SearchManager, AnalyticsManager, etc. - Updated index.ts to minimal entry point * Removed entire KnowledgeGraphManager class definition * Removed 10+ manager imports (now only in KnowledgeGraphManager.ts) * Added single import for KnowledgeGraphManager * Re-exported KnowledgeGraphManager for backward compatibility * Kept only entry point logic (helper functions, main()) **Impact**: - Reduced index.ts from 575 lines to 98 lines (477 lines removed, 82.9% reduction!) 🚀🎯 - **EXCEEDED GOAL**: Now at 98 lines vs <200 line target - Created clean entry point focused solely on initialization - All business logic properly encapsulated in core module - All 396 tests passing **Sprint 4 Complete!**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Final: 98 lines (97.7% total reduction) ✅ **GOAL EXCEEDED!** - Phases 1-18: 4,096 lines removed total - Improvement: 42.8x reduction in file size ## [0.40.0] - 2025-11-26 ### Changed - **Sprint 4: MCP Server Extraction - Phase 17** - Extract all MCP server setup to server/MCPServer.ts **New Server Module**: Created dedicated server module to encapsulate all MCP protocol handling - Created `src/memory/server/MCPServer.ts` (906 lines) * Encapsulates all MCP Server initialization logic * Defines 45+ tool schemas (create_entities, search, analytics, etc.) * Implements tool handler routing via switch statement * Manages server lifecycle (initialization, transport, connection) - Updated index.ts to use MCPServer class * Removed Server, StdioServerTransport, and MCP schema imports * Added MCPServer import and initialization * Removed ~1,100 lines of MCP server setup code * Simplified main() function to create manager and server - Removed unused MEMORY_FILE_PATH global variable **Impact**: - Reduced index.ts from 1,675 lines to 576 lines (1,099 lines removed, 65.6% reduction!) 🚀 - Created clean separation between business logic and protocol handling - Largest single-phase reduction in Sprint 4 refactoring - All 396 tests passing **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 576 lines (86.3% total reduction) 🎯 **MAJOR MILESTONE!** - Phases 1-17: 3,618 lines removed total - Remaining: ~376 lines to reach <200 line target ## [0.39.0] - 2025-11-25 ### Changed - **Sprint 4: Archive Operations Delegation - Phase 16** - Delegate archiveEntities to ArchiveManager **Delegated Archive Operations**: Replaced archiveEntities implementation with ArchiveManager delegation - Added ArchiveManager import and instance to KnowledgeGraphManager - Replaced archiveEntities() implementation (59 lines) with delegation to ArchiveManager - Removed unused saveGraph() private helper method (4 lines) - ArchiveManager handles: * Age-based archiving (entities older than specified date) * Importance-based archiving (entities below importance threshold) * Tag-based archiving (entities with specific tags) * Dry-run mode for preview before actual archiving * Automatic cleanup of relations connected to archived entities **Impact**: - Reduced index.ts from 1,726 lines to 1,675 lines (51 lines removed, 3.0% reduction) - Centralized entity archiving logic in ArchiveManager - Removed last unused private helper method (saveGraph) - All 396 tests passing **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 1,675 lines (60.0% total reduction) 🎯 **60% MILESTONE!** - Phases 1-16: 2,519 lines removed total - Remaining: ~1,475 lines of implementation code to refactor ## [0.38.0] - 2025-11-25 ### Changed - **Sprint 4: Merge Tags Operation Delegation - Phase 15** - Delegate mergeTags to EntityManager **Enhanced EntityManager**: Added mergeTags() method to EntityManager and delegated from index.ts - Added mergeTags() method to EntityManager (46 lines of implementation) * Combines two tags into a target tag across all entities * Normalizes all tags to lowercase for consistency * Updates entity timestamps on modification * Returns affected entity names and count - Replaced mergeTags() implementation in index.ts (34 lines) with delegation to EntityManager **Impact**: - Reduced index.ts from 1,758 lines to 1,726 lines (32 lines removed, 1.9% reduction) - EntityManager now provides complete tag lifecycle management (CRUD + merge + replace) - Consistent tag normalization and timestamp updates - All 396 tests passing **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 1,726 lines (58.9% total reduction) - Phases 1-15: 2,468 lines removed total - Remaining: ~1,526 lines of implementation code to refactor ## [0.37.0] - 2025-11-25 ### Changed - **Sprint 4: Tag Alias Operations Delegation - Phase 14** - Delegate all tag alias operations to TagManager **Delegated Tag Alias Operations**: Replaced inline implementations with TagManager delegations - Removed loadTagAliases() private helper (11 lines) - now handled by TagManager - Removed saveTagAliases() private helper (3 lines) - now handled by TagManager - Replaced resolveTag() implementation (12 lines) with delegation to tagManager - Replaced addTagAlias() implementation (26 lines) with delegation to tagManager - Replaced listTagAliases() implementation (2 lines) with delegation to tagManager - Replaced removeTagAlias() implementation (12 lines) with delegation to tagManager - Replaced getAliasesForTag() implementation (6 lines) with delegation to tagManager - Added TagManager import and instance to KnowledgeGraphManager **Impact**: - Reduced index.ts from 1,821 lines to 1,758 lines (63 lines removed, 3.5% reduction) - Centralized all tag alias management in TagManager - TagManager provides: * Tag alias resolution (synonym to canonical mapping) * Alias creation with validation (prevents duplicates and chained aliases) * Alias listing and removal * Canonical tag lookup (find all synonyms for a tag) * JSONL file persistence (one alias per line) - All 396 tests passing **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 1,758 lines (58.1% total reduction) - Phases 1-14: 2,436 lines removed total - Remaining: ~1,558 lines of implementation code to refactor ## [0.36.0] - 2025-11-25 ### Changed - **Sprint 4: Saved Search Operations Delegation - Phase 13** - Delegate all saved search operations to SearchManager **Delegated Saved Search Operations**: Replaced inline implementations with SearchManager delegations - Removed loadSavedSearches() private helper (11 lines) - now handled by SavedSearchManager - Removed saveSavedSearches() private helper (3 lines) - now handled by SavedSearchManager - Replaced saveSearch() implementation (18 lines) with delegation to searchManager - Replaced listSavedSearches() implementation (2 lines) with delegation to searchManager - Replaced getSavedSearch() implementation (3 lines) with delegation to searchManager - Replaced executeSavedSearch() implementation (19 lines) with delegation to searchManager - Replaced deleteSavedSearch() implementation (11 lines) with delegation to searchManager - Replaced updateSavedSearch() implementation (12 lines) with delegation to searchManager **Impact**: - Reduced index.ts from 1,894 lines to 1,821 lines (73 lines removed, 3.9% reduction) - Centralized all saved search management in SearchManager/SavedSearchManager - SearchManager coordinates search execution through SavedSearchManager - Automatic usage statistics tracking (useCount, lastUsed) handled in SavedSearchManager - File persistence to JSONL format (one search per line) - All 396 tests passing **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 1,821 lines (56.6% total reduction) - Phases 1-13: 2,373 lines removed total - Remaining: ~1,621 lines of implementation code to refactor ## [0.35.0] - 2025-11-25 ### Changed - **Sprint 4: Analytics/Stats Operations Delegation - Phase 12** - Delegate graph analytics and validation to AnalyticsManager **Enhanced AnalyticsManager**: Added getGraphStats() method to AnalyticsManager, completing the analytics delegation - Added getGraphStats() method to AnalyticsManager (82 lines of implementation) * Calculates entity type counts and relation type counts * Finds oldest and newest entities with date tracking * Finds oldest and newest relations with date tracking * Provides comprehensive date range statistics - Added AnalyticsManager import and instance to KnowledgeGraphManager - Replaced getGraphStats() implementation in index.ts (69 lines) with delegation to AnalyticsManager - Replaced validateGraph() implementation in index.ts (127 lines) with delegation to AnalyticsManager **Impact**: - Reduced index.ts from 2,083 lines to 1,894 lines (189 lines removed, 9.1% reduction) - Centralized all graph analytics and validation in AnalyticsManager - AnalyticsManager now provides: * Comprehensive graph statistics (entities, relations, type distributions, date ranges) * Validation with detailed error and warning reporting * Orphaned relation detection * Duplicate entity detection * Invalid data detection * Isolated entity warnings * Missing metadata warnings - All 396 tests passing **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 1,894 lines (54.8% total reduction) - Phases 1-12: 2,300 lines removed total - Remaining: ~1,694 lines of implementation code to refactor ## [0.34.0] - 2025-11-25 ### Changed - **Sprint 4: Tag Operations Delegation - Phase 11** - Delegate entity tag operations to EntityManager **Added Tag Methods to EntityManager**: Enhanced EntityManager with comprehensive tag management capabilities - Added addTags() method to EntityManager (handles normalization and deduplication) - Added removeTags() method to EntityManager (handles tag removal with timestamps) - Added setImportance() method to EntityManager (validates importance range 0-10) - Added addTagsToMultipleEntities() method for bulk tagging operations - Added replaceTag() method for renaming tags across all entities - Removed addTags() implementation from index.ts (29 lines) → delegates to EntityManager - Removed removeTags() implementation from index.ts (33 lines) → delegates to EntityManager - Removed setImportance() implementation from index.ts (22 lines) → delegates to EntityManager - Removed addTagsToMultipleEntities() implementation from index.ts (32 lines) → delegates to EntityManager - Removed replaceTag() implementation from index.ts (24 lines) → delegates to EntityManager - Removed IMPORTANCE_RANGE import (no longer needed after delegation) **Impact**: - Reduced index.ts from 2,207 lines to 2,083 lines (124 lines removed, 5.6% reduction) - Centralized all entity tag management in EntityManager - Tag normalization (lowercase) handled consistently - Duplicate tag filtering automated - Timestamp updates on tag modifications - EntityManager now provides complete entity lifecycle management (CRUD + observations + tags + importance) - All 396 tests passing **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 2,083 lines (49.7% total reduction) - Phases 1-11: 2,111 lines removed total - Remaining: ~1,883 lines of implementation code to refactor ## [0.33.0] - 2025-11-25 ### Changed - **Sprint 4: Import/Export Operations Delegation - Phase 10** - Delegate all import/export operations to dedicated managers **Removed Duplicate Import/Export Implementations**: Refactored KnowledgeGraphManager to use ExportManager and ImportManager modules - Added ExportManager and ImportManager imports and instances to KnowledgeGraphManager - Replaced exportGraph() implementation (19 lines) with delegation to ExportManager - Removed ALL private export helper methods (438 lines total): * exportAsJson() (7 lines) * exportAsCsv() (56 lines) * exportAsGraphML() (89 lines) * exportAsGEXF() (96 lines) * exportAsDOT() (54 lines) * exportAsMarkdown() (65 lines) * exportAsMermaid() (71 lines) - Replaced importGraph() implementation (31 lines) with delegation to ImportManager - Removed ALL private import helper methods (314 lines total): * parseJsonImport() (21 lines) * parseCsvImport() (102 lines) * parseGraphMLImport() (68 lines) * mergeImportedGraph() (118 lines) **Impact**: - Reduced index.ts from 2,999 lines to 2,207 lines (792 lines removed, 26.4% reduction) - Eliminated all import/export format handling code from index.ts - Centralized format parsing in dedicated manager modules - ExportManager supports 7 export formats (JSON, CSV, GraphML, GEXF, DOT, Markdown, Mermaid) - ImportManager supports 3 import formats (JSON, CSV, GraphML) with merge strategies - Improved separation of concerns (format handling fully abstracted) - All 396 tests passing **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 2,207 lines (47.4% total reduction) - Phases 1-10: 1,987 lines removed total - Remaining: ~2,007 lines of implementation code to refactor ## [0.32.0] - 2025-11-25 ### Changed - **Sprint 4: Hierarchy Operations Delegation - Phase 9** - Delegate all hierarchy operations to HierarchyManager **Removed Duplicate Hierarchy Implementations**: Refactored KnowledgeGraphManager to use HierarchyManager module - Added HierarchyManager import and instance to KnowledgeGraphManager - Removed setEntityParent() implementation (27 lines) → delegates to HierarchyManager - Removed wouldCreateCycle() helper method (19 lines) → encapsulated in HierarchyManager - Removed getChildren() implementation (10 lines) → delegates to HierarchyManager - Removed getParent() implementation (15 lines) → delegates to HierarchyManager - Removed getAncestors() implementation (18 lines) → delegates to HierarchyManager - Removed getDescendants() implementation (23 lines) → delegates to HierarchyManager - Removed getSubtree() implementation (22 lines) → delegates to HierarchyManager - Removed getRootEntities() implementation (4 lines) → delegates to HierarchyManager - Removed getEntityDepth() implementation (4 lines) → delegates to HierarchyManager - Removed moveEntity() implementation (3 lines) → delegates to HierarchyManager **Impact**: - Reduced index.ts from 3,118 lines to 2,999 lines (119 lines removed, 3.8% reduction) - Eliminated all hierarchy management logic from index.ts - Centralized hierarchy operations in HierarchyManager - Cycle detection logic now encapsulated in dedicated module - Improved separation of concerns (hierarchy logic fully abstracted) - All 9 hierarchy methods now use single source of truth **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 2,999 lines (28.5% total reduction) - Phases 1-9: 1,195 lines removed total - Remaining: ~2,799 lines of implementation code to refactor ## [0.31.0] - 2025-11-25 ### Changed - **Sprint 4: Observation Management Delegation - Phase 8** - Delegate observation operations to EntityManager **Added Observation Methods to EntityManager**: Enhanced EntityManager with batch observation operations - Added addObservations() method to EntityManager (handles duplicate detection and timestamp updates) - Added deleteObservations() method to EntityManager (handles cascade updates and timestamps) - Removed addObservations() implementation from index.ts (19 lines) → delegates to EntityManager - Removed deleteObservations() implementation from index.ts (16 lines) → delegates to EntityManager - Updated error handling to use EntityNotFoundError instead of generic Error - Fixed test expectation to match EntityNotFoundError message format **Impact**: - Reduced index.ts from 3,147 lines to 3,118 lines (29 lines removed, 0.9% reduction) - Centralized observation management in EntityManager - Consistent error handling using EntityNotFoundError - Improved code organization with all entity operations in one module - EntityManager now handles full entity lifecycle: create, read, update, delete, and observation management **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 3,118 lines (25.7% total reduction) - Phases 1-8: 1,076 lines removed total - Remaining: ~2,918 lines of implementation code to refactor ## [0.30.0] - 2025-11-25 ### Changed - **Sprint 4: Compression Operations Delegation - Phase 7** - Delegate duplicate detection and merging to CompressionManager **Removed Duplicate Compression Logic**: Refactored KnowledgeGraphManager to use CompressionManager module - Removed findDuplicates() implementation (35 lines) → delegates to CompressionManager - Removed mergeEntities() implementation (89 lines) → delegates to CompressionManager - Removed compressGraph() implementation (51 lines) → delegates to CompressionManager - Removed calculateEntitySimilarity() helper method (39 lines) - Removed SIMILARITY_WEIGHTS and levenshteinDistance from imports (unused after delegation) - Added CompressionManager instance to KnowledgeGraphManager **Impact**: - Reduced index.ts from 3,351 lines to 3,147 lines (204 lines removed, 6.1% reduction) - Eliminated ~200 lines of duplicate compression and similarity calculation logic - Single source of truth for duplicate detection with configurable similarity weights - Improved separation of concerns (compression logic fully abstracted) - CompressionManager uses multi-factor similarity scoring (name, type, observations, tags) - Duplicate detection with Levenshtein distance and Jaccard similarity - Merge operations with observation/tag deduplication and importance aggregation **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 3,147 lines (25.0% total reduction) - Phases 1-7: 1,047 lines removed total - Remaining: ~2,947 lines of implementation code to refactor ## [0.29.0] - 2025-11-25 ### Changed - **Sprint 4: Search Operations Delegation - Phase 6** - Delegate all search operations to SearchManager **Removed Duplicate Search Implementations**: Refactored KnowledgeGraphManager to use SearchManager facade - Removed searchNodes() implementation (48 lines) → delegates to SearchManager - Removed openNodes() implementation (17 lines) → delegates to SearchManager - Removed searchByDateRange() implementation (62 lines) → delegates to SearchManager - Removed fuzzySearch() implementation (52 lines) → delegates to SearchManager - Removed getSearchSuggestions() implementation (36 lines) → delegates to SearchManager - Removed searchNodesRanked() implementation (82 lines) → delegates to SearchManager - Removed booleanSearch() implementation (58 lines) → delegates to SearchManager - Removed all TF-IDF helper methods (50 lines): tokenize, calculateTF, calculateIDF, calculateTFIDF, entityToDocument - Removed all boolean query parsing helpers (206 lines): tokenizeBooleanQuery, parseBooleanQuery, evaluateBooleanQuery, entityMatchesTerm - Removed isFuzzyMatch() helper method (24 lines) - Added SearchManager instance coordinating BasicSearch, RankedSearch, BooleanSearch, FuzzySearch modules **Impact**: - Reduced index.ts from 3,972 lines to 3,351 lines (621 lines removed, 15.6% reduction) - Eliminated ~600 lines of duplicate search logic and helper methods - Single source of truth for all search operations with caching and pagination - Improved separation of concerns (search logic fully abstracted) - SearchManager coordinates 4 specialized search modules with consistent interfaces - All search methods benefit from caching (100x+ speedup), TF-IDF indexing (10x+ speedup), pagination - Boolean query parser with full AST support now in dedicated module - Search suggestions with Levenshtein distance in dedicated module **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 3,351 lines (20.1% total reduction) - Phases 1-6: 843 lines removed total - Remaining: ~3,151 lines of implementation code to refactor ## [0.28.0] - 2025-11-25 ### Changed - **Sprint 4a: Relation Operations Delegation - Phase 5** - Delegate relation operations to RelationManager **Removed Duplicate Relation Operations**: Refactored KnowledgeGraphManager to use RelationManager module - Removed 15-line duplicate createRelations() implementation - Removed 26-line duplicate deleteRelations() implementation - Added RelationManager instance to KnowledgeGraphManager - Replaced inline implementations with delegation to relationManager.createRelations() and relationManager.deleteRelations() **Impact**: - Reduced index.ts from 3,995 lines to 3,954 lines (41 lines removed) - Eliminated duplicate relation creation and deletion logic - Single source of truth for relation operations with proper validation - Improved separation of concerns (relation management abstracted) - RelationManager now handles validation, timestamp management, and affected entity updates - Cascading lastModified updates for entities involved in deleted relations **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 3,954 lines (5.7% total reduction) - Phases 1-5: 240 lines removed total - Remaining: ~3,754 lines of implementation code to refactor ## [0.27.0] - 2025-11-25 ### Changed - **Sprint 4a: Entity Operations Delegation - Phase 4** - Delegate entity operations to EntityManager **Removed Duplicate Entity Operations**: Refactored KnowledgeGraphManager to use EntityManager module - Removed 29-line duplicate createEntities() implementation - Removed 6-line duplicate deleteEntities() implementation - Added EntityManager instance to KnowledgeGraphManager - Replaced inline implementations with delegation to entityManager.createEntities() and entityManager.deleteEntities() - Updated BatchCreateEntitiesSchema and BatchCreateRelationsSchema to allow empty arrays (no-op behavior) - Updated EntityManager unit test to expect empty array handling instead of validation error **Impact**: - Reduced index.ts from 4,030 lines to 3,995 lines (35 lines removed) - Eliminated duplicate entity creation and deletion logic - Single source of truth for entity operations with proper validation - Improved separation of concerns (entity management abstracted) - EntityManager now handles validation, timestamp management, tag normalization, and graph limits - Consistent behavior with batch operations (empty arrays return empty results) **Progress Toward Goal**: - Target: Reduce index.ts from 4,194 lines to <200 lines - Current: 3,995 lines (4.7% total reduction) - Phases 1-4: 199 lines removed total - Remaining: ~3,795 lines of implementation code to refactor ## [0.26.0] - 2025-11-25 ### Changed - **Sprint 4: Modular Architecture Refactoring - Phase 3 (Task 4.1)** - Delegate to GraphStorage module **Removed Duplicate Storage Implementations**: Refactored KnowledgeGraphManager to use GraphStorage module - Removed 58-line duplicate loadGraph() implementation - Removed 25-line duplicate saveGraph() implementation - Added GraphStorage instance to KnowledgeGraphManager - Replaced inline implementations with delegation to storage.loadGraph() and storage.saveGraph() - Removed unused memoryFilePath private property **Impact**: - Reduced index.ts from 4,079 lines to 4,030 lines (49 lines removed) - Eliminated duplicate file I/O and JSONL parsing logic - Single source of truth for graph persistence - Improved separation of concerns (storage layer abstracted) - Automatic cache invalidation and search cache clearing now applies **Progress Toward Goal**: - Target: Reduce index.ts from 4,188 lines to <200 lines - Current: 4,030 lines (3.8% total reduction) - Phases 1-3: 164 lines removed total - Remaining: ~3,830 lines of implementation code to refactor ## [0.25.0] - 2025-11-25 ### Changed - **Sprint 4: Modular Architecture Refactoring - Phase 2 (Task 4.1)** - Replace inline implementations **Removed Duplicate levenshteinDistance Implementation**: Replaced 24-line inline implementation with import from utils module - Removed private levenshteinDistance() method from Knowledge GraphManager - Added import of levenshteinDistance from utils/levenshtein.js - Updated all 4 call sites to use imported function instead of class method - isFuzzyMatch() now uses imported levenshteinDistance function **Impact**: - Reduced index.ts from 4,107 lines to 4,079 lines (28 lines removed) - Eliminated duplicate Levenshtein distance algorithm - Single source of truth for string similarity calculations - Improved code reuse and maintainability **Progress Toward Goal**: - Target: Reduce index.ts from 4,188 lines to <200 lines - Current: 4,079 lines (2.6% total reduction) - Phase 1 + Phase 2: 115 lines removed - Remaining: ~3,880 lines of implementation code to refactor ## [0.24.0] - 2025-11-25 ### Changed - **Sprint 4: Modular Architecture Refactoring - Phase 1 (Task 4.1)** - Code cleanup and deduplication **Removed Duplicate Type Definitions**: Cleaned up index.ts by removing 118 lines of duplicate type definitions - Removed duplicate Entity, Relation, KnowledgeGraph interface definitions - Removed duplicate GraphStats, ValidationReport, ValidationError, ValidationWarning definitions - Removed duplicate SavedSearch, TagAlias, SearchResult interface definitions - Removed duplicate BooleanQueryNode, ImportResult, CompressionResult type definitions - Added imports from types/index.js module instead - Re-exported types for backward compatibility **Impact**: - Reduced index.ts from 4,194 lines to 4,107 lines (87 lines removed) - Eliminated type definition duplication between index.ts and types/ module - Improved maintainability (single source of truth for types) - All functionality preserved, fully backward compatible **Progress Toward Goal**: - Target: Reduce index.ts from 4,188 lines to <200 lines - Current: 4,107 lines (2% reduction) - Remaining: ~3,900 lines of implementation code to refactor ## [0.23.0] - 2025-11-25 ### Added - **Sprint 3: Search Result Caching (Task 3.5)** - Faster repeated queries with LRU caching **Search Result Caching**: Cache frequent queries to improve performance for repeated searches - Added SearchCache class with LRU eviction and TTL expiration - Integrated caching into BasicSearch for searchNodes() and searchByDateRange() - Automatic cache invalidation when graph data changes - No external dependencies (pure TypeScript implementation) - Cache statistics tracking for monitoring **Implementation Details**: - SearchCache with configurable max size (default: 500 entries) and TTL (default: 5 minutes) - Hash-based key generation from query parameters - LRU eviction when cache reaches capacity - TTL-based automatic expiration - Global caches for different search types (basic, ranked, boolean, fuzzy) - GraphStorage.saveGraph() automatically clears all caches on write **Features**: - Get/set operations with automatic cache key generation - Cache statistics (hits, misses, size, hit rate) - Periodic cleanup of expired entries - Optional cache disable via constructor parameter (enableCache: boolean) - clearAllSearchCaches() utility for manual invalidation - getAllCacheStats() for monitoring all cache performance **Performance Benefits**: - Instant results for repeated identical queries - Reduced CPU and I/O for frequent searches - Expected 100x+ speedup for cached results - Configurable trade-off between memory and performance ### Changed - BasicSearch constructor now accepts optional `enableCache` parameter (default: true) - BasicSearch.searchNodes() and searchByDateRange() use result caching - GraphStorage.saveGraph() clears all search caches to maintain consistency ## [0.22.0] - 2025-11-25 ### Added - **Sprint 3: Pre-calculated TF-IDF Indexes (Task 3.4)** - 10x+ faster ranked search **TF-IDF Index Pre-calculation**: Speed up ranked search with pre-calculated indexes - Added TFIDFIndexManager for index lifecycle management - Added DocumentVector and TFIDFIndex types for structured index storage - Modified RankedSearch to use pre-calculated indexes when available - Falls back to on-the-fly calculation if index not available - Supports incremental index updates for entity changes - Index persistence to disk in `.indexes/tfidf-index.json` **Implementation Details**: - RankedSearch constructor accepts optional `storageDir` parameter - TFIDFIndexManager.buildIndex() creates full index from knowledge graph - TFIDFIndexManager.updateIndex() efficiently updates changed entities - Pre-calculated term frequencies and IDF stored in JSON format - Index automatically loaded from disk on first search - Backward compatible (works without index, just slower) **Performance Benefits**: - Pre-calculated indexes eliminate redundant TF-IDF calculations - Incremental updates avoid full index rebuilds - Fast path when index available, slow path as fallback - Expected 10x+ speedup for ranked search on large graphs - Reduced CPU usage during search operations ### Changed - RankedSearch constructor now accepts optional `storageDir` parameter for index management - RankedSearch.searchNodesRanked() uses pre-calculated index when available - Added TFIDFIndexManager to manage index building, updating, and persistence ## [0.21.0] - 2025-11-25 ### Added - **Sprint 3: Graph Size Limits & Query Complexity Limits (Tasks 3.7 & 3.9)** - Resource protection **Graph Size Limits (Task 3.7)**: Prevent resource exhaustion with entity and relation quotas - Added GRAPH_LIMITS constants: MAX_ENTITIES (100,000), MAX_RELATIONS (1,000,000) - EntityManager.createEntities() validates entity count before adding - RelationManager.createRelations() validates relation count before adding - Throws ValidationError if limits would be exceeded - Pre-filters duplicates before checking limits for accuracy **Query Complexity Limits (Task 3.9)**: Prevent complex boolean queries from exhausting resources - Added QUERY_LIMITS constants: MAX_DEPTH (10), MAX_TERMS (50), MAX_OPERATORS (20), MAX_QUERY_LENGTH (5000) - BooleanSearch validates query length before parsing - BooleanSearch.validateQueryComplexity() checks nesting depth, term count, operator count - BooleanSearch.calculateQueryComplexity() recursively analyzes query AST - Throws ValidationError with specific metrics if complexity exceeds limits **Features**: - Centralized limit constants in utils/constants.ts - Early validation before expensive operations - Clear error messages with actual vs. maximum values - Protection against malicious or accidental resource exhaustion - Configurable limits for different deployment scenarios ### Changed - EntityManager.createEntities() now validates graph size limits before adding entities - RelationManager.createRelations() now validates graph size limits before adding relations - BooleanSearch.booleanSearch() now validates query complexity before execution ### Security - Protection against resource exhaustion attacks via large graphs - Protection against denial-of-service via complex boolean queries - Input validation prevents malicious query construction ## [0.20.0] - 2025-11-25 ### Added - **Sprint 3: Pagination for Search Operations (Tasks 3.1-3.3)** - Efficient result pagination **Pagination Implementation**: Added offset/limit parameters to 3 search methods - BasicSearch.searchNodes() - Added offset (default: 0) and limit (default: 50, max: 200) parameters - BasicSearch.searchByDateRange() - Added offset and limit parameters - BooleanSearch.booleanSearch() - Added offset and limit parameters - FuzzySearch.fuzzySearch() - Added offset and limit parameters **Features**: - Validated pagination parameters (offset >= 0, limit 1-200) - Used centralized SEARCH_LIMITS constants - Applied pagination after filtering for efficiency - Relations filtered to match paginated entities only - Backward compatible (new parameters are optional with defaults) **Performance Benefits**: - Reduced network payload for large result sets - Improved client-side rendering performance - Consistent behavior across all search methods - Standard defaults (50 results) with configurable limits ### Changed - BasicSearch.searchNodes() signature extended with optional offset and limit - BasicSearch.searchByDateRange() signature extended with optional offset and limit - BooleanSearch.booleanSearch() signature extended with optional offset and limit - FuzzySearch.fuzzySearch() signature extended with optional offset and limit ### Documentation - Updated JSDoc comments with pagination parameter documentation - All changes backward compatible (optional parameters with defaults) ## [0.19.0] - 2025-11-25 ### Added - **Sprint 2: API Reference Documentation (Task 2.9)** - Complete API reference for all 45 tools **API Documentation**: API.md (comprehensive tool reference) - Entity Management (7 tools): createEntities, getEntity, updateEntity, deleteEntities, batchUpdateEntities, listEntities, observeEntity - Relation Management (5 tools): createRelations, getRelations, deleteRelations, listRelations, getRelationTypes - Search Operations (7 tools): searchNodes, searchNodesRanked, booleanSearch, fuzzySearch, openNodes, searchByDateRange, searchByTags - Compression & Deduplication (3 tools): findDuplicates, mergeEntities, compressGraph - Tag Management (5 tools): addTagsToEntities, removeTagsFromEntities, listTags, createTagAlias, getTagSuggestions - Hierarchies (3 tools): setParent, getChildren, getDescendants - Statistics (3 tools): getStats, getEntityTypeStats, getTagStats - Export Operations (3 tools): exportGraph, exportEntities, exportByQuery - Import Operations (1 tool): importGraph - Graph Operations (2 tools): clearGraph, validateGraph - Utility Operations (6 tools): searchSimilarEntities, getEntityHistory, bulkImportObservations, renameEntity, getRecentlyModified, getOrphanedEntities - Common Patterns: Create & connect, search & update, find & merge duplicates - Performance Guidelines: Benchmark table with expected times - Best Practices: 7 recommended practices for optimal usage - Files: `docs/API.md` ### Documentation - **API Reference**: Complete reference for all 45 MCP tools (600+ lines) - **Tool Categories**: Organized into 11 functional categories - **Code Examples**: JSON examples for all tools and common patterns - **Performance Guidance**: Expected times for all operations - **Error Handling**: Standard error format documented - **Best Practices**: 7 guidelines for optimal usage ## [0.18.0] - 2025-11-25 ### Added - **Sprint 2: Architecture Documentation (Task 2.8)** - Comprehensive system architecture guide **Architecture Documentation**: ARCHITECTURE.md (comprehensive system design) - System Overview: Statistics, key features, architecture principles - System Context: MCP client interaction, external actors, system boundaries - Component Architecture: Detailed breakdown of all layers (MCP handler, managers, storage, utils) - Data Model: Entity, Relation, KnowledgeGraph schemas with validation rules - Key Design Decisions: Rationale for JSONL format, in-memory processing, modularity, bucketing, deferred integrity - Data Flow Patterns: Step-by-step flows for create, batch update, search, compression operations - Performance Considerations: Benchmarks table, optimization strategies, scalability limits - Security Architecture: Input validation, path traversal protection, no code injection, error handling - Testing Strategy: Test pyramid, test categories (396 tests), coverage metrics (98%+) - Future Enhancements: Planned improvements and architectural evolution - Files: `docs/ARCHITECTURE.md` ### Documentation - **Architecture Guide**: Complete system architecture (10 sections, 500+ lines) - **Design Rationale**: Explained all major design decisions with trade-offs - **Performance Documentation**: Benchmarks table with 13 operations documented - **Security Model**: Comprehensive security architecture ## [0.17.0] - 2025-11-25 ### Added - **Sprint 2: Performance Tests (Task 2.7)** - Comprehensive performance benchmarks and budgets **Performance Benchmark Tests**: +24 tests - Entity Creation Performance (4 tests): 1 entity (<50ms), 100 entities (<200ms), 1000 entities (<1500ms), batch update 100 (<200ms) - Relation Creation Performance (2 tests): 100 relations (<200ms), 1000 relations (<1500ms) - Search Performance (6 tests): Basic search (<100ms), ranked search (<600ms), boolean search (<150ms), fuzzy search (<200ms), filtered search (<150ms), open 50 nodes (<100ms) - Compression Performance (3 tests): Find duplicates in 100/500 entities (<300ms/<1500ms), compress graph (<400ms) - Graph Loading/Saving (4 tests): Load 100/1000 entities (<100ms/<500ms), save 100/1000 entities (<150ms/<800ms) - Complex Workflows (3 tests): Full CRUD (<300ms), bulk workflow (<500ms), complex query workflow (<400ms) - Memory Efficiency (2 tests): 2000 entities, 5000 total elements (entities + relations) - Files: `__tests__/performance/benchmarks.test.ts` ### Testing - **Test Count**: 396 tests (up from 372, +24 performance tests, +6% increase) - **Performance Budgets**: All operations meet defined performance targets - **All Tests Passing**: 396/396 ✅ - **TypeScript Strict Mode**: ✅ All type checks passing ## [0.16.0] - 2025-11-25 ### Added - **Sprint 2: Edge Case Tests (Task 2.6)** - Comprehensive robustness testing **Edge Case Tests**: +35 tests - Unicode and Special Characters: Emoji, mixed scripts (Cyrillic, CJK, Arabic), RTL text, zero-width chars - Extreme Values: 100 observations, 50 tags, 250-char names, boundary importance values (0, 10) - Empty/Null-like Values: Empty strings, whitespace-only names, empty arrays - Search Edge Cases: Long queries (100+ words), empty queries, nested parentheses, fuzzy thresholds (0, 1) - Relation Edge Cases: Self-references, circular relations (A→B→C→A), long relation types (90 chars), multiple relations - Concurrent Operations: Simultaneous entity creations, concurrent reads/writes - Validation Edge Cases: Invalid importance (-1, 11, 5.5), whitespace handling - Large Graph Operations: 100+ relations per entity, 500+ entities performance (<2s) - Special Query Characters: Regex patterns, SQL injection patterns, XSS patterns - Files: `__tests__/edge-cases/edge-cases.test.ts` ### Testing - **Test Count**: 372 tests (up from 337, +35 edge case tests, +10% increase) - **Edge Case Coverage**: Unicode, extreme values, concurrent operations, large graphs - **All Tests Passing**: 372/372 ✅ - **TypeScript Strict Mode**: ✅ All type checks passing ## [0.15.0] - 2025-11-25 ### Added - **Sprint 2: Integration Tests (Task 2.5)** - End-to-end workflow testing **Integration Workflow Tests**: +12 tests - Entity Creation and Search Workflow: Complete CRUD with multi-method search validation - Compression and Search Workflow: Duplicate merging with search consistency - Batch Update Workflow: Atomic updates with timestamp consistency verification - Complex Query Workflow: Boolean queries on large datasets, ranked search with filters - Date Range and Tag Workflow: Temporal filtering combined with tag filters - Error Handling Workflows: Deferred integrity, atomic rollback validation - Real-World Scenario: Complete team knowledge base (15+ operations) - Performance Testing: 100+ entities search efficiency (<1 second) - Files: `__tests__/integration/workflows.test.ts` ### Testing - **Test Count**: 337 tests (up from 325, +12 integration tests, +4% increase) - **Integration Coverage**: End-to-end workflows validated across all managers - **All Tests Passing**: 337/337 ✅ - **TypeScript Strict Mode**: ✅ All type checks passing ## [0.14.0] - 2025-11-25 ### Added - **Sprint 2: Search Manager Tests (Task 2.4)** - Comprehensive test coverage for all search implementations **BasicSearch Tests**: +37 tests - searchNodes(): 21 tests for text search, tag filtering, importance filtering, combined filters - openNodes(): 8 tests for entity retrieval by name, relation handling - searchByDateRange(): 11 tests for date-based filtering with optional filters - Edge cases: empty query, entities without tags/importance - Coverage: 98.41% statement coverage - Files: `__tests__/unit/search/BasicSearch.test.ts` **RankedSearch Tests**: +35 tests - TF-IDF Scoring: 6 tests for relevance ranking, multi-term queries, score calculation - Matched Fields Tracking: 5 tests for name/type/observation match tracking - Tag Filtering: 5 tests for single/multiple tag filtering with text search - Importance Filtering: 5 tests for min/max/range filtering - Search Limits: 4 tests for default/custom/max limit enforcement - Edge Cases: 7 tests for empty query, special characters, unicode, stopwords - Coverage: 100% statement/branch/function coverage - Files: `__tests__/unit/search/RankedSearch.test.ts` **BooleanSearch Tests**: +52 tests - Boolean Operators: 11 tests for AND/OR/NOT operators, precedence - Field-Specific Queries: 10 tests for name:/type:/observation:/tag: queries - Quoted Strings: 3 tests for multi-word searches - Query Parsing: Complex nested queries, parentheses grouping - Error Handling: Malformed query detection (unclosed parenthesis, unexpected token) - Coverage: 99.19% statement coverage, 100% function coverage - Files: `__tests__/unit/search/BooleanSearch.test.ts` **FuzzySearch Tests**: +53 tests - Exact/Substring Matching: 5 tests for name/type/observation matching - Typo Tolerance: 6 tests for single/transposed/missing/extra characters - Threshold Variations: 6 tests for strict/permissive/default thresholds - Levenshtein Distance: 4 tests for similarity calculation edge cases - Word-level Matching: 3 tests for observation word matching with typos - Combined Filters: 3 tests for fuzzy search with tag/importance filters - Coverage: 97.5% statement coverage, 100% function coverage - Files: `__tests__/unit/search/FuzzySearch.test.ts` ### Testing - **Test Count**: 325 tests (up from 148, +177 search manager tests, +120% increase) - **New Coverage**: - BasicSearch: 98.41% coverage (was 0%) - RankedSearch: 100% coverage (was 0%) - BooleanSearch: 99.19% coverage (was 0%) - FuzzySearch: 97.5% coverage (was 0%) - **All Tests Passing**: 325/325 ✅ - **TypeScript Strict Mode**: ✅ All type checks passing ## [0.13.0] - 2025-11-25 ### Added - **Sprint 3: Performance Improvements** - Batch operations for efficient bulk updates **EntityManager.batchUpdate() (Task 3.6)**: Bulk entity updates - Update multiple entities in single atomic operation - Single graph load/save vs multiple operations (performance optimization) - All entities share same lastModified timestamp - Atomic operation: all succeed or all fail - Comprehensive validation before applying changes - Returns array of all updated entities - Files: `core/EntityManager.ts` **Test Coverage**: +9 tests - Multiple entity updates with different fields - Timestamp consistency across batch - Performance benefits (single I/O operation) - Atomic rollback on error (EntityNotFoundError, ValidationError) - Empty array and edge case handling - Field preservation for unchanged properties ### Performance - **Batch Operations**: Reduces I/O operations for bulk entity updates - Use case: Mass importance adjustments, bulk tagging, category updates - Before: N separate load/save operations for N entities - After: 1 load/save operation for N entities - Ideal for workflows updating 10+ entities simultaneously ### Testing - **Test Count**: 148 tests (up from 139, +9 tests) - **All Tests Passing**: 148/148 ✅ - **TypeScript Strict Mode**: ✅ All type checks passing ## [0.12.0] - 2025-11-25 ### Added - **Sprint 2: Testing & Core Coverage** - Comprehensive unit tests for critical managers **RelationManager Tests (Task 2.2)**: +24 tests - createRelations(): 8 tests for creation, validation, duplicate filtering - deleteRelations(): 6 tests for deletion, timestamp updates, cascading - getRelations(): 7 tests for incoming/outgoing relation retrieval - Graph integrity: 3 tests for referential integrity, circular relations - Full CRUD coverage with error handling - Files: `__tests__/unit/core/RelationManager.test.ts` **CompressionManager Tests (Task 2.3)**: +32 tests - findDuplicates(): 10 tests for similarity detection, bucketing optimization - mergeEntities(): 11 tests for observation/tag combination, relation redirection - compressGraph(): 5 tests for dry-run mode, statistics calculation - Edge cases: 6 tests for empty observations, long names, unicode, special chars - Validates sophisticated duplicate detection algorithm with type/prefix bucketing - Tests all merge strategies (highest importance, earliest createdAt, union of observations/tags) - Files: `__tests__/unit/features/CompressionManager.test.ts` ### Testing - **Test Count**: 139 tests (up from 83, +67% increase) - **Test Files**: 7 test suites covering core managers and features - **New Coverage**: - RelationManager: Comprehensive test coverage (was 0%) - CompressionManager: Comprehensive test coverage (was 0%) - **All Tests Passing**: 139/139 ✅ - **TypeScript Strict Mode**: ✅ All type checks passing - **Zero Vulnerabilities**: npm audit clean ✅ ## [0.11.7] - 2025-11-25 ### Changed - **Sprint 1: Code Quality & Quick Wins** - Systematic improvements from CODE_REVIEW.md analysis **Logging & Dependencies (Tasks 1.1-1.2)**: - Implemented proper logging utility with debug/info/warn/error levels (replaces inconsistent console.* usage) - Added LOG_LEVEL environment variable for debug logging control - Updated shx from 0.3.4 to 0.4.0 (removed deprecated inflight@1.0.6 memory leak, glob@7.2.3) - Files: `utils/logger.ts`, `index.ts`, `package.json` **Code Organization (Tasks 1.3, 1.6)**: - Extracted magic numbers to centralized constants for maintainability: - SIMILARITY_WEIGHTS (NAME: 0.4, TYPE: 0.2, OBSERVATION: 0.3, TAG: 0.1) - DEFAULT_DUPLICATE_THRESHOLD (0.8) - SEARCH_LIMITS (DEFAULT: 50, MAX: 200, MIN: 1) - IMPORTANCE_RANGE (MIN: 0, MAX: 10) - Replaced hardcoded values across index.ts, validationUtils.ts, schemas.ts, RankedSearch.ts - Files: `utils/constants.ts`, `index.ts`, `utils/validationUtils.ts`, `utils/schemas.ts`, `search/RankedSearch.ts` **Build Process (Task 1.4)**: - Simplified build script from "tsc && shx chmod +x dist/*.js" to just "tsc" - Shebang (#!/usr/bin/env node) automatically preserved by TypeScript compiler - Improved cross-platform compatibility - File: `package.json` **Documentation (Task 1.5)**: - Verified 100% JSDoc coverage across all public APIs (88 methods documented) - All core, features, and search modules fully documented with examples - Files: All `core/*.ts`, `features/*.ts`, `search/*.ts` modules ### Security - **Path Validation Enhancement (Task 1.7)**: Protection against path traversal attacks - Created validateFilePath() utility for comprehensive path validation - Normalizes paths, converts relative to absolute, detects path traversal (..) - Applied validation to MEMORY_FILE_PATH environment variable - Prevents ../../../etc/passwd type attacks with clear FileOperationError messages - File: `utils/pathUtils.ts` ### Fixed - **Type Safety Improvements (Task 1.8)**: Replaced `any` types with proper TypeScript types - Converted TransactionOperation to discriminated union (5 operation types with specific data) - Added exhaustiveness checking in transaction operation switch statements - Replaced `details?: any` with `details?: Record<string, unknown>` in ValidationError/ValidationWarning - Full compile-time type safety with strict mode enabled - Files: `core/TransactionManager.ts`, `types/analytics.types.ts`, `index.ts` ### Testing - **All Tests Passing**: 83/83 tests ✅ | TypeScript strict typecheck ✅ - **Zero Vulnerabilities**: npm audit clean ✅ - **Zero Deprecated Warnings**: All dependencies current ✅ ## [0.11.6] - 2025-11-25 ### Documentation - **Refactored README for GitHub Best Practices**: Removed status tracking, focused on features - Removed "What's New" section (version-specific status updates now in CHANGELOG only) - Removed version tags from Features section (e.g., "v0.9.0 Architecture Update") - Removed progress indicators and statistics (e.g., "✅ All 83 tests passing") - Added timeless "Key Features" section describing capabilities, not changes - Updated Features section to focus on what the project IS and CAN DO - Cleaned up Acknowledgments to remove version-specific stats - README now serves as documentation, CHANGELOG serves as history - **Documented Storage File Organization**: Complete configuration documentation - Added detailed `MEMORY_FILE_PATH` environment variable documentation - Added "Storage File Organization" section showing complete file structure - Documented backup directory location (`.backups/`) - Documented auxiliary files: `saved-searches.jsonl`, `tag-aliases.jsonl` - Added naming pattern explanation (all use same base filename with suffixes) - Added configuration examples with and without environment variable - Updated Data Model section with accurate storage file descriptions - Removed reference to non-existent `archive.jsonl` - **All Tests Passing**: 83/83 tests ✅ | TypeScript typecheck ✅ ## [0.11.5] - 2025-11-24 ### Added - **Transaction Support for Atomic Operations**: Prevents data corruption with ACID guarantees - Created `TransactionManager` for atomic multi-operation transactions - `begin()`: Start a new transaction - `commit()`: Apply all staged operations atomically (auto-rollback on failure) - `rollback()`: Manually rollback transaction to pre-transaction state - Stage operations: `createEntity()`, `updateEntity()`, `deleteEntity()`, `createRelation()`, `deleteRelation()` - Provides ACID guarantees: Atomicity, Consistency, Isolation, Durability - Creates automatic backup before commit for rollback capability - All operations succeed together or all fail (no partial failures) - Detailed transaction result with operation counts and error messages - Critical for data integrity in production systems - Files: `core/TransactionManager.ts`, `core/index.ts` - **Comprehensive Unit Tests**: Significantly improved test coverage - Created EntityManager test suite with 22 tests (100% passing) - Tests for createEntities, deleteEntities, getEntity, updateEntity - Tests for validation, persistence, timestamps, edge cases - Created GraphStorage test suite with 10 tests (100% passing) - Tests for loadGraph, saveGraph, caching layer - Tests for cache invalidation, deep copy, backwards compatibility - **83 tests passing** (up from 51, +62% increase) - Test coverage improvements: - Core utils/errors: 34.48% covered (up from 0%) - schemas.ts: 95.65% covered (up from 0%) - constants.ts: 100% covered - Files: `__tests__/unit/core/EntityManager.test.ts`, `__tests__/unit/core/GraphStorage.test.ts` ### Changed - **Updated README**: Documented all v0.11.x production features - Updated version badge to v0.11.5 - Added comprehensive "What's New" section - Documented security, performance, and data protection improvements - Added impact summary highlighting production-readiness - File: `README.md` ### Fixed - **Resolved Circular Import**: Fixed validation schema imports - Moved MIN_IMPORTANCE and MAX_IMPORTANCE constants to schemas.ts - Eliminated circular dependency between schemas.ts and EntityManager.ts - All validation tests now passing - File: `utils/schemas.ts` - **Relaxed Schema Strictness**: Improved validation flexibility - Removed `.strict()` modifier from CreateEntitySchema, UpdateEntitySchema, CreateRelationSchema - Allows for better compatibility with test data and edge cases - Maintains validation integrity while being more forgiving - File: `utils/schemas.ts` ## [0.11.4] - 2025-11-24 ### Added - **Backup and Restore Functionality**: Complete data protection with point-in-time recovery - Created `BackupManager` for managing graph backups - `createBackup()`: Create timestamped backups with metadata (entity/relation counts, file size, description) - `listBackups()`: List all available backups sorted by timestamp (newest first) - `restoreFromBackup()`: Restore graph from any backup file - `deleteBackup()`: Delete specific backup and metadata files - `cleanOldBackups()`: Automatic cleanup keeping N most recent backups (default: 10) - Backups stored in `.backups` directory with format: `backup_YYYY-MM-DD_HH-MM-SS-mmm.jsonl` - Each backup includes metadata file with timestamp, counts, and optional description - Provides critical data protection for production systems - All 51 tests passing ✅ - Files: `features/BackupManager.ts`, `features/index.ts` ## [0.11.3] - 2025-11-24 ### Added - **In-Memory Caching Layer for GraphStorage**: Eliminates repeated disk reads for performance - Implemented in-memory cache for knowledge graph data - Cache populated on first `loadGraph()` call - Returns deep copy of cached data to prevent external mutations - Cache automatically invalidated after every `saveGraph()` write - Added `clearCache()` method for manual cache invalidation - Reduces disk I/O from O(n) to O(1) for read-heavy workloads - Maintains data consistency with write-through invalidation strategy - All 51 tests passing ✅ - Files: `core/GraphStorage.ts` ## [0.11.2] - 2025-11-24 ### Changed - **Optimized Duplicate Detection Algorithm**: Reduced O(n²) complexity to O(n·k) in CompressionManager - Implemented two-level bucketing strategy for duplicate detection - Level 1: Bucket entities by entityType (only compare same types) - Level 2: Sub-bucket by name prefix (first 2 chars normalized) - Compares entities only within same or adjacent buckets - Complexity reduced from O(n²) to O(n·k) where k is average bucket size (typically << n) - For 10,000 entities with 100 types: ~50M comparisons → ~1M comparisons (50x improvement) - Maintains same accuracy as original algorithm while dramatically improving performance - All 51 tests passing ✅ - Files: `features/CompressionManager.ts` ## [0.11.1] - 2025-11-24 ### Added - **Input Validation with Zod Schemas**: Comprehensive runtime type validation for all input data - Created `utils/schemas.ts` with 14 validation schemas covering all input types - `EntitySchema` & `CreateEntitySchema`: Validate entity structure, names, types, observations, tags, importance (0-10) - `RelationSchema` & `CreateRelationSchema`: Validate relation structure with from/to/relationType - `UpdateEntitySchema`: Partial validation for entity updates - `BatchCreateEntitiesSchema` & `BatchCreateRelationsSchema`: Array validation with size constraints (1-1000 items) - `SearchQuerySchema`, `DateRangeSchema`, `TagAliasSchema`: Specialized validation for search and tag operations - Integrated validation into EntityManager (createEntities, deleteEntities, updateEntity) - Integrated validation into RelationManager (createRelations, deleteRelations) - ValidationError now provides detailed error messages with field paths - Prevents malformed data, SQL injection-style attacks, and invalid importance values - All 51 tests passing with strict TypeScript mode ✅ - Files: `utils/schemas.ts`, `utils/index.ts`, `core/EntityManager.ts`, `core/RelationManager.ts` ## [0.11.0] - 2025-11-24 ### Security - **Fixed All Security Vulnerabilities**: Updated dependencies to resolve 6 moderate CVEs - Updated `vitest` from 2.1.8 to 4.0.13 - Updated `@vitest/coverage-v8` from 2.1.8 to latest - Resolved esbuild vulnerability (GHSA-67mh-4wv8-2f99) - All dependencies now secure with 0 vulnerabilities ✅ - Files: `src/memory/package.json` ## [0.10.4] - 2025-11-24 ### Added - **Comprehensive Improvements Summary**: Created `IMPROVEMENTS_SUMMARY.md` documenting all enhancements - Complete version-by-version changelog from v0.9.4 to v0.10.3 - Detailed impact analysis and metrics - Before/after code comparisons - Best practices established - Developer experience improvements documented - Achievement summary: All 10 planned improvements completed ✅ ## [0.10.3] - 2025-11-24 ### Added - **Centralized Configuration Constants**: Created `utils/constants.ts` for application-wide constants - `FILE_EXTENSIONS`: Centralized file extension constants (JSONL, JSON) - `FILE_SUFFIXES`: File name suffixes for auxiliary files (saved searches, tag aliases) - `DEFAULT_FILE_NAMES`: Default file naming conventions - `ENV_VARS`: Environment variable names for configuration - `LOG_PREFIXES`: Consistent log message prefixes - Improves maintainability and reduces magic strings throughout codebase - Files: `utils/constants.ts`, `utils/index.ts` ## [0.10.2] - 2025-11-24 ### Added - **JSDoc Documentation for TagManager**: Comprehensive API documentation for tag alias system - `resolveTag()`: Tag resolution with alias following examples - `addTagAlias()`: Alias creation with validation rules and error scenarios - `getAliasesForTag()`: Retrieve all aliases for a canonical tag - Detailed examples showing synonym mapping and tag normalization - Files: `features/TagManager.ts` ## [0.10.1] - 2025-11-24 ### Added - **JSDoc Documentation for SearchManager**: Comprehensive API documentation for key search methods - `searchNodes()`: Enhanced basic search documentation with filtering examples - `searchNodesRanked()`: TF-IDF ranked search with relevance scoring examples - `booleanSearch()`: Boolean operators with complex query examples - `fuzzySearch()`: Typo-tolerant search with threshold tuning examples - `saveSearch()`: Saved search creation with metadata tracking - `executeSavedSearch()`: Execute saved searches with usage tracking - Files: `search/SearchManager.ts` ## [0.10.0] - 2025-11-24 ### Changed - **Improved Error Handling in CompressionManager**: Use custom error types - Replaced generic Error with InsufficientEntitiesError for merge operations - Replaced generic Error with EntityNotFoundError for missing entities - Updated JSDoc @throws annotations with specific error types - Enables better programmatic error handling for compression operations - Files: `features/CompressionManager.ts` ## [0.9.9] - 2025-11-24 ### Changed - **Improved Error Handling in HierarchyManager**: Use custom error types throughout - Replaced generic Error with EntityNotFoundError for missing entities - Replaced generic Error with CycleDetectedError for hierarchy cycles - Updated JSDoc @throws annotations with specific error types - Enables better programmatic error handling for hierarchical operations - Files: `features/HierarchyManager.ts` ## [0.9.8] - 2025-11-24 ### Added - **JSDoc Documentation for RelationManager**: Comprehensive API documentation for all public methods - `createRelations()`: Batch creation with duplicate filtering and timestamp management - `deleteRelations()`: Cascading timestamp updates for affected entities - `getRelations()`: Bidirectional relation lookup with filtering examples - Files: `core/RelationManager.ts` ## [0.9.7] - 2025-11-24 ### Added - **JSDoc Documentation for ObservationManager**: Comprehensive API documentation for all public methods - `addObservations()`: Batch addition with duplicate filtering and timestamp updates - `deleteObservations()`: Safe deletion with automatic timestamp management - Detailed examples showing single and multi-entity operations - Files: `core/ObservationManager.ts` ## [0.9.6] - 2025-11-24 ### Changed - **Improved Error Handling in ObservationManager**: Use EntityNotFoundError instead of generic Error - Better error messages with consistent error codes - Enables programmatic error handling for observation operations - Files: `core/ObservationManager.ts` ## [0.9.5] - 2025-11-24 ### Added - **JSDoc Documentation for EntityManager**: Comprehensive API documentation for all public methods - `createEntities()`: Detailed docs with batch creation examples, error handling, and timestamp behavior - `deleteEntities()`: Cascading deletion behavior documented with examples - `getEntity()`: Read-only retrieval with null-handling examples - `updateEntity()`: Partial update patterns with multiple field examples - Files: `core/EntityManager.ts` ## [0.9.4] - 2025-11-24 ### Added - **Custom Error Classes**: Comprehensive error type hierarchy for better error handling - `KnowledgeGraphError`: Base error class with error codes - `EntityNotFoundError`, `RelationNotFoundError`, `DuplicateEntityError` - `ValidationError`, `CycleDetectedError`, `InvalidImportanceError` - `FileOperationError`, `ImportError`, `ExportError`, `InsufficientEntitiesError` - All errors include error codes for programmatic handling - Files: `utils/errors.ts`, `core/EntityManager.ts` ### Changed - **Error Handling**: EntityManager now uses custom error types - Better error messages with context - Enables programmatic error handling ## [0.9.3] - 2025-11-24 ### Changed - **Type Safety Improved**: Replaced `any` with `unknown` in validation utils - Added `isObject()` type guard for runtime validation - Files: `utils/validationUtils.ts` ### Added - **JSDoc Documentation**: Comprehensive documentation for KnowledgeGraphManager getters - All getter properties have detailed JSDoc with examples - Files: `core/KnowledgeGraphManager.ts` ### Fixed - **Import Fix**: Removed `as any` type casting in KnowledgeGraphManager - Properly imports and uses BasicSearch instance ## [0.9.2] - 2025-11-24 ### Changed - **Magic Numbers Extracted**: Replaced hardcoded values with named constants - `SIMILARITY_WEIGHTS` in `CompressionManager.ts` (NAME: 40%, TYPE: 20%, OBSERVATIONS: 30%, TAGS: 10%) - `DEFAULT_DUPLICATE_THRESHOLD` (0.8) in `CompressionManager.ts` - `DEFAULT_SEARCH_LIMIT` (50) and `MAX_SEARCH_LIMIT` (200) in `RankedSearch.ts` - `MIN_IMPORTANCE` (0) and `MAX_IMPORTANCE` (10) in `EntityManager.ts` - `DEFAULT_FUZZY_THRESHOLD` (0.7) in `FuzzySearch.ts` - All constants are now documented and configurable - Improves code maintainability and tunability ### Fixed - **Search Limit Enforcement**: Added MAX_SEARCH_LIMIT enforcement in ranked search - Prevents resource exhaustion from excessively large limit values - Automatically caps limit at 200 results maximum ## [0.9.1] - 2025-11-24 ### Fixed - **Console Logging**: Replaced `console.error()` with `console.log()` for informational messages - Migration messages now use `[INFO]` prefix - Server startup messages now use `[INFO]` prefix - Keeps `console.error()` only for actual error conditions - Affected files: `index.ts`, `utils/pathUtils.ts` ### Changed - **Dependencies**: Updated npm dependencies to latest compatible versions - Improved security posture - Reduced deprecated dependency warnings ## [0.9.0] - 2025-11-23 ### Changed - Major Refactoring: Modular Architecture #### Complete Codebase Restructure Refactored monolithic `index.ts` (4,187 lines) into a clean, modular architecture with 40+ TypeScript files. **New Module Structure:** ``` src/memory/ ├── types/ (6 files) - Type definitions ├── utils/ (5 files) - Utility functions ├── core/ (5 files) - Storage & core managers ├── search/ (8 files) - Search implementations └── features/ (9 files) - Feature managers ``` **Key Improvements:** - ✅ **File Size Compliance**: All files under 400 lines (was 4,187 in monolith) - ✅ **Separation of Concerns**: Each module has single, clear responsibility - ✅ **Dependency Injection**: All managers receive dependencies via constructor - ✅ **Composition Pattern**: KnowledgeGraphManager orchestrates via composition - ✅ **Type Safety**: Comprehensive TypeScript interfaces throughout - ✅ **Barrel Exports**: Clean import paths for all modules **Modules Created:** *Types (6 files):* - `entity.types.ts` - Entity, Relation, KnowledgeGraph - `search.types.ts` - SearchResult, SavedSearch, BooleanQueryNode - `analytics.types.ts` - GraphStats, ValidationReport - `import-export.types.ts` - ImportResult, CompressionResult - `tag.types.ts` - TagAlias - `index.ts` - Barrel export *Utilities (5 files):* - `levenshtein.ts` - String similarity algorithm - `tfidf.ts` - TF-IDF search ranking - `dateUtils.ts` - Date parsing and validation - `validationUtils.ts` - Entity/relation validation - `pathUtils.ts` - File path management *Core (5 files):* - `GraphStorage.ts` - JSONL file I/O - `EntityManager.ts` - Entity CRUD operations - `RelationManager.ts` - Relation CRUD operations - `ObservationManager.ts` - Observation management - `KnowledgeGraphManager.ts` - Main orchestrator *Search (8 files):* - `BasicSearch.ts` - Text search with filters - `RankedSearch.ts` - TF-IDF relevance ranking - `BooleanSearch.ts` - AND/OR/NOT query parsing - `FuzzySearch.ts` - Typo-tolerant search - `SearchSuggestions.ts` - "Did you mean?" suggestions - `SavedSearchManager.ts` - Persistent saved searches - `SearchManager.ts` - Unified search orchestrator - `index.ts` - Barrel export *Features (9 files):* - `TagManager.ts` - Tag alias system - `HierarchyManager.ts` - Parent-child relationships - `AnalyticsManager.ts` - Graph validation - `CompressionManager.ts` - Duplicate detection/merging - `ArchiveManager.ts` - Entity archival - `ExportManager.ts` - Multi-format export (JSON, CSV, GraphML, GEXF, DOT, Markdown, Mermaid) - `ImportManager.ts` - Multi-format import with merge strategies - `ImportExportManager.ts` - Import/export orchestrator - `index.ts` - Barrel export **Quality Metrics:** - 📊 **40 TypeScript files** created (from 1 monolithic file) - 📏 **Average file size**: ~200 lines (95% reduction) - ✅ **TypeScript strict mode**: All files pass type checking - ✅ **Test coverage**: 51/51 tests passing - 📦 **Maintainability**: Easy to locate and modify functionality - 🧪 **Testability**: Each module can be tested in isolation **Backward Compatibility:** - ✅ Full API compatibility maintained - ✅ Same public interface via KnowledgeGraphManager - ✅ No breaking changes to existing integrations **Performance Benefits:** - ⚡ Faster imports (import only what you need) - 🌳 Better tree-shaking (unused modules eliminated) - 👥 Parallel development (teams work on different modules) - 🧪 Easier testing (isolated module testing) **Developer Experience:** - 📖 Comprehensive JSDoc documentation - 🎯 Clear module boundaries - 🔧 Dependency injection for flexibility - 📦 Barrel exports for clean imports **Migration:** ```typescript // Before (still works!) import { KnowledgeGraphManager } from './memory/index.js'; // After (recommended) import { KnowledgeGraphManager } from './memory/core/index.js'; // Or use specific modules import { EntityManager } from './memory/core/index.js'; import { RankedSearch } from './memory/search/index.js'; ``` ### Fixed - Resolved duplicate identifier conflicts in SearchManager - Fixed implicit any types in lambda parameters - Corrected barrel export function names in utils module - Fixed Levenshtein test assertion (expected value) ### Documentation - Added REFACTORING_SUMMARY.md with complete architecture overview - Added README files in each module directory - Comprehensive JSDoc comments on all public methods ## [0.8.0] - 2025-11-23 ### Added - Core Features: Hierarchical Nesting, Compression, and Archiving #### Phase 2: Hierarchical Nesting (8 new tools) **New Field:** - **parentId** (string): Optional parent entity reference for tree structures **New Tools:** - **set_entity_parent** - Set or remove entity parent with cycle detection - **get_children** - Get immediate children of an entity - **get_parent** - Get parent of an entity - **get_ancestors** - Get all ancestors (parent chain to root) - **get_descendants** - Get all descendants recursively - **get_subtree** - Get entity + descendants with relations - **get_root_entities** - Get all entities with no parent - **get_entity_depth** - Get depth in hierarchy (0 = root) **Features:** - Parent-child relationships for tree-like organization - Cycle detection prevents circular relationships - BFS traversal for descendants - Depth calculation for hierarchy analysis **Use Cases:** - Projects → Features → Tasks → Subtasks - Documents → Folders → Files → Sections - Categories → Subcategories → Specific Items #### Phase 3: Memory Compression (3 new tools) **New Interface:** - **CompressionResult** - Statistics for compression operations - duplicatesFound, entitiesMerged, observationsCompressed - relationsConsolidated, spaceFreed, mergedEntities **New Tools:** - **find_duplicates** - Find similar entities by threshold (default 0.8) - **merge_entities** - Merge multiple entities into one - **compress_graph** - Automated compression with dry-run mode **Features:** - Multi-factor similarity scoring (name, type, observations, tags) - Weighted algorithm: Name 40%, Type 20%, Observations 30%, Tags 10% - Levenshtein distance for name matching - Jaccard similarity for set overlap - Intelligent merging: combines unique observations/tags, preserves highest importance **Use Cases:** - Duplicate cleanup: Merge "Project Alpha" / "project-alpha" - Data consolidation: Unify fragmented knowledge - Storage optimization: Reduce graph size - Quality improvement: Automated deduplication #### Phase 4: Memory Archiving (1 new tool) **New Tool:** - **archive_entities** - Archive by age, importance, or tags **Criteria (OR logic):** - **olderThan** - Archive entities last modified before ISO date - **importanceLessThan** - Archive entities below importance threshold - **tags** - Archive entities with specific tags **Features:** - Multiple criteria support with OR logic - Dry-run mode for safe preview - Clean removal from active graph - Relation cleanup for archived entities **Use Cases:** - Temporal: Archive entities > 6 months old - Priority: Archive low-importance (< 3) entities - Status: Archive "completed", "draft", "deprecated" tags - Capacity: Keep active memory focused on current work ### Added - Tier 0 Enhancements (9 features, 18 new tools) #### Week 1: Core Quality Improvements **B5: Bulk Tag Operations (3 tools)** - **add_tags_to_multiple** - Add tags to multiple entities at once - **replace_tag** - Rename tag globally across all entities - **merge_tags** - Combine two tags into one **A1: Graph Validation (1 tool)** - **validate_graph** - Comprehensive graph integrity checks - Orphaned relations detection - Duplicate entity detection - Invalid data validation - Warnings for isolated entities, empty observations, missing metadata **C4: Saved Searches (5 tools)** - **save_search** - Save search query with metadata - **list_saved_searches** - List all saved searches - **get_saved_search** - Retrieve saved search - **execute_saved_search** - Run saved search with usage tracking - **delete_saved_search** - Remove saved search - **update_saved_search** - Modify saved search **C2: Fuzzy Search (2 tools)** - **fuzzy_search** - Typo-tolerant search using Levenshtein distance - **get_search_suggestions** - "Did you mean?" suggestions **B2: Tag Aliases (5 tools)** - **add_tag_alias** - Create tag synonym (e.g., "ai" → "artificial-intelligence") - **list_tag_aliases** - List all aliases - **get_aliases_for_tag** - Get aliases for canonical tag - **remove_tag_alias** - Delete alias - **resolve_tag** - Resolve alias to canonical form #### Week 2: Advanced Search & Import/Export **C1: Full-Text Search with TF-IDF Ranking (1 tool)** - **search_nodes_ranked** - Relevance-based search with TF-IDF scoring - Multi-term query support - Field-level match tracking - Configurable result limit (default 50, max 200) - Returns scores and matched fields **C3: Boolean Search (1 tool)** - **boolean_search** - Advanced queries with logical operators - Operators: AND, OR, NOT, parentheses - Field-specific: name:, type:, observation:, tag: - Quoted strings for exact phrases - Recursive descent parser with AST evaluation **D1: Additional Export Formats (4 new formats)** - **GEXF** - Gephi native format with full attributes - **DOT** - GraphViz for publication-quality graphs - **Markdown** - Human-readable documentation - **Mermaid** - Embedded diagrams with importance-based coloring - Updated export_graph tool to support 7 total formats **D2: Import Capabilities (1 tool)** - **import_graph** - Import from JSON, CSV, GraphML - Merge strategies: replace, skip, merge, fail - Dry-run mode for preview - ImportResult with detailed statistics - Error handling and validation ### Changed - Updated version from 0.7.0 to 0.8.0 - Total code expansion: 1,210 → 4,550 lines (+3,340 lines, +276%) - Total MCP tools: 15 → 45 tools (+30 new, +200%) - Export formats: 3 → 7 formats (+133%) - Storage files: 1 → 4 files (memory.jsonl, saved-searches, tag-aliases, archive) ### Technical Notes - All new fields optional for backward compatibility - Cycle detection for hierarchies prevents invalid states - Multi-factor similarity scoring for intelligent compression - Criteria-based archiving with OR logic - Dry-run modes for safe preview of destructive operations - Comprehensive error handling throughout ## [0.7.0] - 2025-11-09 ### Added - Phase 4: Export & Batch Operations #### New Tools - **export_graph** - Export knowledge graph in multiple formats - JSON format: Pretty-printed with all entity and relation data - CSV format: Two-section format (entities + relations) with proper escaping - GraphML format: Standard XML for visualization tools (Gephi, Cytoscape, yEd) - Optional filter parameter supports: startDate, endDate, entityType, tags - All export formats include Phase 1-3 fields (timestamps, tags, importance) #### Enhancements - Added JSDoc documentation to `createEntities()` and `createRelations()` for batch operation efficiency - Documented single `saveGraph()` call per batch operation - CSV export includes proper escaping for commas, quotes, and newlines - GraphML export includes all node/edge attributes with proper XML escaping ### Added - Phase 3: Tags & Importance Categorization #### New Fields - **tags** (string[]): Optional array of tags for entity categorization - Normalized to lowercase for case-insensitive matching - Persisted to JSONL storage - **importance** (number): Optional importance level (0-10 scale) - Validated on creation and modification - Used for filtering and prioritization #### New Tools - **add_tags** - Add tags to existing entities - Normalizes tags to lowercase - Prevents duplicates - Updates lastModified timestamp - **remove_tags** - Remove tags from entities - Case-insensitive matching - Updates lastModified timestamp - **set_importance** - Set entity importance level - Validates 0-10 range - Updates lastModified timestamp #### Enhanced Tools - **search_nodes** - Added optional filters: - `tags` (string[]): Filter by tags (case-insensitive) - `minImportance` (number): Minimum importance threshold - `maxImportance` (number): Maximum importance threshold - **search_by_date_range** - Added optional `tags` filter parameter ### Added - Phase 2: Search & Analytics #### New Tools - **search_by_date_range** - Filter entities and relations by date range - Parameters: startDate (optional), endDate (optional), entityType (optional) - Uses lastModified or createdAt as fallback - Returns filtered knowledge graph - **get_graph_stats** - Get comprehensive graph statistics - Total counts for entities and relations - Entity types breakdown (count per type) - Relation types breakdown (count per type) - Oldest and newest entities with dates - Oldest and newest relations with dates - Date ranges for entities and relations #### New Interface - **GraphStats** - TypeScript interface for statistics output - totalEntities, totalRelations - entityTypesCounts, relationTypesCounts - oldestEntity, newestEntity, oldestRelation, newestRelation - entityDateRange, relationDateRange ### Added - Phase 1: Timestamp Tracking #### New Fields - **createdAt** (string): ISO 8601 timestamp for entity/relation creation - Auto-generated if not provided - Persisted to JSONL storage - **lastModified** (string): ISO 8601 timestamp for last modification - Auto-updated on all modification operations - Smart updates: only changes when actual modifications occur #### Modified Methods - **createEntities()** - Auto-generates createdAt and lastModified timestamps - **createRelations()** - Auto-generates createdAt and lastModified timestamps - **addObservations()** - Updates lastModified only if observations added - **deleteObservations()** - Updates lastModified only if observations removed - **deleteRelations()** - Updates lastModified on affected entities - **loadGraph()** - Backward compatibility for data without timestamps - **saveGraph()** - Persists timestamps to JSONL format #### Technical Details - All timestamps use ISO 8601 format via `new Date().toISOString()` - Optional fields (`?`) ensure backward compatibility - Smart timestamp logic: only update when actual changes occur - Relation deletions update `lastModified` on affected entities ### Changed - Updated server version from 0.6.3 to 0.7.0 - Total code expansion: 713 → 1,210 lines (+497 lines, +70%) - Total MCP tools: 11 → 15 tools (+4 new) ### Technical Notes - All new fields are optional for backward compatibility - Existing data loads gracefully without timestamps, tags, or importance - All export formats maintain backward compatibility - Filter logic reused across search_nodes, searchByDateRange, and export_graph ## [0.6.3] - 2025-11-09 (Initial Fork) ### Added - Forked from modelcontextprotocol/servers - Base memory MCP with 11 original tools: - create_entities - create_relations - add_observations - delete_entities - delete_observations - delete_relations - read_graph - search_nodes - open_nodes ### Repository - GitHub: https://github.com/danielsimonjr/mcp-servers - Location: c:/mcp-servers/memory-mcp/ - Branch: main --- ## Summary of Enhancements | Phase | Features | Tools Added | Lines Added | |-------|----------|-------------|-------------| | Phase 1 | Timestamp tracking (createdAt, lastModified) | 0 | +223 | | Phase 2 | Search & analytics | 2 (search_by_date_range, get_graph_stats) | Included in Phase 1 | | Phase 3 | Tags & importance | 3 (add_tags, remove_tags, set_importance) | +249 | | Phase 4 | Export & batch ops | 1 (export_graph) | +248 | | **Total** | **All enhancements** | **+4 tools (15 total)** | **+497 lines (+70%)** | ## Links - [Repository](https://github.com/danielsimonjr/mcp-servers) - [Workflow Guide](WORKFLOW.md) - [Model Context Protocol](https://modelcontextprotocol.io)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/danielsimonjr/memory-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server