claude-mem 3.1.7 → 3.2.0

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 (47) hide show
  1. package/claude-mem +0 -0
  2. package/dist/bin/cli.d.ts +2 -0
  3. package/dist/bin/cli.js +129 -0
  4. package/dist/commands/compress.d.ts +2 -0
  5. package/dist/commands/compress.js +27 -0
  6. package/dist/commands/install.d.ts +2 -0
  7. package/dist/commands/install.js +649 -0
  8. package/dist/commands/load-context.js +52 -54
  9. package/dist/commands/logs.d.ts +2 -0
  10. package/dist/commands/logs.js +76 -0
  11. package/dist/commands/migrate-to-jsonl.d.ts +5 -0
  12. package/dist/commands/migrate-to-jsonl.js +99 -0
  13. package/dist/commands/status.d.ts +1 -0
  14. package/dist/commands/status.js +136 -0
  15. package/dist/commands/uninstall.d.ts +2 -0
  16. package/dist/commands/uninstall.js +107 -0
  17. package/dist/constants.d.ts +271 -0
  18. package/dist/constants.js +199 -0
  19. package/dist/core/compression/TranscriptCompressor.d.ts +83 -0
  20. package/dist/core/compression/TranscriptCompressor.js +602 -0
  21. package/dist/core/orchestration/PromptOrchestrator.d.ts +165 -0
  22. package/dist/core/orchestration/PromptOrchestrator.js +182 -0
  23. package/dist/lib/time-utils.d.ts +5 -0
  24. package/dist/lib/time-utils.js +70 -0
  25. package/dist/prompts/constants.d.ts +126 -0
  26. package/dist/prompts/constants.js +161 -0
  27. package/dist/prompts/index.d.ts +10 -0
  28. package/dist/prompts/index.js +11 -0
  29. package/dist/prompts/templates/analysis/AnalysisTemplates.d.ts +13 -0
  30. package/dist/prompts/templates/analysis/AnalysisTemplates.js +94 -0
  31. package/dist/prompts/templates/context/ContextTemplates.d.ts +119 -0
  32. package/dist/prompts/templates/context/ContextTemplates.js +399 -0
  33. package/dist/prompts/templates/hooks/HookTemplates.d.ts +175 -0
  34. package/dist/prompts/templates/hooks/HookTemplates.js +394 -0
  35. package/dist/prompts/templates/hooks/HookTemplates.test.d.ts +7 -0
  36. package/dist/prompts/templates/hooks/HookTemplates.test.js +127 -0
  37. package/dist/shared/config.d.ts +4 -0
  38. package/dist/shared/config.js +41 -0
  39. package/dist/shared/error-handler.d.ts +22 -0
  40. package/dist/shared/error-handler.js +142 -0
  41. package/dist/shared/logger.d.ts +19 -0
  42. package/dist/shared/logger.js +51 -0
  43. package/dist/shared/paths.d.ts +28 -0
  44. package/dist/shared/paths.js +100 -0
  45. package/dist/shared/types.d.ts +141 -0
  46. package/dist/shared/types.js +78 -0
  47. package/package.json +1 -1
package/claude-mem CHANGED
Binary file
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,129 @@
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> =======================================
@@ -0,0 +1,2 @@
1
+ import { OptionValues } from 'commander';
2
+ export declare function compress(transcript?: string, options?: OptionValues): Promise<void>;
@@ -0,0 +1,27 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ import { OptionValues } from 'commander';
2
+ export declare function install(options?: OptionValues): Promise<void>;