@webmcp-auto-ui/agent 2.5.26 → 2.5.27

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.
Files changed (36) hide show
  1. package/package.json +1 -1
  2. package/src/autoui-server.ts +27 -0
  3. package/src/index.ts +20 -6
  4. package/src/loop.ts +4 -12
  5. package/src/notebook-widgets/compact.ts +312 -0
  6. package/src/notebook-widgets/document.ts +372 -0
  7. package/src/notebook-widgets/editorial.ts +348 -0
  8. package/src/notebook-widgets/recipes/compact.md +104 -0
  9. package/src/notebook-widgets/recipes/document.md +100 -0
  10. package/src/notebook-widgets/recipes/editorial.md +104 -0
  11. package/src/notebook-widgets/recipes/workspace.md +94 -0
  12. package/src/notebook-widgets/shared.ts +1064 -0
  13. package/src/notebook-widgets/workspace.ts +328 -0
  14. package/src/prompts/claude-prompt-builder.ts +81 -0
  15. package/src/prompts/gemma4-prompt-builder.ts +205 -0
  16. package/src/prompts/index.ts +55 -0
  17. package/src/prompts/mistral-prompt-builder.ts +90 -0
  18. package/src/prompts/qwen-prompt-builder.ts +90 -0
  19. package/src/prompts/tool-call-parsers.ts +322 -0
  20. package/src/prompts/tool-refs.ts +196 -0
  21. package/src/providers/factory.ts +20 -3
  22. package/src/providers/transformers-models.ts +143 -0
  23. package/src/providers/transformers-serialize.ts +81 -0
  24. package/src/providers/transformers.ts +329 -0
  25. package/src/providers/transformers.worker.ts +667 -0
  26. package/src/providers/wasm.ts +132 -332
  27. package/src/recipes/_generated.ts +242 -0
  28. package/src/recipes/hackathon-assemblee-nationale.md +111 -0
  29. package/src/recipes/notebook-playbook.md +129 -0
  30. package/src/tool-layers.ts +7 -403
  31. package/src/trace-observer.ts +669 -0
  32. package/src/types.ts +17 -7
  33. package/src/util/opfs-cache.ts +265 -0
  34. package/tests/gemma-prompt.test.ts +472 -0
  35. package/tests/loop.test.ts +3 -3
  36. package/tests/transformers-serialize.test.ts +103 -0
