reviso-cli 0.1.0__tar.gz → 0.1.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.
- {reviso_cli-0.1.0/src/reviso_cli.egg-info → reviso_cli-0.1.2}/PKG-INFO +9 -7
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/README.md +4 -6
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/pyproject.toml +10 -1
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/__init__.py +1 -1
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/client/http.py +20 -1
- {reviso_cli-0.1.0 → reviso_cli-0.1.2/src/reviso_cli.egg-info}/PKG-INFO +9 -7
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/tests/test_client.py +67 -17
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/LICENSE +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/setup.cfg +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/__main__.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/access.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/cli/__init__.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/cli/doctor.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/cli/guest_comments.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/cli/invites.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/cli/versions.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/client/__init__.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/client/collab.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/client/errors.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/client/participation.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/command_journal.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/document_route_keys.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/document_search.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/errors.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/ids.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/local.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/origin.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/paths.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli/scope.py +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli.egg-info/SOURCES.txt +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli.egg-info/dependency_links.txt +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli.egg-info/entry_points.txt +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli.egg-info/requires.txt +0 -0
- {reviso_cli-0.1.0 → reviso_cli-0.1.2}/src/reviso_cli.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: reviso-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Command line client for Reviso: publish drafts for human review, read reviewer comments back, and publish revisions safely.
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -28,6 +28,10 @@ License: MIT License
|
|
|
28
28
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
29
|
SOFTWARE.
|
|
30
30
|
|
|
31
|
+
Project-URL: Homepage, https://reviso.work
|
|
32
|
+
Project-URL: Documentation, https://github.com/reviso-si/reviso-agent
|
|
33
|
+
Project-URL: Repository, https://github.com/reviso-si/reviso-cli
|
|
34
|
+
Project-URL: Issues, https://github.com/reviso-si/reviso-cli/issues
|
|
31
35
|
Keywords: reviso,review,collaboration,documents,cli,agent
|
|
32
36
|
Classifier: Development Status :: 3 - Alpha
|
|
33
37
|
Classifier: Environment :: Console
|
|
@@ -57,16 +61,14 @@ agent's environment.
|
|
|
57
61
|
|
|
58
62
|
## Install
|
|
59
63
|
|
|
60
|
-
Not on PyPI yet, so install from source:
|
|
61
|
-
|
|
62
64
|
```bash
|
|
63
|
-
pip install
|
|
65
|
+
pip install reviso-cli
|
|
64
66
|
# or run it without installing
|
|
65
|
-
uvx --from
|
|
67
|
+
uvx --from reviso-cli reviso --help
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
Installs the `reviso` command.
|
|
69
|
-
|
|
70
|
+
Installs the `reviso` command. No runtime dependencies: installing it will not
|
|
71
|
+
pull a dependency graph into an agent's environment.
|
|
70
72
|
|
|
71
73
|
## Quick start
|
|
72
74
|
|
|
@@ -11,16 +11,14 @@ agent's environment.
|
|
|
11
11
|
|
|
12
12
|
## Install
|
|
13
13
|
|
|
14
|
-
Not on PyPI yet, so install from source:
|
|
15
|
-
|
|
16
14
|
```bash
|
|
17
|
-
pip install
|
|
15
|
+
pip install reviso-cli
|
|
18
16
|
# or run it without installing
|
|
19
|
-
uvx --from
|
|
17
|
+
uvx --from reviso-cli reviso --help
|
|
20
18
|
```
|
|
21
19
|
|
|
22
|
-
Installs the `reviso` command.
|
|
23
|
-
|
|
20
|
+
Installs the `reviso` command. No runtime dependencies: installing it will not
|
|
21
|
+
pull a dependency graph into an agent's environment.
|
|
24
22
|
|
|
25
23
|
## Quick start
|
|
26
24
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "reviso-cli"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.2"
|
|
8
8
|
description = "Command line client for Reviso: publish drafts for human review, read reviewer comments back, and publish revisions safely."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -28,6 +28,15 @@ dependencies = []
|
|
|
28
28
|
[project.optional-dependencies]
|
|
29
29
|
test = ["pytest>=8.0"]
|
|
30
30
|
|
|
31
|
+
# PyPI renders these as the package page's links. Without them the page is a
|
|
32
|
+
# dead end: someone who finds the package by search has no route to the docs,
|
|
33
|
+
# the source, or the issue tracker.
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://reviso.work"
|
|
36
|
+
Documentation = "https://github.com/reviso-si/reviso-agent"
|
|
37
|
+
Repository = "https://github.com/reviso-si/reviso-cli"
|
|
38
|
+
Issues = "https://github.com/reviso-si/reviso-cli/issues"
|
|
39
|
+
|
|
31
40
|
[project.scripts]
|
|
32
41
|
reviso = "reviso_cli.cli:main"
|
|
33
42
|
|
|
@@ -5,6 +5,7 @@ import json
|
|
|
5
5
|
import urllib.error
|
|
6
6
|
import urllib.request
|
|
7
7
|
from collections.abc import Callable
|
|
8
|
+
from urllib.parse import urlsplit
|
|
8
9
|
|
|
9
10
|
from .errors import raise_for_status
|
|
10
11
|
|
|
@@ -32,7 +33,8 @@ def request_json(base_url: str, key: str | None, method: str, path: str, *,
|
|
|
32
33
|
if source in ("stdio", "hosted_mcp", "python_client"):
|
|
33
34
|
req.add_header("X-Reviso-Client", source)
|
|
34
35
|
try:
|
|
35
|
-
with urllib.request.
|
|
36
|
+
with urllib.request.build_opener(CredentialRedirect).open(
|
|
37
|
+
req, timeout=TIMEOUT) as resp:
|
|
36
38
|
return json.loads(resp.read())
|
|
37
39
|
except urllib.error.HTTPError as e:
|
|
38
40
|
# Do NOT truncate below MAX_ERROR_BODY: the body is usually the
|
|
@@ -57,3 +59,20 @@ def _headers(data: bytes | None, key: str | None,
|
|
|
57
59
|
elif key:
|
|
58
60
|
headers["Authorization"] = f"Bearer {key}"
|
|
59
61
|
return headers
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class CredentialRedirect(urllib.request.HTTPRedirectHandler):
|
|
65
|
+
"""Refuse a redirect that leaves the origin the request was sent to.
|
|
66
|
+
|
|
67
|
+
The default handler follows a redirect and carries the request headers with
|
|
68
|
+
it, so a 302 pointing at another host would hand that host the automation
|
|
69
|
+
key -- or a guest token -- in an Authorization header. A redirect that
|
|
70
|
+
changes scheme or host is far more likely to be an attack or a
|
|
71
|
+
misconfiguration than something this client needs, so it fails instead.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
|
75
|
+
before, after = urlsplit(req.full_url), urlsplit(newurl)
|
|
76
|
+
if (before.scheme, before.netloc) != (after.scheme, after.netloc):
|
|
77
|
+
raise urllib.error.URLError("cross-origin redirect refused")
|
|
78
|
+
return super().redirect_request(req, fp, code, msg, headers, newurl)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: reviso-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Command line client for Reviso: publish drafts for human review, read reviewer comments back, and publish revisions safely.
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -28,6 +28,10 @@ License: MIT License
|
|
|
28
28
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
29
|
SOFTWARE.
|
|
30
30
|
|
|
31
|
+
Project-URL: Homepage, https://reviso.work
|
|
32
|
+
Project-URL: Documentation, https://github.com/reviso-si/reviso-agent
|
|
33
|
+
Project-URL: Repository, https://github.com/reviso-si/reviso-cli
|
|
34
|
+
Project-URL: Issues, https://github.com/reviso-si/reviso-cli/issues
|
|
31
35
|
Keywords: reviso,review,collaboration,documents,cli,agent
|
|
32
36
|
Classifier: Development Status :: 3 - Alpha
|
|
33
37
|
Classifier: Environment :: Console
|
|
@@ -57,16 +61,14 @@ agent's environment.
|
|
|
57
61
|
|
|
58
62
|
## Install
|
|
59
63
|
|
|
60
|
-
Not on PyPI yet, so install from source:
|
|
61
|
-
|
|
62
64
|
```bash
|
|
63
|
-
pip install
|
|
65
|
+
pip install reviso-cli
|
|
64
66
|
# or run it without installing
|
|
65
|
-
uvx --from
|
|
67
|
+
uvx --from reviso-cli reviso --help
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
Installs the `reviso` command.
|
|
69
|
-
|
|
70
|
+
Installs the `reviso` command. No runtime dependencies: installing it will not
|
|
71
|
+
pull a dependency graph into an agent's environment.
|
|
70
72
|
|
|
71
73
|
## Quick start
|
|
72
74
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"""Client behaviour against a fake server.
|
|
2
2
|
|
|
3
3
|
These pin the contract the agent skill depends on: what path a call hits, that
|
|
4
|
-
the base version is actually sent,
|
|
5
|
-
|
|
4
|
+
the base version is actually sent, that a server error envelope surfaces as a
|
|
5
|
+
coded failure, and that a redirect cannot walk the credential off-origin.
|
|
6
6
|
"""
|
|
7
7
|
from __future__ import annotations
|
|
8
8
|
|
|
@@ -14,22 +14,26 @@ import pytest
|
|
|
14
14
|
|
|
15
15
|
from reviso_cli.client import RevisoClient
|
|
16
16
|
|
|
17
|
+
DEFAULT = "*"
|
|
17
18
|
|
|
18
|
-
class _Recorder(BaseHTTPRequestHandler):
|
|
19
|
-
calls: list = []
|
|
20
19
|
|
|
20
|
+
class _Recorder(BaseHTTPRequestHandler):
|
|
21
21
|
def _handle(self) -> None:
|
|
22
22
|
length = int(self.headers.get("Content-Length") or 0)
|
|
23
23
|
raw = self.rfile.read(length).decode() if length else ""
|
|
24
|
-
|
|
24
|
+
server = self.server
|
|
25
|
+
server.calls.append({ # type: ignore[attr-defined]
|
|
25
26
|
"method": self.command,
|
|
26
27
|
"path": self.path,
|
|
27
28
|
"authorization": self.headers.get("Authorization"),
|
|
28
29
|
"body": json.loads(raw) if raw else None,
|
|
29
30
|
})
|
|
30
|
-
status, payload =
|
|
31
|
+
status, payload, location = server.routes.get( # type: ignore[attr-defined]
|
|
32
|
+
self.path, server.routes[DEFAULT])
|
|
31
33
|
body = json.dumps(payload).encode()
|
|
32
34
|
self.send_response(status)
|
|
35
|
+
if location:
|
|
36
|
+
self.send_header("Location", location)
|
|
33
37
|
self.send_header("Content-Type", "application/json")
|
|
34
38
|
self.send_header("Content-Length", str(len(body)))
|
|
35
39
|
self.end_headers()
|
|
@@ -42,17 +46,30 @@ class _Recorder(BaseHTTPRequestHandler):
|
|
|
42
46
|
pass
|
|
43
47
|
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
_Recorder.calls = []
|
|
49
|
+
def _serve(**routes):
|
|
50
|
+
"""Start a fake server. Routes map a path to (status, payload, location)."""
|
|
48
51
|
httpd = HTTPServer(("127.0.0.1", 0), _Recorder)
|
|
52
|
+
httpd.calls = [] # type: ignore[attr-defined]
|
|
53
|
+
httpd.routes = {DEFAULT: (200, {}, "")} # type: ignore[attr-defined]
|
|
54
|
+
for path, spec in routes.items():
|
|
55
|
+
httpd.routes["/" if path == "root" else path] = spec # type: ignore[attr-defined]
|
|
49
56
|
thread = threading.Thread(target=httpd.serve_forever, daemon=True)
|
|
50
57
|
thread.start()
|
|
58
|
+
return httpd, thread
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _stop(httpd, thread) -> None:
|
|
62
|
+
httpd.shutdown()
|
|
63
|
+
thread.join(timeout=5)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@pytest.fixture()
|
|
67
|
+
def server():
|
|
68
|
+
httpd, thread = _serve()
|
|
51
69
|
try:
|
|
52
70
|
yield httpd
|
|
53
71
|
finally:
|
|
54
|
-
httpd
|
|
55
|
-
thread.join(timeout=5)
|
|
72
|
+
_stop(httpd, thread)
|
|
56
73
|
|
|
57
74
|
|
|
58
75
|
def _client(httpd) -> RevisoClient:
|
|
@@ -61,11 +78,12 @@ def _client(httpd) -> RevisoClient:
|
|
|
61
78
|
|
|
62
79
|
|
|
63
80
|
def test_publish_posts_body_and_returns_response(server):
|
|
64
|
-
server.
|
|
81
|
+
server.routes["/api/documents"] = (
|
|
82
|
+
200, {"document_id": "doc_1", "browser_url": "https://x/d"}, "")
|
|
65
83
|
result = _client(server).publish(
|
|
66
84
|
"Title", "# Body", "markdown", "Initial draft", "wsp_1", "")
|
|
67
85
|
assert result["document_id"] == "doc_1"
|
|
68
|
-
call =
|
|
86
|
+
call = server.calls[-1]
|
|
69
87
|
assert call["method"] == "POST"
|
|
70
88
|
assert call["path"] == "/api/documents"
|
|
71
89
|
assert call["authorization"] == "Bearer rak_test"
|
|
@@ -74,16 +92,16 @@ def test_publish_posts_body_and_returns_response(server):
|
|
|
74
92
|
|
|
75
93
|
|
|
76
94
|
def test_update_always_carries_the_base_version(server):
|
|
77
|
-
server.
|
|
95
|
+
server.routes["/api/documents/doc_1/agent-update"] = (200, {"version_id": "ver_2"}, "")
|
|
78
96
|
_client(server).update("doc_1", "# Body", "ver_1", "Fix typo")
|
|
79
|
-
call =
|
|
97
|
+
call = server.calls[-1]
|
|
80
98
|
assert call["path"] == "/api/documents/doc_1/agent-update"
|
|
81
99
|
assert call["body"]["base_version_id"] == "ver_1"
|
|
82
100
|
|
|
83
101
|
|
|
84
102
|
def test_server_error_envelope_becomes_a_coded_failure(server):
|
|
85
|
-
server.
|
|
86
|
-
|
|
103
|
+
server.routes["/api/documents/doc_1/agent-update"] = (
|
|
104
|
+
409, {"error": {"code": "CAS_CONFLICT", "message": "base_version_changed"}}, "")
|
|
87
105
|
with pytest.raises(SystemExit) as excinfo:
|
|
88
106
|
_client(server).update("doc_1", "# Body", "ver_stale", "Fix typo")
|
|
89
107
|
assert "CAS_CONFLICT" in str(excinfo.value)
|
|
@@ -96,3 +114,35 @@ def test_client_has_no_share_link_surface():
|
|
|
96
114
|
for name in ("create_share_link", "list_share_links", "revoke_share_link"):
|
|
97
115
|
assert not hasattr(client, name)
|
|
98
116
|
assert hasattr(client, "create_invite")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def test_cross_origin_redirect_never_reaches_the_other_host(server):
|
|
120
|
+
"""A redirect off-origin must not carry the automation key with it.
|
|
121
|
+
|
|
122
|
+
urllib follows redirects by default and replays the request headers, so
|
|
123
|
+
without the guard the second server receives the Authorization header. The
|
|
124
|
+
assertion that matters is the second one: zero calls arrived there.
|
|
125
|
+
"""
|
|
126
|
+
other, other_thread = _serve()
|
|
127
|
+
try:
|
|
128
|
+
host, port = other.server_address
|
|
129
|
+
server.routes["/healthz"] = (
|
|
130
|
+
302, {"error": {"code": "MOVED"}}, f"http://{host}:{port}/steal")
|
|
131
|
+
|
|
132
|
+
with pytest.raises(SystemExit) as excinfo:
|
|
133
|
+
_client(server).health()
|
|
134
|
+
|
|
135
|
+
assert "cross-origin redirect refused" in str(excinfo.value)
|
|
136
|
+
assert other.calls == []
|
|
137
|
+
finally:
|
|
138
|
+
_stop(other, other_thread)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_same_origin_redirect_is_still_followed(server):
|
|
142
|
+
"""The guard must not break an ordinary redirect on the same origin."""
|
|
143
|
+
server.routes["/healthz"] = (302, {"error": {"code": "MOVED"}}, "/moved")
|
|
144
|
+
server.routes["/moved"] = (200, {"status": "ok"}, "")
|
|
145
|
+
|
|
146
|
+
assert _client(server).health() == {"status": "ok"}
|
|
147
|
+
assert [call["path"] for call in server.calls] == ["/healthz", "/moved"]
|
|
148
|
+
assert server.calls[-1]["authorization"] == "Bearer rak_test"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|