superlocalmemory 2.7.5 → 2.8.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 (174) hide show
  1. package/CHANGELOG.md +120 -155
  2. package/README.md +115 -89
  3. package/api_server.py +2 -12
  4. package/docs/PATTERN-LEARNING.md +64 -199
  5. package/docs/example_graph_usage.py +4 -6
  6. package/install.ps1 +226 -0
  7. package/install.sh +59 -0
  8. package/mcp_server.py +83 -7
  9. package/package.json +3 -10
  10. package/scripts/generate-thumbnails.py +3 -5
  11. package/skills/slm-build-graph/SKILL.md +1 -1
  12. package/skills/slm-list-recent/SKILL.md +1 -1
  13. package/skills/slm-recall/SKILL.md +1 -1
  14. package/skills/slm-remember/SKILL.md +1 -1
  15. package/skills/slm-show-patterns/SKILL.md +1 -1
  16. package/skills/slm-status/SKILL.md +1 -1
  17. package/skills/slm-switch-profile/SKILL.md +1 -1
  18. package/src/agent_registry.py +7 -18
  19. package/src/auth_middleware.py +3 -5
  20. package/src/auto_backup.py +3 -7
  21. package/src/behavioral/__init__.py +49 -0
  22. package/src/behavioral/behavioral_listener.py +203 -0
  23. package/src/behavioral/behavioral_patterns.py +275 -0
  24. package/src/behavioral/cross_project_transfer.py +206 -0
  25. package/src/behavioral/outcome_inference.py +194 -0
  26. package/src/behavioral/outcome_tracker.py +193 -0
  27. package/src/behavioral/tests/__init__.py +4 -0
  28. package/src/behavioral/tests/test_behavioral_integration.py +108 -0
  29. package/src/behavioral/tests/test_behavioral_patterns.py +150 -0
  30. package/src/behavioral/tests/test_cross_project_transfer.py +142 -0
  31. package/src/behavioral/tests/test_mcp_behavioral.py +139 -0
  32. package/src/behavioral/tests/test_mcp_report_outcome.py +117 -0
  33. package/src/behavioral/tests/test_outcome_inference.py +107 -0
  34. package/src/behavioral/tests/test_outcome_tracker.py +96 -0
  35. package/src/cache_manager.py +4 -6
  36. package/src/compliance/__init__.py +48 -0
  37. package/src/compliance/abac_engine.py +149 -0
  38. package/src/compliance/abac_middleware.py +116 -0
  39. package/src/compliance/audit_db.py +215 -0
  40. package/src/compliance/audit_logger.py +148 -0
  41. package/src/compliance/retention_manager.py +289 -0
  42. package/src/compliance/retention_scheduler.py +186 -0
  43. package/src/compliance/tests/__init__.py +4 -0
  44. package/src/compliance/tests/test_abac_enforcement.py +95 -0
  45. package/src/compliance/tests/test_abac_engine.py +124 -0
  46. package/src/compliance/tests/test_abac_mcp_integration.py +118 -0
  47. package/src/compliance/tests/test_audit_db.py +123 -0
  48. package/src/compliance/tests/test_audit_logger.py +98 -0
  49. package/src/compliance/tests/test_mcp_audit.py +128 -0
  50. package/src/compliance/tests/test_mcp_retention_policy.py +125 -0
  51. package/src/compliance/tests/test_retention_manager.py +131 -0
  52. package/src/compliance/tests/test_retention_scheduler.py +99 -0
  53. package/src/db_connection_manager.py +2 -12
  54. package/src/embedding_engine.py +61 -669
  55. package/src/embeddings/__init__.py +47 -0
  56. package/src/embeddings/cache.py +70 -0
  57. package/src/embeddings/cli.py +113 -0
  58. package/src/embeddings/constants.py +47 -0
  59. package/src/embeddings/database.py +91 -0
  60. package/src/embeddings/engine.py +247 -0
  61. package/src/embeddings/model_loader.py +145 -0
  62. package/src/event_bus.py +3 -13
  63. package/src/graph/__init__.py +36 -0
  64. package/src/graph/build_helpers.py +74 -0
  65. package/src/graph/cli.py +87 -0
  66. package/src/graph/cluster_builder.py +188 -0
  67. package/src/graph/cluster_summary.py +148 -0
  68. package/src/graph/constants.py +47 -0
  69. package/src/graph/edge_builder.py +162 -0
  70. package/src/graph/entity_extractor.py +95 -0
  71. package/src/graph/graph_core.py +226 -0
  72. package/src/graph/graph_search.py +231 -0
  73. package/src/graph/hierarchical.py +207 -0
  74. package/src/graph/schema.py +99 -0
  75. package/src/graph_engine.py +45 -1451
  76. package/src/hnsw_index.py +3 -7
  77. package/src/hybrid_search.py +36 -683
  78. package/src/learning/__init__.py +27 -12
  79. package/src/learning/adaptive_ranker.py +50 -12
  80. package/src/learning/cross_project_aggregator.py +2 -12
  81. package/src/learning/engagement_tracker.py +2 -12
  82. package/src/learning/feature_extractor.py +175 -43
  83. package/src/learning/feedback_collector.py +7 -12
  84. package/src/learning/learning_db.py +180 -12
  85. package/src/learning/project_context_manager.py +2 -12
  86. package/src/learning/source_quality_scorer.py +2 -12
  87. package/src/learning/synthetic_bootstrap.py +2 -12
  88. package/src/learning/tests/__init__.py +2 -0
  89. package/src/learning/tests/test_adaptive_ranker.py +2 -6
  90. package/src/learning/tests/test_adaptive_ranker_v28.py +60 -0
  91. package/src/learning/tests/test_aggregator.py +2 -6
  92. package/src/learning/tests/test_auto_retrain_v28.py +35 -0
  93. package/src/learning/tests/test_e2e_ranking_v28.py +82 -0
  94. package/src/learning/tests/test_feature_extractor_v28.py +93 -0
  95. package/src/learning/tests/test_feedback_collector.py +2 -6
  96. package/src/learning/tests/test_learning_db.py +2 -6
  97. package/src/learning/tests/test_learning_db_v28.py +110 -0
  98. package/src/learning/tests/test_learning_init_v28.py +48 -0
  99. package/src/learning/tests/test_outcome_signals.py +48 -0
  100. package/src/learning/tests/test_project_context.py +2 -6
  101. package/src/learning/tests/test_schema_migration.py +319 -0
  102. package/src/learning/tests/test_signal_inference.py +11 -13
  103. package/src/learning/tests/test_source_quality.py +2 -6
  104. package/src/learning/tests/test_synthetic_bootstrap.py +3 -7
  105. package/src/learning/tests/test_workflow_miner.py +2 -6
  106. package/src/learning/workflow_pattern_miner.py +2 -12
  107. package/src/lifecycle/__init__.py +54 -0
  108. package/src/lifecycle/bounded_growth.py +239 -0
  109. package/src/lifecycle/compaction_engine.py +226 -0
  110. package/src/lifecycle/lifecycle_engine.py +302 -0
  111. package/src/lifecycle/lifecycle_evaluator.py +225 -0
  112. package/src/lifecycle/lifecycle_scheduler.py +130 -0
  113. package/src/lifecycle/retention_policy.py +285 -0
  114. package/src/lifecycle/tests/__init__.py +4 -0
  115. package/src/lifecycle/tests/test_bounded_growth.py +193 -0
  116. package/src/lifecycle/tests/test_compaction.py +179 -0
  117. package/src/lifecycle/tests/test_lifecycle_engine.py +137 -0
  118. package/src/lifecycle/tests/test_lifecycle_evaluation.py +177 -0
  119. package/src/lifecycle/tests/test_lifecycle_scheduler.py +127 -0
  120. package/src/lifecycle/tests/test_lifecycle_search.py +109 -0
  121. package/src/lifecycle/tests/test_mcp_compact.py +149 -0
  122. package/src/lifecycle/tests/test_mcp_lifecycle_status.py +114 -0
  123. package/src/lifecycle/tests/test_retention_policy.py +162 -0
  124. package/src/mcp_tools_v28.py +280 -0
  125. package/src/memory-profiles.py +2 -12
  126. package/src/memory-reset.py +2 -12
  127. package/src/memory_compression.py +2 -12
  128. package/src/memory_store_v2.py +76 -20
  129. package/src/migrate_v1_to_v2.py +2 -12
  130. package/src/pattern_learner.py +29 -975
  131. package/src/patterns/__init__.py +24 -0
  132. package/src/patterns/analyzers.py +247 -0
  133. package/src/patterns/learner.py +267 -0
  134. package/src/patterns/scoring.py +167 -0
  135. package/src/patterns/store.py +223 -0
  136. package/src/patterns/terminology.py +138 -0
  137. package/src/provenance_tracker.py +4 -14
  138. package/src/query_optimizer.py +4 -6
  139. package/src/rate_limiter.py +2 -6
  140. package/src/search/__init__.py +20 -0
  141. package/src/search/cli.py +77 -0
  142. package/src/search/constants.py +26 -0
  143. package/src/search/engine.py +239 -0
  144. package/src/search/fusion.py +122 -0
  145. package/src/search/index_loader.py +112 -0
  146. package/src/search/methods.py +162 -0
  147. package/src/search_engine_v2.py +4 -6
  148. package/src/setup_validator.py +7 -13
  149. package/src/subscription_manager.py +2 -12
  150. package/src/tree/__init__.py +59 -0
  151. package/src/tree/builder.py +183 -0
  152. package/src/tree/nodes.py +196 -0
  153. package/src/tree/queries.py +252 -0
  154. package/src/tree/schema.py +76 -0
  155. package/src/tree_manager.py +10 -711
  156. package/src/trust/__init__.py +45 -0
  157. package/src/trust/constants.py +66 -0
  158. package/src/trust/queries.py +157 -0
  159. package/src/trust/schema.py +95 -0
  160. package/src/trust/scorer.py +299 -0
  161. package/src/trust/signals.py +95 -0
  162. package/src/trust_scorer.py +39 -697
  163. package/src/webhook_dispatcher.py +2 -12
  164. package/ui/app.js +1 -1
  165. package/ui/index.html +3 -0
  166. package/ui/js/agents.js +1 -1
  167. package/ui/js/core.js +21 -5
  168. package/ui/js/profiles.js +29 -7
  169. package/ui_server.py +2 -14
  170. package/ATTRIBUTION.md +0 -140
  171. package/docs/ARCHITECTURE-V2.5.md +0 -190
  172. package/docs/GRAPH-ENGINE.md +0 -503
  173. package/docs/architecture-diagram.drawio +0 -405
  174. package/docs/plans/2026-02-13-benchmark-suite.md +0 -1349
