@mechane-ai/elements 0.46.0 → 0.48.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.
Files changed (419) hide show
  1. package/README.md +590 -34
  2. package/bin/mechane-elements-catalog.mjs +104 -12
  3. package/dist/ai.js +4 -4
  4. package/dist/article-BXZr10QQ.js +1904 -0
  5. package/dist/article.js +1 -0
  6. package/dist/catalog.json +3696 -33
  7. package/dist/categorical-values-BpVq8cFj.js +107 -0
  8. package/dist/cells-xVmnQ9oQ.js +384 -0
  9. package/dist/chart-link-AE_xuxiP.js +35 -0
  10. package/dist/chart-tones-ei3BC2AL.js +27 -0
  11. package/dist/charts/cartesian.js +1 -2958
  12. package/dist/charts/cells.js +1 -0
  13. package/dist/charts/comparison.js +1 -0
  14. package/dist/charts/distribution.js +1 -781
  15. package/dist/charts/figure.js +3404 -0
  16. package/dist/charts/graph.js +1 -655
  17. package/dist/charts/hierarchy.js +1 -121
  18. package/dist/charts/image.js +1 -0
  19. package/dist/charts/matrix.js +4 -644
  20. package/dist/charts/plot.js +15 -0
  21. package/dist/charts/relationship.js +1 -0
  22. package/dist/charts/text.js +1 -0
  23. package/dist/charts/timeline.js +1 -266
  24. package/dist/charts/transforms.js +677 -0
  25. package/dist/charts/trend.js +1 -0
  26. package/dist/charts.js +8 -3
  27. package/dist/clock-DSm5lkNE.js +16 -0
  28. package/dist/collections.js +1 -2195
  29. package/dist/color-legend-CIo7DhXB.js +62 -0
  30. package/dist/dates-Cww8UR_n.js +810 -0
  31. package/dist/describe-lesson-BmREzDpt.js +175 -0
  32. package/dist/dumbbell-plot-DQdTxDeO.js +509 -0
  33. package/dist/embedding-map-CF-J-8JW.js +1929 -0
  34. package/dist/feedback.js +1 -1
  35. package/dist/figure-format-B8kRZMlo.js +36 -0
  36. package/dist/figure-frame-BJ3REgTA.js +270 -0
  37. package/dist/forms/dates.js +1 -810
  38. package/dist/forms.js +1 -1
  39. package/dist/heatmap-scale-Zte6Ya-g.js +20 -0
  40. package/dist/image-grid-Dl2sjIMB.js +598 -0
  41. package/dist/kits/evaluation.js +431 -0
  42. package/dist/kits/interpretability.js +1033 -0
  43. package/dist/kits/operations.js +239 -0
  44. package/dist/kits/training.js +335 -0
  45. package/dist/label-place-Z0fryBZb.js +42 -0
  46. package/dist/lesson/agent.js +811 -0
  47. package/dist/lesson/spec.js +661 -0
  48. package/dist/lesson.js +5 -0
  49. package/dist/locate-Bcg3QcP4.js +11 -0
  50. package/dist/mdx.js +227 -0
  51. package/dist/packages/charts/src/cartesian/bar-chart.d.ts +40 -21
  52. package/dist/packages/charts/src/cartesian/bar-data.d.ts +15 -4
  53. package/dist/packages/charts/src/cartesian/bar-overlays.d.ts +7 -3
  54. package/dist/packages/charts/src/cartesian/breakdown-bar.d.ts +10 -8
  55. package/dist/packages/charts/src/cartesian/bridge-chart.d.ts +20 -16
  56. package/dist/packages/charts/src/cartesian/bridge-data.d.ts +5 -4
  57. package/dist/packages/charts/src/cartesian/composition-bars.d.ts +8 -4
  58. package/dist/packages/charts/src/cartesian/index.d.ts +5 -5
  59. package/dist/packages/charts/src/cartesian/reference-lines.d.ts +25 -18
  60. package/dist/packages/charts/src/cartesian/scatter-plot.d.ts +30 -25
  61. package/dist/packages/charts/src/cartesian/sparkline.d.ts +14 -2
  62. package/dist/packages/charts/src/cartesian/time-series-bands.d.ts +3 -2
  63. package/dist/packages/charts/src/cartesian/time-series-data.d.ts +12 -2
  64. package/dist/packages/charts/src/cartesian/time-series-line.d.ts +2 -2
  65. package/dist/packages/charts/src/cartesian/time-series-overlays.d.ts +6 -4
  66. package/dist/packages/charts/src/cartesian/time-series.d.ts +60 -36
  67. package/dist/packages/charts/src/cartesian/value-labels.d.ts +22 -0
  68. package/dist/packages/charts/src/categorical-values.d.ts +1 -1
  69. package/dist/packages/charts/src/cells/bar-cell.d.ts +13 -0
  70. package/dist/packages/charts/src/cells/cell-layout.d.ts +81 -0
  71. package/dist/packages/charts/src/cells/change-cell.d.ts +17 -0
  72. package/dist/packages/charts/src/cells/heat-cell.d.ts +19 -0
  73. package/dist/packages/charts/src/cells/index.d.ts +11 -0
  74. package/dist/packages/charts/src/cells/interval-cell.d.ts +16 -0
  75. package/dist/packages/charts/src/cells/spark-cell.d.ts +22 -0
  76. package/dist/packages/charts/src/chart-frame.d.ts +14 -7
  77. package/dist/packages/charts/src/chart-grid.d.ts +19 -0
  78. package/dist/packages/charts/src/chart-input.d.ts +1 -9
  79. package/dist/packages/charts/src/chart-link.d.ts +56 -0
  80. package/dist/packages/charts/src/chart.d.ts +0 -8
  81. package/dist/packages/charts/src/comparison/bullet-bar.d.ts +34 -0
  82. package/dist/packages/charts/src/comparison/comparison-plot.d.ts +54 -0
  83. package/dist/packages/charts/src/comparison/dot-plot.d.ts +41 -0
  84. package/dist/packages/charts/src/comparison/dumbbell-plot.d.ts +33 -0
  85. package/dist/packages/charts/src/comparison/index.d.ts +6 -0
  86. package/dist/packages/charts/src/distribution/box-plot.d.ts +40 -0
  87. package/dist/packages/charts/src/distribution/distribution-input.d.ts +5 -3
  88. package/dist/packages/charts/src/distribution/distribution-plot.d.ts +28 -161
  89. package/dist/packages/charts/src/distribution/ecdf.d.ts +16 -15
  90. package/dist/packages/charts/src/distribution/group-plot-input.d.ts +35 -0
  91. package/dist/packages/charts/src/distribution/group-plot-layout.d.ts +79 -0
  92. package/dist/packages/charts/src/distribution/group-plot.d.ts +73 -0
  93. package/dist/packages/charts/src/distribution/histogram.d.ts +16 -16
  94. package/dist/packages/charts/src/distribution/index.d.ts +11 -0
  95. package/dist/packages/charts/src/distribution/interval-plot.d.ts +16 -13
  96. package/dist/packages/charts/src/distribution/ranked-bars.d.ts +17 -14
  97. package/dist/packages/charts/src/distribution/ridgeline.d.ts +34 -0
  98. package/dist/packages/charts/src/distribution/strip-plot.d.ts +37 -0
  99. package/dist/packages/charts/src/distribution/violin-plot.d.ts +34 -0
  100. package/dist/packages/charts/src/figure/figure-format.d.ts +34 -0
  101. package/dist/packages/charts/src/figure/figure-frame.d.ts +47 -0
  102. package/dist/packages/charts/src/figure/figure-props.d.ts +54 -0
  103. package/dist/packages/charts/src/figure/tone-scope.d.ts +32 -0
  104. package/dist/packages/charts/src/graph/attribution-graph.d.ts +62 -0
  105. package/dist/packages/charts/src/graph/attribution-layout.d.ts +88 -0
  106. package/dist/packages/charts/src/graph/flow-diagram.d.ts +14 -15
  107. package/dist/packages/charts/src/graph/flow-layout.d.ts +4 -2
  108. package/dist/packages/charts/src/graph/graph-canvas.d.ts +33 -0
  109. package/dist/packages/charts/src/graph/index.d.ts +6 -2
  110. package/dist/packages/charts/src/graph/relation-graph.d.ts +24 -13
  111. package/dist/packages/charts/src/graph/tree-diagram.d.ts +41 -0
  112. package/dist/packages/charts/src/graph/tree-layout.d.ts +71 -0
  113. package/dist/packages/charts/src/hierarchy/area-mark.d.ts +17 -0
  114. package/dist/packages/charts/src/hierarchy/icicle.d.ts +35 -0
  115. package/dist/packages/charts/src/hierarchy/index.d.ts +2 -0
  116. package/dist/packages/charts/src/hierarchy/partition-layout.d.ts +25 -0
  117. package/dist/packages/charts/src/hierarchy/treemap-layout.d.ts +26 -0
  118. package/dist/packages/charts/src/hierarchy/treemap.d.ts +11 -9
  119. package/dist/packages/charts/src/image/attribution-legend.d.ts +13 -0
  120. package/dist/packages/charts/src/image/attribution-overlay.d.ts +50 -0
  121. package/dist/packages/charts/src/image/attribution-ramp.d.ts +16 -0
  122. package/dist/packages/charts/src/image/image-atlas.d.ts +37 -0
  123. package/dist/packages/charts/src/image/image-fill.d.ts +9 -0
  124. package/dist/packages/charts/src/image/image-grid.d.ts +26 -0
  125. package/dist/packages/charts/src/image/image-input.d.ts +27 -0
  126. package/dist/packages/charts/src/image/image-tile.d.ts +27 -0
  127. package/dist/packages/charts/src/image/index.d.ts +7 -0
  128. package/dist/packages/charts/src/index.d.ts +15 -1
  129. package/dist/packages/charts/src/matrix/attention-matrix.d.ts +41 -0
  130. package/dist/packages/charts/src/matrix/calendar-heatmap.d.ts +37 -0
  131. package/dist/packages/charts/src/matrix/color-legend.d.ts +9 -2
  132. package/dist/packages/charts/src/matrix/confusion-matrix.d.ts +36 -0
  133. package/dist/packages/charts/src/matrix/correlation-matrix.d.ts +34 -0
  134. package/dist/packages/charts/src/matrix/heatmap-scale.d.ts +8 -2
  135. package/dist/packages/charts/src/matrix/index.d.ts +15 -3
  136. package/dist/packages/charts/src/matrix/matrix-cells.d.ts +27 -3
  137. package/dist/packages/charts/src/matrix/matrix-figure.d.ts +50 -0
  138. package/dist/packages/charts/src/matrix/matrix-mark.d.ts +34 -0
  139. package/dist/packages/charts/src/matrix/matrix-presets.d.ts +20 -0
  140. package/dist/packages/charts/src/matrix/matrix-range.d.ts +45 -0
  141. package/dist/packages/charts/src/matrix/matrix-strip.d.ts +13 -14
  142. package/dist/packages/charts/src/matrix/matrix-types.d.ts +40 -0
  143. package/dist/packages/charts/src/matrix/matrix.d.ts +13 -11
  144. package/dist/packages/charts/src/matrix/token-heatmap.d.ts +16 -10
  145. package/dist/packages/charts/src/plot/contours.d.ts +45 -0
  146. package/dist/packages/charts/src/plot/index.d.ts +49 -0
  147. package/dist/packages/charts/src/plot/label-place.d.ts +35 -0
  148. package/dist/packages/charts/src/plot/locate.d.ts +18 -0
  149. package/dist/packages/charts/src/plot/path.d.ts +39 -0
  150. package/dist/packages/charts/src/plot/plot-axes.d.ts +20 -0
  151. package/dist/packages/charts/src/plot/plot-layout.d.ts +221 -0
  152. package/dist/packages/charts/src/plot/plot-marks.d.ts +128 -0
  153. package/dist/packages/charts/src/plot/plot-surface.d.ts +32 -0
  154. package/dist/packages/charts/src/plot/render/density-layer.d.ts +17 -0
  155. package/dist/packages/charts/src/plot/render/hit-index.d.ts +37 -0
  156. package/dist/packages/charts/src/plot/render/plot-viewport.d.ts +39 -0
  157. package/dist/packages/charts/src/plot/render/point-layer.d.ts +41 -0
  158. package/dist/packages/charts/src/plot/render/theme-colors.d.ts +15 -0
  159. package/dist/packages/charts/src/plot/scale.d.ts +48 -0
  160. package/dist/packages/charts/src/plot/ticks.d.ts +34 -0
  161. package/dist/packages/charts/src/plot-width.d.ts +3 -2
  162. package/dist/packages/charts/src/relationship/contour-plot.d.ts +61 -0
  163. package/dist/packages/charts/src/relationship/density-map.d.ts +45 -0
  164. package/dist/packages/charts/src/relationship/embedding-map.d.ts +75 -0
  165. package/dist/packages/charts/src/relationship/index.d.ts +11 -0
  166. package/dist/packages/charts/src/relationship/level-legend.d.ts +11 -0
  167. package/dist/packages/charts/src/relationship/measures.d.ts +85 -0
  168. package/dist/packages/charts/src/relationship/parallel-coordinates.d.ts +30 -0
  169. package/dist/packages/charts/src/relationship/range-controls.d.ts +20 -0
  170. package/dist/packages/charts/src/relationship/scatter-matrix.d.ts +20 -0
  171. package/dist/packages/charts/src/spec/chart-guide.d.ts +21 -0
  172. package/dist/packages/charts/src/spec/figure-registry.d.ts +44 -0
  173. package/dist/packages/charts/src/spec/figure-spec.d.ts +147 -0
  174. package/dist/packages/charts/src/spec/figure-text.d.ts +8 -0
  175. package/dist/packages/charts/src/spec/figure.d.ts +12 -0
  176. package/dist/packages/charts/src/spec/guide-data.d.ts +85 -0
  177. package/dist/packages/charts/src/spec/index.d.ts +10 -0
  178. package/dist/packages/charts/src/spec/validate-figure.d.ts +15 -0
  179. package/dist/packages/charts/src/text/index.d.ts +11 -0
  180. package/dist/packages/charts/src/text/token-examples.d.ts +42 -0
  181. package/dist/packages/charts/src/text/token-grid.d.ts +47 -0
  182. package/dist/packages/charts/src/text/token-links.d.ts +49 -0
  183. package/dist/packages/charts/src/text/token-predictions.d.ts +38 -0
  184. package/dist/packages/charts/src/text/token-scale.d.ts +20 -0
  185. package/dist/packages/charts/src/text/token-text.d.ts +39 -0
  186. package/dist/packages/charts/src/timeline/event-strip.d.ts +70 -0
  187. package/dist/packages/charts/src/timeline/index.d.ts +3 -1
  188. package/dist/packages/charts/src/timeline/waterfall.d.ts +24 -13
  189. package/dist/packages/charts/src/transforms/bins.d.ts +91 -0
  190. package/dist/packages/charts/src/transforms/density.d.ts +53 -0
  191. package/dist/packages/charts/src/transforms/fits.d.ts +50 -0
  192. package/dist/packages/charts/src/transforms/index.d.ts +19 -0
  193. package/dist/packages/charts/src/transforms/matrices.d.ts +49 -0
  194. package/dist/packages/charts/src/transforms/quantiles.d.ts +96 -0
  195. package/dist/packages/charts/src/transforms/ranks.d.ts +44 -0
  196. package/dist/packages/charts/src/transforms/runs.d.ts +47 -0
  197. package/dist/packages/charts/src/transforms/sampling.d.ts +75 -0
  198. package/dist/packages/charts/src/transforms/smoothing.d.ts +41 -0
  199. package/dist/packages/charts/src/transforms/values.d.ts +70 -0
  200. package/dist/packages/charts/src/trend/bump-chart.d.ts +33 -0
  201. package/dist/packages/charts/src/trend/column-figure.d.ts +38 -0
  202. package/dist/packages/charts/src/trend/column-positions.d.ts +21 -0
  203. package/dist/packages/charts/src/trend/curve-chart.d.ts +69 -0
  204. package/dist/packages/charts/src/trend/end-labels.d.ts +40 -0
  205. package/dist/packages/charts/src/trend/horizon-chart.d.ts +37 -0
  206. package/dist/packages/charts/src/trend/index.d.ts +10 -0
  207. package/dist/packages/charts/src/trend/line-locate.d.ts +21 -0
  208. package/dist/packages/charts/src/trend/runs-chart.d.ts +50 -0
  209. package/dist/packages/charts/src/trend/slope-chart.d.ts +35 -0
  210. package/dist/packages/kits/src/evaluation/evaluation-data.d.ts +31 -0
  211. package/dist/packages/kits/src/evaluation/index.d.ts +8 -0
  212. package/dist/packages/kits/src/evaluation/leaderboard-cells.d.ts +62 -0
  213. package/dist/packages/kits/src/evaluation/leaderboard.d.ts +59 -0
  214. package/dist/packages/kits/src/evaluation/model-comparison.d.ts +59 -0
  215. package/dist/packages/kits/src/evaluation/score-breakdown.d.ts +33 -0
  216. package/dist/packages/kits/src/interpretability/attention-head-grid.d.ts +56 -0
  217. package/dist/packages/kits/src/interpretability/attribution-workbench.d.ts +29 -0
  218. package/dist/packages/kits/src/interpretability/embedding-atlas.d.ts +41 -0
  219. package/dist/packages/kits/src/interpretability/feature-card.d.ts +33 -0
  220. package/dist/packages/kits/src/interpretability/feature-list.d.ts +51 -0
  221. package/dist/packages/kits/src/interpretability/feature-logits.d.ts +23 -0
  222. package/dist/packages/kits/src/interpretability/features.d.ts +70 -0
  223. package/dist/packages/kits/src/interpretability/index.d.ts +16 -0
  224. package/dist/packages/kits/src/interpretability/kit-styles.d.ts +118 -0
  225. package/dist/packages/kits/src/interpretability/logit-lens.d.ts +50 -0
  226. package/dist/packages/kits/src/interpretability/node-panel.d.ts +32 -0
  227. package/dist/packages/kits/src/interpretability/shared-link.d.ts +8 -0
  228. package/dist/packages/kits/src/interpretability/steering-panel.d.ts +52 -0
  229. package/dist/packages/kits/src/operations/budget-board.d.ts +49 -0
  230. package/dist/packages/kits/src/operations/incident-timeline.d.ts +30 -0
  231. package/dist/packages/kits/src/operations/index.d.ts +6 -0
  232. package/dist/packages/kits/src/operations/service-health.d.ts +66 -0
  233. package/dist/packages/kits/src/training/index.d.ts +8 -0
  234. package/dist/packages/kits/src/training/run-dashboard.d.ts +49 -0
  235. package/dist/packages/kits/src/training/run-legend.d.ts +21 -0
  236. package/dist/packages/kits/src/training/run-marker.d.ts +5 -0
  237. package/dist/packages/kits/src/training/run-state.d.ts +7 -0
  238. package/dist/packages/kits/src/training/run-table.d.ts +63 -0
  239. package/dist/packages/kits/src/training/runs-overview.d.ts +20 -0
  240. package/dist/packages/kits/src/training/runs.d.ts +34 -0
  241. package/dist/packages/teaching/src/agent/index.d.ts +11 -0
  242. package/dist/packages/teaching/src/agent/learner-trace.d.ts +84 -0
  243. package/dist/packages/teaching/src/agent/lesson-bridge.d.ts +59 -0
  244. package/dist/packages/teaching/src/agent/lesson-tour.d.ts +63 -0
  245. package/dist/packages/teaching/src/agent/tutor-tools.d.ts +86 -0
  246. package/dist/packages/teaching/src/article/article-checks.d.ts +9 -0
  247. package/dist/packages/teaching/src/article/article-context.d.ts +49 -0
  248. package/dist/packages/teaching/src/article/article-error.d.ts +12 -0
  249. package/dist/packages/teaching/src/article/article-labels.d.ts +54 -0
  250. package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +14 -0
  251. package/dist/packages/teaching/src/article/article-outline.d.ts +9 -0
  252. package/dist/packages/teaching/src/article/article.d.ts +42 -0
  253. package/dist/packages/teaching/src/article/beat-steps.d.ts +18 -0
  254. package/dist/packages/teaching/src/article/beat.d.ts +16 -0
  255. package/dist/packages/teaching/src/article/challenge.d.ts +29 -0
  256. package/dist/packages/teaching/src/article/exercise-styles.d.ts +76 -0
  257. package/dist/packages/teaching/src/article/figure.d.ts +51 -0
  258. package/dist/packages/teaching/src/article/index.d.ts +31 -0
  259. package/dist/packages/teaching/src/article/lesson-values.d.ts +5 -0
  260. package/dist/packages/teaching/src/article/linked-target.d.ts +22 -0
  261. package/dist/packages/teaching/src/article/notes.d.ts +36 -0
  262. package/dist/packages/teaching/src/article/outline-types.d.ts +73 -0
  263. package/dist/packages/teaching/src/article/predict.d.ts +58 -0
  264. package/dist/packages/teaching/src/article/progress-store.d.ts +64 -0
  265. package/dist/packages/teaching/src/article/scrolly.d.ts +26 -0
  266. package/dist/packages/teaching/src/article/term.d.ts +35 -0
  267. package/dist/packages/teaching/src/article/tex.d.ts +12 -0
  268. package/dist/packages/teaching/src/article/view-essay.d.ts +13 -0
  269. package/dist/packages/teaching/src/article/view-present.d.ts +8 -0
  270. package/dist/packages/teaching/src/article/view-sheet.d.ts +7 -0
  271. package/dist/packages/teaching/src/article/view-static.d.ts +7 -0
  272. package/dist/packages/teaching/src/article/walk.d.ts +34 -0
  273. package/dist/packages/teaching/src/lesson/bound-value.d.ts +29 -0
  274. package/dist/packages/teaching/src/lesson/define-lesson.d.ts +136 -0
  275. package/dist/packages/teaching/src/lesson/index.d.ts +24 -0
  276. package/dist/packages/teaching/src/lesson/inline-choice.d.ts +12 -0
  277. package/dist/packages/teaching/src/lesson/lesson-context.d.ts +18 -0
  278. package/dist/packages/teaching/src/lesson/lesson-error.d.ts +12 -0
  279. package/dist/packages/teaching/src/lesson/lesson-locale.d.ts +4 -0
  280. package/dist/packages/teaching/src/lesson/lesson-persistence.d.ts +17 -0
  281. package/dist/packages/teaching/src/lesson/lesson-player.d.ts +51 -0
  282. package/dist/packages/teaching/src/lesson/lesson-store.d.ts +84 -0
  283. package/dist/packages/teaching/src/lesson/lesson.d.ts +39 -0
  284. package/dist/packages/teaching/src/lesson/param-controls.d.ts +14 -0
  285. package/dist/packages/teaching/src/lesson/param.d.ts +34 -0
  286. package/dist/packages/teaching/src/lesson/playback.d.ts +42 -0
  287. package/dist/packages/teaching/src/lesson/transport.d.ts +19 -0
  288. package/dist/packages/teaching/src/lesson/use-lesson.d.ts +36 -0
  289. package/dist/packages/teaching/src/mdx/essay-components.d.ts +79 -0
  290. package/dist/packages/teaching/src/mdx/essay-markdown.d.ts +41 -0
  291. package/dist/packages/teaching/src/mdx/essay.d.ts +32 -0
  292. package/dist/packages/teaching/src/mdx/index.d.ts +9 -0
  293. package/dist/packages/teaching/src/mdx/requested-view.d.ts +6 -0
  294. package/dist/packages/teaching/src/scene/flow/flow-layout.d.ts +38 -0
  295. package/dist/packages/teaching/src/scene/flow/flow-pulse.d.ts +16 -0
  296. package/dist/packages/teaching/src/scene/flow/scene-flow.d.ts +81 -0
  297. package/dist/packages/teaching/src/scene/index.d.ts +77 -0
  298. package/dist/packages/teaching/src/scene/morph/morph-scope.d.ts +28 -0
  299. package/dist/packages/teaching/src/scene/plane/plane-hit.d.ts +22 -0
  300. package/dist/packages/teaching/src/scene/plane/plane-label.d.ts +23 -0
  301. package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +42 -0
  302. package/dist/packages/teaching/src/scene/plane/plane-math.d.ts +45 -0
  303. package/dist/packages/teaching/src/scene/plane/scene-axes.d.ts +30 -0
  304. package/dist/packages/teaching/src/scene/plane/scene-curve.d.ts +42 -0
  305. package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +59 -0
  306. package/dist/packages/teaching/src/scene/plane/scene-projection.d.ts +27 -0
  307. package/dist/packages/teaching/src/scene/plane/scene-region.d.ts +38 -0
  308. package/dist/packages/teaching/src/scene/plane/scene-rule.d.ts +35 -0
  309. package/dist/packages/teaching/src/scene/plane/scene-vector.d.ts +39 -0
  310. package/dist/packages/teaching/src/scene/scene-bracket.d.ts +24 -0
  311. package/dist/packages/teaching/src/scene/scene-callout.d.ts +26 -0
  312. package/dist/packages/teaching/src/scene/scene-context.d.ts +179 -0
  313. package/dist/packages/teaching/src/scene/scene-custom.d.ts +31 -0
  314. package/dist/packages/teaching/src/scene/scene-geometry.d.ts +181 -0
  315. package/dist/packages/teaching/src/scene/scene-group.d.ts +28 -0
  316. package/dist/packages/teaching/src/scene/scene-highlight.d.ts +19 -0
  317. package/dist/packages/teaching/src/scene/scene-layer.d.ts +16 -0
  318. package/dist/packages/teaching/src/scene/scene-node.d.ts +67 -0
  319. package/dist/packages/teaching/src/scene/scene-obstacles.d.ts +27 -0
  320. package/dist/packages/teaching/src/scene/scene-registry.d.ts +79 -0
  321. package/dist/packages/teaching/src/scene/scene-stagger.d.ts +43 -0
  322. package/dist/packages/teaching/src/scene/scene-style.d.ts +14 -0
  323. package/dist/packages/teaching/src/scene/scene-validate.d.ts +65 -0
  324. package/dist/packages/teaching/src/scene/scene-wire.d.ts +45 -0
  325. package/dist/packages/teaching/src/scene/scene.d.ts +36 -0
  326. package/dist/packages/teaching/src/scene/shapes/cell-color.d.ts +11 -0
  327. package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +69 -0
  328. package/dist/packages/teaching/src/scene/shapes/scene-card.d.ts +114 -0
  329. package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +84 -0
  330. package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +37 -0
  331. package/dist/packages/teaching/src/scene/shapes/scene-stack.d.ts +46 -0
  332. package/dist/packages/teaching/src/scene/shapes/scene-token.d.ts +63 -0
  333. package/dist/packages/teaching/src/scene/shapes/scene-tokens.d.ts +40 -0
  334. package/dist/packages/teaching/src/scene/shapes/stack-book.d.ts +35 -0
  335. package/dist/packages/teaching/src/scene/shapes/stack-layout.d.ts +63 -0
  336. package/dist/packages/teaching/src/scene/shapes/token-layout.d.ts +39 -0
  337. package/dist/packages/teaching/src/spec/advice.d.ts +23 -0
  338. package/dist/packages/teaching/src/spec/chart-names.d.ts +2 -0
  339. package/dist/packages/teaching/src/spec/describe-lesson.d.ts +85 -0
  340. package/dist/packages/teaching/src/spec/explainer-guide.d.ts +21 -0
  341. package/dist/packages/teaching/src/spec/findings.d.ts +39 -0
  342. package/dist/packages/teaching/src/spec/index.d.ts +14 -0
  343. package/dist/packages/teaching/src/spec/lesson-plan.d.ts +43 -0
  344. package/dist/packages/teaching/src/spec/validate-plan.d.ts +11 -0
  345. package/dist/packages/teaching/src/time/clock.d.ts +7 -0
  346. package/dist/packages/teaching/src/time/tween.d.ts +19 -0
  347. package/dist/packages/teaching/src/time/use-tween.d.ts +6 -0
  348. package/dist/param-CqKUTHaO.js +450 -0
  349. package/dist/path-BglsXpnO.js +59 -0
  350. package/dist/plot-axes-DJkLW4wk.js +100 -0
  351. package/dist/plot-layout-CZVSJ-le.js +912 -0
  352. package/dist/plot-marks-uozcbOIX.js +229 -0
  353. package/dist/plot-surface-CbVBvgqZ.js +51 -0
  354. package/dist/plot-width-DcqtSgzb.js +124 -0
  355. package/dist/point-layer-C-EYETAt.js +655 -0
  356. package/dist/reference-lines-BDcttOp0.js +82 -0
  357. package/dist/scale-C2xgZyZN.js +63 -0
  358. package/dist/scene-0z2gbaDE.js +4938 -0
  359. package/dist/scene.js +1 -0
  360. package/dist/slope-chart-BKVEAVCs.js +1279 -0
  361. package/dist/{src-1EHkSFS-.js → src-BD6xlvDt.js} +2 -2
  362. package/dist/{src-DVHlknB6.js → src-CExIrXPC.js} +169 -193
  363. package/dist/src-DIS0YOj0.js +44 -0
  364. package/dist/src-Dcfq8vE4.js +2195 -0
  365. package/dist/styles2.css +907 -59
  366. package/dist/time-series-BgzGNOk0.js +2670 -0
  367. package/dist/token-heatmap-BrW1OsKD.js +1354 -0
  368. package/dist/token-predictions-yerq_Oet.js +1093 -0
  369. package/dist/tone-scope-DKiSw-JR.js +32 -0
  370. package/dist/transport-BJweqDPj.js +715 -0
  371. package/dist/tree-diagram-D09BRqE-.js +1629 -0
  372. package/dist/treemap-CW4WsJNL.js +472 -0
  373. package/dist/use-tween-5HZ55_9d.js +72 -0
  374. package/dist/values-963L6n1m.js +65 -0
  375. package/dist/violin-plot-DrtPZ1-T.js +1292 -0
  376. package/dist/waterfall-DYLSnGjm.js +576 -0
  377. package/package.json +78 -4
  378. package/recipes/allocation-report.tsx +15 -7
  379. package/recipes/counting-cards.tsx +656 -0
  380. package/recipes/explorable-essay.tsx +172 -0
  381. package/skills/extend-elements/SKILL.md +81 -0
  382. package/skills/plan-lesson/SKILL.md +86 -0
  383. package/skills/plan-lesson/references/plan-format.md +114 -0
  384. package/skills/plan-lesson/references/worked-plan.md +171 -0
  385. package/skills/review-elements/SKILL.md +47 -3
  386. package/skills/review-explainer/SKILL.md +97 -0
  387. package/skills/upgrade-elements/SKILL.md +3 -1
  388. package/skills/upgrade-elements/references/releases.md +249 -0
  389. package/skills/use-elements/SKILL.md +22 -14
  390. package/skills/use-elements/references/charts.md +362 -41
  391. package/skills/use-elements/references/figures.md +173 -0
  392. package/skills/use-elements/references/kits.md +180 -0
  393. package/skills/use-elements/references/teaching.md +36 -0
  394. package/skills/write-explainer/SKILL.md +112 -0
  395. package/skills/write-explainer/references/article.md +164 -0
  396. package/skills/write-explainer/references/lesson.md +148 -0
  397. package/skills/write-explainer/references/mdx.md +78 -0
  398. package/skills/write-explainer/references/scene-parts.md +273 -0
  399. package/skills/write-explainer/references/scene.md +168 -0
  400. package/skills/write-explainer/references/tutor.md +104 -0
  401. package/skills/write-explainer/references/worked-essay.md +459 -0
  402. package/templates/essay/AGENTS.md +14 -0
  403. package/templates/essay/README.md +59 -0
  404. package/templates/essay/index.html +17 -0
  405. package/templates/essay/package.template.json +21 -0
  406. package/templates/essay/plan.json +96 -0
  407. package/templates/essay/src/essay.mdx +97 -0
  408. package/templates/essay/src/figures.tsx +92 -0
  409. package/templates/essay/src/lesson.ts +83 -0
  410. package/templates/essay/src/main.tsx +53 -0
  411. package/templates/essay/src/mdx.d.ts +7 -0
  412. package/templates/essay/tsconfig.template.json +15 -0
  413. package/templates/essay/vite.config.template.txt +8 -0
  414. package/dist/categorical-values-BXi-rJuv.js +0 -74
  415. package/dist/chart-data-CIJVWCYt.js +0 -21
  416. package/dist/chart-frame-BaxKn_MB.js +0 -236
  417. package/dist/chart-input-Bm82_9Rd.js +0 -22
  418. package/dist/chart-theme-4zprJ3rW.js +0 -404
  419. package/dist/plot-width-v2c_rA20.js +0 -63
