From 9e0f32513f742323deb79486aed61f13fd484f04 Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 30 Dec 2025 22:11:42 -0400 Subject: [PATCH] fix: artifact-ai output duplication and provider update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add explicit output template {result} to prevent input being appended - Switch provider from claude to opencode-deepseek for better PlantUML generation - Fix plantuml cleanup to extract only first diagram when AI outputs duplicates - Add mermaid cleanup to handle duplicate diagrams - Set result variable instead of using print() for proper output capture 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- smarttools/artifact-ai/config.yaml | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/smarttools/artifact-ai/config.yaml b/smarttools/artifact-ai/config.yaml index 4f51825..6e63573 100644 --- a/smarttools/artifact-ai/config.yaml +++ b/smarttools/artifact-ai/config.yaml @@ -16,6 +16,8 @@ arguments: required: true description: Natural language instruction for generating or modifying the artifact +output: "{result}" + steps: # Step 1: Build format-specific prompt and call AI - type: code @@ -120,7 +122,7 @@ steps: - type: prompt prompt: "{prompt}" - provider: claude + provider: opencode-deepseek output_var: ai_output # Step 2: Clean up output based on format @@ -156,10 +158,23 @@ steps: code = json_match.group(0) elif format == 'plantuml': - # Ensure proper tags - if not code.strip().startswith('@start'): - code = '@startuml\n' + code - if not code.strip().endswith('@enduml') and '@enduml' not in code: - code = code + '\n@enduml' + # Extract first complete @startuml...@enduml block (handles AI outputting duplicates) + puml_match = re.search(r'(@start\w+.*?@end\w+)', code, re.DOTALL) + if puml_match: + code = puml_match.group(1) + else: + # No complete block found - ensure proper tags + if not code.strip().startswith('@start'): + code = '@startuml\n' + code + if not code.strip().endswith('@enduml') and '@enduml' not in code: + code = code + '\n@enduml' - print(code.strip()) + elif format == 'mermaid': + # Extract first complete mermaid diagram (handles duplicates) + # Mermaid starts with diagram type declaration + mermaid_types = r'(graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|journey)' + mermaid_match = re.search(rf'({mermaid_types}[\s\S]*?)(?={mermaid_types}|\Z)', code) + if mermaid_match: + code = mermaid_match.group(1).strip() + + result = code.strip()