claude-mem 3.0.2 â 3.0.4
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/.mcp.json +11 -0
- package/claude-mem +0 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +64 -0
- package/dist/commands/compress.d.ts +2 -0
- package/dist/commands/compress.js +59 -0
- package/dist/commands/install.d.ts +2 -0
- package/dist/commands/install.js +372 -0
- package/dist/commands/load-context.d.ts +2 -0
- package/dist/commands/load-context.js +330 -0
- package/dist/commands/logs.d.ts +2 -0
- package/dist/commands/logs.js +41 -0
- package/dist/commands/migrate.d.ts +9 -0
- package/dist/commands/migrate.js +174 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +159 -0
- package/dist/commands/uninstall.d.ts +2 -0
- package/dist/commands/uninstall.js +105 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.js +33 -0
- package/dist/constants.d.ts +516 -0
- package/dist/constants.js +522 -0
- package/dist/error-handler.d.ts +17 -0
- package/dist/error-handler.js +103 -0
- package/dist/mcp-server-cli.d.ts +34 -0
- package/dist/mcp-server-cli.js +158 -0
- package/dist/mcp-server.d.ts +103 -0
- package/dist/mcp-server.js +269 -0
- package/dist/types.d.ts +148 -0
- package/dist/types.js +78 -0
- package/dist/utils/HookDetector.d.ts +64 -0
- package/dist/utils/HookDetector.js +213 -0
- package/dist/utils/PathResolver.d.ts +16 -0
- package/dist/utils/PathResolver.js +55 -0
- package/dist/utils/SettingsManager.d.ts +63 -0
- package/dist/utils/SettingsManager.js +133 -0
- package/dist/utils/TranscriptCompressor.d.ts +111 -0
- package/dist/utils/TranscriptCompressor.js +486 -0
- package/dist/utils/common.d.ts +29 -0
- package/dist/utils/common.js +14 -0
- package/dist/utils/error-utils.d.ts +93 -0
- package/dist/utils/error-utils.js +238 -0
- package/dist/utils/index.d.ts +19 -0
- package/dist/utils/index.js +26 -0
- package/dist/utils/logger.d.ts +19 -0
- package/dist/utils/logger.js +42 -0
- package/dist/utils/mcp-client-factory.d.ts +51 -0
- package/dist/utils/mcp-client-factory.js +115 -0
- package/dist/utils/mcp-client.d.ts +75 -0
- package/dist/utils/mcp-client.js +120 -0
- package/dist/utils/memory-mcp-client.d.ts +135 -0
- package/dist/utils/memory-mcp-client.js +490 -0
- package/dist/utils/weaviate-mcp-adapter.d.ts +102 -0
- package/dist/utils/weaviate-mcp-adapter.js +587 -0
- package/package.json +3 -2
- package/src/claude-mem.js +0 -859
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { readFileSync, existsSync, readdirSync, statSync } from 'fs';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
export async function status() {
|
|
8
|
+
console.log('đ Claude Memory System Status Check');
|
|
9
|
+
console.log('=====================================\n');
|
|
10
|
+
console.log('đ Installed Hook Scripts:');
|
|
11
|
+
const claudeMemHooksDir = join(homedir(), '.claude-mem', 'hooks');
|
|
12
|
+
const preCompactScript = join(claudeMemHooksDir, 'pre-compact.js');
|
|
13
|
+
const sessionStartScript = join(claudeMemHooksDir, 'session-start.js');
|
|
14
|
+
const checkScript = (path, name) => {
|
|
15
|
+
if (existsSync(path)) {
|
|
16
|
+
const stats = statSync(path);
|
|
17
|
+
const isExecutable = (stats.mode & 0o111) !== 0;
|
|
18
|
+
console.log(` â
${name}: Found`);
|
|
19
|
+
console.log(` Path: ${path}`);
|
|
20
|
+
console.log(` Executable: ${isExecutable ? 'Yes' : 'No (run: chmod +x ' + path + ')'}`);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
console.log(` â ${name}: Not found at ${path}`);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
checkScript(preCompactScript, 'pre-compact.js');
|
|
27
|
+
checkScript(sessionStartScript, 'session-start.js');
|
|
28
|
+
console.log('');
|
|
29
|
+
console.log('âī¸ Settings Configuration:');
|
|
30
|
+
const checkSettings = (name, path) => {
|
|
31
|
+
if (!existsSync(path)) {
|
|
32
|
+
console.log(` âī¸ ${name}: No settings file`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const content = readFileSync(path, 'utf8');
|
|
37
|
+
const settings = JSON.parse(content);
|
|
38
|
+
console.log(` đ ${name}: ${path}`);
|
|
39
|
+
let hasOurPreCompact = false;
|
|
40
|
+
let hasOurSessionStart = false;
|
|
41
|
+
if (settings.hooks?.PreCompact) {
|
|
42
|
+
hasOurPreCompact = settings.hooks.PreCompact.some((matcher) => matcher.hooks?.some((hook) => hook.command?.includes('pre-compact.js') ||
|
|
43
|
+
hook.command?.includes('claude-mem')));
|
|
44
|
+
}
|
|
45
|
+
if (settings.hooks?.SessionStart) {
|
|
46
|
+
hasOurSessionStart = settings.hooks.SessionStart.some((matcher) => matcher.hooks?.some((hook) => hook.command?.includes('session-start.js') ||
|
|
47
|
+
hook.command?.includes('claude-mem')));
|
|
48
|
+
}
|
|
49
|
+
console.log(` PreCompact hook: ${hasOurPreCompact ? 'â
Configured' : 'â Not configured'}`);
|
|
50
|
+
console.log(` SessionStart hook: ${hasOurSessionStart ? 'â
Configured' : 'â Not configured'}`);
|
|
51
|
+
const hookTypes = Object.keys(settings.hooks || {});
|
|
52
|
+
if (hookTypes.length > 0) {
|
|
53
|
+
console.log(` Total hook types: ${hookTypes.length} (${hookTypes.join(', ')})`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.log(` â ī¸ ${name}: Error reading settings - ${error.message}`);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
checkSettings('Global', join(homedir(), '.claude', 'settings.json'));
|
|
61
|
+
checkSettings('Project', join(process.cwd(), '.claude', 'settings.json'));
|
|
62
|
+
console.log('');
|
|
63
|
+
console.log('đĻ Compressed Transcripts:');
|
|
64
|
+
const claudeProjectsDir = join(homedir(), '.claude', 'projects');
|
|
65
|
+
if (existsSync(claudeProjectsDir)) {
|
|
66
|
+
try {
|
|
67
|
+
let compressedCount = 0;
|
|
68
|
+
let archiveCount = 0;
|
|
69
|
+
const searchDir = (dir, depth = 0) => {
|
|
70
|
+
if (depth > 3)
|
|
71
|
+
return;
|
|
72
|
+
const files = readdirSync(dir);
|
|
73
|
+
for (const file of files) {
|
|
74
|
+
const fullPath = join(dir, file);
|
|
75
|
+
const stats = statSync(fullPath);
|
|
76
|
+
if (stats.isDirectory() && !file.startsWith('.')) {
|
|
77
|
+
searchDir(fullPath, depth + 1);
|
|
78
|
+
}
|
|
79
|
+
else if (file.endsWith('.jsonl.compressed')) {
|
|
80
|
+
compressedCount++;
|
|
81
|
+
}
|
|
82
|
+
else if (file.endsWith('.jsonl.archive')) {
|
|
83
|
+
archiveCount++;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
searchDir(claudeProjectsDir);
|
|
88
|
+
console.log(` Compressed files: ${compressedCount}`);
|
|
89
|
+
console.log(` Archive files: ${archiveCount}`);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.log(` â ī¸ Could not scan projects directory`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
console.log(` âšī¸ No Claude projects directory found`);
|
|
97
|
+
}
|
|
98
|
+
console.log('');
|
|
99
|
+
console.log('đ§ Runtime Environment:');
|
|
100
|
+
const checkCommand = (cmd, name) => {
|
|
101
|
+
try {
|
|
102
|
+
const version = execSync(`${cmd} --version`, { encoding: 'utf8' }).trim();
|
|
103
|
+
console.log(` â
${name}: ${version}`);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
console.log(` â ${name}: Not found`);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
checkCommand('node', 'Node.js');
|
|
110
|
+
checkCommand('bun', 'Bun');
|
|
111
|
+
console.log('');
|
|
112
|
+
console.log('đ§ Embedded Weaviate Status:');
|
|
113
|
+
try {
|
|
114
|
+
// Import and test WeaviateMCPAdapter
|
|
115
|
+
const { WeaviateMCPAdapter } = await import('../utils/weaviate-mcp-adapter.js');
|
|
116
|
+
const client = new WeaviateMCPAdapter();
|
|
117
|
+
console.log(' â
Embedded Weaviate client: Ready');
|
|
118
|
+
console.log(' đ Storage: In-memory embedded instance');
|
|
119
|
+
console.log(' đ Features: Vector search, semantic similarity');
|
|
120
|
+
// Test connectivity (don't actually connect to avoid starting instance)
|
|
121
|
+
console.log(' âšī¸ Instance starts automatically when needed');
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
console.log(` â Embedded Weaviate client: Error - ${error.message}`);
|
|
125
|
+
}
|
|
126
|
+
console.log('');
|
|
127
|
+
console.log('đ Summary:');
|
|
128
|
+
const globalPath = join(homedir(), '.claude', 'settings.json');
|
|
129
|
+
const projectPath = join(process.cwd(), '.claude', 'settings.json');
|
|
130
|
+
let isInstalled = false;
|
|
131
|
+
let installLocation = 'Not installed';
|
|
132
|
+
try {
|
|
133
|
+
if (existsSync(globalPath)) {
|
|
134
|
+
const settings = JSON.parse(readFileSync(globalPath, 'utf8'));
|
|
135
|
+
if (settings.hooks?.PreCompact || settings.hooks?.SessionStart) {
|
|
136
|
+
isInstalled = true;
|
|
137
|
+
installLocation = 'Global';
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (existsSync(projectPath)) {
|
|
141
|
+
const settings = JSON.parse(readFileSync(projectPath, 'utf8'));
|
|
142
|
+
if (settings.hooks?.PreCompact || settings.hooks?.SessionStart) {
|
|
143
|
+
isInstalled = true;
|
|
144
|
+
installLocation = installLocation === 'Global' ? 'Global + Project' : 'Project';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch { }
|
|
149
|
+
if (isInstalled) {
|
|
150
|
+
console.log(` â
Claude Memory System is installed (${installLocation})`);
|
|
151
|
+
console.log('');
|
|
152
|
+
console.log('đĄ To test: Use /compact in Claude Code');
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
console.log(` â Claude Memory System is not installed`);
|
|
156
|
+
console.log('');
|
|
157
|
+
console.log('đĄ To install: claude-mem install');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
2
|
+
import { join, resolve, dirname } from 'path';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
export async function uninstall(options = {}) {
|
|
7
|
+
console.log('đ Uninstalling Claude Memory System hooks...');
|
|
8
|
+
const locations = [];
|
|
9
|
+
if (options.all) {
|
|
10
|
+
locations.push({
|
|
11
|
+
name: 'Global',
|
|
12
|
+
path: join(homedir(), '.claude', 'settings.json')
|
|
13
|
+
});
|
|
14
|
+
locations.push({
|
|
15
|
+
name: 'Project',
|
|
16
|
+
path: join(process.cwd(), '.claude', 'settings.json')
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const isProject = options.project;
|
|
21
|
+
locations.push({
|
|
22
|
+
name: isProject ? 'Project' : 'Global',
|
|
23
|
+
path: join(isProject ? process.cwd() : homedir(), '.claude', 'settings.json')
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const projectRoot = resolve(join(__dirname, '..', '..'));
|
|
27
|
+
const preCompactScript = join(projectRoot, 'hooks', 'pre-compact.js');
|
|
28
|
+
const sessionStartScript = join(projectRoot, 'hooks', 'session-start.js');
|
|
29
|
+
let removedCount = 0;
|
|
30
|
+
for (const location of locations) {
|
|
31
|
+
if (!existsSync(location.path)) {
|
|
32
|
+
console.log(`âī¸ No settings found at ${location.name} location`);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const content = readFileSync(location.path, 'utf8');
|
|
37
|
+
const settings = JSON.parse(content);
|
|
38
|
+
if (!settings.hooks) {
|
|
39
|
+
console.log(`âī¸ No hooks configured in ${location.name} settings`);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
let modified = false;
|
|
43
|
+
if (settings.hooks.PreCompact) {
|
|
44
|
+
const filteredPreCompact = settings.hooks.PreCompact.filter((matcher) => {
|
|
45
|
+
const hasOurHook = matcher.hooks?.some((hook) => hook.command === preCompactScript ||
|
|
46
|
+
hook.command?.includes('pre-compact.js') ||
|
|
47
|
+
hook.command?.includes('claude-mem'));
|
|
48
|
+
return !hasOurHook;
|
|
49
|
+
});
|
|
50
|
+
if (filteredPreCompact.length !== settings.hooks.PreCompact.length) {
|
|
51
|
+
settings.hooks.PreCompact = filteredPreCompact.length > 0 ? filteredPreCompact : undefined;
|
|
52
|
+
modified = true;
|
|
53
|
+
console.log(`â
Removed PreCompact hook from ${location.name} settings`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (settings.hooks.SessionStart) {
|
|
57
|
+
const filteredSessionStart = settings.hooks.SessionStart.filter((matcher) => {
|
|
58
|
+
const hasOurHook = matcher.hooks?.some((hook) => hook.command === sessionStartScript ||
|
|
59
|
+
hook.command?.includes('session-start.js') ||
|
|
60
|
+
hook.command?.includes('claude-mem'));
|
|
61
|
+
return !hasOurHook;
|
|
62
|
+
});
|
|
63
|
+
if (filteredSessionStart.length !== settings.hooks.SessionStart.length) {
|
|
64
|
+
settings.hooks.SessionStart = filteredSessionStart.length > 0 ? filteredSessionStart : undefined;
|
|
65
|
+
modified = true;
|
|
66
|
+
console.log(`â
Removed SessionStart hook from ${location.name} settings`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (settings.hooks.PreCompact === undefined) {
|
|
70
|
+
delete settings.hooks.PreCompact;
|
|
71
|
+
}
|
|
72
|
+
if (settings.hooks.SessionStart === undefined) {
|
|
73
|
+
delete settings.hooks.SessionStart;
|
|
74
|
+
}
|
|
75
|
+
if (Object.keys(settings.hooks).length === 0) {
|
|
76
|
+
delete settings.hooks;
|
|
77
|
+
}
|
|
78
|
+
if (modified) {
|
|
79
|
+
const backupPath = location.path + '.backup.' + Date.now();
|
|
80
|
+
writeFileSync(backupPath, content);
|
|
81
|
+
console.log(`đ Created backup: ${backupPath}`);
|
|
82
|
+
writeFileSync(location.path, JSON.stringify(settings, null, 2));
|
|
83
|
+
removedCount++;
|
|
84
|
+
console.log(`â
Updated ${location.name} settings: ${location.path}`);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
console.log(`âšī¸ No Claude Memory System hooks found in ${location.name} settings`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.warn(`Could not process ${location.name} settings: ${error.message}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
console.log('');
|
|
95
|
+
if (removedCount > 0) {
|
|
96
|
+
console.log('⨠Uninstallation complete!');
|
|
97
|
+
console.log('The Claude Memory System hooks have been removed from your settings.');
|
|
98
|
+
console.log('');
|
|
99
|
+
console.log('Note: Your compressed transcripts and archives are preserved.');
|
|
100
|
+
console.log('To reinstall: claude-mem install');
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
console.log('âšī¸ No Claude Memory System hooks were found to remove.');
|
|
104
|
+
}
|
|
105
|
+
}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const PACKAGE_NAME: string;
|
|
2
|
+
export declare const PACKAGE_VERSION: string;
|
|
3
|
+
export declare const PACKAGE_DESCRIPTION: string;
|
|
4
|
+
export declare const CLI_NAME: string;
|
|
5
|
+
export declare const MCP_SERVER_NAME = "claude-mem-server";
|
|
6
|
+
export declare const MCP_SERVER_SCRIPT = "mcp-server-cli.js";
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from 'fs';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
// Default values for compiled binaries
|
|
5
|
+
const DEFAULT_PACKAGE_NAME = 'claude-mem';
|
|
6
|
+
const DEFAULT_PACKAGE_VERSION = '2.0.6';
|
|
7
|
+
const DEFAULT_PACKAGE_DESCRIPTION = 'Memory compression system for Claude Code - persist context across sessions';
|
|
8
|
+
let packageName = DEFAULT_PACKAGE_NAME;
|
|
9
|
+
let packageVersion = DEFAULT_PACKAGE_VERSION;
|
|
10
|
+
let packageDescription = DEFAULT_PACKAGE_DESCRIPTION;
|
|
11
|
+
// Try to read package.json if it exists (for development)
|
|
12
|
+
try {
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
const packageJsonPath = join(__dirname, '..', 'package.json');
|
|
16
|
+
if (existsSync(packageJsonPath)) {
|
|
17
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
18
|
+
packageName = packageJson.name || DEFAULT_PACKAGE_NAME;
|
|
19
|
+
packageVersion = packageJson.version || DEFAULT_PACKAGE_VERSION;
|
|
20
|
+
packageDescription = packageJson.description || DEFAULT_PACKAGE_DESCRIPTION;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// Use defaults if package.json can't be read (compiled binary)
|
|
25
|
+
}
|
|
26
|
+
// Export package configuration
|
|
27
|
+
export const PACKAGE_NAME = packageName;
|
|
28
|
+
export const PACKAGE_VERSION = packageVersion;
|
|
29
|
+
export const PACKAGE_DESCRIPTION = packageDescription;
|
|
30
|
+
// Export commonly used names
|
|
31
|
+
export const CLI_NAME = PACKAGE_NAME; // The CLI command name
|
|
32
|
+
export const MCP_SERVER_NAME = 'claude-mem-server';
|
|
33
|
+
export const MCP_SERVER_SCRIPT = 'mcp-server-cli.js';
|