mcp-memory-keeper 0.10.0
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.
- package/CHANGELOG.md +433 -0
- package/LICENSE +21 -0
- package/README.md +1051 -0
- package/bin/mcp-memory-keeper +52 -0
- package/dist/__tests__/helpers/database-test-helper.js +160 -0
- package/dist/__tests__/helpers/test-server.js +92 -0
- package/dist/__tests__/integration/advanced-features.test.js +614 -0
- package/dist/__tests__/integration/backward-compatibility.test.js +245 -0
- package/dist/__tests__/integration/batchOperationsE2E.test.js +396 -0
- package/dist/__tests__/integration/batchOperationsHandler.test.js +1230 -0
- package/dist/__tests__/integration/channelManagementHandler.test.js +1291 -0
- package/dist/__tests__/integration/channels.test.js +376 -0
- package/dist/__tests__/integration/checkpoint.test.js +251 -0
- package/dist/__tests__/integration/concurrent-access.test.js +190 -0
- package/dist/__tests__/integration/context-operations.test.js +243 -0
- package/dist/__tests__/integration/contextDiff.test.js +852 -0
- package/dist/__tests__/integration/contextDiffHandler.test.js +976 -0
- package/dist/__tests__/integration/contextExportHandler.test.js +510 -0
- package/dist/__tests__/integration/contextGetPaginationDefaults.test.js +298 -0
- package/dist/__tests__/integration/contextReassignChannelHandler.test.js +908 -0
- package/dist/__tests__/integration/contextRelationshipsHandler.test.js +1151 -0
- package/dist/__tests__/integration/contextSearch.test.js +938 -0
- package/dist/__tests__/integration/contextSearchHandler.test.js +552 -0
- package/dist/__tests__/integration/contextWatchActual.test.js +165 -0
- package/dist/__tests__/integration/contextWatchHandler.test.js +1500 -0
- package/dist/__tests__/integration/cross-session-sharing.test.js +302 -0
- package/dist/__tests__/integration/database-initialization.test.js +134 -0
- package/dist/__tests__/integration/enhanced-context-operations.test.js +1082 -0
- package/dist/__tests__/integration/enhancedContextGetHandler.test.js +915 -0
- package/dist/__tests__/integration/enhancedContextTimelineHandler.test.js +716 -0
- package/dist/__tests__/integration/error-cases.test.js +407 -0
- package/dist/__tests__/integration/export-import.test.js +367 -0
- package/dist/__tests__/integration/feature-flags.test.js +542 -0
- package/dist/__tests__/integration/file-operations.test.js +264 -0
- package/dist/__tests__/integration/git-integration.test.js +237 -0
- package/dist/__tests__/integration/index-tools.test.js +496 -0
- package/dist/__tests__/integration/issue11-actual-bug-demo.test.js +304 -0
- package/dist/__tests__/integration/issue11-search-filters-bug.test.js +561 -0
- package/dist/__tests__/integration/issue12-checkpoint-restore-behavior.test.js +621 -0
- package/dist/__tests__/integration/issue13-key-validation.test.js +433 -0
- package/dist/__tests__/integration/knowledge-graph.test.js +338 -0
- package/dist/__tests__/integration/migrations.test.js +528 -0
- package/dist/__tests__/integration/multi-agent.test.js +546 -0
- package/dist/__tests__/integration/pagination-critical-fix.test.js +296 -0
- package/dist/__tests__/integration/paginationDefaultsHandler.test.js +600 -0
- package/dist/__tests__/integration/project-directory.test.js +283 -0
- package/dist/__tests__/integration/resource-cleanup.test.js +149 -0
- package/dist/__tests__/integration/retention.test.js +513 -0
- package/dist/__tests__/integration/search.test.js +333 -0
- package/dist/__tests__/integration/semantic-search.test.js +266 -0
- package/dist/__tests__/integration/server-initialization.test.js +307 -0
- package/dist/__tests__/integration/session-management.test.js +219 -0
- package/dist/__tests__/integration/simplified-sharing.test.js +346 -0
- package/dist/__tests__/integration/smart-compaction.test.js +230 -0
- package/dist/__tests__/integration/summarization.test.js +308 -0
- package/dist/__tests__/integration/watcher-migration-validation.test.js +544 -0
- package/dist/__tests__/security/input-validation.test.js +115 -0
- package/dist/__tests__/utils/agents.test.js +473 -0
- package/dist/__tests__/utils/database.test.js +177 -0
- package/dist/__tests__/utils/git.test.js +122 -0
- package/dist/__tests__/utils/knowledge-graph.test.js +297 -0
- package/dist/__tests__/utils/migrationHealthCheck.test.js +302 -0
- package/dist/__tests__/utils/project-directory-messages.test.js +188 -0
- package/dist/__tests__/utils/timezone-safe-dates.js +119 -0
- package/dist/__tests__/utils/validation.test.js +200 -0
- package/dist/__tests__/utils/vector-store.test.js +231 -0
- package/dist/handlers/contextWatchHandlers.js +206 -0
- package/dist/index.js +4310 -0
- package/dist/index.phase1.backup.js +410 -0
- package/dist/index.phase2.backup.js +704 -0
- package/dist/migrations/003_add_channels.js +174 -0
- package/dist/migrations/004_add_context_watch.js +151 -0
- package/dist/migrations/005_add_context_watch.js +98 -0
- package/dist/migrations/simplify-sharing.js +117 -0
- package/dist/repositories/BaseRepository.js +30 -0
- package/dist/repositories/CheckpointRepository.js +140 -0
- package/dist/repositories/ContextRepository.js +1873 -0
- package/dist/repositories/FileRepository.js +104 -0
- package/dist/repositories/RepositoryManager.js +62 -0
- package/dist/repositories/SessionRepository.js +66 -0
- package/dist/repositories/WatcherRepository.js +252 -0
- package/dist/repositories/index.js +15 -0
- package/dist/server.js +384 -0
- package/dist/test-helpers/database-helper.js +128 -0
- package/dist/types/entities.js +3 -0
- package/dist/utils/agents.js +791 -0
- package/dist/utils/channels.js +150 -0
- package/dist/utils/database.js +731 -0
- package/dist/utils/feature-flags.js +476 -0
- package/dist/utils/git.js +145 -0
- package/dist/utils/knowledge-graph.js +264 -0
- package/dist/utils/migrationHealthCheck.js +373 -0
- package/dist/utils/migrations.js +452 -0
- package/dist/utils/retention.js +460 -0
- package/dist/utils/timestamps.js +112 -0
- package/dist/utils/validation.js +296 -0
- package/dist/utils/vector-store.js +247 -0
- package/package.json +84 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CheckpointRepository = void 0;
|
|
4
|
+
const BaseRepository_js_1 = require("./BaseRepository.js");
|
|
5
|
+
class CheckpointRepository extends BaseRepository_js_1.BaseRepository {
|
|
6
|
+
create(sessionId, input) {
|
|
7
|
+
const id = this.generateId();
|
|
8
|
+
const timestamp = this.getCurrentTimestamp();
|
|
9
|
+
const stmt = this.db.prepare(`
|
|
10
|
+
INSERT INTO checkpoints (id, session_id, name, description, git_status, git_branch, created_at)
|
|
11
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
12
|
+
`);
|
|
13
|
+
stmt.run(id, sessionId, input.name, input.description || null, input.git_status || null, input.git_branch || null, timestamp);
|
|
14
|
+
return this.getById(id);
|
|
15
|
+
}
|
|
16
|
+
getById(id) {
|
|
17
|
+
const stmt = this.db.prepare('SELECT * FROM checkpoints WHERE id = ?');
|
|
18
|
+
return stmt.get(id);
|
|
19
|
+
}
|
|
20
|
+
getByName(sessionId, name) {
|
|
21
|
+
const stmt = this.db.prepare(`
|
|
22
|
+
SELECT * FROM checkpoints
|
|
23
|
+
WHERE session_id = ? AND name = ?
|
|
24
|
+
`);
|
|
25
|
+
return stmt.get(sessionId, name);
|
|
26
|
+
}
|
|
27
|
+
getBySessionId(sessionId) {
|
|
28
|
+
const stmt = this.db.prepare(`
|
|
29
|
+
SELECT * FROM checkpoints
|
|
30
|
+
WHERE session_id = ?
|
|
31
|
+
ORDER BY created_at DESC
|
|
32
|
+
`);
|
|
33
|
+
return stmt.all(sessionId);
|
|
34
|
+
}
|
|
35
|
+
delete(id) {
|
|
36
|
+
// Delete related checkpoint items and files first
|
|
37
|
+
this.db.prepare('DELETE FROM checkpoint_items WHERE checkpoint_id = ?').run(id);
|
|
38
|
+
this.db.prepare('DELETE FROM checkpoint_files WHERE checkpoint_id = ?').run(id);
|
|
39
|
+
// Delete the checkpoint
|
|
40
|
+
this.db.prepare('DELETE FROM checkpoints WHERE id = ?').run(id);
|
|
41
|
+
}
|
|
42
|
+
deleteBySessionId(sessionId) {
|
|
43
|
+
const checkpoints = this.getBySessionId(sessionId);
|
|
44
|
+
for (const checkpoint of checkpoints) {
|
|
45
|
+
this.delete(checkpoint.id);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Checkpoint Items Management
|
|
49
|
+
addContextItem(checkpointId, contextItemId) {
|
|
50
|
+
const stmt = this.db.prepare(`
|
|
51
|
+
INSERT INTO checkpoint_items (id, checkpoint_id, context_item_id)
|
|
52
|
+
VALUES (?, ?, ?)
|
|
53
|
+
`);
|
|
54
|
+
stmt.run(this.generateId(), checkpointId, contextItemId);
|
|
55
|
+
}
|
|
56
|
+
addContextItems(checkpointId, contextItemIds) {
|
|
57
|
+
const stmt = this.db.prepare(`
|
|
58
|
+
INSERT INTO checkpoint_items (id, checkpoint_id, context_item_id)
|
|
59
|
+
VALUES (?, ?, ?)
|
|
60
|
+
`);
|
|
61
|
+
for (const itemId of contextItemIds) {
|
|
62
|
+
stmt.run(this.generateId(), checkpointId, itemId);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
getContextItemIds(checkpointId) {
|
|
66
|
+
const stmt = this.db.prepare(`
|
|
67
|
+
SELECT context_item_id
|
|
68
|
+
FROM checkpoint_items
|
|
69
|
+
WHERE checkpoint_id = ?
|
|
70
|
+
`);
|
|
71
|
+
return stmt.all(checkpointId).map((row) => row.context_item_id);
|
|
72
|
+
}
|
|
73
|
+
// Checkpoint Files Management
|
|
74
|
+
addFile(checkpointId, fileCacheId) {
|
|
75
|
+
const stmt = this.db.prepare(`
|
|
76
|
+
INSERT INTO checkpoint_files (id, checkpoint_id, file_cache_id)
|
|
77
|
+
VALUES (?, ?, ?)
|
|
78
|
+
`);
|
|
79
|
+
stmt.run(this.generateId(), checkpointId, fileCacheId);
|
|
80
|
+
}
|
|
81
|
+
addFiles(checkpointId, fileCacheIds) {
|
|
82
|
+
const stmt = this.db.prepare(`
|
|
83
|
+
INSERT INTO checkpoint_files (id, checkpoint_id, file_cache_id)
|
|
84
|
+
VALUES (?, ?, ?)
|
|
85
|
+
`);
|
|
86
|
+
for (const fileId of fileCacheIds) {
|
|
87
|
+
stmt.run(this.generateId(), checkpointId, fileId);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
getFileCacheIds(checkpointId) {
|
|
91
|
+
const stmt = this.db.prepare(`
|
|
92
|
+
SELECT file_cache_id
|
|
93
|
+
FROM checkpoint_files
|
|
94
|
+
WHERE checkpoint_id = ?
|
|
95
|
+
`);
|
|
96
|
+
return stmt.all(checkpointId).map((row) => row.file_cache_id);
|
|
97
|
+
}
|
|
98
|
+
// Complete checkpoint with items and files
|
|
99
|
+
createComplete(sessionId, input, contextItemIds = [], fileCacheIds = []) {
|
|
100
|
+
const checkpoint = this.create(sessionId, input);
|
|
101
|
+
if (contextItemIds.length > 0) {
|
|
102
|
+
this.addContextItems(checkpoint.id, contextItemIds);
|
|
103
|
+
}
|
|
104
|
+
if (fileCacheIds.length > 0) {
|
|
105
|
+
this.addFiles(checkpoint.id, fileCacheIds);
|
|
106
|
+
}
|
|
107
|
+
return checkpoint;
|
|
108
|
+
}
|
|
109
|
+
getStatsBySession(sessionId) {
|
|
110
|
+
const checkpointCount = this.db
|
|
111
|
+
.prepare(`
|
|
112
|
+
SELECT COUNT(*) as count
|
|
113
|
+
FROM checkpoints
|
|
114
|
+
WHERE session_id = ?
|
|
115
|
+
`)
|
|
116
|
+
.get(sessionId);
|
|
117
|
+
const itemCount = this.db
|
|
118
|
+
.prepare(`
|
|
119
|
+
SELECT COUNT(*) as count
|
|
120
|
+
FROM checkpoint_items ci
|
|
121
|
+
JOIN checkpoints c ON ci.checkpoint_id = c.id
|
|
122
|
+
WHERE c.session_id = ?
|
|
123
|
+
`)
|
|
124
|
+
.get(sessionId);
|
|
125
|
+
const fileCount = this.db
|
|
126
|
+
.prepare(`
|
|
127
|
+
SELECT COUNT(*) as count
|
|
128
|
+
FROM checkpoint_files cf
|
|
129
|
+
JOIN checkpoints c ON cf.checkpoint_id = c.id
|
|
130
|
+
WHERE c.session_id = ?
|
|
131
|
+
`)
|
|
132
|
+
.get(sessionId);
|
|
133
|
+
return {
|
|
134
|
+
count: checkpointCount.count || 0,
|
|
135
|
+
totalItems: itemCount.count || 0,
|
|
136
|
+
totalFiles: fileCount.count || 0,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.CheckpointRepository = CheckpointRepository;
|