claude-mem 3.2.0 → 3.2.2

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 (50) hide show
  1. package/claude-mem +0 -0
  2. package/package.json +1 -2
  3. package/dist/bin/cli.d.ts +0 -2
  4. package/dist/bin/cli.js +0 -129
  5. package/dist/commands/compress.d.ts +0 -2
  6. package/dist/commands/compress.js +0 -27
  7. package/dist/commands/hooks.d.ts +0 -19
  8. package/dist/commands/hooks.js +0 -131
  9. package/dist/commands/install.d.ts +0 -2
  10. package/dist/commands/install.js +0 -649
  11. package/dist/commands/load-context.d.ts +0 -2
  12. package/dist/commands/load-context.js +0 -108
  13. package/dist/commands/logs.d.ts +0 -2
  14. package/dist/commands/logs.js +0 -76
  15. package/dist/commands/migrate-to-jsonl.d.ts +0 -5
  16. package/dist/commands/migrate-to-jsonl.js +0 -99
  17. package/dist/commands/status.d.ts +0 -1
  18. package/dist/commands/status.js +0 -136
  19. package/dist/commands/uninstall.d.ts +0 -2
  20. package/dist/commands/uninstall.js +0 -107
  21. package/dist/constants.d.ts +0 -271
  22. package/dist/constants.js +0 -199
  23. package/dist/core/compression/TranscriptCompressor.d.ts +0 -83
  24. package/dist/core/compression/TranscriptCompressor.js +0 -602
  25. package/dist/core/orchestration/PromptOrchestrator.d.ts +0 -165
  26. package/dist/core/orchestration/PromptOrchestrator.js +0 -182
  27. package/dist/lib/time-utils.d.ts +0 -5
  28. package/dist/lib/time-utils.js +0 -70
  29. package/dist/prompts/constants.d.ts +0 -126
  30. package/dist/prompts/constants.js +0 -161
  31. package/dist/prompts/index.d.ts +0 -10
  32. package/dist/prompts/index.js +0 -11
  33. package/dist/prompts/templates/analysis/AnalysisTemplates.d.ts +0 -13
  34. package/dist/prompts/templates/analysis/AnalysisTemplates.js +0 -94
  35. package/dist/prompts/templates/context/ContextTemplates.d.ts +0 -119
  36. package/dist/prompts/templates/context/ContextTemplates.js +0 -399
  37. package/dist/prompts/templates/hooks/HookTemplates.d.ts +0 -175
  38. package/dist/prompts/templates/hooks/HookTemplates.js +0 -394
  39. package/dist/prompts/templates/hooks/HookTemplates.test.d.ts +0 -7
  40. package/dist/prompts/templates/hooks/HookTemplates.test.js +0 -127
  41. package/dist/shared/config.d.ts +0 -4
  42. package/dist/shared/config.js +0 -41
  43. package/dist/shared/error-handler.d.ts +0 -22
  44. package/dist/shared/error-handler.js +0 -142
  45. package/dist/shared/logger.d.ts +0 -19
  46. package/dist/shared/logger.js +0 -51
  47. package/dist/shared/paths.d.ts +0 -28
  48. package/dist/shared/paths.js +0 -100
  49. package/dist/shared/types.d.ts +0 -141
  50. package/dist/shared/types.js +0 -78
package/claude-mem CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-mem",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "description": "Memory compression system for Claude Code - persist context across sessions",
5
5
  "keywords": [
6
6
  "claude",
@@ -32,7 +32,6 @@
32
32
  "files": [
33
33
  "claude-mem",
34
34
  "hooks",
35
- "dist",
36
35
  ".mcp.json"
37
36
  ]
38
37
  }
