getbased-rag 0.7.0__tar.gz → 0.7.2__tar.gz

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.
Files changed (24) hide show
  1. getbased_rag-0.7.2/LICENSE +20 -0
  2. {getbased_rag-0.7.0/src/getbased_rag.egg-info → getbased_rag-0.7.2}/PKG-INFO +3 -3
  3. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/README.md +1 -1
  4. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/pyproject.toml +2 -2
  5. {getbased_rag-0.7.0 → getbased_rag-0.7.2/src/getbased_rag.egg-info}/PKG-INFO +3 -3
  6. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/getbased_rag.egg-info/SOURCES.txt +1 -0
  7. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/lens/config.py +32 -0
  8. getbased_rag-0.7.2/tests/test_env_loader.py +90 -0
  9. getbased_rag-0.7.0/LICENSE +0 -22
  10. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/setup.cfg +0 -0
  11. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/getbased_rag.egg-info/dependency_links.txt +0 -0
  12. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/getbased_rag.egg-info/entry_points.txt +0 -0
  13. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/getbased_rag.egg-info/requires.txt +0 -0
  14. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/getbased_rag.egg-info/top_level.txt +0 -0
  15. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/lens/__init__.py +0 -0
  16. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/lens/api_key.py +0 -0
  17. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/lens/cli.py +0 -0
  18. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/lens/embedder.py +0 -0
  19. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/lens/ingest.py +0 -0
  20. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/lens/registry.py +0 -0
  21. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/lens/server.py +0 -0
  22. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/src/lens/store.py +0 -0
  23. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/tests/test_onnx_embedder.py +0 -0
  24. {getbased_rag-0.7.0 → getbased_rag-0.7.2}/tests/test_server.py +0 -0
@@ -0,0 +1,20 @@
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU Affero General Public License is a free, copyleft license for
11
+ software and other kinds of works, specifically designed to ensure
12
+ cooperation with the community in the case of network server software.
13
+
14
+ The licenses for most software and other practical works are designed
15
+ to take away your freedom to share and change the works. By contrast,
16
+ our General Public Licenses are intended to guarantee your freedom to
17
+ share and change all versions of a program--to make sure it remains free
18
+ software for all its users.
19
+
20
+ For the full license text, see <https://www.gnu.org/licenses/agpl-3.0.txt>
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: getbased-rag
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: getbased-rag — standalone RAG knowledge server (formerly the Electron-bundled Lens)
5
- License-Expression: GPL-3.0-only
5
+ License-Expression: AGPL-3.0-or-later
6
6
  Requires-Python: >=3.10
7
7
  Description-Content-Type: text/markdown
8
8
  License-File: LICENSE
@@ -230,7 +230,7 @@ lens key Print the API key (creates one if missing)
230
230
 
231
231
  ## License
232
232
 
233
- GPL-3.0-only.
233
+ AGPL-3.0-or-later.
234
234
 
235
235
  ---
236
236
 
@@ -198,7 +198,7 @@ lens key Print the API key (creates one if missing)
198
198
 
199
199
  ## License
200
200
 
201
- GPL-3.0-only.
201
+ AGPL-3.0-or-later.
202
202
 
203
203
  ---
204
204
 
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "getbased-rag"
7
- version = "0.7.0"
7
+ version = "0.7.2"
8
8
  description = "getbased-rag — standalone RAG knowledge server (formerly the Electron-bundled Lens)"
9
9
  readme = "README.md"
10
- license = "GPL-3.0-only"
10
+ license = "AGPL-3.0-or-later"
11
11
  requires-python = ">=3.10"