@@ -1,141 +1,42 @@
1
- # Pattern Learner - Identity Profile Extraction
1
+ # Pattern Learning
2
2
 
3
3
  ## Overview
4
4
 
5
- The Pattern Learner is Layer 4 of the SuperLocalMemory system. It automatically learns user preferences, coding style, and terminology from stored memories using local TF-IDF and heuristic analysis.
5
+ The Pattern Learner is Layer 4 of the SuperLocalMemory system. It automatically learns user preferences, coding style, and terminology from stored memories all processed locally with no external API calls.
6
6
 
7
7
  **No external APIs. All processing is local.**
8
8
 
9
- ## Architecture
9
+ > For technical details on the learning algorithms, see our published research: https://zenodo.org/records/18709670
10
10
 
11
- ```
12
- ┌─────────────────────────────────────────────────────────┐
13
- │ PatternLearner │
14
- │ │
15
- │ ┌──────────────────┐ ┌──────────────────┐ │
16
- │ │ Frequency │ │ Context │ │
17
- │ │ Analyzer │ │ Analyzer │ │
18
- │ └──────────────────┘ └──────────────────┘ │
19
- │ │
20
- │ ┌──────────────────┐ ┌──────────────────┐ │
21
- │ │ Terminology │ │ Confidence │ │
22
- │ │ Learner │ │ Scorer │ │
23
- │ └──────────────────┘ └──────────────────┘ │
24
- │ │
25
- │ ┌──────────────────┐ │
26
- │ │ Pattern Store │ │
27
- │ └──────────────────┘ │
28
- └─────────────────────────────────────────────────────────┘
29
- ```
30
-
31
- ## Components
32
-
33
- ### 1. FrequencyAnalyzer
34
- **Purpose:** Detect technology preferences via frequency counting
35
-
36
- **Categories tracked:**
37
- - Frontend frameworks (React, Next.js, Vue, Angular, Svelte)
38
- - Backend frameworks (Express, FastAPI, Django, Flask)
39
- - Databases (PostgreSQL, MySQL, MongoDB, Redis)
40
- - State management (Redux, Context, Zustand)
41
- - Styling (Tailwind, CSS Modules, Styled Components)
42
- - Languages (Python, JavaScript, TypeScript, Go, Rust)
43
- - Deployment (Docker, Kubernetes, Vercel, AWS)
44
- - Testing (Jest, Pytest, Vitest, Cypress)
45
-
46
- **Algorithm:**
47
- 1. Count keyword mentions across all memories
48
- 2. Calculate relative frequency (top choice vs others)
49
- 3. Create pattern if confidence > 60% and count >= 3
50
-
51
- **Example output:**
52
- ```
53
- Pattern: frontend_framework
54
- Value: "Next.js over React"
55
- Confidence: 85%
56
- Evidence: 12 memories
57
- ```
58
-
59
- ### 2. ContextAnalyzer
60
- **Purpose:** Detect coding style patterns from context
61
-
62
- **Patterns tracked:**
63
- - **Optimization priority:** Performance vs Readability
64
- - **Error handling:** Explicit vs Permissive
65
- - **Testing approach:** Comprehensive vs Minimal
66
- - **Code organization:** Modular vs Monolithic
67
-
68
- **Algorithm:**
69
- 1. Define indicator keywords for each style dimension
70
- 2. Count mentions in memory contexts
71
- 3. Determine dominant style if confidence > 65%
72
-
73
- **Example output:**
74
- ```
75
- Pattern: optimization_priority
76
- Value: "Performance over readability"
77
- Confidence: 90%
78
- Evidence: 15 memories
79
- ```
80
-
81
- ### 3. TerminologyLearner
82
- **Purpose:** Learn user-specific definitions of ambiguous terms
83
-
84
- **Terms tracked:**
85
- - optimize, refactor, clean, simple
86
- - mvp, prototype, scale, production-ready
87
- - fix, improve, update, enhance
88
-
89
- **Algorithm:**
90
- 1. Extract 100-char context window around each term mention
91
- 2. Analyze co-occurring words across contexts
92
- 3. Apply heuristic rules to determine meaning
93
- 4. Require 3+ examples for confidence
94
-
95
- **Example output:**
96
- ```
97
- Pattern: optimize
98
- Value: "Performance optimization (speed/latency)"
99
- Confidence: 90%
100
- Evidence: 15 memories
101
- ```
102
-
103
- ### 4. ConfidenceScorer
104
- **Purpose:** Calculate reliability scores for patterns
11
+ ---
105
12
 
