ape-linux 0.3.0__tar.gz → 0.3.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.
- {ape_linux-0.3.0 → ape_linux-0.3.2}/PKG-INFO +1 -1
- {ape_linux-0.3.0 → ape_linux-0.3.2}/ape_linux.py +32 -1
- {ape_linux-0.3.0 → ape_linux-0.3.2}/pyproject.toml +1 -1
- {ape_linux-0.3.0 → ape_linux-0.3.2}/tests/test_app.py +7 -0
- {ape_linux-0.3.0 → ape_linux-0.3.2}/uv.lock +1 -1
- {ape_linux-0.3.0 → ape_linux-0.3.2}/.github/workflows/publish.yaml +0 -0
- {ape_linux-0.3.0 → ape_linux-0.3.2}/.github/workflows/tests.yaml +0 -0
- {ape_linux-0.3.0 → ape_linux-0.3.2}/.gitignore +0 -0
- {ape_linux-0.3.0 → ape_linux-0.3.2}/.python-version +0 -0
- {ape_linux-0.3.0 → ape_linux-0.3.2}/LICENSE +0 -0
- {ape_linux-0.3.0 → ape_linux-0.3.2}/Makefile +0 -0
- {ape_linux-0.3.0 → ape_linux-0.3.2}/README.md +0 -0
|
@@ -2,15 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
import subprocess
|
|
5
|
+
from importlib.metadata import version
|
|
5
6
|
from typing import Annotated
|
|
6
7
|
|
|
7
8
|
import openai
|
|
8
9
|
import rich.console
|
|
9
10
|
import typer
|
|
10
11
|
|
|
12
|
+
__version__ = version("ape_linux")
|
|
13
|
+
|
|
11
14
|
app = typer.Typer(add_completion=False, pretty_exceptions_enable=False)
|
|
12
15
|
|
|
13
16
|
|
|
17
|
+
def version_callback(value: bool) -> None:
|
|
18
|
+
if value:
|
|
19
|
+
typer.echo(__version__)
|
|
20
|
+
raise typer.Exit()
|
|
21
|
+
|
|
22
|
+
|
|
14
23
|
def call_llm(
|
|
15
24
|
api_key: str, model: str, system_prompt: str, user_prompt: str
|
|
16
25
|
) -> str | None:
|
|
@@ -49,6 +58,16 @@ def main(
|
|
|
49
58
|
help="Run the command if suggested. Dangerous!",
|
|
50
59
|
),
|
|
51
60
|
] = False,
|
|
61
|
+
version: Annotated[
|
|
62
|
+
bool | None,
|
|
63
|
+
typer.Option(
|
|
64
|
+
"--version",
|
|
65
|
+
"-v",
|
|
66
|
+
callback=version_callback,
|
|
67
|
+
help="Show the version and exit.",
|
|
68
|
+
is_eager=True,
|
|
69
|
+
),
|
|
70
|
+
] = None,
|
|
52
71
|
):
|
|
53
72
|
"""Suggest a command for a Linux task described in QUERY.
|
|
54
73
|
|
|
@@ -77,7 +96,19 @@ def main(
|
|
|
77
96
|
Answer: echo "Please try again."
|
|
78
97
|
|
|
79
98
|
Question: Tell me a story
|
|
80
|
-
Answer: echo "Please try again
|
|
99
|
+
Answer: echo "Please try again.
|
|
100
|
+
|
|
101
|
+
It is important that you do not output commands enclosed in ``` ``` Markdown blocks. For example,
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
cd projects
|
|
105
|
+
ls
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
is not allowed. Instead, your output should be a command that is to be entered directly into the command line. For the example above: cd projects && ls
|
|
109
|
+
|
|
110
|
+
You are also allowed to use \\ for command continuation.
|
|
111
|
+
\"""" # noqa: E501
|
|
81
112
|
|
|
82
113
|
user_prompt = f"""\
|
|
83
114
|
Question: {query.strip()}
|
|
@@ -52,3 +52,10 @@ def test_app_for_suggestion_with_execute(mockenv, monkeypatch):
|
|
|
52
52
|
assert result.stdout == "ls\n" # careful, this will actually run
|
|
53
53
|
assert result.stderr == ""
|
|
54
54
|
assert result.exit_code == 0
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def test_app_for_version(mockenv):
|
|
58
|
+
result = runner.invoke(ape_linux.app, ["--version"])
|
|
59
|
+
assert result.stdout == f"{ape_linux.__version__}\n"
|
|
60
|
+
assert result.stderr == ""
|
|
61
|
+
assert result.exit_code == 0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|