12
12
  dependencies = [
13
13
  "fastapi>=0.110",
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: getbased-rag
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: getbased-rag — standalone RAG knowledge server (formerly the Electron-bundled Lens)
5
- License-Expression: GPL-3.0-only
5
+ License-Expression: AGPL-3.0-or-later
6
6
  Requires-Python: >=3.10
7
7
  Description-Content-Type: text/markdown
8
8
  License-File: LICENSE
@@ -230,7 +230,7 @@ lens key Print the API key (creates one if missing)
230
230
 
231
231
  ## License
232
232
 
233
- GPL-3.0-only.
233
+ AGPL-3.0-or-later.
234
234
 
235
235
  ---
236
236
 
@@ -16,5 +16,6 @@ src/lens/ingest.py
16
16
  src/lens/registry.py
17
17
  src/lens/server.py
18
18
  src/lens/store.py
19
+ tests/test_env_loader.py
19
20
  tests/test_onnx_embedder.py
20
21
  tests/test_server.py
@@ -6,6 +6,37 @@ from pathlib import Path
6
6
  from dataclasses import dataclass, field
7
7
 
8
8
 
9
+ def _maybe_load_user_env() -> None:
10
+ """Opt-in: load $XDG_CONFIG_HOME/getbased/env into os.environ.
11
+
12
+ Guarded by GETBASED_STACK_MANAGED=1. setdefault semantics — explicit env
13
+ wins. Silent on missing file; malformed lines skipped.
14
+ Escape hatch: GETBASED_NO_ENV_FILE=1 disables even when managed.
15
+ """
16
+ if os.environ.get("GETBASED_STACK_MANAGED") != "1":
17
+ return
18
+ if os.environ.get("GETBASED_NO_ENV_FILE") == "1":
19
+ return
20
+ xdg = os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config")
21
+ path = os.path.join(xdg, "getbased", "env")
22
+ try:
23
+ with open(path, "r", encoding="utf-8") as fh:
24
+ lines = fh.readlines()
25
+ except OSError:
26
+ return
27
+ for raw in lines:
28
+ line = raw.strip()
29
+ if not line or line.startswith("#") or "=" not in line:
30
+ continue
31
+ key, _, val = line.partition("=")
32
+ key = key.strip()
33
+ val = val.strip()
34
+ if len(val) >= 2 and val[0] == val[-1] and val[0] in ("'", '"'):
35
+ val = val[1:-1]
36
+ if key:
37
+ os.environ.setdefault(key, val)
38
+
39
+
9
40
  def _default_data_dir() -> Path:
10
41
  """Default data directory — platform-specific, matches what Tauri's
11
42
  dirs::data_dir() crate returns so the CLI and the desktop app share one
@@ -89,6 +120,7 @@ class LensConfig:
89
120
  @classmethod
90
121
  def from_env(cls) -> "LensConfig":
91
122
  """Load config from environment variables."""
123
+ _maybe_load_user_env()
92
124
  data_dir = Path(os.environ.get("LENS_DATA_DIR", str(_default_data_dir())))
93
125
 
94
126
  return cls(
@@ -0,0 +1,90 @@
1
+ """Tests for _maybe_load_user_env in lens.config.
2
+
3
+ Mirrors the mcp test for parity. The rag package is less Hermes-critical
4
+ (Hermes runs the legacy /home/elkim/kruse-corpus/lens_server.py, not this
5
+ one) but the same safety rules apply: no flag → no read.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import os
10
+ from pathlib import Path
11
+
12
+ import pytest
13
+
14
+ from lens.config import LensConfig, _maybe_load_user_env
15
+
16
+
17
+ @pytest.fixture
18
+ def env_file(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
19
+ monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path))
20
+ d = tmp_path / "getbased"
21
+ d.mkdir()
22
+ path = d / "env"
23
+ path.write_text("LENS_HOST=from_file.example\n")
24
+ return path
25
+
26
+
27
+ def test_noop_without_managed_flag(env_file, monkeypatch):
28
+ monkeypatch.delenv("GETBASED_STACK_MANAGED", raising=False)
29
+ monkeypatch.delenv("LENS_HOST", raising=False)
30
+
31
+ _maybe_load_user_env()
32
+
33
+ assert "LENS_HOST" not in os.environ
34
+
35
+
36
+ def test_loads_when_managed(env_file, monkeypatch):
37
+ monkeypatch.setenv("GETBASED_STACK_MANAGED", "1")
38
+ monkeypatch.delenv("LENS_HOST", raising=False)
39
+
40
+ _maybe_load_user_env()
41
+
42
+ assert os.environ["LENS_HOST"] == "from_file.example"
43
+
44
+
45
+ def test_explicit_env_wins(env_file, monkeypatch):
46
+ monkeypatch.setenv("GETBASED_STACK_MANAGED", "1")
47
+ monkeypatch.setenv("LENS_HOST", "from_shell.example")
48
+
49
+ _maybe_load_user_env()
50
+
51
+ assert os.environ["LENS_HOST"] == "from_shell.example"
52
+
53
+
54
+ def test_escape_hatch(env_file, monkeypatch):
55
+ monkeypatch.setenv("GETBASED_STACK_MANAGED", "1")
56
+ monkeypatch.setenv("GETBASED_NO_ENV_FILE", "1")
57
+ monkeypatch.delenv("LENS_HOST", raising=False)
58
+
59
+ _maybe_load_user_env()
60
+
61
+ assert "LENS_HOST" not in os.environ
62
+
63
+
64
+ def test_missing_file_silent(tmp_path, monkeypatch):
65
+ monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path))
66
+ monkeypatch.setenv("GETBASED_STACK_MANAGED", "1")
67
+
68
+ _maybe_load_user_env() # must not raise
69
+
70
+
71
+ def test_from_env_invokes_loader(env_file, monkeypatch):
72
+ """LensConfig.from_env() is the single entry point for env-driven
73
+ configuration; it must wire the loader in."""
74
+ monkeypatch.setenv("GETBASED_STACK_MANAGED", "1")
75
+ monkeypatch.delenv("LENS_HOST", raising=False)
76
+
77
+ cfg = LensConfig.from_env()
78
+
79
+ assert cfg.host == "from_file.example"
80
+
81
+
82
+ def test_from_env_parity_without_flag(env_file, monkeypatch):
83
+ """Hermes contract: without the flag, from_env() ignores the shared
84
+ file entirely and uses only explicit env + defaults."""
85
+ monkeypatch.delenv("GETBASED_STACK_MANAGED", raising=False)
86
+ monkeypatch.setenv("LENS_HOST", "explicit.example")
87
+
88
+ cfg = LensConfig.from_env()
89
+
90
+ assert cfg.host == "explicit.example"
@@ -1,22 +0,0 @@
1
- GNU GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
- Preamble
9
-
10
- The GNU General Public License is a free, copyleft license for
11
- software and other kinds of works.
12
-
13
- The licenses for most software and other practical works are designed
14
- to take away your freedom to share and change the works. By contrast,
15
- the GNU General Public License is intended to guarantee your freedom to
16
- share and change all versions of a program--to make sure it remains free
17
- software for all its users. We, the Free Software Foundation, use the
18
- GNU General Public License for most of our software; it applies also to
19
- any other work released this way by its authors. You can apply it to
20
- your programs, too.
21
-
22
- For the full license text, see <https://www.gnu.org/licenses/gpl-3.0.txt>
File without changes