opencode-semantic-memory 0.1.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.
@@ -0,0 +1,89 @@
1
+ """Configuration management for opencode-memory."""
2
+
3
+ from pathlib import Path
4
+ from typing import Any
5
+
6
+ import tomli
7
+ from pydantic import BaseModel, Field
8
+
9
+
10
+ class IdentityConfig(BaseModel):
11
+ """Configuration for user identity."""
12
+
13
+ user: str | None = None # Auto-detected from git if not set
14
+ instance: str = "gitlab.com"
15
+ primary_project: str | None = None # Auto-detected from git if not set
16
+
17
+
18
+ class BootConfig(BaseModel):
19
+ """Configuration for boot context."""
20
+
21
+ identity: bool = True
22
+ active_sessions: bool = True
23
+ hot_items: bool = True
24
+ recent_decisions: bool = False
25
+ unresolved_blockers: bool = True
26
+ max_hot_items: int = 5
27
+ recent_decision_days: int = 3
28
+
29
+
30
+ class IngestionConfig(BaseModel):
31
+ """Configuration for data ingestion."""
32
+
33
+ watch_paths: list[str] = Field(
34
+ default_factory=lambda: [
35
+ "~/.local/share/opencode/opencode.db",
36
+ ]
37
+ )
38
+ db_poll_interval: int = 30
39
+ # Enable/disable automatic session ingestion (pattern-based, no LLM cost)
40
+ enabled: bool = True
41
+ # Enable/disable LLM-based knowledge extraction from old conversations
42
+ # WARNING: This calls 'opencode run' for each conversation, which uses your
43
+ # LLM API and may incur significant costs. Runs every 6 hours on up to 50
44
+ # conversations per cycle.
45
+ llm_extraction: bool = False # Off by default due to cost
46
+ working_directory: str | None = None # cwd for opencode during LLM extraction
47
+
48
+
49
+ class StorageConfig(BaseModel):
50
+ """Configuration for data storage."""
51
+
52
+ path: str = "~/.local/share/opencode-memory"
53
+
54
+
55
+ class Config(BaseModel):
56
+ """Main configuration."""
57
+
58
+ identity: IdentityConfig = Field(default_factory=IdentityConfig)
59
+ boot: BootConfig = Field(default_factory=BootConfig)
60
+ ingestion: IngestionConfig = Field(default_factory=IngestionConfig)
61
+ storage: StorageConfig = Field(default_factory=StorageConfig)
62
+
63
+ @classmethod
64
+ def load(cls, config_path: Path | None = None) -> "Config":
65
+ """Load configuration from file or use defaults."""
66
+ if config_path is None:
67
+ config_path = Path.home() / ".config" / "opencode-memory" / "config.toml"
68
+
69
+ if config_path.exists():
70
+ with open(config_path, "rb") as f:
71
+ data: dict[str, Any] = tomli.load(f)
72
+ return cls.model_validate(data)
73
+
74
+ return cls()
75
+
76
+ @property
77
+ def storage_path(self) -> Path:
78
+ """Get expanded storage path."""
79
+ return Path(self.storage.path).expanduser()
80
+
81
+ @property
82
+ def db_path(self) -> Path:
83
+ """Get path to SQLite database."""
84
+ return self.storage_path / "memory.db"
85
+
86
+ @property
87
+ def vectors_path(self) -> Path:
88
+ """Get path to vector store."""
89
+ return self.storage_path / "vectors"