diff --git a/README.md b/README.md index fd757dd..2fa60f8 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ deliberately declines) is documented in [SEAMS.md](./SEAMS.md). contract in the manifest) when cards are due, and a desktop wake triggers a due check via the lifecycle-hook seam. -Storage is instance-scoped SQLite (`instance_paths().store("learning_wiki")`), +Storage is instance-scoped SQLite (`sdk.plugin_store(plugin_id="learning_wiki")`), no runtime pip deps; the FSRS-4.5 scheduler is pure Python with the published default weights (overridable via config). diff --git a/__init__.py b/__init__.py index 6df3df8..fbdbb49 100644 --- a/__init__.py +++ b/__init__.py @@ -25,12 +25,11 @@ def _data_dir(cfg: dict) -> Path: if override: p = Path(override).expanduser() else: - try: - from infra.paths import instance_paths # host-only; lazy by design + # Lazy so the package stays importable in its host-free test suite. The + # manifest's v0.148 floor guarantees this seam in a real host. + from graph import sdk - p = instance_paths().store("learning_wiki") - except Exception: # noqa: BLE001 — standalone / tests / older host - p = Path.home() / ".protoagent" / "learning_wiki" + p = sdk.plugin_store(plugin_id="learning_wiki") p.mkdir(parents=True, exist_ok=True) return p diff --git a/protoagent.plugin.yaml b/protoagent.plugin.yaml index 6cd2761..617f622 100644 --- a/protoagent.plugin.yaml +++ b/protoagent.plugin.yaml @@ -3,7 +3,7 @@ # (tests/test_packaging.py enforces it). id: learning_wiki name: Learning Wiki -version: 0.3.3 +version: 0.3.4 description: >- An adaptive learning wiki: the agent maintains a persistent, interlinked wiki of concept pages (Karpathy's LLM-wiki pattern) PLUS a learner ledger — per-concept @@ -21,11 +21,11 @@ description: >- enabled: false repository: https://github.com/protoLabsAI/learningWiki-plugin guide_url: https://github.com/protoLabsAI/learningWiki-plugin#install--enable -min_protoagent_version: "0.34.0" +min_protoagent_version: "0.148.0" # sdk.plugin_store config_section: learning_wiki config: - data_dir: "" # override the store dir; default = instance_paths().store("learning_wiki") + data_dir: "" # override the store dir; default = this instance's plugin store desired_retention: 0.9 # FSRS target retrievability at review time (0.7–0.97 sane) fsrs_weights: [] # 17 floats overriding the FSRS-4.5 defaults (empty = published defaults) nudge_interval_hours: 0 # >0 = background surface checks due cards every N hours diff --git a/pyproject.toml b/pyproject.toml index ac045c4..bf98a61 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "learning-wiki" -version = "0.3.3" +version = "0.3.4" description = "Adaptive learning-wiki plugin for protoAgent: LLM-maintained wiki + learner ledger + FSRS spaced review." requires-python = ">=3.11" diff --git a/tests/test_store_path.py b/tests/test_store_path.py new file mode 100644 index 0000000..15467dd --- /dev/null +++ b/tests/test_store_path.py @@ -0,0 +1,35 @@ +from __future__ import annotations + +import sys +import types + +import learning_wiki + + +def test_default_store_comes_from_the_plugin_sdk(monkeypatch, tmp_path): + monkeypatch.delenv("LEARNING_WIKI_DIR", raising=False) + calls = [] + sdk = types.ModuleType("graph.sdk") + + def plugin_store(*, plugin_id): + calls.append(plugin_id) + tmp_path.mkdir(parents=True, exist_ok=True) + return tmp_path + + sdk.plugin_store = plugin_store + graph = types.ModuleType("graph") + graph.sdk = sdk + monkeypatch.setitem(sys.modules, "graph", graph) + monkeypatch.setitem(sys.modules, "graph.sdk", sdk) + + assert learning_wiki._data_dir({}) == tmp_path + assert calls == ["learning_wiki"] + + +def test_config_and_env_overrides_stay_literal_and_skip_the_sdk(monkeypatch, tmp_path): + environment = tmp_path / "environment" + configured = tmp_path / "configured" + monkeypatch.setenv("LEARNING_WIKI_DIR", str(environment)) + + assert learning_wiki._data_dir({}) == environment + assert learning_wiki._data_dir({"data_dir": str(configured)}) == configured