claude-mem 3.1.6 → 3.1.7
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/claude-mem +0 -0
- package/dist/commands/hooks.js +31 -2
- package/dist/commands/load-context.js +38 -6
- package/package.json +1 -1
- package/dist/bin/cli.d.ts +0 -2
- package/dist/bin/cli.js +0 -129
- package/dist/commands/compress.d.ts +0 -2
- package/dist/commands/compress.js +0 -27
- package/dist/commands/install.d.ts +0 -2
- package/dist/commands/install.js +0 -649
- package/dist/commands/logs.d.ts +0 -2
- package/dist/commands/logs.js +0 -76
- package/dist/commands/setup.d.ts +0 -23
- package/dist/commands/setup.js +0 -304
- package/dist/commands/status.d.ts +0 -1
- package/dist/commands/status.js +0 -136
- package/dist/commands/uninstall.d.ts +0 -2
- package/dist/commands/uninstall.js +0 -107
- package/dist/constants.d.ts +0 -271
- package/dist/constants.js +0 -199
- package/dist/core/compression/TranscriptCompressor.d.ts +0 -83
- package/dist/core/compression/TranscriptCompressor.js +0 -561
- package/dist/core/orchestration/PromptOrchestrator.d.ts +0 -165
- package/dist/core/orchestration/PromptOrchestrator.js +0 -182
- package/dist/prompts/constants.d.ts +0 -126
- package/dist/prompts/constants.js +0 -161
- package/dist/prompts/index.d.ts +0 -10
- package/dist/prompts/index.js +0 -11
- package/dist/prompts/templates/analysis/AnalysisTemplates.d.ts +0 -13
- package/dist/prompts/templates/analysis/AnalysisTemplates.js +0 -94
- package/dist/prompts/templates/context/ContextTemplates.d.ts +0 -95
- package/dist/prompts/templates/context/ContextTemplates.js +0 -324
- package/dist/prompts/templates/hooks/HookTemplates.d.ts +0 -175
- package/dist/prompts/templates/hooks/HookTemplates.js +0 -394
- package/dist/prompts/templates/hooks/HookTemplates.test.d.ts +0 -7
- package/dist/prompts/templates/hooks/HookTemplates.test.js +0 -127
- package/dist/shared/config-manager.d.ts +0 -126
- package/dist/shared/config-manager.js +0 -269
- package/dist/shared/config.d.ts +0 -4
- package/dist/shared/config.js +0 -41
- package/dist/shared/error-handler.d.ts +0 -22
- package/dist/shared/error-handler.js +0 -142
- package/dist/shared/logger.d.ts +0 -19
- package/dist/shared/logger.js +0 -51
- package/dist/shared/paths.d.ts +0 -28
- package/dist/shared/paths.js +0 -100
- package/dist/shared/types.d.ts +0 -141
- package/dist/shared/types.js +0 -78
- package/dist/storage/adapters/chroma-mcp-adapter.d.ts +0 -62
- package/dist/storage/adapters/chroma-mcp-adapter.js +0 -92
- package/dist/storage/clients/mcp-client.d.ts +0 -75
- package/dist/storage/clients/mcp-client.js +0 -134
package/claude-mem
CHANGED
|
Binary file
|
package/dist/commands/hooks.js
CHANGED
|
@@ -56,8 +56,37 @@ export async function preCompactHook() {
|
|
|
56
56
|
*/
|
|
57
57
|
export async function sessionStartHook() {
|
|
58
58
|
try {
|
|
59
|
-
//
|
|
60
|
-
|
|
59
|
+
// Read hook data from stdin (Claude Code sends JSON)
|
|
60
|
+
let inputData = '';
|
|
61
|
+
// Set up stdin to read data
|
|
62
|
+
process.stdin.setEncoding('utf8');
|
|
63
|
+
// Collect all input data
|
|
64
|
+
for await (const chunk of process.stdin) {
|
|
65
|
+
inputData += chunk;
|
|
66
|
+
}
|
|
67
|
+
// Parse the JSON input to get the current working directory
|
|
68
|
+
let project;
|
|
69
|
+
if (inputData) {
|
|
70
|
+
try {
|
|
71
|
+
const hookData = JSON.parse(inputData);
|
|
72
|
+
// Extract project name from cwd if provided
|
|
73
|
+
if (hookData.cwd) {
|
|
74
|
+
const pathParts = hookData.cwd.split('/');
|
|
75
|
+
project = pathParts[pathParts.length - 1];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (parseError) {
|
|
79
|
+
// If JSON parsing fails, continue without project filtering
|
|
80
|
+
console.error('Failed to parse session-start hook data:', parseError);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// If no project from hook data, try to get from current working directory
|
|
84
|
+
if (!project) {
|
|
85
|
+
const pathParts = process.cwd().split('/');
|
|
86
|
+
project = pathParts[pathParts.length - 1];
|
|
87
|
+
}
|
|
88
|
+
// Load context with session-start format and project filtering
|
|
89
|
+
await loadContext({ format: 'session-start', count: '10', project });
|
|
61
90
|
}
|
|
62
91
|
catch (error) {
|
|
63
92
|
console.error('Session-start hook failed:', error.message);
|
|
@@ -23,12 +23,44 @@ export async function loadContext(options = {}) {
|
|
|
23
23
|
// Filter by project if specified
|
|
24
24
|
let filteredLines = lines;
|
|
25
25
|
if (options.project) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
// Sanitize project name to match how it's stored (replace hyphens with underscores)
|
|
27
|
+
const sanitizedProject = options.project.replace(/-/g, '_');
|
|
28
|
+
// Process lines in groups - keep session headers and overviews only if the session contains project memories
|
|
29
|
+
const processedLines = [];
|
|
30
|
+
let currentSessionHeader = null;
|
|
31
|
+
let currentSessionOverview = null;
|
|
32
|
+
let sessionHasProjectMemories = false;
|
|
33
|
+
for (const line of lines) {
|
|
34
|
+
if (line.startsWith('# Session:')) {
|
|
35
|
+
// If we had a previous session with project memories, add its header and overview
|
|
36
|
+
if (currentSessionHeader && sessionHasProjectMemories) {
|
|
37
|
+
processedLines.push(currentSessionHeader);
|
|
38
|
+
if (currentSessionOverview) {
|
|
39
|
+
processedLines.push(currentSessionOverview);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Start tracking new session
|
|
43
|
+
currentSessionHeader = line;
|
|
44
|
+
currentSessionOverview = null;
|
|
45
|
+
sessionHasProjectMemories = false;
|
|
46
|
+
}
|
|
47
|
+
else if (line.includes('**Overview:**')) {
|
|
48
|
+
currentSessionOverview = line;
|
|
49
|
+
}
|
|
50
|
+
else if (line.includes(sanitizedProject)) {
|
|
51
|
+
// This is a memory line for the current project
|
|
52
|
+
sessionHasProjectMemories = true;
|
|
53
|
+
processedLines.push(line);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Don't forget the last session if it had project memories
|
|
57
|
+
if (currentSessionHeader && sessionHasProjectMemories) {
|
|
58
|
+
processedLines.push(currentSessionHeader);
|
|
59
|
+
if (currentSessionOverview) {
|
|
60
|
+
processedLines.push(currentSessionOverview);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
filteredLines = processedLines;
|
|
32
64
|
}
|
|
33
65
|
// Take last 10 entries
|
|
34
66
|
const recentLines = filteredLines.slice(-10);
|
package/package.json
CHANGED
package/dist/bin/cli.d.ts
DELETED
package/dist/bin/cli.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// <Block> 1.1 ====================================
|
|
3
|
-
// CLI Dependencies and Imports Setup
|
|
4
|
-
// Natural pattern: Import what you need before using it
|
|
5
|
-
import { Command } from 'commander';
|
|
6
|
-
import { PACKAGE_NAME, PACKAGE_VERSION, PACKAGE_DESCRIPTION } from '../shared/config.js';
|
|
7
|
-
// Import command handlers
|
|
8
|
-
import { compress } from '../commands/compress.js';
|
|
9
|
-
import { install } from '../commands/install.js';
|
|
10
|
-
import { uninstall } from '../commands/uninstall.js';
|
|
11
|
-
import { status } from '../commands/status.js';
|
|
12
|
-
import { logs } from '../commands/logs.js';
|
|
13
|
-
import { loadContext } from '../commands/load-context.js';
|
|
14
|
-
const program = new Command();
|
|
15
|
-
// </Block> =======================================
|
|
16
|
-
// <Block> 1.2 ====================================
|
|
17
|
-
// Program Configuration
|
|
18
|
-
// Natural pattern: Configure program metadata first
|
|
19
|
-
program
|
|
20
|
-
.name(PACKAGE_NAME)
|
|
21
|
-
.description(PACKAGE_DESCRIPTION)
|
|
22
|
-
.version(PACKAGE_VERSION);
|
|
23
|
-
// </Block> =======================================
|
|
24
|
-
// <Block> 1.3 ====================================
|
|
25
|
-
// Compress Command Definition
|
|
26
|
-
// Natural pattern: Define command with its options and handler
|
|
27
|
-
// Compress command
|
|
28
|
-
program
|
|
29
|
-
.command('compress [transcript]')
|
|
30
|
-
.description('Compress a Claude Code transcript into memory')
|
|
31
|
-
.option('--output <path>', 'Output directory for compressed files')
|
|
32
|
-
.option('--dry-run', 'Show what would be compressed without doing it')
|
|
33
|
-
.option('-v, --verbose', 'Show detailed output')
|
|
34
|
-
.action(compress);
|
|
35
|
-
// </Block> =======================================
|
|
36
|
-
// <Block> 1.4 ====================================
|
|
37
|
-
// Install Command Definition
|
|
38
|
-
// Natural pattern: Define command with its options and handler
|
|
39
|
-
// Install command
|
|
40
|
-
program
|
|
41
|
-
.command('install')
|
|
42
|
-
.description('Install Claude Code hooks for automatic compression')
|
|
43
|
-
.option('--user', 'Install for current user (default)')
|
|
44
|
-
.option('--project', 'Install for current project only')
|
|
45
|
-
.option('--local', 'Install to custom local directory')
|
|
46
|
-
.option('--path <path>', 'Custom installation path (with --local)')
|
|
47
|
-
.option('--timeout <ms>', 'Hook execution timeout in milliseconds', '180000')
|
|
48
|
-
.option('--skip-mcp', 'Skip Chroma MCP server installation')
|
|
49
|
-
.option('--force', 'Force installation even if already installed')
|
|
50
|
-
.action(install);
|
|
51
|
-
// </Block> =======================================
|
|
52
|
-
// <Block> 1.5 ====================================
|
|
53
|
-
// Uninstall Command Definition
|
|
54
|
-
// Natural pattern: Define command with its options and handler
|
|
55
|
-
// Uninstall command
|
|
56
|
-
program
|
|
57
|
-
.command('uninstall')
|
|
58
|
-
.description('Remove Claude Code hooks')
|
|
59
|
-
.option('--user', 'Remove from user settings (default)')
|
|
60
|
-
.option('--project', 'Remove from project settings')
|
|
61
|
-
.option('--all', 'Remove from both user and project settings')
|
|
62
|
-
.action(uninstall);
|
|
63
|
-
// </Block> =======================================
|
|
64
|
-
// <Block> 1.6 ====================================
|
|
65
|
-
// Status Command Definition
|
|
66
|
-
// Natural pattern: Define command with its handler
|
|
67
|
-
// Status command
|
|
68
|
-
program
|
|
69
|
-
.command('status')
|
|
70
|
-
.description('Check installation status of Claude Memory System')
|
|
71
|
-
.action(status);
|
|
72
|
-
// </Block> =======================================
|
|
73
|
-
// <Block> 1.7 ====================================
|
|
74
|
-
// Logs Command Definition
|
|
75
|
-
// Natural pattern: Define command with its options and handler
|
|
76
|
-
// Logs command
|
|
77
|
-
program
|
|
78
|
-
.command('logs')
|
|
79
|
-
.description('View claude-mem operation logs')
|
|
80
|
-
.option('--debug', 'Show debug logs only')
|
|
81
|
-
.option('--error', 'Show error logs only')
|
|
82
|
-
.option('--tail [n]', 'Show last n lines', '50')
|
|
83
|
-
.option('--follow', 'Follow log output')
|
|
84
|
-
.action(logs);
|
|
85
|
-
// </Block> =======================================
|
|
86
|
-
// <Block> 1.8 ====================================
|
|
87
|
-
// Load-Context Command Definition
|
|
88
|
-
// Natural pattern: Define command with its options and handler
|
|
89
|
-
// Load-context command
|
|
90
|
-
program
|
|
91
|
-
.command('load-context')
|
|
92
|
-
.description('Load compressed memories for current session')
|
|
93
|
-
.option('--project <name>', 'Filter by project name')
|
|
94
|
-
.option('--count <n>', 'Number of memories to load', '10')
|
|
95
|
-
.option('--raw', 'Output raw JSON instead of formatted text')
|
|
96
|
-
.option('--format <type>', 'Output format: json, session-start, or default')
|
|
97
|
-
.action(loadContext);
|
|
98
|
-
// </Block> =======================================
|
|
99
|
-
// <Block> 1.10 ===================================
|
|
100
|
-
// Hook Commands for Binary Distribution
|
|
101
|
-
// Internal commands called by hook wrappers
|
|
102
|
-
program
|
|
103
|
-
.command('hook:pre-compact', { hidden: true })
|
|
104
|
-
.description('Internal pre-compact hook handler')
|
|
105
|
-
.action(async () => {
|
|
106
|
-
const { preCompactHook } = await import('../commands/hooks.js');
|
|
107
|
-
await preCompactHook();
|
|
108
|
-
});
|
|
109
|
-
program
|
|
110
|
-
.command('hook:session-start', { hidden: true })
|
|
111
|
-
.description('Internal session-start hook handler')
|
|
112
|
-
.action(async () => {
|
|
113
|
-
const { sessionStartHook } = await import('../commands/hooks.js');
|
|
114
|
-
await sessionStartHook();
|
|
115
|
-
});
|
|
116
|
-
program
|
|
117
|
-
.command('hook:session-end', { hidden: true })
|
|
118
|
-
.description('Internal session-end hook handler')
|
|
119
|
-
.action(async () => {
|
|
120
|
-
const { sessionEndHook } = await import('../commands/hooks.js');
|
|
121
|
-
await sessionEndHook();
|
|
122
|
-
});
|
|
123
|
-
// </Block> =======================================
|
|
124
|
-
// <Block> 1.11 ===================================
|
|
125
|
-
// CLI Execution
|
|
126
|
-
// Natural pattern: After defining all commands, parse and execute
|
|
127
|
-
// Parse arguments and execute
|
|
128
|
-
program.parse();
|
|
129
|
-
// </Block> =======================================
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { basename } from 'path';
|
|
2
|
-
import { createLoadingMessage, createCompletionMessage, createOperationSummary, createUserFriendlyError } from '../prompts/templates/context/ContextTemplates.js';
|
|
3
|
-
export async function compress(transcript, options = {}) {
|
|
4
|
-
console.log(createLoadingMessage('compressing'));
|
|
5
|
-
if (!transcript) {
|
|
6
|
-
console.log(createUserFriendlyError('Compression', 'No transcript file provided', 'Please provide a path to a transcript file'));
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
try {
|
|
10
|
-
const startTime = Date.now();
|
|
11
|
-
// Import and run compression
|
|
12
|
-
const { TranscriptCompressor } = await import('../core/compression/TranscriptCompressor.js');
|
|
13
|
-
const compressor = new TranscriptCompressor({
|
|
14
|
-
verbose: options.verbose || false
|
|
15
|
-
});
|
|
16
|
-
const sessionId = options.sessionId || basename(transcript, '.jsonl');
|
|
17
|
-
const archivePath = await compressor.compress(transcript, sessionId);
|
|
18
|
-
const duration = Date.now() - startTime;
|
|
19
|
-
console.log(createCompletionMessage('Compression', undefined, `Session archived as ${basename(archivePath)}`));
|
|
20
|
-
console.log(createOperationSummary('compress', { count: 1, duration, details: `Session: ${sessionId}` }));
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
24
|
-
console.log(createUserFriendlyError('Compression', errorMessage, 'Check that the transcript file exists and you have write permissions'));
|
|
25
|
-
throw error; // Re-throw to maintain existing error handling behavior
|
|
26
|
-
}
|
|
27
|
-
}
|