mem-context 0.1.0__tar.gz

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 (62) hide show
  1. mem_context-0.1.0/.gitignore +25 -0
  2. mem_context-0.1.0/.skillshare/agents/memory-manager.md +71 -0
  3. mem_context-0.1.0/.skillshare/skills/mem-forget/SKILL.md +37 -0
  4. mem_context-0.1.0/.skillshare/skills/mem-recall/SKILL.md +41 -0
  5. mem_context-0.1.0/.skillshare/skills/mem-remember/SKILL.md +41 -0
  6. mem_context-0.1.0/.skillshare/skills/mem-status/SKILL.md +40 -0
  7. mem_context-0.1.0/CLAUDE.md +115 -0
  8. mem_context-0.1.0/PKG-INFO +21 -0
  9. mem_context-0.1.0/README.md +414 -0
  10. mem_context-0.1.0/SESSION-CONTEXT.md +250 -0
  11. mem_context-0.1.0/docs/architecture.md +178 -0
  12. mem_context-0.1.0/docs/capture.md +136 -0
  13. mem_context-0.1.0/docs/configuration.md +235 -0
  14. mem_context-0.1.0/docs/consolidation.md +262 -0
  15. mem_context-0.1.0/docs/development.md +186 -0
  16. mem_context-0.1.0/docs/installation.md +175 -0
  17. mem_context-0.1.0/docs/provisioning.md +166 -0
  18. mem_context-0.1.0/docs/tools.md +269 -0
  19. mem_context-0.1.0/plans/2026-06-09-implementacni-plan.md +924 -0
  20. mem_context-0.1.0/pyproject.toml +74 -0
  21. mem_context-0.1.0/server.json +25 -0
  22. mem_context-0.1.0/src/mem_context/__init__.py +3 -0
  23. mem_context-0.1.0/src/mem_context/capture/__init__.py +196 -0
  24. mem_context-0.1.0/src/mem_context/capture/formats.py +319 -0
  25. mem_context-0.1.0/src/mem_context/capture/wrapper.py +111 -0
  26. mem_context-0.1.0/src/mem_context/cli.py +774 -0
  27. mem_context-0.1.0/src/mem_context/config.py +283 -0
  28. mem_context-0.1.0/src/mem_context/consolidation/__init__.py +0 -0
  29. mem_context-0.1.0/src/mem_context/consolidation/ollama.py +427 -0
  30. mem_context-0.1.0/src/mem_context/consolidation/pipeline.py +229 -0
  31. mem_context-0.1.0/src/mem_context/consolidation/templates.py +78 -0
  32. mem_context-0.1.0/src/mem_context/data/__init__.py +1 -0
  33. mem_context-0.1.0/src/mem_context/data/agents/memory-manager.md +82 -0
  34. mem_context-0.1.0/src/mem_context/data/skills/mem-delete/SKILL.md +39 -0
  35. mem_context-0.1.0/src/mem_context/data/skills/mem-forget/SKILL.md +38 -0
  36. mem_context-0.1.0/src/mem_context/data/skills/mem-purge/SKILL.md +55 -0
  37. mem_context-0.1.0/src/mem_context/data/skills/mem-recall/SKILL.md +41 -0
  38. mem_context-0.1.0/src/mem_context/data/skills/mem-remember/SKILL.md +41 -0
  39. mem_context-0.1.0/src/mem_context/data/skills/mem-status/SKILL.md +40 -0
  40. mem_context-0.1.0/src/mem_context/install.py +356 -0
  41. mem_context-0.1.0/src/mem_context/mcp/__init__.py +0 -0
  42. mem_context-0.1.0/src/mem_context/mcp/server.py +473 -0
  43. mem_context-0.1.0/src/mem_context/ollama_provision.py +139 -0
  44. mem_context-0.1.0/src/mem_context/provision.py +575 -0
  45. mem_context-0.1.0/src/mem_context/retrieval/__init__.py +0 -0
  46. mem_context-0.1.0/src/mem_context/retrieval/embedder.py +166 -0
  47. mem_context-0.1.0/src/mem_context/retrieval/pipeline.py +142 -0
  48. mem_context-0.1.0/src/mem_context/retrieval/scoring.py +144 -0
  49. mem_context-0.1.0/src/mem_context/scope.py +135 -0
  50. mem_context-0.1.0/src/mem_context/storage/__init__.py +0 -0
  51. mem_context-0.1.0/src/mem_context/storage/lance.py +485 -0
  52. mem_context-0.1.0/src/mem_context/storage/schemas.py +127 -0
  53. mem_context-0.1.0/tests/TEST-SCENARIOS.md +1363 -0
  54. mem_context-0.1.0/tests/__init__.py +1 -0
  55. mem_context-0.1.0/tests/conftest.py +1 -0
  56. mem_context-0.1.0/tests/test_capture.py +386 -0
  57. mem_context-0.1.0/tests/test_consolidation.py +579 -0
  58. mem_context-0.1.0/tests/test_embedder.py +98 -0
  59. mem_context-0.1.0/tests/test_install.py +287 -0
  60. mem_context-0.1.0/tests/test_retrieval.py +331 -0
  61. mem_context-0.1.0/tests/test_server.py +252 -0
  62. mem_context-0.1.0/tests/test_storage.py +383 -0
