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.
- basic_memory/__init__.py +1 -1
- basic_memory/alembic/versions/a1b2c3d4e5f6_fix_project_foreign_keys.py +5 -9
- basic_memory/api/app.py +10 -4
- basic_memory/api/routers/directory_router.py +23 -2
- basic_memory/api/routers/knowledge_router.py +25 -8
- basic_memory/api/routers/project_router.py +100 -4
- basic_memory/cli/app.py +9 -28
- basic_memory/cli/auth.py +277 -0
- basic_memory/cli/commands/cloud/__init__.py +5 -0
- basic_memory/cli/commands/cloud/api_client.py +112 -0
- basic_memory/cli/commands/cloud/bisync_commands.py +818 -0
- basic_memory/cli/commands/cloud/core_commands.py +288 -0
- basic_memory/cli/commands/cloud/mount_commands.py +295 -0
- basic_memory/cli/commands/cloud/rclone_config.py +288 -0
- basic_memory/cli/commands/cloud/rclone_installer.py +198 -0
- basic_memory/cli/commands/command_utils.py +43 -0
- basic_memory/cli/commands/import_memory_json.py +0 -4
- basic_memory/cli/commands/mcp.py +77 -60
- basic_memory/cli/commands/project.py +154 -152
- basic_memory/cli/commands/status.py +25 -22
- basic_memory/cli/commands/sync.py +45 -228
- basic_memory/cli/commands/tool.py +87 -16
- basic_memory/cli/main.py +1 -0
- basic_memory/config.py +131 -21
- basic_memory/db.py +104 -3
- basic_memory/deps.py +27 -8
- basic_memory/file_utils.py +37 -13
- basic_memory/ignore_utils.py +295 -0
- basic_memory/markdown/plugins.py +9 -7
- basic_memory/mcp/async_client.py +124 -14
- basic_memory/mcp/project_context.py +141 -0
- basic_memory/mcp/prompts/ai_assistant_guide.py +49 -4
- basic_memory/mcp/prompts/continue_conversation.py +17 -16
- basic_memory/mcp/prompts/recent_activity.py +116 -32
- basic_memory/mcp/prompts/search.py +13 -12
- basic_memory/mcp/prompts/utils.py +11 -4
- basic_memory/mcp/resources/ai_assistant_guide.md +211 -341
- basic_memory/mcp/resources/project_info.py +27 -11
- basic_memory/mcp/server.py +0 -37
- basic_memory/mcp/tools/__init__.py +5 -6
- basic_memory/mcp/tools/build_context.py +67 -56
- basic_memory/mcp/tools/canvas.py +38 -26
- basic_memory/mcp/tools/chatgpt_tools.py +187 -0
- basic_memory/mcp/tools/delete_note.py +81 -47
- basic_memory/mcp/tools/edit_note.py +155 -138
- basic_memory/mcp/tools/list_directory.py +112 -99
- basic_memory/mcp/tools/move_note.py +181 -101
- basic_memory/mcp/tools/project_management.py +113 -277
- basic_memory/mcp/tools/read_content.py +91 -74
- basic_memory/mcp/tools/read_note.py +152 -115
- basic_memory/mcp/tools/recent_activity.py +471 -68
- basic_memory/mcp/tools/search.py +105 -92
- basic_memory/mcp/tools/sync_status.py +136 -130
- basic_memory/mcp/tools/utils.py +4 -0
- basic_memory/mcp/tools/view_note.py +44 -33
- basic_memory/mcp/tools/write_note.py +151 -90
- basic_memory/models/knowledge.py +12 -6
- basic_memory/models/project.py +6 -2
- basic_memory/repository/entity_repository.py +89 -82
- basic_memory/repository/relation_repository.py +13 -0
- basic_memory/repository/repository.py +18 -5
- basic_memory/repository/search_repository.py +46 -2
- basic_memory/schemas/__init__.py +6 -0
- basic_memory/schemas/base.py +39 -11
- basic_memory/schemas/cloud.py +46 -0
- basic_memory/schemas/memory.py +90 -21
- basic_memory/schemas/project_info.py +9 -10
- basic_memory/schemas/sync_report.py +48 -0
- basic_memory/services/context_service.py +25 -11
- basic_memory/services/directory_service.py +124 -3
- basic_memory/services/entity_service.py +100 -48
- basic_memory/services/initialization.py +30 -11
- basic_memory/services/project_service.py +101 -24
- basic_memory/services/search_service.py +16 -8
- basic_memory/sync/sync_service.py +173 -34
- basic_memory/sync/watch_service.py +101 -40
- basic_memory/utils.py +14 -4
- {basic_memory-0.14.4.dist-info → basic_memory-0.15.1.dist-info}/METADATA +57 -9
- basic_memory-0.15.1.dist-info/RECORD +146 -0
- basic_memory/mcp/project_session.py +0 -120
- basic_memory-0.14.4.dist-info/RECORD +0 -133
- {basic_memory-0.14.4.dist-info → basic_memory-0.15.1.dist-info}/WHEEL +0 -0
- {basic_memory-0.14.4.dist-info → basic_memory-0.15.1.dist-info}/entry_points.txt +0 -0
- {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
|
-
|
|
4
|
-
|
|
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
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
17
|
+
## Project Management
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
All tools require explicit project specification.
|
|
20
20
|
|
|
21
|
-
|
|
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
|
-
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
37
|
+
### Default Project Mode
|
|
35
38
|
|
|
39
|
+
When `default_project_mode=true`:
|
|
36
40
|
```python
|
|
37
|
-
#
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
76
|
+
### Searching
|
|
82
77
|
|
|
83
|
-
|
|
78
|
+
```python
|
|
79
|
+
results = await search_notes(
|
|
80
|
+
query="authentication",
|
|
81
|
+
project="main",
|
|
82
|
+
page_size=10
|
|
83
|
+
)
|
|
84
|
+
```
|
|
84
85
|
|
|
85
|
-
|
|
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
|
-
|
|
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
|
|
97
|
+
## Knowledge Graph Essentials
|
|
94
98
|
|
|
95
|
-
|
|
99
|
+
### Observations
|
|
96
100
|
|
|
101
|
+
Categorized facts with optional tags:
|
|
97
102
|
```markdown
|
|
98
|
-
- [
|
|
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
|
-
|
|
108
|
+
### Relations
|
|
102
109
|
|
|
110
|
+
Directional links between entities:
|
|
103
111
|
```markdown
|
|
104
|
-
-
|
|
112
|
+
- implements [[Authentication Spec]]
|
|
113
|
+
- requires [[User Database]]
|
|
114
|
+
- extends [[Base Security Model]]
|
|
105
115
|
```
|
|
106
116
|
|
|
107
|
-
**Common
|
|
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
|
-
|
|
187
|
-
# Coffee Brewing Methods
|
|
119
|
+
### Forward References
|
|
188
120
|
|
|
189
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
141
|
+
## Best Practices
|
|
194
142
|
|
|
195
|
-
|
|
196
|
-
over the extraction.
|
|
143
|
+
### 1. Project Management
|
|
197
144
|
|
|
198
|
-
|
|
145
|
+
**Single-project users:**
|
|
146
|
+
- Enable `default_project_mode=true`
|
|
147
|
+
- Simpler tool calls
|
|
199
148
|
|
|
200
|
-
-
|
|
201
|
-
-
|
|
202
|
-
-
|
|
149
|
+
**Multi-project users:**
|
|
150
|
+
- Keep `default_project_mode=false`
|
|
151
|
+
- Always specify project explicitly
|
|
203
152
|
|
|
204
|
-
|
|
153
|
+
**Discovery:**
|
|
154
|
+
```python
|
|
155
|
+
# Start with discovery
|
|
156
|
+
projects = await list_memory_projects()
|
|
205
157
|
|
|
206
|
-
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
###
|
|
165
|
+
### 2. Building Rich Graphs
|
|
212
166
|
|
|
213
|
-
|
|
214
|
-
|
|
167
|
+
**Always include:**
|
|
168
|
+
- 3-5 observations per note
|
|
169
|
+
- 2-3 relations per note
|
|
170
|
+
- Meaningful categories and relation types
|
|
215
171
|
|
|
216
|
-
|
|
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
|
-
|
|
179
|
+
### 3. Writing Effective Notes
|
|
219
180
|
|
|
220
|
-
|
|
181
|
+
**Structure:**
|
|
182
|
+
```markdown
|
|
183
|
+
# Title
|
|
221
184
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
- [pattern] Companion planting used to deter pests naturally #technique
|
|
185
|
+
## Context
|
|
186
|
+
Background information
|
|
225
187
|
|
|
226
|
-
##
|
|
188
|
+
## Observations
|
|
189
|
+
- [category] Fact with #tags
|
|
190
|
+
- [category] Another fact
|
|
227
191
|
|
|
228
|
-
|
|
229
|
-
-
|
|
230
|
-
- implements [[Organic Gardening Principles]]
|
|
192
|
+
## Relations
|
|
193
|
+
- relation_type [[Exact Entity Title]]
|
|
231
194
|
```
|
|
232
195
|
|
|
233
|
-
|
|
196
|
+
**Categories:** `[idea]`, `[decision]`, `[fact]`, `[technique]`, `[requirement]`
|
|
234
197
|
|
|
235
|
-
|
|
236
|
-
|
|
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
|
-
|
|
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
|
-
|
|
223
|
+
### 5. Recording Context
|
|
241
224
|
|
|
242
|
-
|
|
225
|
+
**Ask permission:**
|
|
226
|
+
> "Would you like me to save our discussion about [topic] to Basic Memory?"
|
|
243
227
|
|
|
244
|
-
|
|
245
|
-
|
|
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
|
-
|
|
231
|
+
**What to record:**
|
|
232
|
+
- Decisions and rationales
|
|
233
|
+
- Important discoveries
|
|
234
|
+
- Action items and plans
|
|
235
|
+
- Connected topics
|
|
249
236
|
|
|
250
|
-
|
|
251
|
-
- inspired_by [[Bakery-Style Cookies]]
|
|
252
|
-
- pairs_with [[Homemade Ice Cream]]
|
|
253
|
-
```
|
|
237
|
+
## Common Patterns
|
|
254
238
|
|
|
255
|
-
###
|
|
239
|
+
### Capture Decision
|
|
256
240
|
|
|
257
|
-
|
|
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
|
-
|
|
260
|
-
2. Create forward references to entities that don't exist yet
|
|
250
|
+
### Link Topics & Build Context
|
|
261
251
|
|
|
262
252
|
```python
|
|
263
|
-
#
|
|
264
|
-
|
|
265
|
-
|
|
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
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
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
|
-
|
|
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
|