Skip to content

Commit a5f8f35

Browse files
grokifyclaude
andcommitted
feat(render): add D2 diagram renderer with sequence, flow, and architecture styles
- Add D2Renderer with three styles: sequence, flow, arch - Sequence diagrams use D2's sequence_diagram shape with phase grouping - Flow diagrams show data flow with entity shapes (person, cylinder, hexagon) - Architecture diagrams group entities by type (Users, Clients, Servers, etc.) - Add FormatD2, FormatD2Flow, FormatD2Arch formats - Update CLI help and README documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c6fc9cf commit a5f8f35

5 files changed

Lines changed: 533 additions & 7 deletions

File tree

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ PIDL models protocols as directed interaction graphs between entities, enabling
3232
## Features
3333

3434
- 📋 **JSON-based DSL** for describing protocol flows
35-
- 🎨 **Multiple output formats**: PlantUML, Mermaid, Graphviz DOT
35+
- 🎨 **Multiple output formats**: PlantUML, Mermaid, Graphviz DOT, D2
3636
- 📚 **Built-in examples**: OAuth 2.0, PKCE, OIDC, MCP, A2A
3737
- ⌨️ **CLI tool** for validation and diagram generation
3838
- 📦 **Go library** for programmatic use
@@ -70,6 +70,15 @@ pidl generate -f mermaid oauth2_pkce
7070

7171
# Graphviz DOT data flow diagram
7272
pidl generate -f dot mcp_tool_invocation
73+
74+
# D2 sequence diagram
75+
pidl generate -f d2 oauth2_pkce
76+
77+
# D2 data flow diagram
78+
pidl generate -f d2-flow oauth2_pkce
79+
80+
# D2 architecture diagram
81+
pidl generate -f d2-arch oauth2_pkce
7382
```
7483

7584
### Create a new protocol file
@@ -171,10 +180,16 @@ Options:
171180
pidl generate [options] <file>
172181

173182
Options:
174-
-f string Output format: plantuml, mermaid, dot (default "plantuml")
183+
-f string Output format: plantuml, mermaid, dot, d2, d2-flow, d2-arch (default "plantuml")
175184
-o string Output file (default: stdout)
176185
```
177186

187+
D2 formats:
188+
189+
- `d2` - Sequence diagram
190+
- `d2-flow` - Data flow diagram with entity shapes
191+
- `d2-arch` - Architecture diagram with entities grouped by type
192+
178193
### examples
179194

180195
```bash

cmd/pidl/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Options:
113113

114114
func cmdGenerate(args []string) {
115115
fs := flag.NewFlagSet("generate", flag.ExitOnError)
116-
formatStr := fs.String("f", "plantuml", "Output format: plantuml, mermaid, dot")
116+
formatStr := fs.String("f", "plantuml", "Output format: plantuml, mermaid, dot, d2, d2-flow, d2-arch")
117117
output := fs.String("o", "", "Output file (default: stdout)")
118118
fs.Usage = func() {
119119
fmt.Print(`Usage: pidl generate [options] <file>
@@ -128,6 +128,9 @@ Formats:
128128
plantuml, puml PlantUML sequence diagram
129129
mermaid, mmd Mermaid sequence diagram
130130
dot, graphviz Graphviz DOT data flow diagram
131+
d2 D2 sequence diagram
132+
d2-flow D2 data flow diagram
133+
d2-arch D2 architecture diagram
131134
`)
132135
}
133136

0 commit comments

Comments
 (0)