From d09a0088ef8ef8d435ffe7ead07132396badade9 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 7 Dec 2025 04:58:37 -0400 Subject: [PATCH] fix: Show available variables in triple-quote format in AI prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The AI follows the pattern better when the available variables are shown in the exact format they should be used: """{input}""", """{response}""", etc. This helps the AI generate code that properly uses triple quotes for variable substitution. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/smarttools/ui_urwid.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/smarttools/ui_urwid.py b/src/smarttools/ui_urwid.py index 0408fd9..b289cc1 100644 --- a/src/smarttools/ui_urwid.py +++ b/src/smarttools/ui_urwid.py @@ -1829,12 +1829,13 @@ class SmartToolsUI: ai_provider_select_btn = Button3DCompact("▼", on_press=show_ai_provider_dropdown) # Default prompt template for AI code generation/adjustment + # Show variables in triple-quote format so the AI follows the pattern + vars_formatted = ', '.join(f'\"\"\"{{{v}}}\"\"\"' for v in vars_available) default_ai_prompt = f"""Write inline Python code (NOT a function definition) according to my instruction. -The code runs directly with variable substitution. To use an available variable: -- Wrap the variable name in curly braces: {{variable}} -- Use triple quotes since the substituted content may contain quotes/newlines -- Example: my_var = \"\"\"{{response}}\"\"\" +The code runs directly with variable substitution. Any available variable used must be wrapped in triple quotes and curly braces like this: \"\"\"{{variable}}\"\"\". The triple quotes are needed since the substituted content may contain quotes/newlines. + +Example: my_var = \"\"\"{{response}}\"\"\" INSTRUCTION: [Describe what you want] @@ -1843,7 +1844,7 @@ CURRENT CODE: {{code}} ``` -AVAILABLE VARIABLES: {', '.join(vars_available)} +AVAILABLE VARIABLES: {vars_formatted} IMPORTANT: Return ONLY executable inline code. Do NOT wrap in a function. No explanations, no markdown fencing, just the code."""