basic-memory 0.14.4__py3-none-any.whl → 0.15.1__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 (84) hide show
  1. basic_memory/__init__.py +1 -1
  2. basic_memory/alembic/versions/a1b2c3d4e5f6_fix_project_foreign_keys.py +5 -9
  3. basic_memory/api/app.py +10 -4
  4. basic_memory/api/routers/directory_router.py +23 -2
  5. basic_memory/api/routers/knowledge_router.py +25 -8
  6. basic_memory/api/routers/project_router.py +100 -4
  7. basic_memory/cli/app.py +9 -28
  8. basic_memory/cli/auth.py +277 -0
  9. basic_memory/cli/commands/cloud/__init__.py +5 -0
  10. basic_memory/cli/commands/cloud/api_client.py +112 -0
  11. basic_memory/cli/commands/cloud/bisync_commands.py +818 -0
  12. basic_memory/cli/commands/cloud/core_commands.py +288 -0
  13. basic_memory/cli/commands/cloud/mount_commands.py +295 -0
  14. basic_memory/cli/commands/cloud/rclone_config.py +288 -0
  15. basic_memory/cli/commands/cloud/rclone_installer.py +198 -0
  16. basic_memory/cli/commands/command_utils.py +43 -0
  17. basic_memory/cli/commands/import_memory_json.py +0 -4
  18. basic_memory/cli/commands/mcp.py +77 -60
  19. basic_memory/cli/commands/project.py +154 -152
  20. basic_memory/cli/commands/status.py +25 -22
  21. basic_memory/cli/commands/sync.py +45 -228
  22. basic_memory/cli/commands/tool.py +87 -16
  23. basic_memory/cli/main.py +1 -0
  24. basic_memory/config.py +131 -21
  25. basic_memory/db.py +104 -3
  26. basic_memory/deps.py +27 -8
  27. basic_memory/file_utils.py +37 -13
  28. basic_memory/ignore_utils.py +295 -0
  29. basic_memory/markdown/plugins.py +9 -7
  30. basic_memory/mcp/async_client.py +124 -14
  31. basic_memory/mcp/project_context.py +141 -0
  32. basic_memory/mcp/prompts/ai_assistant_guide.py +49 -4
  33. basic_memory/mcp/prompts/continue_conversation.py +17 -16
  34. basic_memory/mcp/prompts/recent_activity.py +116 -32
  35. basic_memory/mcp/prompts/search.py +13 -12
  36. basic_memory/mcp/prompts/utils.py +11 -4
  37. basic_memory/mcp/resources/ai_assistant_guide.md +211 -341
  38. basic_memory/mcp/resources/project_info.py +27 -11
  39. basic_memory/mcp/server.py +0 -37
  40. basic_memory/mcp/tools/__init__.py +5 -6
  41. basic_memory/mcp/tools/build_context.py +67 -56
  42. basic_memory/mcp/tools/canvas.py +38 -26
  43. basic_memory/mcp/tools/chatgpt_tools.py +187 -0
  44. basic_memory/mcp/tools/delete_note.py +81 -47
  45. basic_memory/mcp/tools/edit_note.py +155 -138
  46. basic_memory/mcp/tools/list_directory.py +112 -99
  47. basic_memory/mcp/tools/move_note.py +181 -101
  48. basic_memory/mcp/tools/project_management.py +113 -277
  49. basic_memory/mcp/tools/read_content.py +91 -74
  50. basic_memory/mcp/tools/read_note.py +152 -115
  51. basic_memory/mcp/tools/recent_activity.py +471 -68
  52. basic_memory/mcp/tools/search.py +105 -92
  53. basic_memory/mcp/tools/sync_status.py +136 -130
  54. basic_memory/mcp/tools/utils.py +4 -0
  55. basic_memory/mcp/tools/view_note.py +44 -33
  56. basic_memory/mcp/tools/write_note.py +151 -90
  57. basic_memory/models/knowledge.py +12 -6
  58. basic_memory/models/project.py +6 -2
  59. basic_memory/repository/entity_repository.py +89 -82
  60. basic_memory/repository/relation_repository.py +13 -0
  61. basic_memory/repository/repository.py +18 -5
  62. basic_memory/repository/search_repository.py +46 -2
  63. basic_memory/schemas/__init__.py +6 -0
  64. basic_memory/schemas/base.py +39 -11
  65. basic_memory/schemas/cloud.py +46 -0
  66. basic_memory/schemas/memory.py +90 -21
  67. basic_memory/schemas/project_info.py +9 -10
  68. basic_memory/schemas/sync_report.py +48 -0
  69. basic_memory/services/context_service.py +25 -11
  70. basic_memory/services/directory_service.py +124 -3
  71. basic_memory/services/entity_service.py +100 -48
  72. basic_memory/services/initialization.py +30 -11
  73. basic_memory/services/project_service.py +101 -24
  74. basic_memory/services/search_service.py +16 -8
  75. basic_memory/sync/sync_service.py +173 -34
  76. basic_memory/sync/watch_service.py +101 -40
  77. basic_memory/utils.py +14 -4
  78. {basic_memory-0.14.4.dist-info → basic_memory-0.15.1.dist-info}/METADATA +57 -9
  79. basic_memory-0.15.1.dist-info/RECORD +146 -0
  80. basic_memory/mcp/project_session.py +0 -120
  81. basic_memory-0.14.4.dist-info/RECORD +0 -133
  82. {basic_memory-0.14.4.dist-info → basic_memory-0.15.1.dist-info}/WHEEL +0 -0
  83. {basic_memory-0.14.4.dist-info → basic_memory-0.15.1.dist-info}/entry_points.txt +0 -0
  84. {basic_memory-0.14.4.dist-info → basic_memory-0.15.1.dist-info}/licenses/LICENSE +0 -0