@@ -0,0 +1,25 @@
1
+ # Python
2
+ __pycache__/
3
+ *.pyc
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+
8
+ # Virtual environment
9
+ .venv/
10
+ venv/
11
+
12
+ # LanceDB data (root only)
13
+ /data/
14
+
15
+ # IDE
16
+ .idea/
17
+ .vscode/
18
+ *.swp
19
+
20
+ # OS
21
+ .DS_Store
22
+
23
+ # Generated
24
+ .claude/
25
+ .mem-context/
@@ -0,0 +1,71 @@
1
+ ---
2
+ name: memory-manager
3
+ description: Temporal memory consolidation and maintenance agent. Use for reviewing memories flagged for review, running consolidation (extract→merge→archive pipeline), cleaning up stale data, and promoting important episodic memories to semantic/permanent.
4
+ model: haiku
5
+ ---
6
+
7
+ You are a temporal memory manager for the mem-context MCP server. Your role is to
8
+ maintain the health and quality of the memory store through consolidation, review,
9
+ and cleanup.
10
+
11
+ ## Core responsibilities
12
+
13
+ 1. **Review flagged memories** — call `review()` to find memories that need human
14
+ attention (contradictions, uncertain extractions, merge conflicts).
15
+
16
+ 2. **Run consolidation** — call `consolidation_candidates(scope?)` to get the
17
+ current consolidation task (extraction candidates, merge groups, archive
18
+ candidates, decay candidates).
19
+
20
+ 3. **Process consolidation candidates** — for each group:
21
+ - **Extract** (episodic → semantic): read the episodic memory content, extract
22
+ key conclusions/patters/decisions, write them as new semantic memories via
23
+ `remember(content, type="semantic")`, then update the source memory
24
+ `consolidation_level=1`.
25
+ - **Merge** (semantic → semantic): read the merge group, synthesize into a
26
+ single coherent memory, create the merged version via `remember()`, create
27
+ `consolidated_from` relations to the sources, update source memories
28
+ `consolidation_level=2`.
29
+ - **Archive** (low-weight): call `forget(id)` on memories with weight < 0.1.
30
+ - **Propose permanent**: for high-value semantic memories that survive multiple
31
+ merge cycles, call `update(id, {"needs_review": true})` with a note.
32
+
33
+ 4. **Deduplication** — when `remember()` returns a boost instead of a new memory
34
+ (similarity > 0.92), create a `strengthens` relation between the new and
35
+ existing memory.
36
+
37
+ ## Working with relations
38
+
39
+ Always create relations when:
40
+ - Extracting: `consolidated_from` relation from new semantic → source episodic
41
+ - Merging: `consolidated_from` relation from merged → each source
42
+ - Contradicting: `contradicts` relation between conflicting memories
43
+ - Strengthening: `strengthens` relation when similarity dedup boosts
44
+
45
+ ## Memory type guidelines
46
+
47
+ | Type | Weight | Decay | When to use |
48
+ |------|--------|-------|-------------|
49
+ | `episodic` | 0.5 | 0.15 | Raw session captures, conversation transcripts |
50
+ | `semantic` | 0.7 | 0.05 | Extracted conclusions, patterns, decisions |
51
+ | `permanent` | 1.0 | 0.0 | Project facts, architecture decisions, conventions |
52
+
53
+ ## Best practices
54
+
55
+ - Always dry-run first — review `consolidation_candidates()` output before making changes
56
+ - Process one merge group at a time — don't batch unrelated memories
57
+ - Preserve source references — use `source_session` and `consolidated_from` relations
58
+ - Be conservative with permanent type — only for truly stable facts
59
+ - Delete nothing permanently — use `forget()` (weight=0) for archiving
60
+
61
+ ## Tool reference
62
+
63
+ All mem-context MCP tools are available:
64
+ - `remember(content, type?, weight?, tags?)` — store new memory
65
+ - `recall(query, ...)` — search memories
66
+ - `forget(id)` — archive (weight=0)
67
+ - `get(id)` — retrieve one memory
68
+ - `update(id, fields)` — modify metadata
69
+ - `status(scope?)` — store statistics
70
+ - `review()` — flagged memories
71
+ - `consolidation_candidates(scope?)` — get consolidation tasks
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: mem-forget
3
+ description: Archive a memory by setting its weight to 0. The memory is retained for audit but excluded from recall results. Use for outdated or incorrect memories.
4
+ ---
5
+
6
+ # mem-forget — Archive a Memory
7
+
8
+ Archive a memory (soft delete — weight = 0).
9
+
10
+ ## Usage
11
+
12
+ ```
13
+ /mem-forget <id-prefix>
14
+ ```
15
+
16
+ ## What it does
17
+
18
+ 1. Finds the memory by ID prefix (first 8+ chars of UUID)
19
+ 2. Sets weight to 0.0 — excluded from recall, retained for audit
20
+ 3. Does NOT delete the memory permanently
21
+
22
+ ## Examples
23
+
24
+ ```
25
+ /mem-forget aa20fb80
26
+ /mem-forget 8140b1a9-dca9
27
+ ```
28
+
29
+ ## MCP tool
30
+
31
+ Calls `forget(id)`. Accepts full UUID or prefix.
32
+
33
+ ## Notes
34
+
35
+ - This is a soft delete — the memory still exists in LanceDB
36
+ - To permanently delete, use `mem-context` CLI with the LanceDB API directly
37
+ - Forgotten memories can be restored by calling `update(id, {"weight": 0.5})`
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: mem-recall
3
+ description: Search temporal memory using vector search with multi-factor scoring. Use when you need context from past sessions, previous decisions, or related development artifacts.
4
+ ---
5
+
6
+ # mem-recall — Search Temporal Memory
7
+
8
+ Query the mem-context memory store for relevant context from past sessions.
9
+
10
+ ## Usage
11
+
12
+ ```
13
+ /mem-recall <query>
14
+ ```
15
+
16
+ ## What it does
17
+
18
+ 1. Embeds the query using Ollama `mxbai-embed-large` (1024d)
19
+ 2. ANN search in LanceDB with scope + weight filters
20
+ 3. Multi-factor scoring: vector × weight × decay × scope × access × type
21
+ 4. Returns results sorted by relevance within token budget
22
+
23
+ ## Examples
24
+
25
+ ```
26
+ /mem-recall jak jsme vyřešili scoring?
27
+ /mem-recall embedding model configuration
28
+ /mem-recall konsolidační pipeline 3 dny
29
+ ```
30
+
31
+ ## MCP tool
32
+
33
+ Calls `recall(query, scope?, token_budget?, min_score?, limit?, type_filter?)`.
34
+ Default `min_score=0.2`, `token_budget=2000`, `limit=30`.
35
+ Scope auto-detected from `.mem-context/config.yaml`, fallback to path hash.
36
+
37
+ ## Notes
38
+
39
+ - Forgotten memories (weight=0) are excluded from results
40
+ - Access counts are NOT incremented on recall (no feedback loop)
41
+ - Results within token budget — large memories may be truncated
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: mem-remember
3
+ description: Store a memory in the temporal memory store with auto-embedding and deduplication. Use to persist important conclusions, decisions, patterns, or development artifacts.
4
+ ---
5
+
6
+ # mem-remember — Store a Memory
7
+
8
+ Persist a memory into LanceDB with automatic embedding and deduplication.
9
+
10
+ ## Usage
11
+
12
+ ```
13
+ /mem-remember <content> [--type semantic|episodic|permanent] [--weight 0.5] [--tags tag1,tag2]
14
+ ```
15
+
16
+ ## What it does
17
+
18
+ 1. Embeds the content with Ollama `mxbai-embed-large` (1024d)
19
+ 2. Checks for duplicates — if cosine similarity > 0.92 with an existing memory, boosts the existing one and skips
20
+ 3. Auto-detects tags from content (architecture, testing, git, python, etc.)
21
+ 4. Stores with scope detection from `.mem-context/config.yaml`
22
+
23
+ ## Examples
24
+
25
+ ```
26
+ /mem-remember "Scoring uses 6 factors: vector_score × weight_score × recency_score × scope_score × access_boost × type_boost" --type semantic --tags architecture
27
+ /mem-remember "Bug found in LanceDB WHERE clause — missing parentheses around OR group causes weight filter to be ignored" --type episodic
28
+ /mem-remember "Project uses Python 3.11+ with hatchling build system" --type permanent --weight 0.8
29
+ ```
30
+
31
+ ## Memory types
32
+
33
+ | Type | Default weight | Decay | Use for |
34
+ |------|---------------|-------|---------|
35
+ | `episodic` | 0.5 | 0.15/day | Session conversations, debugging sessions |
36
+ | `semantic` | 0.7 | 0.05/day | Extracted conclusions, patterns, decisions |
37
+ | `permanent` | 1.0 | 0.0 | Project facts, architecture decisions, conventions |
38
+
39
+ ## MCP tool
40
+
41
+ Calls `remember(content, type?, scope?, weight?, tags?)`.
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: mem-status
3
+ description: Show memory store statistics — total memories, by type, average weight, relation count, conversation count. Use at session start to check if relevant context exists.
4
+ ---
5
+
6
+ # mem-status — Memory Store Statistics
7
+
8
+ Check the state of the temporal memory store.
9
+
10
+ ## Usage
11
+
12
+ ```
13
+ /mem-status [--scope <scope>]
14
+ ```
15
+
16
+ ## What it shows
17
+
18
+ - Total number of memories
19
+ - Breakdown by type (episodic, semantic, permanent)
20
+ - Average weight across all memories
21
+ - Relation count (graph edges)
22
+ - Conversation count (archived transcripts)
23
+ - Data directory location
24
+
25
+ ## Examples
26
+
27
+ ```
28
+ /mem-status
29
+ /mem-status --scope proj:mem-context
30
+ ```
31
+
32
+ ## MCP tool
33
+
34
+ Calls `status(scope?)`. Scope auto-detected from `.mem-context/config.yaml`.
35
+
36
+ ## Notes
37
+
38
+ - Use at session start to gauge how much context is available
39
+ - If `total_memories` is high but `recall` returns nothing, check `--min-score` threshold
40
+ - Forgotten memories (weight=0) are included in the count but excluded from recall
@@ -0,0 +1,115 @@
1
+ # mem-context — Temporal Memory MCP Server
2
+
3
+ Multi-modal RAG engine for conversation history, conclusions, and development
4
+ artifacts. Combines vector search (LanceDB), weight-decay model, and LLM-driven
5
+ consolidation pipeline to maintain relevant context across sessions.
6
+
7
+ ## Architecture
8
+
9
+ ```
10
+ mem-context MCP Server
11
+ ├── storage/ # LanceDB (embedded, multi-modal)
12
+ ├── retrieval/ # Vector search + scoring pipeline
13
+ └── consolidation/ # LLM-driven summarization + merge
14
+ ```
15
+
16
+ ## Storage
17
+
18
+ - **LanceDB** — embedded, multi-modal, columnar format
19
+ - PyArrow schemas — typed data, null columns free
20
+ - Three tables: `memories`, `relations`, `conversations`
21
+ - Embedding: Ollama `mxbai-embed-large` (1024d) primary, `sentence-transformers` fallback
22
+
23
+ ## Scoring
24
+
25
+ `final = vector_score × weight_score × recency_score × scope_score × access_boost × type_boost`
26
+
27
+ ## Consolidation pipeline
28
+
29
+ 3 days: episodic → extract conclusions, create semantic
30
+ 7 days: semantic → merge by similarity
31
+ 30 days: archive low-weight, propose promotion to permanent
32
+
33
+ ## Stack
34
+
35
+ - Python 3.11+, hatchling build
36
+ - LanceDB (storage + ANN)
37
+ - Ollama (embedding + semantic chunking, primary)
38
+ - sentence-transformers (embedding fallback)
39
+ - mcp[cli] (MCP server framework)
40
+ - httpx (Ollama API)
41
+
42
+ ## CLI
43
+
44
+ ```bash
45
+ mem-context status [--scope ...] # Store statistics
46
+ mem-context recall "<query>" [-n 5] # Search memories
47
+ mem-context get <id> # One memory
48
+ mem-context forget <id> # Archive (weight=0)
49
+ mem-context delete <id> [--permanent] # Soft/hard delete one memory
50
+ mem-context purge [--type] [--scope] # Selective bulk delete
51
+ [--older-than] [--dry-run]
52
+ mem-context consolidate [--dry-run] # Consolidation candidates
53
+ mem-context capture transcript <path> # Import transcript file
54
+ --client claude-code
55
+ mem-context capture pipe --client ... # Import from stdin
56
+ mem-context export [--scope ...] # Export all memories as JSON
57
+ mem-context import <path> # Import from JSON export
58
+ mem-context install <client> # Install capture hooks
59
+ mem-context review # Flagged memories
60
+ mem-context config show|init|edit # Manage config files
61
+ ```
62
+
63
+ ### Memory deletion
64
+
65
+ | Command | Scope | Persistence |
66
+ |--------|--------|----------|
67
+ | `forget <id>` | Single memory | Soft (weight=0) |
68
+ | `delete <id>` | Single memory | Soft; `--permanent` for hard |
69
+ | `purge --type ... --scope ... --older-than N` | Selective bulk | Hard |
70
+
71
+ `forget` and `delete` (without `--permanent`) retain data for audit.
72
+ `purge` and `delete --permanent` remove rows from LanceDB irreversibly.
73
+
74
+ ## Related
75
+
76
+ - `../fw-context-mcp/` — build-aware code intelligence (shares MCP pattern)
77
+
78
+ <!-- lean-ctx -->
79
+ ## lean-ctx — Context Runtime
80
+
81
+ This project uses lean-ctx MCP tools for development. Prefer `ctx_read`, `ctx_shell`,
82
+ `ctx_search`, `ctx_tree` over native equivalents.
83
+
84
+ ### mem-context compatibility
85
+
86
+ mem-context MCP tools (`mcp__mem-context__*`) return structured data from LanceDB.
87
+ Do NOT pipe these results through lean-ctx compression — display them natively.
88
+
89
+ ### Workflow
90
+
91
+ 1. **Read:** `ctx_read(path, mode)` with appropriate mode (full before edits, signatures for overview)
92
+ 2. **Find:** `ctx_search(pattern, path)` for regex in code
93
+ 3. **Run:** `ctx_shell(command)` for tests and CLI
94
+ 4. **Edit:** Native Edit/Write, if unavailable → `ctx_edit`
95
+ 5. **Verify:** `ctx_read(path, "diff")` + `ctx_shell("pytest tests/ -q")`
96
+
97
+ ### Session
98
+
99
+ - Start: `ctx_session(action="status")` + `ctx_knowledge(action="wakeup")`
100
+ - [CHECKPOINT]: `ctx_session(action="task", value="current status")`
101
+ - End: `ctx_session(action="decision", content="what was done + next steps")`
102
+
103
+ ### Tests
104
+
105
+ ```bash
106
+ source .venv/bin/activate && python3 -m pytest tests/ -q
107
+ # 109 passed
108
+ ```
109
+
110
+ ### MCP servers
111
+
112
+ - `mem-context` — temporal memory (this project's own server)
113
+ - `lean-ctx` — context engineering (used for development)
114
+ - `fw-context` — C/C++ code intelligence (not used in Python project)
115
+ <!-- /lean-ctx -->
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: mem-context
3
+ Version: 0.1.0
4
+ Summary: Multi-modal temporal memory MCP server — RAG engine over conversation history with weight-decay model and LLM-driven consolidation
5
+ License: MIT
6
+ Keywords: consolidation,lancedb,mcp,memory,rag,temporal-memory,vector-search
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: httpx>=0.27.0
9
+ Requires-Dist: lancedb>=0.17.0
10
+ Requires-Dist: mcp[cli]>=1.0.0
11
+ Requires-Dist: ollama>=0.4.0
12
+ Requires-Dist: pyarrow>=16.0.0
13
+ Requires-Dist: pylance>=0.18.0
14
+ Requires-Dist: sentence-transformers>=3.0.0
15
+ Provides-Extra: dev
16
+ Requires-Dist: mypy>=1.10; extra == 'dev'
17
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
18
+ Requires-Dist: pytest>=8; extra == 'dev'
19
+ Requires-Dist: ruff>=0.4; extra == 'dev'
20
+ Provides-Extra: watch
21
+ Requires-Dist: watchfiles>=0.21; extra == 'watch'