superlocalmemory 3.4.17 → 3.4.18

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 (78) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +1 -3
  3. package/pyproject.toml +10 -1
  4. package/src/superlocalmemory/cli/setup_wizard.py +30 -0
  5. package/src/superlocalmemory.egg-info/PKG-INFO +4 -1
  6. package/src/superlocalmemory.egg-info/requires.txt +3 -0
  7. package/docs/ARCHITECTURE.md +0 -149
  8. package/docs/api-reference.md +0 -284
  9. package/docs/auto-memory.md +0 -150
  10. package/docs/cli-reference.md +0 -327
  11. package/docs/cloud-backup.md +0 -174
  12. package/docs/compliance.md +0 -191
  13. package/docs/configuration.md +0 -182
  14. package/docs/getting-started.md +0 -102
  15. package/docs/ide-setup.md +0 -261
  16. package/docs/mcp-tools.md +0 -220
  17. package/docs/migration-from-v2.md +0 -170
  18. package/docs/profiles.md +0 -173
  19. package/docs/screenshots/01-dashboard-main.png +0 -0
  20. package/docs/screenshots/02-knowledge-graph.png +0 -0
  21. package/docs/screenshots/03-math-health.png +0 -0
  22. package/docs/screenshots/03-patterns-learning.png +0 -0
  23. package/docs/screenshots/04-learning-dashboard.png +0 -0
  24. package/docs/screenshots/04-recall-lab.png +0 -0
  25. package/docs/screenshots/05-behavioral-analysis.png +0 -0
  26. package/docs/screenshots/05-trust-dashboard.png +0 -0
  27. package/docs/screenshots/06-graph-communities.png +0 -0
  28. package/docs/screenshots/06-settings.png +0 -0
  29. package/docs/screenshots/07-memories-blurred.png +0 -0
  30. package/docs/skill-evolution.md +0 -256
  31. package/docs/troubleshooting.md +0 -310
  32. package/docs/v2-archive/ACCESSIBILITY.md +0 -291
  33. package/docs/v2-archive/ARCHITECTURE.md +0 -886
  34. package/docs/v2-archive/CLI-COMMANDS-REFERENCE.md +0 -425
  35. package/docs/v2-archive/COMPRESSION-README.md +0 -390
  36. package/docs/v2-archive/FRAMEWORK-INTEGRATIONS.md +0 -300
  37. package/docs/v2-archive/MCP-MANUAL-SETUP.md +0 -775
  38. package/docs/v2-archive/MCP-TROUBLESHOOTING.md +0 -787
  39. package/docs/v2-archive/PATTERN-LEARNING.md +0 -228
  40. package/docs/v2-archive/PROFILES-GUIDE.md +0 -453
  41. package/docs/v2-archive/RESET-GUIDE.md +0 -353
  42. package/docs/v2-archive/SEARCH-ENGINE-V2.2.0.md +0 -749
  43. package/docs/v2-archive/SEARCH-INTEGRATION-GUIDE.md +0 -502
  44. package/docs/v2-archive/UI-SERVER.md +0 -262
  45. package/docs/v2-archive/UNIVERSAL-INTEGRATION.md +0 -488
  46. package/docs/v2-archive/V2.2.0-OPTIONAL-SEARCH.md +0 -666
  47. package/docs/v2-archive/WINDOWS-INSTALL-README.txt +0 -34
  48. package/docs/v2-archive/WINDOWS-POST-INSTALL.txt +0 -45
  49. package/docs/v2-archive/example_graph_usage.py +0 -146
  50. package/ui/index.html +0 -1879
  51. package/ui/js/agents.js +0 -192
  52. package/ui/js/auto-settings.js +0 -399
  53. package/ui/js/behavioral.js +0 -276
  54. package/ui/js/clusters.js +0 -206
  55. package/ui/js/compliance.js +0 -252
  56. package/ui/js/core.js +0 -246
  57. package/ui/js/dashboard.js +0 -110
  58. package/ui/js/events.js +0 -178
  59. package/ui/js/fact-detail.js +0 -92
  60. package/ui/js/feedback.js +0 -333
  61. package/ui/js/graph-core.js +0 -447
  62. package/ui/js/graph-filters.js +0 -220
  63. package/ui/js/graph-interactions.js +0 -351
  64. package/ui/js/graph-ui.js +0 -214
  65. package/ui/js/ide-status.js +0 -102
  66. package/ui/js/init.js +0 -45
  67. package/ui/js/learning.js +0 -435
  68. package/ui/js/lifecycle.js +0 -298
  69. package/ui/js/math-health.js +0 -98
  70. package/ui/js/memories.js +0 -264
  71. package/ui/js/modal.js +0 -357
  72. package/ui/js/patterns.js +0 -93
  73. package/ui/js/profiles.js +0 -236
  74. package/ui/js/recall-lab.js +0 -292
  75. package/ui/js/search.js +0 -59
  76. package/ui/js/settings.js +0 -224
  77. package/ui/js/timeline.js +0 -32
  78. package/ui/js/trust-dashboard.js +0 -73
