Neva to Mermaid
Use this skill to convert any Neva source code into a Mermaid flowchart.
Instructions
Read the Neva code to be converted.
Generate a Mermaid flowchart TB diagram using the following rules:
Layout: Always include this header at the top:
---
config:
layout: elk
---
flowchart TB
Ports:
- Use stadium shapes for external ports
:in / :out:
([":data"]), ([":res"]), ([":err"]), etc.
- In edges, label with the port name (
data, res, err, sig, case[0], etc).
Components:
- Use unique Mermaid node IDs.
- Render component nodes as regular boxes using only their declared
instance name:
id["name"].
- Do not annotate component nodes with type names, generic parameters, or
usage information.
Literals:
- Render numeric and string literals as rectangles using Mermaid shape syntax:
zero@{ label: "0", shape: rect }
dot@{ label: "'.'", shape: rect }
Connections:
- Use
-- <port> --> labels for the wire’s port name.
- For
a:out -> b:in, label the edge with the output port name (out), unless Neva explicitly uses the input port name in the wiring (e.g., b:sig).
- Only label an edge with a port name when the Neva source explicitly names a port on that connection.
- Examples that MUST be labeled:
x:res -> y → label edge as res
x -> y:sig → label edge as sig
x:case[0] -> y → label edge as case[0]
If a port name is omitted in Neva, do not infer or guess it. Render an unlabeled edge:
Fan-out / Fan-in (IMPORTANT):
- Mermaid edges do not create real “ports as objects”, so list-wiring must be represented explicitly with virtual junction nodes.
- A junction node is a small circle:
jX(( )) where jX is a unique ID.
Fan-out: src -> [a, b, :out]
- Insert a junction node
jX(( )).
- Wire:
src -- <port> --> jX
- Then wire:
jX --> a, jX --> b, jX --> out_port
Fan-in: [a, b] -> dst:port
- Insert a junction node
jX(( )).
- Wire:
a --> jX and b --> jX
- Then wire:
jX -- <port> --> dst
Grouping (&):
- You MAY use
& to reduce clutter only when it does not hide fan-in/fan-out topology.
- If Neva uses list-wiring (
[...]), prefer junction nodes over &.
Do not look up other files in the repo or call web search; this text
describes the conversion rules.
Ensure the output is ready to be pasted into the Mermaid playground.
Reference Example
Neva
pub def Tap<T>(data T) (res T, err error) {
pass1 Pass<T>
pass2 Pass<T>
lock Lock<T>
handler ITapHandler<T>
---
:data -> [lock:data, handler]
handler:res -> pass1
handler:err -> [pass2, :err]
[pass1, pass2] -> lock:sig
lock -> :res
}
1---2name: neva-to-mermaid3description: Convert Neva programs to valid Mermaid flowchart diagrams. Use when asked to visualize Neva code as Mermaid.4---56# Neva to Mermaid78Use this skill to convert any Neva source code into a Mermaid flowchart.910## Instructions11121. Read the Neva code to be converted.132. Generate a Mermaid `flowchart TB` diagram using the following rules:1415 - **Layout**: Always include this header at the top:16 ```mermaid17 ---18 config:19 layout: elk20 ---21 flowchart TB22 ```2324 - **Ports**:25 - Use **stadium** shapes for external ports `:in` / `:out`:26 - `([":data"])`, `([":res"])`, `([":err"])`, etc.27 - In edges, label with the **port name** (`data`, `res`, `err`, `sig`, `case[0]`, etc).2829 - **Components**:30 - Use unique Mermaid node IDs.31 - Render component nodes as regular boxes using only their declared32 instance name: `id["name"]`.33 - Do not annotate component nodes with type names, generic parameters, or34 usage information.3536 - **Literals**:37 - Render numeric and string literals as rectangles using Mermaid shape syntax:38 - `zero@{ label: "0", shape: rect }`39 - `dot@{ label: "'.'", shape: rect }`4041 - **Connections**:42 - Use `-- <port> -->` labels for the wire’s port name.43 - For `a:out -> b:in`, label the edge with the **output port name** (`out`), unless Neva explicitly uses the input port name in the wiring (e.g., `b:sig`).44 - Only label an edge with a port name when the Neva source explicitly names a port on that connection.45 - Examples that MUST be labeled:46 - `x:res -> y` → label edge as `res`47 - `x -> y:sig` → label edge as `sig`48 - `x:case[0] -> y` → label edge as `case[0]`49 - If a port name is **omitted** in Neva, do **not** infer or guess it. Render an unlabeled edge:50 - `x -> y` → `x --> y`5152 - **Fan-out / Fan-in (IMPORTANT)**:53 - Mermaid edges do not create real “ports as objects”, so list-wiring must be represented explicitly with **virtual junction nodes**.54 - A junction node is a small circle: `jX(( ))` where `jX` is a unique ID.5556 **Fan-out**: `src -> [a, b, :out]`57 - Insert a junction node `jX(( ))`.58 - Wire: `src -- <port> --> jX`59 - Then wire: `jX --> a`, `jX --> b`, `jX --> out_port`6061 **Fan-in**: `[a, b] -> dst:port`62 - Insert a junction node `jX(( ))`.63 - Wire: `a --> jX` and `b --> jX`64 - Then wire: `jX -- <port> --> dst`6566 - **Grouping (`&`)**:67 - You MAY use `&` to reduce clutter only when it does **not** hide fan-in/fan-out topology.68 - If Neva uses list-wiring (`[...]`), prefer junction nodes over `&`.69703. Do not look up other files in the repo or call web search; this text71 describes the conversion rules.724. Ensure the output is ready to be pasted into the Mermaid playground.7374## Reference Example7576### Neva7778```neva79pub def Tap<T>(data T) (res T, err error) {80 pass1 Pass<T>81 pass2 Pass<T>82 lock Lock<T>83 handler ITapHandler<T>84 ---85 :data -> [lock:data, handler]86 handler:res -> pass187 handler:err -> [pass2, :err]88 [pass1, pass2] -> lock:sig89 lock -> :res90}