claude-mem 3.3.7 → 3.3.9

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 (96) hide show
  1. package/README.md +183 -46
  2. package/dist/bin/cli.d.ts +2 -0
  3. package/dist/bin/cli.js +179 -0
  4. package/dist/commands/compress.d.ts +2 -0
  5. package/dist/commands/compress.js +27 -0
  6. package/dist/commands/hooks.d.ts +19 -0
  7. package/dist/commands/hooks.js +131 -0
  8. package/dist/commands/install.d.ts +2 -0
  9. package/dist/commands/install.js +836 -0
  10. package/dist/commands/load-context.d.ts +2 -0
  11. package/dist/commands/load-context.js +151 -0
  12. package/dist/commands/logs.d.ts +2 -0
  13. package/dist/commands/logs.js +76 -0
  14. package/dist/commands/migrate-to-jsonl.d.ts +5 -0
  15. package/dist/commands/migrate-to-jsonl.js +99 -0
  16. package/dist/commands/restore.d.ts +1 -0
  17. package/dist/commands/restore.js +20 -0
  18. package/dist/commands/status.d.ts +1 -0
  19. package/dist/commands/status.js +136 -0
  20. package/dist/commands/trash-empty.d.ts +3 -0
  21. package/dist/commands/trash-empty.js +56 -0
  22. package/dist/commands/trash-view.d.ts +1 -0
  23. package/dist/commands/trash-view.js +101 -0
  24. package/dist/commands/trash.d.ts +6 -0
  25. package/dist/commands/trash.js +49 -0
  26. package/dist/commands/uninstall.d.ts +2 -0
  27. package/dist/commands/uninstall.js +107 -0
  28. package/dist/constants.d.ts +271 -0
  29. package/dist/constants.js +199 -0
  30. package/dist/core/compression/TranscriptCompressor.d.ts +79 -0
  31. package/dist/core/compression/TranscriptCompressor.js +585 -0
  32. package/dist/core/orchestration/PromptOrchestrator.d.ts +165 -0
  33. package/dist/core/orchestration/PromptOrchestrator.js +182 -0
  34. package/dist/lib/time-utils.d.ts +5 -0
  35. package/dist/lib/time-utils.js +70 -0
  36. package/dist/prompts/constants.d.ts +126 -0
  37. package/dist/prompts/constants.js +161 -0
  38. package/dist/prompts/index.d.ts +10 -0
  39. package/dist/prompts/index.js +11 -0
  40. package/dist/prompts/templates/analysis/AnalysisTemplates.d.ts +13 -0
  41. package/dist/prompts/templates/analysis/AnalysisTemplates.js +94 -0
  42. package/dist/prompts/templates/context/ContextTemplates.d.ts +119 -0
  43. package/dist/prompts/templates/context/ContextTemplates.js +399 -0
  44. package/dist/prompts/templates/hooks/HookTemplates.d.ts +175 -0
  45. package/dist/prompts/templates/hooks/HookTemplates.js +394 -0
  46. package/dist/prompts/templates/hooks/HookTemplates.test.d.ts +7 -0
  47. package/dist/prompts/templates/hooks/HookTemplates.test.js +127 -0
  48. package/dist/shared/config.d.ts +4 -0
  49. package/dist/shared/config.js +41 -0
  50. package/dist/shared/error-handler.d.ts +22 -0
  51. package/dist/shared/error-handler.js +142 -0
  52. package/dist/shared/logger.d.ts +19 -0
  53. package/dist/shared/logger.js +51 -0
  54. package/dist/shared/paths.d.ts +28 -0
  55. package/dist/shared/paths.js +100 -0
  56. package/dist/shared/settings.d.ts +41 -0
  57. package/dist/shared/settings.js +81 -0
  58. package/dist/shared/types.d.ts +145 -0
  59. package/dist/shared/types.js +78 -0
  60. package/docs/STATUS.md +155 -0
  61. package/docs/chroma-backend-migration.md +161 -0
  62. package/docs/landing-page-outline.md +287 -0
  63. package/docs/multi-platform-builds.md +96 -0
  64. package/docs/plans/cloud-service-plan.md +274 -0
  65. package/docs/plans/fix-response-format-issue.md +61 -0
  66. package/docs/plans/restructure-session-hook-output.md +102 -0
  67. package/docs/plans/session-start-hook-investigation.md +45 -0
  68. package/docs/plans/src-reorganization-plan.md +181 -0
  69. package/docs/plans/terminal-effects-decision.md +22 -0
  70. package/docs/plans/terminal-effects-integration.md +82 -0
  71. package/docs/plans/trash-bin-feature-plan.md +240 -0
  72. package/docs/plans/trash-bin-minimal-plan.md +102 -0
  73. package/docs/reference/bun-single-executable.md +584 -0
  74. package/docs/reference/cc-output-styles.md +99 -0
  75. package/docs/reference/chroma-mcp-project-memory-example.md +80 -0
  76. package/docs/reference/chroma-mcp-team-example.md +92 -0
  77. package/docs/reference/claude-code/cc-hooks.md +787 -0
  78. package/docs/reference/claude-code/cc-status-line.md +202 -0
  79. package/docs/reference/claude-code/hook-configuration.md +173 -0
  80. package/docs/reference/claude-code/hook-responses.md +127 -0
  81. package/docs/reference/claude-code/hooks.md +175 -0
  82. package/docs/reference/claude-code/mcp-configuration.md +133 -0
  83. package/docs/reference/claude-code/session-start-hook.md +82 -0
  84. package/docs/reference/load-context-format-example.md +33 -0
  85. package/docs/reference/mcp-sdk/mcp-typescript-sdk-readme.md +1323 -0
  86. package/docs/reference/mcp-sdk/server-implementation.md +286 -0
  87. package/docs/reference/mcp-sdk/stdio-transport.md +345 -0
  88. package/docs/todos/fix-response-format-tasks.md +43 -0
  89. package/docs/todos/implementation-todos.md +280 -0
  90. package/docs/todos/restructure-hook-output-tasks.md +103 -0
  91. package/docs/todos/session-start-hook-fix.md +26 -0
  92. package/docs/todos/terminal-effects-tasks.md +42 -0
  93. package/docs/todos/trash-bin-implementation-todos.md +348 -0
  94. package/docs/todos/trash-bin-minimal-todos.md +27 -0
  95. package/package.json +56 -6
  96. package/claude-mem +0 -0
