superlocalmemory 2.3.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 (100) hide show
  1. package/ATTRIBUTION.md +140 -0
  2. package/CHANGELOG.md +1749 -0
  3. package/LICENSE +21 -0
  4. package/README.md +600 -0
  5. package/bin/aider-smart +72 -0
  6. package/bin/slm +202 -0
  7. package/bin/slm-npm +73 -0
  8. package/bin/slm.bat +195 -0
  9. package/bin/slm.cmd +10 -0
  10. package/bin/superlocalmemoryv2:list +3 -0
  11. package/bin/superlocalmemoryv2:profile +3 -0
  12. package/bin/superlocalmemoryv2:recall +3 -0
  13. package/bin/superlocalmemoryv2:remember +3 -0
  14. package/bin/superlocalmemoryv2:reset +3 -0
  15. package/bin/superlocalmemoryv2:status +3 -0
  16. package/completions/slm.bash +58 -0
  17. package/completions/slm.zsh +76 -0
  18. package/configs/antigravity-mcp.json +13 -0
  19. package/configs/chatgpt-desktop-mcp.json +7 -0
  20. package/configs/claude-desktop-mcp.json +15 -0
  21. package/configs/codex-mcp.toml +13 -0
  22. package/configs/cody-commands.json +29 -0
  23. package/configs/continue-mcp.yaml +14 -0
  24. package/configs/continue-skills.yaml +26 -0
  25. package/configs/cursor-mcp.json +15 -0
  26. package/configs/gemini-cli-mcp.json +11 -0
  27. package/configs/jetbrains-mcp.json +11 -0
  28. package/configs/opencode-mcp.json +12 -0
  29. package/configs/perplexity-mcp.json +9 -0
  30. package/configs/vscode-copilot-mcp.json +12 -0
  31. package/configs/windsurf-mcp.json +16 -0
  32. package/configs/zed-mcp.json +12 -0
  33. package/docs/ARCHITECTURE.md +877 -0
  34. package/docs/CLI-COMMANDS-REFERENCE.md +425 -0
  35. package/docs/COMPETITIVE-ANALYSIS.md +210 -0
  36. package/docs/COMPRESSION-README.md +390 -0
  37. package/docs/GRAPH-ENGINE.md +503 -0
  38. package/docs/MCP-MANUAL-SETUP.md +720 -0
  39. package/docs/MCP-TROUBLESHOOTING.md +787 -0
  40. package/docs/PATTERN-LEARNING.md +363 -0
  41. package/docs/PROFILES-GUIDE.md +453 -0
  42. package/docs/RESET-GUIDE.md +353 -0
  43. package/docs/SEARCH-ENGINE-V2.2.0.md +748 -0
  44. package/docs/SEARCH-INTEGRATION-GUIDE.md +502 -0
  45. package/docs/UI-SERVER.md +254 -0
  46. package/docs/UNIVERSAL-INTEGRATION.md +432 -0
  47. package/docs/V2.2.0-OPTIONAL-SEARCH.md +666 -0
  48. package/docs/WINDOWS-INSTALL-README.txt +34 -0
  49. package/docs/WINDOWS-POST-INSTALL.txt +45 -0
  50. package/docs/example_graph_usage.py +148 -0
  51. package/hooks/memory-list-skill.js +130 -0
  52. package/hooks/memory-profile-skill.js +284 -0
  53. package/hooks/memory-recall-skill.js +109 -0
  54. package/hooks/memory-remember-skill.js +127 -0
  55. package/hooks/memory-reset-skill.js +274 -0
  56. package/install-skills.sh +436 -0
  57. package/install.ps1 +417 -0
  58. package/install.sh +755 -0
  59. package/mcp_server.py +585 -0
  60. package/package.json +94 -0
  61. package/requirements-core.txt +24 -0
  62. package/requirements.txt +10 -0
  63. package/scripts/postinstall.js +126 -0
  64. package/scripts/preuninstall.js +57 -0
  65. package/skills/slm-build-graph/SKILL.md +423 -0
  66. package/skills/slm-list-recent/SKILL.md +348 -0
  67. package/skills/slm-recall/SKILL.md +325 -0
  68. package/skills/slm-remember/SKILL.md +194 -0
  69. package/skills/slm-status/SKILL.md +363 -0
  70. package/skills/slm-switch-profile/SKILL.md +442 -0
  71. package/src/__pycache__/cache_manager.cpython-312.pyc +0 -0
  72. package/src/__pycache__/embedding_engine.cpython-312.pyc +0 -0
  73. package/src/__pycache__/graph_engine.cpython-312.pyc +0 -0
  74. package/src/__pycache__/hnsw_index.cpython-312.pyc +0 -0
  75. package/src/__pycache__/hybrid_search.cpython-312.pyc +0 -0
  76. package/src/__pycache__/memory-profiles.cpython-312.pyc +0 -0
  77. package/src/__pycache__/memory-reset.cpython-312.pyc +0 -0
  78. package/src/__pycache__/memory_compression.cpython-312.pyc +0 -0
  79. package/src/__pycache__/memory_store_v2.cpython-312.pyc +0 -0
  80. package/src/__pycache__/migrate_v1_to_v2.cpython-312.pyc +0 -0
  81. package/src/__pycache__/pattern_learner.cpython-312.pyc +0 -0
  82. package/src/__pycache__/query_optimizer.cpython-312.pyc +0 -0
  83. package/src/__pycache__/search_engine_v2.cpython-312.pyc +0 -0
  84. package/src/__pycache__/setup_validator.cpython-312.pyc +0 -0
  85. package/src/__pycache__/tree_manager.cpython-312.pyc +0 -0
  86. package/src/cache_manager.py +520 -0
  87. package/src/embedding_engine.py +671 -0
  88. package/src/graph_engine.py +970 -0
  89. package/src/hnsw_index.py +626 -0
  90. package/src/hybrid_search.py +693 -0
  91. package/src/memory-profiles.py +518 -0
  92. package/src/memory-reset.py +485 -0
  93. package/src/memory_compression.py +999 -0
  94. package/src/memory_store_v2.py +1088 -0
  95. package/src/migrate_v1_to_v2.py +638 -0
  96. package/src/pattern_learner.py +898 -0
  97. package/src/query_optimizer.py +513 -0
  98. package/src/search_engine_v2.py +403 -0
  99. package/src/setup_validator.py +479 -0
  100. package/src/tree_manager.py +720 -0
