feat: support role-based agent prompts

This commit is contained in:
2026-06-02 17:56:38 +01:00
parent 3ccdea330a
commit 34f7364c86
4 changed files with 225 additions and 12 deletions
+22 -2
View File
@@ -7,12 +7,21 @@ import re
TASK_HEADING_RE = re.compile(r"^##\s+(TASK-\d+)\s+[-–—]\s+(.+)$", re.MULTILINE)
STATUS_RE = re.compile(r"^Status:\s*(.+)$", re.MULTILINE)
GOAL_RE = re.compile(r"^Goal:\s*(.+)", re.MULTILINE)
AC_RE = re.compile(r"^- (.+)$", re.MULTILINE)
GAP_RE = re.compile(r"^Implementation Gap:\s*(.+)", re.MULTILINE)
def _indefinite_article(word: str) -> str:
"""Return 'a' or 'an' based on the first letter of word."""
if not word:
return "an"
first = word[0].lower()
if first in "aeiou":
return "an"
return "a"
@dataclass
class Task:
task_id: str
@@ -20,6 +29,15 @@ class Task:
status: str
body: str
def role(self, root: Path) -> tuple[str, str]:
if "Role:" not in self.body:
return ("Implementation Agent", _indefinite_article("Implementation Agent"))
parts = self.body.split("Role:", 1)
value = parts[1].splitlines()[0].strip()
if value:
return (value, _indefinite_article(value))
return ("Implementation Agent", _indefinite_article("Implementation Agent"))
def goal(self, root: Path) -> str:
match = GOAL_RE.search(self.body)
if match:
@@ -167,8 +185,10 @@ def generate_agent_prompt(root: Path) -> str:
if not task:
return "No Todo task found."
role_text, article = task.role(root)
sections = [
"You are an implementation agent.",
f"You are {article} {role_text.lower()}.",
"",
"---",
"",