onesearch-cli 1.7.0__tar.gz → 1.8.0__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. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/PKG-INFO +3 -2
  2. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/onesearch/__init__.py +1 -1
  3. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/onesearch/commands/search.py +1 -1
  4. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/onesearch/commands/status.py +3 -3
  5. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/pyproject.toml +3 -2
  6. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/tests/test_api.py +8 -0
  7. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/tests/test_integration_auth.py +7 -1
  8. onesearch_cli-1.8.0/tests/test_json_output.py +68 -0
  9. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/.gitignore +0 -0
  10. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/README.md +0 -0
  11. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/onesearch/api.py +0 -0
  12. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/onesearch/banner.py +0 -0
  13. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/onesearch/commands/__init__.py +0 -0
  14. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/onesearch/commands/auth.py +0 -0
  15. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/onesearch/commands/config.py +0 -0
  16. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/onesearch/commands/source.py +0 -0
  17. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/onesearch/config.py +0 -0
  18. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/onesearch/context.py +0 -0
  19. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/onesearch/main.py +0 -0
  20. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/tests/test_auth_commands.py +0 -0
  21. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/tests/test_banner.py +0 -0
  22. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/tests/test_config.py +0 -0
  23. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/tests/test_main.py +0 -0
  24. {onesearch_cli-1.7.0 → onesearch_cli-1.8.0}/tests/test_reindex_full.py +0 -0
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: onesearch-cli
3
- Version: 1.7.0
3
+ Version: 1.8.0
4
4
  Summary: Standalone CLI client for a running OneSearch server
5
5
  License: AGPL-3.0-only
6
- Requires-Python: >=3.10
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: certifi>=2026.10.19
7
8
  Requires-Dist: click>=8.1.0
8
9
  Requires-Dist: python-dotenv>=1.0.0
9
10
  Requires-Dist: pyyaml>=6.0.0
@@ -3,4 +3,4 @@
3
3
 
4
4
  """OneSearch CLI - Command-line interface for OneSearch."""
5
5
 
6
- __version__ = "1.7.0"
6
+ __version__ = "1.8.0"
@@ -90,7 +90,7 @@ def search(
90
90
  out = ctx.get_console()
91
91
 
92
92
  if as_json:
93
- console.print(json.dumps(result, indent=2))
93
+ click.echo(json.dumps(result, indent=2))
94
94
  return
95
95
 
96
96
  # Backend returns: {results, total, limit, offset, processing_time_ms}
@@ -54,7 +54,7 @@ def status(ctx: Context, source_id: str | None, as_json: bool):
54
54
  # Backend returns flat: {source_id, source_name, total_files, successful, failed, skipped, last_indexed_at, failed_files}
55
55
  result = api.source_status(source_id)
56
56
  if as_json:
57
- console.print(json.dumps(result, indent=2, default=str))
57
+ click.echo(json.dumps(result, indent=2, default=str))
58
58
  return
59
59
 
60
60
  console.print(f"\n[bold cyan]{result.get('source_name', 'Unknown')}[/bold cyan] (ID: {result.get('source_id', source_id)})")
@@ -92,7 +92,7 @@ def status(ctx: Context, source_id: str | None, as_json: bool):
92
92
  # Backend returns: {sources: [{source_id, source_name, total_files, successful, failed, skipped, last_indexed_at, ...}]}
93
93
  result = api.status()
94
94
  if as_json:
95
- console.print(json.dumps(result, indent=2, default=str))
95
+ click.echo(json.dumps(result, indent=2, default=str))
96
96
  return
97
97
 
98
98
  sources = result.get("sources", [])
@@ -172,7 +172,7 @@ def health(ctx: Context, as_json: bool):
172
172
  "config_exists": config_path.exists(),
173
173
  "backend_url": ctx.url,
174
174
  }
175
- console.print(json.dumps(result, indent=2))
175
+ click.echo(json.dumps(result, indent=2))
176
176
  return
177
177
 
178
178
  # Essential status always shown (even in quiet mode)
@@ -1,13 +1,14 @@
1
1
  [project]
2
2
  name = "onesearch-cli"
3
- version = "1.7.0"
3
+ version = "1.8.0"
4
4
  description = "Standalone CLI client for a running OneSearch server"
5
5
  readme = "README.md"
6
6
  license = {text = "AGPL-3.0-only"}
