Repository navigation
Expand file tree
/
Copy pathprompts.py
More file actions
63 lines (46 loc) · 1.99 KB
/
Copy pathprompts.py
File metadata and controls
63 lines (46 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
Prompt Loading Utilities
========================
Functions for loading prompt templates from the prompts directory.
"""
import shutil
from pathlib import Path
PROMPTS_DIR = Path(__file__).parent / "prompts"
def load_prompt(name: str) -> str:
"""Load a prompt template from the prompts directory."""
prompt_path = PROMPTS_DIR / f"{name}.md"
return prompt_path.read_text()
def get_initializer_prompt() -> str:
"""Load the initializer prompt."""
return load_prompt("initializer_prompt")
def get_coding_prompt() -> str:
"""Load the coding agent prompt."""
return load_prompt("coding_prompt")
def copy_spec_to_project(project_dir: Path, spec_file: str = "app_spec.txt") -> None:
"""Copy the app spec file into the harness directory only.
The spec file is placed in .harness/ (not app/) to keep the app folder
clean and deployable. The agent reads from ../.harness/app_spec.txt.
"""
spec_source = PROMPTS_DIR / spec_file
if not spec_source.exists():
# Try adding .txt or .md extension if not found
if (PROMPTS_DIR / f"{spec_file}.txt").exists():
spec_source = PROMPTS_DIR / f"{spec_file}.txt"
elif (PROMPTS_DIR / f"{spec_file}.md").exists():
spec_source = PROMPTS_DIR / f"{spec_file}.md"
else:
print(f"Warning: Spec file {spec_file} not found in prompts directory")
return
# Create directory structure
harness_dir = project_dir / ".harness"
app_dir = project_dir / "app"
harness_dir.mkdir(parents=True, exist_ok=True)
app_dir.mkdir(parents=True, exist_ok=True)
# Create subdirectories for tests and sessions
(harness_dir / "tests").mkdir(exist_ok=True)
(harness_dir / "sessions").mkdir(exist_ok=True)
# Copy to .harness only (not app/)
harness_spec = harness_dir / "app_spec.txt"
if not harness_spec.exists():
shutil.copy(spec_source, harness_spec)
print(f"Copied {spec_source.name} to .harness/app_spec.txt")