Skip to content

Commit 5f15e37

Browse files
author
Atlas
committed
feat(export): transform prompts to natural user language in workspace.yaml
- Add _make_natural_prompt() to convert technical PR descriptions - Remove conventional commit prefixes (fix:, feat:, etc.) - Transform to Can you add tests for: X? format - Makes prompts feel like real user requests - Tests: 1197 pass
1 parent 961cd7b commit 5f15e37

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

src/swe_forge/export/workspace.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,36 @@ def _extract_test_file_names(test_patch: str) -> list[str]:
2121
return [Path(m).name for m in matches]
2222

2323

24+
def _make_natural_prompt(original_prompt: str, repo: str) -> str:
25+
"""Transform technical PR description into natural user prompt.
26+
27+
Args:
28+
original_prompt: Original PR title/description
29+
repo: Repository name
30+
31+
Returns:
32+
Natural prompt like a real user would write
33+
"""
34+
# Clean up the prompt
35+
prompt = original_prompt.strip()
36+
37+
# Remove common prefixes
38+
for prefix in ["fix:", "feat:", "refactor:", "chore:", "docs:", "style:", "test:"]:
39+
if prompt.lower().startswith(prefix):
40+
prompt = prompt[len(prefix):].strip()
41+
break
42+
43+
# Truncate if too long
44+
if len(prompt) > 150:
45+
prompt = prompt[:147] + "..."
46+
47+
# Create natural prompt
48+
if prompt:
49+
return f"Can you add tests for: {prompt}"
50+
else:
51+
return f"Can you add tests for the changes in {repo}?"
52+
53+
2454
def export_task_to_workspace(
2555
task: SweTask,
2656
output_folder: Path | str,
@@ -76,7 +106,7 @@ def export_task_to_workspace(
76106
},
77107
"language": task.language,
78108
"difficulty_score": task.difficulty_score,
79-
"prompt": task.prompt,
109+
"prompt": _make_natural_prompt(task.prompt, task.repo),
80110
"environment": {
81111
"image": docker_image or "ubuntu:24.04",
82112
"language_version": (

0 commit comments

Comments
 (0)