@@ -0,0 +1,172 @@
1
+ import { Article, Beat, Figure, Predict } from '@mechane-ai/elements/article';
2
+ import { CurveChart } from '@mechane-ai/elements/charts/trend';
3
+ import { defineLesson, Param, useLesson, Value } from '@mechane-ai/elements/lesson';
4
+ import { Scene, SceneNode, SceneWire } from '@mechane-ai/elements/scene';
5
+ import { spacing } from '@mechane-ai/elements/tokens';
6
+
7
+ type EssayProps = { readonly title: string; readonly summary: string };
8
+
9
+ const BATCH_MAX = 256;
10
+ const CURVE_POINTS = 33;
11
+ const PAGE_WIDTH = 1200;
12
+
13
+ /** The page's own gutter: an article fills what it is given and leaves the edges to the page. */
14
+ const pageStyle = {
15
+ boxSizing: 'border-box',
16
+ maxWidth: PAGE_WIDTH,
17
+ margin: '0 auto',
18
+ padding: `${spacing.xxl} ${spacing.lg}`,
19
+ } as const;
20
+
21
+ /** Gradient noise falls with the square root of the batch size. The numbers are synthetic. */
22
+ const lesson = defineLesson({
23
+ id: 'batch-noise',
24
+ title: 'Why a bigger batch is quieter',
25
+ params: {
26
+ batch: {
27
+ kind: 'number',
28
+ label: 'Batch size',
29
+ value: 4,
30
+ min: 1,
31
+ max: BATCH_MAX,
32
+ step: 1,
33
+ scale: 'log',
34
+ format: { maximumFractionDigits: 0 },
35
+ },
36
+ },
37
+ derived: {
38
+ noise: {
39
+ label: 'Gradient noise',
40
+ format: { style: 'percent', maximumFractionDigits: 0 },
41
+ from: ({ batch }) => 1 / Math.sqrt(batch),
42
+ },
43
+ },
44
+ beats: [
45
+ {
46
+ id: 'estimate',
47
+ title: 'A batch estimates the gradient',
48
+ goal: 'See that the gradient of a batch is an average, so its error comes from how few examples it averages.',
49
+ states: [
50
+ { id: 'single', label: 'One example', values: { batch: 1 } },
51
+ { id: 'sixteen', label: 'Sixteen examples', values: { batch: 16 } },
52
+ ],
53
+ },
54
+ {
55
+ id: 'noise',
56
+ title: 'Noise falls with the square root',
57
+ goal: 'Find that four times the examples halves the noise, not quarters it.',
58
+ misconception: 'That doubling the batch halves the noise.',
59
+ states: [
60
+ { id: 'four', label: 'Four examples', values: { batch: 4 } },
61
+ { id: 'sixty-four', label: 'Sixty-four examples', values: { batch: 64 } },
62
+ ],
63
+ },
64
+ ],
65
+ });
66
+
67
+ const batches = Array.from({ length: CURVE_POINTS }, (_, index) => BATCH_MAX ** (index / (CURVE_POINTS - 1)));
68
+
69
+ function BatchScene() {
70
+ const { values, locale } = useLesson(lesson);
71
+
72
+ return (
73
+ <Scene
74
+ title="From a batch to a gradient"
75
+ description="Synthetic. A batch of examples is averaged into one gradient estimate whose noise shrinks as the batch grows."
76
+ locale={locale}
77
+ x={[0, 2]}
78
+ y={[0, 1]}
79
+ height="compact"
80
+ >
81
+ <SceneNode
82
+ id="batch"
83
+ at={[0.5, 0.5]}
84
+ text={`${values.batch} examples`}
85
+ label={`A batch of ${values.batch} examples`}
86
+ />
87
+ <SceneNode
88
+ id="gradient"
89
+ at={[1.5, 0.5]}
90
+ shape="pill"
91
+ text="gradient"
92
+ label={`The averaged gradient, with noise ${Math.round(values.noise * 100)}% of a single example's`}
93
+ tone={values.noise > 0.5 ? 'negative' : 'positive'}
94
+ />
95
+ <SceneWire from="batch" to="gradient" label="The examples are averaged" />
96
+ </Scene>
97
+ );
98
+ }
99
+
100
+ function NoiseCurve() {
101
+ const { values, locale } = useLesson(lesson);
102
+
103
+ return (
104
+ <CurveChart
105
+ title="Gradient noise by batch size"
106
+ description="Synthetic noise as a share of a single example's noise, on a log batch axis."
107
+ locale={locale}
108
+ series={[
109
+ {
110
+ id: 'noise',
111
+ label: 'Noise',
112
+ tone: 'series1',
113
+ points: batches.map((batch) => ({ x: batch, y: 1 / Math.sqrt(batch) })),
114
+ },
115
+ ]}
116
+ x={{ label: 'Batch size', scale: 'log', domain: [1, BATCH_MAX], format: { maximumFractionDigits: 0 } }}
117
+ y={{ label: 'Noise', domain: [0, 1], format: { style: 'percent', maximumFractionDigits: 0 } }}
118
+ markers={[{ x: values.batch, label: 'Now' }]}
119
+ labels="none"
120
+ height="compact"
121
+ />
122
+ );
123
+ }
124
+
125
+ /**
126
+ * Build an explorable essay in one TSX file: a lesson that declares the values, two beats of prose that read them, a
127
+ * scene, a chart and a prediction. Pass a title and a summary. Use an MDX file with the essay starter instead when the
128
+ * prose is long.
129
+ */
130
+ export function ExplorableEssay({ title, summary }: EssayProps) {
131
+ return (
132
+ <main style={pageStyle}>
133
+ <Article lesson={lesson} locale="en-US" title={title} summary={summary}>
134
+ <Beat id="estimate">
135
+ <p>
136
+ A gradient from <Param name="batch" /> examples is their average, so it is noisy by <Value name="noise" />{' '}
137
+ of what a single example gives.
138
+ </p>
139
+ <Figure
140
+ id="batch-scene"
141
+ caption="A batch of examples is averaged into one gradient."
142
+ description="Two boxes joined by an arrow: the batch of examples and the gradient they average into."
143
+ >
144
+ <BatchScene />
145
+ </Figure>
146
+ </Beat>
147
+ <Beat id="noise">
148
+ <Predict
149
+ id="quadruple"
150
+ prompt="Four times the examples: how does the noise change?"
151
+ options={[
152
+ { id: 'quarter', label: 'It falls to a quarter' },
153
+ { id: 'half', label: 'It halves' },
154
+ { id: 'same', label: 'It stays the same' },
155
+ ]}
156
+ answer="half"
157
+ >
158
+ <p>Noise falls with the square root of the batch size, so four times the examples halves it.</p>
159
+ </Predict>
160
+ <Figure
161
+ id="noise-curve"
162
+ caption="Noise at every batch size, with the current one marked."
163
+ description="A curve falling steeply for small batches and slowly for large ones."
164
+ reads={['batch']}
165
+ >
166
+ <NoiseCurve />
167
+ </Figure>
168
+ </Beat>
169
+ </Article>
170
+ </main>
171
+ );
172
+ }
@@ -100,3 +100,84 @@ Check a representative task in the family story with keyboard and the public `/a
100
100
  once the control is disabled, its selection changes, or its data is loading. For sensitive controls also inspect
101
101
  compound snapshots and action results for private values. Update the page recipe if the preferred consumer composition
102
102
  changes.
103
+
104
+ ## A chart
105
+
106
+ Read contract `workspaces/core/.contracts/140-ui-data-display/CONTRACT.md` and the chart guide
107
+ `workspaces/core/docs/ui-charts.md` first. Copy the structure of `packages/charts/src/trend/curve-chart.tsx` and its
108
+ story.
109
+
110
+ 1. Choose the family by the reader's question. A chart that no family fits needs a new kernel part first, and only when
111
+ a named chart needs it. Add the part to `packages/charts/src/plot` or `figure`, keep the edit additive, and export it
112
+ from `plot/index.ts`, which is the public kernel entry `@mechane-ai/elements/charts/plot`.
113
+ 2. Draw with the kernel only: `numericPlot` or `categoryPlot`, `PlotSurface`, `PlotAxes`, `PlotClip` and the marks
114
+ (`LineMark`, `AreaMark`, `BandMark`, `DotMark`, `BarMark`, `RuleMark`, `IntervalMark`, `LabelMark`, `SymbolMark`,
115
+ `RingMark`, `LinkMark`, `ConnectorMark`, `GuideMark`). Do not write a scale, a tick, an axis or a path again, and do
116
+ not restyle a mark. The marks carry the channel meanings.
117
+ 3. Take `FigureProps`, plus `FigureSelectionProps` when a record can be selected. Name state the way the others do:
118
+ `selected` with `onSelectedChange`, `range` with `onRangeChange`. No `format*` function props: use `PlotAxis`,
119
+ `valueFormat` and `timeFormat`, and write text with `formatValue` and `formatTime`. `locale` is required. Height is a
120
+ `PlotHeight`.
121
+ 4. Write ticks with `axisTicks` or `timeAxisTicks` and `tickTexts` from `plot`, and place labels with `freeLabelSpot`.
122
+ Give `FigureFrame` a `seriesLegend` for a legend that names things (above the plot) and a `scaleLegend` for a color
123
+ or size scale (below it). Resolve tones with `useTones()` and never hard-code a color. Spread `useLinkedInspection()`
124
+ into `Chart` when item ids mean the same thing in other charts.
125
+ 5. Validate first and return `FigureInvalid` with the reason. Never repair, clamp, reorder or drop. Refuse input above a
126
+ `<chart>Limits` object with a message that names it. Handle `status`, empty input and `coverage`.
127
+ 6. Keep every prop except callbacks and `ReactNode` slots plain JSON, then register the chart so a figure spec can name
128
+ it. In `packages/charts/src/spec/figure-spec.ts`, add its props to `FigureChartProps`, and a new family to
129
+ `FigureFamily`. In `spec/figure-registry.tsx`, add an entry with the component, its family, its required props with
130
+ their JSON kinds and `isSelectable`. Render the chart from its spec and compare it with the direct call.
131
+ 7. Keep statistics out. If the chart needs a bin, quantile, density or fit, add a named function to
132
+ `packages/charts/src/transforms` with a `describe...` footnote, and take the result as props.
133
+ 8. Add a guide entry in `spec/chart-guide.tsx`: the `question` the chart answers in a reader's words, `use` for when to
134
+ choose it, `avoid` for the chart that is better otherwise, and a small valid `example` spec. Build the data with the
135
+ helpers in `spec/guide-data.ts` where they fit. The types require one entry for every registered chart. The entry
136
+ feeds the wall. Write the chart into the chooser tables of the package `README.md`, `docs/ui-charts.md` and the
137
+ `use-elements` charts reference, which are the guide written out.
138
+ 9. Write the stories: `Charts/<ChartName>` with a default, an interactive story and a `States` story, in `en-US` with
139
+ deterministic data.
140
+ 10. Check the wall. `Charts/Wall`, in `spec/wall.stories.tsx`, draws every registered chart from its guide example
141
+ through `Figure`, so the new chart appears in its family story and in `All` with no further edit. A new family also
142
+ needs a title and a place in the wall's list. Review it in light and dark themes and at phone width. Inspect a
143
+ record by pointer, touch and keyboard. Compare the frame, axes, ticks, legend, readout, footnote and each state with
144
+ its neighbors.
145
+ 11. Add the chart to the family `index.ts`, with its types and its limits. Run `mise run fix` and `mise run check` from
146
+ the factory root.
147
+
148
+ ## A kit component
149
+
150
+ A kit under `packages/kits/src/<kit>` composes charts and collections for a domain question. It adds no marks, scales,
151
+ axes or colors. If you want to draw an SVG mark, use or request a chart instead.
152
+
153
+ - Follow contract `workspaces/core/.contracts/141-ui-domain-kits/CONTRACT.md`. Import other families only through their
154
+ public `index.ts` entries.
155
+ - Take `locale` and declared formats. Take the state the application owns as a value with a change callback. Take the
156
+ words as one partial `labels` prop with English defaults.
157
+ - Use one `ToneScope` over the things shown in more than one figure, and one `ChartLink` or `ChartGrid` where figures
158
+ share ids. Use the table cells from `charts/cells` inside `DataTable` columns.
159
+ - Handle `status`, empty, partial and invalid input. Refuse bad input with a sentence.
160
+ - Compute no statistic. The application supplies means, intervals, ranks and deltas.
161
+ - Write one stories file titled `Kits/<Kit name>` with a story per component, one page that composes them and a `States`
162
+ story. Export the components from the kit's `index.ts` and add the entry to `package.json`.
163
+
164
+ ## A teaching part
165
+
166
+ The teaching layers live in `packages/teaching/src`: `lesson`, `time`, `scene`, `article`, `mdx`, `spec` and `agent`.
167
+ Read contract `workspaces/core/.contracts/142-ui-teaching-layers/CONTRACT.md` first. A part an essay keeps drawing by
168
+ hand, with `SceneCustom` or raw SVG, is a candidate.
169
+
170
+ - Put a scene part in the scene folder that owns its kind: `scene/plane` for coordinate marks, `scene/shapes` for cards,
171
+ cells and tokens, `scene/flow` and `scene/morph`, or the folder root for a core part. Copy `scene/scene-node.tsx` for
172
+ a part on the HTML layer, or `scene/scene-bracket.tsx` for an SVG one.
173
+ - Register the object with `useSceneObject` and draw from the eased values it returns. Never start a frame loop, a timer
174
+ or a keyframe: the one clock in `time/clock.ts` moves everything, and reduced motion takes the end state.
175
+ - Give it a stable `id`, `isShown`, a `label` that makes it a keyboard item, `tone` resolved through the tone scope, and
176
+ a `labels` prop for its own words. Report author errors with `problem`, not by throwing.
177
+ - Inside `packages/teaching/src`, import the defining file, never a folder's `index.ts`. Export the part from its
178
+ folder's `index.ts`, which is the public entry.
179
+ - Add it to `explainerParts` and the guide in `spec/explainer-guide.ts` with the reader's `question`, `guidance` that
180
+ names the better part otherwise, and an `example` that compiles. Add it to `essayComponents` in
181
+ `mdx/essay-components.ts` so MDX essays can use it.
182
+ - Write `Teaching/<Name>` stories beside it: a default with synthetic machine-learning content said to be synthetic,
183
+ states, narrow and reduced motion. Describe it in the `write-explainer` skill's scene references.
@@ -0,0 +1,86 @@
1
+ ---
2
+ name: plan-lesson
3
+ description:
4
+ Plan an explorable explanation before writing any component. Use when asked to explain a topic, a paper or a research
5
+ result as an interactive essay with `@mechane-ai/elements`, or before changing the beats of an existing lesson.
6
+ ---
7
+
8
+ # Plan a lesson
9
+
10
+ An explorable essay is an argument the reader takes part in, not a tour of a model's features. Write the argument as a
11
+ `LessonPlan` first: plain JSON that names the one idea, the values the reader holds, and the beats. Check it with
12
+ `validateLessonPlan`, and write components only once it has no errors. Then follow the `write-explainer` skill.
13
+
14
+ The plan is cheap to change. A beat cut here saves a figure, its prose and its states later.
15
+
16
+ ## The procedure
17
+
18
+ 1. **Find the one idea.** Write the sentence the reader should be able to say afterwards, with its mechanism: "Each step
19
+ multiplies the loss by (1 − 2 × rate)², so it falls for rates under 1 and grows past it." A topic ("learning rates")
20
+ or a list ("rates, momentum and schedules") is not an idea. If the source has three ideas, plan three essays.
21
+ 2. **Name the reader.** `audience` says who reads it and what they already know. Every beat builds only on that and on
22
+ the beats before it.
23
+ 3. **Choose the params.** A param is a value the reader holds and changes: a number with its range, step and format, a
24
+ choice of two to five options, or a toggle. Keep two to five. Each must change something the reader can see. A value
25
+ the reader only reads is a derived value, not a param.
26
+ 4. **Name the derived values.** Each derived value lists the names it `reads` and its `formula` in words. Declare them
27
+ in computing order: a derived value reads params and derived values declared above it.
28
+ 5. **Cut the beats.** One beat is one step of the argument: one `goal` sentence the reader can say after it, the
29
+ `misconception` it corrects, and at most one new param. Start concrete: a specific hand of cards, one token, one
30
+ weight. Generalise in a later beat. Add a beat titled "Recap" after every seven.
31
+ 6. **Pick one figure per beat by its question.** Write the reader's question first ("How much does each card count
32
+ toward the sum?"), then choose the part whose `question` in `explainerGuide` matches, or a chart from `chartGuide`.
33
+ `shows` lists the params and derived values the figure draws. Never invent a part name.
34
+ 7. **Decide where the reader acts.** Put a `predict` ask before a result the reader could guess wrong, in one of the
35
+ first three beats. Put a `challenge` ask after the reader has the tool to reach it. The reader's own action should
36
+ cause each change the beat is about.
37
+ 8. **Declare the states worth seeing.** Each beat's `states` set params to show the beat's point. Order them: the first
38
+ state is the beat's opening picture, which the static view prints and the present view opens at each time the
39
+ presenter reaches the beat. The beat sheet draws every state. A beat that introduces a param has a state that moves
40
+ it.
41
+ 9. **Validate and fix.** Run the validator below. Fix every error, then read every advice and either follow it or state
42
+ in one sentence why the plan declines it.
43
+
44
+ Read [the plan format](references/plan-format.md) for each field and the validator's messages, and
45
+ [a worked plan](references/worked-plan.md) for a complete plan with the reasons behind each choice.
46
+
47
+ ## Check the plan
48
+
49
+ In the essay starter, `src/main.tsx` lists every finding of `plan.json` under the essay as "Lesson checks". From any
50
+ directory where `@mechane-ai/elements` is installed, run the validator in Node:
51
+
52
+ ```sh
53
+ node --input-type=module -e "
54
+ import { readFileSync } from 'node:fs';
55
+ import { validateLessonPlan } from '@mechane-ai/elements/lesson/spec';
56
+ const { isValid, findings } = validateLessonPlan(JSON.parse(readFileSync('plan.json', 'utf8')));
57
+ for (const finding of findings) console.log(finding.severity, finding.path, finding.message);
58
+ console.log(isValid ? 'valid' : 'invalid');
59
+ process.exitCode = isValid ? 0 : 1;
60
+ "
61
+ ```
62
+
63
+ Each finding has a `severity`, a `path` such as `beats[2].states[0].values.rate`, and a sentence that says what to do.
64
+ An `error` is something `defineLesson` would refuse. An `advice` is teaching practice. The plan is valid when no finding
65
+ is an error.
66
+
67
+ ## A good plan
68
+
69
+ - The `idea` is one sentence with a mechanism, and the last beat's `goal` restates it.
70
+ - Every beat has a goal, a figure whose question the goal answers, and a state for each param it introduces.
71
+ - The reader commits to a prediction before the first surprise, and reaches a challenge with their own hands.
72
+ - Every param appears in some figure's `shows` or in a derived value's `reads`.
73
+ - The beats read as a chain: each goal needs the one before it.
74
+
75
+ ## Failure modes
76
+
77
+ | The plan | Why it fails | Fix |
78
+ | --------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- |
79
+ | Beats named after parts of a model or a paper | A tour of features has no argument to follow | Rewrite each title as a claim the beat demonstrates |
80
+ | A param no figure shows | The reader moves a control and nothing answers | Add it to a figure's `shows`, or remove it |
81
+ | Three params introduced in the first beat | The reader cannot tell which change did what | One new param per beat |
82
+ | A figure for every paragraph | Each figure costs attention; most repeat the last | One figure per beat; reuse it across states |
83
+ | No `predict` in the first three beats | The reader watches instead of thinking | Ask before the first result they could get wrong |
84
+ | An abstract first beat: "Let x be an input" | Nothing to hold on to | Start with one concrete case, then generalise |
85
+ | States that set derived values | Derived values follow the params; the plan is wrong | Set the params that produce the value |
86
+ | Synthetic numbers presented as measurements | The reader trusts a fiction | Say "synthetic" in the audience-facing text |
@@ -0,0 +1,114 @@
1
+ # The plan format
2
+
3
+ `LessonPlan` is exported as a type from `@mechane-ai/elements/lesson/spec`. A plan is plain JSON, so a model can write
4
+ it and `validateLessonPlan(input: unknown)` can check it. Its params and beats are the shapes `defineLesson` takes.
5
+
6
+ ## Fields
7
+
8
+ | Field | Holds |
9
+ | ---------- | ---------------------------------------------------------------------------------------------------- |
10
+ | `id` | The lesson id, such as `"card-neuron"`. It names the lesson in the agent bridge and in storage keys. |
11
+ | `title` | The essay's title, a claim rather than a topic where possible. |
12
+ | `audience` | Who reads it and what they already know. |
13
+ | `idea` | The one sentence the reader should leave with. |
14
+ | `params` | Values the reader changes, by name. |
15
+ | `derived` | Values computed from the params, by name, in computing order. Optional. |
16
+ | `beats` | The steps of the argument, in reading order. At least one. |
17
+
18
+ A param is one of three kinds:
19
+
20
+ ```json
21
+ {
22
+ "rate": {
23
+ "kind": "number",
24
+ "label": "Learning rate",
25
+ "value": 0.1,
26
+ "min": 0.05,
27
+ "max": 1.2,
28
+ "step": 0.05,
29
+ "format": { "maximumFractionDigits": 2 }
30
+ },
31
+ "token": {
32
+ "kind": "choice",
33
+ "label": "Followed token",
34
+ "value": "cat",
35
+ "options": [
36
+ { "id": "cat", "label": "cat" },
37
+ { "id": "dog", "label": "dog" }
38
+ ]
39
+ },
40
+ "isMasked": { "kind": "toggle", "label": "Causal mask", "value": false }
41
+ }
42
+ ```
43
+
44
+ - `value` is the opening value. It must lie in the range or be one of the option ids.
45
+ - `format` is `Intl.NumberFormat` options. Use `{ "style": "percent" }` for shares, and
46
+ `{ "style": "unit", "unit": "bit" }` for units `Intl` knows.
47
+ - `scale: "log"` gives each tenfold the same drag distance. It needs `min` above zero.
48
+ - Name a toggle as a question that is true or false: `isMasked`, `hasBias`.
49
+
50
+ A derived value names what it reads and its formula in words. The code comes later, in `defineLesson`:
51
+
52
+ ```json
53
+ {
54
+ "sum": {
55
+ "label": "Weighted sum",
56
+ "format": { "maximumFractionDigits": 1 },
57
+ "reads": ["hand", "heartWeight", "spadeWeight", "bias"],
58
+ "formula": "heart rank × heart weight + spade rank × spade weight + bias"
59
+ }
60
+ }
61
+ ```
62
+
63
+ A beat is a `LessonBeat` with two planning fields:
64
+
65
+ | Field | Holds |
66
+ | --------------- | ------------------------------------------------------------------------------------------------------ |
67
+ | `id`, `title` | The beat's id, used by `<Beat id>`, and its heading. |
68
+ | `goal` | One sentence the reader can say after the beat. A tutor reads it; the reader never sees it. |
69
+ | `misconception` | The wrong belief the beat corrects. Tutor note. |
70
+ | `hints` | Sentences a tutor or a `Challenge` gives, in order. Tutor note. |
71
+ | `steps` | Reveal steps after the first view, for the present view. Defaults to 0. |
72
+ | `states` | `{ id, label, values }` each. `values` set params only. The first opens the static and present views. |
73
+ | `figure` | `{ part, question, shows? }`: a part from `explainerParts` or a chart name, and the reader's question. |
74
+ | `ask` | `{ kind: "predict" \| "challenge", prompt }`. |
75
+
76
+ Read the parts and their questions from Node:
77
+
78
+ ```sh
79
+ node --input-type=module -e "
80
+ import { explainerGuide } from '@mechane-ai/elements/lesson/spec';
81
+ for (const entry of explainerGuide) console.log(entry.part + ': ' + entry.question);
82
+ "
83
+ ```
84
+
85
+ Charts are listed with their questions in `chartGuide` from `@mechane-ai/elements/charts/figure`. A beat's figure is a
86
+ chart when the picture is data on axes, and a scene part when it is things and their connections.
87
+
88
+ ## What the validator says
89
+
90
+ These are real messages for a plan that has the common mistakes:
91
+
92
+ ```text
93
+ error params.temperature.min - A log scale needs min above zero. Use a linear scale, or start at a small positive value.
94
+ error derived.weights.reads - "weights" reads "scores", which is declared after it. defineLesson computes in order, so move "scores" above it.
95
+ error beats[0].figure.part - "AttentionDiagram" is not a teaching part or a chart. Choose a part from explainerGuide or a chart from chartGuide.
96
+ error beats[1].states[0].values.weights - "weights" is a derived value; a state sets params only, and the derived values follow.
97
+ error beats[2].figure.shows - "mask" is not a param or a derived value.
98
+ advice beats[0].goal - Beat "overview" has no goal. Add one sentence the reader should be able to say after it.
99
+ advice beats[0].states - Beat "overview" introduces 3 new params (temperature, heads, isMasked). Introduce one per beat, so the reader can tell what each one does.
100
+ advice beats - None of the first three beats asks for a prediction or a challenge. Add a Predict early, so the reader commits to a guess.
101
+ advice beats[1].figure - This beat shows no figure. Give it one, or fold its prose into the beat before.
102
+ advice derived.weights - No figure shows "weights" and no value reads it. List it in a figure's shows, or remove it.
103
+ ```
104
+
105
+ The advice also names a param that no state moves, and a run of more than seven beats with no beat titled "Recap".
106
+
107
+ ## From the plan to the lesson
108
+
109
+ Copy `params` and each beat's `id`, `title`, `goal`, `misconception`, `hints`, `steps` and `states` into `defineLesson`
110
+ as TypeScript literals. Leave `figure` and `ask` in the plan: they become `<Figure>`, `Predict` and `Challenge` in the
111
+ essay. Write each derived value's `from` as a pure function of the names in its `reads`. Do not import `plan.json` into
112
+ `defineLesson`: JSON widens `"kind": "number"` to a string, and the lesson loses its types.
113
+
114
+ Keep `plan.json` beside the essay. When the argument changes, change the plan first and run the validator again.
@@ -0,0 +1,171 @@
1
+ # A worked plan
2
+
3
+ The plan for an essay told with playing cards: one artificial neuron as a weighted vote over two cards. It passes
4
+ `validateLessonPlan` with no findings. The `write-explainer` skill builds the same essay from it, in
5
+ [its worked essay](../../write-explainer/references/worked-essay.md).
6
+
7
+ ```json
8
+ {
9
+ "id": "card-neuron",
10
+ "title": "A neuron is a weighted vote",
11
+ "audience": "Readers who can add and multiply and have heard that networks have weights, but have never watched one decide.",
12
+ "idea": "A neuron multiplies each input by a weight, adds the products and a bias, and says yes when the total is above zero; learning moves the weights.",
13
+ "params": {
14
+ "hand": {
15
+ "kind": "choice",
16
+ "label": "Hand dealt",
17
+ "value": "queen-seven",
18
+ "options": [
19
+ { "id": "queen-seven", "label": "Queen of Hearts, Seven of Spades" },
20
+ { "id": "two-king", "label": "Two of Hearts, King of Spades" }
21
+ ]
22
+ },
23
+ "heartWeight": {
24
+ "kind": "number",
25
+ "label": "Weight on the heart card",
26
+ "value": 0.5,
27
+ "min": -1,
28
+ "max": 1,
29
+ "step": 0.1,
30
+ "format": { "maximumFractionDigits": 1 }
31
+ },
32
+ "spadeWeight": {
33
+ "kind": "number",
34
+ "label": "Weight on the spade card",
35
+ "value": 0.5,
36
+ "min": -1,
37
+ "max": 1,
38
+ "step": 0.1,
39
+ "format": { "maximumFractionDigits": 1 }
40
+ },
41
+ "bias": {
42
+ "kind": "number",
43
+ "label": "Bias",
44
+ "value": 0,
45
+ "min": -10,
46
+ "max": 10,
47
+ "step": 0.5,
48
+ "format": { "maximumFractionDigits": 1 }
49
+ }
50
+ },
51
+ "derived": {
52
+ "sum": {
53
+ "label": "Weighted sum",
54
+ "format": { "maximumFractionDigits": 1 },
55
+ "reads": ["hand", "heartWeight", "spadeWeight", "bias"],
56
+ "formula": "heart rank × heart weight + spade rank × spade weight + bias"
57
+ },
58
+ "yes": {
59
+ "label": "Chance the neuron says yes",
60
+ "format": { "style": "percent", "maximumFractionDigits": 0 },
61
+ "reads": ["sum"],
62
+ "formula": "the sigmoid of the weighted sum"
63
+ }
64
+ },
65
+ "beats": [
66
+ {
67
+ "id": "hand",
68
+ "title": "Two cards, two numbers",
69
+ "goal": "Read each card as a number, its rank: an ace is 1, a queen 12, a king 13.",
70
+ "misconception": "That the suit changes the number; the suit only says which input the card is.",
71
+ "states": [
72
+ { "id": "queen-seven", "label": "Queen and seven", "values": { "hand": "queen-seven" } },
73
+ { "id": "two-king", "label": "Two and king", "values": { "hand": "two-king" } }
74
+ ],
75
+ "figure": { "part": "SceneStack", "question": "Which two numbers go into the neuron?", "shows": ["hand"] },
76
+ "ask": { "kind": "predict", "prompt": "Which hand adds up to more, before any weights?" }
77
+ },
78
+ {
79
+ "id": "weights",
80
+ "title": "Each card gets a weight",
81
+ "goal": "See that a weight scales its card: at 0.5 the queen counts as 6, and below zero it counts against.",
82
+ "misconception": "That a weight is the card's value; it is how much the value counts.",
83
+ "hints": ["Drag the heart weight below zero and watch the wire turn."],
84
+ "states": [
85
+ { "id": "even", "label": "Both weights 0.5", "values": { "heartWeight": 0.5 } },
86
+ { "id": "against", "label": "Hearts count against", "values": { "heartWeight": -0.5 } }
87
+ ],
88
+ "figure": {
89
+ "part": "Scene",
90
+ "question": "How much does each card count toward the sum?",
91
+ "shows": ["heartWeight", "sum"]
92
+ },
93
+ "ask": { "kind": "predict", "prompt": "Make the heart weight −0.5. Does the weighted sum rise or fall?" }
94
+ },
95
+ {
96
+ "id": "sum",
97
+ "title": "The neuron adds the votes",
98
+ "goal": "Compute the weighted sum of one hand by hand, then check it against the figure.",
99
+ "states": [
100
+ { "id": "balanced", "label": "Spade weight 0.5", "values": { "spadeWeight": 0.5 } },
101
+ { "id": "spade-heavy", "label": "Spade weight 1", "values": { "spadeWeight": 1 } }
102
+ ],
103
+ "figure": {
104
+ "part": "LessonFlow",
105
+ "question": "How is the sum computed from the cards and the weights?",
106
+ "shows": ["sum", "spadeWeight"]
107
+ }
108
+ },
109
+ {
110
+ "id": "bias",
111
+ "title": "The bias sets the bar",
112
+ "goal": "Connect a negative bias with a neuron that needs stronger evidence before it says yes.",
113
+ "misconception": "That the bias is one more card; it is added whatever the hand.",
114
+ "hints": ["At a bias of −8 the cards must add about 10 more.", "Raise the weight on the queen."],
115
+ "states": [
116
+ { "id": "no-bias", "label": "No bias", "values": { "bias": 0 } },
117
+ { "id": "skeptic", "label": "Bias −8", "values": { "bias": -8 } }
118
+ ],
119
+ "figure": { "part": "SceneCurve", "question": "How sure is the neuron at this sum?", "shows": ["sum", "yes"] },
120
+ "ask": {
121
+ "kind": "challenge",
122
+ "prompt": "With a bias of −8, make the neuron at least 90% sure for the queen and seven."
123
+ }
124
+ },
125
+ {
126
+ "id": "learning",
127
+ "title": "Learning moves the weights",
128
+ "goal": "See that training changes only the weights and the bias, never the cards.",
129
+ "states": [
130
+ {
131
+ "id": "before",
132
+ "label": "Before training",
133
+ "values": { "heartWeight": -0.5, "spadeWeight": 0.5, "bias": 0 }
134
+ },
135
+ { "id": "after", "label": "After training", "values": { "heartWeight": 0.8, "spadeWeight": -0.2, "bias": -4 } }
136
+ ],
137
+ "figure": {
138
+ "part": "SceneCells",
139
+ "question": "Which weights did training change, and by how much?",
140
+ "shows": ["heartWeight", "spadeWeight", "bias"]
141
+ }
142
+ }
143
+ ]
144
+ }
145
+ ```
146
+
147
+ ## Why each choice
148
+
149
+ - **The idea has a mechanism.** "Multiplies, adds, says yes above zero; learning moves the weights" can be checked
150
+ against every figure. "How neurons work" could not.
151
+ - **Concrete first.** Beat 1 is two specific cards, read as two numbers. Weights, sums and the sigmoid come after the
152
+ reader holds those numbers.
153
+ - **One new param per beat.** `hand`, then `heartWeight`, then `spadeWeight`, then `bias`. The last beat moves only
154
+ params the reader already knows, so it can move several at once.
155
+ - **Each figure answers its beat's question.** The hand is cards in a deck and a row (`SceneStack`). The vote is wires
156
+ whose thickness is the weight (`Scene` with `SceneWire`). The sum is the lesson's own derivation (`LessonFlow`). The
157
+ confidence is a function of the sum (`SceneCurve`). Training is three numbers (`SceneCells`).
158
+ - **The same card is the same object.** `queen-hearts` is one id in the hand, the vote and the prose, so a `Term` on
159
+ "Queen of Hearts" lights it in every figure.
160
+ - **Predict early, challenge late.** Beat 1 asks which hand is larger before any weight exists, because readers expect
161
+ the king to win. Beat 4 asks the reader to beat a skeptical bias, once they hold every control that can.
162
+ - **States show the point.** Each beat's states differ in exactly the param the beat introduces, so the beat sheet shows
163
+ the cause and its effect side by side.
164
+ - **Misconceptions are specific.** "That a weight is the card's value" names a belief a tutor can test with one
165
+ question.
166
+
167
+ ## What the first draft got wrong
168
+
169
+ The first draft had one beat, "The neuron", with all four params, a `SceneNode` per input and no ask. The validator said
170
+ the beat introduced four params and that no early beat asked anything. Splitting it gave four beats with one new param
171
+ each, and the reader now has a reason to touch each control.