package/dist/bin/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
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,2 +0,0 @@
1
- import { OptionValues } from 'commander';
2
- export declare function compress(transcript?: string, options?: OptionValues): Promise<void>;
@@ -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
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * Hook command handlers for binary distribution
3
- * These execute the actual hook logic embedded in the binary
4
- */
5
- /**
6
- * Pre-compact hook handler
7
- * Runs compression on the Claude Code transcript
8
- */
9
- export declare function preCompactHook(): Promise<void>;
10
- /**
11
- * Session-start hook handler
12
- * Loads context for the new session
13
- */
14
- export declare function sessionStartHook(): Promise<void>;
15
- /**
16
- * Session-end hook handler
17
- * Compresses session transcript when ending with /clear
18
- */
19
- export declare function sessionEndHook(): Promise<void>;
@@ -1,131 +0,0 @@
1
- /**
2
- * Hook command handlers for binary distribution
3
- * These execute the actual hook logic embedded in the binary
4
- */
5
- import { compress } from './compress.js';
6
- import { loadContext } from './load-context.js';
7
- /**
8
- * Pre-compact hook handler
9
- * Runs compression on the Claude Code transcript
10
- */
11
- export async function preCompactHook() {
12
- try {
13
- // Read hook data from stdin (Claude Code sends JSON)
14
- let inputData = '';
15
- // Set up stdin to read data
16
- process.stdin.setEncoding('utf8');
17
- // Collect all input data
18
- for await (const chunk of process.stdin) {
19
- inputData += chunk;
20
- }
21
- // Parse the JSON input
22
- let transcriptPath;
23
- if (inputData) {
24
- try {
25
- const hookData = JSON.parse(inputData);
26
- transcriptPath = hookData.transcript_path;
27
- }
28
- catch (parseError) {
29
- // If JSON parsing fails, treat the input as a direct path
30
- transcriptPath = inputData.trim();
31
- }
32
- }
33
- // Fallback to environment variable or command line argument
34
- if (!transcriptPath) {
35
- transcriptPath = process.env.TRANSCRIPT_PATH || process.argv[2];
36
- }
37
- if (!transcriptPath) {
38
- console.log('🗜️ Compressing session transcript...');
39
- console.log('❌ No transcript path provided to pre-compact hook');
40
- console.log('Hook data received:', inputData || 'none');
41
- console.log('Environment TRANSCRIPT_PATH:', process.env.TRANSCRIPT_PATH || 'not set');
42
- console.log('Command line args:', process.argv.slice(2));
43
- return;
44
- }
45
- // Run compression with the transcript path
46
- await compress(transcriptPath, { dryRun: false });
47
- }
48
- catch (error) {
49
- console.error('Pre-compact hook failed:', error.message);
50
- process.exit(1);
51
- }
52
- }
53
- /**
54
- * Session-start hook handler
55
- * Loads context for the new session
56
- */
57
- export async function sessionStartHook() {
58
- try {
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 });
90
- }
91
- catch (error) {
92
- console.error('Session-start hook failed:', error.message);
93
- process.exit(1);
94
- }
95
- }
96
- /**
97
- * Session-end hook handler
98
- * Compresses session transcript when ending with /clear
99
- */
100
- export async function sessionEndHook() {
101
- try {
102
- // Read hook data from stdin (Claude Code sends JSON)
103
- let inputData = '';
104
- // Set up stdin to read data
105
- process.stdin.setEncoding('utf8');
106
- // Collect all input data
107
- for await (const chunk of process.stdin) {
108
- inputData += chunk;
109
- }
110
- // Parse the JSON input to check the reason for session end
111
- if (inputData) {
112
- try {
113
- const hookData = JSON.parse(inputData);
114
- // If reason is "clear", compress the session transcript before it's deleted
115
- if (hookData.reason === 'clear' && hookData.transcript_path) {
116
- console.log('🗜️ Compressing current session before /clear...');
117
- await compress(hookData.transcript_path, { dryRun: false });
118
- }
119
- }
120
- catch (parseError) {
121
- // If JSON parsing fails, log but don't fail the hook
122
- console.error('Failed to parse hook data:', parseError);
123
- }
124
- }
125
- console.log('Session ended successfully');
126
- }
127
- catch (error) {
128
- console.error('Session-end hook failed:', error.message);
129
- process.exit(1);
130
- }
131
- }
@@ -1,2 +0,0 @@
1
- import { OptionValues } from 'commander';
2
- export declare function install(options?: OptionValues): Promise<void>;