@smallironman/mcp-memory-keeper 0.12.2-fork1

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 (110) hide show
  1. package/CHANGELOG.md +542 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1281 -0
  4. package/bin/mcp-memory-keeper +54 -0
  5. package/dist/__tests__/e2e/issue33-reproduce.test.js +234 -0
  6. package/dist/__tests__/e2e/server-e2e.test.js +341 -0
  7. package/dist/__tests__/helpers/database-test-helper.js +160 -0
  8. package/dist/__tests__/helpers/test-server.js +92 -0
  9. package/dist/__tests__/integration/advanced-features.test.js +614 -0
  10. package/dist/__tests__/integration/backward-compatibility.test.js +245 -0
  11. package/dist/__tests__/integration/batchOperationsE2E.test.js +396 -0
  12. package/dist/__tests__/integration/batchOperationsHandler.test.js +1230 -0
  13. package/dist/__tests__/integration/channelManagementHandler.test.js +1291 -0
  14. package/dist/__tests__/integration/channels.test.js +376 -0
  15. package/dist/__tests__/integration/checkpoint.test.js +251 -0
  16. package/dist/__tests__/integration/concurrent-access.test.js +190 -0
  17. package/dist/__tests__/integration/context-operations.test.js +243 -0
  18. package/dist/__tests__/integration/contextDiff.test.js +852 -0
  19. package/dist/__tests__/integration/contextDiffHandler.test.js +976 -0
  20. package/dist/__tests__/integration/contextExportHandler.test.js +510 -0
  21. package/dist/__tests__/integration/contextGetPaginationDefaults.test.js +298 -0
  22. package/dist/__tests__/integration/contextReassignChannelHandler.test.js +908 -0
  23. package/dist/__tests__/integration/contextRelationshipsHandler.test.js +1151 -0
  24. package/dist/__tests__/integration/contextSearch.test.js +1054 -0
  25. package/dist/__tests__/integration/contextSearchHandler.test.js +552 -0
  26. package/dist/__tests__/integration/contextWatchActual.test.js +165 -0
  27. package/dist/__tests__/integration/contextWatchHandler.test.js +1500 -0
  28. package/dist/__tests__/integration/database-initialization.test.js +134 -0
  29. package/dist/__tests__/integration/enhanced-context-operations.test.js +1082 -0
  30. package/dist/__tests__/integration/enhancedContextGetHandler.test.js +915 -0
  31. package/dist/__tests__/integration/enhancedContextTimelineHandler.test.js +716 -0
  32. package/dist/__tests__/integration/error-cases.test.js +411 -0
  33. package/dist/__tests__/integration/export-import.test.js +367 -0
  34. package/dist/__tests__/integration/feature-flags.test.js +542 -0
  35. package/dist/__tests__/integration/file-operations.test.js +264 -0
  36. package/dist/__tests__/integration/filterBySessionId.test.js +251 -0
  37. package/dist/__tests__/integration/git-integration.test.js +241 -0
  38. package/dist/__tests__/integration/index-tools.test.js +496 -0
  39. package/dist/__tests__/integration/issue11-actual-bug-demo.test.js +304 -0
  40. package/dist/__tests__/integration/issue11-search-filters-bug.test.js +561 -0
  41. package/dist/__tests__/integration/issue12-checkpoint-restore-behavior.test.js +621 -0
  42. package/dist/__tests__/integration/issue13-key-validation.test.js +433 -0
  43. package/dist/__tests__/integration/issue24-final-fix.test.js +241 -0
  44. package/dist/__tests__/integration/issue24-fix-validation.test.js +158 -0
  45. package/dist/__tests__/integration/issue24-reproduce.test.js +225 -0
  46. package/dist/__tests__/integration/issue24-token-limit.test.js +199 -0
  47. package/dist/__tests__/integration/issue33-array-items-schema.test.js +165 -0
  48. package/dist/__tests__/integration/knowledge-graph.test.js +338 -0
  49. package/dist/__tests__/integration/migrations.test.js +528 -0
  50. package/dist/__tests__/integration/multi-agent.test.js +546 -0
  51. package/dist/__tests__/integration/pagination-critical-fix.test.js +296 -0
  52. package/dist/__tests__/integration/paginationDefaultsHandler.test.js +600 -0
  53. package/dist/__tests__/integration/project-directory.test.js +291 -0
  54. package/dist/__tests__/integration/resource-cleanup.test.js +149 -0
  55. package/dist/__tests__/integration/retention.test.js +513 -0
  56. package/dist/__tests__/integration/search.test.js +333 -0
  57. package/dist/__tests__/integration/semantic-search.test.js +266 -0
  58. package/dist/__tests__/integration/server-initialization.test.js +305 -0
  59. package/dist/__tests__/integration/session-management.test.js +219 -0
  60. package/dist/__tests__/integration/simplified-sharing.test.js +346 -0
  61. package/dist/__tests__/integration/smart-compaction.test.js +230 -0
  62. package/dist/__tests__/integration/summarization.test.js +308 -0
  63. package/dist/__tests__/integration/tokenLimitEnforcement.test.js +134 -0
  64. package/dist/__tests__/integration/tool-profiles-integration.test.js +150 -0
  65. package/dist/__tests__/integration/watcher-migration-validation.test.js +544 -0
  66. package/dist/__tests__/security/input-validation.test.js +115 -0
  67. package/dist/__tests__/utils/agents.test.js +473 -0
  68. package/dist/__tests__/utils/database.test.js +177 -0
  69. package/dist/__tests__/utils/git.test.js +122 -0
  70. package/dist/__tests__/utils/knowledge-graph.test.js +297 -0
  71. package/dist/__tests__/utils/migrationHealthCheck.test.js +302 -0
  72. package/dist/__tests__/utils/project-directory-messages.test.js +192 -0
  73. package/dist/__tests__/utils/timezone-safe-dates.js +119 -0
  74. package/dist/__tests__/utils/token-limits.test.js +225 -0
  75. package/dist/__tests__/utils/tool-profiles.test.js +374 -0
  76. package/dist/__tests__/utils/validation.test.js +200 -0
  77. package/dist/__tests__/utils/vector-store.test.js +231 -0
  78. package/dist/handlers/contextWatchHandlers.js +206 -0
  79. package/dist/index.js +4425 -0
  80. package/dist/migrations/003_add_channels.js +174 -0
  81. package/dist/migrations/004_add_context_watch.js +151 -0
  82. package/dist/migrations/005_add_context_watch.js +98 -0
  83. package/dist/migrations/simplify-sharing.js +117 -0
  84. package/dist/repositories/BaseRepository.js +30 -0
  85. package/dist/repositories/CheckpointRepository.js +140 -0
  86. package/dist/repositories/ContextRepository.js +2017 -0
  87. package/dist/repositories/FileRepository.js +104 -0
  88. package/dist/repositories/RepositoryManager.js +62 -0
  89. package/dist/repositories/SessionRepository.js +66 -0
  90. package/dist/repositories/WatcherRepository.js +252 -0
  91. package/dist/repositories/index.js +15 -0
  92. package/dist/test-helpers/database-helper.js +128 -0
  93. package/dist/types/entities.js +3 -0
  94. package/dist/utils/agents.js +791 -0
  95. package/dist/utils/channels.js +150 -0
  96. package/dist/utils/database.js +780 -0
  97. package/dist/utils/feature-flags.js +476 -0
  98. package/dist/utils/git.js +145 -0
  99. package/dist/utils/knowledge-graph.js +264 -0
  100. package/dist/utils/migrationHealthCheck.js +373 -0
  101. package/dist/utils/migrations.js +452 -0
  102. package/dist/utils/retention.js +460 -0
  103. package/dist/utils/timestamps.js +112 -0
  104. package/dist/utils/token-limits.js +350 -0
  105. package/dist/utils/tool-profiles.js +242 -0
  106. package/dist/utils/validation.js +296 -0
  107. package/dist/utils/vector-store.js +247 -0
  108. package/examples/config.json +31 -0
  109. package/examples/project-directory-setup.md +114 -0
  110. package/package.json +85 -0
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const globals_1 = require("@jest/globals");
37
+ const database_1 = require("../../utils/database");
38
+ const RepositoryManager_1 = require("../../repositories/RepositoryManager");
39
+ const contextWatchHandlers_1 = require("../../handlers/contextWatchHandlers");
40
+ const os = __importStar(require("os"));
41
+ const path = __importStar(require("path"));
42
+ const fs = __importStar(require("fs"));
43
+ (0, globals_1.describe)('Context Watch Actual Implementation Tests', () => {
44
+ let dbManager;
45
+ let repositories;
46
+ let tempDbPath;
47
+ let testSessionId;
48
+ (0, globals_1.beforeEach)(async () => {
49
+ tempDbPath = path.join(os.tmpdir(), `test-context-watch-actual-${Date.now()}.db`);
50
+ dbManager = new database_1.DatabaseManager({
51
+ filename: tempDbPath,
52
+ maxSize: 10 * 1024 * 1024,
53
+ walMode: true,
54
+ });
55
+ // Note: Watcher migrations are now automatically applied by DatabaseManager
56
+ repositories = new RepositoryManager_1.RepositoryManager(dbManager);
57
+ // Create test session
58
+ const session = repositories.sessions.create({
59
+ name: 'Test Session',
60
+ description: 'Test session for context watch',
61
+ });
62
+ testSessionId = session.id;
63
+ });
64
+ (0, globals_1.afterEach)(() => {
65
+ dbManager.close();
66
+ try {
67
+ fs.unlinkSync(tempDbPath);
68
+ fs.unlinkSync(`${tempDbPath}-wal`);
69
+ fs.unlinkSync(`${tempDbPath}-shm`);
70
+ }
71
+ catch (_e) {
72
+ // Ignore
73
+ }
74
+ });
75
+ (0, globals_1.describe)('Basic Watcher Operations', () => {
76
+ (0, globals_1.it)('should create a watcher and detect changes', async () => {
77
+ // Create watcher
78
+ const createResult = await (0, contextWatchHandlers_1.handleContextWatch)({
79
+ action: 'create',
80
+ filters: {
81
+ categories: ['task'],
82
+ },
83
+ }, repositories, testSessionId);
84
+ const createResponse = JSON.parse(createResult.content[0].text);
85
+ (0, globals_1.expect)(createResponse.created).toBe(true);
86
+ (0, globals_1.expect)(createResponse.watcherId).toMatch(/^watch_[a-f0-9]{8}$/);
87
+ const watcherId = createResponse.watcherId;
88
+ // Add some context items
89
+ repositories.contexts.save(testSessionId, {
90
+ key: 'task_001',
91
+ value: 'First task',
92
+ category: 'task',
93
+ });
94
+ repositories.contexts.save(testSessionId, {
95
+ key: 'note_001',
96
+ value: 'First note',
97
+ category: 'note',
98
+ });
99
+ // Poll for changes
100
+ const pollResult = await (0, contextWatchHandlers_1.handleContextWatch)({
101
+ action: 'poll',
102
+ watcherId,
103
+ }, repositories, testSessionId);
104
+ const pollResponse = JSON.parse(pollResult.content[0].text);
105
+ // Should only see the task item
106
+ (0, globals_1.expect)(pollResponse.changes).toHaveLength(1);
107
+ (0, globals_1.expect)(pollResponse.changes[0].key).toBe('task_001');
108
+ (0, globals_1.expect)(pollResponse.changes[0].type).toBe('CREATE');
109
+ (0, globals_1.expect)(pollResponse.changes[0].category).toBe('task');
110
+ });
111
+ (0, globals_1.it)('should handle watcher lifecycle', async () => {
112
+ // Create watcher
113
+ const createResult = await (0, contextWatchHandlers_1.handleContextWatch)({
114
+ action: 'create',
115
+ }, repositories, testSessionId);
116
+ const { watcherId } = JSON.parse(createResult.content[0].text);
117
+ // List watchers
118
+ const listResult = await (0, contextWatchHandlers_1.handleContextWatch)({
119
+ action: 'list',
120
+ }, repositories, testSessionId);
121
+ const listResponse = JSON.parse(listResult.content[0].text);
122
+ (0, globals_1.expect)(listResponse.total).toBe(1);
123
+ (0, globals_1.expect)(listResponse.watchers[0].watcherId).toBe(watcherId);
124
+ (0, globals_1.expect)(listResponse.watchers[0].active).toBe(true);
125
+ // Stop watcher
126
+ const stopResult = await (0, contextWatchHandlers_1.handleContextWatch)({
127
+ action: 'stop',
128
+ watcherId,
129
+ }, repositories, testSessionId);
130
+ const stopResponse = JSON.parse(stopResult.content[0].text);
131
+ (0, globals_1.expect)(stopResponse.stopped).toBe(true);
132
+ // Try to poll stopped watcher
133
+ const pollResult = await (0, contextWatchHandlers_1.handleContextWatch)({
134
+ action: 'poll',
135
+ watcherId,
136
+ }, repositories, testSessionId);
137
+ (0, globals_1.expect)(pollResult.content[0].text).toContain('Error: Watcher is stopped');
138
+ });
139
+ (0, globals_1.it)('should apply filters correctly', async () => {
140
+ // Create watcher with key pattern filter
141
+ const createResult = await (0, contextWatchHandlers_1.handleContextWatch)({
142
+ action: 'create',
143
+ filters: {
144
+ keys: ['user_*', '*_config'],
145
+ },
146
+ }, repositories, testSessionId);
147
+ const { watcherId } = JSON.parse(createResult.content[0].text);
148
+ // Add various items
149
+ repositories.contexts.save(testSessionId, { key: 'user_profile', value: 'matches' });
150
+ repositories.contexts.save(testSessionId, { key: 'app_config', value: 'matches' });
151
+ repositories.contexts.save(testSessionId, { key: 'system_settings', value: 'no match' });
152
+ // Poll for changes
153
+ const pollResult = await (0, contextWatchHandlers_1.handleContextWatch)({
154
+ action: 'poll',
155
+ watcherId,
156
+ }, repositories, testSessionId);
157
+ const response = JSON.parse(pollResult.content[0].text);
158
+ (0, globals_1.expect)(response.changes).toHaveLength(2);
159
+ const keys = response.changes.map((c) => c.key);
160
+ (0, globals_1.expect)(keys).toContain('user_profile');
161
+ (0, globals_1.expect)(keys).toContain('app_config');
162
+ (0, globals_1.expect)(keys).not.toContain('system_settings');
163
+ });
164
+ });
165
+ });