@@ -928,6 +928,118 @@ component("gallery", {
928
928
  - **Forgetting to check** that the image field exists in the returned data (some Met Museum objects have no \`primaryImage\`)
929
929
  - **Using \`text\` to display URLs** instead of \`gallery\` — images must be rendered visually
930
930
  - **Not adapting the size**: iNaturalist returns "square" thumbnails by default — replace with "medium" or "large" in the URL
931
+ `,
932
+ 'hackathon-assemblee-nationale': `---
933
+ id: hackathon-assemblee-nationale-mcp-webmcp
934
+ name: Hackathon Assemblée Nationale · MCP & WebMCP starter
935
+ components_used: [notebook-document, notebook-compact]
936
+ when: the user mentions the Assemblée Nationale hackathon, wants to experiment with parliamentary data (Tricoteuses, Legifrance), or asks for a starter notebook to explore deputies, votes, amendments, or legislative texts in a hackathon context. Keywords include "hackathon Assemblée Nationale", "MCP WebMCP hackathon", "tricoteuses playbook", "parlement playground", "hackathon parlementaire".
937
+ servers: [autoui, tricoteuses]
938
+ layout:
939
+ type: single
940
+ ---
941
+
942
+ ## When to use
943
+
944
+ The user is participating in (or preparing for) the Assemblée Nationale hackathon around MCP and WebMCP. They want a ready-to-fork notebook with:
945
+ - A clear onboarding (what the hackathon is about, what data is available)
946
+ - Seed queries against Tricoteuses (parliamentary database) that return meaningful results immediately
947
+ - A visualization or transformation cell that the participant can iterate on
948
+ - A closing "your turn" note inviting them to modify, run, and share
949
+
950
+ This recipe is a **specialization** of the generic \`notebook-playbook\` recipe — pre-filled with parliamentary-specific seed cells and tailored to the hackathon narrative.
951
+
952
+ ## How to use
953
+
954
+ ### Step 1 — Pick the document layout
955
+
956
+ Default to \`notebook-document\` for the hackathon. Reasons:
957
+ - Participants expect to collaborate and leave traces for each other (avatars, comments)
958
+ - The document layout reads naturally as "hackathon brief + starter code" rather than "dev tool"
959
+ - Margin comments can be seeded to hint at directions to explore
960
+
961
+ If the participant asks for a minimal dev-focused playground instead, fall back to \`notebook-compact\`.
962
+
963
+ ### Step 2 — Seed the cells
964
+
965
+ The notebook should contain 5–7 cells covering:
966
+
967
+ 1. **Intro markdown** — title, one-line context of the hackathon, link to relevant docs
968
+ 2. **Challenge markdown** — a few axes of exploration suggested by the hackathon organizers (replace placeholders with actual challenges when known)
969
+ 3. **Starter SQL** — a safe, visibly meaningful query on Tricoteuses (e.g. recent votes, most active deputies, amendments on a specific text)
970
+ 4. **Transform JS** — a small JS cell that post-processes the SQL result (grouping, counting, chart prep)
971
+ 5. **Visualization hint** — a markdown cell pointing at available visualization widgets (\`hemicycle\`, \`profile\`, \`timeline\`)
972
+ 6. **Your turn** — a closing markdown inviting the participant to fork and edit
973
+
974
+ Example template (to be refined with actual hackathon organizers' briefs):
975
+
976
+ \`\`\`
977
+ widget_display({name: "notebook-document", params: {
978
+ title: "Hackathon Assemblée Nationale · starter",
979
+ cells: [
980
+ {
981
+ type: "md",
982
+ content: "### Bienvenue au hackathon IA de l'Assemblée Nationale\\n\\nCe notebook est votre point de départ. Les données parlementaires proviennent du serveur <mark>Tricoteuses</mark>. Forkez, éditez, partagez."
983
+ },
984
+ {
985
+ type: "md",
986
+ content: "### Pistes d'exploration\\n\\n- Profil d'un parlementaire et son activité\\n- Cartographie des votes par groupe politique\\n- Amendements sur un texte précis\\n- Enrichissement Wikipedia des parlementaires\\n- Croisement entre circonscription et données externes"
987
+ },
988
+ {
989
+ type: "sql",
990
+ content: "-- 10 scrutins les plus récents\\nSELECT id, date, intitule, pour, contre, abstention\\nFROM scrutins\\nORDER BY date DESC\\nLIMIT 10",
991
+ comment: {
992
+ who: "organizers",
993
+ when: "start",
994
+ body: "Remplacez par une requête sur un texte qui vous intéresse (LIMIT important)."
995
+ }
996
+ },
997
+ {
998
+ type: "js",
999
+ content: "// Regroupe les scrutins par mois\\nconst byMonth = {};\\nfor (const s of rows) {\\n const m = s.date.slice(0, 7);\\n byMonth[m] = (byMonth[m] || 0) + 1;\\n}\\nconsole.table(byMonth);"
1000
+ },
1001
+ {
1002
+ type: "md",
1003
+ content: "### Visualiser\\n\\nPour afficher un profil parlementaire : \`widget_display({name: \\"profile\\", params: {...}})\`.\\nPour un hémicycle : \`widget_display({name: \\"hemicycle\\", params: {groups, result}})\`.\\nPour une timeline de mandats : \`widget_display({name: \\"timeline\\", params: {events}})\`."
1004
+ },
1005
+ {
1006
+ type: "md",
1007
+ content: "### À vous\\n\\nAjoutez des cellules avec \`+ sql / + code\`, réarrangez, exécutez. Quand vous avez quelque chose d'intéressant, cliquez \`share\` pour partager le lien hyperskill avec votre équipe ou les organisateurs."
1008
+ }
1009
+ ]
1010
+ }})
1011
+ \`\`\`
1012
+
1013
+ ### Step 3 — Adapt to what the user knows
1014
+
1015
+ - If the user has no background in the Tricoteuses schema, mention they can use \`list_tables\` and \`describe_table\` on the Tricoteuses server to discover the data model before writing queries.
1016
+ - If the user already has a specific question ("I want to look at votes on the 2024 budget"), rewrite the starter SQL to target that question directly.
1017
+ - If the user asks for a minimal playground without the hackathon framing, fall back to the generic \`notebook-playbook\` recipe instead.
1018
+
1019
+ ### Step 4 — Share
1020
+
1021
+ After creating the notebook, remind the user that they can:
1022
+ - Use \`share\` → \`Hyperskill link\` to generate a fork-friendly URL to paste into their team's channel
1023
+ - Switch to \`view\` mode when demoing to organizers
1024
+ - Consult \`⟲ history\` to see their iteration trace and restore cells deleted by mistake
1025
+
1026
+ ## Notes
1027
+
1028
+ This recipe is intended as a **starting skeleton** — the concrete hackathon brief (dates, prizes, specific challenges, dataset access restrictions) will be refined in a dedicated session with the organizers. Placeholders in the example above (axes of exploration, comments) should be replaced with the actual material provided by the hackathon team when it is available.
1029
+
1030
+ For parliamentary profile pages, vote results with hemicycles, and legislative file browsing, prefer the dedicated recipes:
1031
+ - \`display-parliamentary-profile-with-hemicycle-and-votes\`
1032
+ - \`explorer-dossiers-legislatifs-parcours-texte\`
1033
+ - \`rechercher-textes-juridiques-legifrance\`
1034
+
1035
+ These recipes produce more specialized layouts than a generic notebook, and are better suited when the output is a single focused page rather than a multi-cell playbook.
1036
+
1037
+ ## Common mistakes
1038
+
1039
+ - **Forgetting the hackathon framing**: without the "bienvenue" and "à vous" markdown cells, participants land on a bare notebook and lose the playbook feeling.
1040
+ - **SQL without LIMIT**: Tricoteuses queries without \`LIMIT\` can return thousands of rows and slow down the first impression.
1041
+ - **Inventing data**: do not seed with fake French parliamentary content (fake deputies, fake votes). If the actual data is not known at seed time, use generic queries (\`SELECT * FROM scrutins LIMIT 5\`) and let the user discover from there.
1042
+ - **Picking the wrong layout**: if the user is solo and wants to code fast, \`notebook-compact\` is better than \`notebook-document\`. Default to document for hackathon context because of the collaborative framing, not as a hard rule.
931
1043
  `,
932
1044
  'hummingbird-data': `---
933
1045
  id: hummingbird-data
@@ -1017,6 +1129,136 @@ Phrase: "Salt crystals sing in the kettle at midnight."
1017
1129
  2. Chat: \`✅ hummingbird-middle followed — N7614\`
1018
1130
 
1019
1131
  Do NOT render any widget.
1132
+ `,
1133
+ 'notebook-playbook': `---
1134
+ id: create-interactive-notebook-playbook
1135
+ name: Create an interactive notebook playbook
1136
+ components_used: [notebook-compact, notebook-workspace, notebook-document, notebook-editorial]
1137
+ when: the user wants to experiment with data, prototype a small analysis, share a reusable scenario, let others fork and try a dataset, or prepare a hackathon-ready playground. Keywords include "playground", "playbook", "experiment", "try", "prototype", "hackathon", "share a notebook", "template", "starter".
1138
+ servers: [autoui]
1139
+ layout:
1140
+ type: single
1141
+ ---
1142
+
1143
+ ## When to use
1144
+
1145
+ The user asks for a **notebook-like interactive playground** that combines text, queries, and code cells. Typical triggers:
1146
+ - "Give me a playground for exploring X"
1147
+ - "Prepare a notebook I can share with my team"
1148
+ - "I want to prototype a small analysis"
1149
+ - "Set up a hackathon starter"
1150
+ - "Make a reusable template for exploring CSVs / this API / these tables"
1151
+
1152
+ This recipe applies across domains (parliamentary data, biodiversity, news, business datasets, etc.) — it only prescribes the **shape** of the answer, not its content.
1153
+
1154
+ ## How to use
1155
+
1156
+ ### Step 1 — Pick the right notebook layout
1157
+
1158
+ Choose one of the four \`notebook-*\` widgets based on the user's implicit intent:
1159
+
1160
+ | Layout | Use when |
1161
+ |---|---|
1162
+ | \`notebook-compact\` | Quick data exploration, reactive dataflow with named outputs, minimal chrome. **Default for most "playground" and "hackathon" requests.** |
1163
+ | \`notebook-workspace\` | The user expects a multi-cell analyst workspace with sources, cell navigation, and a "publish" step. Use when they mention "dashboard", "app", "workspace". |
1164
+ | \`notebook-document\` | The user plans to share and discuss with a team. Use when "collaborate", "review", "comment" appear. |
1165
+ | \`notebook-editorial\` | The user wants a polished, article-like final deliverable mixing prose and code. Use for "memo", "report", "writeup", "blog-style". |
1166
+
1167
+ When in doubt, pick \`notebook-compact\`.
1168
+
1169
+ ### Step 2 — Pre-fill the cells with context-aware seeds
1170
+
1171
+ Never create an empty notebook. Always seed with 3–5 cells that give the user an immediate starting point:
1172
+
1173
+ 1. **First cell: markdown** — title + one-sentence context of what the notebook is for
1174
+ 2. **Second cell: markdown or code** — if an MCP data source is connected, a starter query that returns something visible (e.g. \`SELECT * FROM {table} LIMIT 10\`). Otherwise a markdown cell describing the next step
1175
+ 3. **Third cell: code** — a transformation or a visualization that uses the output of step 2. Use \`varname\` on the SQL cell (\`varname: "rows"\`) and reference it in the JS cell
1176
+ 4. **Last cell: markdown** — a short "to you to play" note inviting the user to add cells, edit, or fork
1177
+
1178
+ Example seed for a generic data playground:
1179
+
1180
+ \`\`\`
1181
+ widget_display({name: "notebook-compact", params: {
1182
+ title: "Exploration playground",
1183
+ cells: [
1184
+ {type: "md", content: "### Exploration playground\\n\\nStart by running the first SQL cell, then iterate."},
1185
+ {type: "sql", content: "select * from source limit 10", varname: "rows"},
1186
+ {type: "js", content: "// explore rows here\\nconsole.table(rows)"},
1187
+ {type: "md", content: "### Your turn\\n\\nAdd cells with \`+ sql\` or \`+ js\`, reorder via the drag handle, and share via the header button."}
1188
+ ]
1189
+ }})
1190
+ \`\`\`
1191
+
1192
+ ### Step 3 — Adapt seeds to the connected MCP server
1193
+
1194
+ If a specific MCP server is connected, replace the generic \`source\` and \`select *\` placeholders with actual tables and queries from that server:
1195
+ - For a parliamentary server (Tricoteuses): use actual tables like \`acteurs\`, \`scrutins\`, \`amendements\` with meaningful LIMIT
1196
+ - For a biodiversity server (iNaturalist): use the server's typical queries to return observations
1197
+ - For a generic SQL server: list tables first (\`list_tables\` or \`describe_table\`), then seed with a \`SELECT * FROM {first_table} LIMIT 10\`
1198
+
1199
+ Always keep queries **short** and **limited** so the first run returns quickly and visually.
1200
+
1201
+ ### Step 4 — Share and fork
1202
+
1203
+ After creating the notebook, mention to the user that they can:
1204
+ - Click \`share\` in the toolbar to open the export modal (hyperskill link for in-session sharing, markdown/png/json for external export)
1205
+ - Switch to \`view\` mode (read-only, no controls visible) when presenting to someone
1206
+ - Access the \`⟲ history\` panel to see the trace of edits, and restore deleted cells
1207
+
1208
+ For hackathon contexts, prefer seeding a **document** layout (comments + avatars) so participants feel they are joining a shared space.
1209
+
1210
+ ## Examples
1211
+
1212
+ ### Generic CSV / table playground
1213
+ \`\`\`
1214
+ // user: "I need a playground to play with this CSV"
1215
+ widget_display({name: "notebook-compact", params: {
1216
+ title: "CSV playground",
1217
+ cells: [
1218
+ {type: "md", content: "### CSV playground\\n\\nRun the SQL cell to see the first rows, then iterate."},
1219
+ {type: "sql", content: "select * from source limit 20", varname: "rows"},
1220
+ {type: "js", content: "// summarize, chart, or filter rows here"}
1221
+ ]
1222
+ }})
1223
+ \`\`\`
1224
+
1225
+ ### Collaborative analysis
1226
+ \`\`\`
1227
+ // user: "Set up a notebook my team can edit together"
1228
+ widget_display({name: "notebook-document", params: {
1229
+ title: "Team analysis",
1230
+ cells: [
1231
+ {type: "md", content: "Kick-off: describe the question here."},
1232
+ {type: "sql", content: "select * from source limit 10"},
1233
+ {type: "md", content: "Your findings: add thoughts, highlights (<mark>key sentence</mark>), and comments on the code cells above."}
1234
+ ]
1235
+ }})
1236
+ \`\`\`
1237
+
1238
+ ### Final memo
1239
+ \`\`\`
1240
+ // user: "Prepare a short memo of my findings"
1241
+ widget_display({name: "notebook-editorial", params: {
1242
+ title: "Findings memo",
1243
+ kicker: "memo",
1244
+ cells: [
1245
+ {type: "md", content: "Three observations from last week's data."},
1246
+ {type: "md", content: "First, the volume is up. Here is the query:"},
1247
+ {type: "sql", content: "select count(*) from source"},
1248
+ {type: "md", content: "Second, the distribution has shifted."},
1249
+ {type: "js", content: "// chart distribution"},
1250
+ {type: "md", content: "We conclude that..."}
1251
+ ]
1252
+ }})
1253
+ \`\`\`
1254
+
1255
+ ## Common mistakes
1256
+
1257
+ - **Empty notebook**: never call \`widget_display\` without at least 3 seed cells. The user expects something they can immediately run.
1258
+ - **Wrong layout for the intent**: do not use \`notebook-editorial\` for quick exploration — it signals "finished article" and intimidates. Use \`notebook-compact\` unless the user explicitly asks for a publication feel.
1259
+ - **Heavy initial queries**: always \`LIMIT 10\` or \`LIMIT 20\` in seed SQL cells. Users will expand later if needed.
1260
+ - **Missing \`varname\` on SQL cells** (in compact layout): the named output is what the compact layout showcases. Without it, the notebook loses half its reactive story.
1261
+ - **Inventing UUIDs or fork IDs**: leave \`id\` and \`forkId\` unset — the widget generates sensible defaults. Only pass \`id\` when restoring an existing notebook.
1020
1262
  `,
1021
1263
  'parlementaire-profile': `---
1022
1264
  id: display-parliamentary-profile-with-hemicycle-and-votes
@@ -0,0 +1,111 @@
1
+ ---
2
+ id: hackathon-assemblee-nationale-mcp-webmcp
3
+ name: Hackathon Assemblée Nationale · MCP & WebMCP starter
4
+ components_used: [notebook-document, notebook-compact]
5
+ when: the user mentions the Assemblée Nationale hackathon, wants to experiment with parliamentary data (Tricoteuses, Legifrance), or asks for a starter notebook to explore deputies, votes, amendments, or legislative texts in a hackathon context. Keywords include "hackathon Assemblée Nationale", "MCP WebMCP hackathon", "tricoteuses playbook", "parlement playground", "hackathon parlementaire".
6
+ servers: [autoui, tricoteuses]
7
+ layout:
8
+ type: single
9
+ ---
10
+
11
+ ## When to use
12
+
13
+ The user is participating in (or preparing for) the Assemblée Nationale hackathon around MCP and WebMCP. They want a ready-to-fork notebook with:
14
+ - A clear onboarding (what the hackathon is about, what data is available)
15
+ - Seed queries against Tricoteuses (parliamentary database) that return meaningful results immediately
16
+ - A visualization or transformation cell that the participant can iterate on
17
+ - A closing "your turn" note inviting them to modify, run, and share
18
+
19
+ This recipe is a **specialization** of the generic `notebook-playbook` recipe — pre-filled with parliamentary-specific seed cells and tailored to the hackathon narrative.
20
+
21
+ ## How to use
22
+
23
+ ### Step 1 — Pick the document layout
24
+
25
+ Default to `notebook-document` for the hackathon. Reasons:
26
+ - Participants expect to collaborate and leave traces for each other (avatars, comments)
27
+ - The document layout reads naturally as "hackathon brief + starter code" rather than "dev tool"
28
+ - Margin comments can be seeded to hint at directions to explore
29
+
30
+ If the participant asks for a minimal dev-focused playground instead, fall back to `notebook-compact`.
31
+
32
+ ### Step 2 — Seed the cells
33
+
34
+ The notebook should contain 5–7 cells covering:
35
+
36
+ 1. **Intro markdown** — title, one-line context of the hackathon, link to relevant docs
37
+ 2. **Challenge markdown** — a few axes of exploration suggested by the hackathon organizers (replace placeholders with actual challenges when known)
38
+ 3. **Starter SQL** — a safe, visibly meaningful query on Tricoteuses (e.g. recent votes, most active deputies, amendments on a specific text)
39
+ 4. **Transform JS** — a small JS cell that post-processes the SQL result (grouping, counting, chart prep)
40
+ 5. **Visualization hint** — a markdown cell pointing at available visualization widgets (`hemicycle`, `profile`, `timeline`)
41
+ 6. **Your turn** — a closing markdown inviting the participant to fork and edit
42
+
43
+ Example template (to be refined with actual hackathon organizers' briefs):
44
+
45
+ ```
46
+ widget_display({name: "notebook-document", params: {
47
+ title: "Hackathon Assemblée Nationale · starter",
48
+ cells: [
49
+ {
50
+ type: "md",
51
+ content: "### Bienvenue au hackathon IA de l'Assemblée Nationale\n\nCe notebook est votre point de départ. Les données parlementaires proviennent du serveur <mark>Tricoteuses</mark>. Forkez, éditez, partagez."
52
+ },
53
+ {
54
+ type: "md",
55
+ content: "### Pistes d'exploration\n\n- Profil d'un parlementaire et son activité\n- Cartographie des votes par groupe politique\n- Amendements sur un texte précis\n- Enrichissement Wikipedia des parlementaires\n- Croisement entre circonscription et données externes"
56
+ },
57
+ {
58
+ type: "sql",
59
+ content: "-- 10 scrutins les plus récents\nSELECT id, date, intitule, pour, contre, abstention\nFROM scrutins\nORDER BY date DESC\nLIMIT 10",
60
+ comment: {
61
+ who: "organizers",
62
+ when: "start",
63
+ body: "Remplacez par une requête sur un texte qui vous intéresse (LIMIT important)."
64
+ }
65
+ },
66
+ {
67
+ type: "js",
68
+ content: "// Regroupe les scrutins par mois\nconst byMonth = {};\nfor (const s of rows) {\n const m = s.date.slice(0, 7);\n byMonth[m] = (byMonth[m] || 0) + 1;\n}\nconsole.table(byMonth);"
69
+ },
70
+ {
71
+ type: "md",
72
+ content: "### Visualiser\n\nPour afficher un profil parlementaire : `widget_display({name: \"profile\", params: {...}})`.\nPour un hémicycle : `widget_display({name: \"hemicycle\", params: {groups, result}})`.\nPour une timeline de mandats : `widget_display({name: \"timeline\", params: {events}})`."
73
+ },
74
+ {
75
+ type: "md",
76
+ content: "### À vous\n\nAjoutez des cellules avec `+ sql / + code`, réarrangez, exécutez. Quand vous avez quelque chose d'intéressant, cliquez `share` pour partager le lien hyperskill avec votre équipe ou les organisateurs."
77
+ }
78
+ ]
79
+ }})
80
+ ```
81
+
82
+ ### Step 3 — Adapt to what the user knows
83
+
84
+ - If the user has no background in the Tricoteuses schema, mention they can use `list_tables` and `describe_table` on the Tricoteuses server to discover the data model before writing queries.
85
+ - If the user already has a specific question ("I want to look at votes on the 2024 budget"), rewrite the starter SQL to target that question directly.
86
+ - If the user asks for a minimal playground without the hackathon framing, fall back to the generic `notebook-playbook` recipe instead.
87
+
88
+ ### Step 4 — Share
89
+
90
+ After creating the notebook, remind the user that they can:
91
+ - Use `share` → `Hyperskill link` to generate a fork-friendly URL to paste into their team's channel
92
+ - Switch to `view` mode when demoing to organizers
93
+ - Consult `⟲ history` to see their iteration trace and restore cells deleted by mistake
94
+
95
+ ## Notes
96
+
97
+ This recipe is intended as a **starting skeleton** — the concrete hackathon brief (dates, prizes, specific challenges, dataset access restrictions) will be refined in a dedicated session with the organizers. Placeholders in the example above (axes of exploration, comments) should be replaced with the actual material provided by the hackathon team when it is available.
98
+
99
+ For parliamentary profile pages, vote results with hemicycles, and legislative file browsing, prefer the dedicated recipes:
100
+ - `display-parliamentary-profile-with-hemicycle-and-votes`
101
+ - `explorer-dossiers-legislatifs-parcours-texte`
102
+ - `rechercher-textes-juridiques-legifrance`
103
+
104
+ These recipes produce more specialized layouts than a generic notebook, and are better suited when the output is a single focused page rather than a multi-cell playbook.
105
+
106
+ ## Common mistakes
107
+
108
+ - **Forgetting the hackathon framing**: without the "bienvenue" and "à vous" markdown cells, participants land on a bare notebook and lose the playbook feeling.
109
+ - **SQL without LIMIT**: Tricoteuses queries without `LIMIT` can return thousands of rows and slow down the first impression.
110
+ - **Inventing data**: do not seed with fake French parliamentary content (fake deputies, fake votes). If the actual data is not known at seed time, use generic queries (`SELECT * FROM scrutins LIMIT 5`) and let the user discover from there.
111
+ - **Picking the wrong layout**: if the user is solo and wants to code fast, `notebook-compact` is better than `notebook-document`. Default to document for hackathon context because of the collaborative framing, not as a hard rule.
@@ -0,0 +1,129 @@
1
+ ---
2
+ id: create-interactive-notebook-playbook
3
+ name: Create an interactive notebook playbook
4
+ components_used: [notebook-compact, notebook-workspace, notebook-document, notebook-editorial]
5
+ when: the user wants to experiment with data, prototype a small analysis, share a reusable scenario, let others fork and try a dataset, or prepare a hackathon-ready playground. Keywords include "playground", "playbook", "experiment", "try", "prototype", "hackathon", "share a notebook", "template", "starter".
6
+ servers: [autoui]
7
+ layout:
8
+ type: single
9
+ ---
10
+
11
+ ## When to use
12
+
13
+ The user asks for a **notebook-like interactive playground** that combines text, queries, and code cells. Typical triggers:
14
+ - "Give me a playground for exploring X"
15
+ - "Prepare a notebook I can share with my team"
16
+ - "I want to prototype a small analysis"
17
+ - "Set up a hackathon starter"
18
+ - "Make a reusable template for exploring CSVs / this API / these tables"
19
+
20
+ This recipe applies across domains (parliamentary data, biodiversity, news, business datasets, etc.) — it only prescribes the **shape** of the answer, not its content.
21
+
22
+ ## How to use
23
+
24
+ ### Step 1 — Pick the right notebook layout
25
+
26
+ Choose one of the four `notebook-*` widgets based on the user's implicit intent:
27
+
28
+ | Layout | Use when |
29
+ |---|---|
30
+ | `notebook-compact` | Quick data exploration, reactive dataflow with named outputs, minimal chrome. **Default for most "playground" and "hackathon" requests.** |
31
+ | `notebook-workspace` | The user expects a multi-cell analyst workspace with sources, cell navigation, and a "publish" step. Use when they mention "dashboard", "app", "workspace". |
32
+ | `notebook-document` | The user plans to share and discuss with a team. Use when "collaborate", "review", "comment" appear. |
33
+ | `notebook-editorial` | The user wants a polished, article-like final deliverable mixing prose and code. Use for "memo", "report", "writeup", "blog-style". |
34
+
35
+ When in doubt, pick `notebook-compact`.
36
+
37
+ ### Step 2 — Pre-fill the cells with context-aware seeds
38
+
39
+ Never create an empty notebook. Always seed with 3–5 cells that give the user an immediate starting point:
40
+
41
+ 1. **First cell: markdown** — title + one-sentence context of what the notebook is for
42
+ 2. **Second cell: markdown or code** — if an MCP data source is connected, a starter query that returns something visible (e.g. `SELECT * FROM {table} LIMIT 10`). Otherwise a markdown cell describing the next step
43
+ 3. **Third cell: code** — a transformation or a visualization that uses the output of step 2. Use `varname` on the SQL cell (`varname: "rows"`) and reference it in the JS cell
44
+ 4. **Last cell: markdown** — a short "to you to play" note inviting the user to add cells, edit, or fork
45
+
46
+ Example seed for a generic data playground:
47
+
48
+ ```
49
+ widget_display({name: "notebook-compact", params: {
50
+ title: "Exploration playground",
51
+ cells: [
52
+ {type: "md", content: "### Exploration playground\n\nStart by running the first SQL cell, then iterate."},
53
+ {type: "sql", content: "select * from source limit 10", varname: "rows"},
54
+ {type: "js", content: "// explore rows here\nconsole.table(rows)"},
55
+ {type: "md", content: "### Your turn\n\nAdd cells with `+ sql` or `+ js`, reorder via the drag handle, and share via the header button."}
56
+ ]
57
+ }})
58
+ ```
59
+
60
+ ### Step 3 — Adapt seeds to the connected MCP server
61
+
62
+ If a specific MCP server is connected, replace the generic `source` and `select *` placeholders with actual tables and queries from that server:
63
+ - For a parliamentary server (Tricoteuses): use actual tables like `acteurs`, `scrutins`, `amendements` with meaningful LIMIT
64
+ - For a biodiversity server (iNaturalist): use the server's typical queries to return observations
65
+ - For a generic SQL server: list tables first (`list_tables` or `describe_table`), then seed with a `SELECT * FROM {first_table} LIMIT 10`
66
+
67
+ Always keep queries **short** and **limited** so the first run returns quickly and visually.
68
+
69
+ ### Step 4 — Share and fork
70
+
71
+ After creating the notebook, mention to the user that they can:
72
+ - Click `share` in the toolbar to open the export modal (hyperskill link for in-session sharing, markdown/png/json for external export)
73
+ - Switch to `view` mode (read-only, no controls visible) when presenting to someone
74
+ - Access the `⟲ history` panel to see the trace of edits, and restore deleted cells
75
+
76
+ For hackathon contexts, prefer seeding a **document** layout (comments + avatars) so participants feel they are joining a shared space.
77
+
78
+ ## Examples
79
+
80
+ ### Generic CSV / table playground
81
+ ```
82
+ // user: "I need a playground to play with this CSV"
83
+ widget_display({name: "notebook-compact", params: {
84
+ title: "CSV playground",
85
+ cells: [
86
+ {type: "md", content: "### CSV playground\n\nRun the SQL cell to see the first rows, then iterate."},
87
+ {type: "sql", content: "select * from source limit 20", varname: "rows"},
88
+ {type: "js", content: "// summarize, chart, or filter rows here"}
89
+ ]
90
+ }})
91
+ ```
92
+
93
+ ### Collaborative analysis
94
+ ```
95
+ // user: "Set up a notebook my team can edit together"
96
+ widget_display({name: "notebook-document", params: {
97
+ title: "Team analysis",
98
+ cells: [
99
+ {type: "md", content: "Kick-off: describe the question here."},
100
+ {type: "sql", content: "select * from source limit 10"},
101
+ {type: "md", content: "Your findings: add thoughts, highlights (<mark>key sentence</mark>), and comments on the code cells above."}
102
+ ]
103
+ }})
104
+ ```
105
+
106
+ ### Final memo
107
+ ```
108
+ // user: "Prepare a short memo of my findings"
109
+ widget_display({name: "notebook-editorial", params: {
110
+ title: "Findings memo",
111
+ kicker: "memo",
112
+ cells: [
113
+ {type: "md", content: "Three observations from last week's data."},
114
+ {type: "md", content: "First, the volume is up. Here is the query:"},
115
+ {type: "sql", content: "select count(*) from source"},
116
+ {type: "md", content: "Second, the distribution has shifted."},
117
+ {type: "js", content: "// chart distribution"},
118
+ {type: "md", content: "We conclude that..."}
119
+ ]
120
+ }})
121
+ ```
122
+
123
+ ## Common mistakes
124
+
125
+ - **Empty notebook**: never call `widget_display` without at least 3 seed cells. The user expects something they can immediately run.
126
+ - **Wrong layout for the intent**: do not use `notebook-editorial` for quick exploration — it signals "finished article" and intimidates. Use `notebook-compact` unless the user explicitly asks for a publication feel.
127
+ - **Heavy initial queries**: always `LIMIT 10` or `LIMIT 20` in seed SQL cells. Users will expand later if needed.
128
+ - **Missing `varname` on SQL cells** (in compact layout): the named output is what the compact layout showcases. Without it, the notebook loses half its reactive story.
129
+ - **Inventing UUIDs or fork IDs**: leave `id` and `forkId` unset — the widget generates sensible defaults. Only pass `id` when restoring an existing notebook.