basic-memory 0.7.0__py3-none-any.whl → 0.17.4__py3-none-any.whl

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.

Potentially problematic release.


This version of basic-memory might be problematic. Click here for more details.

Files changed (195) hide show
  1. basic_memory/__init__.py +5 -1
  2. basic_memory/alembic/alembic.ini +119 -0
  3. basic_memory/alembic/env.py +130 -20
  4. basic_memory/alembic/migrations.py +4 -9
  5. basic_memory/alembic/versions/314f1ea54dc4_add_postgres_full_text_search_support_.py +131 -0
  6. basic_memory/alembic/versions/502b60eaa905_remove_required_from_entity_permalink.py +51 -0
  7. basic_memory/alembic/versions/5fe1ab1ccebe_add_projects_table.py +120 -0
  8. basic_memory/alembic/versions/647e7a75e2cd_project_constraint_fix.py +112 -0
  9. basic_memory/alembic/versions/6830751f5fb6_merge_multiple_heads.py +24 -0
  10. basic_memory/alembic/versions/9d9c1cb7d8f5_add_mtime_and_size_columns_to_entity_.py +49 -0
  11. basic_memory/alembic/versions/a1b2c3d4e5f6_fix_project_foreign_keys.py +49 -0
  12. basic_memory/alembic/versions/a2b3c4d5e6f7_add_search_index_entity_cascade.py +56 -0
  13. basic_memory/alembic/versions/b3c3938bacdb_relation_to_name_unique_index.py +44 -0
  14. basic_memory/alembic/versions/cc7172b46608_update_search_index_schema.py +113 -0
  15. basic_memory/alembic/versions/e7e1f4367280_add_scan_watermark_tracking_to_project.py +37 -0
  16. basic_memory/alembic/versions/f8a9b2c3d4e5_add_pg_trgm_for_fuzzy_link_resolution.py +239 -0
  17. basic_memory/alembic/versions/g9a0b3c4d5e6_add_external_id_to_project_and_entity.py +173 -0
  18. basic_memory/api/app.py +87 -20
  19. basic_memory/api/container.py +133 -0
  20. basic_memory/api/routers/__init__.py +4 -1
  21. basic_memory/api/routers/directory_router.py +84 -0
  22. basic_memory/api/routers/importer_router.py +152 -0
  23. basic_memory/api/routers/knowledge_router.py +180 -23
  24. basic_memory/api/routers/management_router.py +80 -0
  25. basic_memory/api/routers/memory_router.py +9 -64
  26. basic_memory/api/routers/project_router.py +460 -0
  27. basic_memory/api/routers/prompt_router.py +260 -0
  28. basic_memory/api/routers/resource_router.py +136 -11
  29. basic_memory/api/routers/search_router.py +5 -5
  30. basic_memory/api/routers/utils.py +169 -0
  31. basic_memory/api/template_loader.py +292 -0
  32. basic_memory/api/v2/__init__.py +35 -0
  33. basic_memory/api/v2/routers/__init__.py +21 -0
  34. basic_memory/api/v2/routers/directory_router.py +93 -0
  35. basic_memory/api/v2/routers/importer_router.py +181 -0
  36. basic_memory/api/v2/routers/knowledge_router.py +427 -0
  37. basic_memory/api/v2/routers/memory_router.py +130 -0
  38. basic_memory/api/v2/routers/project_router.py +359 -0
  39. basic_memory/api/v2/routers/prompt_router.py +269 -0
  40. basic_memory/api/v2/routers/resource_router.py +286 -0
  41. basic_memory/api/v2/routers/search_router.py +73 -0
  42. basic_memory/cli/app.py +80 -10
  43. basic_memory/cli/auth.py +300 -0
  44. basic_memory/cli/commands/__init__.py +15 -2
  45. basic_memory/cli/commands/cloud/__init__.py +6 -0
  46. basic_memory/cli/commands/cloud/api_client.py +127 -0
  47. basic_memory/cli/commands/cloud/bisync_commands.py +110 -0
  48. basic_memory/cli/commands/cloud/cloud_utils.py +108 -0
  49. basic_memory/cli/commands/cloud/core_commands.py +195 -0
  50. basic_memory/cli/commands/cloud/rclone_commands.py +397 -0
  51. basic_memory/cli/commands/cloud/rclone_config.py +110 -0
  52. basic_memory/cli/commands/cloud/rclone_installer.py +263 -0
  53. basic_memory/cli/commands/cloud/upload.py +240 -0
  54. basic_memory/cli/commands/cloud/upload_command.py +124 -0
  55. basic_memory/cli/commands/command_utils.py +99 -0
  56. basic_memory/cli/commands/db.py +87 -12
  57. basic_memory/cli/commands/format.py +198 -0
  58. basic_memory/cli/commands/import_chatgpt.py +47 -223
  59. basic_memory/cli/commands/import_claude_conversations.py +48 -171
  60. basic_memory/cli/commands/import_claude_projects.py +53 -160
  61. basic_memory/cli/commands/import_memory_json.py +55 -111
  62. basic_memory/cli/commands/mcp.py +67 -11
  63. basic_memory/cli/commands/project.py +889 -0
  64. basic_memory/cli/commands/status.py +52 -34
  65. basic_memory/cli/commands/telemetry.py +81 -0
  66. basic_memory/cli/commands/tool.py +341 -0
  67. basic_memory/cli/container.py +84 -0
  68. basic_memory/cli/main.py +14 -6
  69. basic_memory/config.py +580 -26
  70. basic_memory/db.py +285 -28
  71. basic_memory/deps/__init__.py +293 -0
  72. basic_memory/deps/config.py +26 -0
  73. basic_memory/deps/db.py +56 -0
  74. basic_memory/deps/importers.py +200 -0
  75. basic_memory/deps/projects.py +238 -0
  76. basic_memory/deps/repositories.py +179 -0
  77. basic_memory/deps/services.py +480 -0
  78. basic_memory/deps.py +16 -185
  79. basic_memory/file_utils.py +318 -54
  80. basic_memory/ignore_utils.py +297 -0
  81. basic_memory/importers/__init__.py +27 -0
  82. basic_memory/importers/base.py +100 -0
  83. basic_memory/importers/chatgpt_importer.py +245 -0
  84. basic_memory/importers/claude_conversations_importer.py +192 -0
  85. basic_memory/importers/claude_projects_importer.py +184 -0
  86. basic_memory/importers/memory_json_importer.py +128 -0
  87. basic_memory/importers/utils.py +61 -0
  88. basic_memory/markdown/entity_parser.py +182 -23
  89. basic_memory/markdown/markdown_processor.py +70 -7
  90. basic_memory/markdown/plugins.py +43 -23
  91. basic_memory/markdown/schemas.py +1 -1
  92. basic_memory/markdown/utils.py +38 -14
  93. basic_memory/mcp/async_client.py +135 -4
  94. basic_memory/mcp/clients/__init__.py +28 -0
  95. basic_memory/mcp/clients/directory.py +70 -0
  96. basic_memory/mcp/clients/knowledge.py +176 -0
  97. basic_memory/mcp/clients/memory.py +120 -0
  98. basic_memory/mcp/clients/project.py +89 -0
  99. basic_memory/mcp/clients/resource.py +71 -0
  100. basic_memory/mcp/clients/search.py +65 -0
  101. basic_memory/mcp/container.py +110 -0
  102. basic_memory/mcp/project_context.py +155 -0
  103. basic_memory/mcp/prompts/__init__.py +19 -0
  104. basic_memory/mcp/prompts/ai_assistant_guide.py +70 -0
  105. basic_memory/mcp/prompts/continue_conversation.py +62 -0
  106. basic_memory/mcp/prompts/recent_activity.py +188 -0
  107. basic_memory/mcp/prompts/search.py +57 -0
  108. basic_memory/mcp/prompts/utils.py +162 -0
  109. basic_memory/mcp/resources/ai_assistant_guide.md +283 -0
  110. basic_memory/mcp/resources/project_info.py +71 -0
  111. basic_memory/mcp/server.py +61 -9
  112. basic_memory/mcp/tools/__init__.py +33 -21
  113. basic_memory/mcp/tools/build_context.py +120 -0
  114. basic_memory/mcp/tools/canvas.py +152 -0
  115. basic_memory/mcp/tools/chatgpt_tools.py +190 -0
  116. basic_memory/mcp/tools/delete_note.py +249 -0
  117. basic_memory/mcp/tools/edit_note.py +325 -0
  118. basic_memory/mcp/tools/list_directory.py +157 -0
  119. basic_memory/mcp/tools/move_note.py +549 -0
  120. basic_memory/mcp/tools/project_management.py +204 -0
  121. basic_memory/mcp/tools/read_content.py +281 -0
  122. basic_memory/mcp/tools/read_note.py +265 -0
  123. basic_memory/mcp/tools/recent_activity.py +528 -0
  124. basic_memory/mcp/tools/search.py +377 -24
  125. basic_memory/mcp/tools/utils.py +402 -16
  126. basic_memory/mcp/tools/view_note.py +78 -0
  127. basic_memory/mcp/tools/write_note.py +230 -0
  128. basic_memory/models/__init__.py +3 -2
  129. basic_memory/models/knowledge.py +82 -17
  130. basic_memory/models/project.py +93 -0
  131. basic_memory/models/search.py +68 -8
  132. basic_memory/project_resolver.py +222 -0
  133. basic_memory/repository/__init__.py +2 -0
  134. basic_memory/repository/entity_repository.py +437 -8
  135. basic_memory/repository/observation_repository.py +36 -3
  136. basic_memory/repository/postgres_search_repository.py +451 -0
  137. basic_memory/repository/project_info_repository.py +10 -0
  138. basic_memory/repository/project_repository.py +140 -0
  139. basic_memory/repository/relation_repository.py +79 -4
  140. basic_memory/repository/repository.py +148 -29
  141. basic_memory/repository/search_index_row.py +95 -0
  142. basic_memory/repository/search_repository.py +79 -268
  143. basic_memory/repository/search_repository_base.py +241 -0
  144. basic_memory/repository/sqlite_search_repository.py +437 -0
  145. basic_memory/runtime.py +61 -0
  146. basic_memory/schemas/__init__.py +22 -9
  147. basic_memory/schemas/base.py +131 -12
  148. basic_memory/schemas/cloud.py +50 -0
  149. basic_memory/schemas/directory.py +31 -0
  150. basic_memory/schemas/importer.py +35 -0
  151. basic_memory/schemas/memory.py +194 -25
  152. basic_memory/schemas/project_info.py +213 -0
  153. basic_memory/schemas/prompt.py +90 -0
  154. basic_memory/schemas/request.py +56 -2
  155. basic_memory/schemas/response.py +85 -28
  156. basic_memory/schemas/search.py +36 -35
  157. basic_memory/schemas/sync_report.py +72 -0
  158. basic_memory/schemas/v2/__init__.py +27 -0
  159. basic_memory/schemas/v2/entity.py +133 -0
  160. basic_memory/schemas/v2/resource.py +47 -0
  161. basic_memory/services/__init__.py +2 -1
  162. basic_memory/services/context_service.py +451 -138
  163. basic_memory/services/directory_service.py +310 -0
  164. basic_memory/services/entity_service.py +636 -71
  165. basic_memory/services/exceptions.py +21 -0
  166. basic_memory/services/file_service.py +402 -33
  167. basic_memory/services/initialization.py +216 -0
  168. basic_memory/services/link_resolver.py +50 -56
  169. basic_memory/services/project_service.py +888 -0
  170. basic_memory/services/search_service.py +232 -37
  171. basic_memory/sync/__init__.py +4 -2
  172. basic_memory/sync/background_sync.py +26 -0
  173. basic_memory/sync/coordinator.py +160 -0
  174. basic_memory/sync/sync_service.py +1200 -109
  175. basic_memory/sync/watch_service.py +432 -135
  176. basic_memory/telemetry.py +249 -0
  177. basic_memory/templates/prompts/continue_conversation.hbs +110 -0
  178. basic_memory/templates/prompts/search.hbs +101 -0
  179. basic_memory/utils.py +407 -54
  180. basic_memory-0.17.4.dist-info/METADATA +617 -0
  181. basic_memory-0.17.4.dist-info/RECORD +193 -0
  182. {basic_memory-0.7.0.dist-info → basic_memory-0.17.4.dist-info}/WHEEL +1 -1
  183. {basic_memory-0.7.0.dist-info → basic_memory-0.17.4.dist-info}/entry_points.txt +1 -0
  184. basic_memory/alembic/README +0 -1
  185. basic_memory/cli/commands/sync.py +0 -206
  186. basic_memory/cli/commands/tools.py +0 -157
  187. basic_memory/mcp/tools/knowledge.py +0 -68
  188. basic_memory/mcp/tools/memory.py +0 -170
  189. basic_memory/mcp/tools/notes.py +0 -202
  190. basic_memory/schemas/discovery.py +0 -28
  191. basic_memory/sync/file_change_scanner.py +0 -158
  192. basic_memory/sync/utils.py +0 -31
  193. basic_memory-0.7.0.dist-info/METADATA +0 -378
  194. basic_memory-0.7.0.dist-info/RECORD +0 -82
  195. {basic_memory-0.7.0.dist-info → basic_memory-0.17.4.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,617 @@
1
+ Metadata-Version: 2.4
2
+ Name: basic-memory
3
+ Version: 0.17.4
4
+ Summary: Local-first knowledge management combining Zettelkasten with knowledge graphs
5
+ Project-URL: Homepage, https://github.com/basicmachines-co/basic-memory
6
+ Project-URL: Repository, https://github.com/basicmachines-co/basic-memory
7
+ Project-URL: Documentation, https://github.com/basicmachines-co/basic-memory#readme
8
+ Author-email: Basic Machines <hello@basic-machines.co>
9
+ License: AGPL-3.0-or-later
10
+ License-File: LICENSE
11
+ Requires-Python: >=3.12
12
+ Requires-Dist: aiofiles>=24.1.0
13
+ Requires-Dist: aiosqlite>=0.20.0
14
+ Requires-Dist: alembic>=1.14.1
15
+ Requires-Dist: asyncpg>=0.30.0
16
+ Requires-Dist: dateparser>=1.2.0
17
+ Requires-Dist: fastapi[standard]>=0.115.8
18
+ Requires-Dist: fastmcp==2.12.3
19
+ Requires-Dist: greenlet>=3.1.1
20
+ Requires-Dist: loguru>=0.7.3
21
+ Requires-Dist: markdown-it-py>=3.0.0
22
+ Requires-Dist: mcp>=1.23.1
23
+ Requires-Dist: mdformat-frontmatter>=2.0.8
24
+ Requires-Dist: mdformat-gfm>=0.3.7
25
+ Requires-Dist: mdformat>=0.7.22
26
+ Requires-Dist: nest-asyncio>=1.6.0
27
+ Requires-Dist: openpanel>=0.0.1
28
+ Requires-Dist: pillow>=11.1.0
29
+ Requires-Dist: psycopg==3.3.1
30
+ Requires-Dist: pybars3>=0.9.7
31
+ Requires-Dist: pydantic-settings>=2.6.1
32
+ Requires-Dist: pydantic[email,timezone]>=2.10.3
33
+ Requires-Dist: pyjwt>=2.10.1
34
+ Requires-Dist: pyright>=1.1.390
35
+ Requires-Dist: pytest-aio>=1.9.0
36
+ Requires-Dist: pytest-asyncio>=1.2.0
37
+ Requires-Dist: python-dotenv>=1.1.0
38
+ Requires-Dist: python-frontmatter>=1.1.0
39
+ Requires-Dist: pyyaml>=6.0.1
40
+ Requires-Dist: rich>=13.9.4
41
+ Requires-Dist: sqlalchemy>=2.0.0
42
+ Requires-Dist: typer>=0.9.0
43
+ Requires-Dist: unidecode>=1.3.8
44
+ Requires-Dist: watchfiles>=1.0.4
45
+ Description-Content-Type: text/markdown
46
+
47
+ [![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
48
+ [![PyPI version](https://badge.fury.io/py/basic-memory.svg)](https://badge.fury.io/py/basic-memory)
49
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
50
+ [![Tests](https://github.com/basicmachines-co/basic-memory/workflows/Tests/badge.svg)](https://github.com/basicmachines-co/basic-memory/actions)
51
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
52
+ ![](https://badge.mcpx.dev?type=server 'MCP Server')
53
+ ![](https://badge.mcpx.dev?type=dev 'MCP Dev')
54
+ [![smithery badge](https://smithery.ai/badge/@basicmachines-co/basic-memory)](https://smithery.ai/server/@basicmachines-co/basic-memory)
55
+
56
+ ## 🚀 Basic Memory Cloud is Live!
57
+
58
+ - **Cross-device and multi-platform support is here.** Your knowledge graph now works on desktop, web, and mobile - seamlessly synced across all your AI tools (Claude, ChatGPT, Gemini, Claude Code, and Codex)
59
+ - **Early Supporter Pricing:** Early users get 25% off forever.
60
+ The open source project continues as always. Cloud just makes it work everywhere.
61
+
62
+ [Sign up now →](https://basicmemory.com/beta)
63
+
64
+ with a 7 day free trial
65
+
66
+ # Basic Memory
67
+
68
+ Basic Memory lets you build persistent knowledge through natural conversations with Large Language Models (LLMs) like
69
+ Claude, while keeping everything in simple Markdown files on your computer. It uses the Model Context Protocol (MCP) to
70
+ enable any compatible LLM to read and write to your local knowledge base.
71
+
72
+ - Website: https://basicmachines.co
73
+ - Documentation: https://memory.basicmachines.co
74
+
75
+ ## Pick up your conversation right where you left off
76
+
77
+ - AI assistants can load context from local files in a new conversation
78
+ - Notes are saved locally as Markdown files in real time
79
+ - No project knowledge or special prompting required
80
+
81
+ https://github.com/user-attachments/assets/a55d8238-8dd0-454a-be4c-8860dbbd0ddc
82
+
83
+ ## Quick Start
84
+
85
+ ```bash
86
+ # Install with uv (recommended)
87
+ uv tool install basic-memory
88
+
89
+ # Configure Claude Desktop (edit ~/Library/Application Support/Claude/claude_desktop_config.json)
90
+ # Add this to your config:
91
+ {
92
+ "mcpServers": {
93
+ "basic-memory": {
94
+ "command": "uvx",
95
+ "args": [
96
+ "basic-memory",
97
+ "mcp"
98
+ ]
99
+ }
100
+ }
101
+ }
102
+ # Now in Claude Desktop, you can:
103
+ # - Write notes with "Create a note about coffee brewing methods"
104
+ # - Read notes with "What do I know about pour over coffee?"
105
+ # - Search with "Find information about Ethiopian beans"
106
+
107
+ ```
108
+
109
+ You can view shared context via files in `~/basic-memory` (default directory location).
110
+
111
+ ### Alternative Installation via Smithery
112
+
113
+ You can use [Smithery](https://smithery.ai/server/@basicmachines-co/basic-memory) to automatically configure Basic
114
+ Memory for Claude Desktop:
115
+
116
+ ```bash
117
+ npx -y @smithery/cli install @basicmachines-co/basic-memory --client claude
118
+ ```
119
+
120
+ This installs and configures Basic Memory without requiring manual edits to the Claude Desktop configuration file. The
121
+ Smithery server hosts the MCP server component, while your data remains stored locally as Markdown files.
122
+
123
+ ### Glama.ai
124
+
125
+ <a href="https://glama.ai/mcp/servers/o90kttu9ym">
126
+ <img width="380" height="200" src="https://glama.ai/mcp/servers/o90kttu9ym/badge" alt="basic-memory MCP server" />
127
+ </a>
128
+
129
+ ## Why Basic Memory?
130
+
131
+ Most LLM interactions are ephemeral - you ask a question, get an answer, and everything is forgotten. Each conversation
132
+ starts fresh, without the context or knowledge from previous ones. Current workarounds have limitations:
133
+
134
+ - Chat histories capture conversations but aren't structured knowledge
135
+ - RAG systems can query documents but don't let LLMs write back
136
+ - Vector databases require complex setups and often live in the cloud
137
+ - Knowledge graphs typically need specialized tools to maintain
138
+
139
+ Basic Memory addresses these problems with a simple approach: structured Markdown files that both humans and LLMs can
140
+ read
141
+ and write to. The key advantages:
142
+
143
+ - **Local-first:** All knowledge stays in files you control
144
+ - **Bi-directional:** Both you and the LLM read and write to the same files
145
+ - **Structured yet simple:** Uses familiar Markdown with semantic patterns
146
+ - **Traversable knowledge graph:** LLMs can follow links between topics
147
+ - **Standard formats:** Works with existing editors like Obsidian
148
+ - **Lightweight infrastructure:** Just local files indexed in a local SQLite database
149
+
150
+ With Basic Memory, you can:
151
+
152
+ - Have conversations that build on previous knowledge
153
+ - Create structured notes during natural conversations
154
+ - Have conversations with LLMs that remember what you've discussed before
155
+ - Navigate your knowledge graph semantically
156
+ - Keep everything local and under your control
157
+ - Use familiar tools like Obsidian to view and edit notes
158
+ - Build a personal knowledge base that grows over time
159
+ - Sync your knowledge to the cloud with bidirectional synchronization
160
+ - Authenticate and manage cloud projects with subscription validation
161
+ - Mount cloud storage for direct file access
162
+
163
+ ## How It Works in Practice
164
+
165
+ Let's say you're exploring coffee brewing methods and want to capture your knowledge. Here's how it works:
166
+
167
+ 1. Start by chatting normally:
168
+
169
+ ```
170
+ I've been experimenting with different coffee brewing methods. Key things I've learned:
171
+
172
+ - Pour over gives more clarity in flavor than French press
173
+ - Water temperature is critical - around 205°F seems best
174
+ - Freshly ground beans make a huge difference
175
+ ```
176
+
177
+ ... continue conversation.
178
+
179
+ 2. Ask the LLM to help structure this knowledge:
180
+
181
+ ```
182
+ "Let's write a note about coffee brewing methods."
183
+ ```
184
+
185
+ LLM creates a new Markdown file on your system (which you can see instantly in Obsidian or your editor):
186
+
187
+ ```markdown
188
+ ---
189
+ title: Coffee Brewing Methods
190
+ permalink: coffee-brewing-methods
191
+ tags:
192
+ - coffee
193
+ - brewing
194
+ ---
195
+
196
+ # Coffee Brewing Methods
197
+
198
+ ## Observations
199
+
200
+ - [method] Pour over provides more clarity and highlights subtle flavors
201
+ - [technique] Water temperature at 205°F (96°C) extracts optimal compounds
202
+ - [principle] Freshly ground beans preserve aromatics and flavor
203
+
204
+ ## Relations
205
+
206
+ - relates_to [[Coffee Bean Origins]]
207
+ - requires [[Proper Grinding Technique]]
208
+ - affects [[Flavor Extraction]]
209
+ ```
210
+
211
+ The note embeds semantic content and links to other topics via simple Markdown formatting.
212
+
213
+ 3. You see this file on your computer in real time in the current project directory (default `~/$HOME/basic-memory`).
214
+
215
+ - Realtime sync can be enabled via running `basic-memory sync --watch`
216
+
217
+ 4. In a chat with the LLM, you can reference a topic:
218
+
219
+ ```
220
+ Look at `coffee-brewing-methods` for context about pour over coffee
221
+ ```
222
+
223
+ The LLM can now build rich context from the knowledge graph. For example:
224
+
225
+ ```
226
+ Following relation 'relates_to [[Coffee Bean Origins]]':
227
+ - Found information about Ethiopian Yirgacheffe
228
+ - Notes on Colombian beans' nutty profile
229
+ - Altitude effects on bean characteristics
230
+
231
+ Following relation 'requires [[Proper Grinding Technique]]':
232
+ - Burr vs. blade grinder comparisons
233
+ - Grind size recommendations for different methods
234
+ - Impact of consistent particle size on extraction
235
+ ```
236
+
237
+ Each related document can lead to more context, building a rich semantic understanding of your knowledge base.
238
+
239
+ This creates a two-way flow where:
240
+
241
+ - Humans write and edit Markdown files
242
+ - LLMs read and write through the MCP protocol
243
+ - Sync keeps everything consistent
244
+ - All knowledge stays in local files.
245
+
246
+ ## Technical Implementation
247
+
248
+ Under the hood, Basic Memory:
249
+
250
+ 1. Stores everything in Markdown files
251
+ 2. Uses a SQLite database for searching and indexing
252
+ 3. Extracts semantic meaning from simple Markdown patterns
253
+ - Files become `Entity` objects
254
+ - Each `Entity` can have `Observations`, or facts associated with it
255
+ - `Relations` connect entities together to form the knowledge graph
256
+ 4. Maintains the local knowledge graph derived from the files
257
+ 5. Provides bidirectional synchronization between files and the knowledge graph
258
+ 6. Implements the Model Context Protocol (MCP) for AI integration
259
+ 7. Exposes tools that let AI assistants traverse and manipulate the knowledge graph
260
+ 8. Uses memory:// URLs to reference entities across tools and conversations
261
+
262
+ The file format is just Markdown with some simple markup:
263
+
264
+ Each Markdown file has:
265
+
266
+ ### Frontmatter
267
+
268
+ ```markdown
269
+ title: <Entity title>
270
+ type: <The type of Entity> (e.g. note)
271
+ permalink: <a uri slug>
272
+
273
+ - <optional metadata> (such as tags)
274
+ ```
275
+
276
+ ### Observations
277
+
278
+ Observations are facts about a topic.
279
+ They can be added by creating a Markdown list with a special format that can reference a `category`, `tags` using a
280
+ "#" character, and an optional `context`.
281
+
282
+ Observation Markdown format:
283
+
284
+ ```markdown
285
+ - [category] content #tag (optional context)
286
+ ```
287
+
288
+ Examples of observations:
289
+
290
+ ```markdown
291
+ - [method] Pour over extracts more floral notes than French press
292
+ - [tip] Grind size should be medium-fine for pour over #brewing
293
+ - [preference] Ethiopian beans have bright, fruity flavors (especially from Yirgacheffe)
294
+ - [fact] Lighter roasts generally contain more caffeine than dark roasts
295
+ - [experiment] Tried 1:15 coffee-to-water ratio with good results
296
+ - [resource] James Hoffman's V60 technique on YouTube is excellent
297
+ - [question] Does water temperature affect extraction of different compounds differently?
298
+ - [note] My favorite local shop uses a 30-second bloom time
299
+ ```
300
+
301
+ ### Relations
302
+
303
+ Relations are links to other topics. They define how entities connect in the knowledge graph.
304
+
305
+ Markdown format:
306
+
307
+ ```markdown
308
+ - relation_type [[WikiLink]] (optional context)
309
+ ```
310
+
311
+ Examples of relations:
312
+
313
+ ```markdown
314
+ - pairs_well_with [[Chocolate Desserts]]
315
+ - grown_in [[Ethiopia]]
316
+ - contrasts_with [[Tea Brewing Methods]]
317
+ - requires [[Burr Grinder]]
318
+ - improves_with [[Fresh Beans]]
319
+ - relates_to [[Morning Routine]]
320
+ - inspired_by [[Japanese Coffee Culture]]
321
+ - documented_in [[Coffee Journal]]
322
+ ```
323
+
324
+ ## Using with VS Code
325
+
326
+ Add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing `Ctrl + Shift + P` and typing `Preferences: Open User Settings (JSON)`.
327
+
328
+ ```json
329
+ {
330
+ "mcp": {
331
+ "servers": {
332
+ "basic-memory": {
333
+ "command": "uvx",
334
+ "args": ["basic-memory", "mcp"]
335
+ }
336
+ }
337
+ }
338
+ }
339
+ ```
340
+
341
+ Optionally, you can add it to a file called `.vscode/mcp.json` in your workspace. This will allow you to share the configuration with others.
342
+
343
+ ```json
344
+ {
345
+ "servers": {
346
+ "basic-memory": {
347
+ "command": "uvx",
348
+ "args": ["basic-memory", "mcp"]
349
+ }
350
+ }
351
+ }
352
+ ```
353
+
354
+ You can use Basic Memory with VS Code to easily retrieve and store information while coding.
355
+
356
+ ## Using with Claude Desktop
357
+
358
+ Basic Memory is built using the MCP (Model Context Protocol) and works with the Claude desktop app (https://claude.ai/):
359
+
360
+ 1. Configure Claude Desktop to use Basic Memory:
361
+
362
+ Edit your MCP configuration file (usually located at `~/Library/Application Support/Claude/claude_desktop_config.json`
363
+ for OS X):
364
+
365
+ ```json
366
+ {
367
+ "mcpServers": {
368
+ "basic-memory": {
369
+ "command": "uvx",
370
+ "args": [
371
+ "basic-memory",
372
+ "mcp"
373
+ ]
374
+ }
375
+ }
376
+ }
377
+ ```
378
+
379
+ If you want to use a specific project (see [Multiple Projects](#multiple-projects) below), update your Claude Desktop
380
+ config:
381
+
382
+ ```json
383
+ {
384
+ "mcpServers": {
385
+ "basic-memory": {
386
+ "command": "uvx",
387
+ "args": [
388
+ "basic-memory",
389
+ "mcp",
390
+ "--project",
391
+ "your-project-name"
392
+ ]
393
+ }
394
+ }
395
+ }
396
+ ```
397
+
398
+ 2. Sync your knowledge:
399
+
400
+ ```bash
401
+ # One-time sync of local knowledge updates
402
+ basic-memory sync
403
+
404
+ # Run realtime sync process (recommended)
405
+ basic-memory sync --watch
406
+ ```
407
+
408
+ 3. Cloud features (optional, requires subscription):
409
+
410
+ ```bash
411
+ # Authenticate with cloud
412
+ basic-memory cloud login
413
+
414
+ # Bidirectional sync with cloud
415
+ basic-memory cloud sync
416
+
417
+ # Verify cloud integrity
418
+ basic-memory cloud check
419
+
420
+ # Mount cloud storage
421
+ basic-memory cloud mount
422
+ ```
423
+
424
+ 4. In Claude Desktop, the LLM can now use these tools:
425
+
426
+ **Content Management:**
427
+ ```
428
+ write_note(title, content, folder, tags) - Create or update notes
429
+ read_note(identifier, page, page_size) - Read notes by title or permalink
430
+ read_content(path) - Read raw file content (text, images, binaries)
431
+ view_note(identifier) - View notes as formatted artifacts
432
+ edit_note(identifier, operation, content) - Edit notes incrementally
433
+ move_note(identifier, destination_path) - Move notes with database consistency
434
+ delete_note(identifier) - Delete notes from knowledge base
435
+ ```
436
+
437
+ **Knowledge Graph Navigation:**
438
+ ```
439
+ build_context(url, depth, timeframe) - Navigate knowledge graph via memory:// URLs
440
+ recent_activity(type, depth, timeframe) - Find recently updated information
441
+ list_directory(dir_name, depth) - Browse directory contents with filtering
442
+ ```
443
+
444
+ **Search & Discovery:**
445
+ ```
446
+ search(query, page, page_size) - Search across your knowledge base
447
+ ```
448
+
449
+ **Project Management:**
450
+ ```
451
+ list_memory_projects() - List all available projects
452
+ create_memory_project(project_name, project_path) - Create new projects
453
+ get_current_project() - Show current project stats
454
+ sync_status() - Check synchronization status
455
+ ```
456
+
457
+ **Visualization:**
458
+ ```
459
+ canvas(nodes, edges, title, folder) - Generate knowledge visualizations
460
+ ```
461
+
462
+ 5. Example prompts to try:
463
+
464
+ ```
465
+ "Create a note about our project architecture decisions"
466
+ "Find information about JWT authentication in my notes"
467
+ "Create a canvas visualization of my project components"
468
+ "Read my notes on the authentication system"
469
+ "What have I been working on in the past week?"
470
+ ```
471
+
472
+ ## Futher info
473
+
474
+ See the [Documentation](https://memory.basicmachines.co/) for more info, including:
475
+
476
+ - [Complete User Guide](https://docs.basicmemory.com/user-guide/)
477
+ - [CLI tools](https://docs.basicmemory.com/guides/cli-reference/)
478
+ - [Cloud CLI and Sync](https://docs.basicmemory.com/guides/cloud-cli/)
479
+ - [Managing multiple Projects](https://docs.basicmemory.com/guides/cli-reference/#project)
480
+ - [Importing data from OpenAI/Claude Projects](https://docs.basicmemory.com/guides/cli-reference/#import)
481
+
482
+ ## Logging
483
+
484
+ Basic Memory uses [Loguru](https://github.com/Delgan/loguru) for logging. The logging behavior varies by entry point:
485
+
486
+ | Entry Point | Default Behavior | Use Case |
487
+ |-------------|------------------|----------|
488
+ | CLI commands | File only | Prevents log output from interfering with command output |
489
+ | MCP server | File only | Stdout would corrupt the JSON-RPC protocol |
490
+ | API server | File (local) or stdout (cloud) | Docker/cloud deployments use stdout |
491
+
492
+ **Log file location:** `~/.basic-memory/basic-memory.log` (10MB rotation, 10 days retention)
493
+
494
+ ### Environment Variables
495
+
496
+ | Variable | Default | Description |
497
+ |----------|---------|-------------|
498
+ | `BASIC_MEMORY_LOG_LEVEL` | `INFO` | Log level: DEBUG, INFO, WARNING, ERROR |
499
+ | `BASIC_MEMORY_CLOUD_MODE` | `false` | When `true`, API logs to stdout with structured context |
500
+ | `BASIC_MEMORY_ENV` | `dev` | Set to `test` for test mode (stderr only) |
501
+
502
+ ### Examples
503
+
504
+ ```bash
505
+ # Enable debug logging
506
+ BASIC_MEMORY_LOG_LEVEL=DEBUG basic-memory sync
507
+
508
+ # View logs
509
+ tail -f ~/.basic-memory/basic-memory.log
510
+
511
+ # Cloud/Docker mode (stdout logging with structured context)
512
+ BASIC_MEMORY_CLOUD_MODE=true uvicorn basic_memory.api.app:app
513
+ ```
514
+
515
+ ## Telemetry
516
+
517
+ Basic Memory collects anonymous usage statistics to help improve the software. This follows the [Homebrew model](https://docs.brew.sh/Analytics) - telemetry is on by default with easy opt-out.
518
+
519
+ **What we collect:**
520
+ - App version, Python version, OS, architecture
521
+ - Feature usage (which MCP tools and CLI commands are used)
522
+ - Error types (sanitized - no file paths or personal data)
523
+
524
+ **What we NEVER collect:**
525
+ - Note content, file names, or paths
526
+ - Personal information
527
+ - IP addresses
528
+
529
+ **Opting out:**
530
+ ```bash
531
+ # Disable telemetry
532
+ basic-memory telemetry disable
533
+
534
+ # Check status
535
+ basic-memory telemetry status
536
+
537
+ # Re-enable
538
+ basic-memory telemetry enable
539
+ ```
540
+
541
+ Or set the environment variable:
542
+ ```bash
543
+ export BASIC_MEMORY_TELEMETRY_ENABLED=false
544
+ ```
545
+
546
+ For more details, see the [Telemetry documentation](https://basicmemory.com/telemetry).
547
+
548
+ ## Development
549
+
550
+ ### Running Tests
551
+
552
+ Basic Memory supports dual database backends (SQLite and Postgres). By default, tests run against SQLite. Set `BASIC_MEMORY_TEST_POSTGRES=1` to run against Postgres (uses testcontainers - Docker required).
553
+
554
+ **Quick Start:**
555
+ ```bash
556
+ # Run all tests against SQLite (default, fast)
557
+ just test-sqlite
558
+
559
+ # Run all tests against Postgres (uses testcontainers)
560
+ just test-postgres
561
+
562
+ # Run both SQLite and Postgres tests
563
+ just test
564
+ ```
565
+
566
+ **Available Test Commands:**
567
+
568
+ - `just test` - Run all tests against both SQLite and Postgres
569
+ - `just test-sqlite` - Run all tests against SQLite (fast, no Docker needed)
570
+ - `just test-postgres` - Run all tests against Postgres (uses testcontainers)
571
+ - `just test-unit-sqlite` - Run unit tests against SQLite
572
+ - `just test-unit-postgres` - Run unit tests against Postgres
573
+ - `just test-int-sqlite` - Run integration tests against SQLite
574
+ - `just test-int-postgres` - Run integration tests against Postgres
575
+ - `just test-windows` - Run Windows-specific tests (auto-skips on other platforms)
576
+ - `just test-benchmark` - Run performance benchmark tests
577
+
578
+ **Postgres Testing:**
579
+
580
+ Postgres tests use [testcontainers](https://testcontainers-python.readthedocs.io/) which automatically spins up a Postgres instance in Docker. No manual database setup required - just have Docker running.
581
+
582
+ **Test Markers:**
583
+
584
+ Tests use pytest markers for selective execution:
585
+ - `windows` - Windows-specific database optimizations
586
+ - `benchmark` - Performance tests (excluded from default runs)
587
+
588
+ **Other Development Commands:**
589
+ ```bash
590
+ just install # Install with dev dependencies
591
+ just lint # Run linting checks
592
+ just typecheck # Run type checking
593
+ just format # Format code with ruff
594
+ just check # Run all quality checks
595
+ just migration "msg" # Create database migration
596
+ ```
597
+
598
+ See the [justfile](justfile) for the complete list of development commands.
599
+
600
+ ## License
601
+
602
+ AGPL-3.0
603
+
604
+ Contributions are welcome. See the [Contributing](CONTRIBUTING.md) guide for info about setting up the project locally
605
+ and submitting PRs.
606
+
607
+ ## Star History
608
+
609
+ <a href="https://www.star-history.com/#basicmachines-co/basic-memory&Date">
610
+ <picture>
611
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=basicmachines-co/basic-memory&type=Date&theme=dark" />
612
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=basicmachines-co/basic-memory&type=Date" />
613
+ <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=basicmachines-co/basic-memory&type=Date" />
614
+ </picture>
615
+ </a>
616
+
617
+ Built with ♥️ by Basic Machines