From 3f9b1827c770b7629036e372bde91440f6c1e653 Mon Sep 17 00:00:00 2001 From: Russell Date: Tue, 11 Nov 2025 17:55:35 -0500 Subject: [PATCH] Use underscores instead of dashes for AI-generated filenames (#40) Updated the artifact filename generator to use snake_case (underscores) instead of kebab-case (dashes) for better consistency with Python naming conventions. Changes: - Updated AI prompt examples to show underscore format - Modified filename processing to replace spaces with underscores - Updated validation regex to accept underscores instead of dashes - Changed docstring to reflect underscore usage Examples: hello_world, prime_checker, array_sort (instead of hello-world, etc.) Co-authored-by: Claude --- app.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index aabea29..f9243de 100644 --- a/app.py +++ b/app.py @@ -335,7 +335,7 @@ def get_activities(): def generate_artifact_name(): """Generate a meaningful filename for an artifact using AI. - Returns a 1-3 word filename with dashes based on what the code does. + Returns a 1-3 word filename with underscores based on what the code does. Respects ENABLE_CODE_GEN_FILENAMES environment variable (enabled by default). """ # Check if feature is enabled (default: true) @@ -359,16 +359,16 @@ def generate_artifact_name(): Rules: - Output ONLY the filename, nothing else - Use 1-3 words maximum -- Use lowercase with dashes between words (e.g., "fizzbuzz" or "hello-world" or "prime-checker") +- Use lowercase with underscores between words (e.g., "fizzbuzz" or "hello_world" or "prime_checker") - NO file extension - NO explanations or commentary - Be specific about what the code does Examples: -- Code that prints "Hello World" → "hello-world" -- Code that checks for prime numbers → "prime-checker" +- Code that prints "Hello World" → "hello_world" +- Code that checks for prime numbers → "prime_checker" - Code that plays FizzBuzz → "fizzbuzz" -- Code that sorts an array → "array-sort" +- Code that sorts an array → "array_sort" - Code that calculates factorial → "factorial" """ @@ -389,12 +389,12 @@ Examples: # Clean up the filename (remove quotes, extensions, whitespace) filename = filename.strip('"\'') filename = filename.split('.')[0] # Remove any extension - filename = filename.replace(' ', '-') + filename = filename.replace(' ', '_') filename = filename.lower() - # Validate filename (alphanumeric and dashes only) + # Validate filename (alphanumeric and underscores only) import re - if not re.match(r'^[a-z0-9-]+$', filename): + if not re.match(r'^[a-z0-9_]+$', filename): filename = "compiled_binary" # Ensure it's not too long (max 50 chars)