rio-cli 0.2.0__tar.gz → 0.2.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.
@@ -1,14 +1,15 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: rio-cli
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Command-line client for Rio, an automated code review tool.
5
5
  Project-URL: Homepage, https://github.com/JayTheCoder77/rio
6
6
  Project-URL: Repository, https://github.com/JayTheCoder77/rio
7
7
  Author: JayTheCoder77
8
8
  License-Expression: ISC
9
9
  License-File: LICENSE
10
- Requires-Python: <3.13,>=3.12
10
+ Requires-Python: >=3.12
11
11
  Requires-Dist: httpx>=0.28.1
12
+ Requires-Dist: platformdirs>=4.0
12
13
  Requires-Dist: pyyaml>=6.0
13
14
  Requires-Dist: rich>=15.0.0
14
15
  Requires-Dist: rio-review-core<0.2.0,>=0.1.0
@@ -38,8 +39,17 @@ dashboard's API keys page):
38
39
  rio auth
39
40
  ```
40
41
 
41
- This prompts for your API key, validates it against your Rio instance, and saves it to
42
- `~/.config/rio/config.toml` with restricted (`0600`) file permissions.
42
+ This prompts for your API key, validates it against your Rio instance, and saves it to the
43
+ platform-specific config file shown below. On POSIX the file is written with restricted
44
+ (`0600`) permissions; on Windows it lives under your already-private `%APPDATA%`.
45
+
46
+ | OS | Config file |
47
+ | --- | --- |
48
+ | Linux | `~/.config/rio/config.toml` |
49
+ | macOS | `~/Library/Application Support/rio/config.toml` |
50
+ | Windows | `%APPDATA%\rio\config.toml` |
51
+
52
+ The directory is created for you on first run, so you never need to mkdir by hand.
43
53
 
44
54
  ## Usage
45
55
 
@@ -62,9 +72,10 @@ rio review --staged --include-untracked
62
72
 
63
73
  ## Configuration
64
74
 
65
- `rio auth` manages `~/.config/rio/config.toml` for you. To point the CLI at a
66
- self-hosted `ai-engine` instance instead of the default (`http://localhost:8000`), edit
67
- the `[api] url` value in that file, or set it before running `rio auth`:
75
+ `rio auth` manages the platform-specific config file for you (see the table above for the
76
+ exact location per OS). To point the CLI at a self-hosted `ai-engine` instance instead of
77
+ the default (`https://rio-ai-engine.onrender.com`), edit the `[api] url` value in that
78
+ file, or set it before running `rio auth`:
68
79
 
69
80
  ```toml
70
81
  [api]
@@ -21,8 +21,17 @@ dashboard's API keys page):
21
21
  rio auth
22
22
  ```
23
23
 
24
- This prompts for your API key, validates it against your Rio instance, and saves it to
25
- `~/.config/rio/config.toml` with restricted (`0600`) file permissions.
24
+ This prompts for your API key, validates it against your Rio instance, and saves it to the
25
+ platform-specific config file shown below. On POSIX the file is written with restricted
26
+ (`0600`) permissions; on Windows it lives under your already-private `%APPDATA%`.
27
+
28
+ | OS | Config file |
29
+ | --- | --- |
30
+ | Linux | `~/.config/rio/config.toml` |
31
+ | macOS | `~/Library/Application Support/rio/config.toml` |
32
+ | Windows | `%APPDATA%\rio\config.toml` |
33
+
34
+ The directory is created for you on first run, so you never need to mkdir by hand.
26
35
 
27
36
  ## Usage
28
37
 
@@ -45,9 +54,10 @@ rio review --staged --include-untracked
45
54
 
46
55
  ## Configuration
47
56
 
48
- `rio auth` manages `~/.config/rio/config.toml` for you. To point the CLI at a
49
- self-hosted `ai-engine` instance instead of the default (`http://localhost:8000`), edit
50
- the `[api] url` value in that file, or set it before running `rio auth`:
57
+ `rio auth` manages the platform-specific config file for you (see the table above for the
58
+ exact location per OS). To point the CLI at a self-hosted `ai-engine` instance instead of
59
+ the default (`https://rio-ai-engine.onrender.com`), edit the `[api] url` value in that
60
+ file, or set it before running `rio auth`:
51
61
 
