Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
595 changes: 1 addition & 594 deletions plugin/skills/diagram-recipes/examples/agent-trace.component.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
{
"layout": "columns",
"panes": [
{
"title": "Algorithm",
"type": "markdown",
"content": "## Binary search — `O(log n)`\n\nFind a target in a **sorted** array by halving the search window each step.\n\n```ts\nfunction search(a: number[], t: number) {\n let lo = 0, hi = a.length - 1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (a[mid] === t) return mid; // hit\n if (a[mid] < t) lo = mid + 1; // go right\n else hi = mid - 1; // go left\n }\n return -1; // not found\n}\n```\n\nEach iteration discards half the remaining elements, so it finishes in at most\n`⌈log₂ n⌉` comparisons — 10 for a thousand items, 20 for a million."
},
{
"title": "Trace",
"type": "component",
"content": "{\"type\":\"Stack\",\"props\":{\"gap\":\"sm\",\"p\":\"sm\"},\"children\":[{\"type\":\"Title\",\"props\":{\"order\":4},\"children\":\"Trace — find 23\"},{\"type\":\"Text\",\"props\":{\"c\":\"dimmed\",\"size\":\"sm\",\"mt\":-4},\"children\":\"a = [2, 5, 8, 12, 16, 23, 38, 56, 72, 91]\"},{\"type\":\"Table\",\"props\":{\"withTableBorder\":true,\"withColumnBorders\":true,\"data\":{\"head\":[\"step\",\"lo\",\"hi\",\"mid\",\"a[mid]\",\"action\"],\"body\":[[\"1\",\"0\",\"9\",\"4\",\"16\",\"16 < 23 → go right\"],[\"2\",\"5\",\"9\",\"7\",\"56\",\"56 > 23 → go left\"],[\"3\",\"5\",\"6\",\"5\",\"23\",\"23 = 23 → found @ 5\"]]}}},{\"type\":\"Alert\",\"props\":{\"color\":\"green\",\"title\":\"Found at index 5 in 3 steps\"},\"children\":\"Linear scan would take 6 comparisons; binary search took 3 (⌈log₂ 10⌉ = 4 max).\"}]}"
},
{
"title": "Complexity",
"type": "vegalite",
"content": "{\"$schema\":\"https://vega.github.io/schema/vega-lite/v6.json\",\"title\":{\"text\":\"log n vs n\",\"subtitle\":\"comparisons to find one item\",\"anchor\":\"start\"},\"width\":\"container\",\"height\":300,\"data\":{\"values\":[{\"n\":1,\"ops\":0,\"kind\":\"binary search O(log n)\"},{\"n\":1,\"ops\":1,\"kind\":\"linear scan O(n)\"},{\"n\":8,\"ops\":3,\"kind\":\"binary search O(log n)\"},{\"n\":8,\"ops\":8,\"kind\":\"linear scan O(n)\"},{\"n\":16,\"ops\":4,\"kind\":\"binary search O(log n)\"},{\"n\":16,\"ops\":16,\"kind\":\"linear scan O(n)\"},{\"n\":32,\"ops\":5,\"kind\":\"binary search O(log n)\"},{\"n\":32,\"ops\":32,\"kind\":\"linear scan O(n)\"},{\"n\":64,\"ops\":6,\"kind\":\"binary search O(log n)\"},{\"n\":64,\"ops\":64,\"kind\":\"linear scan O(n)\"},{\"n\":128,\"ops\":7,\"kind\":\"binary search O(log n)\"},{\"n\":128,\"ops\":128,\"kind\":\"linear scan O(n)\"},{\"n\":256,\"ops\":8,\"kind\":\"binary search O(log n)\"},{\"n\":256,\"ops\":256,\"kind\":\"linear scan O(n)\"},{\"n\":512,\"ops\":9,\"kind\":\"binary search O(log n)\"},{\"n\":512,\"ops\":512,\"kind\":\"linear scan O(n)\"},{\"n\":1024,\"ops\":10,\"kind\":\"binary search O(log n)\"},{\"n\":1024,\"ops\":1024,\"kind\":\"linear scan O(n)\"}]},\"mark\":{\"type\":\"line\",\"point\":true,\"tooltip\":true},\"encoding\":{\"x\":{\"field\":\"n\",\"type\":\"quantitative\",\"title\":\"array size (n)\"},\"y\":{\"field\":\"ops\",\"type\":\"quantitative\",\"title\":\"comparisons\",\"scale\":{\"type\":\"symlog\"}},\"color\":{\"field\":\"kind\",\"type\":\"nominal\",\"title\":null,\"scale\":{\"range\":[\"#22c55e\",\"#ef4444\"]}}}}"
}
]
}
{"layout":"columns","panes":[{"title":"Algorithm","type":"markdown","content":"## Binary search — `O(log n)`\n\nFind a target in a **sorted** array by halving the search window each step.\n\n```ts\nfunction search(a: number[], t: number) {\n let lo = 0, hi = a.length - 1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (a[mid] === t) return mid; // hit\n if (a[mid] < t) lo = mid + 1; // go right\n else hi = mid - 1; // go left\n }\n return -1; // not found\n}\n```\n\nEach iteration discards half the remaining elements, so it finishes in at most\n`⌈log₂ n⌉` comparisons — 10 for a thousand items, 20 for a million."},{"title":"Trace","type":"component","content":"{\"type\":\"Stack\",\"props\":{\"gap\":\"sm\",\"p\":\"sm\"},\"children\":[{\"type\":\"Title\",\"props\":{\"order\":4},\"children\":\"Trace — find 23\"},{\"type\":\"Text\",\"props\":{\"c\":\"dimmed\",\"size\":\"sm\",\"mt\":-4},\"children\":\"a = [2, 5, 8, 12, 16, 23, 38, 56, 72, 91]\"},{\"type\":\"Table\",\"props\":{\"withTableBorder\":true,\"withColumnBorders\":true,\"data\":{\"head\":[\"step\",\"lo\",\"hi\",\"mid\",\"a[mid]\",\"action\"],\"body\":[[\"1\",\"0\",\"9\",\"4\",\"16\",\"16 < 23 → go right\"],[\"2\",\"5\",\"9\",\"7\",\"56\",\"56 > 23 → go left\"],[\"3\",\"5\",\"6\",\"5\",\"23\",\"23 = 23 → found @ 5\"]]}}},{\"type\":\"Alert\",\"props\":{\"color\":\"green\",\"title\":\"Found at index 5 in 3 steps\"},\"children\":\"Linear scan would take 6 comparisons; binary search took 3 (⌈log₂ 10⌉ = 4 max).\"}]}"},{"title":"Complexity","type":"vegalite","content":"{\"$schema\":\"https://vega.github.io/schema/vega-lite/v6.json\",\"title\":{\"text\":\"log n vs n\",\"subtitle\":\"comparisons to find one item\",\"anchor\":\"start\"},\"width\":\"container\",\"height\":300,\"data\":{\"values\":[{\"n\":1,\"ops\":0,\"kind\":\"binary search O(log n)\"},{\"n\":1,\"ops\":1,\"kind\":\"linear scan O(n)\"},{\"n\":8,\"ops\":3,\"kind\":\"binary search O(log n)\"},{\"n\":8,\"ops\":8,\"kind\":\"linear scan O(n)\"},{\"n\":16,\"ops\":4,\"kind\":\"binary search O(log n)\"},{\"n\":16,\"ops\":16,\"kind\":\"linear scan O(n)\"},{\"n\":32,\"ops\":5,\"kind\":\"binary search O(log n)\"},{\"n\":32,\"ops\":32,\"kind\":\"linear scan O(n)\"},{\"n\":64,\"ops\":6,\"kind\":\"binary search O(log n)\"},{\"n\":64,\"ops\":64,\"kind\":\"linear scan O(n)\"},{\"n\":128,\"ops\":7,\"kind\":\"binary search O(log n)\"},{\"n\":128,\"ops\":128,\"kind\":\"linear scan O(n)\"},{\"n\":256,\"ops\":8,\"kind\":\"binary search O(log n)\"},{\"n\":256,\"ops\":256,\"kind\":\"linear scan O(n)\"},{\"n\":512,\"ops\":9,\"kind\":\"binary search O(log n)\"},{\"n\":512,\"ops\":512,\"kind\":\"linear scan O(n)\"},{\"n\":1024,\"ops\":10,\"kind\":\"binary search O(log n)\"},{\"n\":1024,\"ops\":1024,\"kind\":\"linear scan O(n)\"}]},\"mark\":{\"type\":\"line\",\"point\":true,\"tooltip\":true},\"encoding\":{\"x\":{\"field\":\"n\",\"type\":\"quantitative\",\"title\":\"array size (n)\"},\"y\":{\"field\":\"ops\",\"type\":\"quantitative\",\"title\":\"comparisons\",\"scale\":{\"type\":\"symlog\"}},\"color\":{\"field\":\"kind\",\"type\":\"nominal\",\"title\":null,\"scale\":{\"range\":[\"#22c55e\",\"#ef4444\"]}}}}"}]}
Original file line number Diff line number Diff line change
@@ -1,50 +1 @@
{
"direction": "LR",
"groups": [
{ "id": "edge", "label": "Edge", "color": "#a1a1aa" },
{ "id": "frontend", "label": "Frontend", "color": "#60a5fa" },
{ "id": "services", "label": "Services", "color": "#fbbf24" },
{ "id": "data", "label": "Data stores", "color": "#22c55e" },
{ "id": "async", "label": "Async / streaming", "color": "#a855f7" }
],
"legend": [
{ "label": "request path", "color": "#a1a1aa" },
{ "label": "datastore write", "color": "#22c55e" },
{ "label": "event stream", "color": "#a855f7", "dash": true }
],
"nodes": [
{ "id": "client", "type": "change", "group": "edge", "data": { "label": "Client", "status": "info", "icon": "user" } },
{ "id": "cdn", "type": "change", "group": "edge", "data": { "label": "CDN", "status": "neutral" } },
{ "id": "lb", "type": "change", "group": "edge", "data": { "label": "Load Balancer", "status": "neutral" } },

{ "id": "web", "type": "change", "group": "frontend", "data": { "label": "Web App", "status": "info" } },
{ "id": "bff", "type": "change", "group": "frontend", "data": { "label": "BFF / Gateway", "status": "info" } },

{ "id": "auth", "type": "change", "group": "services", "data": { "label": "Auth", "status": "active" } },
{ "id": "orders", "type": "change", "group": "services", "data": { "label": "Orders", "status": "active" } },
{ "id": "inventory", "type": "change", "group": "services", "data": { "label": "Inventory", "status": "active" } },
{ "id": "payments", "type": "change", "group": "services", "data": { "label": "Payments", "status": "active" } },

{ "id": "pg", "type": "change", "group": "data", "data": { "label": "PostgreSQL", "status": "success", "icon": "db" } },
{ "id": "redis", "type": "change", "group": "data", "data": { "label": "Redis", "status": "warn", "icon": "db" } },

{ "id": "kafka", "type": "change", "group": "async", "data": { "label": "Kafka", "status": "info", "icon": "bolt" } },
{ "id": "worker", "type": "change", "group": "async", "data": { "label": "Fulfillment Worker", "status": "active" } }
],
"edges": [
{ "source": "client", "target": "cdn" },
{ "source": "cdn", "target": "lb" },
{ "source": "lb", "target": "web" },
{ "source": "web", "target": "bff" },
{ "source": "bff", "target": "auth" },
{ "source": "bff", "target": "orders" },
{ "source": "bff", "target": "inventory" },
{ "source": "bff", "target": "payments" },
{ "source": "auth", "target": "redis", "style": { "stroke": "#22c55e" }, "markerEnd": { "type": "arrowclosed", "color": "#22c55e" } },
{ "source": "orders", "target": "pg", "style": { "stroke": "#22c55e" }, "markerEnd": { "type": "arrowclosed", "color": "#22c55e" } },
{ "source": "inventory", "target": "pg", "style": { "stroke": "#22c55e" }, "markerEnd": { "type": "arrowclosed", "color": "#22c55e" } },
{ "source": "payments", "target": "pg", "style": { "stroke": "#22c55e" }, "markerEnd": { "type": "arrowclosed", "color": "#22c55e" } },
{ "source": "orders", "target": "kafka", "animated": true, "style": { "stroke": "#a855f7" }, "markerEnd": { "type": "arrowclosed", "color": "#a855f7" } },
{ "source": "kafka", "target": "worker", "animated": true, "style": { "stroke": "#a855f7" }, "markerEnd": { "type": "arrowclosed", "color": "#a855f7" } }
]
}
{"direction":"LR","groups":[{"id":"edge","label":"Edge","color":"#a1a1aa"},{"id":"frontend","label":"Frontend","color":"#60a5fa"},{"id":"services","label":"Services","color":"#fbbf24"},{"id":"data","label":"Data stores","color":"#22c55e"},{"id":"async","label":"Async / streaming","color":"#a855f7"}],"legend":[{"label":"request path","color":"#a1a1aa"},{"label":"datastore write","color":"#22c55e"},{"label":"event stream","color":"#a855f7","dash":true}],"nodes":[{"id":"client","type":"change","group":"edge","data":{"label":"Client","status":"info","icon":"user"}},{"id":"cdn","type":"change","group":"edge","data":{"label":"CDN","status":"neutral"}},{"id":"lb","type":"change","group":"edge","data":{"label":"Load Balancer","status":"neutral"}},{"id":"web","type":"change","group":"frontend","data":{"label":"Web App","status":"info"}},{"id":"bff","type":"change","group":"frontend","data":{"label":"BFF / Gateway","status":"info"}},{"id":"auth","type":"change","group":"services","data":{"label":"Auth","status":"active"}},{"id":"orders","type":"change","group":"services","data":{"label":"Orders","status":"active"}},{"id":"inventory","type":"change","group":"services","data":{"label":"Inventory","status":"active"}},{"id":"payments","type":"change","group":"services","data":{"label":"Payments","status":"active"}},{"id":"pg","type":"change","group":"data","data":{"label":"PostgreSQL","status":"success","icon":"db"}},{"id":"redis","type":"change","group":"data","data":{"label":"Redis","status":"warn","icon":"db"}},{"id":"kafka","type":"change","group":"async","data":{"label":"Kafka","status":"info","icon":"bolt"}},{"id":"worker","type":"change","group":"async","data":{"label":"Fulfillment Worker","status":"active"}}],"edges":[{"source":"client","target":"cdn"},{"source":"cdn","target":"lb"},{"source":"lb","target":"web"},{"source":"web","target":"bff"},{"source":"bff","target":"auth"},{"source":"bff","target":"orders"},{"source":"bff","target":"inventory"},{"source":"bff","target":"payments"},{"source":"auth","target":"redis","style":{"stroke":"#22c55e"},"markerEnd":{"type":"arrowclosed","color":"#22c55e"}},{"source":"orders","target":"pg","style":{"stroke":"#22c55e"},"markerEnd":{"type":"arrowclosed","color":"#22c55e"}},{"source":"inventory","target":"pg","style":{"stroke":"#22c55e"},"markerEnd":{"type":"arrowclosed","color":"#22c55e"}},{"source":"payments","target":"pg","style":{"stroke":"#22c55e"},"markerEnd":{"type":"arrowclosed","color":"#22c55e"}},{"source":"orders","target":"kafka","animated":true,"style":{"stroke":"#a855f7"},"markerEnd":{"type":"arrowclosed","color":"#a855f7"}},{"source":"kafka","target":"worker","animated":true,"style":{"stroke":"#a855f7"},"markerEnd":{"type":"arrowclosed","color":"#a855f7"}}]}
153 changes: 1 addition & 152 deletions plugin/skills/diagram-recipes/examples/before-after.component.json
Original file line number Diff line number Diff line change
@@ -1,152 +1 @@
{
"type": "Stack",
"props": {
"gap": "md",
"p": "md"
},
"children": [
{
"type": "Title",
"props": {
"order": 3
},
"children": "Refactor: auth module"
},
{
"type": "SimpleGrid",
"props": {
"cols": 2,
"spacing": "lg"
},
"children": [
{
"type": "Card",
"props": {
"withBorder": true,
"padding": "md"
},
"children": [
{
"type": "Group",
"props": {
"justify": "space-between"
},
"children": [
{
"type": "Text",
"props": {
"fw": 700
},
"children": "Before"
},
{
"type": "Badge",
"props": {
"color": "gray"
},
"children": "main@a1b2c3"
}
]
},
{
"type": "Table",
"props": {
"mt": "sm",
"data": {
"head": [
"Metric",
"Value"
],
"body": [
[
"LOC",
"412"
],
[
"Cyclomatic",
"37"
],
[
"Test cov.",
"61%"
],
[
"p95 latency",
"240ms"
]
]
}
}
}
]
},
{
"type": "Card",
"props": {
"withBorder": true,
"padding": "md"
},
"children": [
{
"type": "Group",
"props": {
"justify": "space-between"
},
"children": [
{
"type": "Text",
"props": {
"fw": 700
},
"children": "After"
},
{
"type": "Badge",
"props": {
"color": "green"
},
"children": "pr#214"
}
]
},
{
"type": "Table",
"props": {
"mt": "sm",
"data": {
"head": [
"Metric",
"Value",
"\u0394"
],
"body": [
[
"LOC",
"286",
"-126"
],
[
"Cyclomatic",
"18",
"-19"
],
[
"Test cov.",
"89%",
"+28%"
],
[
"p95 latency",
"150ms",
"-90ms"
]
]
}
}
}
]
}
]
}
]
}
{"type":"Stack","props":{"gap":"md","p":"md"},"children":[{"type":"Title","props":{"order":3},"children":"Refactor: auth module"},{"type":"SimpleGrid","props":{"cols":2,"spacing":"lg"},"children":[{"type":"Card","props":{"withBorder":true,"padding":"md"},"children":[{"type":"Group","props":{"justify":"space-between"},"children":[{"type":"Text","props":{"fw":700},"children":"Before"},{"type":"Badge","props":{"color":"gray"},"children":"main@a1b2c3"}]},{"type":"Table","props":{"mt":"sm","data":{"head":["Metric","Value"],"body":[["LOC","412"],["Cyclomatic","37"],["Test cov.","61%"],["p95 latency","240ms"]]}}}]},{"type":"Card","props":{"withBorder":true,"padding":"md"},"children":[{"type":"Group","props":{"justify":"space-between"},"children":[{"type":"Text","props":{"fw":700},"children":"After"},{"type":"Badge","props":{"color":"green"},"children":"pr#214"}]},{"type":"Table","props":{"mt":"sm","data":{"head":["Metric","Value","Δ"],"body":[["LOC","286","-126"],["Cyclomatic","18","-19"],["Test cov.","89%","+28%"],["p95 latency","150ms","-90ms"]]}}}]}]}]}
26 changes: 1 addition & 25 deletions plugin/skills/diagram-recipes/examples/bfs-traversal.flow.json
Original file line number Diff line number Diff line change
@@ -1,25 +1 @@
{
"direction": "TB",
"legend": [
{ "label": "start", "color": "#60a5fa" },
{ "label": "frontier (queued)", "color": "#fbbf24" },
{ "label": "visited", "color": "#22c55e" },
{ "label": "undiscovered", "color": "#52525b" }
],
"nodes": [
{ "id": "S", "type": "change", "data": { "label": "S", "status": "info", "sub": "start", "meta": "0" } },
{ "id": "A", "type": "change", "data": { "label": "A", "status": "success", "meta": "1" } },
{ "id": "B", "type": "change", "data": { "label": "B", "status": "active", "sub": "queued", "meta": "1" } },
{ "id": "C", "type": "change", "data": { "label": "C", "status": "active", "sub": "queued", "meta": "2" } },
{ "id": "D", "type": "change", "data": { "label": "D", "status": "active", "sub": "queued", "meta": "2" } },
{ "id": "E", "type": "change", "data": { "label": "E", "status": "neutral" } }
],
"edges": [
{ "source": "S", "target": "A", "markerEnd": { "type": "arrowclosed" } },
{ "source": "S", "target": "B", "markerEnd": { "type": "arrowclosed" } },
{ "source": "A", "target": "C", "markerEnd": { "type": "arrowclosed" } },
{ "source": "A", "target": "D", "markerEnd": { "type": "arrowclosed" } },
{ "source": "B", "target": "D", "markerEnd": { "type": "arrowclosed" } },
{ "source": "B", "target": "E", "markerEnd": { "type": "arrowclosed" } }
]
}
{"direction":"TB","legend":[{"label":"start","color":"#60a5fa"},{"label":"frontier (queued)","color":"#fbbf24"},{"label":"visited","color":"#22c55e"},{"label":"undiscovered","color":"#52525b"}],"nodes":[{"id":"S","type":"change","data":{"label":"S","status":"info","sub":"start","meta":"0"}},{"id":"A","type":"change","data":{"label":"A","status":"success","meta":"1"}},{"id":"B","type":"change","data":{"label":"B","status":"active","sub":"queued","meta":"1"}},{"id":"C","type":"change","data":{"label":"C","status":"active","sub":"queued","meta":"2"}},{"id":"D","type":"change","data":{"label":"D","status":"active","sub":"queued","meta":"2"}},{"id":"E","type":"change","data":{"label":"E","status":"neutral"}}],"edges":[{"source":"S","target":"A","markerEnd":{"type":"arrowclosed"}},{"source":"S","target":"B","markerEnd":{"type":"arrowclosed"}},{"source":"A","target":"C","markerEnd":{"type":"arrowclosed"}},{"source":"A","target":"D","markerEnd":{"type":"arrowclosed"}},{"source":"B","target":"D","markerEnd":{"type":"arrowclosed"}},{"source":"B","target":"E","markerEnd":{"type":"arrowclosed"}}]}
Loading
Loading