package/install.sh ADDED
@@ -0,0 +1,755 @@
1
+ #!/bin/bash
2
+ # ============================================================================
3
+ # SuperLocalMemory V2 Installation Script
4
+ # Copyright (c) 2026 Varun Pratap Bhardwaj
5
+ # Licensed under MIT License
6
+ # Repository: https://github.com/varun369/SuperLocalMemoryV2
7
+ # ============================================================================
8
+
9
+ set -e
10
+
11
+ INSTALL_DIR="${HOME}/.claude-memory"
12
+ REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
13
+
14
+ # Parse command line arguments
15
+ NON_INTERACTIVE=false
16
+
17
+ # Auto-detect non-interactive environment (Docker, CI/CD, pipes)
18
+ if [ ! -t 0 ] || [ ! -t 1 ]; then
19
+ NON_INTERACTIVE=true
20
+ fi
21
+
22
+ for arg in "$@"; do
23
+ case $arg in
24
+ --non-interactive|--auto|--yes|-y)
25
+ NON_INTERACTIVE=true
26
+ shift
27
+ ;;
28
+ --help|-h)
29
+ echo "Usage: $0 [OPTIONS]"
30
+ echo ""
31
+ echo "Options:"
32
+ echo " --non-interactive, --auto, --yes, -y"
33
+ echo " Skip interactive prompts (for scripts/automation)"
34
+ echo " --help, -h Show this help message"
35
+ echo ""
36
+ echo "Note: Non-interactive mode is auto-detected when running in"
37
+ echo " Docker, CI/CD, or piped environments."
38
+ echo ""
39
+ exit 0
40
+ ;;
41
+ esac
42
+ done
43
+
44
+ # Print banner
45
+ echo ""
46
+ echo "╔══════════════════════════════════════════════════════════════╗"
47
+ echo "║ SuperLocalMemory V2 - Installation ║"
48
+ echo "║ by Varun Pratap Bhardwaj ║"
49
+ echo "║ https://github.com/varun369/SuperLocalMemoryV2 ║"
50
+ echo "╚══════════════════════════════════════════════════════════════╝"
51
+ echo ""
52
+
53
+ # Show mode if non-interactive
54
+ if [ "$NON_INTERACTIVE" = true ]; then
55
+ echo "🤖 Running in non-interactive mode (auto-detected)"
56
+ echo " Skipping optional prompts, using defaults"
57
+ echo ""
58
+ fi
59
+
60
+ # Check Python version
61
+ echo "Checking Python version..."
62
+ PYTHON_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
63
+ PYTHON_MAJOR=$(python3 -c 'import sys; print(sys.version_info.major)')
64
+ PYTHON_MINOR=$(python3 -c 'import sys; print(sys.version_info.minor)')
65
+
66
+ if [ "$PYTHON_MAJOR" -lt 3 ] || ([ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 8 ]); then
67
+ echo "✗ Error: Python 3.8+ required (found $PYTHON_VERSION)"
68
+ exit 1
69
+ fi
70
+ echo "✓ Python $PYTHON_VERSION"
71
+
72
+ # Create installation directory
73
+ echo ""
74
+ echo "Creating installation directory..."
75
+ mkdir -p "${INSTALL_DIR}"
76
+ echo "✓ Directory: ${INSTALL_DIR}"
77
+
78
+ # Create universal symlink for non-Claude users
79
+ UNIVERSAL_LINK="${HOME}/.superlocalmemory"
80
+ if [ ! -e "${UNIVERSAL_LINK}" ]; then
81
+ ln -s "${INSTALL_DIR}" "${UNIVERSAL_LINK}" 2>/dev/null && \
82
+ echo "✓ Universal link created: ~/.superlocalmemory → ~/.claude-memory" || true
83
+ fi
84
+
85
+ # Copy source files
86
+ echo ""
87
+ echo "Copying source files..."
88
+ cp -r "${REPO_DIR}/src/"* "${INSTALL_DIR}/"
89
+ echo "✓ Source files copied"
90
+
91
+ # Copy hooks
92
+ echo "Copying hooks..."
93
+ mkdir -p "${INSTALL_DIR}/hooks"
94
+ if [ -d "${REPO_DIR}/hooks" ] && [ "$(ls -A ${REPO_DIR}/hooks)" ]; then
95
+ cp -r "${REPO_DIR}/hooks/"* "${INSTALL_DIR}/hooks/"
96
+ echo "✓ Hooks copied"
97
+ else
98
+ echo "○ No hooks to copy"
99
+ fi
100
+
101
+ # Copy CLI wrappers
102
+ echo "Copying CLI wrappers..."
103
+ mkdir -p "${INSTALL_DIR}/bin"
104
+ cp -r "${REPO_DIR}/bin/"* "${INSTALL_DIR}/bin/"
105
+ chmod +x "${INSTALL_DIR}/bin/"*
106
+ echo "✓ CLI wrappers installed"
107
+
108
+ # Copy API server
109
+ if [ -f "${REPO_DIR}/api_server.py" ]; then
110
+ cp "${REPO_DIR}/api_server.py" "${INSTALL_DIR}/"
111
+ echo "✓ API server copied"
112
+ fi
113
+
114
+ # Copy config if not exists
115
+ if [ ! -f "${INSTALL_DIR}/config.json" ]; then
116
+ echo "Creating default config..."
117
+ cp "${REPO_DIR}/config.json" "${INSTALL_DIR}/config.json"
118
+ echo "✓ Config created"
119
+ else
120
+ echo "○ Config exists (keeping existing)"
121
+ fi
122
+
123
+ # Create necessary directories
124
+ echo ""
125
+ echo "Creating directories..."
126
+ mkdir -p "${INSTALL_DIR}/backups"
127
+ mkdir -p "${INSTALL_DIR}/profiles"
128
+ mkdir -p "${INSTALL_DIR}/vectors"
129
+ mkdir -p "${INSTALL_DIR}/cold-storage"
130
+ mkdir -p "${INSTALL_DIR}/jobs"
131
+ echo "✓ Directories created"
132
+
133
+ # Make Python scripts executable
134
+ chmod +x "${INSTALL_DIR}/"*.py 2>/dev/null || true
135
+
136
+ # Initialize database
137
+ echo ""
138
+ echo "Initializing database..."
139
+ if python3 "${INSTALL_DIR}/setup_validator.py" --init > /dev/null 2>&1; then
140
+ echo "✓ Database initialized"
141
+ else
142
+ # Fallback: create basic tables
143
+ python3 -c "
144
+ import sqlite3
145
+ from pathlib import Path
146
+ db_path = Path.home() / '.claude-memory' / 'memory.db'
147
+ conn = sqlite3.connect(db_path)
148
+ cursor = conn.cursor()
149
+ cursor.execute('''CREATE TABLE IF NOT EXISTS memories (
150
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
151
+ content TEXT NOT NULL,
152
+ summary TEXT,
153
+ project_path TEXT,
154
+ project_name TEXT,
155
+ tags TEXT DEFAULT '[]',
156
+ category TEXT,
157
+ parent_id INTEGER,
158
+ tree_path TEXT DEFAULT '/',
159
+ depth INTEGER DEFAULT 0,
160
+ memory_type TEXT DEFAULT 'session',
161
+ importance INTEGER DEFAULT 5,
162
+ content_hash TEXT,
163
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
164
+ last_accessed TIMESTAMP,
165
+ access_count INTEGER DEFAULT 0,
166
+ compressed_at TIMESTAMP,
167
+ tier INTEGER DEFAULT 1,
168
+ cluster_id INTEGER
169
+ )''')
170
+ cursor.execute('CREATE TABLE IF NOT EXISTS graph_nodes (id INTEGER PRIMARY KEY, memory_id INTEGER UNIQUE, entities TEXT DEFAULT \"[]\", embedding_vector BLOB, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)')
171
+ cursor.execute('CREATE TABLE IF NOT EXISTS graph_edges (id INTEGER PRIMARY KEY, source_memory_id INTEGER, target_memory_id INTEGER, similarity REAL, relationship_type TEXT, shared_entities TEXT DEFAULT \"[]\", created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)')
172
+ cursor.execute('CREATE TABLE IF NOT EXISTS graph_clusters (id INTEGER PRIMARY KEY, cluster_name TEXT, description TEXT, memory_count INTEGER DEFAULT 0, avg_importance REAL DEFAULT 5.0, top_entities TEXT DEFAULT \"[]\", created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)')
173
+ cursor.execute('CREATE TABLE IF NOT EXISTS identity_patterns (id INTEGER PRIMARY KEY, pattern_type TEXT, pattern_key TEXT, pattern_value TEXT, confidence REAL DEFAULT 0.0, frequency INTEGER DEFAULT 1, last_seen TIMESTAMP DEFAULT CURRENT_TIMESTAMP, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)')
174
+ cursor.execute('CREATE TABLE IF NOT EXISTS pattern_examples (id INTEGER PRIMARY KEY, pattern_id INTEGER, memory_id INTEGER, context TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)')
175
+ cursor.execute('CREATE TABLE IF NOT EXISTS memory_tree (id INTEGER PRIMARY KEY, node_type TEXT, name TEXT, parent_id INTEGER, tree_path TEXT DEFAULT \"/\", depth INTEGER DEFAULT 0, memory_count INTEGER DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)')
176
+ cursor.execute('CREATE TABLE IF NOT EXISTS memory_archive (id INTEGER PRIMARY KEY, original_memory_id INTEGER, compressed_content TEXT, compression_type TEXT DEFAULT \"tier2\", original_size INTEGER, compressed_size INTEGER, archived_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)')
177
+ cursor.execute('CREATE TABLE IF NOT EXISTS system_metadata (key TEXT PRIMARY KEY, value TEXT NOT NULL)')
178
+ cursor.execute(\"INSERT OR REPLACE INTO system_metadata (key, value) VALUES ('product', 'SuperLocalMemory V2'), ('author', 'Varun Pratap Bhardwaj'), ('repository', 'https://github.com/varun369/SuperLocalMemoryV2'), ('license', 'MIT'), ('schema_version', '2.0.0')\")
179
+ conn.commit()
180
+ conn.close()
181
+ print('Database ready')
182
+ " && echo "✓ Database initialized (fallback)"
183
+ fi
184
+
185
+ # Install core dependencies (required for graph & dashboard)
186
+ echo ""
187
+ echo "Installing core dependencies..."
188
+ echo "⏳ This ensures graph visualization and patterns work out-of-box"
189
+
190
+ # Detect pip installation method
191
+ if pip3 install --help | grep -q "break-system-packages"; then
192
+ PIP_FLAGS="--break-system-packages"
193
+ else
194
+ PIP_FLAGS=""
195
+ fi
196
+
197
+ if [ -f "${REPO_DIR}/requirements-core.txt" ]; then
198
+ if pip3 install $PIP_FLAGS -q -r "${REPO_DIR}/requirements-core.txt"; then
199
+ echo "✓ Core dependencies installed (graph, dashboard, patterns)"
200
+ else
201
+ echo "⚠️ Core dependency installation failed. Some features may not work."
202
+ echo " Install manually: pip3 install -r ${REPO_DIR}/requirements-core.txt"
203
+ fi
204
+ else
205
+ echo "⚠️ requirements-core.txt not found, skipping dependency installation"
206
+ fi
207
+
208
+ # Initialize knowledge graph and pattern learning
209
+ echo ""
210
+ echo "Initializing advanced features..."
211
+
212
+ # Add sample memories if database is empty (for first-time users)
213
+ MEMORY_COUNT=$(python3 -c "
214
+ import sqlite3
215
+ from pathlib import Path
216
+ db_path = Path.home() / '.claude-memory' / 'memory.db'
217
+ conn = sqlite3.connect(db_path)
218
+ cursor = conn.cursor()
219
+ cursor.execute('SELECT COUNT(*) FROM memories')
220
+ print(cursor.fetchone()[0])
221
+ conn.close()
222
+ " 2>/dev/null || echo "0")
223
+
224
+ if [ "$MEMORY_COUNT" -eq 0 ]; then
225
+ echo "○ Adding sample memories for demonstration..."
226
+ python3 "${INSTALL_DIR}/memory_store_v2.py" add "SuperLocalMemory V2 is a local-first, privacy-focused memory system for AI assistants. All data stays on your machine." --tags "supermemory,system,intro" --importance 8 > /dev/null 2>&1 || true
227
+ python3 "${INSTALL_DIR}/memory_store_v2.py" add "Knowledge graph uses TF-IDF for entity extraction and Leiden clustering for community detection." --tags "architecture,graph" --importance 7 > /dev/null 2>&1 || true
228
+ python3 "${INSTALL_DIR}/memory_store_v2.py" add "Pattern learning analyzes your coding preferences, style, and terminology to provide better context." --tags "architecture,patterns" --importance 7 > /dev/null 2>&1 || true
229
+ fi
230
+
231
+ # Build knowledge graph (Layer 3)
232
+ echo "○ Building knowledge graph..."
233
+ if python3 "${INSTALL_DIR}/graph_engine.py" build > /dev/null 2>&1; then
234
+ echo " ✓ Knowledge graph initialized"
235
+ else
236
+ echo " ⚠️ Graph build skipped (dependencies not installed)"
237
+ fi
238
+
239
+ # Run pattern learning (Layer 4)
240
+ echo "○ Learning patterns..."
241
+ if python3 "${INSTALL_DIR}/pattern_learner.py" update > /dev/null 2>&1; then
242
+ PATTERN_COUNT=$(python3 -c "
243
+ import sqlite3
244
+ from pathlib import Path
245
+ db_path = Path.home() / '.claude-memory' / 'memory.db'
246
+ conn = sqlite3.connect(db_path)
247
+ cursor = conn.cursor()
248
+ cursor.execute('SELECT COUNT(*) FROM identity_patterns')
249
+ count = cursor.fetchone()[0]
250
+ conn.close()
251
+ print(count)
252
+ " 2>/dev/null || echo "0")
253
+ echo " ✓ Pattern learning complete ($PATTERN_COUNT patterns found)"
254
+ else
255
+ echo " ⚠️ Pattern learning skipped (dependencies not installed)"
256
+ fi
257
+
258
+ # Check optional dependencies
259
+ echo ""
260
+ echo "Checking optional dependencies..."
261
+ python3 -c "import sklearn" 2>/dev/null && echo "✓ scikit-learn (Knowledge Graph)" || echo "○ scikit-learn not installed (optional)"
262
+ python3 -c "import numpy" 2>/dev/null && echo "✓ numpy (Vector Operations)" || echo "○ numpy not installed (optional)"
263
+ python3 -c "import igraph" 2>/dev/null && echo "✓ python-igraph (Clustering)" || echo "○ python-igraph not installed (optional)"
264
+ python3 -c "import fastapi" 2>/dev/null && echo "✓ fastapi (UI Server)" || echo "○ fastapi not installed (optional)"
265
+
266
+ # Auto-configure PATH
267
+ echo ""
268
+ echo "Configuring PATH..."
269
+
270
+ # Detect user's default shell (not installer script's shell)
271
+ USER_SHELL="${SHELL:-/bin/bash}"
272
+ SHELL_CONFIG=""
273
+
274
+ if [[ "$USER_SHELL" == *"zsh"* ]]; then
275
+ SHELL_CONFIG="${HOME}/.zshrc"
276
+ # Create .zshrc if it doesn't exist
277
+ touch "${SHELL_CONFIG}" 2>/dev/null
278
+ elif [[ "$USER_SHELL" == *"bash"* ]]; then
279
+ # For bash, prefer .bash_profile on macOS, .bashrc on Linux
280
+ if [[ "$(uname)" == "Darwin" ]] && [ -f "${HOME}/.bash_profile" ]; then
281
+ SHELL_CONFIG="${HOME}/.bash_profile"
282
+ else
283
+ SHELL_CONFIG="${HOME}/.bashrc"
284
+ touch "${SHELL_CONFIG}" 2>/dev/null
285
+ fi
286
+ else
287
+ # Fallback: check which config exists
288
+ if [ -f "${HOME}/.zshrc" ]; then
289
+ SHELL_CONFIG="${HOME}/.zshrc"
290
+ elif [ -f "${HOME}/.bash_profile" ]; then
291
+ SHELL_CONFIG="${HOME}/.bash_profile"
292
+ elif [ -f "${HOME}/.bashrc" ]; then
293
+ SHELL_CONFIG="${HOME}/.bashrc"
294
+ else
295
+ # Default to zsh on modern macOS
296
+ SHELL_CONFIG="${HOME}/.zshrc"
297
+ touch "${SHELL_CONFIG}"
298
+ fi
299
+ fi
300
+
301
+ # Check if PATH already configured
302
+ PATH_EXPORT="export PATH=\"\${HOME}/.claude-memory/bin:\${PATH}\""
303
+ if grep -q ".claude-memory/bin" "${SHELL_CONFIG}" 2>/dev/null; then
304
+ echo "○ PATH already configured in ${SHELL_CONFIG}"
305
+ else
306
+ # Add PATH export to shell config
307
+ echo "" >> "${SHELL_CONFIG}"
308
+ echo "# SuperLocalMemory V2 - Added by installer on $(date '+%Y-%m-%d')" >> "${SHELL_CONFIG}"
309
+ echo "${PATH_EXPORT}" >> "${SHELL_CONFIG}"
310
+ echo "✓ PATH configured in ${SHELL_CONFIG}"
311
+ fi
312
+
313
+ # Add to current session PATH
314
+ export PATH="${HOME}/.claude-memory/bin:${PATH}"
315
+ echo "✓ Commands available in current session"
316
+
317
+ # ============================================================================
318
+ # UNIVERSAL INTEGRATION - Auto-detect and configure IDEs/CLI tools
319
+ # ============================================================================
320
+
321
+ echo ""
322
+ echo "╔══════════════════════════════════════════════════════════════╗"
323
+ echo "║ Universal Integration - Auto-Detection ║"
324
+ echo "╚══════════════════════════════════════════════════════════════╝"
325
+ echo ""
326
+ echo "Detecting installed tools..."
327
+ echo ""
328
+
329
+ DETECTED_TOOLS=()
330
+
331
+ # Function to configure MCP for an IDE
332
+ configure_mcp() {
333
+ local tool_name="$1"
334
+ local config_source="$2"
335
+ local config_dest="$3"
336
+
337
+ # Replace {{INSTALL_DIR}} with actual path
338
+ sed "s|{{INSTALL_DIR}}|${INSTALL_DIR}|g" "${config_source}" > /tmp/slm-config-$$.json
339
+
340
+ # Create config directory if needed
341
+ mkdir -p "$(dirname "${config_dest}")"
342
+
343
+ # Backup existing config
344
+ if [ -f "${config_dest}" ]; then
345
+ cp "${config_dest}" "${config_dest}.backup.$(date +%Y%m%d-%H%M%S)"
346
+ echo " ✓ Backed up existing ${tool_name} config"
347
+ fi
348
+
349
+ # Install config
350
+ cp /tmp/slm-config-$$.json "${config_dest}"
351
+ rm /tmp/slm-config-$$.json
352
+
353
+ echo " ✓ ${tool_name} MCP configured"
354
+ }
355
+
356
+ # Copy MCP server to install directory
357
+ if [ -f "${REPO_DIR}/mcp_server.py" ]; then
358
+ cp "${REPO_DIR}/mcp_server.py" "${INSTALL_DIR}/"
359
+ chmod +x "${INSTALL_DIR}/mcp_server.py"
360
+ echo "✓ MCP Server installed"
361
+ fi
362
+
363
+ # Detect Claude Desktop
364
+ if [ -d "${HOME}/Library/Application Support/Claude" ] || [ -d "${HOME}/.config/Claude" ]; then
365
+ DETECTED_TOOLS+=("Claude Desktop")
366
+
367
+ if [ -f "${REPO_DIR}/configs/claude-desktop-mcp.json" ]; then
368
+ # Determine config path based on OS
369
+ if [ -d "${HOME}/Library/Application Support/Claude" ]; then
370
+ CONFIG_PATH="${HOME}/Library/Application Support/Claude/claude_desktop_config.json"
371
+ else
372
+ CONFIG_PATH="${HOME}/.config/Claude/claude_desktop_config.json"
373
+ fi
374
+
375
+ configure_mcp "Claude Desktop" \
376
+ "${REPO_DIR}/configs/claude-desktop-mcp.json" \
377
+ "${CONFIG_PATH}"
378
+ fi
379
+ fi
380
+
381
+ # Detect Cursor
382
+ if [ -d "${HOME}/.cursor" ] || command -v cursor &>/dev/null; then
383
+ DETECTED_TOOLS+=("Cursor")
384
+
385
+ if [ -f "${REPO_DIR}/configs/cursor-mcp.json" ]; then
386
+ configure_mcp "Cursor" \
387
+ "${REPO_DIR}/configs/cursor-mcp.json" \
388
+ "${HOME}/.cursor/mcp_settings.json"
389
+ fi
390
+ fi
391
+
392
+ # Detect Windsurf
393
+ if [ -d "${HOME}/.windsurf" ] || command -v windsurf &>/dev/null; then
394
+ DETECTED_TOOLS+=("Windsurf")
395
+
396
+ if [ -f "${REPO_DIR}/configs/windsurf-mcp.json" ]; then
397
+ configure_mcp "Windsurf" \
398
+ "${REPO_DIR}/configs/windsurf-mcp.json" \
399
+ "${HOME}/.windsurf/mcp_settings.json"
400
+ fi
401
+ fi
402
+
403
+ # Detect VS Code with Continue
404
+ if [ -d "${HOME}/.continue" ]; then
405
+ DETECTED_TOOLS+=("Continue.dev")
406
+
407
+ if [ -f "${REPO_DIR}/configs/continue-mcp.yaml" ]; then
408
+ # For Continue, append to config if exists, otherwise create
409
+ CONTINUE_CONFIG="${HOME}/.continue/config.yaml"
410
+ mkdir -p "${HOME}/.continue"
411
+
412
+ if [ -f "${CONTINUE_CONFIG}" ]; then
413
+ echo " ○ Continue.dev config exists - manual merge recommended"
414
+ echo " See: ${REPO_DIR}/configs/continue-mcp.yaml"
415
+ else
416
+ sed "s|{{INSTALL_DIR}}|${INSTALL_DIR}|g" "${REPO_DIR}/configs/continue-mcp.yaml" > "${CONTINUE_CONFIG}"
417
+ echo " ✓ Continue.dev MCP configured"
418
+ fi
419
+ fi
420
+ fi
421
+
422
+ # Detect Zed Editor
423
+ if [ -d "${HOME}/.config/zed" ] || command -v zed &>/dev/null; then
424
+ DETECTED_TOOLS+=("Zed Editor")
425
+
426
+ if [ -f "${REPO_DIR}/configs/zed-mcp.json" ]; then
427
+ configure_mcp "Zed Editor" \
428
+ "${REPO_DIR}/configs/zed-mcp.json" \
429
+ "${HOME}/.config/zed/context_servers.json"
430
+ fi
431
+ fi
432
+
433
+ # Detect OpenCode
434
+ if [ -d "${HOME}/.opencode" ]; then
435
+ DETECTED_TOOLS+=("OpenCode")
436
+
437
+ if [ -f "${REPO_DIR}/configs/opencode-mcp.json" ]; then
438
+ configure_mcp "OpenCode" \
439
+ "${REPO_DIR}/configs/opencode-mcp.json" \
440
+ "${HOME}/.opencode/mcp.json"
441
+ fi
442
+ fi
443
+
444
+ # Detect Antigravity (Gemini)
445
+ if [ -d "${HOME}/.gemini/antigravity" ]; then
446
+ DETECTED_TOOLS+=("Antigravity")
447
+
448
+ if [ -f "${REPO_DIR}/configs/antigravity-mcp.json" ]; then
449
+ configure_mcp "Antigravity" \
450
+ "${REPO_DIR}/configs/antigravity-mcp.json" \
451
+ "${HOME}/.gemini/antigravity/mcp_config.json"
452
+ fi
453
+ fi
454
+
455
+ # Detect Perplexity
456
+ if [ -d "${HOME}/.perplexity" ]; then
457
+ DETECTED_TOOLS+=("Perplexity")
458
+
459
+ if [ -f "${REPO_DIR}/configs/perplexity-mcp.json" ]; then
460
+ configure_mcp "Perplexity" \
461
+ "${REPO_DIR}/configs/perplexity-mcp.json" \
462
+ "${HOME}/.perplexity/mcp.json"
463
+ fi
464
+ fi
465
+
466
+ # Detect ChatGPT Desktop (requires HTTP transport, not stdio)
467
+ if [ -d "${HOME}/Library/Application Support/ChatGPT" ] || [ -d "${HOME}/.config/ChatGPT" ]; then
468
+ DETECTED_TOOLS+=("ChatGPT (manual)")
469
+ echo " ○ ChatGPT Desktop detected - requires HTTP transport"
470
+ echo " Run: slm serve (then expose via ngrok for ChatGPT)"
471
+ echo " Guide: docs/MCP-MANUAL-SETUP.md#chatgpt-desktop-app"
472
+ fi
473
+
474
+ # Detect Cody (VS Code extension) - Works on macOS/Linux/Windows
475
+ if [ -d "${HOME}/.vscode/extensions" ] || [ -d "${HOME}/.config/Code/User/extensions" ]; then
476
+ EXTENSIONS_DIR="${HOME}/.vscode/extensions"
477
+ [ -d "${HOME}/.config/Code/User/extensions" ] && EXTENSIONS_DIR="${HOME}/.config/Code/User/extensions"
478
+
479
+ if ls "${EXTENSIONS_DIR}" 2>/dev/null | grep -q "sourcegraph.cody"; then
480
+ DETECTED_TOOLS+=("Cody (manual)")
481
+ echo " ○ Cody detected - manual setup required"
482
+ echo " See: docs/MCP-MANUAL-SETUP.md#cody-vs-codejetbrains"
483
+ fi
484
+ fi
485
+
486
+ # Detect OpenAI Codex CLI
487
+ if [ -d "${HOME}/.codex" ] || command -v codex &>/dev/null; then
488
+ DETECTED_TOOLS+=("Codex CLI")
489
+
490
+ # Try native codex mcp add command first
491
+ if command -v codex &>/dev/null; then
492
+ if codex mcp add superlocalmemory-v2 --env "PYTHONPATH=${INSTALL_DIR}" -- python3 "${INSTALL_DIR}/mcp_server.py" 2>/dev/null; then
493
+ echo " ✓ Codex CLI MCP configured (via codex mcp add)"
494
+ else
495
+ # Fallback: Write TOML config
496
+ CODEX_CONFIG="${HOME}/.codex/config.toml"
497
+ mkdir -p "${HOME}/.codex"
498
+ if [ -f "${CODEX_CONFIG}" ] && grep -q "superlocalmemory-v2" "${CODEX_CONFIG}" 2>/dev/null; then
499
+ echo " ○ Codex CLI already configured"
500
+ else
501
+ cp "${CODEX_CONFIG}" "${CODEX_CONFIG}.backup.$(date +%Y%m%d-%H%M%S)" 2>/dev/null || true
502
+ cat >> "${CODEX_CONFIG}" <<TOML_EOF
503
+
504
+ [mcp_servers.superlocalmemory-v2]
505
+ command = "python3"
506
+ args = ["${INSTALL_DIR}/mcp_server.py"]
507
+
508
+ [mcp_servers.superlocalmemory-v2.env]
509
+ PYTHONPATH = "${INSTALL_DIR}"
510
+ TOML_EOF
511
+ echo " ✓ Codex CLI MCP configured (TOML appended)"
512
+ fi
513
+ fi
514
+ else
515
+ # codex command not in PATH but .codex dir exists
516
+ CODEX_CONFIG="${HOME}/.codex/config.toml"
517
+ mkdir -p "${HOME}/.codex"
518
+ if [ -f "${CODEX_CONFIG}" ] && grep -q "superlocalmemory-v2" "${CODEX_CONFIG}" 2>/dev/null; then
519
+ echo " ○ Codex CLI already configured"
520
+ else
521
+ cp "${CODEX_CONFIG}" "${CODEX_CONFIG}.backup.$(date +%Y%m%d-%H%M%S)" 2>/dev/null || true
522
+ cat >> "${CODEX_CONFIG}" <<TOML_EOF
523
+
524
+ [mcp_servers.superlocalmemory-v2]
525
+ command = "python3"
526
+ args = ["${INSTALL_DIR}/mcp_server.py"]
527
+
528
+ [mcp_servers.superlocalmemory-v2.env]
529
+ PYTHONPATH = "${INSTALL_DIR}"
530
+ TOML_EOF
531
+ echo " ✓ Codex CLI MCP configured (TOML appended)"
532
+ fi
533
+ fi
534
+ fi
535
+
536
+ # Detect VS Code / GitHub Copilot
537
+ if command -v code &>/dev/null || command -v code-insiders &>/dev/null; then
538
+ DETECTED_TOOLS+=("VS Code/Copilot")
539
+
540
+ if [ -f "${REPO_DIR}/configs/vscode-copilot-mcp.json" ]; then
541
+ # VS Code user-level MCP config
542
+ VSCODE_MCP="${HOME}/.vscode/mcp.json"
543
+ mkdir -p "${HOME}/.vscode"
544
+
545
+ if [ -f "${VSCODE_MCP}" ] && grep -q "superlocalmemory-v2" "${VSCODE_MCP}" 2>/dev/null; then
546
+ echo " ○ VS Code/Copilot already configured"
547
+ else
548
+ if [ -f "${VSCODE_MCP}" ]; then
549
+ cp "${VSCODE_MCP}" "${VSCODE_MCP}.backup.$(date +%Y%m%d-%H%M%S)"
550
+ echo " ✓ Backed up existing VS Code MCP config"
551
+ fi
552
+ sed "s|{{INSTALL_DIR}}|${INSTALL_DIR}|g" "${REPO_DIR}/configs/vscode-copilot-mcp.json" > "${VSCODE_MCP}"
553
+ echo " ✓ VS Code/Copilot MCP configured"
554
+ fi
555
+ fi
556
+ fi
557
+
558
+ # Detect Gemini CLI (separate from Antigravity)
559
+ if command -v gemini &>/dev/null || [ -f "${HOME}/.gemini/settings.json" ]; then
560
+ # Only add if not already detected as Antigravity
561
+ if [[ ! " ${DETECTED_TOOLS[*]} " =~ " Antigravity " ]]; then
562
+ DETECTED_TOOLS+=("Gemini CLI")
563
+ else
564
+ DETECTED_TOOLS+=("Gemini CLI")
565
+ fi
566
+
567
+ if [ -f "${REPO_DIR}/configs/gemini-cli-mcp.json" ]; then
568
+ GEMINI_CONFIG="${HOME}/.gemini/settings.json"
569
+ mkdir -p "${HOME}/.gemini"
570
+
571
+ if [ -f "${GEMINI_CONFIG}" ] && grep -q "superlocalmemory-v2" "${GEMINI_CONFIG}" 2>/dev/null; then
572
+ echo " ○ Gemini CLI already configured"
573
+ else
574
+ if [ -f "${GEMINI_CONFIG}" ]; then
575
+ cp "${GEMINI_CONFIG}" "${GEMINI_CONFIG}.backup.$(date +%Y%m%d-%H%M%S)"
576
+ echo " ✓ Backed up existing Gemini CLI config"
577
+ fi
578
+ sed "s|{{INSTALL_DIR}}|${INSTALL_DIR}|g" "${REPO_DIR}/configs/gemini-cli-mcp.json" > "${GEMINI_CONFIG}"
579
+ echo " ✓ Gemini CLI MCP configured"
580
+ fi
581
+ fi
582
+ fi
583
+
584
+ # Detect JetBrains IDEs (manual setup required - GUI-based)
585
+ if [ -d "${HOME}/Library/Application Support/JetBrains" ] || [ -d "${HOME}/.config/JetBrains" ]; then
586
+ DETECTED_TOOLS+=("JetBrains (manual)")
587
+ echo " ○ JetBrains IDE detected - manual setup via GUI"
588
+ echo " Settings → AI Assistant → MCP Servers → Add"
589
+ echo " Template: configs/jetbrains-mcp.json"
590
+ fi
591
+
592
+ # Install Universal Skills (SKILL.md for all detected tools)
593
+ if [ -f "${REPO_DIR}/install-skills.sh" ]; then
594
+ echo ""
595
+ echo "Installing Universal Skills..."
596
+ bash "${REPO_DIR}/install-skills.sh" --auto 2>/dev/null || echo " ○ Skills installation skipped (optional)"
597
+ fi
598
+
599
+ # Install MCP Python package if not present
600
+ if ! python3 -c "import mcp" 2>/dev/null; then
601
+ echo ""
602
+ echo "Installing MCP SDK..."
603
+ pip3 install mcp --quiet 2>/dev/null && echo "✓ MCP SDK installed" || echo "○ MCP SDK install failed (manual install: pip3 install mcp)"
604
+ fi
605
+
606
+ # Install bash completions
607
+ if [ -d "/usr/local/etc/bash_completion.d" ] && [ -f "${REPO_DIR}/completions/slm.bash" ]; then
608
+ sudo cp "${REPO_DIR}/completions/slm.bash" /usr/local/etc/bash_completion.d/slm 2>/dev/null && echo "✓ Bash completion installed" || true
609
+ fi
610
+
611
+ # Summary of detected tools
612
+ echo ""
613
+ if [ ${#DETECTED_TOOLS[@]} -gt 0 ]; then
614
+ echo "✓ Detected and configured:"
615
+ for tool in "${DETECTED_TOOLS[@]}"; do
616
+ echo " • $tool"
617
+ done
618
+ echo ""
619
+ echo "These tools now have native access to SuperLocalMemory!"
620
+ echo "Restart them to use the new MCP integration."
621
+ else
622
+ echo "○ No additional tools detected"
623
+ echo " MCP server is available if you install Cursor, Windsurf, etc."
624
+ fi
625
+
626
+ echo ""
627
+ echo "Universal CLI commands also available:"
628
+ echo " slm remember <content> - Simple command (anywhere)"
629
+ echo " slm recall <query> - Search from any terminal"
630
+ echo " slm status - Check system status"
631
+ echo ""
632
+
633
+ # Manual setup guide for other tools
634
+ echo "╔══════════════════════════════════════════════════════════════╗"
635
+ echo "║ Manual Setup for Other Apps ║"
636
+ echo "╚══════════════════════════════════════════════════════════════╝"
637
+ echo ""
638
+ echo "Want to use SuperLocalMemory in other apps?"
639
+ echo ""
640
+ echo " • ChatGPT Desktop - Add via Settings → MCP"
641
+ echo " • Perplexity - Add via Settings → Integrations"
642
+ echo " • Zed Editor - Configure in settings.json"
643
+ echo " • Cody - Configure in VS Code settings"
644
+ echo " • Custom tools - See integration guide"
645
+ echo ""
646
+ echo "Full manual setup guide:"
647
+ echo " docs/MCP-MANUAL-SETUP.md"
648
+ echo " https://github.com/varun369/SuperLocalMemoryV2/blob/main/docs/MCP-MANUAL-SETUP.md"
649
+ echo ""
650
+
651
+ # Summary
652
+ echo ""
653
+ echo "╔══════════════════════════════════════════════════════════════╗"
654
+ echo "║ Installation Complete! ║"
655
+ echo "╚══════════════════════════════════════════════════════════════╝"
656
+ echo ""
657
+ echo "✓ Commands are now globally available!"
658
+ echo ""
659
+ echo " You can use them immediately:"
660
+ echo ""
661
+ echo "Available commands (two ways to use them):"
662
+ echo ""
663
+ echo "OPTION 1: Original commands (still work):"
664
+ echo " superlocalmemoryv2:remember - Save a new memory"
665
+ echo " superlocalmemoryv2:recall - Search memories"
666
+ echo " superlocalmemoryv2:list - List recent memories"
667
+ echo " superlocalmemoryv2:status - Check system status"
668
+ echo ""
669
+ echo "OPTION 2: New simple commands:"
670
+ echo " slm remember <content> - Save (simpler syntax)"
671
+ echo " slm recall <query> - Search"
672
+ echo " slm list - List recent"
673
+ echo " slm status - System status"
674
+ echo ""
675
+ echo "Quick start (try now):"
676
+ echo " slm status"
677
+ echo " slm remember 'My first memory'"
678
+ echo " slm recall 'first'"
679
+ echo ""
680
+ # Optional: Offer to install optional features
681
+ if [ "$NON_INTERACTIVE" = true ]; then
682
+ INSTALL_CHOICE="N"
683
+ echo ""
684
+ echo "╔══════════════════════════════════════════════════════════════╗"
685
+ echo "║ Non-Interactive Mode: Skipping Optional Features ║"
686
+ echo "╚══════════════════════════════════════════════════════════════╝"
687
+ echo ""
688
+ echo "To install optional features later:"
689
+ echo " Advanced Search: pip3 install -r ${REPO_DIR}/requirements-search.txt"
690
+ echo " Web Dashboard: pip3 install -r ${REPO_DIR}/requirements-ui.txt"
691
+ echo " Full Package: pip3 install -r ${REPO_DIR}/requirements-full.txt"
692
+ echo ""
693
+ else
694
+ echo ""
695
+ echo "╔══════════════════════════════════════════════════════════════╗"
696
+ echo "║ Optional Features Available ║"
697
+ echo "╚══════════════════════════════════════════════════════════════╝"
698
+ echo ""
699
+ echo "Core features already installed:"
700
+ echo " ✓ Knowledge graph with Leiden clustering"
701
+ echo " ✓ Pattern learning and identity profiles"
702
+ echo " ✓ Web dashboard at http://localhost:8000"
703
+ echo ""
704
+ echo "Optional advanced search features:"
705
+ echo ""
706
+ echo " 1) Advanced Semantic Search (~1.5GB, 5-10 min)"
707
+ echo " • Sentence transformers for better search quality"
708
+ echo " • Vector similarity with HNSWLIB"
709
+ echo " • Recommended for large memory databases (>500 items)"
710
+ echo ""
711
+ echo " N) Skip (install later)"
712
+ echo ""
713
+ echo -n "Choose option [1/N]: "
714
+ read -r INSTALL_CHOICE
715
+ fi
716
+
717
+ case "$INSTALL_CHOICE" in
718
+ 1)
719
+ echo ""
720
+ echo "Installing Advanced Search features..."
721
+ echo "⏳ Downloading ~1.5GB (ML models)..."
722
+ if pip3 install $PIP_FLAGS -r "${REPO_DIR}/requirements-search.txt"; then
723
+ echo "✓ Advanced Search installed successfully"
724
+ echo ""
725
+ echo "Search now uses semantic embeddings for better quality!"
726
+ else
727
+ echo "⚠️ Installation failed. Install manually later:"
728
+ echo " pip3 install -r ${REPO_DIR}/requirements-search.txt"
729
+ fi
730
+ ;;
731
+ [Nn]|*)
732
+ echo ""
733
+ echo "Skipping advanced search."
734
+ echo ""
735
+ echo "To install later:"
736
+ echo " pip3 install -r ${REPO_DIR}/requirements-search.txt"
737
+ echo ""
738
+ echo "Start Web Dashboard:"
739
+ echo " python3 ~/.claude-memory/ui_server.py"
740
+ echo " Then open: http://localhost:8000"
741
+ ;;
742
+ esac
743
+
744
+ echo ""
745
+ echo "╔══════════════════════════════════════════════════════════════╗"
746
+ echo "║ ATTRIBUTION NOTICE (REQUIRED BY MIT LICENSE) ║"
747
+ echo "╠══════════════════════════════════════════════════════════════╣"
748
+ echo "║ Created by: Varun Pratap Bhardwaj ║"
749
+ echo "║ Role: Solution Architect & Original Creator ║"
750
+ echo "║ Repository: github.com/varun369/SuperLocalMemoryV2 ║"
751
+ echo "║ License: MIT (attribution must be preserved) ║"
752
+ echo "║ ║"
753
+ echo "║ See ATTRIBUTION.md for full attribution requirements ║"
754
+ echo "╚══════════════════════════════════════════════════════════════╝"
755
+ echo ""