@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.
- package/CHANGELOG.md +542 -0
- package/LICENSE +21 -0
- package/README.md +1281 -0
- package/bin/mcp-memory-keeper +54 -0
- package/dist/__tests__/e2e/issue33-reproduce.test.js +234 -0
- package/dist/__tests__/e2e/server-e2e.test.js +341 -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 +1054 -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/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 +411 -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/filterBySessionId.test.js +251 -0
- package/dist/__tests__/integration/git-integration.test.js +241 -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/issue24-final-fix.test.js +241 -0
- package/dist/__tests__/integration/issue24-fix-validation.test.js +158 -0
- package/dist/__tests__/integration/issue24-reproduce.test.js +225 -0
- package/dist/__tests__/integration/issue24-token-limit.test.js +199 -0
- package/dist/__tests__/integration/issue33-array-items-schema.test.js +165 -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 +291 -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 +305 -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/tokenLimitEnforcement.test.js +134 -0
- package/dist/__tests__/integration/tool-profiles-integration.test.js +150 -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 +192 -0
- package/dist/__tests__/utils/timezone-safe-dates.js +119 -0
- package/dist/__tests__/utils/token-limits.test.js +225 -0
- package/dist/__tests__/utils/tool-profiles.test.js +374 -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 +4425 -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 +2017 -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/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 +780 -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/token-limits.js +350 -0
- package/dist/utils/tool-profiles.js +242 -0
- package/dist/utils/validation.js +296 -0
- package/dist/utils/vector-store.js +247 -0
- package/examples/config.json +31 -0
- package/examples/project-directory-setup.md +114 -0
- package/package.json +85 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Channel utility functions for deriving and managing channel names
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.deriveChannelFromBranch = deriveChannelFromBranch;
|
|
40
|
+
exports.deriveDefaultChannel = deriveDefaultChannel;
|
|
41
|
+
exports.isValidChannel = isValidChannel;
|
|
42
|
+
exports.normalizeChannel = normalizeChannel;
|
|
43
|
+
exports.createSessionWithGitInfo = createSessionWithGitInfo;
|
|
44
|
+
/**
|
|
45
|
+
* Derives a channel name from a git branch name
|
|
46
|
+
* @param branch - Git branch name
|
|
47
|
+
* @returns Derived channel name (max 20 chars) or null if branch should be skipped
|
|
48
|
+
*/
|
|
49
|
+
function deriveChannelFromBranch(branch) {
|
|
50
|
+
if (!branch || branch.trim() === '')
|
|
51
|
+
return null;
|
|
52
|
+
// Skip main and master branches - they should not have their own channels
|
|
53
|
+
if (branch === 'main' || branch === 'master')
|
|
54
|
+
return null;
|
|
55
|
+
// Replace special characters with hyphens
|
|
56
|
+
let channel = branch
|
|
57
|
+
.toLowerCase()
|
|
58
|
+
.replace(/[^a-z0-9-_]/g, '-')
|
|
59
|
+
.replace(/--+/g, '-')
|
|
60
|
+
.replace(/^-|-$/g, '');
|
|
61
|
+
// If channel is empty after cleaning, return general
|
|
62
|
+
if (!channel)
|
|
63
|
+
return 'general';
|
|
64
|
+
// Truncate to 20 characters
|
|
65
|
+
if (channel.length > 20) {
|
|
66
|
+
channel = channel.substring(0, 20);
|
|
67
|
+
}
|
|
68
|
+
return channel;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Derives a default channel name from branch or session name
|
|
72
|
+
* @param branch - Git branch name (optional)
|
|
73
|
+
* @param sessionName - Session name (optional)
|
|
74
|
+
* @returns Derived channel name (max 20 chars) or 'general' if no inputs
|
|
75
|
+
*/
|
|
76
|
+
function deriveDefaultChannel(branch, sessionName) {
|
|
77
|
+
// First try to derive from branch
|
|
78
|
+
if (branch) {
|
|
79
|
+
const branchChannel = deriveChannelFromBranch(branch);
|
|
80
|
+
if (branchChannel) {
|
|
81
|
+
return branchChannel;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// If branch derivation failed or returned null (main/master), try session name
|
|
85
|
+
if (sessionName) {
|
|
86
|
+
const sessionChannel = deriveChannelFromBranch(sessionName);
|
|
87
|
+
if (sessionChannel) {
|
|
88
|
+
return sessionChannel;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Default fallback
|
|
92
|
+
return 'general';
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Validates a channel name
|
|
96
|
+
* @param channel - Channel name to validate
|
|
97
|
+
* @returns true if valid, false otherwise
|
|
98
|
+
*/
|
|
99
|
+
function isValidChannel(channel) {
|
|
100
|
+
if (!channel || typeof channel !== 'string') {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
// Check length
|
|
104
|
+
if (channel.length === 0 || channel.length > 20) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
// Check format (lowercase letters, numbers, hyphens only)
|
|
108
|
+
return /^[a-z0-9]+(-[a-z0-9]+)*$/.test(channel);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Normalizes a channel name to ensure it's valid
|
|
112
|
+
* @param channel - Channel name to normalize
|
|
113
|
+
* @returns Normalized channel name
|
|
114
|
+
*/
|
|
115
|
+
function normalizeChannel(channel) {
|
|
116
|
+
if (!channel || typeof channel !== 'string') {
|
|
117
|
+
return 'general';
|
|
118
|
+
}
|
|
119
|
+
// Apply same logic as deriveDefaultChannel
|
|
120
|
+
const normalized = channel
|
|
121
|
+
.toLowerCase()
|
|
122
|
+
.trim()
|
|
123
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
124
|
+
.replace(/^-+|-+$/g, '');
|
|
125
|
+
if (!normalized) {
|
|
126
|
+
return 'general';
|
|
127
|
+
}
|
|
128
|
+
// Truncate if needed
|
|
129
|
+
if (normalized.length > 20) {
|
|
130
|
+
return normalized.substring(0, 20).replace(/-+$/, '');
|
|
131
|
+
}
|
|
132
|
+
return normalized;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Creates a session configuration with automatic channel derivation from git
|
|
136
|
+
* @param options - Options including name and git operations
|
|
137
|
+
* @returns Session configuration with derived channel
|
|
138
|
+
*/
|
|
139
|
+
async function createSessionWithGitInfo(options) {
|
|
140
|
+
const { v4: uuidv4 } = await Promise.resolve().then(() => __importStar(require('uuid')));
|
|
141
|
+
const branch = await options.git.getCurrentBranch();
|
|
142
|
+
const channel = deriveChannelFromBranch(branch || '') ||
|
|
143
|
+
deriveChannelFromBranch(options.name || '') ||
|
|
144
|
+
'general';
|
|
145
|
+
return {
|
|
146
|
+
id: uuidv4(),
|
|
147
|
+
name: options.name || `Session ${Date.now()}`,
|
|
148
|
+
default_channel: channel,
|
|
149
|
+
};
|
|
150
|
+
}
|