7
- requires-python = ">=3.10"
7
+ requires-python = ">=3.11"
8
8
  dependencies = [
9
9
  "click>=8.1.0",
10
10
  "requests>=2.31.0",
11
+ "certifi>=2026.10.19",
11
12
  "rich>=13.0.0",
12
13
  "python-dotenv>=1.0.0",
13
14
  "pyyaml>=6.0.0",
@@ -2,6 +2,7 @@ import pytest
2
2
  import requests
3
3
 
4
4
  from onesearch.api import APIError, OneSearchAPI
5
+ from onesearch.config import get_auth_token
5
6
 
6
7
 
7
8
  class DummyResponse:
@@ -23,6 +24,13 @@ def test_api_client_sets_bearer_token():
23
24
  assert api.session.headers["Authorization"] == "Bearer secret"
24
25
 
25
26
 
27
+ def test_api_token_is_sent_unchanged_as_bearer(monkeypatch):
28
+ token = "os_AbCd-efGh_ijKlMnOpQrStUvWxYz0123456789abcdefgh"
29
+ monkeypatch.setenv("ONESEARCH_TOKEN", token)
30
+ api = OneSearchAPI(base_url="http://localhost:8000", token=get_auth_token())
31
+ assert api.session.headers["Authorization"] == f"Bearer {token}"
32
+
33
+
26
34
  def test_auth_error_message_is_actionable(monkeypatch):
27
35
  api = OneSearchAPI(base_url="http://localhost:8000")
28
36
 
@@ -51,7 +51,13 @@ def db_session():
51
51
 
52
52
 
53
53
  @pytest.fixture
54
- def backend_client(db_session):
54
+ def backend_client(db_session, tmp_path, monkeypatch):
55
+ # The app writes a generated session key to /app/data at startup when
56
+ # SESSION_SECRET isn't set. Keep it in tmp instead.
57
+ import app.api.auth as auth_module
58
+ monkeypatch.setattr(auth_module, "_session_secret_path", lambda: tmp_path / "session_secret")
59
+ monkeypatch.setattr(auth_module, "_generated_secret", None)
60
+
55
61
  def override_get_db():
56
62
  try:
57
63
  yield db_session
@@ -0,0 +1,68 @@
1
+ # Copyright (C) 2026 demigodmode
2
+ # SPDX-License-Identifier: AGPL-3.0-only
3
+
4
+ """--json output has to stay parseable when stdout isn't a terminal."""
5
+
6
+ import json
7
+
8
+ from click.testing import CliRunner
9
+
10
+ from onesearch.context import Context
11
+ from onesearch.main import cli
12
+
13
+ LONG_TEXT = "lorem ipsum dolor sit amet " * 10
14
+
15
+
16
+ class FakeAPI:
17
+ def search(self, **kwargs):
18
+ return {
19
+ "results": [{"path": "/docs/notes.txt", "snippet": LONG_TEXT}],
20
+ "total": 1,
21
+ "limit": 20,
22
+ "offset": 0,
23
+ "processing_time_ms": 3,
24
+ }
25
+
26
+ def status(self):
27
+ return {"sources": [{"source_id": "s1", "source_name": LONG_TEXT, "total_files": 1}]}
28
+
29
+ def source_status(self, source_id):
30
+ return {"source_id": source_id, "source_name": LONG_TEXT, "total_files": 1, "failed_files": []}
31
+
32
+ def health(self, allow_degraded=False):
33
+ return {"status": "ok", "version": "0.0.0", "message": LONG_TEXT}
34
+
35
+
36
+ def _invoke(monkeypatch, args):
37
+ monkeypatch.setattr(Context, "get_api", lambda self: FakeAPI())
38
+ runner = CliRunner()
39
+ return runner.invoke(cli, ["--url", "http://testserver", *args], obj=Context())
40
+
41
+
42
+ def test_search_json_is_valid_with_long_strings(monkeypatch):
43
+ result = _invoke(monkeypatch, ["search", "lorem", "--json"])
44
+
45
+ assert result.exit_code == 0, result.output
46
+ data = json.loads(result.output)
47
+ assert data["results"][0]["snippet"] == LONG_TEXT
48
+
49
+
50
+ def test_status_json_is_valid_with_long_strings(monkeypatch):
51
+ result = _invoke(monkeypatch, ["status", "--json"])
52
+
53
+ assert result.exit_code == 0, result.output
54
+ assert json.loads(result.output)["sources"][0]["source_name"] == LONG_TEXT
55
+
56
+
57
+ def test_source_status_json_is_valid_with_long_strings(monkeypatch):
58
+ result = _invoke(monkeypatch, ["status", "s1", "--json"])
59
+
60
+ assert result.exit_code == 0, result.output
61
+ assert json.loads(result.output)["source_name"] == LONG_TEXT
62
+
63
+
64
+ def test_health_json_is_valid_with_long_strings(monkeypatch):
65
+ result = _invoke(monkeypatch, ["health", "--json"])
66
+
67
+ assert result.exit_code == 0, result.output
68
+ assert json.loads(result.output)["message"] == LONG_TEXT
File without changes
File without changes