pygent 0.1.7__tar.gz → 0.1.8__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 (26) hide show
  1. {pygent-0.1.7 → pygent-0.1.8}/PKG-INFO +1 -1
  2. {pygent-0.1.7 → pygent-0.1.8}/README.md +3 -3
  3. {pygent-0.1.7 → pygent-0.1.8}/pygent/runtime.py +8 -3
  4. {pygent-0.1.7 → pygent-0.1.8}/pygent.egg-info/PKG-INFO +1 -1
  5. {pygent-0.1.7 → pygent-0.1.8}/pygent.egg-info/SOURCES.txt +1 -0
  6. {pygent-0.1.7 → pygent-0.1.8}/pyproject.toml +1 -1
  7. pygent-0.1.8/tests/test_runtime.py +25 -0
  8. {pygent-0.1.7 → pygent-0.1.8}/LICENSE +0 -0
  9. {pygent-0.1.7 → pygent-0.1.8}/pygent/__init__.py +0 -0
  10. {pygent-0.1.7 → pygent-0.1.8}/pygent/__main__.py +0 -0
  11. {pygent-0.1.7 → pygent-0.1.8}/pygent/agent.py +0 -0
  12. {pygent-0.1.7 → pygent-0.1.8}/pygent/cli.py +0 -0
  13. {pygent-0.1.7 → pygent-0.1.8}/pygent/models.py +0 -0
  14. {pygent-0.1.7 → pygent-0.1.8}/pygent/openai_compat.py +0 -0
  15. {pygent-0.1.7 → pygent-0.1.8}/pygent/py.typed +0 -0
  16. {pygent-0.1.7 → pygent-0.1.8}/pygent/tools.py +0 -0
  17. {pygent-0.1.7 → pygent-0.1.8}/pygent/ui.py +0 -0
  18. {pygent-0.1.7 → pygent-0.1.8}/pygent.egg-info/dependency_links.txt +0 -0
  19. {pygent-0.1.7 → pygent-0.1.8}/pygent.egg-info/entry_points.txt +0 -0
  20. {pygent-0.1.7 → pygent-0.1.8}/pygent.egg-info/requires.txt +0 -0
  21. {pygent-0.1.7 → pygent-0.1.8}/pygent.egg-info/top_level.txt +0 -0
  22. {pygent-0.1.7 → pygent-0.1.8}/setup.cfg +0 -0
  23. {pygent-0.1.7 → pygent-0.1.8}/tests/test_autorun.py +0 -0
  24. {pygent-0.1.7 → pygent-0.1.8}/tests/test_custom_model.py +0 -0
  25. {pygent-0.1.7 → pygent-0.1.8}/tests/test_tools.py +0 -0
  26. {pygent-0.1.7 → pygent-0.1.8}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygent
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Summary: Pygent is a minimalist coding assistant that runs commands in a Docker container when available and falls back to local execution. See https://marianochaves.github.io/pygent for documentation and https://github.com/marianochaves/pygent for the source code.
5
5
  Author-email: Mariano Chaves <mchaves.software@gmail.com>
6
6
  Project-URL: Documentation, https://marianochaves.github.io/pygent
@@ -1,6 +1,6 @@
1
1
  # Pygent
2
2
 
