aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2026-10-11 14:57:58 +0300
committerJoel Kronqvist <joel.kronqvist@iki.fi>2026-10-11 14:57:58 +0300
commit085133e1b87d56edc9f0542ea830ca0a385204c0 (patch)
tree5223efd6317729df45eb0a0400cb9ae373d05114
parent0e3d7053c4d1a774d43e241ff04571d57b9a6673 (diff)
downloadagent-085133e1b87d56edc9f0542ea830ca0a385204c0.tar.gz
agent-085133e1b87d56edc9f0542ea830ca0a385204c0.zip
feat: mypy action
-rw-r--r--actions.py15
-rwxr-xr-xllm.py5
2 files changed, 18 insertions, 2 deletions
diff --git a/actions.py b/actions.py
index dfeebc3..589dd51 100644
--- a/actions.py
+++ b/actions.py
@@ -106,6 +106,20 @@ def _shell(args: JSON, config: AgentConfig) -> JSON:
}
+def _mypy(args: JSON, config: AgentConfig) -> JSON:
+ '{"action": "mypy", "path": PATH} - run mypy type checking on PATH'
+ try:
+ res = subprocess.run(
+ ["mypy", args["path"]],
+ cwd=config.workdir,
+ capture_output=True,
+ text=True,
+ )
+ return {"status": "success", "stdout": res.stdout, "stderr": res.stderr}
+ except Exception as e:
+ return {"status": "error", "reason": f"An unexpected error occurred: {e}"}
+
+
ls = Action("ls", _ls.__doc__ or "", _ls)
read = Action("read", _read.__doc__ or "", _read)
write = Action(
@@ -121,3 +135,4 @@ shell = Action(
_shell,
formatter=lambda args: f"shell command `{args['command']}`",
)
+mypy = Action("mypy", _mypy.__doc__ or "", _mypy)
diff --git a/llm.py b/llm.py
index 649f927..bea4536 100755
--- a/llm.py
+++ b/llm.py
@@ -144,15 +144,16 @@ def main():
config = AgentConfig(
workdir=args.workdir,
- actions=[ls, read, write, tldr, shell],
+ actions=[ls, read, write, tldr, shell, mypy],
trustlevels={
"ls": 0,
"read": 0,
"tldr": 0,
+ "mypy": 0,
"write": 1,
"shell": 2,
},
- trustlevel=0,
+ trustlevel=1,
)
state = (