Create the project prompts directory and copy base templates. This sets up a new project with template files that can be customized. Args: project_dir: The absolute path to the project directory Returns: The path to the project prompts directory
(project_dir: Path)
| 301 | |
| 302 | |
| 303 | def scaffold_project_prompts(project_dir: Path) -> Path: |
| 304 | """ |
| 305 | Create the project prompts directory and copy base templates. |
| 306 | |
| 307 | This sets up a new project with template files that can be customized. |
| 308 | |
| 309 | Args: |
| 310 | project_dir: The absolute path to the project directory |
| 311 | |
| 312 | Returns: |
| 313 | The path to the project prompts directory |
| 314 | """ |
| 315 | project_prompts = get_project_prompts_dir(project_dir) |
| 316 | project_prompts.mkdir(parents=True, exist_ok=True) |
| 317 | |
| 318 | # Create .autoforge directory with .gitignore for runtime files |
| 319 | from autoforge_paths import ensure_autoforge_dir |
| 320 | autoforge_dir = ensure_autoforge_dir(project_dir) |
| 321 | |
| 322 | # Define template mappings: (source_template, destination_name) |
| 323 | templates = [ |
| 324 | ("app_spec.template.txt", "app_spec.txt"), |
| 325 | ("coding_prompt.template.md", "coding_prompt.md"), |
| 326 | ("initializer_prompt.template.md", "initializer_prompt.md"), |
| 327 | ("testing_prompt.template.md", "testing_prompt.md"), |
| 328 | ] |
| 329 | |
| 330 | copied_files = [] |
| 331 | for template_name, dest_name in templates: |
| 332 | template_path = TEMPLATES_DIR / template_name |
| 333 | dest_path = project_prompts / dest_name |
| 334 | |
| 335 | # Only copy if template exists and destination doesn't |
| 336 | if template_path.exists() and not dest_path.exists(): |
| 337 | try: |
| 338 | shutil.copy(template_path, dest_path) |
| 339 | copied_files.append(dest_name) |
| 340 | except (OSError, PermissionError) as e: |
| 341 | print(f" Warning: Could not copy {dest_name}: {e}") |
| 342 | |
| 343 | # Copy allowed_commands.yaml template to .autoforge/ |
| 344 | examples_dir = Path(__file__).parent / "examples" |
| 345 | allowed_commands_template = examples_dir / "project_allowed_commands.yaml" |
| 346 | allowed_commands_dest = autoforge_dir / "allowed_commands.yaml" |
| 347 | if allowed_commands_template.exists() and not allowed_commands_dest.exists(): |
| 348 | try: |
| 349 | shutil.copy(allowed_commands_template, allowed_commands_dest) |
| 350 | copied_files.append(".autoforge/allowed_commands.yaml") |
| 351 | except (OSError, PermissionError) as e: |
| 352 | print(f" Warning: Could not copy allowed_commands.yaml: {e}") |
| 353 | |
| 354 | if copied_files: |
| 355 | print(f" Created project files: {', '.join(copied_files)}") |
| 356 | |
| 357 | return project_prompts |
| 358 | |
| 359 | |
| 360 | def has_project_prompts(project_dir: Path) -> bool: |
no test coverage detected