fix: artifact-ai output duplication and provider update
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
6c54b35291
commit
9e0f32513f
|
|
@ -16,6 +16,8 @@ arguments:
|
||||||
required: true
|
required: true
|
||||||
description: Natural language instruction for generating or modifying the artifact
|
description: Natural language instruction for generating or modifying the artifact
|
||||||
|
|
||||||
|
output: "{result}"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Step 1: Build format-specific prompt and call AI
|
# Step 1: Build format-specific prompt and call AI
|
||||||
- type: code
|
- type: code
|
||||||
|
|
@ -120,7 +122,7 @@ steps:
|
||||||
|
|
||||||
- type: prompt
|
- type: prompt
|
||||||
prompt: "{prompt}"
|
prompt: "{prompt}"
|
||||||
provider: claude
|
provider: opencode-deepseek
|
||||||
output_var: ai_output
|
output_var: ai_output
|
||||||
|
|
||||||
# Step 2: Clean up output based on format
|
# Step 2: Clean up output based on format
|
||||||
|
|
@ -156,10 +158,23 @@ steps:
|
||||||
code = json_match.group(0)
|
code = json_match.group(0)
|
||||||
|
|
||||||
elif format == 'plantuml':
|
elif format == 'plantuml':
|
||||||
# Ensure proper tags
|
# Extract first complete @startuml...@enduml block (handles AI outputting duplicates)
|
||||||
if not code.strip().startswith('@start'):
|
puml_match = re.search(r'(@start\w+.*?@end\w+)', code, re.DOTALL)
|
||||||
code = '@startuml\n' + code
|
if puml_match:
|
||||||
if not code.strip().endswith('@enduml') and '@enduml' not in code:
|
code = puml_match.group(1)
|
||||||
code = code + '\n@enduml'
|
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()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue