superlocalmemory 2.6.0 → 2.7.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/CHANGELOG.md +167 -1803
- package/README.md +212 -397
- package/bin/slm +179 -3
- package/bin/superlocalmemoryv2:learning +4 -0
- package/bin/superlocalmemoryv2:patterns +4 -0
- package/docs/ACCESSIBILITY.md +291 -0
- package/docs/ARCHITECTURE.md +12 -6
- package/docs/FRAMEWORK-INTEGRATIONS.md +300 -0
- package/docs/MCP-MANUAL-SETUP.md +14 -4
- package/install.sh +99 -3
- package/mcp_server.py +291 -1
- package/package.json +2 -1
- package/requirements-learning.txt +12 -0
- package/scripts/verify-v27.sh +233 -0
- package/skills/slm-show-patterns/SKILL.md +224 -0
- package/src/learning/__init__.py +201 -0
- package/src/learning/adaptive_ranker.py +826 -0
- package/src/learning/cross_project_aggregator.py +866 -0
- package/src/learning/engagement_tracker.py +638 -0
- package/src/learning/feature_extractor.py +461 -0
- package/src/learning/feedback_collector.py +690 -0
- package/src/learning/learning_db.py +842 -0
- package/src/learning/project_context_manager.py +582 -0
- package/src/learning/source_quality_scorer.py +685 -0
- package/src/learning/synthetic_bootstrap.py +1047 -0
- package/src/learning/tests/__init__.py +0 -0
- package/src/learning/tests/test_adaptive_ranker.py +328 -0
- package/src/learning/tests/test_aggregator.py +309 -0
- package/src/learning/tests/test_feedback_collector.py +295 -0
- package/src/learning/tests/test_learning_db.py +606 -0
- package/src/learning/tests/test_project_context.py +296 -0
- package/src/learning/tests/test_source_quality.py +355 -0
- package/src/learning/tests/test_synthetic_bootstrap.py +433 -0
- package/src/learning/tests/test_workflow_miner.py +322 -0
- package/src/learning/workflow_pattern_miner.py +665 -0
- package/ui/index.html +346 -13
- package/ui/js/clusters.js +90 -1
- package/ui/js/graph-core.js +445 -0
- package/ui/js/graph-cytoscape-monolithic-backup.js +1168 -0
- package/ui/js/graph-cytoscape.js +1168 -0
- package/ui/js/graph-d3-backup.js +32 -0
- package/ui/js/graph-filters.js +220 -0
- package/ui/js/graph-interactions.js +354 -0
- package/ui/js/graph-ui.js +214 -0
- package/ui/js/memories.js +52 -0
- package/ui/js/modal.js +104 -1
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: slm-show-patterns
|
|
3
|
+
description: Show what SuperLocalMemory has learned about your preferences, workflow patterns, and project context. Use when the user asks "what have you learned about me?" or wants to see their coding identity patterns. Shows tech preferences, workflow sequences, and engagement health.
|
|
4
|
+
version: "2.7.0"
|
|
5
|
+
license: MIT
|
|
6
|
+
compatibility: "Requires SuperLocalMemory V2.7+ with learning features"
|
|
7
|
+
attribution:
|
|
8
|
+
creator: Varun Pratap Bhardwaj
|
|
9
|
+
role: Solution Architect & Original Creator
|
|
10
|
+
project: SuperLocalMemory V2
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# SuperLocalMemory: Show Patterns
|
|
14
|
+
|
|
15
|
+
Show what SuperLocalMemory has learned about your preferences, workflow, and coding identity.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
slm patterns list [threshold]
|
|
21
|
+
slm learning status
|
|
22
|
+
slm engagement
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Example Output
|
|
26
|
+
|
|
27
|
+
### Learned Patterns
|
|
28
|
+
```bash
|
|
29
|
+
$ slm patterns list 0.5
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Output:**
|
|
33
|
+
```
|
|
34
|
+
Learned Patterns (confidence >= 0.5)
|
|
35
|
+
=====================================
|
|
36
|
+
|
|
37
|
+
TECH PREFERENCES (cross-project):
|
|
38
|
+
#1 preferred_framework: React confidence: 0.92 (seen in 3 profiles)
|
|
39
|
+
#2 preferred_language: Python confidence: 0.88 (seen in 2 profiles)
|
|
40
|
+
#3 preferred_backend: FastAPI confidence: 0.85 (seen in 2 profiles)
|
|
41
|
+
#4 testing_style: pytest confidence: 0.78 (seen in 1 profile)
|
|
42
|
+
#5 preferred_db: PostgreSQL confidence: 0.71 (seen in 2 profiles)
|
|
43
|
+
|
|
44
|
+
WORKFLOW PATTERNS:
|
|
45
|
+
#6 morning_sequence: recall -> code -> remember frequency: 34
|
|
46
|
+
#7 debug_sequence: recall -> recall -> remember frequency: 18
|
|
47
|
+
#8 review_sequence: list -> recall -> remember frequency: 12
|
|
48
|
+
|
|
49
|
+
PROJECT CONTEXT:
|
|
50
|
+
#9 active_project: SuperLocalMemoryV2 last_seen: 2 hours ago
|
|
51
|
+
#10 active_project: client-dashboard last_seen: 1 day ago
|
|
52
|
+
|
|
53
|
+
Total: 10 patterns (7 high confidence)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Learning Status
|
|
57
|
+
```bash
|
|
58
|
+
$ slm learning status
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Output:**
|
|
62
|
+
```
|
|
63
|
+
SuperLocalMemory v2.7 -- Learning System Status
|
|
64
|
+
==================================================
|
|
65
|
+
LightGBM: installed (4.5.0)
|
|
66
|
+
SciPy: installed (1.14.1)
|
|
67
|
+
ML Ranking: available
|
|
68
|
+
Full Learning: available
|
|
69
|
+
|
|
70
|
+
Feedback signals: 247
|
|
71
|
+
Unique queries: 89
|
|
72
|
+
Patterns learned: 34 (12 high confidence)
|
|
73
|
+
Workflow patterns: 8
|
|
74
|
+
Sources tracked: 4
|
|
75
|
+
Models trained: 2
|
|
76
|
+
Learning DB size: 128 KB
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Engagement Metrics
|
|
80
|
+
```bash
|
|
81
|
+
$ slm engagement
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Output:**
|
|
85
|
+
```
|
|
86
|
+
SuperLocalMemory -- Engagement Health
|
|
87
|
+
======================================
|
|
88
|
+
Status: HEALTHY
|
|
89
|
+
|
|
90
|
+
This Week:
|
|
91
|
+
Memories saved: 12
|
|
92
|
+
Recalls performed: 28
|
|
93
|
+
Memories marked useful: 8
|
|
94
|
+
Feedback ratio: 28.6%
|
|
95
|
+
|
|
96
|
+
Trends:
|
|
97
|
+
Recall frequency: increasing (up 15% from last week)
|
|
98
|
+
Save frequency: stable
|
|
99
|
+
Useful feedback: increasing (up 40% from last week)
|
|
100
|
+
|
|
101
|
+
Streaks:
|
|
102
|
+
Current daily streak: 5 days
|
|
103
|
+
Longest streak: 14 days
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## What the Patterns Mean
|
|
107
|
+
|
|
108
|
+
### Tech Preferences
|
|
109
|
+
Cross-project patterns that transfer between profiles. These represent your coding identity -- which frameworks, languages, and tools you consistently choose.
|
|
110
|
+
|
|
111
|
+
**How they are learned:**
|
|
112
|
+
- Extracted from memory content (mentions of frameworks, tools)
|
|
113
|
+
- Weighted by recency and frequency
|
|
114
|
+
- Confidence increases when the same preference appears across multiple profiles
|
|
115
|
+
|
|
116
|
+
**How they help:**
|
|
117
|
+
- When you `recall`, results matching your preferred stack rank higher
|
|
118
|
+
- Your AI tools can reference these to tailor suggestions
|
|
119
|
+
|
|
120
|
+
### Workflow Patterns
|
|
121
|
+
Sequences of actions you repeat. The system learns your work rhythm.
|
|
122
|
+
|
|
123
|
+
**Examples:**
|
|
124
|
+
- `recall -> code -> remember` = "Research, build, document" workflow
|
|
125
|
+
- `recall -> recall -> remember` = "Deep investigation" workflow
|
|
126
|
+
|
|
127
|
+
**How they help:**
|
|
128
|
+
- System predicts what you will need next
|
|
129
|
+
- Can pre-load relevant context based on your current workflow stage
|
|
130
|
+
|
|
131
|
+
### Engagement Health
|
|
132
|
+
Overall system usage metrics (fully local, zero telemetry).
|
|
133
|
+
|
|
134
|
+
**Healthy indicators:**
|
|
135
|
+
- Regular daily usage (streaks)
|
|
136
|
+
- Balanced save/recall ratio
|
|
137
|
+
- Increasing useful feedback
|
|
138
|
+
|
|
139
|
+
**Warning signs:**
|
|
140
|
+
- No recalls for 7+ days = stale memories
|
|
141
|
+
- No saves for 7+ days = not capturing knowledge
|
|
142
|
+
- Zero feedback = system cannot learn your preferences
|
|
143
|
+
|
|
144
|
+
## Correcting Patterns
|
|
145
|
+
|
|
146
|
+
If the system learned something wrong, correct it:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# See all patterns
|
|
150
|
+
slm patterns list
|
|
151
|
+
|
|
152
|
+
# Correct pattern #3 from "FastAPI" to "Django"
|
|
153
|
+
slm patterns correct 3 Django
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The correction increases confidence to 1.0 and records the change history.
|
|
157
|
+
|
|
158
|
+
## Options
|
|
159
|
+
|
|
160
|
+
| Command | Description | Use Case |
|
|
161
|
+
|---------|-------------|----------|
|
|
162
|
+
| `slm patterns list` | All patterns (no threshold) | See everything learned |
|
|
163
|
+
| `slm patterns list 0.7` | High confidence only | See reliable patterns |
|
|
164
|
+
| `slm patterns correct <id> <value>` | Fix a wrong pattern | Override incorrect learning |
|
|
165
|
+
| `slm learning status` | System health | Check deps and stats |
|
|
166
|
+
| `slm learning retrain` | Force model retrain | After bulk feedback |
|
|
167
|
+
| `slm learning reset` | Delete all learning data | Fresh start (memories preserved) |
|
|
168
|
+
| `slm engagement` | Usage metrics | Track your engagement health |
|
|
169
|
+
|
|
170
|
+
## Use Cases
|
|
171
|
+
|
|
172
|
+
### 1. "What Have You Learned About Me?"
|
|
173
|
+
```bash
|
|
174
|
+
slm patterns list
|
|
175
|
+
# Shows all preferences, workflows, and project context
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 2. Pre-Session Context Loading
|
|
179
|
+
```bash
|
|
180
|
+
slm patterns context
|
|
181
|
+
# Returns structured context for AI tools to consume
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### 3. Onboarding a New AI Tool
|
|
185
|
+
```bash
|
|
186
|
+
slm learning status
|
|
187
|
+
# Verify learning is active, then use your existing memories
|
|
188
|
+
# New tool benefits from all previously learned patterns
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 4. Weekly Review
|
|
192
|
+
```bash
|
|
193
|
+
slm engagement
|
|
194
|
+
# Check if you are using your memory system effectively
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Requirements
|
|
198
|
+
|
|
199
|
+
- SuperLocalMemory V2.7+
|
|
200
|
+
- Optional: `lightgbm` and `scipy` for ML-powered ranking
|
|
201
|
+
- Works without optional deps (uses rule-based ranking as fallback)
|
|
202
|
+
|
|
203
|
+
## Notes
|
|
204
|
+
|
|
205
|
+
- **Privacy:** All learning is local. Zero telemetry, zero cloud calls.
|
|
206
|
+
- **Separate storage:** Learning data lives in `learning.db`, separate from `memory.db`.
|
|
207
|
+
- **Non-destructive:** `slm learning reset` only deletes learning data, never memories.
|
|
208
|
+
- **Graceful degradation:** If learning deps are missing, core features work normally.
|
|
209
|
+
|
|
210
|
+
## Related Commands
|
|
211
|
+
|
|
212
|
+
- `slm recall` - Search memories (results ranked by learned patterns)
|
|
213
|
+
- `slm useful <id>` - Mark memory as useful (feedback for learning)
|
|
214
|
+
- `slm status` - Overall system status
|
|
215
|
+
- `slm patterns update` - Re-learn patterns from existing memories
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
**Created by:** [Varun Pratap Bhardwaj](https://github.com/varun369) (Solution Architect)
|
|
220
|
+
**Project:** SuperLocalMemory V2
|
|
221
|
+
**License:** MIT with attribution requirements (see [ATTRIBUTION.md](../../ATTRIBUTION.md))
|
|
222
|
+
**Repository:** https://github.com/varun369/SuperLocalMemoryV2
|
|
223
|
+
|
|
224
|
+
*Open source doesn't mean removing credit. Attribution must be preserved per MIT License terms.*
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
SuperLocalMemory V2 - Learning System (v2.7)
|
|
4
|
+
Copyright (c) 2026 Varun Pratap Bhardwaj
|
|
5
|
+
Licensed under MIT License
|
|
6
|
+
|
|
7
|
+
Repository: https://github.com/varun369/SuperLocalMemoryV2
|
|
8
|
+
Author: Varun Pratap Bhardwaj (Solution Architect)
|
|
9
|
+
|
|
10
|
+
NOTICE: This software is protected by MIT License.
|
|
11
|
+
Attribution must be preserved in all copies or derivatives.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
"""
|
|
15
|
+
Learning System — Feature detection and graceful import.
|
|
16
|
+
|
|
17
|
+
This module detects available dependencies and exposes feature flags
|
|
18
|
+
that the rest of the system uses to enable/disable learning features.
|
|
19
|
+
|
|
20
|
+
Design principle: If ANY import fails, the entire learning system
|
|
21
|
+
degrades gracefully to v2.6 behavior. Core memory operations are
|
|
22
|
+
NEVER affected by learning system failures.
|
|
23
|
+
|
|
24
|
+
Dependencies (all optional):
|
|
25
|
+
lightgbm>=4.0.0 — Learning-to-Rank re-ranker
|
|
26
|
+
scipy>=1.9.0 — Statistical functions (temporal decay, KDE)
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
import logging
|
|
30
|
+
from pathlib import Path
|
|
31
|
+
|
|
32
|
+
logger = logging.getLogger("superlocalmemory.learning")
|
|
33
|
+
|
|
34
|
+
# ============================================================================
|
|
35
|
+
# Feature Detection
|
|
36
|
+
# ============================================================================
|
|
37
|
+
|
|
38
|
+
# Check LightGBM availability (required for ML ranking)
|
|
39
|
+
try:
|
|
40
|
+
import lightgbm # noqa: F401
|
|
41
|
+
HAS_LIGHTGBM = True
|
|
42
|
+
LIGHTGBM_VERSION = lightgbm.__version__
|
|
43
|
+
except ImportError:
|
|
44
|
+
HAS_LIGHTGBM = False
|
|
45
|
+
LIGHTGBM_VERSION = None
|
|
46
|
+
|
|
47
|
+
# Check SciPy availability (required for statistical functions)
|
|
48
|
+
try:
|
|
49
|
+
import scipy # noqa: F401
|
|
50
|
+
HAS_SCIPY = True
|
|
51
|
+
SCIPY_VERSION = scipy.__version__
|
|
52
|
+
except ImportError:
|
|
53
|
+
HAS_SCIPY = False
|
|
54
|
+
SCIPY_VERSION = None
|
|
55
|
+
|
|
56
|
+
# Check scikit-learn availability (already in core, but verify)
|
|
57
|
+
try:
|
|
58
|
+
import sklearn # noqa: F401
|
|
59
|
+
HAS_SKLEARN = True
|
|
60
|
+
except ImportError:
|
|
61
|
+
HAS_SKLEARN = False
|
|
62
|
+
|
|
63
|
+
# ============================================================================
|
|
64
|
+
# Composite Feature Flags
|
|
65
|
+
# ============================================================================
|
|
66
|
+
|
|
67
|
+
# ML ranking requires LightGBM
|
|
68
|
+
ML_RANKING_AVAILABLE = HAS_LIGHTGBM
|
|
69
|
+
|
|
70
|
+
# Full learning requires LightGBM + SciPy
|
|
71
|
+
FULL_LEARNING_AVAILABLE = HAS_LIGHTGBM and HAS_SCIPY
|
|
72
|
+
|
|
73
|
+
# Rule-based ranking works with zero optional deps
|
|
74
|
+
RULE_BASED_RANKING_AVAILABLE = True
|
|
75
|
+
|
|
76
|
+
# ============================================================================
|
|
77
|
+
# Paths
|
|
78
|
+
# ============================================================================
|
|
79
|
+
|
|
80
|
+
MEMORY_DIR = Path.home() / ".claude-memory"
|
|
81
|
+
LEARNING_DB_PATH = MEMORY_DIR / "learning.db"
|
|
82
|
+
MEMORY_DB_PATH = MEMORY_DIR / "memory.db"
|
|
83
|
+
MODELS_DIR = MEMORY_DIR / "models"
|
|
84
|
+
|
|
85
|
+
# ============================================================================
|
|
86
|
+
# Module-level lazy imports
|
|
87
|
+
# ============================================================================
|
|
88
|
+
|
|
89
|
+
# These are imported lazily to avoid circular imports and to allow
|
|
90
|
+
# individual module failures without breaking the whole system.
|
|
91
|
+
|
|
92
|
+
_learning_db = None
|
|
93
|
+
_adaptive_ranker = None
|
|
94
|
+
_feedback_collector = None
|
|
95
|
+
_engagement_tracker = None
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def get_learning_db():
|
|
99
|
+
"""Get or create the LearningDB singleton."""
|
|
100
|
+
global _learning_db
|
|
101
|
+
if _learning_db is None:
|
|
102
|
+
try:
|
|
103
|
+
from .learning_db import LearningDB
|
|
104
|
+
_learning_db = LearningDB()
|
|
105
|
+
except Exception as e:
|
|
106
|
+
logger.warning("Failed to initialize LearningDB: %s", e)
|
|
107
|
+
return None
|
|
108
|
+
return _learning_db
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def get_adaptive_ranker():
|
|
112
|
+
"""Get or create the AdaptiveRanker singleton."""
|
|
113
|
+
global _adaptive_ranker
|
|
114
|
+
if _adaptive_ranker is None:
|
|
115
|
+
try:
|
|
116
|
+
from .adaptive_ranker import AdaptiveRanker
|
|
117
|
+
_adaptive_ranker = AdaptiveRanker()
|
|
118
|
+
except Exception as e:
|
|
119
|
+
logger.warning("Failed to initialize AdaptiveRanker: %s", e)
|
|
120
|
+
return None
|
|
121
|
+
return _adaptive_ranker
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def get_feedback_collector():
|
|
125
|
+
"""Get or create the FeedbackCollector singleton."""
|
|
126
|
+
global _feedback_collector
|
|
127
|
+
if _feedback_collector is None:
|
|
128
|
+
try:
|
|
129
|
+
from .feedback_collector import FeedbackCollector
|
|
130
|
+
_feedback_collector = FeedbackCollector()
|
|
131
|
+
except Exception as e:
|
|
132
|
+
logger.warning("Failed to initialize FeedbackCollector: %s", e)
|
|
133
|
+
return None
|
|
134
|
+
return _feedback_collector
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def get_engagement_tracker():
|
|
138
|
+
"""Get or create the EngagementTracker singleton."""
|
|
139
|
+
global _engagement_tracker
|
|
140
|
+
if _engagement_tracker is None:
|
|
141
|
+
try:
|
|
142
|
+
from .engagement_tracker import EngagementTracker
|
|
143
|
+
_engagement_tracker = EngagementTracker()
|
|
144
|
+
except Exception as e:
|
|
145
|
+
logger.warning("Failed to initialize EngagementTracker: %s", e)
|
|
146
|
+
return None
|
|
147
|
+
return _engagement_tracker
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def get_status() -> dict:
|
|
151
|
+
"""Return learning system status for diagnostics."""
|
|
152
|
+
status = {
|
|
153
|
+
"learning_available": FULL_LEARNING_AVAILABLE,
|
|
154
|
+
"ml_ranking_available": ML_RANKING_AVAILABLE,
|
|
155
|
+
"rule_based_available": RULE_BASED_RANKING_AVAILABLE,
|
|
156
|
+
"dependencies": {
|
|
157
|
+
"lightgbm": {
|
|
158
|
+
"installed": HAS_LIGHTGBM,
|
|
159
|
+
"version": LIGHTGBM_VERSION,
|
|
160
|
+
},
|
|
161
|
+
"scipy": {
|
|
162
|
+
"installed": HAS_SCIPY,
|
|
163
|
+
"version": SCIPY_VERSION,
|
|
164
|
+
},
|
|
165
|
+
"sklearn": {
|
|
166
|
+
"installed": HAS_SKLEARN,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
"paths": {
|
|
170
|
+
"learning_db": str(LEARNING_DB_PATH),
|
|
171
|
+
"models_dir": str(MODELS_DIR),
|
|
172
|
+
},
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
# Add learning DB stats if available
|
|
176
|
+
ldb = get_learning_db()
|
|
177
|
+
if ldb:
|
|
178
|
+
try:
|
|
179
|
+
status["learning_db_stats"] = ldb.get_stats()
|
|
180
|
+
except Exception:
|
|
181
|
+
status["learning_db_stats"] = None
|
|
182
|
+
|
|
183
|
+
return status
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
# Log feature availability on import
|
|
187
|
+
if FULL_LEARNING_AVAILABLE:
|
|
188
|
+
logger.info(
|
|
189
|
+
"Learning system available: LightGBM %s, SciPy %s",
|
|
190
|
+
LIGHTGBM_VERSION, SCIPY_VERSION
|
|
191
|
+
)
|
|
192
|
+
elif ML_RANKING_AVAILABLE:
|
|
193
|
+
logger.info(
|
|
194
|
+
"Partial learning: LightGBM %s available, SciPy missing",
|
|
195
|
+
LIGHTGBM_VERSION
|
|
196
|
+
)
|
|
197
|
+
else:
|
|
198
|
+
logger.info(
|
|
199
|
+
"Learning dependencies not installed. "
|
|
200
|
+
"Install with: pip3 install -r requirements-learning.txt"
|
|
201
|
+
)
|