basic-memory 0.0.0__tar.gz → 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.

Potentially problematic release.


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

Files changed (131) hide show
  1. basic_memory-0.1.0/.github/workflows/test.yml +43 -0
  2. basic_memory-0.1.0/CHANGELOG.md +50 -0
  3. basic_memory-0.1.0/PKG-INFO +296 -0
  4. basic_memory-0.1.0/README.md +258 -0
  5. {basic_memory-0.0.0 → basic_memory-0.1.0}/pyproject.toml +3 -2
  6. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/api/app.py +23 -1
  7. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/api/routers/memory_router.py +1 -1
  8. basic_memory-0.1.0/src/basic_memory/cli/commands/__init__.py +5 -0
  9. basic_memory-0.1.0/src/basic_memory/cli/commands/import_memory_json.py +139 -0
  10. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/cli/main.py +1 -1
  11. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/config.py +5 -1
  12. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/db.py +40 -21
  13. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/file_utils.py +27 -62
  14. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/markdown/__init__.py +2 -0
  15. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/markdown/entity_parser.py +1 -1
  16. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/markdown/markdown_processor.py +2 -14
  17. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/markdown/plugins.py +1 -1
  18. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/markdown/schemas.py +1 -3
  19. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/mcp/tools/memory.py +8 -3
  20. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/models/__init__.py +9 -6
  21. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/models/base.py +4 -3
  22. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/repository/search_repository.py +8 -3
  23. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/schemas/base.py +5 -2
  24. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/schemas/memory.py +4 -1
  25. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/services/__init__.py +2 -1
  26. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/services/context_service.py +1 -1
  27. basic_memory-0.1.0/src/basic_memory/services/database_service.py +158 -0
  28. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/services/entity_service.py +52 -2
  29. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/services/file_service.py +0 -1
  30. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/sync/sync_service.py +25 -0
  31. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/api/test_knowledge_router.py +1 -1
  32. basic_memory-0.1.0/tests/cli/test_import_memory_json.py +175 -0
  33. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/conftest.py +3 -3
  34. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/markdown/test_entity_parser.py +2 -2
  35. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/markdown/test_markdown_plugins.py +4 -4
  36. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/markdown/test_markdown_processor.py +1 -1
  37. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/markdown/test_observation_edge_cases.py +2 -16
  38. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/markdown/test_parser_edge_cases.py +1 -1
  39. basic_memory-0.1.0/tests/services/test_database_service.py +158 -0
  40. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/services/test_entity_service.py +33 -4
  41. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/sync/test_sync_service.py +167 -4
  42. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/sync/test_watch_service.py +1 -1
  43. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/test_basic_memory.py +2 -2
  44. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/utils/test_file_utils.py +59 -78
  45. {basic_memory-0.0.0 → basic_memory-0.1.0}/uv.lock +55 -743
  46. basic_memory-0.0.0/CHANGELOG.md +0 -5
  47. basic_memory-0.0.0/PKG-INFO +0 -71
  48. basic_memory-0.0.0/README.md +0 -34
  49. basic_memory-0.0.0/src/basic_memory/cli/commands/__init__.py +0 -9
  50. basic_memory-0.0.0/tests/cli/test_status.py +0 -170
  51. {basic_memory-0.0.0 → basic_memory-0.1.0}/.github/workflows/release.yml +0 -0
  52. {basic_memory-0.0.0 → basic_memory-0.1.0}/.gitignore +0 -0
  53. {basic_memory-0.0.0 → basic_memory-0.1.0}/.python-version +0 -0
  54. {basic_memory-0.0.0 → basic_memory-0.1.0}/CITATION.cff +0 -0
  55. {basic_memory-0.0.0 → basic_memory-0.1.0}/CODE_OF_CONDUCT.md +0 -0
  56. {basic_memory-0.0.0 → basic_memory-0.1.0}/CONTRIBUTING.md +0 -0
  57. {basic_memory-0.0.0 → basic_memory-0.1.0}/LICENSE +0 -0
  58. {basic_memory-0.0.0 → basic_memory-0.1.0}/Makefile +0 -0
  59. {basic_memory-0.0.0 → basic_memory-0.1.0}/basic-memory.md +0 -0
  60. {basic_memory-0.0.0 → basic_memory-0.1.0}/memory.json +0 -0
  61. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/__init__.py +0 -0
  62. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/api/__init__.py +0 -0
  63. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/api/routers/__init__.py +0 -0
  64. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/api/routers/knowledge_router.py +0 -0
  65. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/api/routers/resource_router.py +0 -0
  66. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/api/routers/search_router.py +0 -0
  67. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/cli/__init__.py +0 -0
  68. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/cli/app.py +0 -0
  69. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/cli/commands/init.py +0 -0
  70. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/cli/commands/status.py +0 -0
  71. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/cli/commands/sync.py +0 -0
  72. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/deps.py +0 -0
  73. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/markdown/utils.py +0 -0
  74. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/mcp/__init__.py +0 -0
  75. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/mcp/async_client.py +0 -0
  76. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/mcp/main.py +0 -0
  77. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/mcp/server.py +0 -0
  78. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/mcp/tools/__init__.py +0 -0
  79. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/mcp/tools/ai_edit.py +0 -0
  80. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/mcp/tools/knowledge.py +0 -0
  81. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/mcp/tools/notes.py +0 -0
  82. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/mcp/tools/search.py +0 -0
  83. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/mcp/tools/utils.py +0 -0
  84. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/models/knowledge.py +0 -0
  85. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/models/search.py +0 -0
  86. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/repository/__init__.py +0 -0
  87. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/repository/entity_repository.py +0 -0
  88. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/repository/observation_repository.py +0 -0
  89. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/repository/relation_repository.py +0 -0
  90. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/repository/repository.py +0 -0
  91. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/schemas/__init__.py +0 -0
  92. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/schemas/delete.py +0 -0
  93. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/schemas/discovery.py +0 -0
  94. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/schemas/request.py +0 -0
  95. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/schemas/response.py +0 -0
  96. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/schemas/search.py +0 -0
  97. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/services/exceptions.py +0 -0
  98. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/services/link_resolver.py +0 -0
  99. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/services/search_service.py +0 -0
  100. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/services/service.py +0 -0
  101. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/sync/__init__.py +0 -0
  102. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/sync/file_change_scanner.py +0 -0
  103. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/sync/utils.py +0 -0
  104. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/sync/watch_service.py +0 -0
  105. {basic_memory-0.0.0 → basic_memory-0.1.0}/src/basic_memory/utils.py +0 -0
  106. {basic_memory-0.0.0 → basic_memory-0.1.0}/tasks.md +0 -0
  107. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/api/conftest.py +0 -0
  108. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/api/test_memory_router.py +0 -0
  109. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/api/test_resource_router.py +0 -0
  110. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/api/test_search_router.py +0 -0
  111. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/edit_file_test.py +0 -0
  112. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/markdown/__init__.py +0 -0
  113. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/markdown/test_relation_edge_cases.py +0 -0
  114. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/mcp/conftest.py +0 -0
  115. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/mcp/test_tool_ai_edit.py +0 -0
  116. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/mcp/test_tool_get_entity.py +0 -0
  117. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/mcp/test_tool_memory.py +0 -0
  118. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/mcp/test_tool_notes.py +0 -0
  119. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/repository/test_entity_repository.py +0 -0
  120. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/repository/test_observation_repository.py +0 -0
  121. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/repository/test_relation_repository.py +0 -0
  122. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/repository/test_repository.py +0 -0
  123. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/schemas/test_memory_url.py +0 -0
  124. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/schemas/test_schemas.py +0 -0
  125. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/schemas/test_search.py +0 -0
  126. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/services/test_context_service.py +0 -0
  127. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/services/test_file_service.py +0 -0
  128. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/services/test_link_resolver.py +0 -0
  129. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/services/test_search_service.py +0 -0
  130. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/sync/test_file_change_scanner.py +0 -0
  131. {basic_memory-0.0.0 → basic_memory-0.1.0}/tests/utils/test_permalink_formatting.py +0 -0