@@ -1,886 +0,0 @@
1
- # Architecture Documentation
2
-
3
- ## SuperLocalMemory V2 - Technical Architecture
4
-
5
- This document provides a comprehensive technical overview of SuperLocalMemory V2's architecture, design decisions, and implementation details.
6
-
7
- ---
8
-
9
- ## Table of Contents
10
-
11
- - [System Overview](#system-overview)
12
- - [Universal Integration](#universal-integration)
13
- - [7-Layer Architecture](#7-layer-architecture)
14
- - [Component Details](#component-details)
15
- - [Data Flow](#data-flow)
16
- - [Technology Stack](#technology-stack)
17
- - [Design Decisions](#design-decisions)
18
- - [Performance Characteristics](#performance-characteristics)
19
- - [Security & Privacy](#security--privacy)
20
- - [Scalability](#scalability)
21
-
22
- ---
23
-
24
- ## System Overview
25
-
26
- SuperLocalMemory V2 is a **standalone, local-first, intelligent memory system** that transforms flat memory storage into a living knowledge graph with pattern learning capabilities.
27
-
28
- Works independently or integrates with Claude CLI, GPT, local LLMs, or any AI assistant.
29
-
30
- ### Core Principles
31
-
32
- 1. **Local-First:** All data stored locally, zero external API calls
33
- 2. **Privacy-First:** No telemetry, no tracking, complete user control
34
- 3. **Intelligence:** Auto-discovery of relationships and patterns
35
- 4. **Modularity:** Independent layers with clear interfaces
36
- 5. **Performance:** Sub-second operations for typical workloads (< 500 memories)
37
-
38
- ### Architecture Philosophy
39
-
40
- ```
41
- Simple Storage → Intelligent Organization → Adaptive Learning
42
- (SQLite) (Graphs + Indexes) (Pattern Recognition)
43
- ```
44
-
45
- ---
46
-
47
- ## Universal Integration
48
-
49
- **Version 2.4.1** transforms SuperLocalMemory from Claude-Code-only to a universal memory system that works across 16+ IDEs and CLI tools with zero configuration.
50
-
51
- ### Three-Tier Access Architecture
52
-
53
- ```
54
- ┌─────────────────────────────────────────────────────────────┐
55
- │ ACCESS METHODS │
56
- ├─────────────────────────────────────────────────────────────┤
57
- │ TIER 1: MCP (Model Context Protocol) │
58
- │ • Cursor IDE - Native AI tool access │
59
- │ • Windsurf IDE - Built-in integration │
60
- │ • Claude Desktop - Direct MCP support │
61
- │ • Continue.dev - MCP context providers │
62
- ├─────────────────────────────────────────────────────────────┤
63
- │ TIER 2: Skills & Commands │
64
- │ • Claude Code - /superlocalmemoryv2-* │
65
- │ • Continue.dev - /slm-* slash commands │
66
- │ • Cody - Custom commands via settings │
67
- ├─────────────────────────────────────────────────────────────┤
68
- │ TIER 3: Universal CLI │
69
- │ • slm wrapper - Simple command syntax │
70
- │ • aider-smart - Auto-context injection │
71
- │ • Any terminal - Direct Python execution │
72
- └────────────────┬────────────────────────────────────────────┘
73
-
74
-
75
- ┌───────────────────┐
76
- │ SuperLocalMemory │
77
- │ Core (Unchanged) │
78
- │ memory.db (SQLite) │
79
- └───────────────────┘
80
- ```
81
-
82
- ### MCP Server Implementation
83
-
84
- **File:** `mcp_server.py` (450+ lines)
85
-
86
- The MCP server provides native integration with modern AI tools:
87
-
88
- **12 Tools:**
89
- - `remember(content, tags, project)` - Save memories
90
- - `recall(query, limit)` - Search memories
91
- - `list_recent(limit)` - Recent memories
92
- - `get_status()` - System status
93
- - `build_graph()` - Build knowledge graph
94
- - `switch_profile(name)` - Change profile
95
- - `search(query)` - Search memories (OpenAI MCP spec for ChatGPT Connectors)
96
- - `fetch(id)` - Fetch memory by ID (OpenAI MCP spec for ChatGPT Connectors)
97
- - `backup_status()` - Auto-backup status
98
- - `memory_used(memory_id, query, usefulness)` - Feedback for learning (v2.7)
99
- - `get_learned_patterns(min_confidence, category)` - Retrieve learned patterns (v2.7)
100
- - `correct_pattern(pattern_id, correct_value)` - Correct a learned pattern (v2.7)
101
-
102
- **6 Resources:**
103
- - `memory://recent/{limit}` - Recent memories feed
104
- - `memory://stats` - System statistics
105
- - `memory://graph/clusters` - Graph clusters
106
- - `memory://patterns/identity` - Learned patterns
107
- - `memory://learning/status` - Learning system status (v2.7)
108
- - `memory://engagement` - Engagement metrics (v2.7)
109
-
110
- **2 Prompts:**
111
- - `coding_identity_prompt` - User's coding style
112
- - `project_context_prompt` - Current project context
113
-
114
- **Transport Support:**
115
- - stdio (default) - For local IDE integration
116
- - HTTP - For remote/network access
117
- - streamable-http - For ChatGPT 2026+ Connectors
118
-
119
- **Key Design:** Zero duplication - calls existing `memory_store_v2.py` functions
120
-
121
- ### Auto-Detection System
122
-
123
- **File:** `install.sh` (enhanced)
124
-
125
- Installation automatically detects and configures:
126
-
127
- ```bash
128
- # Detect installed tools
129
- [ -d "$HOME/Library/Application Support/Claude" ] && configure_claude_desktop
130
- [ -d "$HOME/.cursor" ] && configure_cursor
131
- [ -d "$HOME/.windsurf" ] && configure_windsurf
132
- [ -d "$HOME/.continue" ] && configure_continue
133
- ```
134
-
135
- **For each detected tool:**
136
- 1. Creates configuration from template
137
- 2. Substitutes {{INSTALL_DIR}} with actual path
138
- 3. Backs up existing configs
139
- 4. Installs new config
140
- 5. Reports success
141
-
142
- **Zero manual configuration required.**
143
-
144
- ### Universal CLI Wrapper
145
-
146
- **File:** `bin/slm`
147
-
148
- Provides simple syntax for all operations:
149
-
150
- ```bash
151
- slm remember "content" # Calls superlocalmemoryv2-remember
152
- slm recall "query" # Calls superlocalmemoryv2-recall
153
- slm list # Recent memories
154
- slm status # System health
155
- slm profile list # Profile management
156
- slm graph build # Knowledge graph
157
- ```
158
-
159
- **Implementation:** Bash wrapper routing to existing CLI commands - no duplicate logic
160
-
161
- ### Backward Compatibility
162
-
163
- **100% backward compatible:**
164
- - All original commands work unchanged
165
- - Database schema unchanged
166
- - Profile system intact
167
- - Skills system unchanged
168
- - Zero breaking changes
169
-
170
- **Upgrade path:**
171
- 1. Run `./install.sh`
172
- 2. Auto-detection configures new tools
173
- 3. Existing workflows continue working
174
- 4. New capabilities available immediately
175
-
176
- ### Integration Matrix
177
-
178
- | Tool | Integration Method | Configuration |
179
- |------|-------------------|---------------|
180
- | Claude Code | Skills (unchanged) | Existing |
181
- | Cursor | MCP stdio | Auto-detected |
182
- | Windsurf | MCP stdio | Auto-detected |
183
- | Claude Desktop | MCP stdio | Auto-detected |
184
- | Continue.dev | MCP + Skills | Auto-detected |
185
- | Cody | Custom commands | Auto-detected |
186
- | Aider | Smart wrapper | Always available |
187
- | Any terminal | slm wrapper | Always available |
188
-
189
- ### Design Decision: Additive Architecture
190
-
191
- **Reasoning:**
192
- - New files only - zero modifications to core src/
193
- - Original commands unchanged
194
- - Optional MCP layer on top
195
- - Fallback to CLI if MCP unavailable
196
- - Single source of truth (memory.db)
197
-
198
- **Trade-offs:**
199
- - Slight code duplication in wrappers (bash + MCP)
200
- - More installation complexity (auto-detection)
201
- - Multiple access paths to same data
202
-
203
- **Benefits:**
204
- - Zero risk to existing users
205
- - Instant rollback (remove new files)
206
- - Easy testing (each tier independent)
207
- - Universal adoption without migration
208
-
209
- ---
210
-
211
- ## 7-Layer Architecture
212
-
213
- SuperLocalMemory V2 uses a hierarchical, additive architecture where each layer builds on the previous without replacing it. Version 2.3.0 introduced universal access across 16+ IDEs, and subsequent releases (through 2.4.1) added profiles, hierarchical clustering, and community summaries.
214
-
215
- ```
216
- ┌─────────────────────────────────────────────────────────────────┐
217
- │ SuperLocalMemory V2 │
218
- │ 7-Layer Universal Architecture │
219
- └─────────────────────────────────────────────────────────────────┘
220
-
221
- ┌─────────────────────────────────────────────────────────────────┐
222
- │ Layer 7: Universal Access │
223
- │ Three access methods: MCP Protocol, Skills, CLI │
224
- │ All share one database (~/.superlocalmemory/memory.db) │
225
- │ Output: Unified access across 16+ IDEs and tools │
226
- └─────────────────────────────────────────────────────────────────┘
227
-
228
- ┌─────────────────────────────────────────────────────────────────┐
229
- │ Layer 6: MCP Integration (mcp_server.py) │
230
- │ 12 tools, 6 resources, 2 prompts │
231
- │ Auto-configured for Claude Desktop, Cursor, Windsurf, etc. │
232
- │ Output: Native AI tool access via Model Context Protocol │
233
- └─────────────────────────────────────────────────────────────────┘
234
-
235
- ┌─────────────────────────────────────────────────────────────────┐
236
- │ Layer 5: Skills Layer (skills/*) │
237
- │ 7 slash-command skills for Claude Code, Continue.dev, Cody │
238
- │ slm-remember, slm-recall, slm-status, slm-list-recent, │
239
- │ slm-build-graph, slm-switch-profile, slm-show-patterns │
240
- │ Output: Familiar /command interface across AI tools │
241
- └─────────────────────────────────────────────────────────────────┘
242
-
243
- ┌─────────────────────────────────────────────────────────────────┐
244
- │ Layer 4: Pattern Learning (Identity Profiles) │
245
- ├─────────────────────────────────────────────────────────────────┤
246
- │ │
247
- │ ┌──────────────────┐ ┌──────────────────┐ │
248
- │ │ Frequency │ │ Context │ │
249
- │ │ Analysis │ │ Analysis │ │
250
- │ └──────────────────┘ └──────────────────┘ │
251
- │ │
252
- │ ┌──────────────────┐ ┌──────────────────┐ │
253
- │ │ Terminology │ │ Confidence │ │
254
- │ │ Learning │ │ Scoring │ │
255
- │ └──────────────────┘ └──────────────────┘ │
256
- │ │
257
- │ Output: Identity profiles with confidence scores │
258
- └─────────────────────────────────────────────────────────────────┘
259
-
260
- ┌─────────────────────────────────────────────────────────────────┐
261
- │ Layer 3: Knowledge Graph (GraphRAG) │
262
- ├─────────────────────────────────────────────────────────────────┤
263
- │ │
264
- │ ┌──────────────────┐ ┌──────────────────┐ │
265
- │ │ TF-IDF Entity │ │ Leiden │ │
266
- │ │ Extraction │ │ Clustering │ │
267
- │ └──────────────────┘ └──────────────────┘ │
268
- │ │
269
- │ ┌──────────────────┐ ┌──────────────────┐ │
270
- │ │ Auto-naming │ │ Relationship │ │
271
- │ │ Clusters │ │ Discovery │ │
272
- │ └──────────────────┘ └──────────────────┘ │
273
- │ │
274
- │ Output: Clusters of related memories, entity relationships │
275
- └─────────────────────────────────────────────────────────────────┘
276
-
277
- ┌─────────────────────────────────────────────────────────────────┐
278
- │ Layer 2: Hierarchical Index (PageIndex-inspired) │
279
- ├─────────────────────────────────────────────────────────────────┤
280
- │ │
281
- │ ┌──────────────────┐ ┌──────────────────┐ │
282
- │ │ Tree Structure │ │ Parent-Child │ │
283
- │ │ Management │ │ Relationships │ │
284
- │ └──────────────────┘ └──────────────────┘ │
285
- │ │
286
- │ ┌──────────────────┐ ┌──────────────────┐ │
287
- │ │ Fast Navigation │ │ Contextual │ │
288
- │ │ Paths │ │ Grouping │ │
289
- │ └──────────────────┘ └──────────────────┘ │
290
- │ │
291
- │ Output: Hierarchical organization, breadcrumb navigation │
292
- └─────────────────────────────────────────────────────────────────┘
293
-
294
- ┌─────────────────────────────────────────────────────────────────┐
295
- │ Layer 1: Raw Storage (SQLite Foundation) │
296
- ├─────────────────────────────────────────────────────────────────┤
297
- │ │
298
- │ ┌──────────────────┐ ┌──────────────────┐ │
299
- │ │ Full-Text │ │ Vector │ │
300
- │ │ Search (FTS5) │ │ Embeddings │ │
301
- │ └──────────────────┘ └──────────────────┘ │
302
- │ │
303
- │ ┌──────────────────┐ ┌──────────────────┐ │
304
- │ │ Tags & │ │ Compression │ │
305
- │ │ Metadata │ │ Archives │ │
306
- │ └──────────────────┘ └──────────────────┘ │
307
- │ │
308
- │ Output: Persistent storage, fast search, metadata │
309
- └─────────────────────────────────────────────────────────────────┘
310
- ```
311
-
312
- **Optional Add-on Layers (v2.2.0):**
313
- - **Advanced Search:** BM25 engine, HNSW vector index, hybrid search
314
- - **Visualization:** Web dashboard with timeline, graph view, statistics
315
-
316
- ---
317
-
318
- ## Component Details
319
-
320
- ### Layer 1: Raw Storage (SQLite)
321
-
322
- **Responsibility:** Persistent storage, basic search, metadata management
323
-
324
- **Components:**
325
-
326
- 1. **memory_store_v2.py** - Core CRUD operations
327
- - Add, update, delete memories
328
- - Tag management
329
- - Search interface
330
-
331
- 2. **SQLite Schema:**
332
- ```sql
333
- -- Main memories table
334
- CREATE TABLE memories (
335
- id INTEGER PRIMARY KEY,
336
- content TEXT NOT NULL,
337
- timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
338
- tags TEXT, -- JSON array
339
- metadata TEXT, -- JSON object
340
- tier INTEGER DEFAULT 1, -- Compression tier
341
- parent_id INTEGER, -- For tree structure
342
- FOREIGN KEY (parent_id) REFERENCES memories(id)
343
- );
344
-
345
- -- Full-text search index
346
- CREATE VIRTUAL TABLE memories_fts USING fts5(
347
- content, tags,
348
- content=memories,
349
- content_rowid=id
350
- );
351
-
352
- -- Graph tables
353
- CREATE TABLE graph_clusters (
354
- id INTEGER PRIMARY KEY,
355
- name TEXT,
356
- description TEXT
357
- );
358
-
359
- CREATE TABLE graph_cluster_members (
360
- cluster_id INTEGER,
361
- memory_id INTEGER,
362
- FOREIGN KEY (cluster_id) REFERENCES graph_clusters(id),
363
- FOREIGN KEY (memory_id) REFERENCES memories(id)
364
- );
365
-
366
- -- Pattern learning tables
367
- CREATE TABLE learned_patterns (
368
- id INTEGER PRIMARY KEY,
369
- category TEXT,
370
- subcategory TEXT,
371
- pattern_text TEXT,
372
- confidence REAL,
373
- frequency INTEGER,
374
- last_seen DATETIME
375
- );
376
- ```
377
-
378
- 3. **Compression System** (memory_compression.py)
379
- - Progressive summarization
380
- - Tier-based compression (Tier 1→2→3)
381
- - Cold storage archival
382
-
383
- **Performance:**
384
- - Full-text search: Sub-11ms median for typical databases (see wiki Performance Benchmarks for measured data)
385
- - Insert: <10ms
386
- - Tag search: ~30ms
387
-
388
- ---
389
-
390
- ### Layer 2: Hierarchical Index (PageIndex)
391
-
392
- **Responsibility:** Tree-based organization, contextual grouping
393
-
394
- **Components:**
395
-
396
- 1. **tree_manager.py** - Tree structure operations
397
- - Parent-child relationship management
398
- - Breadcrumb generation
399
- - Subtree queries
400
-
401
- **Key Features:**
402
- - Fast navigation through related memories
403
- - Contextual grouping (e.g., "Project Alpha" → subtasks)
404
- - Efficient ancestor/descendant queries
405
-
406
- **Schema Integration:**
407
- ```sql
408
- -- Parent-child relationships
409
- parent_id INTEGER FOREIGN KEY → memories(id)
410
-
411
- -- Query: Get all children
412
- SELECT * FROM memories WHERE parent_id = ?
413
-
414
- -- Query: Get breadcrumb path
415
- WITH RECURSIVE ancestors AS (...)
416
- ```
417
-
418
- **Use Cases:**
419
- - Project hierarchies
420
- - Conversation threading
421
- - Multi-step task tracking
422
-
423
- ---
424
-
425
- ### Layer 3: Knowledge Graph (GraphRAG)
426
-
427
- **Responsibility:** Relationship discovery, auto-clustering, entity extraction
428
-
429
- **Components:**
430
-
431
- 1. **graph_engine.py** - Graph construction and queries
432
- - TF-IDF entity extraction
433
- - Leiden clustering algorithm
434
- - Cluster naming via LLM patterns
435
- - Relationship discovery
436
-
437
- **Algorithm Pipeline:**
438
-
439
- ```
440
- Memories → TF-IDF → Entity Extraction → Similarity Matrix → Leiden Clustering → Named Clusters
441
- ```
442
-
443
- **Step-by-Step:**
444
-
445
- 1. **Entity Extraction (TF-IDF):**
446
- ```python
447
- # Extract top terms from each memory
448
- tfidf_vectorizer = TfidfVectorizer(
449
- max_features=20,
450
- stop_words='english',
451
- ngram_range=(1, 2)
452
- )
453
- entities = tfidf_vectorizer.fit_transform(memories)
454
- ```
455
-
456
- 2. **Similarity Calculation:**
457
- ```python
458
- # Cosine similarity between memories
459
- similarity_matrix = cosine_similarity(entities)
460
- ```
461
-
462
- 3. **Leiden Clustering:**
463
- ```python
464
- # Community detection in similarity graph
465
- import leidenalg
466
- communities = leidenalg.find_partition(graph, resolution=1.0)
467
- ```
468
-
469
- 4. **Auto-Naming:**
470
- ```python
471
- # Extract common terms from cluster members
472
- cluster_name = most_frequent_terms(cluster_memories)
473
- # Example: "Authentication & Security"
474
- ```
475
-
476
- **Performance:**
477
- - Build time: <30ms (20 memories)
478
- - Build time: ~2s (100 memories)
479
- - Query time: <10ms (related memories)
480
-
481
- **Output:**
482
- - Clusters with auto-generated names
483
- - Entity relationships
484
- - Related memory suggestions
485
-
486
- ---
487
-
488
- ### Layer 4: Pattern Learning (xMemory-inspired)
489
-
490
- **Responsibility:** Learn user preferences, coding style, terminology
491
-
492
- **Components:**
493
-
494
- 1. **pattern_learner.py** - Pattern extraction and scoring
495
- - Frequency analysis
496
- - Context analysis
497
- - Confidence scoring
498
- - Identity profile generation
499
-
500
- **Analysis Categories:**
501
-
502
- ```python
503
- CATEGORIES = {
504
- "preferences": {
505
- "framework": ["React", "Vue", "Angular", ...],
506
- "language": ["Python", "JavaScript", "Go", ...],
507
- "architecture": ["microservices", "monolith", ...],
508
- "security": ["JWT", "OAuth", "API keys", ...]
509
- },
510
- "style": {
511
- "code_preferences": ["functional", "OOP", ...],
512
- "priorities": ["performance", "readability", ...]
513
- },
514
- "terminology": {
515
- "common_terms": [...],
516
- "technical_vocabulary": [...]
517
- }
518
- }
519
- ```
520
-
521
- **Confidence Scoring:**
522
-
523
- ```python
524
- confidence = frequency / total_memories
525
-
526
- # Example:
527
- # "React" appears in 6/10 memories → 60% confidence
528
- # "Vue" appears in 1/10 memories → 10% confidence
529
- ```
530
-
531
- **Output Format:**
532
-
533
- ```json
534
- {
535
- "preferences": {
536
- "framework": {
537
- "React": 0.60,
538
- "Angular": 0.20
539
- },
540
- "language": {
541
- "Python": 0.50,
542
- "JavaScript": 0.40
543
- }
544
- },
545
- "style": {
546
- "priorities": {
547
- "performance": 0.53,
548
- "readability": 0.30
549
- }
550
- }
551
- }
552
- ```
553
-
554
- **Use Cases:**
555
- - Personalized AI assistant context
556
- - Style guide generation
557
- - Skill tracking
558
- - Learning trajectory analysis
559
-
560
- ---
561
-
562
- ## Data Flow
563
-
564
- ### Write Path (Adding Memory)
565
-
566
- ```
567
- User Input
568
-
569
- memory_store_v2.py: add()
570
-
571
- SQLite: INSERT into memories table
572
-
573
- FTS5: Update full-text index
574
-
575
- [Optional] tree_manager: Set parent_id
576
-
577
- [Async] graph_engine: Rebuild trigger
578
-
579
- [Async] pattern_learner: Update trigger
580
- ```
581
-
582
- ### Read Path (Search)
583
-
584
- ```
585
- User Query
586
-
587
- memory_store_v2.py: search()
588
-
589
- SQLite FTS5: Full-text search
590
-
591
- Results + Metadata
592
-
593
- [Optional] graph_engine: Enrich with related memories
594
-
595
- [Optional] pattern_learner: Add context suggestions
596
-
597
- User Output
598
- ```
599
-
600
- ### Graph Build Path
601
-
602
- ```
603
- Trigger: Manual or scheduled
604
-
605
- graph_engine.py: build()
606
-
607
- Fetch all memories from SQLite
608
-
609
- TF-IDF: Extract entities
610
-
611
- Cosine Similarity: Calculate relationships
612
-
613
- Leiden Algorithm: Detect communities
614
-
615
- Auto-naming: Generate cluster names
616
-
617
- SQLite: INSERT into graph_clusters, graph_cluster_members
618
-
619
- Statistics output
620
- ```
621
-
622
- ---
623
-
624
- ## Technology Stack
625
-
626
- ### Core Technologies
627
-
628
- | Component | Technology | Version | Purpose |
629
- |-----------|-----------|---------|---------|
630
- | Database | SQLite | 3.35+ | Persistent storage |
631
- | Search | FTS5 | Built-in | Full-text search |
632
- | Language | Python | 3.8+ | Core implementation |
633
- | Clustering | Leiden Algorithm | Custom impl | Community detection |
634
- | Entity Extraction | TF-IDF | scikit-learn-style | Term importance |
635
- | CLI | Bash scripts | - | User commands |
636
-
637
- ### Python Standard Library Only
638
-
639
- **No external dependencies required for core features:**
640
- - `sqlite3` - Database
641
- - `json` - Configuration, metadata
642
- - `re` - Text processing
643
- - `datetime` - Timestamps
644
- - `hashlib` - ID generation
645
- - `collections` - Data structures
646
-
647
- **Optional (for advanced features):**
648
- - `scikit-learn` - Full TF-IDF implementation
649
- - `leidenalg` - Advanced clustering
650
-
651
- **Fallback implementations provided** for systems without optional dependencies.
652
-
653
- ---
654
-
655
- ## Design Decisions
656
-
657
- ### Decision 1: SQLite Over NoSQL
658
-
659
- **Reasoning:**
660
- - Local-first: No server setup required
661
- - ACID transactions: Data integrity guaranteed
662
- - FTS5: Built-in full-text search
663
- - Widely available: Pre-installed on most systems
664
- - Zero configuration: Works out of the box
665
-
666
- **Trade-offs:**
667
- - Single-writer: Not suitable for high-concurrency scenarios
668
- - Limited to local disk: No distributed access (feature, not bug)
669
-
670
- ---
671
-
672
- ### Decision 2: 7-Layer Additive Architecture
673
-
674
- **Reasoning:**
675
- - Modularity: Each layer can be disabled independently
676
- - Progressive enhancement: System works even if upper layers fail
677
- - Clear separation: Easy to understand and maintain
678
- - Testability: Each layer can be tested in isolation
679
- - Universal access: Layers 5-7 enable multi-IDE support without changing core
680
-
681
- **Trade-offs:**
682
- - Slight redundancy: Some data duplicated across layers
683
- - Build time: Graph/pattern layers require periodic rebuilds
684
- - More installation complexity: Auto-detection for 16+ IDEs
685
-
686
- ---
687
-
688
- ### Decision 3: Local-Only, No External APIs
689
-
690
- **Reasoning:**
691
- - Privacy: User data never leaves machine
692
- - Reliability: No internet dependency
693
- - Speed: No network latency
694
- - Cost: No API bills
695
-
696
- **Trade-offs:**
697
- - No cloud sync: Multi-device requires manual export/import
698
- - Limited ML: No access to large models (by design)
699
-
700
- ---
701
-
702
- ### Decision 4: TF-IDF + Leiden Clustering
703
-
704
- **Reasoning:**
705
- - TF-IDF: Fast, lightweight, no training required
706
- - Leiden: Better than Louvain, finds quality communities
707
- - Deterministic: Same input = same output
708
- - Scalable: O(n log n) complexity
709
-
710
- **Alternatives considered:**
711
- - Vector embeddings: Too heavy, requires models
712
- - LDA: Slower, less interpretable
713
- - Simple keyword matching: Too simplistic
714
-
715
- ---
716
-
717
- ### Decision 5: Confidence Scoring Over Binary Classification
718
-
719
- **Reasoning:**
720
- - Nuance: Captures uncertainty in patterns
721
- - User control: Filter by confidence threshold
722
- - Adaptability: Patterns evolve as memories grow
723
- - Transparency: Users see why patterns are suggested
724
-
725
- **Example:**
726
- ```
727
- React: 60% confidence → High priority suggestion
728
- Vue: 10% confidence → Low priority, exploratory
729
- ```
730
-
731
- ---
732
-
733
- ## Performance Characteristics
734
-
735
- ### Time Complexity
736
-
737
- | Operation | Complexity | Typical Time |
738
- |-----------|-----------|--------------|
739
- | Add memory | O(1) | <10ms |
740
- | Search (FTS5) | O(log n) | ~11ms median (100 memories) |
741
- | Graph build | O(n²) worst, O(n log n) avg | ~2s (100 memories) |
742
- | Pattern update | O(n) | <2s (100 memories) |
743
- | Find related | O(1) | <10ms |
744
-
745
- ### Space Complexity
746
-
747
- | Component | Storage | Notes |
748
- |-----------|---------|-------|
749
- | Raw memories | ~1KB/memory | Typical text memory |
750
- | FTS5 index | ~30% overhead | Full-text search index |
751
- | Graph data | ~100 bytes/memory | Cluster memberships |
752
- | Patterns | ~1KB total | Aggregate statistics |
753
- | Compression (Tier 2) | 60% reduction | Summarized old memories |
754
- | Compression (Tier 3) | 96% reduction | Archived to JSON |
755
-
756
- **Example:** 500 memories ≈ 500KB raw + 150KB index + 50KB graph = ~700KB total
757
-
758
- ---
759
-
760
- ## Security & Privacy
761
-
762
- ### Threat Model
763
-
764
- **Assumptions:**
765
- - User has physical access to machine
766
- - Local filesystem is trusted
767
- - No network threats (local-only)
768
-
769
- **Protections:**
770
-
771
- 1. **No External Data Leaks:**
772
- - Zero API calls
773
- - No telemetry
774
- - No auto-updates
775
-
776
- 2. **Data Integrity:**
777
- - SQLite ACID transactions
778
- - Automatic backups before resets
779
-
780
- 3. **Access Control:**
781
- - Relies on filesystem permissions
782
- - Standard Unix/macOS security model
783
-
784
- **Not Protected Against:**
785
- - Physical access to machine
786
- - Root/admin access
787
- - Filesystem malware
788
-
789
- **Recommendation:** Use full-disk encryption for sensitive data.
790
-
791
- ---
792
-
793
- ## Scalability
794
-
795
- ### Current Limits (Tested)
796
-
797
- | Memories | Build Time | Search Time (median) | Database Size |
798
- |----------|-----------|----------------------|---------------|
799
- | 100 | 0.28s | 10.6ms | ~150KB |
800
- | 500 | ~5s | 65.2ms | ~700KB |
801
- | 1,000 | 10.6s | 124.3ms | 1.50 MB |
802
- | 5,000 | 277s | 1,172ms | ~6.8 MB |
803
-
804
- ### Scaling Strategies
805
-
806
- **For 1000+ memories:**
807
- 1. **Profile Splitting:** Separate contexts (work, personal, learning)
808
- 2. **Compression:** Auto-archive old memories (Tier 3)
809
- 3. **Incremental Builds:** Graph updates instead of full rebuilds
810
- 4. **Selective Loading:** Load only active profile
811
-
812
- **Future Optimizations:**
813
- - Graph delta updates (vs. full rebuild)
814
- - Lazy pattern loading
815
- - Memory pagination for large searches
816
-
817
- ---
818
-
819
- ## Extension Points
820
-
821
- ### Adding New Layers
822
-
823
- ```python
824
- # Layer 5 example: Predictive recommendations
825
- class RecommendationEngine:
826
- def suggest_next_memory(self, context):
827
- # Use patterns + graph to predict what user might add next
828
- pass
829
- ```
830
-
831
- ### Adding New Pattern Categories
832
-
833
- ```python
834
- # In pattern_learner.py
835
- CATEGORIES["preferences"]["testing"] = [
836
- "pytest", "jest", "unittest", "TDD", "BDD"
837
- ]
838
- ```
839
-
840
- ### Custom Clustering Algorithms
841
-
842
- ```python
843
- # In graph_engine.py
844
- def custom_clustering(similarity_matrix):
845
- # Implement alternative clustering
846
- pass
847
- ```
848
-
849
- ---
850
-
851
- ## Conclusion
852
-
853
- SuperLocalMemory V2's architecture provides:
854
- - **Simplicity:** Standard tools (SQLite, Python stdlib)
855
- - **Intelligence:** Auto-discovery of patterns and relationships
856
- - **Privacy:** 100% local, zero external dependencies
857
- - **Modularity:** Independent layers, clear interfaces
858
- - **Performance:** Sub-second operations for typical workloads
859
-
860
- **Design Philosophy:** Start simple (Layer 1), add intelligence progressively (Layers 2-4), enable universal access (Layers 5-7), maintain local-first principles throughout.
861
-
862
- ---
863
-
864
- ## Further Reading
865
-
866
- - [Compression System](COMPRESSION-README.md)
867
- - [CLI Commands Reference](CLI-COMMANDS-REFERENCE.md)
868
- - [MCP Troubleshooting](MCP-TROUBLESHOOTING.md)
869
- - [Universal Integration Guide](UNIVERSAL-INTEGRATION.md)
870
- - [Wiki: Knowledge Graph Guide](https://github.com/qualixar/superlocalmemory/wiki/Knowledge-Graph-Guide)
871
- - [Wiki: Pattern Learning](https://github.com/qualixar/superlocalmemory/wiki/Pattern-Learning-Explained)
872
-
873
- ---
874
-
875
- ## Author
876
-
877
- **Varun Pratap Bhardwaj**
878
- *Solution Architect*
879
-
880
- SuperLocalMemory V2 - Intelligent local memory system for AI coding assistants.
881
-
882
- ---
883
-
884
- **Questions about architecture?**
885
-
886
- See [CONTRIBUTING.md](CONTRIBUTING.md) for development discussions or open an issue on GitHub.