106
- **Formula:**
107
- ```python
108
- confidence = (evidence_count / total_memories) * recency_bonus * distribution_factor
13
+ ## What It Learns
109
14
 
110
- Where:
111
- - evidence_count: Number of memories supporting pattern
112
- - total_memories: Total memories in database
113
- - recency_bonus: 1.2 if >50% evidence is from last 30 days, else 1.0
114
- - distribution_factor: 1.1 if memories span >7 days, 0.8 if <3 memories
115
- ```
15
+ Pattern learning analyzes your saved memories and builds a profile of your preferences across multiple dimensions:
116
16
 
117
- **Conservative by design:** Low confidence with small datasets is correct behavior.
17
+ - **Technology preferences** Which frameworks, languages, and tools appear most often in your memories
18
+ - **Architecture choices** — Your preferred patterns (e.g., REST vs GraphQL, microservices vs monolith)
19
+ - **Security approaches** — Your go-to authentication and authorization patterns
20
+ - **Coding style** — Performance vs readability, testing approach, code organization
21
+ - **Domain terminology** — How you define common terms in your project context
118
22
 
119
- ### 5. PatternStore
120
- **Purpose:** Persist patterns to database
23
+ Each detected preference gets a confidence score based on the supporting evidence. The system is conservative by design — low confidence with small datasets is correct behavior, not a bug.
121
24
 
