@danielsimonjr/memory-mcp 12.5.2 → 12.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/README.md +158 -14
  2. package/dist/core/EntityManager.d.ts +263 -0
  3. package/dist/core/EntityManager.d.ts.map +1 -0
  4. package/dist/core/EntityManager.js +478 -0
  5. package/dist/core/GraphStorage.d.ts +344 -0
  6. package/dist/core/GraphStorage.d.ts.map +1 -0
  7. package/dist/core/GraphStorage.js +708 -0
  8. package/dist/core/GraphTraversal.d.ts +136 -0
  9. package/dist/core/GraphTraversal.d.ts.map +1 -0
  10. package/dist/core/GraphTraversal.js +556 -0
  11. package/dist/core/HierarchyManager.d.ts +111 -0
  12. package/dist/core/HierarchyManager.d.ts.map +1 -0
  13. package/dist/core/HierarchyManager.js +224 -0
  14. package/dist/core/ManagerContext.d.ts +72 -0
  15. package/dist/core/ManagerContext.d.ts.map +1 -0
  16. package/dist/core/ManagerContext.js +118 -0
  17. package/dist/core/ObservationManager.d.ts +85 -0
  18. package/dist/core/ObservationManager.d.ts.map +1 -0
  19. package/dist/core/ObservationManager.js +123 -0
  20. package/dist/core/RelationManager.d.ts +131 -0
  21. package/dist/core/RelationManager.d.ts.map +1 -0
  22. package/dist/core/RelationManager.js +210 -0
  23. package/dist/core/SQLiteStorage.d.ts +354 -0
  24. package/dist/core/SQLiteStorage.d.ts.map +1 -0
  25. package/dist/core/SQLiteStorage.js +917 -0
  26. package/dist/core/StorageFactory.d.ts +45 -0
  27. package/dist/core/StorageFactory.d.ts.map +1 -0
  28. package/dist/core/StorageFactory.js +64 -0
  29. package/dist/core/TransactionManager.d.ts +259 -0
  30. package/dist/core/TransactionManager.d.ts.map +1 -0
  31. package/dist/core/TransactionManager.js +392 -0
  32. package/dist/core/index.d.ts +16 -0
  33. package/dist/core/index.d.ts.map +1 -0
  34. package/dist/core/index.js +17 -0
  35. package/dist/features/AnalyticsManager.d.ts +44 -0
  36. package/dist/features/AnalyticsManager.d.ts.map +1 -0
  37. package/dist/features/AnalyticsManager.js +223 -0
  38. package/dist/features/ArchiveManager.d.ts +121 -0
  39. package/dist/features/ArchiveManager.d.ts.map +1 -0
  40. package/dist/features/ArchiveManager.js +240 -0
  41. package/dist/features/CompressionManager.d.ts +109 -0
  42. package/dist/features/CompressionManager.d.ts.map +1 -0
  43. package/dist/features/CompressionManager.js +404 -0
  44. package/dist/features/IOManager.d.ts +221 -0
  45. package/dist/features/IOManager.d.ts.map +1 -0
  46. package/dist/features/IOManager.js +997 -0
  47. package/dist/features/StreamingExporter.d.ts +105 -0
  48. package/dist/features/StreamingExporter.d.ts.map +1 -0
  49. package/dist/features/StreamingExporter.js +150 -0
  50. package/dist/features/TagManager.d.ts +147 -0
  51. package/dist/features/TagManager.d.ts.map +1 -0
  52. package/dist/features/TagManager.js +210 -0
  53. package/dist/features/index.d.ts +12 -0
  54. package/dist/features/index.d.ts.map +1 -0
  55. package/dist/features/index.js +11 -0
  56. package/dist/index.js +16 -4
  57. package/dist/search/BasicSearch.d.ts +51 -0
  58. package/dist/search/BasicSearch.d.ts.map +1 -0
  59. package/dist/search/BasicSearch.js +137 -0
  60. package/dist/search/BooleanSearch.d.ts +98 -0
  61. package/dist/search/BooleanSearch.d.ts.map +1 -0
  62. package/dist/search/BooleanSearch.js +430 -0
  63. package/dist/search/EmbeddingService.d.ts +178 -0
  64. package/dist/search/EmbeddingService.d.ts.map +1 -0
  65. package/dist/search/EmbeddingService.js +358 -0
  66. package/dist/search/FuzzySearch.d.ts +118 -0
  67. package/dist/search/FuzzySearch.d.ts.map +1 -0
  68. package/dist/search/FuzzySearch.js +312 -0
  69. package/dist/search/RankedSearch.d.ts +71 -0
  70. package/dist/search/RankedSearch.d.ts.map +1 -0
  71. package/dist/search/RankedSearch.js +238 -0
  72. package/dist/search/SavedSearchManager.d.ts +79 -0
  73. package/dist/search/SavedSearchManager.d.ts.map +1 -0
  74. package/dist/search/SavedSearchManager.js +145 -0
  75. package/dist/search/SearchFilterChain.d.ts +120 -0
  76. package/dist/search/SearchFilterChain.d.ts.map +1 -0
  77. package/dist/search/SearchFilterChain.js +185 -0
  78. package/dist/search/SearchManager.d.ts +285 -0
  79. package/dist/search/SearchManager.d.ts.map +1 -0
  80. package/dist/search/SearchManager.js +338 -0
  81. package/dist/search/SearchSuggestions.d.ts +27 -0
  82. package/dist/search/SearchSuggestions.d.ts.map +1 -0
  83. package/dist/search/SearchSuggestions.js +57 -0
  84. package/dist/search/SemanticSearch.d.ts +146 -0
  85. package/dist/search/SemanticSearch.d.ts.map +1 -0
  86. package/dist/search/SemanticSearch.js +313 -0
  87. package/dist/search/TFIDFIndexManager.d.ts +63 -0
  88. package/dist/search/TFIDFIndexManager.d.ts.map +1 -0
  89. package/dist/search/TFIDFIndexManager.js +215 -0
  90. package/dist/search/VectorStore.d.ts +235 -0
  91. package/dist/search/VectorStore.d.ts.map +1 -0
  92. package/dist/search/VectorStore.js +311 -0
  93. package/dist/search/index.d.ts +18 -0
  94. package/dist/search/index.d.ts.map +1 -0
  95. package/dist/search/index.js +21 -0
  96. package/dist/server/MCPServer.d.ts.map +1 -1
  97. package/dist/server/toolDefinitions.d.ts +1 -1
  98. package/dist/server/toolDefinitions.d.ts.map +1 -1
  99. package/dist/server/toolDefinitions.js +254 -2
  100. package/dist/server/toolHandlers.d.ts.map +1 -1
  101. package/dist/server/toolHandlers.js +257 -26
  102. package/dist/types/index.d.ts +13 -0
  103. package/dist/types/index.d.ts.map +1 -0
  104. package/dist/types/index.js +12 -0
  105. package/dist/types/types.d.ts +1234 -0
  106. package/dist/types/types.d.ts.map +1 -0
  107. package/dist/types/types.js +9 -0
  108. package/dist/utils/compressedCache.d.ts +192 -0
  109. package/dist/utils/compressedCache.d.ts.map +1 -0
  110. package/dist/utils/compressedCache.js +309 -0
  111. package/dist/utils/compressionUtil.d.ts +214 -0
  112. package/dist/utils/compressionUtil.d.ts.map +1 -0
  113. package/dist/utils/compressionUtil.js +247 -0
  114. package/dist/utils/constants.d.ts +245 -0
  115. package/dist/utils/constants.d.ts.map +1 -0
  116. package/dist/utils/constants.js +252 -0
  117. package/dist/utils/entityUtils.d.ts +321 -0
  118. package/dist/utils/entityUtils.d.ts.map +1 -0
  119. package/dist/utils/entityUtils.js +538 -0
  120. package/dist/utils/errors.d.ts +77 -0
  121. package/dist/utils/errors.d.ts.map +1 -0
  122. package/dist/utils/errors.js +121 -0
  123. package/dist/utils/formatters.d.ts +145 -0
  124. package/dist/utils/formatters.d.ts.map +1 -0
  125. package/dist/utils/formatters.js +132 -0
  126. package/dist/utils/index.d.ts +22 -0
  127. package/dist/utils/index.d.ts.map +1 -0
  128. package/dist/utils/index.js +75 -0
  129. package/dist/utils/indexes.d.ts +270 -0
  130. package/dist/utils/indexes.d.ts.map +1 -0
  131. package/dist/utils/indexes.js +526 -0
  132. package/dist/utils/logger.d.ts +24 -0
  133. package/dist/utils/logger.d.ts.map +1 -0
  134. package/dist/utils/logger.js +33 -0
  135. package/dist/utils/parallelUtils.d.ts +72 -0
  136. package/dist/utils/parallelUtils.d.ts.map +1 -0
  137. package/dist/utils/parallelUtils.js +169 -0
  138. package/dist/utils/schemas.d.ts +374 -0
  139. package/dist/utils/schemas.d.ts.map +1 -0
  140. package/dist/utils/schemas.js +484 -0
  141. package/dist/utils/searchAlgorithms.d.ts +99 -0
  142. package/dist/utils/searchAlgorithms.d.ts.map +1 -0
  143. package/dist/utils/searchAlgorithms.js +167 -0
  144. package/dist/utils/searchCache.d.ts +108 -0
  145. package/dist/utils/searchCache.d.ts.map +1 -0
  146. package/dist/utils/searchCache.js +209 -0
  147. package/dist/utils/taskScheduler.d.ts +290 -0
  148. package/dist/utils/taskScheduler.d.ts.map +1 -0
  149. package/dist/utils/taskScheduler.js +466 -0
  150. package/dist/workers/WorkerPool.d.ts +81 -0
  151. package/dist/workers/WorkerPool.d.ts.map +1 -0
  152. package/dist/workers/WorkerPool.js +121 -0
  153. package/dist/workers/index.d.ts +12 -0
  154. package/dist/workers/index.d.ts.map +1 -0
  155. package/dist/workers/index.js +9 -0
  156. package/dist/workers/levenshteinWorker.d.ts +60 -0
  157. package/dist/workers/levenshteinWorker.d.ts.map +1 -0
  158. package/dist/workers/levenshteinWorker.js +98 -0
  159. package/package.json +9 -8
