basic-memory 0.4.3__py3-none-any.whl → 0.5.0__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/api/routers/resource_router.py +1 -1
- basic_memory/mcp/tools/notes.py +41 -23
- {basic_memory-0.4.3.dist-info → basic_memory-0.5.0.dist-info}/METADATA +1 -1
- {basic_memory-0.4.3.dist-info → basic_memory-0.5.0.dist-info}/RECORD +8 -8
- {basic_memory-0.4.3.dist-info → basic_memory-0.5.0.dist-info}/WHEEL +0 -0
- {basic_memory-0.4.3.dist-info → basic_memory-0.5.0.dist-info}/entry_points.txt +0 -0
- {basic_memory-0.4.3.dist-info → basic_memory-0.5.0.dist-info}/licenses/LICENSE +0 -0
basic_memory/__init__.py
CHANGED
|
@@ -31,7 +31,7 @@ def get_entity_ids(item: SearchIndexRow) -> list[int]:
|
|
|
31
31
|
from_entity = item.from_id
|
|
32
32
|
to_entity = item.to_id # pyright: ignore [reportReturnType]
|
|
33
33
|
return [from_entity, to_entity] if to_entity else [from_entity] # pyright: ignore [reportReturnType]
|
|
34
|
-
case _:
|
|
34
|
+
case _: # pragma: no cover
|
|
35
35
|
raise ValueError(f"Unexpected type: {item.type}")
|
|
36
36
|
|
|
37
37
|
|
basic_memory/mcp/tools/notes.py
CHANGED
|
@@ -17,15 +17,14 @@ from basic_memory.schemas.memory import memory_url_path
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
@mcp.tool(
|
|
20
|
-
description="Create or update a markdown note. Returns the
|
|
20
|
+
description="Create or update a markdown note. Returns a markdown formatted summary of the semantic content.",
|
|
21
21
|
)
|
|
22
22
|
async def write_note(
|
|
23
23
|
title: str,
|
|
24
24
|
content: str,
|
|
25
25
|
folder: str,
|
|
26
26
|
tags: Optional[List[str]] = None,
|
|
27
|
-
|
|
28
|
-
) -> EntityResponse | str:
|
|
27
|
+
) -> str:
|
|
29
28
|
"""Write a markdown note to the knowledge base.
|
|
30
29
|
|
|
31
30
|
The content can include semantic observations and relations using markdown syntax.
|
|
@@ -53,14 +52,16 @@ async def write_note(
|
|
|
53
52
|
content: Markdown content for the note, can include observations and relations
|
|
54
53
|
folder: the folder where the file should be saved
|
|
55
54
|
tags: Optional list of tags to categorize the note
|
|
56
|
-
verbose: If True, returns full EntityResponse with semantic info
|
|
57
55
|
|
|
58
56
|
Returns:
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
A markdown formatted summary of the semantic content, including:
|
|
58
|
+
- Creation/update status
|
|
59
|
+
- File path and checksum
|
|
60
|
+
- Observation counts by category
|
|
61
|
+
- Relation counts (resolved/unresolved)
|
|
62
|
+
- Tags if present
|
|
61
63
|
|
|
62
64
|
Examples:
|
|
63
|
-
# Note with both explicit and inline relations
|
|
64
65
|
write_note(
|
|
65
66
|
title="Search Implementation",
|
|
66
67
|
content="# Search Component\\n\\n"
|
|
@@ -73,20 +74,6 @@ async def write_note(
|
|
|
73
74
|
"- depends_on [[Database Schema]]",
|
|
74
75
|
folder="docs/components"
|
|
75
76
|
)
|
|
76
|
-
|
|
77
|
-
# Note with tags
|
|
78
|
-
write_note(
|
|
79
|
-
title="Error Handling Design",
|
|
80
|
-
content="# Error Handling\\n\\n"
|
|
81
|
-
"This design builds on [[Reliability Design]].\\n\\n"
|
|
82
|
-
"## Approach\\n"
|
|
83
|
-
"- [design] Use error codes #architecture\\n"
|
|
84
|
-
"- [tech] Implement retry logic #implementation\\n\\n"
|
|
85
|
-
"## Relations\\n"
|
|
86
|
-
"- extends [[Base Error Handling]]",
|
|
87
|
-
folder="docs/design",
|
|
88
|
-
tags=["architecture", "reliability"]
|
|
89
|
-
)
|
|
90
77
|
"""
|
|
91
78
|
logger.info(f"Writing note folder:'{folder}' title: '{title}'")
|
|
92
79
|
|
|
@@ -101,12 +88,43 @@ async def write_note(
|
|
|
101
88
|
entity_metadata=metadata,
|
|
102
89
|
)
|
|
103
90
|
|
|
104
|
-
#
|
|
91
|
+
# Create or update via knowledge API
|
|
105
92
|
logger.info(f"Creating {entity.permalink}")
|
|
106
93
|
url = f"/knowledge/entities/{entity.permalink}"
|
|
107
94
|
response = await call_put(client, url, json=entity.model_dump())
|
|
108
95
|
result = EntityResponse.model_validate(response.json())
|
|
109
|
-
|
|
96
|
+
|
|
97
|
+
# Format semantic summary based on status code
|
|
98
|
+
action = "Created" if response.status_code == 201 else "Updated"
|
|
99
|
+
assert result.checksum is not None
|
|
100
|
+
summary = [
|
|
101
|
+
f"# {action} {result.file_path} ({result.checksum[:8]})",
|
|
102
|
+
f"permalink: {result.permalink}",
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
if result.observations:
|
|
106
|
+
categories = {}
|
|
107
|
+
for obs in result.observations:
|
|
108
|
+
categories[obs.category] = categories.get(obs.category, 0) + 1
|
|
109
|
+
|
|
110
|
+
summary.append("\n## Observations")
|
|
111
|
+
for category, count in sorted(categories.items()):
|
|
112
|
+
summary.append(f"- {category}: {count}")
|
|
113
|
+
|
|
114
|
+
if result.relations:
|
|
115
|
+
unresolved = sum(1 for r in result.relations if not r.to_id)
|
|
116
|
+
resolved = len(result.relations) - unresolved
|
|
117
|
+
|
|
118
|
+
summary.append("\n## Relations")
|
|
119
|
+
summary.append(f"- Resolved: {resolved}")
|
|
120
|
+
if unresolved:
|
|
121
|
+
summary.append(f"- Unresolved: {unresolved}")
|
|
122
|
+
summary.append("\nUnresolved relations will be retried on next sync.")
|
|
123
|
+
|
|
124
|
+
if tags:
|
|
125
|
+
summary.append(f"\n## Tags\n- {', '.join(tags)}")
|
|
126
|
+
|
|
127
|
+
return "\n".join(summary)
|
|
110
128
|
|
|
111
129
|
|
|
112
130
|
@mcp.tool(description="Read note content by title, permalink, relation, or pattern")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: basic-memory
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Local-first knowledge management combining Zettelkasten with knowledge graphs
|
|
5
5
|
Project-URL: Homepage, https://github.com/basicmachines-co/basic-memory
|
|
6
6
|
Project-URL: Repository, https://github.com/basicmachines-co/basic-memory
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
basic_memory/__init__.py,sha256=
|
|
1
|
+
basic_memory/__init__.py,sha256=oSbUpibWuITY-SoYtwzq1d3ISgJIVK5Ft8pFz6SYZ1A,122
|
|
2
2
|
basic_memory/config.py,sha256=PZA2qgwKACvKfRcM3H-BPB_8FYVhgZAwTmlKJ3ROfhU,1643
|
|
3
3
|
basic_memory/db.py,sha256=IK_gz8Uiwcgxe8TjarW7kpl8cVVNtEnR0lm1LemgZ8I,5283
|
|
4
4
|
basic_memory/deps.py,sha256=UzivBw6e6iYcU_8SQ8LNCmSsmFyHfjdzfWvnfNzqbRc,5375
|
|
@@ -14,7 +14,7 @@ basic_memory/api/app.py,sha256=3ddcWTxVjMy_5SUq89kROhMwosZqcr67Q5evOlSR9GE,1389
|
|
|
14
14
|
basic_memory/api/routers/__init__.py,sha256=iviQ1QVYobC8huUuyRhEjcA0BDjrOUm1lXHXhJkxP9A,239
|
|
15
15
|
basic_memory/api/routers/knowledge_router.py,sha256=cMLhRczOfSRnsZdyR0bSS8PENPRTu70dlwaV27O34bs,5705
|
|
16
16
|
basic_memory/api/routers/memory_router.py,sha256=pF0GzmWoxmjhtxZM8jCmfLwqjey_fmXER5vYbD8fsQw,4556
|
|
17
|
-
basic_memory/api/routers/resource_router.py,sha256=
|
|
17
|
+
basic_memory/api/routers/resource_router.py,sha256=MoW8LEjBfNbJsp6Nt2JnE4LKe3ysiVqwgY5BMCFuPCQ,4360
|
|
18
18
|
basic_memory/api/routers/search_router.py,sha256=dCRnBbp3r966U8UYwgAaxZBbg7yX7pC8QJqagdACUi0,1086
|
|
19
19
|
basic_memory/cli/__init__.py,sha256=arcKLAWRDhPD7x5t80MlviZeYzwHZ0GZigyy3NKVoGk,33
|
|
20
20
|
basic_memory/cli/app.py,sha256=NG6gs_UzyXBiQLHbiZRZlew3nb7G7i_8gwPh1383EnA,450
|
|
@@ -40,7 +40,7 @@ basic_memory/mcp/server.py,sha256=L92Vit7llaKT9NlPZfxdp67C33niObmRH2QFyUhmnD0,35
|
|
|
40
40
|
basic_memory/mcp/tools/__init__.py,sha256=MHZmWw016N0qbtC3f186Jg1tPzh2g88_ZsCKJ0oyrrs,873
|
|
41
41
|
basic_memory/mcp/tools/knowledge.py,sha256=2U8YUKCizsAETHCC1mBVKMfCEef6tlc_pa2wOmA9mD4,2016
|
|
42
42
|
basic_memory/mcp/tools/memory.py,sha256=gl4MBm9l2lMOfu_xmUqjoZacWSIHOAYZiAm8z7oDuY8,5203
|
|
43
|
-
basic_memory/mcp/tools/notes.py,sha256=
|
|
43
|
+
basic_memory/mcp/tools/notes.py,sha256=ZJGMU-14_aIQvrDA-yaLbnDoFdjIgx7SzE7PWTf7c4o,7249
|
|
44
44
|
basic_memory/mcp/tools/search.py,sha256=tx6aIuB2FWmmrvzu3RHSQvszlk-zHcwrWhkLLHWjuZc,1105
|
|
45
45
|
basic_memory/mcp/tools/utils.py,sha256=icm-Xyqw3GxooGYkXqjEjoZvIGy_Z3CPw-uUYBxR_YQ,4831
|
|
46
46
|
basic_memory/models/__init__.py,sha256=Bf0xXV_ryndogvZDiVM_Wb6iV2fHUxYNGMZNWNcZi0s,307
|
|
@@ -74,8 +74,8 @@ basic_memory/sync/file_change_scanner.py,sha256=4whJej6t9sxwUp1ox93efJ0bBHSnAr6S
|
|
|
74
74
|
basic_memory/sync/sync_service.py,sha256=nAOX4N90lbpRJeq5tRR_7PYptIoWwhXMUljE7yrneF4,7087
|
|
75
75
|
basic_memory/sync/utils.py,sha256=wz1Fe7Mb_M5N9vYRQnDKGODiMGcj5MEK16KVJ3eoQ9g,1191
|
|
76
76
|
basic_memory/sync/watch_service.py,sha256=CtKBrP1imI3ZSEgJl7Ffi-JZ_oDGKrhiyGgs41h5QYI,7563
|
|
77
|
-
basic_memory-0.
|
|
78
|
-
basic_memory-0.
|
|
79
|
-
basic_memory-0.
|
|
80
|
-
basic_memory-0.
|
|
81
|
-
basic_memory-0.
|
|
77
|
+
basic_memory-0.5.0.dist-info/METADATA,sha256=PMFAU3vLghjj7SV2yHnEXBvwatUbkbzIBtBYzUxtX-4,10791
|
|
78
|
+
basic_memory-0.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
79
|
+
basic_memory-0.5.0.dist-info/entry_points.txt,sha256=IDQa_VmVTzmvMrpnjhEfM0S3F--XsVGEj3MpdJfuo-Q,59
|
|
80
|
+
basic_memory-0.5.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
81
|
+
basic_memory-0.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|