jev-cli 0.6.0__tar.gz → 0.6.3__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.
- {jev_cli-0.6.0 → jev_cli-0.6.3}/PKG-INFO +14 -2
- {jev_cli-0.6.0 → jev_cli-0.6.3}/README.md +13 -1
- {jev_cli-0.6.0 → jev_cli-0.6.3}/pyproject.toml +1 -1
- {jev_cli-0.6.0 → jev_cli-0.6.3}/src/jev_cli/__init__.py +46 -3
- {jev_cli-0.6.0 → jev_cli-0.6.3}/src/jev_cli/mcp_server.py +1 -1
- {jev_cli-0.6.0 → jev_cli-0.6.3}/tests/test_jev.py +35 -2
- {jev_cli-0.6.0 → jev_cli-0.6.3}/LICENSE +0 -0
- {jev_cli-0.6.0 → jev_cli-0.6.3}/scripts/embed_skills.py +0 -0
- {jev_cli-0.6.0 → jev_cli-0.6.3}/skills/jev-cli/SKILL.md +0 -0
- {jev_cli-0.6.0 → jev_cli-0.6.3}/skills/jev-cli/references/cli.md +0 -0
- {jev_cli-0.6.0 → jev_cli-0.6.3}/src/jev_cli/bundled_skills/jev-cli/SKILL.md +0 -0
- {jev_cli-0.6.0 → jev_cli-0.6.3}/src/jev_cli/bundled_skills/jev-cli/references/cli.md +0 -0
- {jev_cli-0.6.0 → jev_cli-0.6.3}/src/jev_cli/py.typed +0 -0
- {jev_cli-0.6.0 → jev_cli-0.6.3}/tests/test_mcp_server.py +0 -0
- {jev_cli-0.6.0 → jev_cli-0.6.3}/tests/test_skill.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jev-cli
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.3
|
|
4
4
|
Summary: Small CLI and stdio MCP server for TypeSafe Jev
|
|
5
5
|
Keywords: typesafe,jev,cli,mcp,ai
|
|
6
6
|
License-Expression: MIT
|
|
@@ -23,6 +23,18 @@ A small CLI and stdio MCP server for [TypeSafe Jev](https://docs.typesafe.ai/int
|
|
|
23
23
|
|
|
24
24
|
The `jev` command is useful when application code needs a fast classification or judgment instead of generated prose. The `jev-mcp` command exposes the same judgments to MCP hosts over stdio.
|
|
25
25
|
|
|
26
|
+
[](assets/jev-cli-terminal-demo.mp4)
|
|
27
|
+
|
|
28
|
+
_Click the thumbnail to watch the 19-second terminal demo._
|
|
29
|
+
|
|
30
|
+
## Screenshots
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+

|
|
35
|
+
|
|
36
|
+

|
|
37
|
+
|
|
26
38
|
> **Unofficial:** This is an independent community project. It is not affiliated with, maintained by, or endorsed by TypeSafe AI.
|
|
27
39
|
|
|
28
40
|
## Features
|
|
@@ -59,7 +71,7 @@ jev --version
|
|
|
59
71
|
Expected output:
|
|
60
72
|
|
|
61
73
|
```text
|
|
62
|
-
jev 0.6.
|
|
74
|
+
jev 0.6.3
|
|
63
75
|
```
|
|
64
76
|
|
|
65
77
|
## Authentication
|
|
@@ -4,6 +4,18 @@ A small CLI and stdio MCP server for [TypeSafe Jev](https://docs.typesafe.ai/int
|
|
|
4
4
|
|
|
5
5
|
The `jev` command is useful when application code needs a fast classification or judgment instead of generated prose. The `jev-mcp` command exposes the same judgments to MCP hosts over stdio.
|
|
6
6
|
|
|
7
|
+
[](assets/jev-cli-terminal-demo.mp4)
|
|
8
|
+
|
|
9
|
+
_Click the thumbnail to watch the 19-second terminal demo._
|
|
10
|
+
|
|
11
|
+
## Screenshots
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
7
19
|
> **Unofficial:** This is an independent community project. It is not affiliated with, maintained by, or endorsed by TypeSafe AI.
|
|
8
20
|
|
|
9
21
|
## Features
|
|
@@ -40,7 +52,7 @@ jev --version
|
|
|
40
52
|
Expected output:
|
|
41
53
|
|
|
42
54
|
```text
|
|
43
|
-
jev 0.6.
|
|
55
|
+
jev 0.6.3
|
|
44
56
|
```
|
|
45
57
|
|
|
46
58
|
## Authentication
|
|
@@ -49,6 +49,44 @@ class CliError(Exception):
|
|
|
49
49
|
self.exit_code = exit_code
|
|
50
50
|
|
|
51
51
|
|
|
52
|
+
def masked_getpass(prompt: str) -> str:
|
|
53
|
+
"""Read a secret while showing one asterisk per entered character."""
|
|
54
|
+
try:
|
|
55
|
+
import termios
|
|
56
|
+
except ImportError:
|
|
57
|
+
return getpass.getpass(prompt)
|
|
58
|
+
|
|
59
|
+
stream = sys.stderr
|
|
60
|
+
stream.write(prompt)
|
|
61
|
+
stream.flush()
|
|
62
|
+
fd = sys.stdin.fileno()
|
|
63
|
+
previous = termios.tcgetattr(fd)
|
|
64
|
+
current = previous.copy()
|
|
65
|
+
current[3] &= ~(termios.ECHO | termios.ICANON)
|
|
66
|
+
characters: list[str] = []
|
|
67
|
+
try:
|
|
68
|
+
termios.tcsetattr(fd, termios.TCSADRAIN, current)
|
|
69
|
+
while True:
|
|
70
|
+
character = sys.stdin.read(1)
|
|
71
|
+
if character in ("\n", "\r"):
|
|
72
|
+
stream.write("\n")
|
|
73
|
+
return "".join(characters)
|
|
74
|
+
if character == "\x03":
|
|
75
|
+
raise KeyboardInterrupt
|
|
76
|
+
if character in ("\x7f", "\b"):
|
|
77
|
+
if characters:
|
|
78
|
+
characters.pop()
|
|
79
|
+
stream.write("\b \b")
|
|
80
|
+
elif character:
|
|
81
|
+
characters.append(character)
|
|
82
|
+
stream.write("*")
|
|
83
|
+
else:
|
|
84
|
+
raise EOFError
|
|
85
|
+
stream.flush()
|
|
86
|
+
finally:
|
|
87
|
+
termios.tcsetattr(fd, termios.TCSADRAIN, previous)
|
|
88
|
+
|
|
89
|
+
|
|
52
90
|
def api_key(provider: str = "official") -> str:
|
|
53
91
|
config = PROVIDERS[provider]
|
|
54
92
|
if value := os.environ.get(config["key_env"]):
|
|
@@ -73,7 +111,7 @@ def api_key(provider: str = "official") -> str:
|
|
|
73
111
|
|
|
74
112
|
def set_api_key(provider: str = "official") -> None:
|
|
75
113
|
label = "TypeSafe" if provider == "official" else provider
|
|
76
|
-
value =
|
|
114
|
+
value = masked_getpass(f"{label} API key: ").strip() if sys.stdin.isatty() else sys.stdin.read().strip()
|
|
77
115
|
if not value:
|
|
78
116
|
raise CliError("API key is empty")
|
|
79
117
|
CREDENTIALS_FILE.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
|
|
@@ -241,7 +279,7 @@ def call(payload: dict[str, Any], endpoint: str, provider: str = "official") ->
|
|
|
241
279
|
headers={
|
|
242
280
|
"Authorization": f"Bearer {api_key(provider)}",
|
|
243
281
|
"Content-Type": "application/json",
|
|
244
|
-
"User-Agent": "jev-cli/0.6.
|
|
282
|
+
"User-Agent": "jev-cli/0.6.3",
|
|
245
283
|
**provider_headers,
|
|
246
284
|
},
|
|
247
285
|
method="POST",
|
|
@@ -257,6 +295,8 @@ def call(payload: dict[str, Any], endpoint: str, provider: str = "official") ->
|
|
|
257
295
|
detail = body
|
|
258
296
|
code = 3 if exc.code in (401, 403) else 4 if exc.code in (429, 500, 502, 503, 504) else 1
|
|
259
297
|
raise CliError(f"API HTTP {exc.code}: {json.dumps(detail, ensure_ascii=False)}", code) from exc
|
|
298
|
+
except json.JSONDecodeError as exc:
|
|
299
|
+
raise CliError(f"API returned invalid JSON: {exc}", 4) from exc
|
|
260
300
|
except (urllib.error.URLError, TimeoutError) as exc:
|
|
261
301
|
raise CliError(f"API connection failed: {exc}", 4) from exc
|
|
262
302
|
if not isinstance(result, dict):
|
|
@@ -286,7 +326,7 @@ def parser() -> argparse.ArgumentParser:
|
|
|
286
326
|
prog="jev",
|
|
287
327
|
description="Evaluate text or JSON with TypeSafe Jev. Uses its own local credential store.",
|
|
288
328
|
)
|
|
289
|
-
root.add_argument("--version", action="version", version="jev 0.6.
|
|
329
|
+
root.add_argument("--version", action="version", version="jev 0.6.3")
|
|
290
330
|
sub = root.add_subparsers(dest="command", required=True)
|
|
291
331
|
common = common_parser()
|
|
292
332
|
|
|
@@ -400,6 +440,9 @@ def main() -> int:
|
|
|
400
440
|
except (KeyError, TypeError) as exc:
|
|
401
441
|
print(json.dumps({"ok": False, "error": f"unexpected API response: {exc}"}), file=sys.stderr)
|
|
402
442
|
return 1
|
|
443
|
+
except KeyboardInterrupt:
|
|
444
|
+
print("\nCancelled.", file=sys.stderr)
|
|
445
|
+
return 130
|
|
403
446
|
|
|
404
447
|
|
|
405
448
|
if __name__ == "__main__":
|
|
@@ -134,7 +134,7 @@ logger = logging.getLogger(__name__)
|
|
|
134
134
|
mcp = MCPServer(
|
|
135
135
|
name="jev",
|
|
136
136
|
title="TypeSafe Jev",
|
|
137
|
-
version="0.6.
|
|
137
|
+
version="0.6.3",
|
|
138
138
|
instructions=(
|
|
139
139
|
"Ask TypeSafe Jev typed questions about text or JSON state. Use noul for a yes/no "
|
|
140
140
|
"probability, choice for one key from explicit options, score for an ordered level, "
|
|
@@ -5,7 +5,12 @@ import unittest
|
|
|
5
5
|
import urllib.error
|
|
6
6
|
from email.message import Message
|
|
7
7
|
from pathlib import Path
|
|
8
|
-
from unittest.mock import patch
|
|
8
|
+
from unittest.mock import MagicMock, patch
|
|
9
|
+
|
|
10
|
+
try:
|
|
11
|
+
import termios
|
|
12
|
+
except ImportError:
|
|
13
|
+
termios = None
|
|
9
14
|
|
|
10
15
|
import jev_cli as jev
|
|
11
16
|
|
|
@@ -140,6 +145,26 @@ class JevTest(unittest.TestCase):
|
|
|
140
145
|
self.assertEqual(jev.CREDENTIALS_FILE.stat().st_mode & 0o777, 0o600)
|
|
141
146
|
self.assertEqual(jev.CREDENTIALS_FILE.parent.stat().st_mode & 0o777, 0o700)
|
|
142
147
|
|
|
148
|
+
def test_auth_set_interrupt_exits_without_traceback(self):
|
|
149
|
+
with patch("sys.argv", ["jev", "auth", "set"]), patch.object(
|
|
150
|
+
jev, "set_api_key", side_effect=KeyboardInterrupt
|
|
151
|
+
), patch("sys.stderr", new_callable=io.StringIO) as stderr:
|
|
152
|
+
self.assertEqual(jev.main(), 130)
|
|
153
|
+
self.assertEqual(stderr.getvalue(), "\nCancelled.\n")
|
|
154
|
+
self.assertNotIn("Traceback", stderr.getvalue())
|
|
155
|
+
|
|
156
|
+
@unittest.skipIf(termios is None, "termios is unavailable")
|
|
157
|
+
def test_masked_getpass_shows_one_asterisk_per_character(self):
|
|
158
|
+
stdin = MagicMock()
|
|
159
|
+
stdin.fileno.return_value = 7
|
|
160
|
+
stdin.read.side_effect = ["s", "e", "x", "\x7f", "c", "r", "e", "t", "\n"]
|
|
161
|
+
stderr = io.StringIO()
|
|
162
|
+
with patch("sys.stdin", stdin), patch("sys.stderr", stderr), patch.object(
|
|
163
|
+
termios, "tcgetattr", return_value=[0, 0, 0, termios.ECHO, 0, 0]
|
|
164
|
+
), patch.object(termios, "tcsetattr"):
|
|
165
|
+
self.assertEqual(jev.masked_getpass("TypeSafe API key: "), "secret")
|
|
166
|
+
self.assertEqual(stderr.getvalue(), "TypeSafe API key: ***\b \b****\n")
|
|
167
|
+
|
|
143
168
|
def test_set_api_key_prompts_without_echo_on_tty(self):
|
|
144
169
|
import tempfile
|
|
145
170
|
from pathlib import Path
|
|
@@ -147,7 +172,7 @@ class JevTest(unittest.TestCase):
|
|
|
147
172
|
with tempfile.TemporaryDirectory() as directory, patch.object(
|
|
148
173
|
jev, "CREDENTIALS_FILE", Path(directory) / "jev-cli" / "credentials.json"
|
|
149
174
|
), patch("sys.stdin.isatty", return_value=True), patch.object(
|
|
150
|
-
jev
|
|
175
|
+
jev, "masked_getpass", return_value="prompted-key"
|
|
151
176
|
) as prompt, patch.dict(os.environ, {}, clear=True):
|
|
152
177
|
jev.set_api_key()
|
|
153
178
|
prompt.assert_called_once_with("TypeSafe API key: ")
|
|
@@ -344,6 +369,14 @@ class JevTest(unittest.TestCase):
|
|
|
344
369
|
jev.call({"state": "test", "questions": {}}, "https://example.test")
|
|
345
370
|
self.assertEqual(raised.exception.exit_code, 4)
|
|
346
371
|
|
|
372
|
+
def test_call_maps_non_json_success_response_to_exit_code_4(self):
|
|
373
|
+
with patch.object(jev, "api_key", return_value="test-key"), patch(
|
|
374
|
+
"urllib.request.urlopen", return_value=io.BytesIO(b"<html>gateway timeout</html>")
|
|
375
|
+
):
|
|
376
|
+
with self.assertRaisesRegex(jev.CliError, "API returned invalid JSON") as raised:
|
|
377
|
+
jev.call({"state": "test", "questions": {}}, "https://example.test")
|
|
378
|
+
self.assertEqual(raised.exception.exit_code, 4)
|
|
379
|
+
|
|
347
380
|
def test_main_prints_only_primary_value(self):
|
|
348
381
|
argv = ["jev", "noul", "--question", "Urgent?", "--state", "today", "--value"]
|
|
349
382
|
with patch("sys.argv", argv), patch.object(
|
|
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
|