52
62
  ```toml
53
63
  [api]
@@ -1,17 +1,18 @@
1
1
  [project]
2
2
  name = "rio-cli"
3
- version = "0.2.0"
3
+ version = "0.2.2"
4
4
  description = "Command-line client for Rio, an automated code review tool."
5
5
  readme = "README.md"
6
6
  license = "ISC"
7
7
  authors = [{ name = "JayTheCoder77" }]
8
- requires-python = ">=3.12,<3.13"
8
+ requires-python = ">=3.12"
9
9
  dependencies = [
10
10
  "rio-review-core>=0.1.0,<0.2.0",
11
11
  "httpx>=0.28.1",
12
12
  "rich>=15.0.0",
13
13
  "typer>=0.27.1",
14
- "pyyaml>=6.0"
14
+ "pyyaml>=6.0",
15
+ "platformdirs>=4.0",
15
16
  ]
16
17
 
17
18
  [project.scripts]
@@ -29,8 +29,11 @@ def _write_config(data: dict) -> None:
29
29
  lines.append(f'api_key = "{api_section["api_key"]}"')
30
30
 
31
31
  CONFIG_PATH.write_text("\n".join(lines) + "\n")
32
- # This file holds a real credential don't rely on the default umask.
33
- os.chmod(CONFIG_PATH, stat.S_IRUSR | stat.S_IWUSR) # 0o600
32
+ # This file holds a real credential. On POSIX, lock it to the user via 0o600.
33
+ # That mode has no real meaning on Windows, where %APPDATA% is already
34
+ # per-user private by default.
35
+ if os.name != "nt":
36
+ os.chmod(CONFIG_PATH, stat.S_IRUSR | stat.S_IWUSR) # 0o600
34
37
 
35
38
 
36
39
  def _validate_api_key(api_key: str, ai_engine_url: str) -> None:
@@ -1,11 +1,15 @@
1
- from pathlib import Path
1
+ import os
2
2
 
3
+ import platformdirs
3
4
  import tomllib
4
5
 
5
6
  from rio_cli.utils import _fail
6
7
 
7
- DEFAULT_AI_ENGINE_URL = "http://localhost:8000"
8
- CONFIG_PATH = Path.home() / ".config" / "rio" / "config.toml"
8
+ DEFAULT_AI_ENGINE_URL = os.environ.get(
9
+ "RIO_API_URL", "https://rio-ai-engine.onrender.com"
10
+ )
11
+ # DEFAULT_AI_ENGINE_URL = "http://localhost:8000"
12
+ CONFIG_PATH = platformdirs.user_config_path("rio") / "config.toml"
9
13
 
10
14
  def get_ai_engine_url() -> str:
11
15
  if not CONFIG_PATH.exists():
@@ -7,11 +7,12 @@ from rio_cli.utils import _fail
7
7
 
8
8
 
9
9
  def _post_review(diff_text : str) -> list[Finding]:
10
- headers : dict = {}
11
10
  api_key = get_api_key()
12
- if api_key:
13
- headers["Authorization"] = f"Bearer {api_key}"
14
-
11
+ if not api_key:
12
+ _fail("Error: not authenticated. Run `rio auth` first.")
13
+
14
+ headers = {"Authorization": f"Bearer {api_key}"}
15
+
15
16
  rio_config = load_rio_config()
16
17
  ai_engine_url = get_ai_engine_url()
17
18
  try:
@@ -26,7 +27,13 @@ def _post_review(diff_text : str) -> list[Finding]:
26
27
 
27
28
  except httpx.TimeoutException:
28
29
  _fail("Error: ai-engine request timed out.")
29
-
30
+
31
+ if response.status_code == 401:
32
+ _fail("Error: not authenticated. Run `rio auth` first.")
33
+ if response.status_code == 412:
34
+ _fail(f"Error: {response.json().get('detail', response.text)}")
35
+ if response.status_code == 422:
36
+ _fail(f"Error: {response.json().get('detail', response.text)}")
30
37
  if response.status_code != 200:
31
38
  _fail(f"Error: ai-engine returned {response.status_code}: {response.text}")
32
39
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes