@zyro-sec/merman 0.0.0-stage → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +29 -4
- package/script/layout-audit.ts +98 -0
- package/src/core/canvas.ts +228 -0
- package/src/core/color/style.ts +56 -0
- package/src/core/drawing.ts +301 -0
- package/src/core/geometry.ts +347 -0
- package/src/core/mermaid.ts +38 -0
- package/src/core/render-grid.ts +51 -0
- package/src/core/spatial.ts +243 -0
- package/src/core/text-lines.ts +32 -0
- package/src/core/text.ts +44 -0
- package/src/detect.ts +17 -0
- package/src/diagnostics.ts +16 -0
- package/src/flowchart/drawing.ts +340 -0
- package/src/flowchart/labels.ts +144 -0
- package/src/flowchart/layout.ts +1427 -0
- package/src/flowchart/options.ts +12 -0
- package/src/flowchart/parser.ts +467 -0
- package/src/flowchart/render.ts +10 -0
- package/src/flowchart/routing.ts +1542 -0
- package/src/flowchart/style.ts +79 -0
- package/src/flowchart/types.ts +65 -0
- package/src/gantt/diagram.ts +8 -0
- package/src/gantt/drawing.ts +191 -0
- package/src/gantt/parser.ts +161 -0
- package/src/gantt/render-grid.ts +17 -0
- package/src/gantt/style.ts +36 -0
- package/src/gantt/types.ts +44 -0
- package/src/gitgraph/diagram.ts +8 -0
- package/src/gitgraph/drawing.ts +234 -0
- package/src/gitgraph/parser.ts +219 -0
- package/src/gitgraph/render-grid.ts +17 -0
- package/src/gitgraph/style.ts +37 -0
- package/src/gitgraph/types.ts +36 -0
- package/src/markdown.ts +336 -0
- package/src/palette.ts +75 -0
- package/src/plugin.ts +15 -0
- package/src/sequence/diagram.ts +8 -0
- package/src/sequence/drawing.ts +287 -0
- package/src/sequence/options.ts +8 -0
- package/src/sequence/parser.ts +282 -0
- package/src/sequence/placement.ts +684 -0
- package/src/sequence/render-grid.ts +22 -0
- package/src/sequence/style.ts +81 -0
- package/src/sequence/types.ts +74 -0
- package/src/state/diagram.ts +8 -0
- package/src/state/drawing.ts +360 -0
- package/src/state/endpoint.ts +15 -0
- package/src/state/layout.ts +1134 -0
- package/src/state/note.ts +59 -0
- package/src/state/options.ts +11 -0
- package/src/state/parser.ts +224 -0
- package/src/state/render-grid.ts +22 -0
- package/src/state/routing.ts +1522 -0
- package/src/state/search.ts +103 -0
- package/src/state/style.ts +52 -0
- package/src/state/types.ts +63 -0
- package/src/state/visible-model.ts +77 -0
- package/src/test/diagram.ts +32 -0
- package/src/test/layout-audit/fixtures.ts +538 -0
- package/src/test/layout-audit/harness.ts +522 -0
- package/src/timeline/diagram.ts +8 -0
- package/src/timeline/drawing.ts +109 -0
- package/src/timeline/parser.ts +119 -0
- package/src/timeline/render-grid.ts +17 -0
- package/src/timeline/style.ts +36 -0
- package/src/timeline/types.ts +31 -0
- package/tsconfig.json +10 -0
- package/README.md +0 -3
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
import type { FlowchartDirection } from "../../flowchart/types.js"
|
|
2
|
+
import type { StateDiagramDirection } from "../../state/types.js"
|
|
3
|
+
|
|
4
|
+
export type LayoutFixture = {
|
|
5
|
+
id: string
|
|
6
|
+
kind: "flowchart" | "state"
|
|
7
|
+
family: string
|
|
8
|
+
profile: LabelProfile
|
|
9
|
+
source: string
|
|
10
|
+
curated?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type LabelProfile = "short" | "long" | "unicode"
|
|
14
|
+
|
|
15
|
+
const flowVariants = [
|
|
16
|
+
["TB", "short"],
|
|
17
|
+
["TD", "long"],
|
|
18
|
+
["BT", "unicode"],
|
|
19
|
+
["LR", "short"],
|
|
20
|
+
["RL", "long"],
|
|
21
|
+
["TB", "unicode"],
|
|
22
|
+
["TD", "short"],
|
|
23
|
+
["BT", "long"],
|
|
24
|
+
["LR", "unicode"],
|
|
25
|
+
["RL", "short"],
|
|
26
|
+
["LR", "long"],
|
|
27
|
+
["TD", "unicode"],
|
|
28
|
+
["TB", "long"],
|
|
29
|
+
["BT", "short"],
|
|
30
|
+
["RL", "unicode"],
|
|
31
|
+
] as const satisfies readonly (readonly [FlowchartDirection, LabelProfile])[]
|
|
32
|
+
|
|
33
|
+
const stateVariants = [
|
|
34
|
+
["TB", "short"],
|
|
35
|
+
["TD", "long"],
|
|
36
|
+
["LR", "unicode"],
|
|
37
|
+
["RL", "short"],
|
|
38
|
+
["TB", "long"],
|
|
39
|
+
["TD", "unicode"],
|
|
40
|
+
["LR", "short"],
|
|
41
|
+
["RL", "long"],
|
|
42
|
+
["LR", "long"],
|
|
43
|
+
["TD", "short"],
|
|
44
|
+
["TB", "unicode"],
|
|
45
|
+
["RL", "unicode"],
|
|
46
|
+
["BT", "short"],
|
|
47
|
+
["BT", "long"],
|
|
48
|
+
["BT", "unicode"],
|
|
49
|
+
] as const satisfies readonly (readonly [StateDiagramDirection, LabelProfile])[]
|
|
50
|
+
|
|
51
|
+
function nodeLabel(id: string, profile: LabelProfile): string {
|
|
52
|
+
if (profile === "long") return `${id} deliberate deployment stage with a long descriptive label`
|
|
53
|
+
if (profile === "unicode") return `${id} 東京<br/>résumé 🚀`
|
|
54
|
+
return `${id} node`
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function edgeLabel(id: string, profile: LabelProfile): string {
|
|
58
|
+
if (profile === "long") return `${id} transition carrying detailed deployment context`
|
|
59
|
+
if (profile === "unicode") return `${id} 東京<br/>✓ prêt`
|
|
60
|
+
return `${id} edge`
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function flowNode(id: string, profile: LabelProfile): string {
|
|
64
|
+
return ` ${id}["${nodeLabel(id, profile)}"]`
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function flowEdge(from: string, to: string, id: string, profile: LabelProfile): string {
|
|
68
|
+
return ` ${from} -->|"${edgeLabel(id, profile)}"| ${to}`
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function flowSource(
|
|
72
|
+
direction: FlowchartDirection,
|
|
73
|
+
profile: LabelProfile,
|
|
74
|
+
nodes: readonly string[],
|
|
75
|
+
edges: readonly [from: string, to: string, id: string][],
|
|
76
|
+
extra: readonly string[] = [],
|
|
77
|
+
): string {
|
|
78
|
+
return [
|
|
79
|
+
`flowchart ${direction}`,
|
|
80
|
+
...nodes.map((id) => flowNode(id, profile)),
|
|
81
|
+
...extra,
|
|
82
|
+
...edges.map(([from, to, id]) => flowEdge(from, to, id, profile)),
|
|
83
|
+
].join("\n")
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const flowFamilies = {
|
|
87
|
+
chain(direction: FlowchartDirection, profile: LabelProfile) {
|
|
88
|
+
return flowSource(
|
|
89
|
+
direction,
|
|
90
|
+
profile,
|
|
91
|
+
["A", "B", "C", "D", "E", "F"],
|
|
92
|
+
[
|
|
93
|
+
["A", "B", "E01"],
|
|
94
|
+
["B", "C", "E02"],
|
|
95
|
+
["C", "D", "E03"],
|
|
96
|
+
["D", "E", "E04"],
|
|
97
|
+
["E", "F", "E05"],
|
|
98
|
+
],
|
|
99
|
+
)
|
|
100
|
+
},
|
|
101
|
+
fork(direction: FlowchartDirection, profile: LabelProfile) {
|
|
102
|
+
return flowSource(
|
|
103
|
+
direction,
|
|
104
|
+
profile,
|
|
105
|
+
["A", "B", "C", "D", "E"],
|
|
106
|
+
[
|
|
107
|
+
["A", "B", "E01"],
|
|
108
|
+
["A", "C", "E02"],
|
|
109
|
+
["A", "D", "E03"],
|
|
110
|
+
["A", "E", "E04"],
|
|
111
|
+
],
|
|
112
|
+
)
|
|
113
|
+
},
|
|
114
|
+
join(direction: FlowchartDirection, profile: LabelProfile) {
|
|
115
|
+
return flowSource(
|
|
116
|
+
direction,
|
|
117
|
+
profile,
|
|
118
|
+
["A", "B", "C", "D", "E"],
|
|
119
|
+
[
|
|
120
|
+
["A", "E", "E01"],
|
|
121
|
+
["B", "E", "E02"],
|
|
122
|
+
["C", "E", "E03"],
|
|
123
|
+
["D", "E", "E04"],
|
|
124
|
+
],
|
|
125
|
+
)
|
|
126
|
+
},
|
|
127
|
+
cycle(direction: FlowchartDirection, profile: LabelProfile) {
|
|
128
|
+
return flowSource(
|
|
129
|
+
direction,
|
|
130
|
+
profile,
|
|
131
|
+
["A", "B", "C", "D"],
|
|
132
|
+
[
|
|
133
|
+
["A", "B", "E01"],
|
|
134
|
+
["B", "C", "E02"],
|
|
135
|
+
["C", "D", "E03"],
|
|
136
|
+
["D", "A", "E04"],
|
|
137
|
+
["C", "A", "E05"],
|
|
138
|
+
],
|
|
139
|
+
)
|
|
140
|
+
},
|
|
141
|
+
crossing(direction: FlowchartDirection, profile: LabelProfile) {
|
|
142
|
+
return flowSource(
|
|
143
|
+
direction,
|
|
144
|
+
profile,
|
|
145
|
+
["A", "B", "C", "D", "E", "F"],
|
|
146
|
+
[
|
|
147
|
+
["A", "C", "E01"],
|
|
148
|
+
["A", "D", "E02"],
|
|
149
|
+
["B", "C", "E03"],
|
|
150
|
+
["B", "D", "E04"],
|
|
151
|
+
["C", "E", "E05"],
|
|
152
|
+
["D", "F", "E06"],
|
|
153
|
+
],
|
|
154
|
+
)
|
|
155
|
+
},
|
|
156
|
+
"decision-loops"(direction: FlowchartDirection, profile: LabelProfile) {
|
|
157
|
+
return flowSource(
|
|
158
|
+
direction,
|
|
159
|
+
profile,
|
|
160
|
+
["A", "B", "C", "D", "E", "F", "G", "H", "I"],
|
|
161
|
+
[
|
|
162
|
+
["A", "B", "E01"],
|
|
163
|
+
["A", "C", "E02"],
|
|
164
|
+
["B", "D", "E03"],
|
|
165
|
+
["D", "E", "E04"],
|
|
166
|
+
["E", "B", "E05"],
|
|
167
|
+
["C", "F", "E06"],
|
|
168
|
+
["F", "G", "E07"],
|
|
169
|
+
["G", "C", "E08"],
|
|
170
|
+
["E", "H", "E09"],
|
|
171
|
+
["G", "H", "E10"],
|
|
172
|
+
["H", "A", "E11"],
|
|
173
|
+
["D", "I", "E12"],
|
|
174
|
+
["F", "I", "E13"],
|
|
175
|
+
],
|
|
176
|
+
)
|
|
177
|
+
},
|
|
178
|
+
parallel(direction: FlowchartDirection, profile: LabelProfile) {
|
|
179
|
+
return flowSource(
|
|
180
|
+
direction,
|
|
181
|
+
profile,
|
|
182
|
+
["A", "B", "C"],
|
|
183
|
+
[
|
|
184
|
+
["A", "B", "E01"],
|
|
185
|
+
["A", "B", "E02"],
|
|
186
|
+
["A", "B", "E03"],
|
|
187
|
+
["B", "C", "E04"],
|
|
188
|
+
["B", "C", "E05"],
|
|
189
|
+
],
|
|
190
|
+
)
|
|
191
|
+
},
|
|
192
|
+
self(direction: FlowchartDirection, profile: LabelProfile) {
|
|
193
|
+
return flowSource(
|
|
194
|
+
direction,
|
|
195
|
+
profile,
|
|
196
|
+
["A", "B", "C"],
|
|
197
|
+
[
|
|
198
|
+
["A", "A", "E01"],
|
|
199
|
+
["A", "B", "E02"],
|
|
200
|
+
["B", "B", "E03"],
|
|
201
|
+
["B", "C", "E04"],
|
|
202
|
+
],
|
|
203
|
+
)
|
|
204
|
+
},
|
|
205
|
+
subgraph(direction: FlowchartDirection, profile: LabelProfile) {
|
|
206
|
+
return [
|
|
207
|
+
`flowchart ${direction}`,
|
|
208
|
+
` subgraph Left["Left ${nodeLabel("SG1", profile)}"]`,
|
|
209
|
+
flowNode("A", profile),
|
|
210
|
+
flowNode("B", profile),
|
|
211
|
+
" end",
|
|
212
|
+
` subgraph Right["Right ${nodeLabel("SG2", profile)}"]`,
|
|
213
|
+
flowNode("C", profile),
|
|
214
|
+
flowNode("D", profile),
|
|
215
|
+
" end",
|
|
216
|
+
flowEdge("A", "B", "E01", profile),
|
|
217
|
+
flowEdge("A", "C", "E02", profile),
|
|
218
|
+
flowEdge("B", "D", "E03", profile),
|
|
219
|
+
flowEdge("C", "D", "E04", profile),
|
|
220
|
+
].join("\n")
|
|
221
|
+
},
|
|
222
|
+
"nested-subgraph"(direction: FlowchartDirection, profile: LabelProfile) {
|
|
223
|
+
const local = direction === "LR" || direction === "RL" ? "TB" : "LR"
|
|
224
|
+
return [
|
|
225
|
+
`flowchart ${direction}`,
|
|
226
|
+
` subgraph Outer["Outer ${nodeLabel("SG1", profile)}"]`,
|
|
227
|
+
` direction ${local}`,
|
|
228
|
+
` subgraph Inner["Inner ${nodeLabel("SG2", profile)}"]`,
|
|
229
|
+
flowNode("A", profile),
|
|
230
|
+
flowNode("B", profile),
|
|
231
|
+
" end",
|
|
232
|
+
flowNode("C", profile),
|
|
233
|
+
" end",
|
|
234
|
+
flowNode("D", profile),
|
|
235
|
+
flowEdge("A", "B", "E01", profile),
|
|
236
|
+
flowEdge("A", "C", "E02", profile),
|
|
237
|
+
flowEdge("B", "D", "E03", profile),
|
|
238
|
+
flowEdge("C", "D", "E04", profile),
|
|
239
|
+
].join("\n")
|
|
240
|
+
},
|
|
241
|
+
} satisfies Record<string, (direction: FlowchartDirection, profile: LabelProfile) => string>
|
|
242
|
+
|
|
243
|
+
function stateDeclaration(id: string, profile: LabelProfile, indent = " "): string {
|
|
244
|
+
return `${indent}state "${nodeLabel(id, profile)}" as ${id}`
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function stateTransition(from: string, to: string, id: string, profile: LabelProfile, indent = " "): string {
|
|
248
|
+
return `${indent}${from} --> ${to}: ${edgeLabel(id, profile)}`
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function stateSource(
|
|
252
|
+
direction: StateDiagramDirection,
|
|
253
|
+
profile: LabelProfile,
|
|
254
|
+
states: readonly string[],
|
|
255
|
+
transitions: readonly [from: string, to: string, id: string][],
|
|
256
|
+
extra: readonly string[] = [],
|
|
257
|
+
): string {
|
|
258
|
+
return [
|
|
259
|
+
"stateDiagram-v2",
|
|
260
|
+
` direction ${direction}`,
|
|
261
|
+
...states.map((id) => stateDeclaration(id, profile)),
|
|
262
|
+
...extra,
|
|
263
|
+
...transitions.map(([from, to, id]) => stateTransition(from, to, id, profile)),
|
|
264
|
+
].join("\n")
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const stateFamilies = {
|
|
268
|
+
chain(direction: StateDiagramDirection, profile: LabelProfile) {
|
|
269
|
+
return stateSource(
|
|
270
|
+
direction,
|
|
271
|
+
profile,
|
|
272
|
+
["A", "B", "C", "D", "E"],
|
|
273
|
+
[
|
|
274
|
+
["A", "B", "E01"],
|
|
275
|
+
["B", "C", "E02"],
|
|
276
|
+
["C", "D", "E03"],
|
|
277
|
+
["D", "E", "E04"],
|
|
278
|
+
],
|
|
279
|
+
[" [*] --> A", " E --> [*]"],
|
|
280
|
+
)
|
|
281
|
+
},
|
|
282
|
+
fork(direction: StateDiagramDirection, profile: LabelProfile) {
|
|
283
|
+
return stateSource(
|
|
284
|
+
direction,
|
|
285
|
+
profile,
|
|
286
|
+
["A", "B", "C", "D"],
|
|
287
|
+
[
|
|
288
|
+
["A", "B", "E01"],
|
|
289
|
+
["A", "C", "E02"],
|
|
290
|
+
["A", "D", "E03"],
|
|
291
|
+
],
|
|
292
|
+
)
|
|
293
|
+
},
|
|
294
|
+
join(direction: StateDiagramDirection, profile: LabelProfile) {
|
|
295
|
+
return stateSource(
|
|
296
|
+
direction,
|
|
297
|
+
profile,
|
|
298
|
+
["A", "B", "C", "D"],
|
|
299
|
+
[
|
|
300
|
+
["A", "D", "E01"],
|
|
301
|
+
["B", "D", "E02"],
|
|
302
|
+
["C", "D", "E03"],
|
|
303
|
+
],
|
|
304
|
+
)
|
|
305
|
+
},
|
|
306
|
+
cycle(direction: StateDiagramDirection, profile: LabelProfile) {
|
|
307
|
+
return stateSource(
|
|
308
|
+
direction,
|
|
309
|
+
profile,
|
|
310
|
+
["A", "B", "C", "D"],
|
|
311
|
+
[
|
|
312
|
+
["A", "B", "E01"],
|
|
313
|
+
["B", "C", "E02"],
|
|
314
|
+
["C", "D", "E03"],
|
|
315
|
+
["D", "A", "E04"],
|
|
316
|
+
["C", "A", "E05"],
|
|
317
|
+
],
|
|
318
|
+
)
|
|
319
|
+
},
|
|
320
|
+
crossing(direction: StateDiagramDirection, profile: LabelProfile) {
|
|
321
|
+
return stateSource(
|
|
322
|
+
direction,
|
|
323
|
+
profile,
|
|
324
|
+
["A", "B", "C", "D"],
|
|
325
|
+
[
|
|
326
|
+
["A", "C", "E01"],
|
|
327
|
+
["A", "D", "E02"],
|
|
328
|
+
["B", "C", "E03"],
|
|
329
|
+
["B", "D", "E04"],
|
|
330
|
+
],
|
|
331
|
+
)
|
|
332
|
+
},
|
|
333
|
+
parallel(direction: StateDiagramDirection, profile: LabelProfile) {
|
|
334
|
+
return stateSource(
|
|
335
|
+
direction,
|
|
336
|
+
profile,
|
|
337
|
+
["A", "B", "C"],
|
|
338
|
+
[
|
|
339
|
+
["A", "B", "E01"],
|
|
340
|
+
["A", "B", "E02"],
|
|
341
|
+
["A", "B", "E03"],
|
|
342
|
+
["B", "C", "E04"],
|
|
343
|
+
],
|
|
344
|
+
)
|
|
345
|
+
},
|
|
346
|
+
self(direction: StateDiagramDirection, profile: LabelProfile) {
|
|
347
|
+
return stateSource(
|
|
348
|
+
direction,
|
|
349
|
+
profile,
|
|
350
|
+
["A", "B", "C"],
|
|
351
|
+
[
|
|
352
|
+
["A", "A", "E01"],
|
|
353
|
+
["A", "B", "E02"],
|
|
354
|
+
["B", "B", "E03"],
|
|
355
|
+
["B", "C", "E04"],
|
|
356
|
+
],
|
|
357
|
+
)
|
|
358
|
+
},
|
|
359
|
+
choice(direction: StateDiagramDirection, profile: LabelProfile) {
|
|
360
|
+
return stateSource(
|
|
361
|
+
direction,
|
|
362
|
+
profile,
|
|
363
|
+
["A", "B", "C"],
|
|
364
|
+
[
|
|
365
|
+
["A", "Choice", "E01"],
|
|
366
|
+
["Choice", "B", "E02"],
|
|
367
|
+
["Choice", "C", "E03"],
|
|
368
|
+
["C", "A", "E04"],
|
|
369
|
+
],
|
|
370
|
+
[" state Choice <<choice>>"],
|
|
371
|
+
)
|
|
372
|
+
},
|
|
373
|
+
notes(direction: StateDiagramDirection, profile: LabelProfile) {
|
|
374
|
+
return stateSource(
|
|
375
|
+
direction,
|
|
376
|
+
profile,
|
|
377
|
+
["A", "B", "C"],
|
|
378
|
+
[
|
|
379
|
+
["A", "B", "E01"],
|
|
380
|
+
["B", "C", "E02"],
|
|
381
|
+
["C", "A", "E03"],
|
|
382
|
+
],
|
|
383
|
+
[
|
|
384
|
+
` note left of A: ${edgeLabel("N01", profile)}`,
|
|
385
|
+
` note right of B: ${edgeLabel("N02", profile)}`,
|
|
386
|
+
` note right of C: ${edgeLabel("N03", profile)}`,
|
|
387
|
+
],
|
|
388
|
+
)
|
|
389
|
+
},
|
|
390
|
+
composite(direction: StateDiagramDirection, profile: LabelProfile) {
|
|
391
|
+
return [
|
|
392
|
+
"stateDiagram-v2",
|
|
393
|
+
` direction ${direction}`,
|
|
394
|
+
` state "${nodeLabel("Outer", profile)}" as Outer {`,
|
|
395
|
+
stateDeclaration("A", profile, " "),
|
|
396
|
+
stateDeclaration("B", profile, " "),
|
|
397
|
+
" [*] --> A",
|
|
398
|
+
stateTransition("A", "B", "E01", profile, " "),
|
|
399
|
+
" B --> [*]",
|
|
400
|
+
" }",
|
|
401
|
+
stateDeclaration("Done", profile),
|
|
402
|
+
stateTransition("Outer", "Done", "E02", profile),
|
|
403
|
+
` note right of B: ${edgeLabel("N01", profile)}`,
|
|
404
|
+
].join("\n")
|
|
405
|
+
},
|
|
406
|
+
"nested-composite"(direction: StateDiagramDirection, profile: LabelProfile) {
|
|
407
|
+
return [
|
|
408
|
+
"stateDiagram-v2",
|
|
409
|
+
` direction ${direction}`,
|
|
410
|
+
` state "${nodeLabel("Session", profile)}" as Session {`,
|
|
411
|
+
" [*] --> Open",
|
|
412
|
+
` state "${nodeLabel("Open", profile)}" as Open {`,
|
|
413
|
+
stateDeclaration("Clean", profile, " "),
|
|
414
|
+
stateDeclaration("Dirty", profile, " "),
|
|
415
|
+
" [*] --> Clean",
|
|
416
|
+
stateTransition("Clean", "Dirty", "E01", profile, " "),
|
|
417
|
+
stateTransition("Dirty", "Clean", "E02", profile, " "),
|
|
418
|
+
" Dirty --> [*]",
|
|
419
|
+
" }",
|
|
420
|
+
" Open --> [*]",
|
|
421
|
+
" }",
|
|
422
|
+
stateDeclaration("Done", profile),
|
|
423
|
+
stateTransition("Session", "Done", "E03", profile),
|
|
424
|
+
` note right of Dirty: ${edgeLabel("N01", profile)}`,
|
|
425
|
+
].join("\n")
|
|
426
|
+
},
|
|
427
|
+
} satisfies Record<string, (direction: StateDiagramDirection, profile: LabelProfile) => string>
|
|
428
|
+
|
|
429
|
+
export const deploymentArchitectureSource = `flowchart LR
|
|
430
|
+
Client[OpenCode client]
|
|
431
|
+
|
|
432
|
+
subgraph CF[Cloudflare]
|
|
433
|
+
DNS[opencode.ai]
|
|
434
|
+
Web[Console frontend Worker]
|
|
435
|
+
Proxy[Console API proxy Worker]
|
|
436
|
+
Infer[inference-next Worker]
|
|
437
|
+
KV[Model registry KV]
|
|
438
|
+
Redis[Upstash Redis]
|
|
439
|
+
Logs[Axiom / Cloudflare logs]
|
|
440
|
+
Lake[Pipeline to R2 data lake]
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
subgraph AWS[AWS]
|
|
444
|
+
EKS[EKS cluster]
|
|
445
|
+
API[Console API pod<br/>1 replica]
|
|
446
|
+
OTEL[OTel collector]
|
|
447
|
+
ECR[ECR]
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
DB[(PlanetScale)]
|
|
451
|
+
Models[Anthropic / OpenAI / other providers]
|
|
452
|
+
|
|
453
|
+
Client -->|/inference/*| DNS --> Infer
|
|
454
|
+
Client -->|/console/*| DNS --> Web
|
|
455
|
+
Web -->|/console/api, /auth, etc.| Proxy
|
|
456
|
+
Proxy -->|Cloudflare VPC service| API
|
|
457
|
+
|
|
458
|
+
Infer -->|public DATABASE_URL| DB
|
|
459
|
+
Infer --> KV
|
|
460
|
+
Infer --> Redis
|
|
461
|
+
Infer --> Models
|
|
462
|
+
Infer --> Logs
|
|
463
|
+
Infer --> Lake
|
|
464
|
+
|
|
465
|
+
API -->|private DATABASE_AWS_URL| DB
|
|
466
|
+
API --> OTEL
|
|
467
|
+
ECR --> API`
|
|
468
|
+
|
|
469
|
+
export function layoutFixtures(): readonly LayoutFixture[] {
|
|
470
|
+
const flowcharts = Object.entries(flowFamilies).flatMap(([family, source]) =>
|
|
471
|
+
flowVariants.map(([direction, profile]) => ({
|
|
472
|
+
id: `flowchart/${family}/${direction.toLowerCase()}-${profile}`,
|
|
473
|
+
kind: "flowchart" as const,
|
|
474
|
+
family,
|
|
475
|
+
profile,
|
|
476
|
+
source: source(direction, profile),
|
|
477
|
+
})),
|
|
478
|
+
)
|
|
479
|
+
const states = Object.entries(stateFamilies).flatMap(([family, source]) =>
|
|
480
|
+
stateVariants.map(([direction, profile]) => ({
|
|
481
|
+
id: `state/${family}/${direction.toLowerCase()}-${profile}`,
|
|
482
|
+
kind: "state" as const,
|
|
483
|
+
family,
|
|
484
|
+
profile,
|
|
485
|
+
source: source(direction, profile),
|
|
486
|
+
})),
|
|
487
|
+
)
|
|
488
|
+
return [
|
|
489
|
+
...flowcharts,
|
|
490
|
+
{
|
|
491
|
+
id: "flowchart/deployment-architecture/curated",
|
|
492
|
+
kind: "flowchart" as const,
|
|
493
|
+
family: "deployment-architecture",
|
|
494
|
+
profile: "short" as const,
|
|
495
|
+
source: deploymentArchitectureSource,
|
|
496
|
+
curated: true,
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
id: "flowchart/grouped-fanout/curated",
|
|
500
|
+
kind: "flowchart" as const,
|
|
501
|
+
family: "grouped-fanout",
|
|
502
|
+
profile: "short" as const,
|
|
503
|
+
source: `flowchart TD
|
|
504
|
+
subgraph Group
|
|
505
|
+
S[Source]
|
|
506
|
+
S -->|route 0 detail| N0[Node 0]
|
|
507
|
+
S -->|route 1 detail| N1[Node 1]
|
|
508
|
+
S -->|route 2 detail| N2[Node 2]
|
|
509
|
+
S -->|route 3 detail| N3[Node 3]
|
|
510
|
+
end`,
|
|
511
|
+
curated: true,
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
id: "flowchart/subgraph-pipeline/curated",
|
|
515
|
+
kind: "flowchart" as const,
|
|
516
|
+
family: "subgraph-pipeline",
|
|
517
|
+
profile: "short" as const,
|
|
518
|
+
source: `flowchart TD
|
|
519
|
+
subgraph S1["1. provider.transform (seed)"]
|
|
520
|
+
A1["Catalog model → copy catalog variants"]
|
|
521
|
+
A2["Custom model → apply package/modelID/limit + seed default variants"]
|
|
522
|
+
end
|
|
523
|
+
subgraph S2["2. plugin model.transform"]
|
|
524
|
+
B["Plugin can replace variants, clear to [], or ignore"]
|
|
525
|
+
end
|
|
526
|
+
subgraph S3["3. config model.transform (post)"]
|
|
527
|
+
C1{"Config sets reasoning or variants?"}
|
|
528
|
+
C1 -- yes --> C2["Apply explicit config"]
|
|
529
|
+
C1 -- no --> C3{"Config changed package (or recreated removed model)?"}
|
|
530
|
+
C3 -- yes --> C4["Respell / reseed variants"]
|
|
531
|
+
C3 -- no --> C5["Keep current variants"]
|
|
532
|
+
end
|
|
533
|
+
S1 --> S2 --> S3`,
|
|
534
|
+
curated: true,
|
|
535
|
+
},
|
|
536
|
+
...states,
|
|
537
|
+
]
|
|
538
|
+
}
|