@@ -1,413 +1,283 @@
1
1
  # AI Assistant Guide for Basic Memory
2
2
 
3
- This guide helps AIs use Basic Memory tools effectively when working with users. It covers reading, writing, and
4
- navigating knowledge through the Model Context Protocol (MCP).
3
+ Quick reference for using Basic Memory tools effectively through MCP.
4
+
5
+ **For comprehensive coverage**: See the [Extended AI Assistant Guide](https://github.com/basicmachines-co/basic-memory/blob/main/docs/ai-assistant-guide-extended.md) with detailed examples, advanced patterns, and self-contained sections.
5
6
 
6
7
  ## Overview
7
8
 
8
- Basic Memory allows you and users to record context in local Markdown files, building a rich knowledge base through
9
- natural conversations. The system automatically creates a semantic knowledge graph from simple text patterns.
9
+ Basic Memory creates a semantic knowledge graph from markdown files. Focus on building rich connections between notes.
10
+
11
+ - **Local-First**: Plain text files on user's computer
12
+ - **Persistent**: Knowledge survives across sessions
13
+ - **Semantic**: Observations and relations create a knowledge graph
10
14
 
11
- - **Local-First**: All data is stored in plain text files on the user's computer
12
- - **Real-Time**: Users see content updates immediately
13
- - **Bi-Directional**: Both you and users can read and edit notes
14
- - **Semantic**: Simple patterns create a structured knowledge graph
15
- - **Persistent**: Knowledge persists across sessions and conversations
15
+ **Your role**: You're helping humans build enduring knowledge they'll own forever. The semantic graph (observations, relations, context) helps you provide better assistance by understanding connections and maintaining continuity. Think: lasting insights worth keeping, not disposable chat logs.
16
16
 
17
- ## The Importance of the Knowledge Graph
17
+ ## Project Management
18
18
 
19
- **Basic Memory's value comes from connections between notes, not just the notes themselves.**
19
+ All tools require explicit project specification.
20
20
 
21
- When writing notes, your primary goal should be creating a rich, interconnected knowledge graph:
21
+ **Three-tier resolution:**
22
+ 1. CLI constraint: `--project name` (highest priority)
23
+ 2. Explicit parameter: `project="name"` in tool calls
24
+ 3. Default mode: `default_project_mode=true` in config (fallback)
22
25
 
23
- 1. **Increase Semantic Density**: Add multiple observations and relations to each note
24
- 2. **Use Accurate References**: Aim to reference existing entities by their exact titles
25
- 3. **Create Forward References**: Feel free to reference entities that don't exist yet - Basic Memory will resolve these
26
- when they're created later
27
- 4. **Create Bidirectional Links**: When appropriate, connect entities from both directions
28
- 5. **Use Meaningful Categories**: Add semantic context with appropriate observation categories
29
- 6. **Choose Precise Relations**: Use specific relation types that convey meaning
26
+ ### Quick Setup Check
30
27
 
31
- Remember: A knowledge graph with 10 heavily connected notes is more valuable than 20 isolated notes. Your job is to help
32
- build these connections!
28
+ ```python
29
+ # Discover projects
30
+ projects = await list_memory_projects()
31
+
32
+ # Check if default_project_mode enabled
33
+ # If yes: project parameter optional
34
+ # If no: project parameter required
35
+ ```
33
36
 
34
- ## Core Tools Reference
37
+ ### Default Project Mode
35
38
 
39
+ When `default_project_mode=true`:
36
40
  ```python
37
- # Writing knowledge - THE MOST IMPORTANT TOOL!
38
- response = await write_note(
39
- title="Search Design", # Required: Note title
40
- content="# Search Design\n...", # Required: Note content
41
- folder="specs", # Optional: Folder to save in
42
- tags=["search", "design"], # Optional: Tags for categorization
43
- verbose=True # Optional: Get parsing details
44
- )
41
+ # These are equivalent:
42
+ await write_note("Note", "Content", "folder")
43
+ await write_note("Note", "Content", "folder", project="main")
44
+ ```
45
+
46
+ When `default_project_mode=false` (default):
47
+ ```python
48
+ # Project required:
49
+ await write_note("Note", "Content", "folder", project="main") # ✓
50
+ await write_note("Note", "Content", "folder") # ✗ Error
51
+ ```
45
52
 
46
- # Reading knowledge
47
- content = await read_note("Search Design") # By title
48
- content = await read_note("specs/search-design") # By path
49
- content = await read_note("memory://specs/search") # By memory URL
53
+ ## Core Tools
50
54
 
51
- # Searching for knowledge
52
- results = await search_notes(
53
- query="authentication system", # Text to search for
54
- page=1, # Optional: Pagination
55
- page_size=10 # Optional: Results per page
56
- )
55
+ ### Writing Knowledge
57
56
 
58
- # Building context from the knowledge graph
59
- context = await build_context(
60
- url="memory://specs/search", # Starting point
61
- depth=2, # Optional: How many hops to follow
62
- timeframe="1 month" # Optional: Recent timeframe
57
+ ```python
58
+ await write_note(
59
+ title="Topic",
60
+ content="# Topic\n## Observations\n- [category] fact\n## Relations\n- relates_to [[Other]]",
61
+ folder="notes",
62
+ project="main" # Required unless default_project_mode=true
63
63
  )
64
+ ```
64
65
 
65
- # Checking recent changes
66
- activity = await recent_activity(
67
- type="all", # Optional: Entity types to include
68
- depth=1, # Optional: Related items to include
69
- timeframe="1 week" # Optional: Time window
70
- )
66
+ ### Reading Knowledge
71
67
 
72
- # Creating a knowledge visualization
73
- canvas_result = await canvas(
74
- nodes=[{"id": "note1", "label": "Search Design"}], # Nodes to display
75
- edges=[{"from": "note1", "to": "note2"}], # Connections
76
- title="Project Overview", # Canvas title
77
- folder="diagrams" # Storage location
78
- )
68
+ ```python
69
+ # By identifier
70
+ content = await read_note("Topic", project="main")
71
+
72
+ # By memory:// URL
73
+ content = await read_note("memory://folder/topic", project="main")
79
74
  ```
80
75
 
81
- ## memory:// URLs Explained
76
+ ### Searching
82
77
 
83
- Basic Memory uses a special URL format to reference entities in the knowledge graph:
78
+ ```python
79
+ results = await search_notes(
80
+ query="authentication",
81
+ project="main",
82
+ page_size=10
83
+ )
84
+ ```
84
85
 
85
- - `memory://title` - Reference by title
86
- - `memory://folder/title` - Reference by folder and title
87
- - `memory://permalink` - Reference by permalink
88
- - `memory://path/relation_type/*` - Follow all relations of a specific type
89
- - `memory://path/*/target` - Find all entities with relations to target
86
+ ### Building Context
90
87
 
91
- ## Semantic Markdown Format
88
+ ```python
89
+ context = await build_context(
90
+ url="memory://specs/auth",
91
+ project="main",
92
+ depth=2,
93
+ timeframe="1 week"
94
+ )
95
+ ```
92
96
 
93
- Knowledge is encoded in standard markdown using simple patterns:
97
+ ## Knowledge Graph Essentials
94
98
 
95
- **Observations** - Facts about an entity:
99
+ ### Observations
96
100
 
101
+ Categorized facts with optional tags:
97
102
  ```markdown
98
- - [category] This is an observation #tag1 #tag2 (optional context)
103
+ - [decision] Use JWT for authentication #security
104
+ - [technique] Hash passwords with bcrypt #best-practice
105
+ - [requirement] Support OAuth 2.0 providers
99
106
  ```
100
107
 
101
- **Relations** - Links between entities:
108
+ ### Relations
102
109
 
110
+ Directional links between entities:
103
111
  ```markdown
104
- - relation_type [[Target Entity]] (optional context)
112
+ - implements [[Authentication Spec]]
113
+ - requires [[User Database]]
114
+ - extends [[Base Security Model]]
105
115
  ```
106
116
 
107
- **Common Categories & Relation Types:**
108
-
109
- - Categories: `[idea]`, `[decision]`, `[question]`, `[fact]`, `[requirement]`, `[technique]`, `[recipe]`, `[preference]`
110
- - Relations: `relates_to`, `implements`, `requires`, `extends`, `part_of`, `pairs_with`, `inspired_by`,
111
- `originated_from`
112
-
113
- ## When to Record Context
114
-
115
- **Always consider recording context when**:
116
-
117
- 1. Users make decisions or reach conclusions
118
- 2. Important information emerges during conversation
119
- 3. Multiple related topics are discussed
120
- 4. The conversation contains information that might be useful later
121
- 5. Plans, tasks, or action items are mentioned
122
-
123
- **Protocol for recording context**:
124
-
125
- 1. Identify valuable information in the conversation
126
- 2. Ask the user: "Would you like me to record our discussion about [topic] in Basic Memory?"
127
- 3. If they agree, use `write_note` to capture the information
128
- 4. If they decline, continue without recording
129
- 5. Let the user know when information has been recorded: "I've saved our discussion about [topic] to Basic Memory."
130
-
131
- ## Understanding User Interactions
132
-
133
- Users will interact with Basic Memory in patterns like:
134
-
135
- 1. **Creating knowledge**:
136
- ```
137
- Human: "Let's write up what we discussed about search."
138
-
139
- You: I'll create a note capturing our discussion about the search functionality.
140
- [Use write_note() to record the conversation details]
141
- ```
142
-
143
- 2. **Referencing existing knowledge**:
144
- ```
145
- Human: "Take a look at memory://specs/search"
146
-
147
- You: I'll examine that information.
148
- [Use build_context() to gather related information]
149
- [Then read_note() to access specific content]
150
- ```
151
-
152
- 3. **Finding information**:
153
- ```
154
- Human: "What were our decisions about auth?"
155
-
156
- You: Let me find that information for you.
157
- [Use search_notes() to find relevant notes]
158
- [Then build_context() to understand connections]
159
- ```
160
-
161
- ## Key Things to Remember
162
-
163
- 1. **Files are Truth**
164
- - All knowledge lives in local files on the user's computer
165
- - Users can edit files outside your interaction
166
- - Changes need to be synced by the user (usually automatic)
167
- - Always verify information is current with `recent_activity()`
168
-
169
- 2. **Building Context Effectively**
170
- - Start with specific entities
171
- - Follow meaningful relations
172
- - Check recent changes
173
- - Build context incrementally
174
- - Combine related information
175
-
176
- 3. **Writing Knowledge Wisely**
177
- - Using the same title+folder will overwrite existing notes
178
- - Structure content with clear headings and sections
179
- - Use semantic markup for observations and relations
180
- - Keep files organized in logical folders
181
-
182
- ## Common Knowledge Patterns
183
-
184
- ### Capturing Decisions
117
+ **Common relation types:** `relates_to`, `implements`, `requires`, `extends`, `part_of`, `contrasts_with`
185
118
 
186
- ```markdown
187
- # Coffee Brewing Methods
119
+ ### Forward References
188
120
 
189
- ## Context
121
+ Reference entities that don't exist yet:
122
+ ```python
123
+ # Create note with forward reference
124
+ await write_note(
125
+ title="Login Flow",
126
+ content="## Relations\n- requires [[OAuth Provider]]", # Doesn't exist yet
127
+ folder="auth",
128
+ project="main"
129
+ )
190
130
 
191
- I've experimented with various brewing methods including French press, pour over, and espresso.
131
+ # Later, create referenced entity
132
+ await write_note(
133
+ title="OAuth Provider",
134
+ content="# OAuth Provider\n...",
135
+ folder="auth",
136
+ project="main"
137
+ )
138
+ # → Relation automatically resolved
139
+ ```
192
140
 
193
- ## Decision
141
+ ## Best Practices
194
142
 
195
- Pour over is my preferred method for light to medium roasts because it highlights subtle flavors and offers more control
196
- over the extraction.
143
+ ### 1. Project Management
197
144
 
198
- ## Observations
145
+ **Single-project users:**
146
+ - Enable `default_project_mode=true`
147
+ - Simpler tool calls
199
148
 
200
- - [technique] Blooming the coffee grounds for 30 seconds improves extraction #brewing
201
- - [preference] Water temperature between 195-205°F works best #temperature
202
- - [equipment] Gooseneck kettle provides better control of water flow #tools
149
+ **Multi-project users:**
150
+ - Keep `default_project_mode=false`
151
+ - Always specify project explicitly
203
152
 
204
- ## Relations
153
+ **Discovery:**
154
+ ```python
155
+ # Start with discovery
156
+ projects = await list_memory_projects()
205
157
 
206
- - pairs_with [[Light Roast Beans]]
207
- - contrasts_with [[French Press Method]]
208
- - requires [[Proper Grinding Technique]]
158
+ # Cross-project activity (no project param = all projects)
159
+ activity = await recent_activity()
160
+
161
+ # Or specific project
162
+ activity = await recent_activity(project="main")
209
163
  ```
210
164
 
211
- ### Recording Project Structure
165
+ ### 2. Building Rich Graphs
212
166
 
213
- ```markdown
214
- # Garden Planning
167
+ **Always include:**
168
+ - 3-5 observations per note
169
+ - 2-3 relations per note
170
+ - Meaningful categories and relation types
215
171
 
216
- ## Overview
172
+ **Search before creating:**
173
+ ```python
174
+ # Find existing entities to reference
175
+ results = await search_notes(query="authentication", project="main")
176
+ # Use exact titles in [[WikiLinks]]
177
+ ```
217
178
 
218
- This document outlines the garden layout and planting strategy for this season.
179
+ ### 3. Writing Effective Notes
219
180
 
220
- ## Observations
181
+ **Structure:**
182
+ ```markdown
183
+ # Title
221
184
 
222
- - [structure] Raised beds in south corner for sun exposure #layout
223
- - [structure] Drip irrigation system installed for efficiency #watering
224
- - [pattern] Companion planting used to deter pests naturally #technique
185
+ ## Context
186
+ Background information
225
187
 
226
- ## Relations
188
+ ## Observations
189
+ - [category] Fact with #tags
190
+ - [category] Another fact
227
191
 
228
- - contains [[Vegetable Section]]
229
- - contains [[Herb Garden]]
230
- - implements [[Organic Gardening Principles]]
192
+ ## Relations
193
+ - relation_type [[Exact Entity Title]]
231
194
  ```
232
195
 
233
- ### Technical Discussions
196
+ **Categories:** `[idea]`, `[decision]`, `[fact]`, `[technique]`, `[requirement]`
234
197
 
235
- ```markdown
236
- # Recipe Improvement Discussion
198
+ ### 4. Error Handling
199
+
200
+ **Missing project:**
201
+ ```python
202
+ try:
203
+ await search_notes(query="test") # Missing project parameter - will error
204
+ except:
205
+ # Show available projects
206
+ projects = await list_memory_projects()
207
+ # Then retry with project
208
+ results = await search_notes(query="test", project=projects[0].name)
209
+ ```
237
210
 
238
- ## Key Points
211
+ **Forward references:**
212
+ ```python
213
+ # Check response for unresolved relations
214
+ response = await write_note(
215
+ title="New Topic",
216
+ content="## Relations\n- relates_to [[Future Topic]]",
217
+ folder="notes",
218
+ project="main"
219
+ )
220
+ # Forward refs will resolve when target created
221
+ ```
239
222
 
240
- Discussed strategies for improving the chocolate chip cookie recipe.
223
+ ### 5. Recording Context
241
224
 
242
- ## Observations
225
+ **Ask permission:**
226
+ > "Would you like me to save our discussion about [topic] to Basic Memory?"
243
227
 
244
- - [issue] Cookies spread too thin when baked at 350°F #texture
245
- - [solution] Chilling dough for 24 hours improves flavor and reduces spreading #technique
246
- - [decision] Will use brown butter instead of regular butter #flavor
228
+ **Confirm when done:**
229
+ > "I've saved our discussion to Basic Memory."
247
230
 
248
- ## Relations
231
+ **What to record:**
232
+ - Decisions and rationales
233
+ - Important discoveries
234
+ - Action items and plans
235
+ - Connected topics
249
236
 
250
- - improves [[Basic Cookie Recipe]]
251
- - inspired_by [[Bakery-Style Cookies]]
252
- - pairs_with [[Homemade Ice Cream]]
253
- ```
237
+ ## Common Patterns
254
238
 
255
- ### Creating Effective Relations
239
+ ### Capture Decision
256
240
 
257
- When creating relations, you can:
241
+ ```python
242
+ await write_note(
243
+ title="DB Choice",
244
+ content="""# DB Choice\n## Decision\nUse PostgreSQL\n## Observations\n- [requirement] ACID compliance #reliability\n- [decision] PostgreSQL over MySQL\n## Relations\n- implements [[Data Architecture]]""",
245
+ folder="decisions",
246
+ project="main"
247
+ )
248
+ ```
258
249
 
259
- 1. Reference existing entities by their exact title
260
- 2. Create forward references to entities that don't exist yet
250
+ ### Link Topics & Build Context
261
251
 
262
252
  ```python
263
- # Example workflow for creating notes with effective relations
264
- async def create_note_with_effective_relations():
265
- # Search for existing entities to reference
266
- search_results = await search_notes("travel")
267
- existing_entities = [result.title for result in search_results.primary_results]
268
-
269
- # Check if specific entities exist
270
- packing_tips_exists = "Packing Tips" in existing_entities
271
- japan_travel_exists = "Japan Travel Guide" in existing_entities
272
-
273
- # Prepare relations section - include both existing and forward references
274
- relations_section = "## Relations\n"
275
-
276
- # Existing reference - exact match to known entity
277
- if packing_tips_exists:
278
- relations_section += "- references [[Packing Tips]]\n"
279
- else:
280
- # Forward reference - will be linked when that entity is created later
281
- relations_section += "- references [[Packing Tips]]\n"
282
-
283
- # Another possible reference
284
- if japan_travel_exists:
285
- relations_section += "- part_of [[Japan Travel Guide]]\n"
286
-
287
- # You can also check recently modified notes to reference them
288
- recent = await recent_activity(timeframe="1 week")
289
- recent_titles = [item.title for item in recent.primary_results]
290
-
291
- if "Transportation Options" in recent_titles:
292
- relations_section += "- relates_to [[Transportation Options]]\n"
293
-
294
- # Always include meaningful forward references, even if they don't exist yet
295
- relations_section += "- located_in [[Tokyo]]\n"
296
- relations_section += "- visited_during [[Spring 2023 Trip]]\n"
297
-
298
- # Now create the note with both verified and forward relations
299
- content = f"""# Tokyo Neighborhood Guide
300
-
301
- ## Overview
302
- Details about different Tokyo neighborhoods and their unique characteristics.
253
+ # Link bidirectionally
254
+ await write_note(title="API Auth", content="## Relations\n- part_of [[API Design]]", folder="api", project="main")
255
+ await edit_note(identifier="API Design", operation="append", content="\n- includes [[API Auth]]", project="main")
303
256
 
304
- ## Observations
305
- - [area] Shibuya is a busy shopping district #shopping
306
- - [transportation] Yamanote Line connects major neighborhoods #transit
307
- - [recommendation] Visit Shimokitazawa for vintage shopping #unique
308
- - [tip] Get a Suica card for easy train travel #convenience
309
-
310
- {relations_section}
311
- """
312
-
313
- result = await write_note(
314
- title="Tokyo Neighborhood Guide",
315
- content=content,
316
- verbose=True
317
- )
318
-
319
- # You can check which relations were resolved and which are forward references
320
- if result and 'relations' in result:
321
- resolved = [r['to_name'] for r in result['relations'] if r.get('target_id')]
322
- forward_refs = [r['to_name'] for r in result['relations'] if not r.get('target_id')]
323
-
324
- print(f"Resolved relations: {resolved}")
325
- print(f"Forward references that will be resolved later: {forward_refs}")
257
+ # Search and build context
258
+ results = await search_notes(query="authentication", project="main")
259
+ context = await build_context(url=f"memory://{results[0].permalink}", project="main", depth=2)
326
260
  ```
327
261
 
328
- ## Error Handling
329
-
330
- Common issues to watch for:
331
-
332
- 1. **Missing Content**
333
- ```python
334
- try:
335
- content = await read_note("Document")
336
- except:
337
- # Try search instead
338
- results = await search_notes("Document")
339
- if results and results.primary_results:
340
- # Found something similar
341
- content = await read_note(results.primary_results[0].permalink)
342
- ```
343
-
344
- 2. **Forward References (Unresolved Relations)**
345
- ```python
346
- response = await write_note(..., verbose=True)
347
- # Check for forward references (unresolved relations)
348
- forward_refs = []
349
- for relation in response.get('relations', []):
350
- if not relation.get('target_id'):
351
- forward_refs.append(relation.get('to_name'))
352
-
353
- if forward_refs:
354
- # This is a feature, not an error! Inform the user about forward references
355
- print(f"Note created with forward references to: {forward_refs}")
356
- print("These will be automatically linked when those notes are created.")
357
-
358
- # Optionally suggest creating those entities now
359
- print("Would you like me to create any of these notes now to complete the connections?")
360
- ```
361
-
362
- 3. **Sync Issues**
363
- ```python
364
- # If information seems outdated
365
- activity = await recent_activity(timeframe="1 hour")
366
- if not activity or not activity.primary_results:
367
- print("It seems there haven't been recent updates. You might need to run 'basic-memory sync'.")
368
- ```
262
+ ## Tool Quick Reference
369
263
 
370
- ## Best Practices
264
+ | Tool | Purpose | Key Params |
265
+ |------|---------|------------|
266
+ | `write_note` | Create/update | title, content, folder, project |
267
+ | `read_note` | Read content | identifier, project |
268
+ | `edit_note` | Modify existing | identifier, operation, content, project |
269
+ | `search_notes` | Find notes | query, project |
270
+ | `build_context` | Graph traversal | url, depth, project |
271
+ | `recent_activity` | Recent changes | timeframe, project |
272
+ | `list_memory_projects` | Show projects | (none) |
273
+
274
+ ## memory:// URL Format
275
+
276
+ - `memory://title` - By title
277
+ - `memory://folder/title` - By folder + title
278
+ - `memory://permalink` - By permalink
279
+ - `memory://folder/*` - All in folder
280
+
281
+ For full documentation: https://docs.basicmemory.com
371
282
 
372
- 1. **Proactively Record Context**
373
- - Offer to capture important discussions
374
- - Record decisions, rationales, and conclusions
375
- - Link to related topics
376
- - Ask for permission first: "Would you like me to save our discussion about [topic]?"
377
- - Confirm when complete: "I've saved our discussion to Basic Memory"
378
-
379
- 2. **Create a Rich Semantic Graph**
380
- - **Add meaningful observations**: Include at least 3-5 categorized observations in each note
381
- - **Create deliberate relations**: Connect each note to at least 2-3 related entities
382
- - **Use existing entities**: Before creating a new relation, search for existing entities
383
- - **Verify wikilinks**: When referencing `[[Entity]]`, use exact titles of existing notes
384
- - **Check accuracy**: Use `search_notes()` or `recent_activity()` to confirm entity titles
385
- - **Use precise relation types**: Choose specific relation types that convey meaning (e.g., "implements" instead
386
- of "relates_to")
387
- - **Consider bidirectional relations**: When appropriate, create inverse relations in both entities
388
-
389
- 3. **Structure Content Thoughtfully**
390
- - Use clear, descriptive titles
391
- - Organize with logical sections (Context, Decision, Implementation, etc.)
392
- - Include relevant context and background
393
- - Add semantic observations with appropriate categories
394
- - Use a consistent format for similar types of notes
395
- - Balance detail with conciseness
396
-
397
- 4. **Navigate Knowledge Effectively**
398
- - Start with specific searches
399
- - Follow relation paths
400
- - Combine information from multiple sources
401
- - Verify information is current
402
- - Build a complete picture before responding
403
-
404
- 5. **Help Users Maintain Their Knowledge**
405
- - Suggest organizing related topics
406
- - Identify potential duplicates
407
- - Recommend adding relations between topics
408
- - Offer to create summaries of scattered information
409
- - Suggest potential missing relations: "I notice this might relate to [topic], would you like me to add that
410
- connection?"
411
-
412
- Built with ♥️ b
413
- y Basic Machines
283
+ Built with ♥️ by Basic Machines