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.
- opencode_memory/__init__.py +3 -0
- opencode_memory/cache.py +261 -0
- opencode_memory/cli.py +794 -0
- opencode_memory/config.py +89 -0
- opencode_memory/daemon.py +879 -0
- opencode_memory/enrichment/__init__.py +0 -0
- opencode_memory/enrichment/gitlab.py +237 -0
- opencode_memory/extraction.py +225 -0
- opencode_memory/historical_ingest.py +142 -0
- opencode_memory/http_server.py +464 -0
- opencode_memory/ingestion/__init__.py +7 -0
- opencode_memory/ingestion/embeddings.py +211 -0
- opencode_memory/ingestion/extractors.py +287 -0
- opencode_memory/ingestion/opencode_db.py +448 -0
- opencode_memory/ingestion/parser.py +344 -0
- opencode_memory/ingestion/watcher.py +88 -0
- opencode_memory/linking/__init__.py +5 -0
- opencode_memory/linking/linker.py +323 -0
- opencode_memory/metrics.py +273 -0
- opencode_memory/models.py +171 -0
- opencode_memory/project.py +86 -0
- opencode_memory/query/__init__.py +5 -0
- opencode_memory/query/hybrid.py +196 -0
- opencode_memory/server.py +2795 -0
- opencode_memory/session/__init__.py +5 -0
- opencode_memory/session/registry.py +57 -0
- opencode_memory/storage/__init__.py +6 -0
- opencode_memory/storage/sqlite.py +1608 -0
- opencode_memory/storage/vectors.py +199 -0
- opencode_semantic_memory-0.1.0.dist-info/METADATA +531 -0
- opencode_semantic_memory-0.1.0.dist-info/RECORD +33 -0
- opencode_semantic_memory-0.1.0.dist-info/WHEEL +4 -0
- opencode_semantic_memory-0.1.0.dist-info/entry_points.txt +3 -0
|
@@ -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"
|