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.
- package/ATTRIBUTION.md +140 -0
- package/CHANGELOG.md +1749 -0
- package/LICENSE +21 -0
- package/README.md +600 -0
- package/bin/aider-smart +72 -0
- package/bin/slm +202 -0
- package/bin/slm-npm +73 -0
- package/bin/slm.bat +195 -0
- package/bin/slm.cmd +10 -0
- package/bin/superlocalmemoryv2:list +3 -0
- package/bin/superlocalmemoryv2:profile +3 -0
- package/bin/superlocalmemoryv2:recall +3 -0
- package/bin/superlocalmemoryv2:remember +3 -0
- package/bin/superlocalmemoryv2:reset +3 -0
- package/bin/superlocalmemoryv2:status +3 -0
- package/completions/slm.bash +58 -0
- package/completions/slm.zsh +76 -0
- package/configs/antigravity-mcp.json +13 -0
- package/configs/chatgpt-desktop-mcp.json +7 -0
- package/configs/claude-desktop-mcp.json +15 -0
- package/configs/codex-mcp.toml +13 -0
- package/configs/cody-commands.json +29 -0
- package/configs/continue-mcp.yaml +14 -0
- package/configs/continue-skills.yaml +26 -0
- package/configs/cursor-mcp.json +15 -0
- package/configs/gemini-cli-mcp.json +11 -0
- package/configs/jetbrains-mcp.json +11 -0
- package/configs/opencode-mcp.json +12 -0
- package/configs/perplexity-mcp.json +9 -0
- package/configs/vscode-copilot-mcp.json +12 -0
- package/configs/windsurf-mcp.json +16 -0
- package/configs/zed-mcp.json +12 -0
- package/docs/ARCHITECTURE.md +877 -0
- package/docs/CLI-COMMANDS-REFERENCE.md +425 -0
- package/docs/COMPETITIVE-ANALYSIS.md +210 -0
- package/docs/COMPRESSION-README.md +390 -0
- package/docs/GRAPH-ENGINE.md +503 -0
- package/docs/MCP-MANUAL-SETUP.md +720 -0
- package/docs/MCP-TROUBLESHOOTING.md +787 -0
- package/docs/PATTERN-LEARNING.md +363 -0
- package/docs/PROFILES-GUIDE.md +453 -0
- package/docs/RESET-GUIDE.md +353 -0
- package/docs/SEARCH-ENGINE-V2.2.0.md +748 -0
- package/docs/SEARCH-INTEGRATION-GUIDE.md +502 -0
- package/docs/UI-SERVER.md +254 -0
- package/docs/UNIVERSAL-INTEGRATION.md +432 -0
- package/docs/V2.2.0-OPTIONAL-SEARCH.md +666 -0
- package/docs/WINDOWS-INSTALL-README.txt +34 -0
- package/docs/WINDOWS-POST-INSTALL.txt +45 -0
- package/docs/example_graph_usage.py +148 -0
- package/hooks/memory-list-skill.js +130 -0
- package/hooks/memory-profile-skill.js +284 -0
- package/hooks/memory-recall-skill.js +109 -0
- package/hooks/memory-remember-skill.js +127 -0
- package/hooks/memory-reset-skill.js +274 -0
- package/install-skills.sh +436 -0
- package/install.ps1 +417 -0
- package/install.sh +755 -0
- package/mcp_server.py +585 -0
- package/package.json +94 -0
- package/requirements-core.txt +24 -0
- package/requirements.txt +10 -0
- package/scripts/postinstall.js +126 -0
- package/scripts/preuninstall.js +57 -0
- package/skills/slm-build-graph/SKILL.md +423 -0
- package/skills/slm-list-recent/SKILL.md +348 -0
- package/skills/slm-recall/SKILL.md +325 -0
- package/skills/slm-remember/SKILL.md +194 -0
- package/skills/slm-status/SKILL.md +363 -0
- package/skills/slm-switch-profile/SKILL.md +442 -0
- package/src/__pycache__/cache_manager.cpython-312.pyc +0 -0
- package/src/__pycache__/embedding_engine.cpython-312.pyc +0 -0
- package/src/__pycache__/graph_engine.cpython-312.pyc +0 -0
- package/src/__pycache__/hnsw_index.cpython-312.pyc +0 -0
- package/src/__pycache__/hybrid_search.cpython-312.pyc +0 -0
- package/src/__pycache__/memory-profiles.cpython-312.pyc +0 -0
- package/src/__pycache__/memory-reset.cpython-312.pyc +0 -0
- package/src/__pycache__/memory_compression.cpython-312.pyc +0 -0
- package/src/__pycache__/memory_store_v2.cpython-312.pyc +0 -0
- package/src/__pycache__/migrate_v1_to_v2.cpython-312.pyc +0 -0
- package/src/__pycache__/pattern_learner.cpython-312.pyc +0 -0
- package/src/__pycache__/query_optimizer.cpython-312.pyc +0 -0
- package/src/__pycache__/search_engine_v2.cpython-312.pyc +0 -0
- package/src/__pycache__/setup_validator.cpython-312.pyc +0 -0
- package/src/__pycache__/tree_manager.cpython-312.pyc +0 -0
- package/src/cache_manager.py +520 -0
- package/src/embedding_engine.py +671 -0
- package/src/graph_engine.py +970 -0
- package/src/hnsw_index.py +626 -0
- package/src/hybrid_search.py +693 -0
- package/src/memory-profiles.py +518 -0
- package/src/memory-reset.py +485 -0
- package/src/memory_compression.py +999 -0
- package/src/memory_store_v2.py +1088 -0
- package/src/migrate_v1_to_v2.py +638 -0
- package/src/pattern_learner.py +898 -0
- package/src/query_optimizer.py +513 -0
- package/src/search_engine_v2.py +403 -0
- package/src/setup_validator.py +479 -0
- package/src/tree_manager.py +720 -0
package/requirements.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# SuperLocalMemory V2 - Core Requirements
|
|
2
|
+
# ============================================================================
|
|
3
|
+
# SuperLocalMemory V2.2.0 has ZERO core dependencies
|
|
4
|
+
# All functionality works with Python 3.8+ standard library only
|
|
5
|
+
#
|
|
6
|
+
# For optional advanced features, see:
|
|
7
|
+
# - requirements-full.txt (all optional features)
|
|
8
|
+
# - requirements-ui.txt (web dashboard only)
|
|
9
|
+
# - requirements-search.txt (advanced search only)
|
|
10
|
+
# ============================================================================
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* SuperLocalMemory V2 - NPM Postinstall Script
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2026 Varun Pratap Bhardwaj
|
|
6
|
+
* Solution Architect & Original Creator
|
|
7
|
+
*
|
|
8
|
+
* Licensed under MIT License (see LICENSE file)
|
|
9
|
+
* Repository: https://github.com/varun369/SuperLocalMemoryV2
|
|
10
|
+
*
|
|
11
|
+
* ATTRIBUTION REQUIRED: This notice must be preserved in all copies.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const { spawnSync } = require('child_process');
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const os = require('os');
|
|
17
|
+
const fs = require('fs');
|
|
18
|
+
|
|
19
|
+
console.log('\n════════════════════════════════════════════════════════════');
|
|
20
|
+
console.log(' SuperLocalMemory V2 - Post-Installation');
|
|
21
|
+
console.log(' by Varun Pratap Bhardwaj');
|
|
22
|
+
console.log(' https://github.com/varun369/SuperLocalMemoryV2');
|
|
23
|
+
console.log('════════════════════════════════════════════════════════════\n');
|
|
24
|
+
|
|
25
|
+
// Detect if this is a global install
|
|
26
|
+
const isGlobal = process.env.npm_config_global === 'true' ||
|
|
27
|
+
process.env.npm_config_global === true ||
|
|
28
|
+
(process.env.npm_config_prefix && !process.env.npm_config_prefix.includes('node_modules'));
|
|
29
|
+
|
|
30
|
+
if (!isGlobal) {
|
|
31
|
+
console.log('📦 Local installation detected.');
|
|
32
|
+
console.log(' SuperLocalMemory is designed for global installation.');
|
|
33
|
+
console.log(' Run: npm install -g superlocalmemory');
|
|
34
|
+
console.log('');
|
|
35
|
+
console.log('⏩ Skipping system installation for local install.');
|
|
36
|
+
console.log('');
|
|
37
|
+
process.exit(0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
console.log('🌍 Global installation detected. Running system setup...\n');
|
|
41
|
+
|
|
42
|
+
// Find the package root (where install.sh/install.ps1 lives)
|
|
43
|
+
const packageRoot = path.join(__dirname, '..');
|
|
44
|
+
const installScript = os.platform() === 'win32'
|
|
45
|
+
? path.join(packageRoot, 'install.ps1')
|
|
46
|
+
: path.join(packageRoot, 'install.sh');
|
|
47
|
+
|
|
48
|
+
// Check if install script exists
|
|
49
|
+
if (!fs.existsSync(installScript)) {
|
|
50
|
+
console.error('❌ Error: Install script not found at ' + installScript);
|
|
51
|
+
console.error(' Package may be corrupted. Please reinstall:');
|
|
52
|
+
console.error(' npm uninstall -g superlocalmemory');
|
|
53
|
+
console.error(' npm install -g superlocalmemory');
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Run the appropriate install script
|
|
58
|
+
console.log('Running installer: ' + path.basename(installScript));
|
|
59
|
+
console.log('This will:');
|
|
60
|
+
console.log(' • Copy files to ~/.claude-memory/');
|
|
61
|
+
console.log(' • Configure MCP for 16+ AI tools');
|
|
62
|
+
console.log(' • Install universal skills');
|
|
63
|
+
console.log(' • Set up CLI commands\n');
|
|
64
|
+
|
|
65
|
+
let result;
|
|
66
|
+
|
|
67
|
+
if (os.platform() === 'win32') {
|
|
68
|
+
// Windows: Run PowerShell script
|
|
69
|
+
console.log('Platform: Windows (PowerShell)\n');
|
|
70
|
+
result = spawnSync('powershell', [
|
|
71
|
+
'-ExecutionPolicy', 'Bypass',
|
|
72
|
+
'-File', installScript,
|
|
73
|
+
'--non-interactive'
|
|
74
|
+
], {
|
|
75
|
+
stdio: 'inherit',
|
|
76
|
+
cwd: packageRoot
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
// Mac/Linux: Run bash script
|
|
80
|
+
console.log('Platform: ' + (os.platform() === 'darwin' ? 'macOS' : 'Linux') + ' (Bash)\n');
|
|
81
|
+
result = spawnSync('bash', [installScript, '--non-interactive'], {
|
|
82
|
+
stdio: 'inherit',
|
|
83
|
+
cwd: packageRoot
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (result.error) {
|
|
88
|
+
console.error('\n❌ Installation failed with error:', result.error.message);
|
|
89
|
+
console.error('\nPlease run the install script manually:');
|
|
90
|
+
if (os.platform() === 'win32') {
|
|
91
|
+
console.error(' powershell -ExecutionPolicy Bypass -File "' + installScript + '"');
|
|
92
|
+
} else {
|
|
93
|
+
console.error(' bash "' + installScript + '"');
|
|
94
|
+
}
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (result.status !== 0) {
|
|
99
|
+
console.error('\n❌ Installation script exited with code ' + result.status);
|
|
100
|
+
console.error('\nPlease run the install script manually:');
|
|
101
|
+
if (os.platform() === 'win32') {
|
|
102
|
+
console.error(' powershell -ExecutionPolicy Bypass -File "' + installScript + '"');
|
|
103
|
+
} else {
|
|
104
|
+
console.error(' bash "' + installScript + '"');
|
|
105
|
+
}
|
|
106
|
+
process.exit(result.status);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
console.log('\n════════════════════════════════════════════════════════════');
|
|
110
|
+
console.log(' ✅ SuperLocalMemory V2 installed successfully!');
|
|
111
|
+
console.log('════════════════════════════════════════════════════════════\n');
|
|
112
|
+
|
|
113
|
+
console.log('Quick Start:');
|
|
114
|
+
console.log(' slm remember "Your first memory"');
|
|
115
|
+
console.log(' slm recall "search query"');
|
|
116
|
+
console.log(' slm status');
|
|
117
|
+
console.log(' slm help\n');
|
|
118
|
+
|
|
119
|
+
console.log('Documentation:');
|
|
120
|
+
console.log(' README: https://github.com/varun369/SuperLocalMemoryV2');
|
|
121
|
+
console.log(' Wiki: https://github.com/varun369/SuperLocalMemoryV2/wiki');
|
|
122
|
+
console.log(' Local: ~/.claude-memory/\n');
|
|
123
|
+
|
|
124
|
+
console.log('MCP Integration:');
|
|
125
|
+
console.log(' Auto-configured for: Claude Desktop, Cursor, Windsurf, etc.');
|
|
126
|
+
console.log(' Restart your AI tool to activate.\n');
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* SuperLocalMemory V2 - NPM Preuninstall Script
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2026 Varun Pratap Bhardwaj
|
|
6
|
+
* Solution Architect & Original Creator
|
|
7
|
+
*
|
|
8
|
+
* Licensed under MIT License (see LICENSE file)
|
|
9
|
+
* Repository: https://github.com/varun369/SuperLocalMemoryV2
|
|
10
|
+
*
|
|
11
|
+
* ATTRIBUTION REQUIRED: This notice must be preserved in all copies.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const os = require('os');
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
|
|
18
|
+
console.log('\n════════════════════════════════════════════════════════════');
|
|
19
|
+
console.log(' SuperLocalMemory V2 - Uninstalling');
|
|
20
|
+
console.log('════════════════════════════════════════════════════════════\n');
|
|
21
|
+
|
|
22
|
+
const SLM_DIR = path.join(os.homedir(), '.claude-memory');
|
|
23
|
+
|
|
24
|
+
if (fs.existsSync(SLM_DIR)) {
|
|
25
|
+
console.log('⚠️ Your data is preserved at: ' + SLM_DIR);
|
|
26
|
+
console.log('');
|
|
27
|
+
console.log(' This includes:');
|
|
28
|
+
console.log(' • Your memory database (memory.db)');
|
|
29
|
+
console.log(' • All learned patterns');
|
|
30
|
+
console.log(' • Knowledge graph');
|
|
31
|
+
console.log(' • Profile data');
|
|
32
|
+
console.log('');
|
|
33
|
+
console.log(' To completely remove SuperLocalMemory:');
|
|
34
|
+
if (os.platform() === 'win32') {
|
|
35
|
+
console.log(' rmdir /s "' + SLM_DIR + '"');
|
|
36
|
+
} else {
|
|
37
|
+
console.log(' rm -rf "' + SLM_DIR + '"');
|
|
38
|
+
}
|
|
39
|
+
console.log('');
|
|
40
|
+
console.log(' To backup your data first:');
|
|
41
|
+
if (os.platform() === 'win32') {
|
|
42
|
+
console.log(' xcopy "' + SLM_DIR + '" "%USERPROFILE%\\slm-backup\\" /E /I');
|
|
43
|
+
} else {
|
|
44
|
+
console.log(' cp -r "' + SLM_DIR + '" ~/slm-backup/');
|
|
45
|
+
}
|
|
46
|
+
console.log('');
|
|
47
|
+
} else {
|
|
48
|
+
console.log('ℹ️ No data directory found at ' + SLM_DIR);
|
|
49
|
+
console.log('');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
console.log('📦 Removing NPM package...');
|
|
53
|
+
console.log(' (slm and superlocalmemory commands will be unavailable)');
|
|
54
|
+
console.log('');
|
|
55
|
+
|
|
56
|
+
// No actual deletion here - we preserve user data
|
|
57
|
+
// NPM will remove the package files automatically
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: slm-build-graph
|
|
3
|
+
description: Build or rebuild the knowledge graph from existing memories using TF-IDF entity extraction and Leiden clustering. Use when search results seem poor, after bulk imports, or to optimize performance. Automatically discovers relationships between memories and creates topic clusters.
|
|
4
|
+
version: "2.1.0"
|
|
5
|
+
license: MIT
|
|
6
|
+
compatibility: "Requires SuperLocalMemory V2 installed at ~/.claude-memory/, optional dependencies: python-igraph, leidenalg"
|
|
7
|
+
attribution:
|
|
8
|
+
creator: Varun Pratap Bhardwaj
|
|
9
|
+
role: Solution Architect & Original Creator
|
|
10
|
+
project: SuperLocalMemory V2
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# SuperLocalMemory: Build Knowledge Graph
|
|
14
|
+
|
|
15
|
+
Build or rebuild the knowledge graph from existing memories to improve search quality and discover hidden relationships.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
slm build-graph [--force] [--clustering]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## What It Does
|
|
24
|
+
|
|
25
|
+
### 1. Entity Extraction (TF-IDF)
|
|
26
|
+
- Scans all memories
|
|
27
|
+
- Identifies important terms (entities)
|
|
28
|
+
- Creates nodes in knowledge graph
|
|
29
|
+
- Examples: "FastAPI", "JWT", "PostgreSQL", "React hooks"
|
|
30
|
+
|
|
31
|
+
### 2. Relationship Discovery
|
|
32
|
+
- Finds memories sharing entities
|
|
33
|
+
- Calculates similarity scores
|
|
34
|
+
- Creates edges between related nodes
|
|
35
|
+
- Discovers indirect connections
|
|
36
|
+
|
|
37
|
+
### 3. Topic Clustering (Optional)
|
|
38
|
+
- Groups related memories into clusters
|
|
39
|
+
- Uses Leiden algorithm (community detection)
|
|
40
|
+
- Creates semantic topic groups
|
|
41
|
+
- Examples: "Authentication cluster", "Database cluster"
|
|
42
|
+
|
|
43
|
+
## Examples
|
|
44
|
+
|
|
45
|
+
### Example 1: Basic Graph Build
|
|
46
|
+
```bash
|
|
47
|
+
$ slm build-graph
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Output:**
|
|
51
|
+
```
|
|
52
|
+
🔄 Building Knowledge Graph...
|
|
53
|
+
|
|
54
|
+
Phase 1: Entity Extraction
|
|
55
|
+
Scanning 1,247 memories...
|
|
56
|
+
Extracted 892 unique entities
|
|
57
|
+
Created 892 graph nodes
|
|
58
|
+
✓ Complete (3.2s)
|
|
59
|
+
|
|
60
|
+
Phase 2: Relationship Discovery
|
|
61
|
+
Computing similarity scores...
|
|
62
|
+
Created 3,456 edges (relationships)
|
|
63
|
+
Avg edges per node: 3.9
|
|
64
|
+
✓ Complete (5.1s)
|
|
65
|
+
|
|
66
|
+
Phase 3: Optimization
|
|
67
|
+
Indexing graph structure...
|
|
68
|
+
Pruning weak edges (score < 0.3)...
|
|
69
|
+
Final edge count: 2,134
|
|
70
|
+
✓ Complete (1.2s)
|
|
71
|
+
|
|
72
|
+
✅ Knowledge graph built successfully!
|
|
73
|
+
|
|
74
|
+
Graph Statistics:
|
|
75
|
+
Nodes: 892
|
|
76
|
+
Edges: 2,134
|
|
77
|
+
Density: 0.27%
|
|
78
|
+
Largest Component: 856 nodes (96%)
|
|
79
|
+
|
|
80
|
+
Next: Use `slm recall` to see improved search results
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Example 2: Force Rebuild
|
|
84
|
+
```bash
|
|
85
|
+
$ slm build-graph --force
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Rebuilds from scratch** (deletes existing graph first)
|
|
89
|
+
|
|
90
|
+
**Use when:**
|
|
91
|
+
- Graph seems corrupted
|
|
92
|
+
- Major bulk import completed
|
|
93
|
+
- Want fresh start
|
|
94
|
+
|
|
95
|
+
### Example 3: With Clustering
|
|
96
|
+
```bash
|
|
97
|
+
$ slm build-graph --clustering
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Requires optional dependencies:**
|
|
101
|
+
```bash
|
|
102
|
+
pip3 install python-igraph leidenalg
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Additional output:**
|
|
106
|
+
```
|
|
107
|
+
Phase 4: Topic Clustering (Leiden)
|
|
108
|
+
Detecting communities...
|
|
109
|
+
Found 47 clusters
|
|
110
|
+
Largest cluster: 89 memories
|
|
111
|
+
Smallest cluster: 3 memories
|
|
112
|
+
Modularity score: 0.82 (excellent)
|
|
113
|
+
✓ Complete (2.3s)
|
|
114
|
+
|
|
115
|
+
Discovered Clusters:
|
|
116
|
+
Cluster 1 (89 memories): "Authentication & Security"
|
|
117
|
+
Top entities: JWT, OAuth, tokens, auth, security
|
|
118
|
+
|
|
119
|
+
Cluster 2 (76 memories): "Database & PostgreSQL"
|
|
120
|
+
Top entities: PostgreSQL, database, SQL, queries, indexes
|
|
121
|
+
|
|
122
|
+
Cluster 3 (54 memories): "React & Frontend"
|
|
123
|
+
Top entities: React, hooks, components, state, props
|
|
124
|
+
|
|
125
|
+
...
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Arguments
|
|
129
|
+
|
|
130
|
+
| Argument | Description | When to Use |
|
|
131
|
+
|----------|-------------|-------------|
|
|
132
|
+
| `--force` | Delete existing graph and rebuild | Corruption, fresh start |
|
|
133
|
+
| `--clustering` | Run topic clustering | Want to discover topic groups |
|
|
134
|
+
| `--verbose` | Show detailed progress | Debugging, understanding process |
|
|
135
|
+
| `--dry-run` | Preview without saving | Testing, analysis |
|
|
136
|
+
|
|
137
|
+
## When to Run
|
|
138
|
+
|
|
139
|
+
### Always Run After:
|
|
140
|
+
1. **Bulk imports** - Added 50+ memories at once
|
|
141
|
+
2. **Database restore** - Restored from backup
|
|
142
|
+
3. **Major project milestone** - Sprint complete, project phase done
|
|
143
|
+
|
|
144
|
+
### Run Periodically:
|
|
145
|
+
4. **Monthly** - Keep graph optimized
|
|
146
|
+
5. **After 500 new memories** - Maintain quality
|
|
147
|
+
6. **When search feels slow** - Rebuild indexes
|
|
148
|
+
|
|
149
|
+
### Run on Issues:
|
|
150
|
+
7. **Poor search results** - Graph may be stale
|
|
151
|
+
8. **Missing relationships** - Rebuild connections
|
|
152
|
+
9. **Corrupted graph errors** - Force rebuild
|
|
153
|
+
|
|
154
|
+
## What Gets Built
|
|
155
|
+
|
|
156
|
+
### Graph Nodes
|
|
157
|
+
**Entities extracted from memories:**
|
|
158
|
+
- Technologies: "FastAPI", "PostgreSQL", "React"
|
|
159
|
+
- Concepts: "authentication", "performance", "testing"
|
|
160
|
+
- Patterns: "TDD", "async", "REST API"
|
|
161
|
+
- Decisions: "prefer X over Y"
|
|
162
|
+
|
|
163
|
+
**Node properties:**
|
|
164
|
+
- Entity text
|
|
165
|
+
- Frequency (how many memories mention it)
|
|
166
|
+
- Importance score
|
|
167
|
+
- First seen / last seen
|
|
168
|
+
|
|
169
|
+
### Graph Edges
|
|
170
|
+
**Relationships between entities:**
|
|
171
|
+
- **Similarity edge:** Memories share similar content
|
|
172
|
+
- **Co-occurrence edge:** Entities appear together
|
|
173
|
+
- **Sequential edge:** Memories created close in time
|
|
174
|
+
|
|
175
|
+
**Edge properties:**
|
|
176
|
+
- Similarity score (0.0 - 1.0)
|
|
177
|
+
- Shared entities list
|
|
178
|
+
- Edge type
|
|
179
|
+
|
|
180
|
+
### Clusters (if --clustering)
|
|
181
|
+
**Topic groups discovered:**
|
|
182
|
+
- Cluster ID
|
|
183
|
+
- Cluster name (auto-generated from top entities)
|
|
184
|
+
- Member memories (which memories belong)
|
|
185
|
+
- Top entities in cluster
|
|
186
|
+
- Modularity score (how well-defined)
|
|
187
|
+
|
|
188
|
+
## Performance
|
|
189
|
+
|
|
190
|
+
| Memory Count | Build Time | Notes |
|
|
191
|
+
|--------------|------------|-------|
|
|
192
|
+
| 100 | ~1s | Instant |
|
|
193
|
+
| 1,000 | ~10s | Fast |
|
|
194
|
+
| 10,000 | ~2min | Acceptable |
|
|
195
|
+
| 50,000+ | ~15min | Plan accordingly |
|
|
196
|
+
|
|
197
|
+
**With clustering (add ~50%):**
|
|
198
|
+
- 1,000 memories: ~15s
|
|
199
|
+
- 10,000 memories: ~3min
|
|
200
|
+
|
|
201
|
+
**Factors affecting speed:**
|
|
202
|
+
- Memory content length
|
|
203
|
+
- Vocabulary size (unique words)
|
|
204
|
+
- Hardware (CPU, RAM)
|
|
205
|
+
|
|
206
|
+
## Advanced Usage
|
|
207
|
+
|
|
208
|
+
### Incremental Updates
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
# Add new memories
|
|
212
|
+
slm remember "New content..." --tags new
|
|
213
|
+
|
|
214
|
+
# Incremental graph update (fast)
|
|
215
|
+
slm build-graph # Only processes new memories
|
|
216
|
+
|
|
217
|
+
# Force full rebuild (slower, thorough)
|
|
218
|
+
slm build-graph --force
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Monitoring Quality
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
# Check graph stats before
|
|
225
|
+
slm status | grep "Knowledge Graph"
|
|
226
|
+
|
|
227
|
+
# Build graph
|
|
228
|
+
slm build-graph --verbose
|
|
229
|
+
|
|
230
|
+
# Check stats after
|
|
231
|
+
slm status | grep "Knowledge Graph"
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Scripting & Automation
|
|
235
|
+
|
|
236
|
+
**Weekly rebuild (cron job):**
|
|
237
|
+
```bash
|
|
238
|
+
#!/bin/bash
|
|
239
|
+
# Every Sunday at 3 AM
|
|
240
|
+
|
|
241
|
+
echo "$(date): Starting graph rebuild"
|
|
242
|
+
slm build-graph --clustering >> /var/log/slm-build.log 2>&1
|
|
243
|
+
echo "$(date): Graph rebuild complete"
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Post-import hook:**
|
|
247
|
+
```bash
|
|
248
|
+
#!/bin/bash
|
|
249
|
+
# After bulk import
|
|
250
|
+
|
|
251
|
+
memories_added=$1
|
|
252
|
+
|
|
253
|
+
if [ "$memories_added" -gt 50 ]; then
|
|
254
|
+
echo "Large import detected, rebuilding graph..."
|
|
255
|
+
slm build-graph
|
|
256
|
+
fi
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Clustering Analysis
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# Build with clustering
|
|
263
|
+
slm build-graph --clustering
|
|
264
|
+
|
|
265
|
+
# Check discovered clusters
|
|
266
|
+
slm status --verbose | grep -A 20 "Topic Clusters"
|
|
267
|
+
|
|
268
|
+
# Search within specific cluster
|
|
269
|
+
slm recall "FastAPI" --cluster "Backend & APIs"
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Troubleshooting
|
|
273
|
+
|
|
274
|
+
### "Build failed: Memory error"
|
|
275
|
+
|
|
276
|
+
**Cause:** Not enough RAM for large graph
|
|
277
|
+
|
|
278
|
+
**Solution:**
|
|
279
|
+
```bash
|
|
280
|
+
# Build in chunks (process fewer memories at once)
|
|
281
|
+
slm build-graph --chunk-size 1000
|
|
282
|
+
|
|
283
|
+
# Or increase system memory
|
|
284
|
+
# Or archive old memories
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### "Clustering requires python-igraph"
|
|
288
|
+
|
|
289
|
+
**Cause:** Optional dependencies not installed
|
|
290
|
+
|
|
291
|
+
**Solution:**
|
|
292
|
+
```bash
|
|
293
|
+
pip3 install python-igraph leidenalg
|
|
294
|
+
|
|
295
|
+
# Verify
|
|
296
|
+
python3 -c "import igraph; import leidenalg"
|
|
297
|
+
|
|
298
|
+
# Try again
|
|
299
|
+
slm build-graph --clustering
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### "Graph build slow"
|
|
303
|
+
|
|
304
|
+
**Causes:**
|
|
305
|
+
- Large database
|
|
306
|
+
- Slow disk I/O
|
|
307
|
+
- Complex memory content
|
|
308
|
+
|
|
309
|
+
**Solutions:**
|
|
310
|
+
```bash
|
|
311
|
+
# Show progress
|
|
312
|
+
slm build-graph --verbose
|
|
313
|
+
|
|
314
|
+
# Skip clustering (faster)
|
|
315
|
+
slm build-graph # No --clustering flag
|
|
316
|
+
|
|
317
|
+
# Check disk space
|
|
318
|
+
df -h ~/.claude-memory/
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### "Edges seem wrong"
|
|
322
|
+
|
|
323
|
+
**Cause:** Stale graph or poor similarity threshold
|
|
324
|
+
|
|
325
|
+
**Solution:**
|
|
326
|
+
```bash
|
|
327
|
+
# Force complete rebuild
|
|
328
|
+
slm build-graph --force
|
|
329
|
+
|
|
330
|
+
# Adjust similarity threshold (advanced)
|
|
331
|
+
slm build-graph --min-similarity 0.4 # Default: 0.3
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Graph Metrics Explained
|
|
335
|
+
|
|
336
|
+
### Node Count
|
|
337
|
+
**Total unique entities found**
|
|
338
|
+
- Good: > 100 for 1,000 memories
|
|
339
|
+
- Poor: < 10 for 1,000 memories
|
|
340
|
+
|
|
341
|
+
**Why matters:** More nodes = richer semantic understanding
|
|
342
|
+
|
|
343
|
+
### Edge Count
|
|
344
|
+
**Total relationships discovered**
|
|
345
|
+
- Good: Edges/Nodes ratio > 2
|
|
346
|
+
- Poor: Ratio < 1 (disconnected graph)
|
|
347
|
+
|
|
348
|
+
**Why matters:** More edges = better search via relationships
|
|
349
|
+
|
|
350
|
+
### Density
|
|
351
|
+
**How connected the graph is**
|
|
352
|
+
- Formula: (Edges / Possible Edges) × 100
|
|
353
|
+
- Typical: 0.1% - 1%
|
|
354
|
+
- Too low (<0.05%): Memories very disconnected
|
|
355
|
+
- Too high (>5%): May indicate poor entity extraction
|
|
356
|
+
|
|
357
|
+
### Largest Component
|
|
358
|
+
**Size of biggest connected subgraph**
|
|
359
|
+
- Good: >80% of nodes
|
|
360
|
+
- Poor: <50% (fragmented knowledge)
|
|
361
|
+
|
|
362
|
+
**Why matters:** Smaller component = isolated knowledge islands
|
|
363
|
+
|
|
364
|
+
### Modularity (Clustering)
|
|
365
|
+
**How well-defined clusters are**
|
|
366
|
+
- Excellent: >0.7
|
|
367
|
+
- Good: 0.5 - 0.7
|
|
368
|
+
- Poor: <0.3
|
|
369
|
+
|
|
370
|
+
**Why matters:** Higher = clearer topic separation
|
|
371
|
+
|
|
372
|
+
## Impact on Other Commands
|
|
373
|
+
|
|
374
|
+
### slm recall (Search)
|
|
375
|
+
**Before graph build:**
|
|
376
|
+
- Relies mainly on keyword matching
|
|
377
|
+
- May miss related memories
|
|
378
|
+
|
|
379
|
+
**After graph build:**
|
|
380
|
+
- Discovers indirect relationships
|
|
381
|
+
- Finds conceptually similar memories
|
|
382
|
+
- Better ranked results
|
|
383
|
+
|
|
384
|
+
**Example:**
|
|
385
|
+
```
|
|
386
|
+
Query: "authentication"
|
|
387
|
+
|
|
388
|
+
Before:
|
|
389
|
+
- Direct matches only (JWT, auth, login)
|
|
390
|
+
|
|
391
|
+
After:
|
|
392
|
+
- Direct matches (JWT, auth, login)
|
|
393
|
+
- + Related concepts (security, tokens, OAuth)
|
|
394
|
+
- + Connected memories (API design, user management)
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### slm status
|
|
398
|
+
Shows updated graph statistics
|
|
399
|
+
|
|
400
|
+
### slm switch-profile
|
|
401
|
+
Each profile has separate graph
|
|
402
|
+
|
|
403
|
+
## Notes
|
|
404
|
+
|
|
405
|
+
- **Non-destructive:** Original memories never modified
|
|
406
|
+
- **Idempotent:** Can run multiple times safely
|
|
407
|
+
- **Automatic:** Search uses graph automatically after build
|
|
408
|
+
- **Privacy:** All processing local
|
|
409
|
+
|
|
410
|
+
## Related Commands
|
|
411
|
+
|
|
412
|
+
- `slm recall` - Search uses the graph
|
|
413
|
+
- `slm status` - Check graph stats
|
|
414
|
+
- `slm remember` - Add memories (triggers incremental update)
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
**Created by:** [Varun Pratap Bhardwaj](https://github.com/varun369) (Solution Architect)
|
|
419
|
+
**Project:** SuperLocalMemory V2
|
|
420
|
+
**License:** MIT with attribution requirements (see [ATTRIBUTION.md](../../ATTRIBUTION.md))
|
|
421
|
+
**Repository:** https://github.com/varun369/SuperLocalMemoryV2
|
|
422
|
+
|
|
423
|
+
*Open source doesn't mean removing credit. Attribution must be preserved per MIT License terms.*
|