122
- **Tables:**
123
- - `identity_patterns`: Pattern definitions with confidence scores
124
- - `pattern_examples`: Representative excerpts showing patterns
25
+ ---
125
26
 
126
27
  ## Usage
127
28
 
128
29
  ### Command Line Interface
129
30
 
130
31
  ```bash
131
- # Full pattern update (run weekly)
32
+ # Full pattern update (run weekly or after bulk imports)
132
33
  python pattern_learner.py update
133
34
 
134
35
  # List learned patterns
135
36
  python pattern_learner.py list [min_confidence]
136
- # Example: python pattern_learner.py list 0.7 # Show patterns with >70% confidence
37
+ # Example: python pattern_learner.py list 0.7
137
38
 
138
- # Get context for Claude injection
39
+ # Get context formatted for AI assistant injection
139
40
  python pattern_learner.py context [min_confidence]
140
41
  # Example: python pattern_learner.py context 0.6
141
42
 
@@ -160,13 +61,16 @@ learner.on_new_memory(memory_id=42)
160
61
  # Query patterns
161
62
  patterns = learner.get_patterns(min_confidence=0.7)
162
63
 
163
- # Get formatted context for Claude
64
+ # Get formatted context for AI injection
164
65
  context = learner.get_identity_context(min_confidence=0.7)
165
66
  ```
166
67
 
68
+ ---
69
+
167
70
  ## Example Output
168
71
 
169
72
  ### Pattern List
73
+
170
74
  ```
171
75
  Type Category Pattern Confidence Evidence
172
76
  -----------------------------------------------------------------------------------------------
@@ -177,51 +81,42 @@ terminology general Optimize: Performance optimi... 90% 15
177
81
  style general Error Handling: Explicit err... 78% 9
178
82
  ```
179
83
 
180
- ### Claude Context Injection
84
+ ### AI Context Injection
85
+
181
86
  ```markdown
182
87
  ## Working with User - Learned Patterns
183
88
 
184
89
  **Technology Preferences:**
185
90
  - **Frontend Framework:** Next.js over React (confidence: 85%, 12 examples)
186
91
  - **Database:** PostgreSQL (confidence: 72%, 8 examples)
187
- - **State Management:** Redux for complex, Context for simple (confidence: 68%, 7 examples)
188
92
 
189
93
  **Coding Style:**
190
94
  - **Optimization Priority:** Performance over readability (confidence: 90%, 15 examples)
191
95
  - **Error Handling:** Explicit error boundaries (confidence: 78%, 9 examples)
192
- - **Code Organization:** Modular organization (confidence: 75%, 11 examples)
193
96
 
194
97
  **Terminology:**
195
98
  - **Optimize:** Performance optimization (speed/latency) (confidence: 90%, 15 examples)
196
- - **Refactor:** Architecture change, not just renaming (confidence: 82%, 10 examples)
197
- - **MVP:** Core features only, no polish (confidence: 85%, 8 examples)
198
99
  ```
199
100
 
200
- ## Confidence Calibration
101
+ ---
201
102
 
202
- ### Small Datasets (<20 memories)
203
- - **Expected confidence:** 10-40%
204
- - **Reason:** Limited evidence means low certainty
205
- - **Recommendation:** Use min_confidence=0.1 for exploration
103
+ ## Confidence Calibration
206
104
 
207
- ### Medium Datasets (20-100 memories)
208
- - **Expected confidence:** 40-70%
209
- - **Reason:** Patterns emerging but still developing
210
- - **Recommendation:** Use min_confidence=0.5 for reliable patterns
105
+ | Dataset Size | Expected Confidence | Recommended Threshold |
106
+ |-------------|--------------------|-----------------------|
107
+ | Under 20 memories | 10-40% | Use 0.1 for exploration |
108
+ | 20-100 memories | 40-70% | Use 0.5 for reliable patterns |
109
+ | Over 100 memories | 70-95% | Use 0.7 for high-confidence patterns |
211
110
 
212
- ### Large Datasets (>100 memories)
213
- - **Expected confidence:** 70-95%
214
- - **Reason:** Strong evidence across time
215
- - **Recommendation:** Use min_confidence=0.7 for high-confidence patterns
111
+ The system is designed to be conservative. Low confidence with small datasets is correct behavior.
216
112
 