3
- Pygent is a coding assistant that executes each request inside an isolated Docker container whenever possible. If Docker is unavailable (for instance on some Windows setups) the commands are executed locally instead.
3
+ Pygent is a coding assistant that executes each request inside an isolated Docker container whenever possible. If Docker is unavailable (for instance on some Windows setups) the commands are executed locally instead. Full documentation is available in the `docs/` directory and at [marianochaves.github.io/pygent](https://marianochaves.github.io/pygent/).
4
4
 
5
5
  ## Features
6
6
 
@@ -23,7 +23,7 @@ To run commands in Docker containers also install `pygent[docker]`.
23
23
 
24
24
  ## Configuration
25
25
 
26
- Behaviour can be adjusted via environment variables:
26
+ Behaviour can be adjusted via environment variables (see `docs/configuration.md` for a complete list):
27
27
 
28
28
  * `OPENAI_API_KEY` &ndash; key used to access the OpenAI API.
29
29
  Set this to your API key or a key from any compatible provider.
@@ -63,7 +63,7 @@ ag.step("echo 'Hello World'")
63
63
  ag.runtime.cleanup()
64
64
  ```
65
65
 
66
- See the `examples/` folder for more complete scripts. Models can be swapped by
66
+ See the [examples](https://github.com/marianochaves/pygent/tree/main/examples) folder for more complete scripts. Models can be swapped by
67
67
  passing an object implementing the ``Model`` interface when creating the
68
68
  ``Agent``. The default uses an OpenAI-compatible API, but custom models are
69
69
  easy to plug in.
@@ -48,7 +48,11 @@ class Runtime:
48
48
 
49
49
  # ---------------- public API ----------------
50
50
  def bash(self, cmd: str, timeout: int = 30) -> str:
51
- """Run a command in the container or locally and return the output."""
51
+ """Run a command in the container or locally and return the output.
52
+
53
+ The executed command is always included in the returned string so the
54
+ caller can display what was run.
55
+ """
52
56
  if self._use_docker and self.container is not None:
53
57
  res = self.container.exec_run(
54
58
  cmd,
@@ -60,7 +64,8 @@ class Runtime:
60
64
  stdout, stderr = (
61
65
  res.output if isinstance(res.output, tuple) else (res.output, b"")
62
66
  )
63
- return (stdout or b"").decode() + (stderr or b"").decode()
67
+ output = (stdout or b"").decode() + (stderr or b"").decode()
68
+ return f"$ {cmd}\n{output}"
64
69
  proc = subprocess.run(
65
70
  cmd,
66
71
  shell=True,
@@ -69,7 +74,7 @@ class Runtime:
69
74
  text=True,
70
75
  timeout=timeout,
71
76
  )
72
- return proc.stdout + proc.stderr
77
+ return f"$ {cmd}\n{proc.stdout + proc.stderr}"
73
78
 
74
79
  def write_file(self, path: Union[str, Path], content: str) -> str:
75
80
  p = self.base_dir / path
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygent
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Summary: Pygent is a minimalist coding assistant that runs commands in a Docker container when available and falls back to local execution. See https://marianochaves.github.io/pygent for documentation and https://github.com/marianochaves/pygent for the source code.
5
5
  Author-email: Mariano Chaves <mchaves.software@gmail.com>
6
6
  Project-URL: Documentation, https://marianochaves.github.io/pygent
@@ -19,5 +19,6 @@ pygent.egg-info/requires.txt
19
19
  pygent.egg-info/top_level.txt
20
20
  tests/test_autorun.py
21
21
  tests/test_custom_model.py
22
+ tests/test_runtime.py
22
23
  tests/test_tools.py
23
24
  tests/test_version.py
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pygent"
3
- version = "0.1.7"
3
+ version = "0.1.8"
4
4
  description = "Pygent is a minimalist coding assistant that runs commands in a Docker container when available and falls back to local execution. See https://marianochaves.github.io/pygent for documentation and https://github.com/marianochaves/pygent for the source code."
5
5
  authors = [ { name = "Mariano Chaves", email = "mchaves.software@gmail.com" } ]
6
6
  requires-python = ">=3.9"
@@ -0,0 +1,25 @@
1
+ import os
2
+ import sys
3
+ import types
4
+
5
+ sys.modules.setdefault('openai', types.ModuleType('openai'))
6
+ sys.modules.setdefault('docker', types.ModuleType('docker'))
7
+ rich_mod = types.ModuleType('rich')
8
+ console_mod = types.ModuleType('console')
9
+ console_mod.Console = lambda *a, **k: None
10
+ panel_mod = types.ModuleType('panel')
11
+ panel_mod.Panel = lambda *a, **k: None
12
+ sys.modules.setdefault('rich', rich_mod)
13
+ sys.modules.setdefault('rich.console', console_mod)
14
+ sys.modules.setdefault('rich.panel', panel_mod)
15
+
16
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
17
+
18
+ from pygent.runtime import Runtime
19
+
20
+
21
+ def test_bash_includes_command():
22
+ rt = Runtime(use_docker=False)
23
+ out = rt.bash('echo hi')
24
+ rt.cleanup()
25
+ assert out.startswith('$ echo hi\n')
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