Coverage for src/pullapprove/agent/__init__.py: 0%
27 statements
« prev ^ index » next coverage.py v7.8.2, created at 2025-08-05 11:07 -0500
« prev ^ index » next coverage.py v7.8.2, created at 2025-08-05 11:07 -0500
1import shlex
2import subprocess
3from enum import Enum
4from functools import cached_property
6from .shared import load_prompt
9class AgentType(Enum):
10 EDIT = "edit"
11 NEW = "new"
12 FIX = "fix"
13 MIGRATE_V3 = "migrate_v3"
14 MIGRATE_CODEOWNERS = "migrate_codeowners"
17class Agent:
18 def __init__(self, agent_type: AgentType):
19 self.agent_type = agent_type
21 @cached_property
22 def prompt(self):
23 prompt = load_prompt("base")
25 prompt += "\n\n" + load_prompt(self.agent_type.value)
27 return prompt
29 def run_command(self, command: str):
30 prompt = self.prompt
31 prompt += "\n\n" + load_prompt("cli")
33 command_args = shlex.split(command)
34 command_args.append(prompt)
36 result = subprocess.run(command_args)
38 return result.returncode == 0
41__all__ = ["Agent", "AgentType", "load_prompt"]