217
- **Note:** The system is designed to be conservative. Low confidence with small datasets is correct behavior, not a bug.
113
+ ---
218
114
 
219
115
  ## Pattern Update Schedule
220
116
 
221
117
  ### Incremental (on `/remember`)
222
- - Quick check for pattern updates
223
- - For datasets >50 memories, defers to weekly update
224
- - For small datasets, triggers full update
118
+ - Quick check for pattern updates on every new memory
119
+ - For large datasets, defers to weekly consolidation
225
120
 
226
121
  ### Weekly Consolidation
227
122
  - Full re-analysis of all memories
@@ -231,13 +126,15 @@ style general Error Handling: Explicit err... 78% 9
231
126
  0 2 * * 0 cd ~/.claude-memory && python3 pattern_learner.py update >> pattern_updates.log 2>&1
232
127
  ```
233
128
 
129
+ ---
130
+
234
131
  ## Integration with AI Assistants
235
132
 
236
- ### Context Injection
133
+ ### Automatic Context Injection
134
+
237
135
  The `get_identity_context()` method formats patterns for any AI assistant's context window:
238
136
 
239
137
  ```python
240
- # In your AI assistant integration:
241
138
  learner = PatternLearner()
242
139
  identity_context = learner.get_identity_context(min_confidence=0.7)
243
140
 
@@ -249,76 +146,64 @@ prompt = f"""
249
146
  """
250
147
  ```
251
148
 
149
+ **Works with:** Claude CLI, GPT, local LLMs, or any AI assistant that accepts context.
150
+
252
151
  ### Benefits
253
152
  1. **Personalized responses:** AI understands your technology preferences
254
153
  2. **Consistent terminology:** AI uses terms the way you define them
255
154
  3. **Style matching:** AI respects your coding style priorities
256
- 4. **Efficient communication:** No need to repeat preferences
257
-
258
- **Works with:** Claude CLI, GPT, local LLMs, or any AI assistant that accepts context.
259
-
260
- ## Implementation Details
155
+ 4. **Efficient communication:** No need to repeat preferences every session
261
156
 
262
- ### Technology Stack
263
- - **Language:** Python 3.8+
264
- - **Database:** SQLite3 (local)
265
- - **NLP:** sklearn TfidfVectorizer (optional, local)
266
- - **No external APIs**
267
-
268
- ### Files
269
- - `pattern_learner.py` - Main implementation (850 lines)
270
- - `memory.db` - SQLite database (includes pattern tables)
271
- - Schema tables:
272
- - `identity_patterns` - Pattern definitions
273
- - `pattern_examples` - Representative excerpts
157
+ ---
274
158
 
275
- ### Performance
276
- - **Full analysis (100 memories):** ~2-3 seconds
277
- - **Query patterns:** <10ms
278
- - **Database size:** ~1KB per pattern
159
+ ## Privacy & Security
279
160
 
280
- ## Security & Privacy
161
+ - **No external API calls** — all processing is local
162
+ - **All data stays local** — stored in `~/.claude-memory/`
163
+ - **SQL injection protected** — parameterized queries throughout
164
+ - **No credentials stored**
165
+ - **No network access required**
281
166
 
282
- ✅ **No external API calls**
283
- ✅ **All data stays local** (~/.claude-memory/)
284
- ✅ **SQL injection protected** (parameterized queries)
285
- ✅ **No credentials stored**
286
- ✅ **No network access required**
167
+ ---
287
168
 
288
169
  ## Limitations
289
170
 
290
- 1. **English-only:** Pattern detection optimized for English text
291
- 2. **Technical domains:** Works best with technical/coding memories
292
- 3. **Minimum memories:** Requires 3+ mentions for pattern detection
293
- 4. **Confidence calibration:** Conservative scoring (by design)
171
+ 1. **English-optimized:** Pattern detection works best with English text
172
+ 2. **Technical domains:** Works best with technical and coding memories
173
+ 3. **Minimum samples:** Requires a few mentions before a pattern is detected
174
+ 4. **Conservative scoring:** Low confidence with small datasets is by design
175
+
176
+ ---
294
177
 
295
178
  ## Troubleshooting
296
179
 
297
180
  ### "No patterns learned yet"
298
181
  - **Cause:** Not enough memories or technical content
299
- - **Solution:** Add 10-20 memories with technical details
182
+ - **Solution:** Add 10-20 memories with technical details about your preferences
300
183
 
301
184
  ### Low confidence scores
302
185
  - **Cause:** Small dataset or mixed evidence
303
- - **Solution:** Normal behavior. Use lower threshold (0.1-0.3) or add more memories
186
+ - **Solution:** Normal behavior. Lower the threshold (0.1-0.3) or add more memories
304
187
 
305
188
  ### Wrong preference detected
306
- - **Cause:** More mentions of alternative technology
307
- - **Solution:** Add more memories showing correct preference
189
+ - **Cause:** More mentions of alternative technology than your true preference
190
+ - **Solution:** Add more memories explicitly stating your correct preference
308
191
 
309
192
  ### Pattern not updating
310
193
  - **Cause:** Weekly update not run
311
194
  - **Solution:** Run `python pattern_learner.py update` manually
312
195
 
196
+ ---
197
+
313
198
  ## Testing
314
199
 
315
- Sample memories for testing pattern detection:
200
+ Sample memories for verifying pattern detection:
316
201
 
317
202
  ```bash
