mem8 1.2.0__py3-none-any.whl

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.
ai_mem/__init__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "1.2.0"
@@ -0,0 +1,109 @@
1
+ """Claude Code integration functionality for AI-Mem."""
2
+
3
+ from pathlib import Path
4
+ from typing import Dict, Any, Optional
5
+
6
+
7
+ def generate_claude_memory_integration(config: Dict[str, Any]) -> str:
8
+ """Generate CLAUDE.md content for AI-Mem integration."""
9
+ repos_config = ""
10
+ if config.get('repositories'):
11
+ repos_config = "\n".join([
12
+ f"- {repo['name']}: {repo.get('thoughts_paths', ['No thoughts found'])[0] if repo.get('thoughts_paths') else 'No thoughts found'}"
13
+ for repo in config.get('repositories', [])
14
+ ])
15
+ else:
16
+ repos_config = "- No repositories discovered (run ai-mem quick-start to discover)"
17
+
18
+ claude_md_content = f"""
19
+ # AI Memory Integration
20
+
21
+ This project uses AI-Mem for memory management across repositories.
22
+
23
+ ## Available Repositories
24
+ {repos_config}
25
+
26
+ ## Memory Commands
27
+ - `/setup-memory` - Configure AI memory for this project
28
+ - `/browse-memories` - Search and explore thoughts across repositories
29
+ - `ai-mem search "query"` - Full-text search across all memories
30
+ - `ai-mem quick-start --web` - Launch visual memory browser
31
+ - `ai-mem dashboard` - Open web interface
32
+
33
+ ## Shared Thoughts Location
34
+ Shared thoughts: `{config.get('shared_location', 'thoughts/shared/')}`
35
+
36
+ ## Workflow Integration
37
+ - Research documents: `thoughts/shared/research/`
38
+ - Implementation plans: `thoughts/shared/plans/`
39
+ - PR discussions: `thoughts/shared/prs/`
40
+ - User notes: `thoughts/{config.get('username', 'user')}/`
41
+
42
+ ## Quick Start
43
+ Run `ai-mem quick-start --web` to set up AI-Mem and launch the visual interface.
44
+ """
45
+ return claude_md_content
46
+
47
+
48
+ def update_claude_md_integration(config: Dict[str, Any]) -> bool:
49
+ """Add AI-Mem integration section to existing CLAUDE.md."""
50
+ claude_md_path = Path('.claude/CLAUDE.md')
51
+ project_claude_md = Path('CLAUDE.md')
52
+
53
+ # Try both locations
54
+ target_file = None
55
+ if claude_md_path.exists():
56
+ target_file = claude_md_path
57
+ elif project_claude_md.exists():
58
+ target_file = project_claude_md
59
+
60
+ if target_file:
61
+ try:
62
+ content = target_file.read_text(encoding='utf-8')
63
+ if 'AI Memory Integration' not in content:
64
+ integration = generate_claude_memory_integration(config)
65
+ content += f"\n{integration}"
66
+ target_file.write_text(content, encoding='utf-8')
67
+ return True
68
+ except (OSError, UnicodeDecodeError):
69
+ return False
70
+
71
+ return False
72
+
73
+
74
+ def create_minimal_claude_md(config: Dict[str, Any]) -> bool:
75
+ """Create a minimal CLAUDE.md file with AI-Mem integration."""
76
+ claude_md = Path('CLAUDE.md')
77
+
78
+ if not claude_md.exists():
79
+ integration = generate_claude_memory_integration(config)
80
+ minimal_content = f"""# Project Memory
81
+
82
+ This project uses AI-Mem for intelligent memory management and team collaboration.
83
+ {integration}
84
+ """
85
+ try:
86
+ claude_md.write_text(minimal_content, encoding='utf-8')
87
+ return True
88
+ except OSError:
89
+ return False
90
+
91
+ return False
92
+
93
+
94
+ def setup_claude_code_integration(config: Dict[str, Any]) -> Dict[str, Any]:
95
+ """Set up Claude Code integration for AI-Mem."""
96
+ results = {'updated': [], 'created': [], 'errors': []}
97
+
98
+ # Try to update existing CLAUDE.md
99
+ if update_claude_md_integration(config):
100
+ if Path('.claude/CLAUDE.md').exists():
101
+ results['updated'].append('.claude/CLAUDE.md')
102
+ elif Path('CLAUDE.md').exists():
103
+ results['updated'].append('CLAUDE.md')
104
+
105
+ # If no CLAUDE.md exists and this isn't a Claude Code project, create one
106
+ elif not Path('.claude').exists() and create_minimal_claude_md(config):
107
+ results['created'].append('CLAUDE.md')
108
+
109
+ return results