basic-memory 0.5.0__py3-none-any.whl → 0.6.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/app.py +7 -0
- basic_memory/cli/main.py +0 -4
- basic_memory/config.py +5 -0
- basic_memory/utils.py +35 -4
- {basic_memory-0.5.0.dist-info → basic_memory-0.6.0.dist-info}/METADATA +2 -1
- {basic_memory-0.5.0.dist-info → basic_memory-0.6.0.dist-info}/RECORD +10 -10
- {basic_memory-0.5.0.dist-info → basic_memory-0.6.0.dist-info}/WHEEL +0 -0
- {basic_memory-0.5.0.dist-info → basic_memory-0.6.0.dist-info}/entry_points.txt +0 -0
- {basic_memory-0.5.0.dist-info → basic_memory-0.6.0.dist-info}/licenses/LICENSE +0 -0
basic_memory/__init__.py
CHANGED
basic_memory/api/app.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from contextlib import asynccontextmanager
|
|
4
4
|
|
|
5
|
+
import logfire
|
|
5
6
|
from fastapi import FastAPI, HTTPException
|
|
6
7
|
from fastapi.exception_handlers import http_exception_handler
|
|
7
8
|
from loguru import logger
|
|
@@ -10,11 +11,13 @@ import basic_memory
|
|
|
10
11
|
from basic_memory import db
|
|
11
12
|
from basic_memory.config import config as app_config
|
|
12
13
|
from basic_memory.api.routers import knowledge, search, memory, resource
|
|
14
|
+
from basic_memory.utils import setup_logging
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
@asynccontextmanager
|
|
16
18
|
async def lifespan(app: FastAPI): # pragma: no cover
|
|
17
19
|
"""Lifecycle manager for the FastAPI app."""
|
|
20
|
+
setup_logging(log_file=".basic-memory/basic-memory.log")
|
|
18
21
|
logger.info(f"Starting Basic Memory API {basic_memory.__version__}")
|
|
19
22
|
await db.run_migrations(app_config)
|
|
20
23
|
yield
|
|
@@ -30,6 +33,10 @@ app = FastAPI(
|
|
|
30
33
|
lifespan=lifespan,
|
|
31
34
|
)
|
|
32
35
|
|
|
36
|
+
if app_config != "test":
|
|
37
|
+
logfire.instrument_fastapi(app)
|
|
38
|
+
|
|
39
|
+
|
|
33
40
|
# Include routers
|
|
34
41
|
app.include_router(knowledge.router)
|
|
35
42
|
app.include_router(search.router)
|
basic_memory/cli/main.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Main CLI entry point for basic-memory.""" # pragma: no cover
|
|
2
2
|
|
|
3
3
|
from basic_memory.cli.app import app # pragma: no cover
|
|
4
|
-
from basic_memory.utils import setup_logging # pragma: no cover
|
|
5
4
|
|
|
6
5
|
# Register commands
|
|
7
6
|
from basic_memory.cli.commands import ( # noqa: F401 # pragma: no cover
|
|
@@ -16,8 +15,5 @@ from basic_memory.cli.commands import ( # noqa: F401 # pragma: no cover
|
|
|
16
15
|
)
|
|
17
16
|
|
|
18
17
|
|
|
19
|
-
# Set up logging when module is imported
|
|
20
|
-
setup_logging(log_file=".basic-memory/basic-memory-cli.log") # pragma: no cover
|
|
21
|
-
|
|
22
18
|
if __name__ == "__main__": # pragma: no cover
|
|
23
19
|
app()
|
basic_memory/config.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Configuration management for basic-memory."""
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
|
+
from typing import Literal
|
|
4
5
|
|
|
5
6
|
from pydantic import Field, field_validator
|
|
6
7
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
@@ -8,10 +9,14 @@ from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
8
9
|
DATABASE_NAME = "memory.db"
|
|
9
10
|
DATA_DIR_NAME = ".basic-memory"
|
|
10
11
|
|
|
12
|
+
Environment = Literal["test", "dev", "prod"]
|
|
13
|
+
|
|
11
14
|
|
|
12
15
|
class ProjectConfig(BaseSettings):
|
|
13
16
|
"""Configuration for a specific basic-memory project."""
|
|
14
17
|
|
|
18
|
+
env: Environment = Field(default="dev", description="Environment name")
|
|
19
|
+
|
|
15
20
|
# Default to ~/basic-memory but allow override with env var: BASIC_MEMORY_HOME
|
|
16
21
|
home: Path = Field(
|
|
17
22
|
default_factory=lambda: Path.home() / "basic-memory",
|
basic_memory/utils.py
CHANGED
|
@@ -9,8 +9,11 @@ from typing import Optional, Union
|
|
|
9
9
|
from loguru import logger
|
|
10
10
|
from unidecode import unidecode
|
|
11
11
|
|
|
12
|
+
import basic_memory
|
|
12
13
|
from basic_memory.config import config
|
|
13
14
|
|
|
15
|
+
import logfire
|
|
16
|
+
|
|
14
17
|
|
|
15
18
|
def generate_permalink(file_path: Union[Path, str]) -> str:
|
|
16
19
|
"""Generate a stable permalink from a file path.
|
|
@@ -61,19 +64,45 @@ def generate_permalink(file_path: Union[Path, str]) -> str:
|
|
|
61
64
|
return "/".join(clean_segments)
|
|
62
65
|
|
|
63
66
|
|
|
64
|
-
def setup_logging(
|
|
67
|
+
def setup_logging(
|
|
68
|
+
home_dir: Path = config.home, log_file: Optional[str] = None
|
|
69
|
+
) -> None: # pragma: no cover
|
|
65
70
|
"""
|
|
66
71
|
Configure logging for the application.
|
|
72
|
+
:param home_dir: the root directory for the application
|
|
73
|
+
:param log_file: the name of the log file to write to
|
|
74
|
+
:param app: the fastapi application instance
|
|
67
75
|
"""
|
|
68
76
|
|
|
69
77
|
# Remove default handler and any existing handlers
|
|
70
78
|
logger.remove()
|
|
71
79
|
|
|
72
|
-
# Add file handler
|
|
73
|
-
if log_file:
|
|
80
|
+
# Add file handler if we are not running tests
|
|
81
|
+
if log_file and config.env != "test":
|
|
82
|
+
# enable pydantic logfire
|
|
83
|
+
logfire.configure(
|
|
84
|
+
code_source=logfire.CodeSource(
|
|
85
|
+
repository="https://github.com/basicmachines-co/basic-memory",
|
|
86
|
+
revision=basic_memory.__version__,
|
|
87
|
+
root_path="/src/basic_memory",
|
|
88
|
+
),
|
|
89
|
+
environment=config.env,
|
|
90
|
+
)
|
|
91
|
+
logger.configure(handlers=[logfire.loguru_handler()])
|
|
92
|
+
|
|
93
|
+
# instrument code spans
|
|
94
|
+
logfire.instrument_sqlite3()
|
|
95
|
+
logfire.instrument_pydantic()
|
|
96
|
+
|
|
97
|
+
from basic_memory.db import _engine as engine
|
|
98
|
+
|
|
99
|
+
if engine:
|
|
100
|
+
logfire.instrument_sqlalchemy(engine=engine)
|
|
101
|
+
|
|
102
|
+
# setup logger
|
|
74
103
|
log_path = home_dir / log_file
|
|
75
104
|
logger.add(
|
|
76
|
-
str(log_path),
|
|
105
|
+
str(log_path),
|
|
77
106
|
level=config.log_level,
|
|
78
107
|
rotation="100 MB",
|
|
79
108
|
retention="10 days",
|
|
@@ -85,3 +114,5 @@ def setup_logging(home_dir: Path = config.home, log_file: Optional[str] = None)
|
|
|
85
114
|
|
|
86
115
|
# Add stderr handler
|
|
87
116
|
logger.add(sys.stderr, level=config.log_level, backtrace=True, diagnose=True, colorize=True)
|
|
117
|
+
|
|
118
|
+
logger.info(f"ENV: '{config.env}' Log level: '{config.log_level}' Logging to {log_file}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: basic-memory
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.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
|
|
@@ -15,6 +15,7 @@ Requires-Dist: dateparser>=1.2.0
|
|
|
15
15
|
Requires-Dist: fastapi[standard]>=0.115.8
|
|
16
16
|
Requires-Dist: greenlet>=3.1.1
|
|
17
17
|
Requires-Dist: icecream>=2.1.3
|
|
18
|
+
Requires-Dist: logfire[fastapi,sqlalchemy,sqlite3]>=3.6.0
|
|
18
19
|
Requires-Dist: loguru>=0.7.3
|
|
19
20
|
Requires-Dist: markdown-it-py>=3.0.0
|
|
20
21
|
Requires-Dist: mcp>=1.2.0
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
basic_memory/__init__.py,sha256=
|
|
2
|
-
basic_memory/config.py,sha256=
|
|
1
|
+
basic_memory/__init__.py,sha256=dDb_uz3MKuWHLxcMY3ytbIQPv3aAHuYxKZ3jAvt2rPo,122
|
|
2
|
+
basic_memory/config.py,sha256=NGalTXjTw6OlIDdmWRygy-2jBqGfl9AuXGHy3MUdM-I,1793
|
|
3
3
|
basic_memory/db.py,sha256=IK_gz8Uiwcgxe8TjarW7kpl8cVVNtEnR0lm1LemgZ8I,5283
|
|
4
4
|
basic_memory/deps.py,sha256=UzivBw6e6iYcU_8SQ8LNCmSsmFyHfjdzfWvnfNzqbRc,5375
|
|
5
5
|
basic_memory/file_utils.py,sha256=gp7RCFWaddFnELIyTc1E19Rk8jJsrKshG2n8ZZR-kKA,5751
|
|
6
|
-
basic_memory/utils.py,sha256=
|
|
6
|
+
basic_memory/utils.py,sha256=UriwNFpuHXaWLjEQwIitb1yelzeMhkuKDnIpUh6Zfbw,3388
|
|
7
7
|
basic_memory/alembic/README,sha256=MVlc9TYmr57RbhXET6QxgyCcwWP7w-vLkEsirENqiIQ,38
|
|
8
8
|
basic_memory/alembic/env.py,sha256=XqJVQhS41ba7NCPmmaSZ09_tbSLnwsY2bcpJpqx_ZTc,2107
|
|
9
9
|
basic_memory/alembic/migrations.py,sha256=CIbkMHEKZ60aDUhFGSQjv8kDNM7sazfvEYHGGcy1DBk,858
|
|
10
10
|
basic_memory/alembic/script.py.mako,sha256=MEqL-2qATlST9TAOeYgscMn1uy6HUS9NFvDgl93dMj8,635
|
|
11
11
|
basic_memory/alembic/versions/3dae7c7b1564_initial_schema.py,sha256=lTbWlAnd1es7xU99DoJgfaRe1_Kte8TL98riqeKGV80,4363
|
|
12
12
|
basic_memory/api/__init__.py,sha256=wCpj-21j1D0KzKl9Ql6unLBVFY0K1uGp_FeSZRKtqpk,72
|
|
13
|
-
basic_memory/api/app.py,sha256=
|
|
13
|
+
basic_memory/api/app.py,sha256=0vmDJDhKkRN1f7XDO3hqcUpXrLRmcHOH79O5x4hPtho,1573
|
|
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
|
|
@@ -18,7 +18,7 @@ basic_memory/api/routers/resource_router.py,sha256=MoW8LEjBfNbJsp6Nt2JnE4LKe3ysi
|
|
|
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
|
|
21
|
-
basic_memory/cli/main.py,sha256=
|
|
21
|
+
basic_memory/cli/main.py,sha256=4RElTaSskLZvS7EAk4KbkU7inDRhoQqHcr_UR5I6lMo,423
|
|
22
22
|
basic_memory/cli/commands/__init__.py,sha256=OQGLaKTsOdPsp2INM_pHzmOlbVfdL0sytBNgvqTqCDY,159
|
|
23
23
|
basic_memory/cli/commands/db.py,sha256=XW2ujzas5j2Gf01NOPQI89L4NK-21GksO_OIekKxv6c,770
|
|
24
24
|
basic_memory/cli/commands/import_chatgpt.py,sha256=Jnqj_kswM9S-qauPCHqLiMIQMvY4PXULHZSiqVJ_veQ,8150
|
|
@@ -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.6.0.dist-info/METADATA,sha256=GcfzSP0T_Fr8dh6xAIYPrZKBXLOTiMyQ-9vg6EJ3JkI,10849
|
|
78
|
+
basic_memory-0.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
79
|
+
basic_memory-0.6.0.dist-info/entry_points.txt,sha256=IDQa_VmVTzmvMrpnjhEfM0S3F--XsVGEj3MpdJfuo-Q,59
|
|
80
|
+
basic_memory-0.6.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
81
|
+
basic_memory-0.6.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|