package/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # Memory MCP Server
2
2
 
3
- [![Version](https://img.shields.io/badge/version-12.5.1-blue.svg)](https://github.com/danielsimonjr/memory-mcp)
3
+ [![Version](https://img.shields.io/badge/version-12.7.0-blue.svg)](https://github.com/danielsimonjr/memory-mcp)
4
4
  [![NPM](https://img.shields.io/npm/v/@danielsimonjr/memory-mcp.svg)](https://www.npmjs.com/package/@danielsimonjr/memory-mcp)
5
5
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
6
6
  [![MCP](https://img.shields.io/badge/MCP-1.0-purple.svg)](https://modelcontextprotocol.io)
7
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.6-blue.svg)](https://www.typescriptlang.org/)
8
- [![Coverage](https://img.shields.io/badge/coverage-80.7%25-yellow.svg)](docs/architecture/TEST_COVERAGE.md)
8
+ [![Coverage](https://img.shields.io/badge/coverage-84.8%25-yellowgreen.svg)](docs/architecture/TEST_COVERAGE.md)
9
9
 
10
10
  An **enhanced fork** of the official [Model Context Protocol](https://modelcontextprotocol.io) memory server with advanced features for **hierarchical nesting**, **intelligent compression**, **semantic search**, **graph algorithms**, **archiving**, **advanced search**, and **multi-format import/export**.
11
11
 
12
- > **Enterprise-grade knowledge graph** with **213 tools** including hierarchical organization, semantic search with embeddings, graph traversal algorithms, duplicate detection, smart archiving, project scoping, temporal knowledge graph, semantic forget, agent diary, **entity bitemporal validity (η.4.4)**, **optimistic concurrency control (η.5.5.c)**, **role-based access control (η.6.1)**, **W3C Linked Data exports** (Turtle / JSON-LD / RDF/XML — η.5.4), **PII redaction on export** (η.6.3), **procedural memory (3B.4)**, **active retrieval (3B.5)**, **causal reasoning (3B.6)**, **world model (3B.7)**, **`do_not_remember` exclusions**, **decision rationale** (ADR memory + markdown dual-write), **structured project context** (facts / conventions / commands / glossary), **heuristic guidelines**, **tool affordance + ToolCallObserver pipeline** (with MCP shim), **observation dedup**, and **spell correction** (memoryjs v2.1.0 — Phase 16) for long-term memory management.
12
+ > **Enterprise-grade knowledge graph** with **241 tools** including hierarchical organization, semantic search with embeddings, graph traversal algorithms, duplicate detection, smart archiving, project scoping, temporal knowledge graph, semantic forget, agent diary, **entity bitemporal validity (η.4.4)**, **optimistic concurrency control (η.5.5.c)**, **role-based access control (η.6.1)**, **W3C Linked Data exports** (Turtle / JSON-LD / RDF/XML — η.5.4), **PII redaction on export** (η.6.3), **procedural memory (3B.4)**, **active retrieval (3B.5)**, **causal reasoning (3B.6)**, **world model (3B.7)**, **`do_not_remember` exclusions**, **decision rationale** (ADR memory + markdown dual-write), **structured project context** (facts / conventions / commands / glossary), **heuristic guidelines**, **tool affordance + ToolCallObserver pipeline** (with MCP shim), **observation dedup**, **spell correction** (memoryjs v2.1.0 — Phase 16), **n-ary event memory**, **reconstructive (Cue–Tag–Content) memory with snapshot persistence**, **relation consolidation**, **agent reflections**, and a **graph-connectivity hybrid-search channel with evidence-path explanations** (memoryjs v3.0.0 — v12.7.0) for long-term memory management.
13
13
 
14
14
  ## Table of Contents
15
15
 
@@ -21,6 +21,7 @@ An **enhanced fork** of the official [Model Context Protocol](https://modelconte
21
21
  - [Configuration](#configuration)
22
22
  - [Development](#development)
23
23
  - [Documentation](#documentation)
24
+ - [Companion Skill](#companion-skill)
24
25
  - [Contributing](#contributing)
25
26
  - [Changelog](#changelog)
26
27
  - [License](#license)
@@ -180,7 +181,7 @@ cd memory-mcp
180
181
  npm install
181
182
  npm run build
182
183
 
183
- # Run tests (665 tests, >80% statement coverage)
184
+ # Run tests (791 tests, ~85% statement coverage)
184
185
  npm test
185
186
 
186
187
  # Type check
@@ -259,9 +260,9 @@ Discrete facts about entities. Each observation should be atomic and independent
259
260
 
260
261
  ## API Reference
261
262
 
262
- ### Complete Tool List (160 Tools)
263
+ ### Complete Tool List (241 Tools)
263
264
 
264
- > Tool count: 160 tools across 51 categories. The 23 newest tools (Phase 15 / memoryjs v1.14+) are documented at the end under **Phase 15** sections. For full per-tool schemas see [docs/architecture/API.md](docs/architecture/API.md).
265
+ > Tool count: 241 tools across 65 categories. The newest tools are documented at the end under the **Phase 15**, **Phase 16 (memoryjs v2.1.0)**, **v12.3.2 / v12.5.0**, and **v12.7.0 (memoryjs v3.0.0)** sections. For full per-tool schemas see [docs/architecture/API.md](docs/architecture/API.md) or `src/server/toolDefinitions.ts`.
265
266
 
266
267
  #### Entity Operations (4 tools)
267
268
  | Tool | Description |
@@ -562,6 +563,142 @@ Discrete facts about entities. Each observation should be atomic and independent
562
563
  - **`create_entities`** — Now accepts v1.6 freshness fields (`ttl`, `confidence`), v1.8 project scope (`projectId`), and η.4.4 bitemporal fields (`validFrom`, `validUntil`, `observationMeta`) per entity.
563
564
  - **`set_memory_visibility`** — Auto-promotes plain entities to `AgentEntity` (stamps `agentId` / `memoryType` / `confidence`) instead of silently returning `null`. Supports η.5.5.b extensions (`allowedRoles`, `visibleFrom`, `visibleUntil`).
564
565
 
566
+ #### Tool Affordance (11 tools) — Phase 16 / memoryjs v2.1.0
567
+ | Tool | Description |
568
+ |------|-------------|
569
+ | `record_tool_outcome` | Record a tool call outcome (success/failure) into affordance stats |
570
+ | `get_tool_affordance_stats` | Per-tool success-rate and usage statistics |
571
+ | `suggest_tool` | Suggest the best tool for a task based on recorded affordances |
572
+ | `list_tool_affordances` | List all recorded tool affordances |
573
+ | `remove_tool_affordance` | Remove one tool's affordance record |
574
+ | `observe_tool_start` | `ToolCallObserver` lifecycle: mark a tool call started |
575
+ | `observe_tool_complete` | Mark an observed tool call completed successfully |
576
+ | `observe_tool_error` | Mark an observed tool call failed |
577
+ | `observe_tool_partial` | Mark an observed tool call partially successful |
578
+ | `observe_tool_cancel` | Cancel an in-flight tool observation |
579
+ | `tool_observer_in_flight_count` | Count of currently in-flight observed tool calls |
580
+
581
+ #### Heuristic Guidelines (10 tools) — Phase 16 / memoryjs v2.1.0
582
+ | Tool | Description |
583
+ |------|-------------|
584
+ | `add_heuristic` | Store a heuristic guideline ("when X, prefer Y") |
585
+ | `get_heuristic` | Fetch one heuristic by id |
586
+ | `list_heuristics` | List stored heuristics |
587
+ | `heuristic_count` | Count of stored heuristics |
588
+ | `match_heuristics` | Heuristics matching a context string |
589
+ | `reinforce_heuristic` | Strengthen a heuristic after successful application |
590
+ | `record_heuristic_contradiction` | Record evidence contradicting a heuristic |
591
+ | `detect_heuristic_conflicts` | Detect mutually contradictory heuristics |
592
+ | `remove_heuristic` | Remove one heuristic |
593
+ | `clear_heuristics` | Remove all heuristics |
594
+
595
+ #### Project Context (12 tools) — Phase 16 / memoryjs v2.1.0
596
+ | Tool | Description |
597
+ |------|-------------|
598
+ | `upsert_project_context` | Create/replace a project's structured context record |
599
+ | `get_project_context` | Fetch a project's context record |
600
+ | `append_project_fact` | Append a fact to a project context |
601
+ | `append_project_convention` | Append a coding/workflow convention |
602
+ | `append_project_command` | Append a named command (e.g. build/test invocations) |
603
+ | `append_project_glossary_term` | Append a glossary term + definition |
604
+ | `remove_project_fact` | Remove a fact by index/value |
605
+ | `remove_project_convention` | Remove a convention |
606
+ | `remove_project_command` | Remove a command |
607
+ | `remove_project_glossary_term` | Remove a glossary term |
608
+ | `clear_project_context` | Delete a project's context record |
609
+ | `format_project_context_for_llm` | Render the context as LLM-ready markdown |
610
+
611
+ #### Decision Rationale (10 tools) — Phase 16 / memoryjs v2.1.0
612
+ | Tool | Description |
613
+ |------|-------------|
614
+ | `propose_decision` | Record a proposed decision with rationale |
615
+ | `accept_decision` | Mark a decision accepted |
616
+ | `reject_decision` | Mark a decision rejected |
617
+ | `supersede_decision` | Supersede a decision with a newer one |
618
+ | `find_decisions_by_context` | Decisions matching a context string |
619
+ | `get_decision_chain` | Follow a decision's supersession chain |
620
+ | `list_decisions` | List decisions (filterable by status) |
621
+ | `get_decision` | Fetch one decision by id |
622
+ | `export_decision_as_adr_markdown` | Render a decision as ADR markdown |
623
+ | `parse_adr_markdown` | Parse ADR markdown back into a decision record |
624
+
625
+ #### Exclusion / `do_not_remember` (5 tools) — Phase 16 / memoryjs v2.1.0
626
+ | Tool | Description |
627
+ |------|-------------|
628
+ | `add_exclusion_rule` | Add a rule for content that must not be remembered |
629
+ | `list_exclusion_rules` | List exclusion rules |
630
+ | `remove_exclusion_rule` | Remove one exclusion rule |
631
+ | `check_exclusion` | Check whether a text would be excluded |
632
+ | `find_matching_memories_for_rule` | Existing memories matching an exclusion rule |
633
+
634
+ #### Observation Dedup (2 tools) — Phase 16 / memoryjs v2.1.0
635
+ | Tool | Description |
636
+ |------|-------------|
637
+ | `find_duplicate_observations` | Exact duplicate observations across entities |
638
+ | `find_jaccard_duplicate_observations` | Near-duplicates via Jaccard token similarity |
639
+
640
+ #### Spell Correction (3 tools) — Phase 16 / memoryjs v2.1.0
641
+ | Tool | Description |
642
+ |------|-------------|
643
+ | `spell_suggest` | "Did you mean?" suggestions for a query term |
644
+ | `spell_rebuild_vocabulary` | Rebuild the spell-check vocabulary from the graph |
645
+ | `spell_vocabulary_size` | Current vocabulary size |
646
+
647
+ #### Active Project Scope (2 tools) — v12.3.2
648
+ | Tool | Description |
649
+ |------|-------------|
650
+ | `set_project_scope` | Set the server's active project-scope filter (per-session mutable state) |
651
+ | `get_project_scope` | Get the active project scope (`{ projectId }`, null when unscoped) |
652
+
653
+ #### Engineering / Diagnostics (10 tools) — v12.5.0
654
+ | Tool | Description |
655
+ |------|-------------|
656
+ | `diag` | Server + storage diagnostic snapshot |
657
+ | `health` | Quick health check |
658
+ | `check_graph` | Graph integrity check |
659
+ | `reindex` | Rebuild search indexes |
660
+ | `cache_stats` | Stats for the global search caches |
661
+ | `cache_clear` | Bust all global search caches |
662
+ | `graph_size` | Entity/relation/observation counts + on-disk footprint |
663
+ | `inspect_entity` | Verbose single-entity snapshot (observations, relations, hierarchy) |
664
+ | `hierarchy_tree` | Hierarchy as nested JSON |
665
+ | `entity_neighbors` | Incoming/outgoing relations + degree counts for one entity |
666
+
667
+ #### Event Memory (5 tools) — v12.7.0 / memoryjs v3.0.0
668
+ | Tool | Description |
669
+ |------|-------------|
670
+ | `record_event` | Reify an action as an event hub entity with role-typed relations (`actor_of` / `targeted` / `occurred_in` / `participant_in`) and optional `flow:<key>` grouping |
671
+ | `get_event` | Load one event with its resolved role endpoints |
672
+ | `query_events` | Query by actor / target / action / flowKey / time range, chronologically ordered |
673
+ | `get_event_flow` | Full timeline of a named flow (e.g. a release or incident) |
674
+ | `who_did_what` | "Who did what (to target / in context / within range)?" join over events |
675
+
676
+ #### Reconstructive Memory (5 tools) — v12.7.0 / memoryjs v3.0.0
677
+ | Tool | Description |
678
+ |------|-------------|
679
+ | `ingest_dialogue` | Distill dialogue turns into the Cue–Tag–Content associative graph (also persisted into the live knowledge graph) |
680
+ | `reconstruct_memory` | Answer a query via active multi-step traversal; returns evidence + trajectory |
681
+ | `reconstructive_memory_stats` | CTC graph size statistics |
682
+ | `save_reconstructive_memory` | Serialize the CTC graph to a `<basename>-reconstructive.json` sidecar |
683
+ | `load_reconstructive_memory` | Restore the CTC graph from the sidecar (survives restarts) |
684
+
685
+ #### Relation Consolidation (2 tools) — v12.7.0 / memoryjs v3.0.0
686
+ | Tool | Description |
687
+ |------|-------------|
688
+ | `analyze_relation_duplicates` | Dry-run the three-tier relation janitor: spelling variants, inverse duplicates, semantic duplicates (with embeddings) |
689
+ | `consolidate_relations` | Apply tier 1+2 merges (`apply: true`) or dry-run (default) |
690
+
691
+ #### Agent Reflection (4 tools) — v12.7.0 / memoryjs v3.0.0
692
+ | Tool | Description |
693
+ |------|-------------|
694
+ | `create_reflection` | Persist an evidence-backed generalized lesson (scope: session / project / global) |
695
+ | `list_reflections` | List reflections, filterable by scope / source / confidence |
696
+ | `get_relevant_reflections` | Reflections relevant to a session (sourceSessionId + evidence overlap) |
697
+ | `archive_reflection` | Soft-delete a reflection out of default listings |
698
+
699
+ #### v12.7.0 enhancements to existing tools
700
+ - **`hybrid_search`** — Now accepts memoryjs v3's additive options: `graphWeight` (graph-connectivity channel via normalized PageRank), `expandNeighbors` (one-hop expansion of top results with damped scores), `explain` (annotate results with evidence paths from query anchors), and `lookFor` (rank expansion neighbors by a free-text connection description).
701
+
565
702
  ## Configuration
566
703
 
567
704
  ### Environment Variables
@@ -645,7 +782,7 @@ node dist/migrate-from-jsonl-to-sqlite.js --from memory.db --to memory.jsonl
645
782
  ```bash
646
783
  npm install # Install dependencies
647
784
  npm run build # Build TypeScript
648
- npm test # Run tests (665 tests across 26 files; >80% coverage)
785
+ npm test # Run tests (791 tests across 36 files; ~85% coverage)
649
786
  npm run typecheck # Strict type checking
650
787
  npm run watch # Development watch mode
651
788
  npm run clean # Remove dist/ directory
@@ -654,7 +791,7 @@ npm run docs:deps # Generate dependency graph
654
791
 
655
792
  ### Architecture
656
793
 
657
- After the **Phase 13 extraction**, this repo is a thin MCP wrapper. All graph logic, managers, and storage live in [`@danielsimonjr/memoryjs`](https://www.npmjs.com/package/@danielsimonjr/memoryjs) (currently `^1.15.0`).
794
+ After the **Phase 13 extraction**, this repo is a thin MCP wrapper. All graph logic, managers, and storage live in [`@danielsimonjr/memoryjs`](https://www.npmjs.com/package/@danielsimonjr/memoryjs) (currently `^3.0.0`).
658
795
 
659
796
  ```
660
797
  memory-mcp (this repo) @danielsimonjr/memoryjs (npm dep)
@@ -672,7 +809,7 @@ memory-mcp (this repo) @danielsimonjr/memoryjs (npm dep)
672
809
  | Layer | Lives in | Files |
673
810
  |-------|----------|-------|
674
811
  | MCP protocol (stdio transport, tool registration, dispatch) | `memory-mcp` | 5 |
675
- | Tool schemas (160 tools across 51 categories) | `memory-mcp` (`toolDefinitions.ts`) | 1 |
812
+ | Tool schemas (241 tools across 65 categories) | `memory-mcp` (`toolDefinitions.ts`) | 1 |
676
813
  | Handler registry + Zod validation + response compression | `memory-mcp` (`toolHandlers.ts` + `responseCompressor.ts`) | 2 |
677
814
  | Managers (Entity / Relation / Search / IO / Tag / Hierarchy / Analytics / Compression / Archive / GraphTraversal / SemanticSearch / RankedSearch / etc.) | `memoryjs` | 100+ |
678
815
  | Storage (JSONL + SQLite with FTS5 + StorageFactory + TransactionManager) | `memoryjs` | — |
@@ -686,10 +823,10 @@ memory-mcp/
686
823
  │ ├── index.ts # Entry point: ManagerContext + start MCPServer; re-exports memoryjs types
687
824
  │ └── server/
688
825
  │ ├── MCPServer.ts # MCP Server setup, stdio transport, request handlers
689
- │ ├── toolDefinitions.ts # 160 tool schemas (name, description, inputSchema)
826
+ │ ├── toolDefinitions.ts # 241 tool schemas (name, description, inputSchema)
690
827
  │ ├── toolHandlers.ts # Handler registry: validate args → call manager → format response
691
828
  │ └── responseCompressor.ts # Brotli + base64 wrapper for >256KB payloads
692
- ├── tests/ # Test suite (26 files, 665 tests, >80% statement coverage)
829
+ ├── tests/ # Test suite (36 files, 791 tests, ~85% statement coverage)
693
830
  │ ├── unit/ # Unit tests (response compressor, tool defs, validate-fact handler)
694
831
  │ ├── integration/ # MCP server lifecycle
695
832
  │ ├── e2e/tools/ # Per-category tool tests + handler-smoke broad coverage
@@ -732,7 +869,7 @@ memory-mcp/
732
869
  Comprehensive documentation in `docs/`:
733
870
 
734
871
  **Architecture**
735
- - [API.md](docs/architecture/API.md) - Complete API documentation for all 160 tools
872
+ - [API.md](docs/architecture/API.md) - Complete API documentation for all 241 tools
736
873
  - [ARCHITECTURE.md](docs/architecture/ARCHITECTURE.md) - Technical architecture and system design
737
874
  - [COMPONENTS.md](docs/architecture/COMPONENTS.md) - Component breakdown and responsibilities
738
875
  - [OVERVIEW.md](docs/architecture/OVERVIEW.md) - High-level project overview
@@ -748,6 +885,10 @@ Comprehensive documentation in `docs/`:
748
885
  - [WORKFLOW.md](docs/development/WORKFLOW.md) - Development procedures
749
886
  - [MIGRATION.md](docs/guides/MIGRATION.md) - Version upgrade guide
750
887
 
888
+ ## Companion skill
889
+
890
+ This plugin ships a `memory` skill (`memory-mcp:memory`, `/memory`) — a playbook over the knowledge-graph tools covering graph CRUD/search/maintenance, project indexing, and storage migration. See [skills/memory/SKILL.md](skills/memory/SKILL.md).
891
+
751
892
  ## Contributing
752
893
 
753
894
  We welcome contributions!
@@ -767,9 +908,12 @@ We welcome contributions!
767
908
 
768
909
  All notable changes are documented in **[CHANGELOG.md](CHANGELOG.md)**.
769
910
 
770
- **Current version**: v12.3.0 - [View full changelog](CHANGELOG.md)
911
+ **Current version**: v12.7.0 - [View full changelog](CHANGELOG.md)
771
912
 
772
913
  Recent highlights:
914
+ - **v12.7.0** (241 tools): Upgraded `@danielsimonjr/memoryjs` `^2.8.1` → `^3.0.0` and surfaced its new features as 16 tools — event memory (5), reconstructive Cue–Tag–Content memory + snapshot persistence (5), relation consolidation (2), agent reflection (4) — plus v3 graph-channel / evidence-path options on `hybrid_search`. Refactored handlers onto the new `ManagerContext` accessors (`hybridSearchManager`, `governanceManager`, `eventManager`, `reflectionManager`, `reconstructiveMemory()`, `close()`).
915
+ - **v12.5.0** (225 tools): 10 engineering / diagnostic tools mirroring the memoryjs CLI surface (`diag`, `health`, `check_graph`, `reindex`, cache stats/clear, `graph_size`, `inspect_entity`, `hierarchy_tree`, `entity_neighbors`).
916
+ - **v12.3.2** (215 tools): Backport of the deferred `set_project_scope` / `get_project_scope` pair.
773
917
  - **v12.3.0** (213 tools): **Phase 16** — 53 new tools surfacing memoryjs v2.1.0 across seven new manager surfaces: `do_not_remember` exclusion rules (5), decision rationale + ADR markdown dual-write (10), structured project context (12), heuristic guidelines (10), tool affordance + `ToolCallObserver` producer pipeline (11), observation dedup (2), spell correction (3). Bumped `@danielsimonjr/memoryjs` dep `^1.15.0` → `^2.1.0`.
774
918
  - **v12.2.3**: Publishability — switched `@danielsimonjr/memoryjs` dep from local `file:` link to published `^1.15.0` (npm rejects `file:` deps for published packages).
775
919
  - **v12.2.2**: Doc-only — roadmap completion audit grading Phase 6-15 status against current code.
@@ -806,7 +950,7 @@ Enhanced fork of [Model Context Protocol memory server](https://github.com/model
806
950
  - Multi-format import/export with merge strategies
807
951
  - SQLite backend with better-sqlite3 (3-10x faster)
808
952
  - Transaction support with ACID guarantees
809
- - Comprehensive test suite (665 tests, 26 test files in this wrapper repo; full-coverage core graph tests live in `@danielsimonjr/memoryjs`)
953
+ - Comprehensive test suite (791 tests, 36 test files in this wrapper repo; full-coverage core graph tests live in `@danielsimonjr/memoryjs`)
810
954
 
811
955
  ---
812
956
 
@@ -0,0 +1,263 @@
1
+ /**
2
+ * Entity Manager
3
+ *
4
+ * Handles CRUD operations for entities in the knowledge graph.
5
+ * Focused on core entity and tag operations only (Phase 4: Consolidate God Objects).
6
+ *
7
+ * @module core/EntityManager
8
+ */
9
+ import type { Entity } from '../types/index.js';
10
+ import type { GraphStorage } from './GraphStorage.js';
11
+ /**
12
+ * Minimum importance value (least important).
13
+ */
14
+ export declare const MIN_IMPORTANCE = 0;
15
+ /**
16
+ * Maximum importance value (most important).
17
+ */
18
+ export declare const MAX_IMPORTANCE = 10;
19
+ /**
20
+ * Manages entity operations with automatic timestamp handling.
21
+ */
22
+ export declare class EntityManager {
23
+ private storage;
24
+ constructor(storage: GraphStorage);
25
+ /**
26
+ * Create multiple entities in a single batch operation.
27
+ *
28
+ * This method performs the following operations:
29
+ * - Filters out entities that already exist (duplicate names)
30
+ * - Automatically adds createdAt and lastModified timestamps
31
+ * - Normalizes all tags to lowercase for consistent searching
32
+ * - Validates importance values (must be between 0-10)
33
+ *
34
+ * @param entities - Array of entities to create. Each entity must have a unique name.
35
+ * @returns Promise resolving to array of newly created entities (excludes duplicates)
36
+ * @throws {InvalidImportanceError} If any entity has importance outside the valid range [0-10]
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const manager = new EntityManager(storage);
41
+ *
42
+ * // Create single entity
43
+ * const results = await manager.createEntities([{
44
+ * name: 'Alice',
45
+ * entityType: 'person',
46
+ * observations: ['Works as engineer', 'Lives in Seattle'],
47
+ * importance: 7,
48
+ * tags: ['Team', 'Engineering']
49
+ * }]);
50
+ *
51
+ * // Create multiple entities at once
52
+ * const users = await manager.createEntities([
53
+ * { name: 'Bob', entityType: 'person', observations: [] },
54
+ * { name: 'Charlie', entityType: 'person', observations: [] }
55
+ * ]);
56
+ * ```
57
+ */
58
+ createEntities(entities: Entity[]): Promise<Entity[]>;
59
+ /**
60
+ * Delete multiple entities by name in a single batch operation.
61
+ *
62
+ * This method performs cascading deletion:
63
+ * - Removes all specified entities from the graph
64
+ * - Automatically removes all relations where these entities are source or target
65
+ * - Silently ignores entity names that don't exist (no error thrown)
66
+ *
67
+ * @param entityNames - Array of entity names to delete
68
+ * @returns Promise that resolves when deletion is complete
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const manager = new EntityManager(storage);
73
+ *
74
+ * // Delete single entity
75
+ * await manager.deleteEntities(['Alice']);
76
+ *
77
+ * // Delete multiple entities at once
78
+ * await manager.deleteEntities(['Bob', 'Charlie', 'Dave']);
79
+ *
80
+ * // Safe to delete non-existent entities (no error)
81
+ * await manager.deleteEntities(['NonExistent']); // No error thrown
82
+ * ```
83
+ */
84
+ deleteEntities(entityNames: string[]): Promise<void>;
85
+ /**
86
+ * Retrieve a single entity by its unique name.
87
+ *
88
+ * This is a read-only operation that does not modify the graph.
89
+ * Entity names are case-sensitive.
90
+ *
91
+ * @param name - The unique name of the entity to retrieve
92
+ * @returns Promise resolving to the Entity object if found, or null if not found
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const manager = new EntityManager(storage);
97
+ *
98
+ * // Get an existing entity
99
+ * const alice = await manager.getEntity('Alice');
100
+ * if (alice) {
101
+ * console.log(alice.observations);
102
+ * console.log(alice.importance);
103
+ * }
104
+ *
105
+ * // Handle non-existent entity
106
+ * const missing = await manager.getEntity('NonExistent');
107
+ * console.log(missing); // null
108
+ * ```
109
+ */
110
+ getEntity(name: string): Promise<Entity | null>;
111
+ /**
112
+ * Update one or more fields of an existing entity.
113
+ *
114
+ * This method allows partial updates - only the fields specified in the updates
115
+ * object will be changed. All other fields remain unchanged.
116
+ * The lastModified timestamp is automatically updated.
117
+ *
118
+ * @param name - The unique name of the entity to update
119
+ * @param updates - Partial entity object containing only the fields to update
120
+ * @returns Promise resolving to the fully updated Entity object
121
+ * @throws {EntityNotFoundError} If no entity with the given name exists
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * const manager = new EntityManager(storage);
126
+ *
127
+ * // Update importance only
128
+ * const updated = await manager.updateEntity('Alice', {
129
+ * importance: 9
130
+ * });
131
+ *
132
+ * // Update multiple fields
133
+ * await manager.updateEntity('Bob', {
134
+ * entityType: 'senior_engineer',
135
+ * tags: ['leadership', 'architecture'],
136
+ * observations: ['Led project X', 'Designed system Y']
137
+ * });
138
+ *
139
+ * // Add observations (requires reading existing entity first)
140
+ * const entity = await manager.getEntity('Charlie');
141
+ * if (entity) {
142
+ * await manager.updateEntity('Charlie', {
143
+ * observations: [...entity.observations, 'New observation']
144
+ * });
145
+ * }
146
+ * ```
147
+ */
148
+ updateEntity(name: string, updates: Partial<Entity>): Promise<Entity>;
149
+ /**
150
+ * Update multiple entities in a single batch operation.
151
+ *
152
+ * This method is more efficient than calling updateEntity multiple times
153
+ * as it loads and saves the graph only once. All updates are applied atomically.
154
+ * The lastModified timestamp is automatically updated for all entities.
155
+ *
156
+ * @param updates - Array of updates, each containing entity name and changes
157
+ * @returns Promise resolving to array of updated entities
158
+ * @throws {EntityNotFoundError} If any entity is not found
159
+ * @throws {ValidationError} If any update data is invalid
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * const manager = new EntityManager(storage);
164
+ *
165
+ * // Update multiple entities at once
166
+ * const updated = await manager.batchUpdate([
167
+ * { name: 'Alice', updates: { importance: 9 } },
168
+ * { name: 'Bob', updates: { importance: 8, tags: ['senior'] } },
169
+ * { name: 'Charlie', updates: { entityType: 'lead_engineer' } }
170
+ * ]);
171
+ *
172
+ * console.log(`Updated ${updated.length} entities`);
173
+ *
174
+ * // Efficiently update many entities (single graph load/save)
175
+ * const massUpdate = employees.map(name => ({
176
+ * name,
177
+ * updates: { tags: ['team-2024'] }
178
+ * }));
179
+ * await manager.batchUpdate(massUpdate);
180
+ * ```
181
+ */
182
+ batchUpdate(updates: Array<{
183
+ name: string;
184
+ updates: Partial<Entity>;
185
+ }>): Promise<Entity[]>;
186
+ /**
187
+ * Add tags to an entity.
188
+ *
189
+ * Tags are normalized to lowercase and duplicates are filtered out.
190
+ *
191
+ * @param entityName - Name of the entity
192
+ * @param tags - Tags to add
193
+ * @returns Result with entity name and added tags
194
+ * @throws {EntityNotFoundError} If entity is not found
195
+ */
196
+ addTags(entityName: string, tags: string[]): Promise<{
197
+ entityName: string;
198
+ addedTags: string[];
199
+ }>;
200
+ /**
201
+ * Remove tags from an entity.
202
+ *
203
+ * @param entityName - Name of the entity
204
+ * @param tags - Tags to remove
205
+ * @returns Result with entity name and removed tags
206
+ * @throws {EntityNotFoundError} If entity is not found
207
+ */
208
+ removeTags(entityName: string, tags: string[]): Promise<{
209
+ entityName: string;
210
+ removedTags: string[];
211
+ }>;
212
+ /**
213
+ * Set importance level for an entity.
214
+ *
215
+ * @param entityName - Name of the entity
216
+ * @param importance - Importance level (0-10)
217
+ * @returns Result with entity name and importance
218
+ * @throws {EntityNotFoundError} If entity is not found
219
+ * @throws {Error} If importance is out of range
220
+ */
221
+ setImportance(entityName: string, importance: number): Promise<{
222
+ entityName: string;
223
+ importance: number;
224
+ }>;
225
+ /**
226
+ * Add tags to multiple entities in a single operation.
227
+ *
228
+ * @param entityNames - Names of entities to tag
229
+ * @param tags - Tags to add to each entity
230
+ * @returns Array of results showing which tags were added to each entity
231
+ */
232
+ addTagsToMultipleEntities(entityNames: string[], tags: string[]): Promise<{
233
+ entityName: string;
234
+ addedTags: string[];
235
+ }[]>;
236
+ /**
237
+ * Replace a tag with a new tag across all entities (rename tag).
238
+ *
239
+ * @param oldTag - Tag to replace
240
+ * @param newTag - New tag value
241
+ * @returns Result with affected entities and count
242
+ */
243
+ replaceTag(oldTag: string, newTag: string): Promise<{
244
+ affectedEntities: string[];
245
+ count: number;
246
+ }>;
247
+ /**
248
+ * Merge two tags into one target tag across all entities.
249
+ *
250
+ * Combines tag1 and tag2 into targetTag. Any entity with either tag1 or tag2
251
+ * will have both removed and targetTag added (if not already present).
252
+ *
253
+ * @param tag1 - First tag to merge
254
+ * @param tag2 - Second tag to merge
255
+ * @param targetTag - Target tag to merge into
256
+ * @returns Object with affected entity names and count
257
+ */
258
+ mergeTags(tag1: string, tag2: string, targetTag: string): Promise<{
259
+ affectedEntities: string[];
260
+ count: number;
261
+ }>;
262
+ }
263
+ //# sourceMappingURL=EntityManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityManager.d.ts","sourceRoot":"","sources":["../../src/core/EntityManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAKtD;;GAEG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC;;GAEG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,YAAY;IAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA0D3D;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB1D;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAuB3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,WAAW,CACf,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC,GACzD,OAAO,CAAC,MAAM,EAAE,CAAC;IAuCpB;;;;;;;;;OASG;IACG,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAsBvG;;;;;;;OAOG;IACG,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAoC5G;;;;;;;;OAQG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAkBhH;;;;;;OAMG;IACG,yBAAyB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IAiC9H;;;;;;OAMG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAuBxG;;;;;;;;;;OAUG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAmCvH"}