318
203
  # Add sample memories
319
204
  python memory_store.py add "Built with Next.js for better performance" --tags nextjs
320
205
  python memory_store.py add "Using Next.js on all new projects" --tags nextjs
321
- python memory_store.py add "Optimized API from 200ms to 50ms" --tags performance
206
+ python memory_store.py add "Optimized API from slow to fast" --tags performance
322
207
  python memory_store.py add "Performance is critical for UX" --tags performance
323
208
  python memory_store.py add "When I say optimize, I mean make it faster" --tags terminology
324
209
 
@@ -330,27 +215,7 @@ python pattern_learner.py list 0.1
330
215
  python pattern_learner.py context 0.1
331
216
  ```
332
217
 
333
- ## Future Enhancements
334
-
335
- Potential improvements (not yet implemented):
336
-
337
- 1. **True incremental updates:** Update only affected patterns
338
- 2. **Pattern decay:** Reduce confidence over time if not reinforced
339
- 3. **Conflict detection:** Identify contradicting patterns
340
- 4. **Cross-project patterns:** Detect project-specific vs global preferences
341
- 5. **Multi-language support:** Extend beyond English
342
- 6. **Pattern visualization:** Web UI for pattern exploration
343
-
344
- ## References
345
-
346
- Architecture documentation:
347
- - `docs/architecture/05-pattern-learner.md` - Detailed algorithm specification
348
- - `docs/architecture/01-database-schema.md` - Pattern table schemas
349
- - `docs/ARCHITECTURE.md` - System overview
350
-
351
- Research inspiration:
352
- - xMemory (arxiv.org/abs/2602.02007) - Semantic memory components
353
- - A-RAG - Agentic multi-level retrieval
218
+ ---
354
219
 
355
220
  ## License
356
221
 
@@ -358,6 +223,6 @@ Part of SuperLocalMemory system. See main project LICENSE.
358
223
 
359
224
  ---
360
225
 
361
- **Implementation Status:** Complete and tested
226
+ **Implementation Status:** Complete and tested
362
227
 
363
228
  **Last Updated:** 2026-02-05
@@ -1,16 +1,14 @@
1
1
  #!/usr/bin/env python3
2
- """
3
- SuperLocalMemory V2 - example_graph_usage.py
2
+ # SPDX-License-Identifier: MIT
3
+ # Copyright (c) 2026 SuperLocalMemory (superlocalmemory.com)
4
+ """SuperLocalMemory V2 - example_graph_usage.py
4
5
 
5
- Copyright (c) 2026 Varun Pratap Bhardwaj
6
6
  Solution Architect & Original Creator
7
7
 
8
- Licensed under MIT License (see LICENSE file)
9
- Repository: https://github.com/varun369/SuperLocalMemoryV2
8
+ (see LICENSE file)
10
9
 
11
10
  ATTRIBUTION REQUIRED: This notice must be preserved in all copies.
12
11
  """
13
-
14
12
  import sys
15
13
  from pathlib import Path
16
14
 
package/install.ps1 CHANGED
@@ -308,6 +308,232 @@ if ($userPath -notlike "*$installBinDir*") {
308
308
  Write-Host "INFO: PATH already configured" -ForegroundColor Yellow
309
309
  }
310
310
 
311
+ # ============================================================================
312
+ # MCP Auto-Configuration — Detect and configure AI tools
313
+ # ============================================================================
314
+ Write-Host ""
315
+ Write-Host "=================================================================="
316
+ Write-Host " Universal Integration - Auto-Detection "
317
+ Write-Host "=================================================================="
318
+ Write-Host ""
319
+ Write-Host "Detecting installed AI tools..."
320
+ Write-Host ""
321
+
322
+ # Use Continue for MCP section so missing tools don't abort the installer
323
+ $savedErrorAction = $ErrorActionPreference
324
+ $ErrorActionPreference = "Continue"
325
+
326
+ $DETECTED_TOOLS = @()
327
+
328
+ # Helper: configure MCP for a given tool using its template
329
+ function Configure-McpTool {
330
+ param(
331
+ [string]$ToolName,
332
+ [string]$TemplatePath,
333
+ [string]$ConfigPath
334
+ )
335
+
336
+ if (-not (Test-Path $TemplatePath)) {
337
+ Write-Host " WARNING: Template not found for $ToolName — skipping" -ForegroundColor Yellow
338
+ return
339
+ }
340
+
341
+ # Create config directory if needed
342
+ $configDir = Split-Path -Parent $ConfigPath
343
+ if (-not (Test-Path $configDir)) {
344
+ New-Item -ItemType Directory -Path $configDir -Force | Out-Null
345
+ }
346
+
347
+ # Check if already configured
348
+ if ((Test-Path $ConfigPath) -and (Select-String -Path $ConfigPath -Pattern "superlocalmemory" -Quiet -ErrorAction SilentlyContinue)) {
349
+ Write-Host " INFO: $ToolName already configured" -ForegroundColor Yellow
350
+ return
351
+ }
352
+
353
+ # Backup existing config with timestamp
354
+ if (Test-Path $ConfigPath) {
355
+ $timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
356
+ Copy-Item -Path $ConfigPath -Destination "$ConfigPath.backup.$timestamp" -Force
357
+ Write-Host " OK Backed up existing $ToolName config" -ForegroundColor Green
358
+ }
359
+
360
+ # Read template, substitute install path, fix command for Windows (python not python3)
361
+ $configContent = (Get-Content $TemplatePath -Raw) -replace '\{\{INSTALL_DIR\}\}', ($INSTALL_DIR -replace '\\', '\\')
362
+ $configContent = $configContent -replace '"python3"', '"python"'
363
+ Set-Content -Path $ConfigPath -Value $configContent -Encoding UTF8 -Force
364
+
365
+ Write-Host " OK $ToolName MCP configured" -ForegroundColor Green
366
+ }
367
+
368
+ # Copy MCP server to install directory (ensure it is present)
369
+ $mcpServerSrc = Join-Path $REPO_DIR "mcp_server.py"
370
+ if (Test-Path $mcpServerSrc) {
371
+ Copy-Item -Path $mcpServerSrc -Destination $INSTALL_DIR -Force
372
+ }
373
+
374
+ # --- 1. Claude Desktop ---
375
+ $claudeAppData = Join-Path $env:APPDATA "Claude"
376
+ if (Test-Path $claudeAppData) {
377
+ $DETECTED_TOOLS += "Claude Desktop"
378
+ $template = Join-Path $REPO_DIR "configs\claude-desktop-mcp.json"
379
+ $configDest = Join-Path $claudeAppData "claude_desktop_config.json"
380
+ Configure-McpTool -ToolName "Claude Desktop" -TemplatePath $template -ConfigPath $configDest
381
+ }
382
+
383
+ # --- 2. Cursor ---
384
+ $cursorDir = Join-Path $env:USERPROFILE ".cursor"
385
+ $cursorCmd = Get-Command cursor -ErrorAction SilentlyContinue
386
+ if ((Test-Path $cursorDir) -or $cursorCmd) {
387
+ $DETECTED_TOOLS += "Cursor"
388
+ $template = Join-Path $REPO_DIR "configs\cursor-mcp.json"
389
+ $configDest = Join-Path $cursorDir "mcp_settings.json"
390
+ Configure-McpTool -ToolName "Cursor" -TemplatePath $template -ConfigPath $configDest
391
+ }
392
+
393
+ # --- 3. Windsurf ---
394
+ $windsurfDir = Join-Path $env:USERPROFILE ".windsurf"
395
+ $windsurfCmd = Get-Command windsurf -ErrorAction SilentlyContinue
396
+ if ((Test-Path $windsurfDir) -or $windsurfCmd) {
397
+ $DETECTED_TOOLS += "Windsurf"
398
+ $template = Join-Path $REPO_DIR "configs\windsurf-mcp.json"
399
+ $configDest = Join-Path $windsurfDir "mcp_settings.json"
400
+ Configure-McpTool -ToolName "Windsurf" -TemplatePath $template -ConfigPath $configDest
401
+ }
402
+
403
+ # --- 4. VS Code / GitHub Copilot ---
404
+ $vscodeCmd = Get-Command code -ErrorAction SilentlyContinue
405
+ $vscodeInsidersCmd = Get-Command code-insiders -ErrorAction SilentlyContinue
406
+ if ($vscodeCmd -or $vscodeInsidersCmd) {
407
+ $DETECTED_TOOLS += "VS Code/Copilot"
408
+ $template = Join-Path $REPO_DIR "configs\vscode-copilot-mcp.json"
409
+ $vscodeDir = Join-Path $env:USERPROFILE ".vscode"
410
+ $configDest = Join-Path $vscodeDir "mcp.json"
411
+ Configure-McpTool -ToolName "VS Code/Copilot" -TemplatePath $template -ConfigPath $configDest
412
+ }
413
+
414
+ # --- 5. Gemini CLI ---
415
+ $geminiCmd = Get-Command gemini -ErrorAction SilentlyContinue
416
+ $geminiSettings = Join-Path $env:USERPROFILE ".gemini\settings.json"
417
+ if ($geminiCmd -or (Test-Path $geminiSettings)) {
418
+ $DETECTED_TOOLS += "Gemini CLI"
419
+ $template = Join-Path $REPO_DIR "configs\gemini-cli-mcp.json"
420
+ $geminiDir = Join-Path $env:USERPROFILE ".gemini"
421
+ $configDest = Join-Path $geminiDir "settings.json"
422
+ Configure-McpTool -ToolName "Gemini CLI" -TemplatePath $template -ConfigPath $configDest
423
+ }
424
+
425
+ # --- 6. Codex CLI ---
426
+ $codexDir = Join-Path $env:USERPROFILE ".codex"
427
+ $codexCmd = Get-Command codex -ErrorAction SilentlyContinue
428
+ if ((Test-Path $codexDir) -or $codexCmd) {
429
+ $DETECTED_TOOLS += "Codex CLI"
430
+
431
+ $codexConfigured = $false
432
+
433
+ # Preferred: use native codex mcp add command
434
+ if ($codexCmd) {
435
+ try {
436
+ & codex mcp add superlocalmemory-v2 --env "PYTHONPATH=$INSTALL_DIR" -- python "$INSTALL_DIR\mcp_server.py" 2>$null
437
+ Write-Host " OK Codex CLI MCP configured (via codex mcp add)" -ForegroundColor Green
438
+ $codexConfigured = $true
439
+ } catch {
440
+ # codex mcp add failed — fall through to TOML method
441
+ }
442
+ }
443
+
444
+ # Fallback: write TOML config directly
445
+ if (-not $codexConfigured) {
446
+ $codexConfig = Join-Path $codexDir "config.toml"
447
+ if (-not (Test-Path $codexDir)) {
448
+ New-Item -ItemType Directory -Path $codexDir -Force | Out-Null
449
+ }
450
+
451
+ if ((Test-Path $codexConfig) -and (Select-String -Path $codexConfig -Pattern "superlocalmemory-v2" -Quiet -ErrorAction SilentlyContinue)) {
452
+ Write-Host " INFO: Codex CLI already configured" -ForegroundColor Yellow
453
+ } else {
454
+ # Backup existing config
455
+ if (Test-Path $codexConfig) {
456
+ $timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
457
+ Copy-Item -Path $codexConfig -Destination "$codexConfig.backup.$timestamp" -Force
458
+ Write-Host " OK Backed up existing Codex CLI config" -ForegroundColor Green
459
+ }
460
+
461
+ # Append TOML block
462
+ $tomlBlock = @"
463
+
464
+ [mcp_servers.superlocalmemory-v2]
465
+ command = "python"
466
+ args = ["$INSTALL_DIR\mcp_server.py"]
467
+
468
+ [mcp_servers.superlocalmemory-v2.env]
469
+ PYTHONPATH = "$INSTALL_DIR"
470
+ "@
471
+ Add-Content -Path $codexConfig -Value $tomlBlock -Encoding UTF8
472
+ Write-Host " OK Codex CLI MCP configured (TOML appended)" -ForegroundColor Green
473
+ }
474
+ }
475
+ }
476
+
477
+ # --- 7. Perplexity ---
478
+ $perplexityDir = Join-Path $env:USERPROFILE ".perplexity"
479
+ if (Test-Path $perplexityDir) {
480
+ $DETECTED_TOOLS += "Perplexity"
481
+ $template = Join-Path $REPO_DIR "configs\perplexity-mcp.json"
482
+ $configDest = Join-Path $perplexityDir "mcp.json"
483
+ Configure-McpTool -ToolName "Perplexity" -TemplatePath $template -ConfigPath $configDest
484
+ }
485
+
486
+ # --- 8. OpenCode ---
487
+ $opencodeDir = Join-Path $env:USERPROFILE ".opencode"
488
+ if (Test-Path $opencodeDir) {
489
+ $DETECTED_TOOLS += "OpenCode"
490
+ $template = Join-Path $REPO_DIR "configs\opencode-mcp.json"
491
+ $configDest = Join-Path $opencodeDir "mcp.json"
492
+ Configure-McpTool -ToolName "OpenCode" -TemplatePath $template -ConfigPath $configDest
493
+ }
494
+
495
+ # --- 9. Zed Editor ---
496
+ $zedConfigDir = Join-Path $env:USERPROFILE ".config\zed"
497
+ $zedCmd = Get-Command zed -ErrorAction SilentlyContinue
498
+ if ((Test-Path $zedConfigDir) -or $zedCmd) {
499
+ $DETECTED_TOOLS += "Zed Editor"
500
+ $template = Join-Path $REPO_DIR "configs\zed-mcp.json"
501
+ $configDest = Join-Path $zedConfigDir "context_servers.json"
502
+ Configure-McpTool -ToolName "Zed Editor" -TemplatePath $template -ConfigPath $configDest
503
+ }
504
+
505
+ # Install MCP Python package if not present
506
+ try {
507
+ & python -c "import mcp" 2>$null
508
+ } catch {
509
+ Write-Host ""
510
+ Write-Host "Installing MCP SDK..."
511
+ try {
512
+ & python -m pip install mcp -q 2>$null
513
+ Write-Host "OK MCP SDK installed" -ForegroundColor Green
514
+ } catch {
515
+ Write-Host "INFO: MCP SDK install failed (manual install: python -m pip install mcp)" -ForegroundColor Yellow
516
+ }
517
+ }
518
+
519
+ # Summary of detected tools
520
+ Write-Host ""
521
+ if ($DETECTED_TOOLS.Count -gt 0) {
522
+ Write-Host "OK Detected and configured:" -ForegroundColor Green
523
+ foreach ($tool in $DETECTED_TOOLS) {
524
+ Write-Host " * $tool"
525
+ }
526
+ Write-Host ""
527
+ Write-Host "These tools now have native access to SuperLocalMemory!"
528
+ Write-Host "Restart them to use the new MCP integration."
529
+ } else {
530
+ Write-Host "INFO: No additional AI tools detected" -ForegroundColor Yellow
531
+ Write-Host " MCP server is available if you install Claude Desktop, Cursor, etc."
532
+ }
533
+
534
+ # Restore original error action preference
535
+ $ErrorActionPreference = $savedErrorAction
536
+
311
537
  # Summary
312
538
  Write-Host ""
313
539
  Write-Host "=================================================================="