@@ -0,0 +1,43 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version: [ "3.12" ]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ with:
20
+ submodules: true
21
+
22
+ - name: Set up Python ${{ matrix.python-version }}
23
+ uses: actions/setup-python@v4
24
+ with:
25
+ python-version: ${{ matrix.python-version }}
26
+ cache: 'pip'
27
+
28
+ - name: Install uv
29
+ run: |
30
+ pip install uv
31
+
32
+ - name: Create virtual env
33
+ run: |
34
+ uv venv
35
+
36
+ - name: Install dependencies
37
+ run: |
38
+ uv pip install -e .[dev]
39
+
40
+ - name: Run tests
41
+ run: |
42
+ uv pip install pytest pytest-cov
43
+ uv run make test
@@ -0,0 +1,50 @@
1
+ # CHANGELOG
2
+
3
+
4
+ ## v0.1.0 (2025-02-07)
5
+
6
+ ### Bug Fixes
7
+
8
+ - Create virtual env in test workflow
9
+ ([`8092e6d`](https://github.com/basicmachines-co/basic-memory/commit/8092e6d38d536bfb6f93c3d21ea9baf1814f9b0a))
10
+
11
+ - Fix permalink uniqueness violations on create/update/sync
12
+ ([`135bec1`](https://github.com/basicmachines-co/basic-memory/commit/135bec181d9b3d53725c8af3a0959ebc1aa6afda))
13
+
14
+ - Fix recent activity bug
15
+ ([`3d2c0c8`](https://github.com/basicmachines-co/basic-memory/commit/3d2c0c8c32fcfdaf70a1f96a59d8f168f38a1aa9))
16
+
17
+ - Install fastapi deps after removing basic-foundation
18
+ ([`51a741e`](https://github.com/basicmachines-co/basic-memory/commit/51a741e7593a1ea0e5eb24e14c70ff61670f9663))
19
+
20
+ - Remove basic-foundation from deps
21
+ ([`b8d0c71`](https://github.com/basicmachines-co/basic-memory/commit/b8d0c7160f29c97cdafe398a7e6a5240473e0c89))
22
+
23
+ - Run tests via uv
24
+ ([`4eec820`](https://github.com/basicmachines-co/basic-memory/commit/4eec820a32bc059a405e2f4dac4c73b245ca4722))
25
+
26
+ ### Chores
27
+
28
+ - Rename import tool
29
+ ([`af6b7dc`](https://github.com/basicmachines-co/basic-memory/commit/af6b7dc40a55eaa2aa78d6ea831e613851081d52))
30
+
31
+ ### Features
32
+
33
+ - Add memory-json importer, tweak observation content
34
+ ([`3484e26`](https://github.com/basicmachines-co/basic-memory/commit/3484e26631187f165ee6eb85517e94717b7cf2cf))
35
+
36
+
37
+ ## v0.0.1 (2025-02-04)
38
+
39
+ ### Bug Fixes
40
+
41
+ - Fix versioning for 0.0.1 release
42
+ ([`ba1e494`](https://github.com/basicmachines-co/basic-memory/commit/ba1e494ed1afbb7af3f97c643126bced425da7e0))
43
+
44
+
45
+ ## v0.0.0 (2025-02-04)
46
+
47
+ ### Chores
48
+
49
+ - Remove basic-foundation src ref in pyproject.toml
50
+ ([`29fce8b`](https://github.com/basicmachines-co/basic-memory/commit/29fce8b0b922d54d7799bf2534107ee6cfb961b8))
@@ -0,0 +1,296 @@
1
+ Metadata-Version: 2.4
2
+ Name: basic-memory
3
+ Version: 0.1.0
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.1
12
+ Requires-Dist: aiosqlite>=0.20.0
13
+ Requires-Dist: alembic>=1.14.1
14
+ Requires-Dist: dateparser>=1.2.0
15
+ Requires-Dist: fastapi[standard]>=0.115.8
16
+ Requires-Dist: greenlet>=3.1.1
17
+ Requires-Dist: icecream>=2.1.3
18
+ Requires-Dist: loguru>=0.7.3
19
+ Requires-Dist: markdown-it-py>=3.0.0
20
+ Requires-Dist: mcp>=1.2.0
21
+ Requires-Dist: pydantic-settings>=2.6.1
22
+ Requires-Dist: pydantic[email,timezone]>=2.10.3
23
+ Requires-Dist: pyright>=1.1.390
24
+ Requires-Dist: python-frontmatter>=1.1.0
25
+ Requires-Dist: pyyaml>=6.0.1
26
+ Requires-Dist: rich>=13.9.4
27
+ Requires-Dist: sqlalchemy>=2.0.0
28
+ Requires-Dist: typer>=0.9.0
29
+ Requires-Dist: unidecode>=1.3.8
30
+ Requires-Dist: watchfiles>=1.0.4
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
33
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
34
+ Requires-Dist: pytest-mock>=3.12.0; extra == 'dev'
35
+ Requires-Dist: pytest>=8.3.4; extra == 'dev'
36
+ Requires-Dist: ruff>=0.1.6; extra == 'dev'
37
+ Description-Content-Type: text/markdown
38
+
39
+ # Basic Memory
40
+
41
+ Basic Memory lets you build persistent knowledge through natural conversations with Large Language Models (LLMs) like
42
+ Claude, while keeping everything in simple markdown files on your computer. It uses the Model Context Protocol (MCP) to
43
+ enable any compatible LLM to read and write to your local knowledge base.
44
+
45
+ ## What is Basic Memory?
46
+
47
+ Most people use LLMs like calculators - paste in some text, expect to get an answer back, repeat. Each conversation
48
+ starts fresh,
49
+ and any knowledge or context is lost. Some try to work around this by:
50
+
51
+ - Saving chat histories (but they're hard to reference)
52
+ - Copying and pasting previous conversations (messy and repetitive)
53
+ - Using RAG systems to query documents (complex and often cloud-based)
54
+
55
+ Basic Memory takes a different approach by letting both humans and LLMs read and write knowledge naturally using
56
+ standard markdown files. This means:
57
+
58
+ - Your knowledge stays in files you control
59
+ - Both you and the LLM can read and write notes
60
+ - Context persists across conversations
61
+ - Context stays local and user controlled
62
+
63
+ ## How It Works in Practice
64
+
65
+ Let's say you're working on a new project and want to capture design decisions. Here's how it works:
66
+
67
+ 1. Start by chatting normally:
68
+
69
+ ```markdown
70
+ We need to design a new auth system, some key features:
71
+
72
+ - local first, don't delegate users to third party system
73
+ - support multiple platforms via jwt
74
+ - want to keep it simple but secure
75
+ ```
76
+
77
+ ... continue conversation.
78
+
79
+ 2. Ask Claude to help structure this knowledge:
80
+
81
+ ```
82
+ "Lets write a note about the auth system design."
83
+ ```
84
+
85
+ Claude creates a new markdown file on your system (which you can see instantly in Obsidian or your editor):
86
+
87
+ ```markdown
88
+ ---
89
+ title: Auth System Design
90
+ permalink: auth-system-design
91
+ tags
92
+ - design
93
+ - auth
94
+ ---
95
+
96
+ # Auth System Design
97
+
98
+ ## Observations
99
+
100
+ - [requirement] Local-first authentication without third party delegation
101
+ - [tech] JWT-based auth for cross-platform support
102
+ - [principle] Balance simplicity with security
103
+
104
+ ## Relations
105
+
106
+ - implements [[Security Requirements]]
107
+ - relates_to [[Platform Support]]
108
+ - referenced_by [[JWT Implementation]]
109
+ ```
110
+
111
+ The note embeds semantic content (Observations) and links to other topics (Relations) via simple markdown formatting.
112
+
113
+ 3. You can edit this file directly in your editor in real time:
114
+
115
+ ```markdown
116
+ # Auth System Design
117
+
118
+ ## Observations
119
+
120
+ - [requirement] Local-first authentication without third party delegation
121
+ - [tech] JWT-based auth for cross-platform support
122
+ - [principle] Balance simplicity with security
123
+ - [decision] Will use bcrypt for password hashing # Added by you
124
+
125
+ ## Relations
126
+
127
+ - implements [[Security Requirements]]
128
+ - relates_to [[Platform Support]]
129
+ - referenced_by [[JWT Implementation]]
130
+ - blocks [[User Service]] # Added by you
131
+ ```
132
+
133
+ 4. In a new chat with Claude, you can reference this knowledge:
134
+
135
+ ```
136
+ "Claude, look at memory://auth-system-design for context about our auth system"
137
+ ```
138
+
139
+ Claude can now build rich context from the knowledge graph. For example:
140
+
141
+ ```
142
+ Following relation 'implements [[Security Requirements]]':
143
+ - Found authentication best practices
144
+ - OWASP guidelines for JWT
145
+ - Rate limiting requirements
146
+
147
+ Following relation 'relates_to [[Platform Support]]':
148
+ - Mobile auth requirements
149
+ - Browser security considerations
150
+ - JWT storage strategies
151
+ ```
152
+
153
+ Each related document can lead to more context, building a rich semantic understanding of your knowledge base. All of
154
+ this context comes from standard markdown files that both humans and LLMs can read and write.
155
+
156
+ Everything stays in local markdown files that you can:
157
+
158
+ - Edit in any text editor
159
+ - Version via git
160
+ - Back up normally
161
+ - Share when you want to
162
+
163
+ ## Technical Implementation
164
+
165
+ Under the hood, Basic Memory:
166
+
167
+ 1. Stores everything in markdown files
168
+ 2. Uses a SQLite database just for searching and indexing
169
+ 3. Extracts semantic meaning from simple markdown patterns
170
+ 4. Maintains a local knowledge graph from file content
171
+
172
+ The file format is just markdown with some simple markup:
173
+
174
+ Frontmatter
175
+
176
+ - title
177
+ - type
178
+ - permalink
179
+ - optional metadata
180
+
181
+ Observations
182
+
183
+ - facts about a topic
184
+
185
+ ```markdown
186
+ - [category] content #tag (optional context)
187
+ ```
188
+
189
+ Relations
190
+
191
+ - links to other topics
192
+
193
+ ```markdown
194
+ - relation_type [[WikiLink]] (optional context)
195
+ ```
196
+
197
+ Example:
198
+
199
+ ```markdown
200
+ ---
201
+ title: Note tile
202
+ type: note
203
+ permalink: unique/stable/id # Added automatically
204
+ tags
205
+ - tag1
206
+ - tag2
207
+ ---
208
+
209
+ # Note Title
210
+
211
+ Regular markdown content...
212
+
213
+ ## Observations
214
+
215
+ - [category] Structured knowledge #tag (optional context)
216
+ - [idea] Another observation
217
+
218
+ ## Relations
219
+
220
+ - links_to [[Other Note]]
221
+ - implements [[Some Spec]]
222
+ ```
223
+
224
+ Basic Memory will parse the markdown and derive the semantic relationships in the content. When you run
225
+ `basic-memory sync`:
226
+
227
+ 1. New and changed files are detected
228
+ 2. Markdown patterns become semantic knowledge:
229
+
230
+ - `[tech]` becomes a categorized observation
231
+ - `[[WikiLink]]` creates a relation in the knowledge graph
232
+ - Tags and metadata are indexed for search
233
+
234
+ 3. A SQLite database maintains these relationships for fast querying
235
+ 4. Claude and other MCP-compatible LLMs can access this knowledge via memory:// URLs
236
+
237
+ This creates a two-way flow where:
238
+
239
+ - Humans write and edit markdown files
240
+ - LLMs read and write through the MCP protocol
241
+ - Sync keeps everything consistent
242
+ - All knowledge stays in local files.
243
+
244
+ ## Using with Claude
245
+
246
+ Basic Memory works with the Claude desktop app (https://claude.ai/):
247
+
248
+ 1. Install Basic Memory locally:
249
+
250
+ ```bash
251
+ {
252
+ "mcpServers": {
253
+ "basic-memory": {
254
+ "command": "uvx",
255
+ "args": [
256
+ "basic-memory"
257
+ ]
258
+ }
259
+ }
260
+ ```
261
+
262
+ 2. Add to Claude Desktop:
263
+
264
+ ```
265
+ Basic Memory is available with these tools:
266
+ - write_note() for creating/updating notes
267
+ - read_note() for loading notes
268
+ - build_context() to load notes via memory:// URLs
269
+ - recent_activity() to find recently updated information
270
+ - search() to search infomation in the knowledge base
271
+ ```
272
+
273
+ 3. Install via uv
274
+
275
+ ```bash
276
+ uv add basic-memory
277
+
278
+ # sync local knowledge updates
279
+ basic-memory sync
280
+
281
+ # run realtime sync process
282
+ basic-memory sync --watch
283
+ ```
284
+
285
+ ## Design Philosophy
286
+
287
+ Basic Memory is built on some key ideas:
288
+
289
+ - Your knowledge should stay in files you control
290
+ - Both humans and AI should use natural formats
291
+ - Simple text patterns can capture rich meaning
292
+ - Local-first doesn't mean feature-poor
293
+
294
+ ## License
295
+
296
+ AGPL-3.0
@@ -0,0 +1,258 @@
1
+ # Basic Memory
2
+
3
+ Basic Memory lets you build persistent knowledge through natural conversations with Large Language Models (LLMs) like
4
+ Claude, while keeping everything in simple markdown files on your computer. It uses the Model Context Protocol (MCP) to
5
+ enable any compatible LLM to read and write to your local knowledge base.
6
+
7
+ ## What is Basic Memory?
8
+
9
+ Most people use LLMs like calculators - paste in some text, expect to get an answer back, repeat. Each conversation
10
+ starts fresh,
11
+ and any knowledge or context is lost. Some try to work around this by:
12
+
13
+ - Saving chat histories (but they're hard to reference)
14
+ - Copying and pasting previous conversations (messy and repetitive)
15
+ - Using RAG systems to query documents (complex and often cloud-based)
16
+
17
+ Basic Memory takes a different approach by letting both humans and LLMs read and write knowledge naturally using
18
+ standard markdown files. This means:
19
+
20
+ - Your knowledge stays in files you control
21
+ - Both you and the LLM can read and write notes
22
+ - Context persists across conversations
23
+ - Context stays local and user controlled
24
+
25
+ ## How It Works in Practice
26
+
27
+ Let's say you're working on a new project and want to capture design decisions. Here's how it works:
28
+
29
+ 1. Start by chatting normally:
30
+
31
+ ```markdown
32
+ We need to design a new auth system, some key features:
33
+
34
+ - local first, don't delegate users to third party system
35
+ - support multiple platforms via jwt
36
+ - want to keep it simple but secure
37
+ ```
38
+
39
+ ... continue conversation.
40
+
41
+ 2. Ask Claude to help structure this knowledge:
42
+
43
+ ```
44
+ "Lets write a note about the auth system design."
45
+ ```
46
+
47
+ Claude creates a new markdown file on your system (which you can see instantly in Obsidian or your editor):
48
+
49
+ ```markdown
50
+ ---
51
+ title: Auth System Design
52
+ permalink: auth-system-design
53
+ tags
54
+ - design
55
+ - auth
56
+ ---
57
+
58
+ # Auth System Design
59
+
60
+ ## Observations
61
+
62
+ - [requirement] Local-first authentication without third party delegation
63
+ - [tech] JWT-based auth for cross-platform support
64
+ - [principle] Balance simplicity with security
65
+
66
+ ## Relations
67
+
68
+ - implements [[Security Requirements]]
69
+ - relates_to [[Platform Support]]
70
+ - referenced_by [[JWT Implementation]]
71
+ ```
72
+
73
+ The note embeds semantic content (Observations) and links to other topics (Relations) via simple markdown formatting.
74
+
75
+ 3. You can edit this file directly in your editor in real time:
76
+
77
+ ```markdown
78
+ # Auth System Design
79
+
80
+ ## Observations
81
+
82
+ - [requirement] Local-first authentication without third party delegation
83
+ - [tech] JWT-based auth for cross-platform support
84
+ - [principle] Balance simplicity with security
85
+ - [decision] Will use bcrypt for password hashing # Added by you
86
+
87
+ ## Relations
88
+
89
+ - implements [[Security Requirements]]
90
+ - relates_to [[Platform Support]]
91
+ - referenced_by [[JWT Implementation]]
92
+ - blocks [[User Service]] # Added by you
93
+ ```
94
+
95
+ 4. In a new chat with Claude, you can reference this knowledge:
96
+
97
+ ```
98
+ "Claude, look at memory://auth-system-design for context about our auth system"
99
+ ```
100
+
101
+ Claude can now build rich context from the knowledge graph. For example:
102
+
103
+ ```
104
+ Following relation 'implements [[Security Requirements]]':
105
+ - Found authentication best practices
106
+ - OWASP guidelines for JWT
107
+ - Rate limiting requirements
108
+
109
+ Following relation 'relates_to [[Platform Support]]':
110
+ - Mobile auth requirements
111
+ - Browser security considerations
112
+ - JWT storage strategies
113
+ ```
114
+
115
+ Each related document can lead to more context, building a rich semantic understanding of your knowledge base. All of
116
+ this context comes from standard markdown files that both humans and LLMs can read and write.
117
+
118
+ Everything stays in local markdown files that you can:
119
+
120
+ - Edit in any text editor
121
+ - Version via git
122
+ - Back up normally
123
+ - Share when you want to
124
+
125
+ ## Technical Implementation
126
+
127
+ Under the hood, Basic Memory:
128
+
129
+ 1. Stores everything in markdown files
130
+ 2. Uses a SQLite database just for searching and indexing
131
+ 3. Extracts semantic meaning from simple markdown patterns
132
+ 4. Maintains a local knowledge graph from file content
133
+
134
+ The file format is just markdown with some simple markup:
135
+
136
+ Frontmatter
137
+
138
+ - title
139
+ - type
140
+ - permalink
141
+ - optional metadata
142
+
143
+ Observations
144
+
145
+ - facts about a topic
146
+
147
+ ```markdown
148
+ - [category] content #tag (optional context)
149
+ ```
150
+
151
+ Relations
152
+
153
+ - links to other topics
154
+
155
+ ```markdown
156
+ - relation_type [[WikiLink]] (optional context)
157
+ ```
158
+
159
+ Example:
160
+
161
+ ```markdown
162
+ ---
163
+ title: Note tile
164
+ type: note
165
+ permalink: unique/stable/id # Added automatically
166
+ tags
167
+ - tag1
168
+ - tag2
169
+ ---
170
+
171
+ # Note Title
172
+
173
+ Regular markdown content...
174
+
175
+ ## Observations
176
+
177
+ - [category] Structured knowledge #tag (optional context)
178
+ - [idea] Another observation
179
+
180
+ ## Relations
181
+
182
+ - links_to [[Other Note]]
183
+ - implements [[Some Spec]]
184
+ ```
185
+
186
+ Basic Memory will parse the markdown and derive the semantic relationships in the content. When you run
187
+ `basic-memory sync`:
188
+
189
+ 1. New and changed files are detected
190
+ 2. Markdown patterns become semantic knowledge:
191
+
192
+ - `[tech]` becomes a categorized observation
193
+ - `[[WikiLink]]` creates a relation in the knowledge graph
194
+ - Tags and metadata are indexed for search
195
+
196
+ 3. A SQLite database maintains these relationships for fast querying
197
+ 4. Claude and other MCP-compatible LLMs can access this knowledge via memory:// URLs
198
+
199
+ This creates a two-way flow where:
200
+
201
+ - Humans write and edit markdown files
202
+ - LLMs read and write through the MCP protocol
203
+ - Sync keeps everything consistent
204
+ - All knowledge stays in local files.
205
+
206
+ ## Using with Claude
207
+
208
+ Basic Memory works with the Claude desktop app (https://claude.ai/):
209
+
210
+ 1. Install Basic Memory locally:
211
+
212
+ ```bash
213
+ {
214
+ "mcpServers": {
215
+ "basic-memory": {
216
+ "command": "uvx",
217
+ "args": [
218
+ "basic-memory"
219
+ ]
220
+ }
221
+ }
222
+ ```
223
+
224
+ 2. Add to Claude Desktop:
225
+
226
+ ```
227
+ Basic Memory is available with these tools:
228
+ - write_note() for creating/updating notes
229
+ - read_note() for loading notes
230
+ - build_context() to load notes via memory:// URLs
231
+ - recent_activity() to find recently updated information
232
+ - search() to search infomation in the knowledge base
233
+ ```
234
+
235
+ 3. Install via uv
236
+
237
+ ```bash
238
+ uv add basic-memory
239
+
240
+ # sync local knowledge updates
241
+ basic-memory sync
242
+
243
+ # run realtime sync process
244
+ basic-memory sync --watch
245
+ ```
246
+
247
+ ## Design Philosophy
248
+
249
+ Basic Memory is built on some key ideas:
250
+
251
+ - Your knowledge should stay in files you control
252
+ - Both humans and AI should use natural formats
253
+ - Simple text patterns can capture rich meaning
254
+ - Local-first doesn't mean feature-poor
255
+
256
+ ## License
257
+
258
+ AGPL-3.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "basic-memory"
3
- version = "0.0.0"
3
+ version = "0.1.0"
4
4
  description = "Local-first knowledge management combining Zettelkasten with knowledge graphs"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12.1"
@@ -20,13 +20,14 @@ dependencies = [
20
20
  "pydantic-settings>=2.6.1",
21
21
  "loguru>=0.7.3",
22
22
  "pyright>=1.1.390",
23
- "basic-foundation",
24
23
  "markdown-it-py>=3.0.0",
25
24
  "python-frontmatter>=1.1.0",
26
25
  "rich>=13.9.4",
27
26
  "unidecode>=1.3.8",
28
27
  "dateparser>=1.2.0",
29
28
  "watchfiles>=1.0.4",
29
+ "fastapi[standard]>=0.115.8",
30
+ "alembic>=1.14.1",
30
31
  ]
31
32
 
32
33
  [project.optional-dependencies]
@@ -7,18 +7,40 @@ from fastapi.exception_handlers import http_exception_handler
7
7
  from loguru import logger
8
8
 
9
9
  from basic_memory import db
10
- from .routers import knowledge, search, memory, resource
10
+ from basic_memory.api.routers import knowledge, search, memory, resource
11
+ from basic_memory.config import config
12
+ from basic_memory.services import DatabaseService
11
13
 
12
14
 
13
15
  @asynccontextmanager
14
16
  async def lifespan(app: FastAPI):
15
17
  """Lifecycle manager for the FastAPI app."""
16
18
  logger.info("Starting Basic Memory API")
19
+
20
+ # check the db state
21
+ await check_db(app)
17
22
  yield
18
23
  logger.info("Shutting down Basic Memory API")
19
24
  await db.shutdown_db()
20
25
 
21
26
 
27
+ async def check_db(app: FastAPI):
28
+ logger.info("Checking database state")
29
+
30
+ # Initialize DB management service
31
+ db_service = DatabaseService(
32
+ config=config,
33
+ )
34
+
35
+ # Check and initialize DB if needed
36
+ if not await db_service.check_db():
37
+ raise RuntimeError("Database initialization failed")
38
+
39
+ # Clean up old backups on shutdown
40
+ await db_service.cleanup_backups()
41
+
42
+
43
+
22
44
  # Initialize FastAPI app
23
45
  app = FastAPI(
24
46
  title="Basic Memory API",