claude-mem 3.2.0 → 3.2.1

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
@@ -1,161 +0,0 @@
1
- /**
2
- * Claude Memory System - Prompt-Related Constants and Templates
3
- *
4
- * This file contains all prompts, instructions, and output templates
5
- * for the analysis and context priming system.
6
- */
7
- import * as HookTemplates from './templates/hooks/HookTemplates.js';
8
- // =============================================================================
9
- // ANALYSIS PROMPTS AND TEMPLATES
10
- // =============================================================================
11
- /**
12
- * Entity naming patterns for the knowledge graph
13
- */
14
- export const ENTITY_NAMING_PATTERNS = {
15
- component: "Component_Name",
16
- decision: "Decision_Name",
17
- pattern: "Pattern_Name",
18
- tool: "Tool_Name",
19
- fix: "Fix_Name",
20
- workflow: "Workflow_Name"
21
- };
22
- /**
23
- * Available entity types for classification
24
- */
25
- export const ENTITY_TYPES = {
26
- component: "component", // UI components, modules, services
27
- pattern: "pattern", // Architectural or design patterns
28
- workflow: "workflow", // Processes, pipelines, sequences
29
- integration: "integration", // APIs, external services, data sources
30
- concept: "concept", // Abstract ideas, methodologies, principles
31
- decision: "decision", // Design choices, trade-offs, solutions
32
- tool: "tool", // Utilities, libraries, development tools
33
- fix: "fix" // Bug fixes, patches, workarounds
34
- };
35
- /**
36
- * Standard observation fields for entities
37
- */
38
- export const OBSERVATION_FIELDS = [
39
- "Core purpose: [what it fundamentally does]",
40
- "Brief description: [one-line summary for session-start display]",
41
- "Implementation: [key technical details, code patterns]",
42
- "Dependencies: [what it requires or builds upon]",
43
- "Usage context: [when/why it's used]",
44
- "Performance characteristics: [speed, reliability, constraints]",
45
- "Integration points: [how it connects to other systems]",
46
- "Keywords: [searchable terms for this concept]",
47
- "Decision rationale: [why this approach was chosen]",
48
- "Next steps: [what needs to be done next with this component]",
49
- "Files modified: [list of files changed]",
50
- "Tools used: [development tools/commands used]"
51
- ];
52
- /**
53
- * Relationship types for creating meaningful entity connections
54
- */
55
- export const RELATIONSHIP_TYPES = [
56
- "executes_via", "orchestrates_through", "validates_using",
57
- "provides_auth_to", "manages_state_for", "processes_events_from",
58
- "caches_data_from", "routes_requests_to", "transforms_data_for",
59
- "extends", "enhances_performance_of", "builds_upon",
60
- "fixes_issue_in", "replaces", "optimizes",
61
- "triggers_tool", "receives_result_from"
62
- ];
63
- // =============================================================================
64
- // CONTEXT PRIMING TEMPLATES
65
- // =============================================================================
66
- /**
67
- * System message templates for context priming
68
- */
69
- export const CONTEXT_TEMPLATES = {
70
- PRIMARY_CONTEXT: (projectName) => `Context primed for project: ${projectName}. Access memories with chroma_query_documents(["${projectName}*"]) or chroma_get_documents(["document_id"]).`,
71
- RECENT_SESSIONS: (sessionList) => `Recent sessions available: ${sessionList}`,
72
- AVAILABLE_ENTITIES: (type, entities, hasMore, moreCount) => `Available ${type} entities: ${entities.join(', ')}${hasMore ? ` (+${moreCount} more)` : ''}`,
73
- SESSION_START_HEADER: '🧠 Active Working Context from Previous Sessions:',
74
- SESSION_START_SEPARATOR: '═'.repeat(70),
75
- RESUME_INSTRUCTIONS: `💡 TO RESUME: Load active components with chroma_get_documents(["<exact_document_ids>"])
76
- 📊 TO EXPLORE: Search related work with chroma_query_documents(["<keywords>"])`
77
- };
78
- // =============================================================================
79
- // SESSION START OUTPUT TEMPLATES
80
- // =============================================================================
81
- /**
82
- * Session start formatting templates
83
- */
84
- export const SESSION_START_TEMPLATES = {
85
- FOCUS_LINE: (focus) => `📌 CURRENT FOCUS: ${focus}`,
86
- LAST_WORKED: (timeAgo, projectName) => `Last worked: ${timeAgo} | Project: ${projectName}`,
87
- SECTIONS: {
88
- COMPONENTS: '🎯 ACTIVE COMPONENTS (load these for context):',
89
- DECISIONS: '🔄 RECENT DECISIONS & PATTERNS:',
90
- TOOLS: '🛠️ TOOLS & INFRASTRUCTURE:',
91
- FIXES: '🐛 RECENT FIXES:',
92
- ACTIONS: '⚡ NEXT ACTIONS:'
93
- },
94
- ACTION_PREFIX: '□ ',
95
- ENTITY_BULLET: '• '
96
- };
97
- /**
98
- * Time formatting for "time ago" displays
99
- */
100
- export const TIME_FORMATS = {
101
- JUST_NOW: 'just now',
102
- HOURS_AGO: (hours) => `${hours} hour${hours > 1 ? 's' : ''} ago`,
103
- DAYS_AGO: (days) => `${days} day${days > 1 ? 's' : ''} ago`,
104
- RECENTLY: 'recently'
105
- };
106
- // =============================================================================
107
- // HOOK RESPONSE TEMPLATES
108
- // =============================================================================
109
- /**
110
- * Standard hook response structures for Claude Code integration
111
- */
112
- export const HOOK_RESPONSES = {
113
- SUCCESS: (hookEventName, message) => ({
114
- hookSpecificOutput: {
115
- hookEventName,
116
- status: "success",
117
- message
118
- },
119
- suppressOutput: true
120
- }),
121
- SKIPPED: (hookEventName, message) => ({
122
- hookSpecificOutput: {
123
- hookEventName,
124
- status: "skipped",
125
- message
126
- },
127
- suppressOutput: true
128
- }),
129
- BLOCKED: (reason) => ({
130
- decision: "block",
131
- reason
132
- }),
133
- CONTINUE: (hookEventName, additionalContext) => ({
134
- continue: true,
135
- ...(additionalContext && {
136
- hookSpecificOutput: {
137
- hookEventName,
138
- additionalContext
139
- }
140
- })
141
- }),
142
- ERROR: (reason) => ({
143
- decision: "block",
144
- reason
145
- })
146
- };
147
- /**
148
- * Pre-defined hook messages
149
- */
150
- export const HOOK_MESSAGES = {
151
- COMPRESSION_SUCCESS: "Memory compression completed successfully",
152
- COMPRESSION_FAILED: (stderr) => `Compression failed: ${stderr}`,
153
- CONTEXT_LOADED: "Project context loaded successfully",
154
- CONTEXT_SKIPPED: "Continuing session - context loading skipped",
155
- NO_TRANSCRIPT: "No transcript path provided",
156
- HOOK_ERROR: (error) => `Hook error: ${error}`
157
- };
158
- /**
159
- * Export hook templates for direct usage
160
- */
161
- export { HookTemplates };
@@ -1,10 +0,0 @@
1
- /**
2
- * Prompts Module - Single source of truth for all prompt generation
3
- *
4
- * This module provides a centralized system for generating prompts across
5
- * the claude-mem system. It includes the core PromptOrchestrator class
6
- * and all related TypeScript interfaces.
7
- */
8
- export type { AnalysisContext, SessionContext, HookContext, AnalysisPrompt, SessionPrompt, HookResponse, } from '../core/orchestration/PromptOrchestrator.js';
9
- export { PromptOrchestrator, } from '../core/orchestration/PromptOrchestrator.js';
10
- export { createPromptOrchestrator, createAnalysisContext, createSessionContext, createHookContext, } from '../core/orchestration/PromptOrchestrator.js';
@@ -1,11 +0,0 @@
1
- /**
2
- * Prompts Module - Single source of truth for all prompt generation
3
- *
4
- * This module provides a centralized system for generating prompts across
5
- * the claude-mem system. It includes the core PromptOrchestrator class
6
- * and all related TypeScript interfaces.
7
- */
8
- // Export the main class
9
- export { PromptOrchestrator, } from '../core/orchestration/PromptOrchestrator.js';
10
- // Export factory functions
11
- export { createPromptOrchestrator, createAnalysisContext, createSessionContext, createHookContext, } from '../core/orchestration/PromptOrchestrator.js';
@@ -1,13 +0,0 @@
1
- /**
2
- * Analysis Templates for LLM Instructions
3
- *
4
- * Generates prompts for extracting memories from conversations and storing in Chroma
5
- */
6
- /**
7
- * Creates the comprehensive analysis prompt for memory extraction
8
- */
9
- export declare function buildComprehensiveAnalysisPrompt(projectPrefix: string, sessionId: string, timestamp?: string, archiveFilename?: string): string;
10
- /**
11
- * Creates the analysis prompt
12
- */
13
- export declare function createAnalysisPrompt(transcript: string, sessionId: string, projectPrefix: string, timestamp?: string): string;
@@ -1,94 +0,0 @@
1
- /**
2
- * Analysis Templates for LLM Instructions
3
- *
4
- * Generates prompts for extracting memories from conversations and storing in Chroma
5
- */
6
- import Handlebars from 'handlebars';
7
- // =============================================================================
8
- // MAIN ANALYSIS PROMPT TEMPLATE
9
- // =============================================================================
10
- const ANALYSIS_PROMPT = `You are analyzing a Claude Code conversation transcript to create memories using the Chroma MCP memory system.
11
-
12
- YOUR TASK:
13
- 1. Extract key learnings and accomplishments as natural language memories
14
- 2. Store memories using mcp__claude-mem__chroma_add_documents
15
- 3. Return a structured JSON response with the extracted summaries
16
-
17
- WHAT TO EXTRACT:
18
- - Technical implementations (functions, classes, APIs, databases)
19
- - Design patterns and architectural decisions
20
- - Bug fixes and problem solutions
21
- - Workflows, processes, and integrations
22
- - Performance optimizations and improvements
23
-
24
- STORAGE INSTRUCTIONS:
25
- Call mcp__claude-mem__chroma_add_documents with:
26
- - collection_name: "claude_memories"
27
- - documents: Array of natural language descriptions
28
- - ids: ["{{projectPrefix}}_{{sessionId}}_1", "{{projectPrefix}}_{{sessionId}}_2", ...]
29
- - metadatas: Array with fields:
30
- * type: component/pattern/workflow/integration/concept/decision/tool/fix
31
- * keywords: Comma-separated search terms
32
- * context: Brief situation description
33
- * timestamp: "{{timestamp}}"
34
- * session_id: "{{sessionId}}"
35
-
36
- ERROR HANDLING:
37
- If you get "IDs already exist" errors, use mcp__claude-mem__chroma_update_documents instead.
38
- If any tool calls fail, continue and return the JSON response anyway.
39
-
40
- Project: {{projectPrefix}}
41
- Session ID: {{sessionId}}
42
-
43
- Conversation to compress:`;
44
- // Compile template once
45
- const compiledAnalysisPrompt = Handlebars.compile(ANALYSIS_PROMPT, { noEscape: true });
46
- // =============================================================================
47
- // MAIN API FUNCTIONS
48
- // =============================================================================
49
- /**
50
- * Creates the comprehensive analysis prompt for memory extraction
51
- */
52
- export function buildComprehensiveAnalysisPrompt(projectPrefix, sessionId, timestamp, archiveFilename) {
53
- const context = {
54
- projectPrefix,
55
- sessionId,
56
- timestamp: timestamp || new Date().toISOString(),
57
- archiveFilename: archiveFilename || `${sessionId}.jsonl.archive`
58
- };
59
- return compiledAnalysisPrompt(context);
60
- }
61
- /**
62
- * Creates the analysis prompt
63
- */
64
- export function createAnalysisPrompt(transcript, sessionId, projectPrefix, timestamp) {
65
- const prompt = buildComprehensiveAnalysisPrompt(projectPrefix, sessionId, timestamp);
66
- const responseFormat = `
67
-
68
- RESPONSE FORMAT:
69
- After storing memories in Chroma, return EXACTLY this JSON structure wrapped in tags:
70
-
71
- <JSONResponse>
72
- {
73
- "overview": "2-3 sentence summary of session themes and accomplishments. Write for any developer to understand by organically defining jargon.",
74
- "summaries": [
75
- {
76
- "text": "What was accomplished (start with action verb)",
77
- "document_id": "${projectPrefix}_${sessionId}_1",
78
- "keywords": "comma, separated, terms",
79
- "timestamp": "${timestamp || new Date().toISOString()}",
80
- "archive": "${sessionId}.jsonl.archive"
81
- }
82
- ]
83
- }
84
- </JSONResponse>
85
-
86
- IMPORTANT:
87
- - Return 3-10 summaries based on conversation complexity
88
- - Each summary should correspond to a memory you attempted to store
89
- - If tool calls fail, still return the JSON response with summaries
90
- - The JSON must be valid and complete
91
- - Place NOTHING outside the <JSONResponse> tags
92
- - Do not include any explanatory text before or after the JSON`;
93
- return prompt + '\n\n' + transcript + responseFormat;
94
- }
@@ -1,119 +0,0 @@
1
- /**
2
- * Context Templates for Human-Readable Formatting
3
- *
4
- * Essential templates for user-facing messages in the memory system.
5
- * Focused on session start messages, error handling, and operation feedback.
6
- * Now uses Handlebars templating for proper separation of data and presentation.
7
- */
8
- /**
9
- * Creates a welcoming session start message explaining what memories were loaded
10
- */
11
- export declare function createSessionStartMessage(projectName: string, memoryCount: number, lastSessionTime?: string): string;
12
- /**
13
- * Creates a loading message during context retrieval
14
- */
15
- export declare function createLoadingMessage(operation: string): string;
16
- /**
17
- * Creates a completion message after context operations
18
- */
19
- export declare function createCompletionMessage(operation: string, count?: number, details?: string): string;
20
- /**
21
- * Creates user-friendly error messages with helpful suggestions
22
- */
23
- export declare function createUserFriendlyError(operation: string, error: string, suggestion?: string): string;
24
- /**
25
- * Common error scenarios with built-in suggestions
26
- */
27
- export declare const ERROR_SCENARIOS: {
28
- NO_MEMORIES: (projectName: string) => {
29
- message: string;
30
- suggestion: string;
31
- };
32
- CONNECTION_FAILED: () => {
33
- message: string;
34
- suggestion: string;
35
- };
36
- SEARCH_FAILED: (query: string) => {
37
- message: string;
38
- suggestion: string;
39
- };
40
- LOAD_TIMEOUT: () => {
41
- message: string;
42
- suggestion: string;
43
- };
44
- };
45
- /**
46
- * Creates contextual error messages based on common scenarios
47
- */
48
- export declare function createContextualError(scenario: keyof typeof ERROR_SCENARIOS, ...args: string[]): string;
49
- /**
50
- * Formats timestamps into human-readable "time ago" format
51
- */
52
- export declare function formatTimeAgo(timestamp: string | Date): string;
53
- /**
54
- * Creates summary text for memory operations
55
- */
56
- export declare function createOperationSummary(operation: 'compress' | 'load' | 'search' | 'archive', results: {
57
- count: number;
58
- duration?: number;
59
- details?: string;
60
- }): string;
61
- /**
62
- * Interface for memory entry data structure
63
- */
64
- interface MemoryEntry {
65
- summary: string;
66
- keywords?: string;
67
- location?: string;
68
- sessionId?: string;
69
- number?: number;
70
- }
71
- /**
72
- * Formats current date and time for session start
73
- */
74
- export declare function formatCurrentDateTime(): string;
75
- /**
76
- * Extracts overview section from JSON objects
77
- * Looks for objects with type "overview" and matching project
78
- */
79
- export declare function extractOverview(recentObjects: any[], projectName?: string): string | null;
80
- /**
81
- * Interface for overview with timestamp
82
- */
83
- interface OverviewEntry {
84
- content: string;
85
- timestamp?: Date;
86
- timeAgo?: string;
87
- }
88
- /**
89
- * Extracts multiple overviews with timestamps
90
- * Returns up to 'count' most recent overviews
91
- */
92
- export declare function extractOverviews(recentObjects: any[], count?: number, projectName?: string): OverviewEntry[];
93
- /**
94
- * Pure data processing function - converts JSON objects into structured memory entries
95
- * No formatting is done here, only data parsing and cleaning
96
- */
97
- export declare function processMemoryEntries(recentObjects: any[]): MemoryEntry[];
98
- /**
99
- * Renders the complete session start template with provided data using Handlebars
100
- * Data processing is separated from presentation - template controls the format
101
- */
102
- export declare function renderSessionStartTemplate(params: {
103
- projectName: string;
104
- memoryCount: number;
105
- lastSessionTime?: string;
106
- recentObjects: any[];
107
- }): string;
108
- /**
109
- * Outputs session start content using dual streams:
110
- * - stdout (console.log) -> Claude's context only (granular memories)
111
- * - stderr (console.error) -> User visible (clean overviews)
112
- */
113
- export declare function outputSessionStartContent(params: {
114
- projectName: string;
115
- memoryCount: number;
116
- lastSessionTime?: string;
117
- recentObjects: any[];
118
- }): void;
119
- export {};