@gemboss/ui 0.57.0 → 0.58.0

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.
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Where each box of a skill's flow stands (dagre), for the canvas (`./canvas.tsx`). Lifted from content-radar's lib/skill-flow.js
3
+ * `layoutFlow` (03/11/2026) with the lanes as a parameter. It imports @dagrejs/dagre, an OPTIONAL peer of the kit: only the
4
+ * `@gemboss/ui/skill-flow` entry reaches this file, never the kit's index, so a surface that does not draw a flow never loads it.
5
+ *
6
+ * Box sizes are estimated from the words (the canvas has fixed widths and boxes grow in height): skill-flow.css keeps the same
7
+ * numbers (padding, type size, the tool pills). Change one, change the other.
8
+ */
9
+ import { graphlib, layout as dagreRun } from "@dagrejs/dagre";
10
+ import { FLOW_DIRECTIONS, shortTool, validateFlow, type Flow, type FlowDirection, type FlowEdgeKind, type FlowNode, type FlowPhase } from "./model";
11
+
12
+ const NODE_W: Record<string, number> = { start: 184, end: 184, step: 212, stop: 212, decision: 212, exit: 188 };
13
+ const LANE = { head: 34, pad: 14, gap: 44, min: 240, side: 40 };
14
+
15
+ export function nodeSize(n: Pick<FlowNode, "kind" | "label" | "tools" | "human">): { width: number; height: number } {
16
+ const width = NODE_W[n.kind] || 212;
17
+ const inner = width - (n.kind === "decision" ? 44 : 26);
18
+ const eyebrow = n.kind === "step" && !n.human ? 0 : 16;
19
+ const lines = Math.min(2, Math.max(1, Math.ceil(n.label.length / Math.floor(inner / 7.6))));
20
+ let rows = 0;
21
+ let used = Infinity;
22
+ for (const t of n.tools || []) {
23
+ const w = Math.ceil(shortTool(t).length * 6.7) + 14;
24
+ if (used + 4 + w > inner) { rows += 1; used = w; } else used += 4 + w;
25
+ }
26
+ const height = 18 + eyebrow + lines * 18 + (rows ? 6 + rows * 18 + (rows - 1) * 4 : 0);
27
+ return { width, height: Math.max(height, 44) };
28
+ }
29
+
30
+ type Sized = FlowNode & { size: { width: number; height: number } };
31
+ type Pos = { x: number; y: number };
32
+
33
+ // One dagre pass. Measured on content-radar's playbooks (24/10/2026): dagre's default alignment pushed the main line one column
34
+ // over after every branch that leaves the skill, a staircase. So: an exit node does NOT go into dagre, it stands right of its
35
+ // decision ("No →", as on paper); "UR" keeps the main line in one column, then everything is flipped so side branches leave to the
36
+ // RIGHT: a box's left edge is kept for the line coming in from the lane before.
37
+ function dagreLayout(nodes: Sized[], edges: Flow["edges"], rankdir: FlowDirection) {
38
+ const tb = rankdir === "TB";
39
+ const ids = new Set(nodes.map((n) => n.id));
40
+ const byId = new Map(nodes.map((n) => [n.id, n]));
41
+ const side = new Map<string, string>();
42
+ for (const n of nodes) {
43
+ if (n.kind !== "exit") continue;
44
+ const into = edges.find((e) => e.to === n.id && ids.has(e.from) && byId.get(e.from)!.kind !== "exit");
45
+ if (into) side.set(n.id, into.from);
46
+ }
47
+ const g = new graphlib.Graph();
48
+ g.setGraph({ rankdir, align: "UR", nodesep: 22, ranksep: 40, edgesep: 12, marginx: 0, marginy: 0 });
49
+ g.setDefaultEdgeLabel(() => ({}));
50
+ for (const n of nodes) if (!side.has(n.id)) g.setNode(n.id, { ...n.size });
51
+ // A loop edge (back to fix) does not rank: it goes backwards.
52
+ for (const e of edges) {
53
+ if (e.kind === "loop" || !g.hasNode(e.from) || !g.hasNode(e.to)) continue;
54
+ g.setEdge(e.from, e.to, { minlen: 1, weight: e.kind === "no" ? 1 : 3 });
55
+ }
56
+ dagreRun(g as never);
57
+ const gr = g.graph() as { width?: number; height?: number };
58
+ let width = gr.width || 0;
59
+ let height = gr.height || 0;
60
+ const pos = new Map<string, Pos>();
61
+ for (const n of nodes) {
62
+ if (side.has(n.id)) continue;
63
+ const p = g.node(n.id) as unknown as Pos;
64
+ // Flip across the flow's axis (TB: left ↔ right; LR: top ↔ bottom).
65
+ pos.set(n.id, tb ? { x: width - p.x - n.size.width / 2, y: p.y - n.size.height / 2 } : { x: p.x - n.size.width / 2, y: height - p.y - n.size.height / 2 });
66
+ }
67
+ const placed = () => [...pos.entries()].map(([id, p]) => ({ ...p, w: byId.get(id)!.size.width, h: byId.get(id)!.size.height }));
68
+ for (const [id, parent] of side) {
69
+ const n = byId.get(id)!;
70
+ const pn = byId.get(parent)!;
71
+ const p = pos.get(parent)!;
72
+ // Right after the decision, and after anything already on that row (a side branch, another exit of the same decision).
73
+ let q: Pos;
74
+ if (tb) {
75
+ const y = Math.max(0, p.y + (pn.size.height - n.size.height) / 2);
76
+ const row = placed().filter((b) => b.y < y + n.size.height && b.y + b.h > y && b.x >= p.x);
77
+ q = { x: Math.max(...row.map((b) => b.x + b.w)) + LANE.side, y };
78
+ } else {
79
+ const x = Math.max(0, p.x + (pn.size.width - n.size.width) / 2);
80
+ const col = placed().filter((b) => b.x < x + n.size.width && b.x + b.w > x && b.y >= p.y);
81
+ q = { x, y: Math.max(...col.map((b) => b.y + b.h)) + LANE.side };
82
+ }
83
+ pos.set(id, q);
84
+ width = Math.max(width, q.x + n.size.width);
85
+ height = Math.max(height, q.y + n.size.height);
86
+ }
87
+ return { pos, width, height };
88
+ }
89
+
90
+ export interface FlowBand { phase: string; label: string; lane: number; x: number; y: number; width: number; height: number }
91
+ export interface LaidNode { id: string; type: FlowNode["kind"]; lane: number; position: Pos; width: number; height: number; data: FlowNode }
92
+ export interface LaidEdge {
93
+ id: string; source: string; target: string; sourceHandle: string; targetHandle: string; type: "flow";
94
+ data: { kind: FlowEdgeKind; label: string; offset?: number; centerX?: number; centerY?: number };
95
+ }
96
+ export interface FlowLayout { direction: FlowDirection; lanes: boolean; width: number; height: number; bands: FlowBand[]; nodes: LaidNode[]; edges: LaidEdge[] }
97
+
98
+ /**
99
+ * A flow (checked or not) → where each box stands, for React Flow.
100
+ * - `lanes: false` (default): one stream in `direction`, the phases as bands one after another (label in the margin). Narrow screens.
101
+ * - `lanes: true`: each phase a lane side by side (TB: lanes are columns, read top down then the next column). Wide screens.
102
+ * `lane` on a band and a node is the phase's index in `phases`: the canvas colours by it. Handles: `s-<side>` (source) /
103
+ * `t-<side>` (target), side t | b | l | r: a node on the canvas carries all eight. `height` is an estimate (real words may run
104
+ * a line longer); the canvas lets the box grow.
105
+ */
106
+ export function layoutFlow(input: unknown, { phases, direction, lanes = false }: { phases: readonly FlowPhase[]; direction?: FlowDirection; lanes?: boolean }): FlowLayout {
107
+ // The drawing only: the caller may carry extra keys at the top (a note, a source), and examples (with `html` from a server)
108
+ // do not move a box. validateFlow takes neither, so both go before it checks.
109
+ const bare = (n: unknown) => (n && typeof n === "object" && !Array.isArray(n) ? (({ examples: _x, ...rest }: Record<string, unknown>) => rest)(n as Record<string, unknown>) : n);
110
+ const obj = input && typeof input === "object" && !Array.isArray(input) ? (input as Record<string, unknown>) : null;
111
+ const flow = validateFlow(obj ? { direction: obj.direction, nodes: Array.isArray(obj.nodes) ? obj.nodes.map(bare) : obj.nodes, edges: obj.edges } : input, { phases });
112
+ const dir: FlowDirection = direction && FLOW_DIRECTIONS.includes(direction) ? direction : flow.direction;
113
+ const tb = dir === "TB";
114
+ const list: Sized[] = flow.nodes.map((n) => ({ ...n, size: nodeSize(n) }));
115
+ const byId = new Map(list.map((n) => [n.id, n]));
116
+ const at = new Map<string, Pos>();
117
+ const laneOf = Object.fromEntries(phases.map((p, i) => [p.key, i]));
118
+ const labelOf = Object.fromEntries(phases.map((p) => [p.key, p.label]));
119
+ const present = phases.map((p) => p.key).filter((p) => list.some((n) => n.phase === p));
120
+ const laneIdx = Object.fromEntries(present.map((p, i) => [p, i]));
121
+ const bands: Array<Omit<FlowBand, "label" | "lane">> = [];
122
+ let width: number;
123
+ let height: number;
124
+
125
+ if (lanes) {
126
+ let off = 0;
127
+ for (const ph of present) {
128
+ const sub = list.filter((n) => n.phase === ph);
129
+ const L = dagreLayout(sub, flow.edges.filter((e) => byId.get(e.from)!.phase === ph && byId.get(e.to)!.phase === ph), dir);
130
+ const cross = tb ? L.width : L.height;
131
+ const inner = Math.max(cross, LANE.min - 2 * LANE.pad);
132
+ const shift = (inner - cross) / 2;
133
+ for (const n of sub) {
134
+ const p = L.pos.get(n.id)!;
135
+ at.set(n.id, tb ? { x: off + LANE.pad + shift + p.x, y: LANE.head + LANE.pad + p.y } : { x: LANE.head + LANE.pad + p.x, y: off + LANE.pad + shift + p.y });
136
+ }
137
+ const main = LANE.head + 2 * LANE.pad + (tb ? L.height : L.width);
138
+ bands.push(tb ? { phase: ph, x: off, y: 0, width: inner + 2 * LANE.pad, height: main } : { phase: ph, x: 0, y: off, width: main, height: inner + 2 * LANE.pad });
139
+ off += inner + 2 * LANE.pad + LANE.gap;
140
+ }
141
+ // Every lane the same length, as a table.
142
+ const span = Math.max(...bands.map((b) => (tb ? b.height : b.width)));
143
+ for (const b of bands) { if (tb) b.height = span; else b.width = span; }
144
+ width = tb ? off - LANE.gap : span;
145
+ height = tb ? span : off - LANE.gap;
146
+ } else {
147
+ const L = dagreLayout(list, flow.edges, dir);
148
+ for (const n of list) {
149
+ const p = L.pos.get(n.id)!;
150
+ at.set(n.id, tb ? { x: LANE.head + LANE.pad + p.x, y: LANE.pad + p.y } : { x: LANE.pad + p.x, y: LANE.head + LANE.pad + p.y });
151
+ }
152
+ // A wider margin at the end: a loop goes round the main line on the right (TB) / below it (LR).
153
+ width = tb ? LANE.head + LANE.pad + LANE.side * 2 + L.width : 2 * LANE.pad + L.width;
154
+ height = tb ? 2 * LANE.pad + L.height : LANE.head + LANE.pad + LANE.side * 2 + L.height;
155
+ // A phase's band runs along the flow from its first box to its last; two bands meet in the middle of the gap between them.
156
+ const span = present.map((ph) => {
157
+ const own = list.filter((n) => n.phase === ph).map((n) => { const p = at.get(n.id)!; return tb ? [p.y, p.y + n.size.height] : [p.x, p.x + n.size.width]; });
158
+ return { phase: ph, a: Math.min(...own.map((r) => r[0]!)), b: Math.max(...own.map((r) => r[1]!)) };
159
+ });
160
+ const total = tb ? height : width;
161
+ span.forEach((s, i) => {
162
+ const lo = i === 0 ? 0 : (span[i - 1]!.b + s.a) / 2;
163
+ const hi = i === span.length - 1 ? total : (s.b + span[i + 1]!.a) / 2;
164
+ bands.push(tb ? { phase: s.phase, x: 0, y: lo, width, height: Math.max(hi - lo, 0) } : { phase: s.phase, x: lo, y: 0, width: Math.max(hi - lo, 0), height });
165
+ });
166
+ }
167
+
168
+ // Which side of a box each line leaves from: forward along the flow, bottom → top; into another lane, right → left (or back)
169
+ // and down the gap between the two lanes (centerX), never across a lane's boxes; back within a lane (a loop), round the
170
+ // outside of every box in between.
171
+ const box = (id: string) => {
172
+ const n = byId.get(id)!;
173
+ const p = at.get(id)!;
174
+ const len = tb ? n.size.height : n.size.width;
175
+ const cross = tb ? n.size.width : n.size.height;
176
+ return { m: tb ? p.y : p.x, len, c: tb ? p.x : p.y, mid: (tb ? p.x : p.y) + cross / 2, end: (tb ? p.x : p.y) + cross };
177
+ };
178
+ const F = tb ? ["b", "t"] : ["r", "l"];
179
+ const PLUS = tb ? ["r", "l"] : ["b", "t"];
180
+ const MINUS = tb ? ["l", "r"] : ["t", "b"];
181
+ const BACK = tb ? ["r", "r"] : ["b", "b"];
182
+ const gapAfter = (ph: string) => { const b = bands.find((x) => x.phase === ph)!; return tb ? b.x + b.width + LANE.gap / 2 : b.y + b.height + LANE.gap / 2; };
183
+ const edges: LaidEdge[] = flow.edges.map((e, i) => {
184
+ const s = box(e.from);
185
+ const t = box(e.to);
186
+ const sp = byId.get(e.from)!.phase;
187
+ const tp = byId.get(e.to)!.phase;
188
+ const dl = lanes ? laneIdx[tp]! - laneIdx[sp]! : 0;
189
+ const data: LaidEdge["data"] = { kind: e.kind, label: e.label };
190
+ let pick: string[];
191
+ if (dl) {
192
+ pick = dl > 0 ? PLUS : MINUS;
193
+ // The gap right after the lane in front (the source's going forward, the target's coming back); a forward line takes the
194
+ // left half of the gap and a loop the right half, so a solid and a dashed line never lie on each other.
195
+ data[tb ? "centerX" : "centerY"] = gapAfter(dl > 0 ? present[laneIdx[tp]! - 1]! : tp) + (e.kind === "loop" ? 8 : -8);
196
+ } else if (t.m >= s.m + s.len - 2) {
197
+ // A branch that leaves a decision sideways goes out of the box's side ("No ←"), so two branches never share a point and
198
+ // the Yes / No labels never sit on each other.
199
+ const sideways = byId.get(e.from)!.kind === "decision" && Math.abs(t.mid - s.mid) > 24;
200
+ pick = sideways ? [t.mid < s.mid ? MINUS[0]! : PLUS[0]!, F[1]!] : F;
201
+ // A straight line would cross a box in between (a jump over a step): go round on the right, like a loop.
202
+ const a = Math.min(s.mid, t.mid) - 4;
203
+ const b = Math.max(s.mid, t.mid) + 4;
204
+ const scope = list.filter((n) => n.id !== e.from && n.id !== e.to && (!lanes || n.phase === sp)).map((n) => box(n.id));
205
+ if (!sideways && scope.some((n) => n.m < t.m && n.m + n.len > s.m + s.len && n.c < b && n.end > a)) {
206
+ pick = BACK;
207
+ const far = Math.max(...scope.filter((n) => n.m < t.m + t.len && n.m + n.len > s.m).map((n) => n.end), s.end, t.end);
208
+ data.offset = Math.round(Math.max(20, far - Math.max(s.end, t.end) + 20));
209
+ }
210
+ } else if (t.m + t.len <= s.m + 2) {
211
+ pick = BACK;
212
+ const lo = Math.min(s.m, t.m);
213
+ const hi = Math.max(s.m + s.len, t.m + t.len);
214
+ const far = Math.max(...list.filter((n) => !lanes || n.phase === sp).map((n) => box(n.id)).filter((b) => b.m < hi && b.m + b.len > lo).map((b) => b.end));
215
+ data.offset = Math.round(Math.max(20, far - Math.max(s.end, t.end) + 20));
216
+ } else pick = t.c > s.c ? PLUS : MINUS;
217
+ return { id: `e${i}-${e.from}-${e.to}`, source: e.from, target: e.to, sourceHandle: `s-${pick[0]}`, targetHandle: `t-${pick[1]}`, type: "flow", data };
218
+ });
219
+
220
+ return {
221
+ direction: dir,
222
+ lanes: Boolean(lanes),
223
+ width,
224
+ height,
225
+ bands: bands.map((b) => ({ ...b, label: labelOf[b.phase] ?? b.phase, lane: laneOf[b.phase] ?? 0 })),
226
+ nodes: list.map(({ size, ...n }) => ({ id: n.id, type: n.kind, lane: laneOf[n.phase] ?? 0, position: at.get(n.id)!, width: size.width, height: size.height, data: n })),
227
+ edges,
228
+ };
229
+ }
@@ -0,0 +1,256 @@
1
+ /**
2
+ * A SKILL'S FLOW, AS DATA (03/11/2026, lifted from content-radar's lib/skill-flow.js: Chris 27/10/2026, "làm đúng kiểu bên content
3
+ * radar … dùng chung theo gemboss ui để sau update cho dễ"). Pure: no file reads, no React, no layout library. The canvas
4
+ * (`./canvas.tsx`) and the layout (`./layout.ts`, dagre) read what this module checks; a server checks a flow.json with it before
5
+ * it hands one to a browser.
6
+ *
7
+ * The one change from content-radar: the LANES are the caller's. content-radar's four (prep · write · check · publish) were its
8
+ * writer's phases imported straight into the module; here every function that needs them takes `phases`, so GemBoss's packs bring
9
+ * their own (read · frame · build · check) and content-radar keeps its own.
10
+ *
11
+ * Format (plain JSON; label / detail / examples are the skill's data, in the skill's language; the words around the canvas are the
12
+ * surface's, English by default):
13
+ * { direction: "TB" | "LR",
14
+ * nodes: [{ id, label, kind, phase, detail?, tools?: ["gemboss_…"], human?, examples?: [{ title, kind, md }] }],
15
+ * edges: [{ from, to, label?, kind? }] }
16
+ * node kind: start | step | decision | stop (a person confirms) | exit (leaves this skill, another one takes over) | end
17
+ * phase: one of the caller's phase keys, the node's lane
18
+ * edge kind: normal | yes | no | loop (back to fix, e.g. a check failed → build again)
19
+ * examples: 1–3 made-up examples of one step. kind: input | output | good | bad | tool. `md` is short Markdown; the server may
20
+ * attach `html` (flowWithHtml) so the browser needs no Markdown library.
21
+ */
22
+
23
+ export const FLOW_NODE_KINDS = ["start", "step", "decision", "stop", "exit", "end"] as const;
24
+ export const FLOW_EDGE_KINDS = ["normal", "yes", "no", "loop"] as const;
25
+ export const FLOW_DIRECTIONS = ["TB", "LR"] as const;
26
+ export const FLOW_EXAMPLE_KINDS = ["input", "output", "good", "bad", "tool"] as const;
27
+
28
+ export type FlowNodeKind = (typeof FLOW_NODE_KINDS)[number];
29
+ export type FlowEdgeKind = (typeof FLOW_EDGE_KINDS)[number];
30
+ export type FlowDirection = (typeof FLOW_DIRECTIONS)[number];
31
+ export type FlowExampleKind = (typeof FLOW_EXAMPLE_KINDS)[number];
32
+
33
+ /** One lane of the canvas: a key the flow's nodes name in `phase`, and the words drawn on it. Order = left to right (or top down). */
34
+ export interface FlowPhase { key: string; label: string }
35
+
36
+ export interface FlowExample { title: string; kind: FlowExampleKind; md: string; html?: string }
37
+ export interface FlowNode {
38
+ id: string;
39
+ label: string;
40
+ kind: FlowNodeKind;
41
+ phase: string;
42
+ detail: string;
43
+ tools: string[];
44
+ /** A person does this step (always true for `stop`). */
45
+ human: boolean;
46
+ examples: FlowExample[];
47
+ }
48
+ export interface FlowEdge { from: string; to: string; label: string; kind: FlowEdgeKind }
49
+ export interface Flow { direction: FlowDirection; nodes: FlowNode[]; edges: FlowEdge[] }
50
+
51
+ /** Length ceilings: a label sits in a two-line box, an edge label is a small pill on a line; longer words go in `detail`. */
52
+ export const FLOW_LIMITS = { nodes: 60, label: 48, detail: 700, edgeLabel: 28, tools: 4, examples: 3, exampleTitle: 60, exampleMd: 900 } as const;
53
+
54
+ const TERMINAL = new Set<string>(["end", "exit"]);
55
+ const TOP_KEYS = new Set(["direction", "nodes", "edges"]);
56
+ const NODE_KEYS = new Set(["id", "label", "kind", "phase", "detail", "tools", "human", "examples"]);
57
+ const EXAMPLE_KEYS = new Set(["title", "kind", "md"]);
58
+ const EDGE_KEYS = new Set(["from", "to", "label", "kind"]);
59
+ const ID = /^[a-z0-9][a-z0-9-]*$/;
60
+ // A tool name as an MCP client sees it: `gemboss_get_skill`, `gemboss.get_skill`, `radar_skill_get`.
61
+ const TOOL = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)?$/;
62
+
63
+ const text = (v: unknown) => (typeof v === "string" ? v.replace(/\s+/g, " ").trim() : "");
64
+ const fail = (errs: string[]) => new Error(`invalid flow (${errs.length} problem${errs.length === 1 ? "" : "s"}): ${errs.join("; ")}`);
65
+ const isObject = (v: unknown): v is Record<string, unknown> => !!v && typeof v === "object" && !Array.isArray(v);
66
+
67
+ /**
68
+ * Check a flow and return it normalised (whitespace collapsed; defaults for kind, tools, human, direction). Throws ONE error that
69
+ * lists every problem, so whoever edits the file sees the whole list at once.
70
+ */
71
+ export function validateFlow(input: unknown, { phases, allowHtml = false }: {
72
+ phases: readonly FlowPhase[];
73
+ /** Keep an example's `html` (a server rendered its Markdown, flowWithHtml). A flow FILE never carries html: off by default. */
74
+ allowHtml?: boolean;
75
+ }): Flow {
76
+ let x: unknown = input;
77
+ if (typeof x === "string") { try { x = JSON.parse(x); } catch { throw new Error("invalid flow: not JSON"); } }
78
+ if (!isObject(x)) throw new Error("invalid flow: must be an object { direction, nodes, edges }");
79
+ const keys = phases.map((p) => p.key);
80
+ const errs: string[] = [];
81
+ for (const k of Object.keys(x)) if (!TOP_KEYS.has(k)) errs.push(`unknown key "${k}" at the top (only direction, nodes, edges)`);
82
+ const direction = (x.direction == null ? "TB" : x.direction) as FlowDirection;
83
+ if (!FLOW_DIRECTIONS.includes(direction)) errs.push(`direction "${String(direction)}" is not one of ${FLOW_DIRECTIONS.join(" | ")}`);
84
+ if (!Array.isArray(x.nodes) || !x.nodes.length) errs.push("nodes must be a list with at least one node");
85
+ if (!Array.isArray(x.edges)) errs.push("edges must be a list");
86
+ if (!Array.isArray(x.nodes) || !Array.isArray(x.edges)) throw fail(errs);
87
+ if (x.nodes.length > FLOW_LIMITS.nodes) errs.push(`more than ${FLOW_LIMITS.nodes} nodes: split the skill or merge steps`);
88
+
89
+ const nodes: FlowNode[] = [];
90
+ const byId = new Map<string, FlowNode>();
91
+ (x.nodes as unknown[]).forEach((n, i) => {
92
+ const at = `node #${i + 1}${isObject(n) && typeof n.id === "string" && n.id ? ` "${n.id}"` : ""}`;
93
+ if (!isObject(n)) { errs.push(`${at}: must be an object`); return; }
94
+ for (const k of Object.keys(n)) if (!NODE_KEYS.has(k)) errs.push(`${at}: unknown key "${k}" (known: ${[...NODE_KEYS].join(", ")})`);
95
+ const id = text(n.id);
96
+ if (!ID.test(id)) errs.push(`${at}: id must be lowercase letters, digits and dashes (e.g. "gather")`);
97
+ else if (byId.has(id)) errs.push(`${at}: id used twice`);
98
+ const label = text(n.label);
99
+ if (!label) errs.push(`${at}: no label`);
100
+ else if (label.length > FLOW_LIMITS.label) errs.push(`${at}: label is ${label.length} characters (at most ${FLOW_LIMITS.label}; put the rest in detail)`);
101
+ const kind = (n.kind == null ? "step" : n.kind) as FlowNodeKind;
102
+ if (!FLOW_NODE_KINDS.includes(kind)) errs.push(`${at}: kind "${String(kind)}" is not one of ${FLOW_NODE_KINDS.join(" | ")}`);
103
+ const phase = typeof n.phase === "string" ? n.phase : "";
104
+ if (!keys.includes(phase)) errs.push(`${at}: phase "${phase}" is not one of ${keys.join(" | ")}`);
105
+ if (n.detail != null && typeof n.detail !== "string") errs.push(`${at}: detail must be text`);
106
+ const detail = text(n.detail);
107
+ if (detail.length > FLOW_LIMITS.detail) errs.push(`${at}: detail is longer than ${FLOW_LIMITS.detail} characters`);
108
+ let tools: string[] = [];
109
+ if (n.tools != null) {
110
+ if (!Array.isArray(n.tools)) errs.push(`${at}: tools must be a list of tool names`);
111
+ else {
112
+ tools = n.tools.map(text);
113
+ for (const t of tools) if (!TOOL.test(t)) errs.push(`${at}: tool name "${t}" is not valid`);
114
+ if (new Set(tools).size !== tools.length) errs.push(`${at}: a tool is named twice`);
115
+ if (tools.length > FLOW_LIMITS.tools) errs.push(`${at}: more than ${FLOW_LIMITS.tools} tools (the box is full: split the step)`);
116
+ }
117
+ }
118
+ if (n.human != null && typeof n.human !== "boolean") errs.push(`${at}: human must be true or false`);
119
+ const examples: FlowExample[] = [];
120
+ if (n.examples != null) {
121
+ if (!Array.isArray(n.examples)) errs.push(`${at}: examples must be a list`);
122
+ else {
123
+ if (n.examples.length > FLOW_LIMITS.examples) errs.push(`${at}: more than ${FLOW_LIMITS.examples} examples`);
124
+ (n.examples as unknown[]).forEach((ex, j) => {
125
+ const ea = `${at}, example #${j + 1}`;
126
+ if (!isObject(ex)) { errs.push(`${ea}: must be an object { title, kind, md }`); return; }
127
+ for (const k of Object.keys(ex)) if (!EXAMPLE_KEYS.has(k) && !(allowHtml && k === "html")) errs.push(`${ea}: unknown key "${k}" (known: title, kind, md)`);
128
+ if (allowHtml && ex.html != null && typeof ex.html !== "string") errs.push(`${ea}: html must be text`);
129
+ const title = text(ex.title);
130
+ if (!title) errs.push(`${ea}: no title`);
131
+ else if (title.length > FLOW_LIMITS.exampleTitle) errs.push(`${ea}: title is longer than ${FLOW_LIMITS.exampleTitle} characters`);
132
+ if (!FLOW_EXAMPLE_KINDS.includes(ex.kind as FlowExampleKind)) errs.push(`${ea}: kind "${String(ex.kind ?? "")}" is not one of ${FLOW_EXAMPLE_KINDS.join(" | ")}`);
133
+ // md keeps its line breaks (Markdown); only the ends are trimmed.
134
+ const md = typeof ex.md === "string" ? ex.md.replace(/\r\n?/g, "\n").trim() : "";
135
+ if (!md) errs.push(`${ea}: md is empty`);
136
+ else if (md.length > FLOW_LIMITS.exampleMd) errs.push(`${ea}: md is ${md.length} characters (at most ${FLOW_LIMITS.exampleMd})`);
137
+ examples.push({ title, kind: ex.kind as FlowExampleKind, md, ...(allowHtml && typeof ex.html === "string" ? { html: ex.html } : {}) });
138
+ });
139
+ }
140
+ }
141
+ const node: FlowNode = { id, label, kind, phase, detail, tools, human: n.human === true || kind === "stop", examples };
142
+ nodes.push(node);
143
+ if (ID.test(id) && !byId.has(id)) byId.set(id, node);
144
+ });
145
+
146
+ const edges: FlowEdge[] = [];
147
+ const pairs = new Set<string>();
148
+ (x.edges as unknown[]).forEach((e, i) => {
149
+ const at = `edge #${i + 1}${isObject(e) && e.from ? ` ${String(e.from)} → ${String(e.to)}` : ""}`;
150
+ if (!isObject(e)) { errs.push(`${at}: must be an object`); return; }
151
+ for (const k of Object.keys(e)) if (!EDGE_KEYS.has(k)) errs.push(`${at}: unknown key "${k}" (known: ${[...EDGE_KEYS].join(", ")})`);
152
+ const from = text(e.from);
153
+ const to = text(e.to);
154
+ if (!byId.has(from)) errs.push(`${at}: no node "${from}"`);
155
+ if (!byId.has(to)) errs.push(`${at}: no node "${to}"`);
156
+ if (from && from === to) errs.push(`${at}: a node points at itself`);
157
+ const kind = (e.kind == null ? "normal" : e.kind) as FlowEdgeKind;
158
+ if (!FLOW_EDGE_KINDS.includes(kind)) errs.push(`${at}: kind "${String(kind)}" is not one of ${FLOW_EDGE_KINDS.join(" | ")}`);
159
+ if ((kind === "yes" || kind === "no") && byId.get(from) && byId.get(from)!.kind !== "decision") errs.push(`${at}: a ${kind} edge only leaves a decision`);
160
+ if (e.label != null && typeof e.label !== "string") errs.push(`${at}: label must be text`);
161
+ const label = text(e.label);
162
+ if (label.length > FLOW_LIMITS.edgeLabel) errs.push(`${at}: label is longer than ${FLOW_LIMITS.edgeLabel} characters`);
163
+ if (pairs.has(`${from}>${to}`)) errs.push(`${at}: the same edge twice`);
164
+ pairs.add(`${from}>${to}`);
165
+ edges.push({ from, to, label, kind });
166
+ });
167
+
168
+ // The shape of the whole: one way in, somewhere to end, no dead end, every node reachable and every node able to finish.
169
+ const ok = edges.filter((e) => byId.has(e.from) && byId.has(e.to));
170
+ const outs = (id: string) => ok.filter((e) => e.from === id);
171
+ const starts = nodes.filter((n) => n.kind === "start");
172
+ if (starts.length !== 1) errs.push(starts.length ? `${starts.length} start nodes (only one)` : "no start node");
173
+ if (!nodes.some((n) => n.kind === "end")) errs.push("no end node");
174
+ for (const n of byId.values()) {
175
+ const out = outs(n.id).length;
176
+ if (n.kind === "start" && ok.some((e) => e.to === n.id)) errs.push(`start node "${n.id}" must have no edge coming in`);
177
+ if (TERMINAL.has(n.kind) && out) errs.push(`node "${n.id}" (${n.kind}) ends the flow and must have no edge going out`);
178
+ if (!TERMINAL.has(n.kind) && !out) errs.push(`node "${n.id}" is a dead end: no edge goes out (use kind end or exit to finish)`);
179
+ if (n.kind === "decision" && out && out < 2) errs.push(`node "${n.id}" (decision) needs at least two branches`);
180
+ }
181
+ if (starts.length === 1 && byId.has(starts[0]!.id)) {
182
+ const seen = walk(starts[0]!.id, ok, "from", "to");
183
+ const lost = [...byId.keys()].filter((id) => !seen.has(id));
184
+ if (lost.length) errs.push(`not reachable from start: ${lost.join(", ")}`);
185
+ }
186
+ const ends = [...byId.values()].filter((n) => TERMINAL.has(n.kind)).map((n) => n.id);
187
+ if (ends.length) {
188
+ const back = new Set<string>();
189
+ for (const id of ends) for (const s of walk(id, ok, "to", "from")) back.add(s);
190
+ const stuck = [...byId.keys()].filter((id) => !back.has(id));
191
+ if (stuck.length) errs.push(`loops forever, never reaches an end or exit: ${stuck.join(", ")}`);
192
+ }
193
+ if (errs.length) throw fail(errs);
194
+ return { direction, nodes, edges };
195
+ }
196
+
197
+ function walk(from: string, edges: FlowEdge[], a: "from" | "to", b: "from" | "to"): Set<string> {
198
+ const seen = new Set([from]);
199
+ const queue = [from];
200
+ while (queue.length) {
201
+ const id = queue.shift()!;
202
+ for (const e of edges) if (e[a] === id && !seen.has(e[b])) { seen.add(e[b]); queue.push(e[b]); }
203
+ }
204
+ return seen;
205
+ }
206
+
207
+ /** Attach `html` to every example with the caller's Markdown renderer (a server route): the browser needs no Markdown library. */
208
+ export function flowWithHtml<F extends Flow>(flow: F, render: (md: string) => string): F {
209
+ return { ...flow, nodes: flow.nodes.map((n) => ({ ...n, examples: (n.examples || []).map((x) => ({ ...x, html: render(x.md) })) })) };
210
+ }
211
+
212
+ /** The phases a flow actually uses, in the caller's order. */
213
+ export const phasesIn = (flow: Pick<Flow, "nodes">, phases: readonly FlowPhase[]): FlowPhase[] =>
214
+ phases.filter((p) => flow.nodes.some((n) => n.phase === p.key));
215
+
216
+ /** A tool's short name in a box: the surface's own prefix off (`gemboss_get_skill` → `get_skill`). */
217
+ export const shortTool = (t: string, prefixes: readonly string[] = ["gemboss_", "gemboss.", "radar_"]): string => {
218
+ const s = String(t);
219
+ const p = prefixes.find((x) => s.startsWith(x));
220
+ return p ? s.slice(p.length) : s;
221
+ };
222
+
223
+ // ── Zoom (pure, so it can be tested; the canvas calls it) ────────────────────────────────────────────────────────────────
224
+ /** 10%–400%, as the GemBoss admin's own canvases (use-canvas-viewport.ts): zoom out freely, as a design tool does. */
225
+ export const FLOW_ZOOM = { min: 0.1, max: 4 } as const;
226
+
227
+ /** Whether a plain wheel pans the canvas: always in full screen; in a page only once zoomed in past the fit (until then the wheel
228
+ * scrolls the page, so a reader is never trapped in a tall box in the middle of it). ⌘ / Ctrl + wheel always zooms. */
229
+ export const flowWheelPans = ({ zoom, home, full = false }: { zoom: number; home: number; full?: boolean }) =>
230
+ Boolean(full || (home > 0 && zoom > home * 1.02));
231
+
232
+ /** ⌘ + wheel (React Flow zooms with Ctrl and a pinch only): the new viewport around the pointer (px, py inside the canvas), with
233
+ * d3-zoom's own wheelDelta (line 0.05, page 1, pixel 0.002) so it feels the same as Ctrl + wheel. The point under the pointer stays. */
234
+ export function wheelZoom(
235
+ vp: { x: number; y: number; zoom: number },
236
+ { px, py, deltaY, deltaMode = 0 }: { px: number; py: number; deltaY: number; deltaMode?: number },
237
+ { min = FLOW_ZOOM.min, max = FLOW_ZOOM.max }: { min?: number; max?: number } = {},
238
+ ): { x: number; y: number; zoom: number } {
239
+ const d = -Number(deltaY || 0) * (deltaMode === 1 ? 0.05 : deltaMode ? 1 : 0.002);
240
+ const zoom = Math.min(max, Math.max(min, vp.zoom * 2 ** d));
241
+ const r = zoom / vp.zoom;
242
+ return { x: px - (px - vp.x) * r, y: py - (py - vp.y) * r, zoom };
243
+ }
244
+
245
+ /** A zoom level to print: 1 → "100%". */
246
+ export const zoomLabel = (z: number) => `${Math.round(Number(z || 0) * 100)}%`;
247
+
248
+ /** A key while the canvas has focus → "in" | "out" | "reset" | null. + (and = without Shift) / − / 0, with or without ⌘ / Ctrl: focus
249
+ * inside the canvas, ⌘ + zooms the CANVAS, not the page. Alt is left alone. */
250
+ export function flowZoomKey({ key, altKey = false }: { key?: string; altKey?: boolean } = {}): "in" | "out" | "reset" | null {
251
+ if (altKey) return null;
252
+ if (key === "+" || key === "=") return "in";
253
+ if (key === "-" || key === "_" || key === "−") return "out";
254
+ if (key === "0") return "reset";
255
+ return null;
256
+ }
@@ -0,0 +1 @@
1
+ .skf{container-type:inline-size;display:grid;gap:10px;min-width:0;--skf-sticky: 12px;--skf-card: var(--gemboss-surface, #ffffff);--skf-ink: var(--gemboss-text, #1b1c1e);--skf-muted: var(--gemboss-text-muted, #686b71);--skf-line: var(--gemboss-divider, #e5e7ea);--skf-line-2: var(--gemboss-chip-line, #cfd6ce);--skf-sunk: var(--gemboss-primary-soft, #f2f3f5);--skf-canvas: var(--gemboss-canvas, #ffffff);--skf-accent: var(--gemboss-accent, #5661f5);--skf-edge: color-mix(in srgb, var(--skf-muted) 72%, transparent);--skf-no: var(--gemboss-danger, #d72c0d);--skf-loop: var(--gemboss-warning, #9a6700);--skf-yes: var(--gemboss-success-strong, #0a6a4c);--skf-mono: ui-monospace, SFMono-Regular, Menlo, monospace}.skf [data-lane="0"]{--skf-ph: var(--gemboss-accent, #5661f5)}.skf [data-lane="1"]{--skf-ph: var(--gemboss-warning, #9a6700)}.skf [data-lane="2"]{--skf-ph: var(--gemboss-success, #007f5f)}.skf [data-lane="3"]{--skf-ph: var(--gemboss-text-muted, #686b71)}.skf [data-lane="4"]{--skf-ph: var(--gemboss-accent-strong, #3a44de)}.skf [data-lane="5"]{--skf-ph: var(--gemboss-danger, #d72c0d)}.skf-top{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px 16px}.skf-legend{display:flex;flex-wrap:wrap;gap:4px 14px;margin:0;padding:0;list-style:none;font-size:12px;color:var(--skf-muted)}.skf-legend li{display:inline-flex;align-items:center;gap:6px}.skf-hint{margin:0;font-size:12px;color:var(--skf-muted)}.skf-dot{display:inline-block;width:8px;height:8px;border-radius:2px;background:var(--skf-ph);flex:none}.skf-key{display:inline-block;width:14px;height:10px;border:1px solid var(--skf-line-2);border-radius:4px;background:var(--skf-card)}.skf-key--decision{width:16px;border:0;background:var(--skf-muted);clip-path:polygon(4px 0,calc(100% - 4px) 0,100% 50%,calc(100% - 4px) 100%,4px 100%,0 50%)}.skf-key--stop{border-color:var(--gemboss-warning-border, #f5d569);background:var(--gemboss-warning-soft, #fff8e0)}.skf-key--exit{border:1px dashed var(--skf-no);background:transparent}.skf-line{display:inline-block;width:18px;height:0;border-top:2px solid var(--skf-no)}.skf-line--loop{border-top:2px dashed var(--skf-loop)}.skf-note{margin:0;padding:8px 10px;border-radius:8px;font-size:12px;background:var(--skf-sunk);color:var(--skf-muted)}.skf-note--bad{background:var(--gemboss-danger-soft, #fff0e9);color:var(--gemboss-danger-strong, #b42318)}.skf__stage{position:relative;min-width:0}.skf__stage--wait{height:320px;border:1px solid var(--skf-line);border-radius:12px;background:var(--skf-sunk)}.skf__canvas{position:absolute;inset:0;overflow:hidden;border:1px solid var(--skf-line);border-radius:12px;background:var(--skf-canvas)}.skf__canvas:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:2px}.skf .react-flow{font-family:inherit;--xy-background-color: var(--skf-canvas);--xy-background-pattern-color: var(--skf-line);--xy-edge-stroke: var(--skf-edge);--xy-edge-stroke-width: 1.5;--xy-attribution-background-color: transparent}.skf .react-flow__attribution a{color:var(--skf-muted)}.skf .skf-h{opacity:0;width:1px;height:1px;min-width:0;min-height:0;border:0}.skf__tools{position:sticky;top:var(--skf-sticky);z-index:6;height:0;display:flex;justify-content:flex-end;align-items:flex-start;pointer-events:none}.skf-zoom{pointer-events:auto;display:flex;align-items:center;gap:2px;margin:10px 10px 0 0;padding:3px;border-radius:12px;border:1px solid var(--skf-line);background:var(--skf-card);box-shadow:var(--gemboss-shadow-raised, 0 4px 16px rgba(31, 30, 29, .1))}.skf-zoom .skf-zoom__btn{display:inline-flex;align-items:center;justify-content:center;gap:5px;min-width:30px;height:30px;padding:0 7px;border:0;border-radius:8px;background:transparent;color:var(--skf-ink);font:inherit;font-size:12px;font-weight:600;cursor:pointer}.skf-zoom .skf-zoom__btn:hover:not(:disabled),.skf-zoom .skf-zoom__btn:active:not(:disabled){background:var(--gemboss-hover, #eceef2);color:var(--skf-ink)}.skf-zoom .skf-zoom__btn:disabled{background:transparent;color:var(--skf-muted);opacity:.45;cursor:default}.skf-zoom .skf-zoom__btn:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:1px}.skf-zoom svg{width:15px;height:15px;flex:none}.skf-zoom__pct{min-width:44px;text-align:center;font-size:12px;font-weight:600;font-variant-numeric:tabular-nums;color:var(--skf-muted)}.skf-zoom__sep{width:1px;height:18px;margin:0 3px;background:var(--skf-line)}@media (pointer: coarse){.skf-zoom .skf-zoom__btn{min-width:38px;height:38px}}.skf .react-flow__node-band{pointer-events:none}.skf-band{position:relative;box-sizing:border-box;width:100%;height:100%;background:color-mix(in srgb,var(--skf-ph) 5%,transparent);border-top:1px solid color-mix(in srgb,var(--skf-ph) 22%,transparent)}.skf-band--lane{border:1px solid color-mix(in srgb,var(--skf-ph) 18%,transparent);border-radius:16px}.skf-band__label{position:absolute;left:12px;top:10px;font-size:11px;line-height:14px;font-weight:650;letter-spacing:.08em;text-transform:uppercase;color:color-mix(in srgb,var(--skf-ph) 80%,var(--skf-ink))}.skf-band:not(.skf-band--lane) .skf-band__label{left:9px;top:12px;writing-mode:vertical-rl;transform:rotate(180deg)}.skf-node{position:relative;isolation:isolate;box-sizing:border-box;width:100%;padding:8px 12px 8px 14px;border:1px solid var(--skf-line-2);border-radius:12px;background:var(--skf-card);color:var(--skf-ink);box-shadow:var(--gemboss-shadow-resting, 0 1px 2px rgba(31, 30, 29, .04), 0 2px 6px rgba(31, 30, 29, .06));cursor:pointer;display:flex;flex-direction:column;text-align:left;overflow:hidden}.skf-node:before{content:"";position:absolute;left:0;top:0;bottom:0;width:4px;background:var(--skf-ph)}.skf-node__eye{display:flex;align-items:center;gap:4px;margin-bottom:2px;font-size:11px;line-height:14px;font-weight:650;letter-spacing:.05em;text-transform:uppercase;color:color-mix(in srgb,var(--skf-ph) 78%,var(--skf-ink))}.skf-node__label{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;font-size:13px;line-height:18px;font-weight:600;overflow-wrap:anywhere}.skf-node__tools{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}.skf-node__tools code{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 7px;border-radius:999px;font:500 11px/18px var(--skf-mono);background:var(--skf-sunk);color:var(--skf-muted)}.skf-node:hover{border-color:var(--skf-muted)}.skf-node[data-on]{border-color:var(--skf-accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--skf-accent) 22%,transparent)}.skf .react-flow__node:focus-visible .skf-node{outline:2px solid var(--ui-focus, #5661f5);outline-offset:2px}.skf-node--start,.skf-node--end{border-radius:999px;padding:8px 18px;align-items:center;text-align:center}.skf-node--start:before,.skf-node--end:before{display:none}.skf-node--start{border:1.5px solid var(--skf-ink)}.skf-node--start .skf-node__tools,.skf-node--end .skf-node__tools{justify-content:center}.skf-node--end{background:var(--gemboss-primary, #1b1c1e);border-color:var(--gemboss-primary, #1b1c1e);color:var(--gemboss-on-primary, #ffffff)}.skf-node--end .skf-node__eye{color:inherit;opacity:.75}.skf-node--stop{border-color:var(--gemboss-warning-border, #f5d569);background:color-mix(in srgb,var(--gemboss-warning-soft, #fff8e0) 70%,var(--skf-card))}.skf-node--stop .skf-node__eye{align-self:flex-start;padding:0 6px;border-radius:999px;background:var(--gemboss-warning-soft, #fff8e0);color:var(--gemboss-warning, #9a6700);box-shadow:inset 0 0 0 1px var(--gemboss-warning-border, #f5d569)}.skf-node--exit{border:1px dashed var(--skf-no);background:color-mix(in srgb,var(--gemboss-danger-soft, #fff0e9) 60%,var(--skf-card));box-shadow:none}.skf-node--exit:before{display:none}.skf-node--exit .skf-node__eye{color:var(--skf-no)}.skf-node--decision{border:0;background:none;box-shadow:none;padding:9px 22px;overflow:visible}.skf-node--decision:before,.skf-node--decision:after{content:"";position:absolute;z-index:-1;display:block;width:auto}.skf-node--decision:before{inset:0;background:var(--skf-ph);clip-path:polygon(14px 0,calc(100% - 14px) 0,100% 50%,calc(100% - 14px) 100%,14px 100%,0 50%)}.skf-node--decision:after{inset:1.5px;background:var(--skf-card);clip-path:polygon(13px 0,calc(100% - 13px) 0,100% 50%,calc(100% - 13px) 100%,13px 100%,0 50%)}.skf-node--decision[data-on]:before{background:var(--skf-accent)}.skf-node--decision[data-on]{box-shadow:none}.skf .skf-node[data-dim],.skf .skf-band[data-dim]{opacity:.4;transition:opacity .2s ease}.skf .skf-node[data-dim]:hover,.skf .skf-node[data-dim][data-on]{opacity:1}@media (prefers-reduced-motion: reduce){.skf .skf-node[data-dim],.skf .skf-band[data-dim]{transition:none}}.skf .react-flow__edge-path.skf-edge{stroke:var(--skf-edge);stroke-width:1.5}.skf .react-flow__edge-path.skf-edge--no{stroke:var(--skf-no)}.skf .react-flow__edge-path.skf-edge--loop{stroke:var(--skf-loop);stroke-dasharray:5 4}.skf .react-flow__edge.is-on .react-flow__edge-path.skf-edge{stroke-width:2.5}.skf .react-flow__edgelabel-renderer{z-index:1}.skf-elabel{position:absolute;left:0;top:0;pointer-events:all;white-space:nowrap;padding:1px 7px;border-radius:999px;font-size:11px;line-height:16px;font-weight:500;background:var(--skf-card);color:var(--skf-muted);box-shadow:inset 0 0 0 1px var(--skf-line)}.skf-elabel b{font-weight:700}.skf-elabel--yes b{color:var(--skf-yes)}.skf-elabel--no{color:var(--skf-no);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--skf-no) 35%,transparent)}.skf-elabel--loop{color:var(--skf-loop);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--skf-loop) 35%,transparent)}.skf__float{position:absolute;top:0;right:0;bottom:0;width:384px;padding:56px 12px 12px;box-sizing:border-box;pointer-events:none}.skf__float .skf-panel{position:sticky;top:calc(var(--skf-sticky) + 48px);pointer-events:auto;max-height:min(100%,calc(100dvh - 160px));overflow:auto;box-shadow:var(--gemboss-shadow-raised, 0 4px 16px rgba(31, 30, 29, .1))}.skf-panel{box-sizing:border-box;margin:0;padding:12px 14px 14px;border:1px solid var(--skf-line);border-radius:12px;background:var(--skf-card);color:var(--skf-ink);font-size:13px;line-height:1.5}.skf-panel--empty{color:var(--skf-muted);font-size:12px}.skf-panel__head{display:flex;align-items:center;justify-content:space-between;gap:8px}.skf-panel__eye{display:flex;align-items:center;gap:6px;margin:0;font-size:11px;font-weight:650;letter-spacing:.06em;text-transform:uppercase;color:var(--skf-muted)}.skf-panel .skf-panel__x{border:0;background:transparent;font:inherit;font-size:18px;line-height:1;padding:2px 4px;color:var(--skf-muted);cursor:pointer;border-radius:6px}.skf-panel .skf-panel__x:hover,.skf-panel .skf-panel__x:active{background:var(--gemboss-hover, #eceef2);color:var(--skf-ink)}.skf-panel h4{margin:4px 0 6px;font-size:15px;line-height:1.35;font-weight:650}.skf-panel__detail{margin:0;color:var(--skf-ink)}.skf-panel__h{margin:12px 0 6px;font-size:11px;font-weight:650;letter-spacing:.06em;text-transform:uppercase;color:var(--skf-muted)}.skf-panel__h span{margin-left:6px;font-weight:500;letter-spacing:0;text-transform:none}.skf-panel__tools{display:flex;flex-wrap:wrap;gap:4px}.skf-panel__tools code{padding:0 7px;border-radius:999px;font:500 11px/20px var(--skf-mono);background:var(--skf-sunk);color:var(--skf-ink)}.skf-panel__next{margin:0;padding:0;list-style:none;display:grid;gap:4px}.skf-panel .skf-panel__go,.skf-panel .skf-panel__back{font:inherit;color:inherit;background:transparent;border:0;padding:0;cursor:pointer;text-align:left}.skf-panel .skf-panel__go{display:flex;align-items:baseline;gap:8px;width:100%;padding:5px 6px;margin:0 -6px;border-radius:8px}.skf-panel .skf-panel__go:hover,.skf-panel .skf-panel__go:active{background:var(--gemboss-hover, #eceef2);color:inherit}.skf-panel .skf-panel__back:hover,.skf-panel .skf-panel__back:active{background:transparent;color:var(--skf-ink)}.skf-panel__next em{font-style:normal;color:var(--skf-muted)}.skf-panel__from{margin:10px 0 0;font-size:12px;color:var(--skf-muted)}.skf-panel .skf-panel__back{text-decoration:underline;text-underline-offset:2px}.skf-panel button:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:1px}.skf-chip{flex:none;min-width:34px;text-align:center;padding:0 6px;border-radius:999px;font-size:11px;line-height:16px;font-weight:700;background:var(--skf-sunk);color:var(--skf-muted)}.skf-chip--yes{color:var(--skf-yes);background:var(--gemboss-success-soft, #e3f1df)}.skf-chip--no{color:var(--skf-no);background:var(--gemboss-danger-soft, #fff0e9)}.skf-chip--loop{color:var(--skf-loop);background:var(--gemboss-warning-soft, #fff8e0)}.skf-panel__ex{display:grid;gap:8px;grid-template-columns:minmax(0,1fr)}.skf-ex{min-width:0;padding:8px 10px 10px;border:1px solid var(--skf-line);border-radius:8px;background:var(--skf-card)}.skf-ex--good{border-color:var(--gemboss-success-border, #b7dfcd)}.skf-ex--bad{border-color:var(--gemboss-danger-border, #f5c9bc)}.skf-ex--tool{background:var(--skf-sunk)}.skf-ex__head{display:flex;align-items:baseline;gap:8px;margin:0 0 4px;font-size:12px;font-weight:650}.skf-ex__kind{flex:none;padding:0 6px;border-radius:999px;font-size:11px;line-height:16px;font-weight:700;letter-spacing:.03em;background:var(--skf-sunk);color:var(--skf-muted)}.skf-ex--good .skf-ex__kind{background:var(--gemboss-success-soft, #e3f1df);color:var(--skf-yes)}.skf-ex--bad .skf-ex__kind{background:var(--gemboss-danger-soft, #fff0e9);color:var(--skf-no)}.skf-ex--tool .skf-ex__kind{background:var(--skf-card);color:var(--skf-ink)}.skf-ex--input .skf-ex__kind,.skf-ex--output .skf-ex__kind{background:color-mix(in srgb,var(--skf-accent) 12%,var(--skf-card));color:var(--gemboss-accent-strong, #3a44de)}.skf-ex__md{font-size:12px;line-height:1.5;min-width:0;overflow-wrap:anywhere}.skf-ex__md>:first-child{margin-top:0}.skf-ex__md>:last-child{margin-bottom:0}.skf-ex__md :is(p,ul,ol,blockquote){margin:4px 0}.skf-ex__md :is(ul,ol){padding-left:18px}.skf-ex__md pre{margin:4px 0;padding:6px 8px;border-radius:6px;overflow-x:auto;white-space:pre;font-size:11px;background:var(--skf-card);border:1px solid var(--skf-line)}.skf-ex__md blockquote{padding-left:8px;border-left:2px solid var(--skf-line-2);color:var(--skf-muted)}.skf-ex__md :not(pre)>code{padding:0 4px;border-radius:4px;font:500 11px/16px var(--skf-mono);background:var(--skf-sunk)}@media (min-width: 48em){dialog.ui-modal.ui-reader.skf-pop{width:98vw;max-width:98vw;height:96dvh}}.skf--full{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;gap:8px;padding:10px 12px 12px;box-sizing:border-box;--skf-sticky: 0px}.skf--full .skf__stage{flex:1 1 auto;min-height:0}.skf--full .skf__float .skf-panel{position:static;max-height:100%}.skf--full>.skf-panel{flex:none;max-height:42%;overflow:auto}@media (max-width: 47.9975em){.skf--full{padding:8px}.skf--full .skf-legend{display:none}}
@@ -0,0 +1 @@
1
+ .ui-skillstats{display:grid;gap:18px;min-width:0;color:var(--gemboss-text, #1b1c1e);font-size:13px;line-height:20px}.ui-skillstats__nums{display:grid;grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:12px;margin:0}.ui-skillstats__num{display:grid;gap:2px;padding-top:8px;border-top:1px solid var(--gemboss-divider, #e5e7ea);min-width:0}.ui-skillstats__num dt{font-size:12px;line-height:16px;color:var(--gemboss-text-muted, #686b71)}.ui-skillstats__num dd{margin:0;font-size:22px;line-height:28px;font-weight:650;font-variant-numeric:tabular-nums}.ui-skillstats__last{margin:-8px 0 0;font-size:12px;color:var(--gemboss-text-muted, #686b71)}.ui-skillstats__sec{display:grid;gap:8px;min-width:0}.ui-skillstats__h{margin:0;font-size:12px;line-height:16px;font-weight:650;letter-spacing:.06em;text-transform:uppercase;color:var(--gemboss-text-muted, #686b71)}.ui-skillstats__one{margin:0;font-size:12px;color:var(--gemboss-text-muted, #686b71)}.ui-skillstats__legend,.ui-skillstats__outs{display:flex;flex-wrap:wrap;gap:4px 16px;margin:0;padding:0;list-style:none}.ui-skillstats__key,.ui-skillstats__out{display:inline-flex;align-items:center;gap:6px;font-size:12px}.ui-skillstats__key span,.ui-skillstats__out span{color:var(--gemboss-text-muted, #686b71);font-variant-numeric:tabular-nums}.ui-skillstats__key>i{width:8px;height:8px;border-radius:2px;background:var(--c)}.ui-skillstats__key--s1{--c: var(--ui-series-1, #5661f5)}.ui-skillstats__key--s2{--c: var(--ui-series-2, #0f9f8f)}.ui-skillstats__key--s3{--c: var(--ui-series-3, #d9822b)}.ui-skillstats__key--s4{--c: var(--ui-series-4, #c2417a)}.ui-skillstats__key--neutral{--c: var(--ui-text-muted, #686b71)}.ui-skillstats__out>i{width:7px;height:7px;box-sizing:border-box;border-radius:50%;border:1.5px solid var(--c);background:var(--c)}.ui-skillstats__out--done{--c: var(--gemboss-success, #007f5f)}.ui-skillstats__out--stopped{--c: var(--gemboss-chip-line, #cfd6ce)}.ui-skillstats__out--stopped>i{background:transparent}.ui-skillstats__out--blocked{--c: var(--gemboss-warning, #9a6700)}.ui-skillstats__out--error{--c: var(--gemboss-danger, #d72c0d)}.ui-skillstats__top{margin:0;font-size:12px;color:var(--gemboss-text-muted, #686b71)}.ui-skillstats__top code{padding:0 6px;border-radius:6px;font:600 11px/18px ui-monospace,SFMono-Regular,Menlo,monospace;background:var(--gemboss-primary-soft, #f2f3f5);color:var(--gemboss-text, #1b1c1e)}.ui-skillstats__vwrap{overflow-x:auto;max-width:100%}.ui-skillstats__versions{border-collapse:collapse;min-width:320px;width:100%;font-size:12px;font-variant-numeric:tabular-nums}.ui-skillstats__versions :is(th,td){padding:6px 10px;text-align:right;border-bottom:1px solid var(--gemboss-divider, #e5e7ea)}.ui-skillstats__versions :is(th,td):first-child{text-align:left;padding-left:0}.ui-skillstats__versions thead th{font-size:12px;font-weight:550;color:var(--gemboss-text-muted, #686b71)}.ui-skillstats__versions tbody th{font-weight:600}.ui-skillstats--empty{padding:20px;border:1px dashed var(--gemboss-divider, #e5e7ea);border-radius:12px}.ui-skillstats__empty{display:grid;gap:2px;margin:0}.ui-skillstats__empty b{font-size:14px;font-weight:600}.ui-skillstats__empty span{font-size:12px;color:var(--gemboss-text-muted, #686b71)}