diff --git a/reponame.bundle b/reponame.bundle deleted file mode 100644 index 16f027d5..00000000 Binary files a/reponame.bundle and /dev/null differ diff --git a/src/basic_memory/cli/main.py b/src/basic_memory/cli/main.py index 20c656e4..f8e34b82 100644 --- a/src/basic_memory/cli/main.py +++ b/src/basic_memory/cli/main.py @@ -35,5 +35,9 @@ def init_db( asyncio.run(_init_db()) +@app.command() +def hello(name: str): + print(f"Hello {name}") + if __name__ == "__main__": # pragma: no cover app() \ No newline at end of file diff --git a/src/basic_memory/config.py b/src/basic_memory/config.py index 38d608e6..d1bb552a 100644 --- a/src/basic_memory/config.py +++ b/src/basic_memory/config.py @@ -14,14 +14,14 @@ DATA_DIR_NAME = "data" class ProjectConfig(BaseSettings): """Configuration for a specific basic-memory project.""" - name: str = Field(default="default") - path: Path = Field( - default_factory=lambda: Path.home() / ".basic-memory" / "projects" / "default", - description="Path to project files", + # Default to ~/.basic-memory but allow override with env var + home: Path = Field( + default_factory=lambda: Path.home() / ".basic-memory", + description="Base path for basic-memory files", ) model_config = SettingsConfigDict( - env_prefix="BASIC_MEMORY_", # env vars like BASIC_MEMORY_DB_URL + env_prefix="BASIC_MEMORY_", extra="ignore", env_file=".env", env_file_encoding="utf-8", @@ -29,26 +29,20 @@ class ProjectConfig(BaseSettings): @property def knowledge_dir(self) -> Path: - """Get knowledge directory path based on project path.""" - knowledge_path = self.path / KNOWLEDGE_DIR_NAME - knowledge_path.parent.mkdir(parents=True, exist_ok=True) - return knowledge_path + """Get knowledge directory path.""" + return self.home / KNOWLEDGE_DIR_NAME @property def documents_dir(self) -> Path: - """Get documents directory path based on project path.""" - documents_path = self.path / DOCUMENTS_DIR_NAME - documents_path.parent.mkdir(parents=True, exist_ok=True) - return documents_path + """Get documents directory path.""" + return self.home / DOCUMENTS_DIR_NAME @property def database_path(self) -> Path: - """Get SQLite database URL based on project path.""" - db_path = self.path / DATA_DIR_NAME / DATABASE_NAME - db_path.parent.mkdir(parents=True, exist_ok=True) - return db_path + """Get SQLite database path.""" + return self.home / DATA_DIR_NAME / DATABASE_NAME - @field_validator("path") + @field_validator("home") @classmethod def ensure_path_exists(cls, v: Path) -> Path: """Ensure project path exists.""" diff --git a/src/basic_memory/mcp/main.py b/src/basic_memory/mcp/main.py index 52b10953..9c725b7e 100644 --- a/src/basic_memory/mcp/main.py +++ b/src/basic_memory/mcp/main.py @@ -6,6 +6,7 @@ Creates and configures the shared MCP instance and handles server startup. import sys from loguru import logger +from basic_memory.config import config # Import shared mcp instance from basic_memory.mcp.server import mcp @@ -14,14 +15,15 @@ from basic_memory.mcp.tools import knowledge, search, documents __all__ = ["mcp", "knowledge", "search", "documents"] -def setup_logging(log_file: str = "basic-memory-mcp.log"): +def setup_logging(home_dir: str = config.home, log_file: str = "basic-memory.log"): """Configure logging for the application.""" # Remove default handler logger.remove() - + log = f"{home_dir}/{log_file}" + # Add file handler with rotation logger.add( - log_file, + log, rotation="100 MB", retention="10 days", backtrace=True, @@ -38,6 +40,9 @@ def setup_logging(log_file: str = "basic-memory-mcp.log"): if __name__ == "__main__": - setup_logging() + + home_dir = config.home + setup_logging(home_dir) logger.info("Starting Basic Memory MCP server") + logger.info(f"Home directory: {home_dir}" ) mcp.run() \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index 08aa3f2f..0d8cf0e0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -38,7 +38,7 @@ def test_config(tmp_path): config = ProjectConfig( name="test", ) - config.path = tmp_path + config.home = tmp_path return config