@@ -0,0 +1,6 @@
1
+ interface TrashOptions {
2
+ force?: boolean;
3
+ recursive?: boolean;
4
+ }
5
+ export declare function trash(filePaths: string | string[], options?: TrashOptions): Promise<void>;
6
+ export {};
@@ -0,0 +1,49 @@
1
+ import { renameSync, existsSync, mkdirSync, statSync } from 'fs';
2
+ import { join, basename } from 'path';
3
+ import { homedir } from 'os';
4
+ import { glob } from 'glob';
5
+ export async function trash(filePaths, options = {}) {
6
+ const trashDir = join(homedir(), '.claude-mem', 'trash');
7
+ if (!existsSync(trashDir))
8
+ mkdirSync(trashDir, { recursive: true });
9
+ // Handle single string or array of paths
10
+ const paths = Array.isArray(filePaths) ? filePaths : [filePaths];
11
+ for (const filePath of paths) {
12
+ // Handle glob patterns
13
+ const expandedPaths = await glob(filePath);
14
+ const actualPaths = expandedPaths.length > 0 ? expandedPaths : [filePath];
15
+ for (const actualPath of actualPaths) {
16
+ try {
17
+ // Check if file exists
18
+ if (!existsSync(actualPath)) {
19
+ if (!options.force) {
20
+ console.error(`trash: ${actualPath}: No such file or directory`);
21
+ continue;
22
+ }
23
+ // With -f, silently skip missing files
24
+ continue;
25
+ }
26
+ // Check if it's a directory and we need recursive
27
+ const stats = statSync(actualPath);
28
+ if (stats.isDirectory() && !options.recursive) {
29
+ if (!options.force) {
30
+ console.error(`trash: ${actualPath}: is a directory`);
31
+ continue;
32
+ }
33
+ }
34
+ // Generate unique destination name to avoid conflicts
35
+ const fileName = basename(actualPath);
36
+ const timestamp = Date.now();
37
+ const destination = join(trashDir, `${fileName}.${timestamp}`);
38
+ renameSync(actualPath, destination);
39
+ console.log(`Moved ${fileName} to trash`);
40
+ }
41
+ catch (error) {
42
+ if (!options.force) {
43
+ const errorMessage = error instanceof Error ? error.message : String(error);
44
+ console.error(`trash: ${actualPath}: ${errorMessage}`);
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,2 @@
1
+ import { OptionValues } from 'commander';
2
+ export declare function uninstall(options?: OptionValues): Promise<void>;
@@ -0,0 +1,107 @@
1
+ import { readFileSync, writeFileSync, existsSync } from 'fs';
2
+ import { join } from 'path';
3
+ import { homedir } from 'os';
4
+ export async function uninstall(options = {}) {
5
+ console.log('🔄 Uninstalling Claude Memory System hooks...');
6
+ const locations = [];
7
+ if (options.all) {
8
+ locations.push({
9
+ name: 'User',
10
+ path: join(homedir(), '.claude', 'settings.json')
11
+ });
12
+ locations.push({
13
+ name: 'Project',
14
+ path: join(process.cwd(), '.claude', 'settings.json')
15
+ });
16
+ }
17
+ else {
18
+ const isProject = options.project;
19
+ locations.push({
20
+ name: isProject ? 'Project' : 'User',
21
+ path: join(isProject ? process.cwd() : homedir(), '.claude', 'settings.json')
22
+ });
23
+ }
24
+ const claudeMemHooksDir = join(homedir(), '.claude-mem', 'hooks');
25
+ const preCompactScript = join(claudeMemHooksDir, 'pre-compact.js');
26
+ const sessionStartScript = join(claudeMemHooksDir, 'session-start.js');
27
+ const sessionEndScript = join(claudeMemHooksDir, 'session-end.js');
28
+ let removedCount = 0;
29
+ for (const location of locations) {
30
+ if (!existsSync(location.path)) {
31
+ console.log(`⏭️ No settings found at ${location.name} location`);
32
+ continue;
33
+ }
34
+ try {
35
+ const content = readFileSync(location.path, 'utf8');
36
+ const settings = JSON.parse(content);
37
+ if (!settings.hooks) {
38
+ console.log(`⏭️ No hooks configured in ${location.name} settings`);
39
+ continue;
40
+ }
41
+ let modified = false;
42
+ if (settings.hooks.PreCompact) {
43
+ const filteredPreCompact = settings.hooks.PreCompact.filter((matcher) => !matcher.hooks?.some((hook) => hook.command === preCompactScript ||
44
+ hook.command?.includes('pre-compact.js') ||
45
+ hook.command?.includes('claude-mem')));
46
+ if (filteredPreCompact.length !== settings.hooks.PreCompact.length) {
47
+ settings.hooks.PreCompact = filteredPreCompact.length ? filteredPreCompact : undefined;
48
+ modified = true;
49
+ console.log(`✅ Removed PreCompact hook from ${location.name} settings`);
50
+ }
51
+ }
52
+ if (settings.hooks.SessionStart) {
53
+ const filteredSessionStart = settings.hooks.SessionStart.filter((matcher) => !matcher.hooks?.some((hook) => hook.command === sessionStartScript ||
54
+ hook.command?.includes('session-start.js') ||
55
+ hook.command?.includes('claude-mem')));
56
+ if (filteredSessionStart.length !== settings.hooks.SessionStart.length) {
57
+ settings.hooks.SessionStart = filteredSessionStart.length ? filteredSessionStart : undefined;
58
+ modified = true;
59
+ console.log(`✅ Removed SessionStart hook from ${location.name} settings`);
60
+ }
61
+ }
62
+ if (settings.hooks.SessionEnd) {
63
+ const filteredSessionEnd = settings.hooks.SessionEnd.filter((matcher) => !matcher.hooks?.some((hook) => hook.command === sessionEndScript ||
64
+ hook.command?.includes('session-end.js') ||
65
+ hook.command?.includes('claude-mem')));
66
+ if (filteredSessionEnd.length !== settings.hooks.SessionEnd.length) {
67
+ settings.hooks.SessionEnd = filteredSessionEnd.length ? filteredSessionEnd : undefined;
68
+ modified = true;
69
+ console.log(`✅ Removed SessionEnd hook from ${location.name} settings`);
70
+ }
71
+ }
72
+ if (settings.hooks.PreCompact === undefined)
73
+ delete settings.hooks.PreCompact;
74
+ if (settings.hooks.SessionStart === undefined)
75
+ delete settings.hooks.SessionStart;
76
+ if (settings.hooks.SessionEnd === undefined)
77
+ delete settings.hooks.SessionEnd;
78
+ if (!Object.keys(settings.hooks).length)
79
+ delete settings.hooks;
80
+ if (modified) {
81
+ const backupPath = location.path + '.backup.' + Date.now();
82
+ writeFileSync(backupPath, content);
83
+ console.log(`📋 Created backup: ${backupPath}`);
84
+ writeFileSync(location.path, JSON.stringify(settings, null, 2));
85
+ removedCount++;
86
+ console.log(`✅ Updated ${location.name} settings: ${location.path}`);
87
+ }
88
+ else {
89
+ console.log(`ℹ️ No Claude Memory System hooks found in ${location.name} settings`);
90
+ }
91
+ }
92
+ catch (error) {
93
+ console.log(`⚠️ Could not process ${location.name} settings: ${error.message}`);
94
+ }
95
+ }
96
+ console.log('');
97
+ if (removedCount > 0) {
98
+ console.log('✨ Uninstallation complete!');
99
+ console.log('The Claude Memory System hooks have been removed from your settings.');
100
+ console.log('');
101
+ console.log('Note: Your compressed transcripts and archives are preserved.');
102
+ console.log('To reinstall: claude-mem install');
103
+ }
104
+ else {
105
+ console.log('ℹ️ No Claude Memory System hooks were found to remove.');
106
+ }
107
+ }
@@ -0,0 +1,271 @@
1
+ /**
2
+ * Claude Memory System - Core Constants
3
+ *
4
+ * This file contains core application constants, CLI messages,
5
+ * configuration templates, and infrastructure-related constants.
6
+ */
7
+ /**
8
+ * MCP server configuration template
9
+ */
10
+ export declare const MCP_CONFIG_TEMPLATE: {
11
+ readonly "claude-mem": {
12
+ readonly command: "npx";
13
+ readonly args: readonly ["-y", "@modelcontextprotocol/server-memory"];
14
+ };
15
+ };
16
+ /**
17
+ * Hook configuration templates for Claude settings
18
+ */
19
+ export declare const HOOK_CONFIG_TEMPLATES: {
20
+ readonly PRE_COMPACT: (scriptPath: string) => {
21
+ pattern: string;
22
+ hooks: {
23
+ type: string;
24
+ command: string;
25
+ timeout: number;
26
+ }[];
27
+ };
28
+ readonly SESSION_START: (scriptPath: string) => {
29
+ pattern: string;
30
+ hooks: {
31
+ type: string;
32
+ command: string;
33
+ timeout: number;
34
+ }[];
35
+ };
36
+ readonly SESSION_END: (scriptPath: string) => {
37
+ pattern: string;
38
+ hooks: {
39
+ type: string;
40
+ command: string;
41
+ timeout: number;
42
+ }[];
43
+ };
44
+ };
45
+ /**
46
+ * Command-line interface messages
47
+ */
48
+ export declare const CLI_MESSAGES: {
49
+ readonly INSTALLATION: {
50
+ readonly STARTING: "🚀 Installing Claude Memory System with Chroma...";
51
+ readonly SUCCESS: "🎉 Installation complete! Vector database ready.";
52
+ readonly HOOKS_INSTALLED: "✅ Installed hooks to ~/.claude-mem/hooks/";
53
+ readonly MCP_CONFIGURED: (path: string) => string;
54
+ readonly EMBEDDED_READY: "🧠 Chroma initialized for persistent semantic memory";
55
+ readonly ALREADY_INSTALLED: "⚠️ Claude Memory hooks are already installed.";
56
+ readonly USE_FORCE: " Use --force to overwrite existing installation.";
57
+ readonly SETTINGS_WRITTEN: (type: string, path: string) => string;
58
+ };
59
+ readonly NEXT_STEPS: readonly ["1. Restart Claude Code to load the new hooks", "2. Use `/clear` and `/compact` in Claude Code to save and compress session memories", "3. New sessions will automatically load relevant context"];
60
+ readonly ERRORS: {
61
+ readonly HOOKS_NOT_FOUND: "❌ Hook source files not found";
62
+ readonly SETTINGS_WRITE_FAILED: (path: string, error: string) => string;
63
+ readonly MCP_CONFIG_PARSE_FAILED: (error: string) => string;
64
+ readonly MCP_CONFIG_WRITE_FAILED: (error: string) => string;
65
+ readonly COMPRESSION_FAILED: (error: string) => string;
66
+ readonly CONTEXT_LOAD_FAILED: (error: string) => string;
67
+ };
68
+ readonly STATUS: {
69
+ readonly NO_INDEX: "📚 No memory index found. Starting fresh session.";
70
+ readonly RECENT_MEMORIES: "🧠 Recent memories from previous sessions:";
71
+ readonly MEMORY_COUNT: (count: number) => string;
72
+ readonly FULL_CONTEXT_AVAILABLE: "💡 Full context available via MCP memory tools";
73
+ };
74
+ };
75
+ /**
76
+ * Debug logging message templates
77
+ */
78
+ export declare const DEBUG_MESSAGES: {
79
+ readonly COMPRESSION_STARTED: "🚀 COMPRESSION STARTED";
80
+ readonly TRANSCRIPT_PATH: (path: string) => string;
81
+ readonly SESSION_ID: (id: string) => string;
82
+ readonly PROJECT_NAME: (name: string) => string;
83
+ readonly CLAUDE_SDK_CALL: "🤖 Calling Claude SDK to analyze and populate memory database...";
84
+ readonly TRANSCRIPT_STATS: (size: number, count: number) => string;
85
+ readonly COMPRESSION_COMPLETE: (count: number) => string;
86
+ readonly CLAUDE_PATH_FOUND: (path: string) => string;
87
+ readonly MCP_CONFIG_USED: (path: string) => string;
88
+ };
89
+ /**
90
+ * Memory database search templates
91
+ */
92
+ export declare const SEARCH_TEMPLATES: {
93
+ readonly SEARCH_SCRIPT: (query: string) => string;
94
+ readonly SEARCH_PREFIX: "Search for: ";
95
+ };
96
+ /**
97
+ * Chroma MCP server configuration template
98
+ */
99
+ export declare const CHROMA_MCP_CONFIG: {
100
+ readonly "claude-mem": {
101
+ readonly command: "npx";
102
+ readonly args: readonly ["-y", "@modelcontextprotocol/server-memory"];
103
+ };
104
+ };
105
+ /**
106
+ * Chroma collection names for documents
107
+ */
108
+ export declare const CHROMA_COLLECTIONS: {
109
+ readonly DOCUMENTS: "claude_mem_documents";
110
+ readonly MEMORIES: "claude_mem_memories";
111
+ };
112
+ /**
113
+ * Default Chroma configuration values
114
+ */
115
+ export declare const CHROMA_DEFAULTS: {
116
+ readonly HOST: "localhost:8000";
117
+ readonly COLLECTION: "claude_mem_documents";
118
+ };
119
+ /**
120
+ * Chroma-specific CLI messages
121
+ */
122
+ export declare const CHROMA_MESSAGES: {
123
+ readonly CONNECTION: {
124
+ readonly CONNECTING: "🔗 Connecting to Chroma server...";
125
+ readonly CONNECTED: "✅ Connected to Chroma successfully";
126
+ readonly FAILED: (error: string) => string;
127
+ readonly DISCONNECTED: "👋 Disconnected from Chroma";
128
+ };
129
+ readonly SEARCH: {
130
+ readonly SEMANTIC_SEARCH: "🧠 Using semantic search with Chroma...";
131
+ readonly KEYWORD_SEARCH: "🔍 Using keyword search with Chroma...";
132
+ readonly HYBRID_SEARCH: "🔬 Using hybrid search with Chroma...";
133
+ readonly RESULTS_FOUND: (count: number) => string;
134
+ };
135
+ readonly SETUP: {
136
+ readonly STARTING_CHROMA: "🚀 Starting Chroma instance...";
137
+ readonly CHROMA_READY: "✅ Chroma is ready and accepting connections";
138
+ readonly INITIALIZING_COLLECTIONS: "📋 Initializing document collections...";
139
+ };
140
+ };
141
+ /**
142
+ * Chroma error messages
143
+ */
144
+ export declare const CHROMA_ERRORS: {
145
+ readonly CONNECTION_FAILED: "Could not establish connection to Chroma server";
146
+ readonly MCP_SERVER_NOT_FOUND: "Chroma MCP server not found";
147
+ readonly INVALID_COLLECTION: (collection: string) => string;
148
+ readonly QUERY_FAILED: (query: string, error: string) => string;
149
+ readonly DOCUMENT_CREATION_FAILED: (id: string) => string;
150
+ readonly COLLECTION_CREATION_FAILED: (name: string) => string;
151
+ };
152
+ /**
153
+ * Export all core constants for easy importing
154
+ */
155
+ export declare const CONSTANTS: {
156
+ readonly MCP_CONFIG_TEMPLATE: {
157
+ readonly "claude-mem": {
158
+ readonly command: "npx";
159
+ readonly args: readonly ["-y", "@modelcontextprotocol/server-memory"];
160
+ };
161
+ };
162
+ readonly HOOK_CONFIG_TEMPLATES: {
163
+ readonly PRE_COMPACT: (scriptPath: string) => {
164
+ pattern: string;
165
+ hooks: {
166
+ type: string;
167
+ command: string;
168
+ timeout: number;
169
+ }[];
170
+ };
171
+ readonly SESSION_START: (scriptPath: string) => {
172
+ pattern: string;
173
+ hooks: {
174
+ type: string;
175
+ command: string;
176
+ timeout: number;
177
+ }[];
178
+ };
179
+ readonly SESSION_END: (scriptPath: string) => {
180
+ pattern: string;
181
+ hooks: {
182
+ type: string;
183
+ command: string;
184
+ timeout: number;
185
+ }[];
186
+ };
187
+ };
188
+ readonly CLI_MESSAGES: {
189
+ readonly INSTALLATION: {
190
+ readonly STARTING: "🚀 Installing Claude Memory System with Chroma...";
191
+ readonly SUCCESS: "🎉 Installation complete! Vector database ready.";
192
+ readonly HOOKS_INSTALLED: "✅ Installed hooks to ~/.claude-mem/hooks/";
193
+ readonly MCP_CONFIGURED: (path: string) => string;
194
+ readonly EMBEDDED_READY: "🧠 Chroma initialized for persistent semantic memory";
195
+ readonly ALREADY_INSTALLED: "⚠️ Claude Memory hooks are already installed.";
196
+ readonly USE_FORCE: " Use --force to overwrite existing installation.";
197
+ readonly SETTINGS_WRITTEN: (type: string, path: string) => string;
198
+ };
199
+ readonly NEXT_STEPS: readonly ["1. Restart Claude Code to load the new hooks", "2. Use `/clear` and `/compact` in Claude Code to save and compress session memories", "3. New sessions will automatically load relevant context"];
200
+ readonly ERRORS: {
201
+ readonly HOOKS_NOT_FOUND: "❌ Hook source files not found";
202
+ readonly SETTINGS_WRITE_FAILED: (path: string, error: string) => string;
203
+ readonly MCP_CONFIG_PARSE_FAILED: (error: string) => string;
204
+ readonly MCP_CONFIG_WRITE_FAILED: (error: string) => string;
205
+ readonly COMPRESSION_FAILED: (error: string) => string;
206
+ readonly CONTEXT_LOAD_FAILED: (error: string) => string;
207
+ };
208
+ readonly STATUS: {
209
+ readonly NO_INDEX: "📚 No memory index found. Starting fresh session.";
210
+ readonly RECENT_MEMORIES: "🧠 Recent memories from previous sessions:";
211
+ readonly MEMORY_COUNT: (count: number) => string;
212
+ readonly FULL_CONTEXT_AVAILABLE: "💡 Full context available via MCP memory tools";
213
+ };
214
+ };
215
+ readonly DEBUG_MESSAGES: {
216
+ readonly COMPRESSION_STARTED: "🚀 COMPRESSION STARTED";
217
+ readonly TRANSCRIPT_PATH: (path: string) => string;
218
+ readonly SESSION_ID: (id: string) => string;
219
+ readonly PROJECT_NAME: (name: string) => string;
220
+ readonly CLAUDE_SDK_CALL: "🤖 Calling Claude SDK to analyze and populate memory database...";
221
+ readonly TRANSCRIPT_STATS: (size: number, count: number) => string;
222
+ readonly COMPRESSION_COMPLETE: (count: number) => string;
223
+ readonly CLAUDE_PATH_FOUND: (path: string) => string;
224
+ readonly MCP_CONFIG_USED: (path: string) => string;
225
+ };
226
+ readonly SEARCH_TEMPLATES: {
227
+ readonly SEARCH_SCRIPT: (query: string) => string;
228
+ readonly SEARCH_PREFIX: "Search for: ";
229
+ };
230
+ readonly CHROMA_MCP_CONFIG: {
231
+ readonly "claude-mem": {
232
+ readonly command: "npx";
233
+ readonly args: readonly ["-y", "@modelcontextprotocol/server-memory"];
234
+ };
235
+ };
236
+ readonly CHROMA_COLLECTIONS: {
237
+ readonly DOCUMENTS: "claude_mem_documents";
238
+ readonly MEMORIES: "claude_mem_memories";
239
+ };
240
+ readonly CHROMA_DEFAULTS: {
241
+ readonly HOST: "localhost:8000";
242
+ readonly COLLECTION: "claude_mem_documents";
243
+ };
244
+ readonly CHROMA_MESSAGES: {
245
+ readonly CONNECTION: {
246
+ readonly CONNECTING: "🔗 Connecting to Chroma server...";
247
+ readonly CONNECTED: "✅ Connected to Chroma successfully";
248
+ readonly FAILED: (error: string) => string;
249
+ readonly DISCONNECTED: "👋 Disconnected from Chroma";
250
+ };
251
+ readonly SEARCH: {
252
+ readonly SEMANTIC_SEARCH: "🧠 Using semantic search with Chroma...";
253
+ readonly KEYWORD_SEARCH: "🔍 Using keyword search with Chroma...";
254
+ readonly HYBRID_SEARCH: "🔬 Using hybrid search with Chroma...";
255
+ readonly RESULTS_FOUND: (count: number) => string;
256
+ };
257
+ readonly SETUP: {
258
+ readonly STARTING_CHROMA: "🚀 Starting Chroma instance...";
259
+ readonly CHROMA_READY: "✅ Chroma is ready and accepting connections";
260
+ readonly INITIALIZING_COLLECTIONS: "📋 Initializing document collections...";
261
+ };
262
+ };
263
+ readonly CHROMA_ERRORS: {
264
+ readonly CONNECTION_FAILED: "Could not establish connection to Chroma server";
265
+ readonly MCP_SERVER_NOT_FOUND: "Chroma MCP server not found";
266
+ readonly INVALID_COLLECTION: (collection: string) => string;
267
+ readonly QUERY_FAILED: (query: string, error: string) => string;
268
+ readonly DOCUMENT_CREATION_FAILED: (id: string) => string;
269
+ readonly COLLECTION_CREATION_FAILED: (name: string) => string;
270
+ };
271
+ };
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Claude Memory System - Core Constants
3
+ *
4
+ * This file contains core application constants, CLI messages,
5
+ * configuration templates, and infrastructure-related constants.
6
+ */
7
+ // =============================================================================
8
+ // CONFIGURATION TEMPLATES
9
+ // =============================================================================
10
+ /**
11
+ * MCP server configuration template
12
+ */
13
+ export const MCP_CONFIG_TEMPLATE = {
14
+ "claude-mem": {
15
+ command: "npx",
16
+ args: ["-y", "@modelcontextprotocol/server-memory"]
17
+ }
18
+ };
19
+ /**
20
+ * Hook configuration templates for Claude settings
21
+ */
22
+ export const HOOK_CONFIG_TEMPLATES = {
23
+ PRE_COMPACT: (scriptPath) => ({
24
+ pattern: "*",
25
+ hooks: [{
26
+ type: "command",
27
+ command: scriptPath,
28
+ timeout: 180000
29
+ }]
30
+ }),
31
+ SESSION_START: (scriptPath) => ({
32
+ pattern: "*",
33
+ hooks: [{
34
+ type: "command",
35
+ command: scriptPath,
36
+ timeout: 30000
37
+ }]
38
+ }),
39
+ SESSION_END: (scriptPath) => ({
40
+ pattern: "*",
41
+ hooks: [{
42
+ type: "command",
43
+ command: scriptPath,
44
+ timeout: 180000
45
+ }]
46
+ })
47
+ };
48
+ // =============================================================================
49
+ // CLI MESSAGES AND STATUS TEMPLATES
50
+ // =============================================================================
51
+ /**
52
+ * Command-line interface messages
53
+ */
54
+ export const CLI_MESSAGES = {
55
+ INSTALLATION: {
56
+ STARTING: '🚀 Installing Claude Memory System with Chroma...',
57
+ SUCCESS: '🎉 Installation complete! Vector database ready.',
58
+ HOOKS_INSTALLED: '✅ Installed hooks to ~/.claude-mem/hooks/',
59
+ MCP_CONFIGURED: (path) => `✅ Configured MCP memory server in ${path}`,
60
+ EMBEDDED_READY: '🧠 Chroma initialized for persistent semantic memory',
61
+ ALREADY_INSTALLED: '⚠️ Claude Memory hooks are already installed.',
62
+ USE_FORCE: ' Use --force to overwrite existing installation.',
63
+ SETTINGS_WRITTEN: (type, path) => `✅ Installed hooks in ${type} settings\n Settings file: ${path}`
64
+ },
65
+ NEXT_STEPS: [
66
+ '1. Restart Claude Code to load the new hooks',
67
+ '2. Use `/clear` and `/compact` in Claude Code to save and compress session memories',
68
+ '3. New sessions will automatically load relevant context'
69
+ ],
70
+ ERRORS: {
71
+ HOOKS_NOT_FOUND: '❌ Hook source files not found',
72
+ SETTINGS_WRITE_FAILED: (path, error) => `❌ Failed to write settings file: ${error}\n Path: ${path}`,
73
+ MCP_CONFIG_PARSE_FAILED: (error) => `⚠️ Warning: Could not parse existing MCP config: ${error}`,
74
+ MCP_CONFIG_WRITE_FAILED: (error) => `⚠️ Warning: Could not write MCP config: ${error}`,
75
+ COMPRESSION_FAILED: (error) => `❌ Compression failed: ${error}`,
76
+ CONTEXT_LOAD_FAILED: (error) => `❌ Failed to load context: ${error}`
77
+ },
78
+ STATUS: {
79
+ NO_INDEX: '📚 No memory index found. Starting fresh session.',
80
+ RECENT_MEMORIES: '🧠 Recent memories from previous sessions:',
81
+ MEMORY_COUNT: (count) => `📚 Showing ${count} most recent memories`,
82
+ FULL_CONTEXT_AVAILABLE: '💡 Full context available via MCP memory tools'
83
+ }
84
+ };
85
+ // =============================================================================
86
+ // DEBUG AND LOGGING TEMPLATES
87
+ // =============================================================================
88
+ /**
89
+ * Debug logging message templates
90
+ */
91
+ export const DEBUG_MESSAGES = {
92
+ COMPRESSION_STARTED: '🚀 COMPRESSION STARTED',
93
+ TRANSCRIPT_PATH: (path) => `📁 Transcript Path: ${path}`,
94
+ SESSION_ID: (id) => `🔍 Session ID: ${id}`,
95
+ PROJECT_NAME: (name) => `📝 PROJECT NAME: ${name}`,
96
+ CLAUDE_SDK_CALL: '🤖 Calling Claude SDK to analyze and populate memory database...',
97
+ TRANSCRIPT_STATS: (size, count) => `📊 Transcript size: ${size} characters, ${count} messages`,
98
+ COMPRESSION_COMPLETE: (count) => `✅ COMPRESSION COMPLETE\n Total summaries extracted: ${count}`,
99
+ CLAUDE_PATH_FOUND: (path) => `🎯 Found Claude Code at: ${path}`,
100
+ MCP_CONFIG_USED: (path) => `📋 Using MCP config: ${path}`
101
+ };
102
+ // =============================================================================
103
+ // SEARCH AND QUERY TEMPLATES
104
+ // =============================================================================
105
+ /**
106
+ * Memory database search templates
107
+ */
108
+ export const SEARCH_TEMPLATES = {
109
+ SEARCH_SCRIPT: (query) => `
110
+ import { query } from "@anthropic-ai/claude-code";
111
+
112
+ const searchQuery = process.env.SEARCH_QUERY || '';
113
+
114
+ const result = await query({
115
+ prompt: "Search for: " + searchQuery,
116
+ options: {
117
+ mcpConfig: "~/.claude/.mcp.json",
118
+ allowedTools: ["mcp__claude-mem__chroma_query_documents"],
119
+ outputFormat: "json"
120
+ }
121
+ });
122
+ `,
123
+ SEARCH_PREFIX: "Search for: "
124
+ };
125
+ // =============================================================================
126
+ // CHROMA INTEGRATION CONSTANTS
127
+ // =============================================================================
128
+ /**
129
+ * Chroma MCP server configuration template
130
+ */
131
+ export const CHROMA_MCP_CONFIG = {
132
+ "claude-mem": {
133
+ command: "npx",
134
+ args: ["-y", "@modelcontextprotocol/server-memory"]
135
+ }
136
+ };
137
+ /**
138
+ * Chroma collection names for documents
139
+ */
140
+ export const CHROMA_COLLECTIONS = {
141
+ DOCUMENTS: 'claude_mem_documents',
142
+ MEMORIES: 'claude_mem_memories'
143
+ };
144
+ /**
145
+ * Default Chroma configuration values
146
+ */
147
+ export const CHROMA_DEFAULTS = {
148
+ HOST: 'localhost:8000',
149
+ COLLECTION: 'claude_mem_documents'
150
+ };
151
+ /**
152
+ * Chroma-specific CLI messages
153
+ */
154
+ export const CHROMA_MESSAGES = {
155
+ CONNECTION: {
156
+ CONNECTING: '🔗 Connecting to Chroma server...',
157
+ CONNECTED: '✅ Connected to Chroma successfully',
158
+ FAILED: (error) => `❌ Failed to connect to Chroma: ${error}`,
159
+ DISCONNECTED: '👋 Disconnected from Chroma'
160
+ },
161
+ SEARCH: {
162
+ SEMANTIC_SEARCH: '🧠 Using semantic search with Chroma...',
163
+ KEYWORD_SEARCH: '🔍 Using keyword search with Chroma...',
164
+ HYBRID_SEARCH: '🔬 Using hybrid search with Chroma...',
165
+ RESULTS_FOUND: (count) => `📊 Found ${count} results in Chroma`
166
+ },
167
+ SETUP: {
168
+ STARTING_CHROMA: '🚀 Starting Chroma instance...',
169
+ CHROMA_READY: '✅ Chroma is ready and accepting connections',
170
+ INITIALIZING_COLLECTIONS: '📋 Initializing document collections...'
171
+ }
172
+ };
173
+ /**
174
+ * Chroma error messages
175
+ */
176
+ export const CHROMA_ERRORS = {
177
+ CONNECTION_FAILED: 'Could not establish connection to Chroma server',
178
+ MCP_SERVER_NOT_FOUND: 'Chroma MCP server not found',
179
+ INVALID_COLLECTION: (collection) => `Invalid Chroma collection: ${collection}`,
180
+ QUERY_FAILED: (query, error) => `Query failed for '${query}': ${error}`,
181
+ DOCUMENT_CREATION_FAILED: (id) => `Failed to create document '${id}' in Chroma`,
182
+ COLLECTION_CREATION_FAILED: (name) => `Failed to create collection '${name}' in Chroma`
183
+ };
184
+ /**
185
+ * Export all core constants for easy importing
186
+ */
187
+ export const CONSTANTS = {
188
+ MCP_CONFIG_TEMPLATE,
189
+ HOOK_CONFIG_TEMPLATES,
190
+ CLI_MESSAGES,
191
+ DEBUG_MESSAGES,
192
+ SEARCH_TEMPLATES,
193
+ // Chroma constants
194
+ CHROMA_MCP_CONFIG,
195
+ CHROMA_COLLECTIONS,
196
+ CHROMA_DEFAULTS,
197
+ CHROMA_MESSAGES,
198
+ CHROMA_ERRORS
199
+ };