# discussion-diagram-editor - Modify PlantUML diagrams based on natural language # Usage: cat diagram.puml | discussion-diagram-editor --instruction "Add a cache" name: discussion-diagram-editor description: Modify PlantUML diagrams based on natural language instructions category: Discussion arguments: - flag: --instruction variable: instruction required: true description: Natural language instruction for how to modify the diagram steps: # Step 1: Call AI to modify the diagram - type: prompt prompt: | You are a PlantUML diagram editor. Your task is to modify the given PlantUML diagram based on the user's instruction. ## Current Diagram ```plantuml {input} ``` ## Instruction {instruction} ## Rules 1. Output ONLY the modified PlantUML code, nothing else 2. Keep the @startuml and @enduml tags 3. Preserve existing elements unless the instruction says to remove them 4. Use proper PlantUML syntax 5. If the instruction is unclear, make a reasonable interpretation 6. Keep the diagram style consistent 7. Do NOT include markdown code fences or explanations Output the complete modified PlantUML code now: provider: claude output_var: ai_output # Step 2: Clean up output - type: code output_var: result code: | import re result = ai_output.strip() # Remove markdown code blocks if present if result.startswith('```'): lines = result.split('\n') start = 1 if lines[0].startswith('```') else 0 end = len(lines) for i in range(len(lines) - 1, -1, -1): if lines[i].strip() == '```': end = i break result = '\n'.join(lines[start:end]) # Ensure it has proper tags result = result.strip() if not result.startswith('@startuml'): result = '@startuml\n' + result if not result.endswith('@enduml'): result = result + '\n@enduml' print(result)