@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,180 @@
1
+ # Kits
2
+
3
+ A kit is a small set of domain components built from the chart families. A kit chooses which figures answer a domain
4
+ question, arranges them, shares one tone scope and one linked inspection between them, and writes the words. It adds no
5
+ marks, colors or axes.
6
+
7
+ Import a kit from `@mechane-ai/elements/kits/<kit>`. Every component of the training, operations, evaluation and
8
+ interpretability kits:
9
+
10
+ - takes `locale` and declared formats, never pre-formatted numbers;
11
+ - takes the state it shows as a value with a change callback, such as `selected` with `onSelectedChange`;
12
+ - takes its visible words as `labels`, a partial object with English defaults;
13
+ - handles `status`, empty and invalid input, and refuses bad input with a sentence;
14
+ - computes nothing. The application supplies means, intervals, ranks and deltas, or calls
15
+ `@mechane-ai/elements/charts/transforms` first. A list may sort and filter the rows it is given.
16
+
17
+ An explorable essay is not a kit: it uses the teaching layers in [teaching](teaching.md), which replace the old
18
+ explainers kit. The rules for kits are
19
+ [contract 141](https://github.com/mechane-ai/mechane/blob/main/workspaces/core/.contracts/141-ui-domain-kits/CONTRACT.md).
20
+
21
+ | Kit | Entry | Use it for |
22
+ | ---------------- | ------------------------ | -------------------------------------------------------------------------- |
23
+ | Training | `/kits/training` | Watching and comparing training runs. |
24
+ | Operations | `/kits/operations` | The health, budgets and events of a service. |
25
+ | Evaluation | `/kits/evaluation` | Ranking and comparing models on benchmarks. |
26
+ | Interpretability | `/kits/interpretability` | Reading learned features, attribution, attention, logit lens and steering. |
27
+
28
+ ## Training
29
+
30
+ For runs of one experiment. A run keeps one id and one hue in the dashboard, the table and every chart.
31
+
32
+ - `RunDashboard` draws one `CurveChart` panel per metric with one step cursor. It takes `runs`, `metrics`, `series`
33
+ (metric id, then run id, then points in increasing step), a step axis `x`, `selected` with `onSelectedChange`, and
34
+ `hidden` with `onHiddenChange`.
35
+ - `RunTable` is the table and the legend. It takes `title`, `runs`, `columns` for settings, `metrics` as `bar` or
36
+ `spark` columns, `selected`, `hidden`, `sort` with `onSortChange` and `showOnlyDifferences`. Pressing a row asks to
37
+ focus the run, or to clear the focus when it is already focused, so `onSelectedChange` receives an id or `null`.
38
+ - `RunsOverview` shows a whole sweep as gray lines with one highlighted run and a median band. Use it when there are
39
+ more runs than hues. It takes `runs`, `x`, `y`, `summary` and `summaryText`.
40
+
41
+ A `RunRecord` is `{ id, label, state, detail?, tone? }`, with `state` one of `running`, `finished`, `failed` or
42
+ `stopped`. `runLimits.runs` is 12. The application supplies the prepared curves, smoothed or not, the settings per run
43
+ and the final results. It holds selection, hiding and sorting.
44
+
45
+ ## Operations
46
+
47
+ For a service in production.
48
+
49
+ - `ServiceHealth` shows the service state in words, headline tiles with a trend, and time-series panels on one shared
50
+ time axis. It takes `service`, `indicators`, `charts`, `timestampUnit`, `timeFormat` and `locale`. Give a chart series
51
+ the same `id` as its indicator and the two share a hue.
52
+ - `BudgetBoard` shows objectives and budgets as bars against targets. It takes `groups` of rows that share a unit, each
53
+ with a `value` axis, and `selected` with `onSelectedChange`.
54
+ - `IncidentTimeline` shows deploys, alerts and incidents in three lanes over a `window`. It takes `events`, a
55
+ `timeFormat` that names its time zone, and `selected` with `onSelectedChange`.
56
+
57
+ The application judges every state and writes its words. Nothing here works out health from a number or a color.
58
+
59
+ ## Evaluation
60
+
61
+ For models compared on benchmarks. Every model has one id, `EvaluationModel` `{ id, label, detail?, tone? }`.
62
+
63
+ - `Leaderboard` is a ranked table of models over measure columns. A column has a `kind` of `score`, `interval`,
64
+ `change`, `trend` or `heat`, a `format`, `isHigherBetter` and, except for `change`, a shared `domain`. It takes
65
+ `models`, `columns`, `rows`, `sort` with `onSortChange` and `selected` with `onSelectedChange`. Here `selected` is the
66
+ list of checked model ids, and the rows have no checkboxes without the callback. `leaderboardLimits` is 100 models and
67
+ 10 columns.
68
+ - `ScoreBreakdown` shows one benchmark by category with a dot per model and an optional interval. It takes `models`,
69
+ `categories`, `scores`, `value` and `selected`.
70
+ - `ModelComparison` shows two models head to head: a dumbbell per benchmark and a table of differences. It takes `a`,
71
+ `b`, `rows`, `value`, `isHigherBetter` and `differenceFormat`. Each difference is B minus A.
72
+
73
+ A score is a number, an estimate with its interval `{ value, low, high }`, or `null` where it was not measured. The
74
+ application supplies the ranks, intervals, differences and tests. Resting on a leaderboard row marks that model in the
75
+ linked figures.
76
+
77
+ ## Interpretability
78
+
79
+ For reading what a model learned and how it computes an answer. A feature, such as a sparse autoencoder latent, keeps
80
+ one id in the list, the card, the map and the attribution graph, so resting on it in one place lights it in the others.
81
+ A kit that holds several figures shares one tone scope and one chart link. The application supplies every activation,
82
+ attribution, attention weight and decoded layer. No component runs a model. A `FeatureSummary` is
83
+ `{ id, label, source?, explanation?, frequency? }`, and `featureLimits` is 5000 features and 8 search matches. Each
84
+ change callback receives `details` with a `reason` of `press`, `input` or `imperative`.
85
+
86
+ - `FeatureCard` answers "what is this feature?": its name, id and explanation, how often it fires, the contexts that
87
+ activate it most, and the output tokens it promotes and suppresses. It takes `feature` and, each optional, `density`
88
+ (`bins`, a `value` axis and a `count` axis), `examples` (`examples`, a `domain`, `valueFormat`, optional `palette` and
89
+ `context`) and `logits` (`tokens` of `{ id, token, value }` and a `value` axis). It leaves out what is absent. Use
90
+ `size="compact"` in grids and side panels, `actions` for controls beside the name, and `frequencyFormat` for the
91
+ share. It owns no state.
92
+ - `FeatureList` answers "which features exist, and which one should I open?" as a sortable, searchable table. Each row
93
+ is a `FeatureSummary` with optional `maxActivation` and a `profile`, one value per layer. It takes `title`,
94
+ `features`, `frequencyDomain` (starts at zero), `frequencyFormat`, `activationFormat` and optional `profileDomain`.
95
+ The application holds `selected` with `onSelectedChange`, `query` with `onQueryChange` and `sort` with `onSortChange`.
96
+ It filters and sorts the rows it is given, and refuses duplicate ids.
97
+ - `AttributionWorkbench` answers "which features carry the answer from the prompt to the output?" It is an
98
+ `AttributionGraph` beside a panel for the node in focus. It takes the graph's props (`title`, `locale`, `layers`,
99
+ `nodes`, `edges`, `weightLabel`, `weightFormat`, and optional `valueLabel`, `valueFormat` and `direction`) and
100
+ `details`, a `FeatureCardData` per node id. The application holds `selected` with `onSelectedChange` and `pinned` with
101
+ `onPinnedChange`. Pointing at a node shows its card, pressing keeps it, and pinning builds a subgraph. A key of
102
+ `details` that is not a node is refused.
103
+ - `AttentionHeadGrid` answers "what does each head look at?" One attention pattern per head over the same tokens and the
104
+ same 0 to 1 scale, with the selected head enlarged beside the lines from each token. It takes `title`, `tokens`,
105
+ `heads` (`id`, `label`, optional `description`, `weights` with null for a masked pair), `mask` of `none` or `causal`,
106
+ and `minPanelWidth`. The application holds `selected` (the enlarged head) with `onSelectedChange` and `pair`, the
107
+ token pair every head marks, with `onPairChange`. Its id is `matrixCellId(destination, source)`: the token that
108
+ attends, then the token attended to. Left out, `pair` is kept by the grid. It draws at most 32 heads
109
+ (`attentionHeadLimits`). Weights show where a head reads from, not what it computes.
110
+ - `LogitLens` answers "at which layer does the answer form?" A grid of the model's top next-token guess at every layer
111
+ and prompt position, shaded by probability, and a curve of chosen tokens by layer for the selected position. It takes
112
+ `title`, `columns` (the prompt tokens), `layers` (`id`, `label`, `depth`), `cells` (the top prediction and probability
113
+ per layer and position), optional `tracks` (`id`, `columnId`, `token` and one probability per layer) and
114
+ `valueFormat`. The application holds `selected`, a cell id from `tokenGridCellId(layerId, columnId)`, with
115
+ `onSelectedChange`, and decodes every layer.
116
+ - `EmbeddingAtlas` answers "where is a feature on the map, and what is it?" An `EmbeddingMap` with a search box, a list
117
+ of matches and a card for the open feature. It takes the map's props (`title`, `points`, `groups`, `x`, `y` and the
118
+ others), `landmarks` (`id`, `x`, `y`) and `details`, a `FeatureCardData` per landmark id. The application holds
119
+ `query` with `onQueryChange` and `selected` with `onSelectedChange`, and projects the points. A landmark with no
120
+ details is refused.
121
+ - `SteeringPanel` answers "what does the model do when I change a feature's strength?" A slider per feature beside
122
+ next-token predictions, with a tick for each token before steering, and optionally the text before and after. It takes
123
+ `title`, `features` (`id`, `label`, `min`, `max`, `step`, optional `neutral` and `description`), `values` by feature
124
+ id, `predictions` (each with a `baseline`), and optional `prompt`, `completions` (`baseline`, `steered`) and
125
+ `strengthFormat`. The application holds `values` with `onValuesChange`, which Reset also calls with every neutral
126
+ strength, and generates the outputs for the current setting.
127
+
128
+ ```tsx
129
+ import { FeatureCard, FeatureList } from '@mechane-ai/elements/kits/interpretability';
130
+
131
+ <FeatureList
132
+ title="Layer 20 features"
133
+ locale="en-US"
134
+ features={[
135
+ { id: 'f-1', label: 'Golden Gate Bridge', frequency: 0.0004, maxActivation: 9.2 },
136
+ { id: 'f-2', label: 'Suspension bridges', frequency: 0.0011, maxActivation: 6.8 },
137
+ ]}
138
+ frequencyDomain={[0, 0.002]}
139
+ frequencyFormat={{ style: 'percent', maximumFractionDigits: 2 }}
140
+ activationFormat={{ maximumFractionDigits: 1 }}
141
+ selected={openFeature}
142
+ onSelectedChange={(id) => setOpenFeature(id)}
143
+ />;
144
+
145
+ <FeatureCard locale="en-US" size="compact" feature={{ id: 'f-1', label: 'Golden Gate Bridge', frequency: 0.0004 }} />;
146
+ ```
147
+
148
+ ## Put a kit on a page
149
+
150
+ The dashboard and the table each keep a tone scope over `runs`, so a run has one hue in both. The application holds
151
+ selection and hiding and passes them to both.
152
+
153
+ ```tsx
154
+ import { RunDashboard, RunTable } from '@mechane-ai/elements/kits/training';
155
+
156
+ <>
157
+ <RunDashboard
158
+ title="Validation"
159
+ locale="en-US"
160
+ runs={runs}
161
+ metrics={metrics}
162
+ series={series}
163
+ x={{ label: 'Training step', format: { maximumFractionDigits: 0 } }}
164
+ selected={selected}
165
+ onSelectedChange={(id) => setSelected(id)}
166
+ hidden={hidden}
167
+ onHiddenChange={(ids) => setHidden(ids)}
168
+ hasLegend={false}
169
+ />
170
+ <RunTable
171
+ title="Runs"
172
+ locale="en-US"
173
+ runs={runs}
174
+ selected={selected}
175
+ onSelectedChange={(id) => setSelected(id)}
176
+ hidden={hidden}
177
+ onHiddenChange={(ids) => setHidden(ids)}
178
+ />
179
+ </>;
180
+ ```
@@ -0,0 +1,36 @@
1
+ # Teaching layers
2
+
3
+ For an explorable explanation: an essay whose reader changes values in the prose, watches diagrams move between states,
4
+ predicts results and reaches challenges. Five entries work together.
5
+
6
+ | Entry | Holds |
7
+ | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
8
+ | `@mechane-ai/elements/lesson` | `defineLesson`, `Lesson`, `useLesson`, `Param`, `Value`, block controls, `Playback`, `Transport`, `BoundValue` |
9
+ | `@mechane-ai/elements/scene` | `Scene` and its parts: nodes, wires, notes, the plane, cards, cells, tokens, flows, morphs |
10
+ | `@mechane-ai/elements/article` | `Article`, `Beat`, `Figure`, `FigureReference`, `Reveal`, `useRevealed`, `Scrolly`, `Predict`, `Challenge`, `Term`, `DiagramPart`, notes, `TeX`, `articleOutline`, `answerSources` |
11
+ | `@mechane-ai/elements/mdx` | `Essay` and `essayComponents`, for one `.mdx` file as the essay |
12
+ | `@mechane-ai/elements/lesson/spec` | `validateLessonPlan`, `checkLesson`, `describeLesson`, `lessonWalk`, `explainerGuide` |
13
+ | `@mechane-ai/elements/lesson/agent` | `tutorTools`, `createLearnerTrace`, `summarizeTrace`, `playTour`, `validateTour`, `tourFromTrace` |
14
+
15
+ The ideas, in one breath: one lesson store holds every value the reader, the application or an agent may change; a scene
16
+ object with a stable id eases to its new props by itself, so you describe states and never write an animation; an
17
+ article renders the same beats as a scrolling essay, a presentation, a static page and a beat sheet.
18
+
19
+ ## When to switch skills
20
+
21
+ - Asked to explain a topic, a paper or a result interactively: follow the `plan-lesson` skill before writing a
22
+ component.
23
+ - Building or changing the essay: follow the `write-explainer` skill. Start a new one with
24
+ `pnpm exec mechane-elements-catalog --new-essay <directory>`.
25
+ - Checking someone's essay: follow the `review-explainer` skill.
26
+
27
+ ## Moved from the explainers kit
28
+
29
+ `/kits/explainers` no longer exists. `BoundValue` is in `/lesson`; inside a lesson, `<Param name>` replaces it. `Term`,
30
+ `DiagramPart` and `FigureReference` are in `/article`. `NumberedFigure` is `Figure`, `StorySteps` is `Scrolly` with
31
+ `ScrollyStep`s, and `Explainer` is `Article`, which numbers figures from the markup instead of a `figures` list.
32
+
33
+ ## Name clashes
34
+
35
+ - `/article` exports `Figure`, a numbered figure around a chart or scene. `/charts/figure` exports another `Figure`,
36
+ which draws a JSON figure spec. Alias one when a file needs both.
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: write-explainer
3
+ description:
4
+ Write an explorable explanation with the Elements teaching layers from a validated lesson plan. Use when building or
5
+ changing an interactive essay, a lesson, a scene diagram or an MDX essay with `@mechane-ai/elements`.
6
+ ---
7
+
8
+ # Write an explainer
9
+
10
+ Start from a lesson plan that `validateLessonPlan` accepts. If there is none, follow the `plan-lesson` skill first.
11
+
12
+ The layers do the work a hand-written essay repeats: one lesson store holds every value, one clock moves everything,
13
+ scenes ease between states, and the article arranges the same children as an essay, a presentation, a static page and a
14
+ beat sheet. You describe states. You never write an animation.
15
+
16
+ ## Set up
17
+
18
+ For a new essay, scaffold the starter and run it:
19
+
20
+ ```sh
21
+ pnpm exec mechane-elements-catalog --new-essay my-essay
22
+ cd my-essay && pnpm install && pnpm dev
23
+ ```
24
+
25
+ It holds `plan.json`, `src/lesson.ts` (the lesson), `src/figures.tsx` (the figures), `src/essay.mdx` (the prose) and
26
+ `src/main.tsx`, which renders the essay with a "Lesson checks" list under it. In an existing application, import
27
+ `@mechane-ai/elements/styles.css` once and render an `Article` in TSX, or an `Essay` for an MDX file.
28
+
29
+ ## The procedure
30
+
31
+ 1. **Define the lesson.** Copy the plan's params and beats into `defineLesson` in its own file, and write each derived
32
+ value's `from` as a pure function. Every component imports this one definition.
33
+ 2. **Write one beat at a time,** in plan order. For each beat:
34
+ - prose with `<Param name>` where the reader changes a value and `<Value name>` where they read one;
35
+ - its figure: a component that reads `useLesson(lesson)` and draws a chart or a `Scene`, wrapped in
36
+ `<Figure id caption description reads>`;
37
+ - its ask: `Predict` before the result, or `Challenge` once the reader has the controls;
38
+ - `Playback` with a `Transport` for anything that unfolds in time, and `Term` for words that name a figure's object.
39
+ 3. **Look at the beat sheet after every beat.** Open the `sheet` view (`/?view=sheet` in the starter). It draws every
40
+ beat at each declared state, read-only, with a "Checks" list. It is your eyes: if a state looks the same as another,
41
+ the figure does not show the beat's point. Fix every check before the next beat.
42
+ 4. **Read the static view** (`/?view=static`). Every beat opens at its first state with each figure's description after
43
+ it. If the essay does not teach there, the prose leans on motion.
44
+ 5. **Run the checks.** `checkLesson(lesson)` from `@mechane-ai/elements/lesson/spec` must return no findings you have
45
+ not decided to keep. Then review with the `review-explainer` skill.
46
+
47
+ [The worked essay](references/worked-essay.md) is a complete essay built this way, type checked against the package. The
48
+ package ships a second, larger one as a recipe: `pnpm exec mechane-elements-catalog counting cards` prints its path
49
+ (`recipes/counting-cards.tsx`) and its Storybook story (`Recipes/Counting Cards`). It deals a deck with `SceneStack`
50
+ stagger, reveals with `useRevealed` and morphs cards into bars; its story builds the tutor `answers` with
51
+ `answerSources`.
52
+
53
+ ## Choose the part by the reader's question
54
+
55
+ Take the part from `explainerGuide` (in `@mechane-ai/elements/lesson/spec`), whose examples compile. Do not invent one.
56
+
57
+ | The reader asks | Part |
58
+ | ------------------------------------------------------------- | -------------------------------------------- |
59
+ | What happens if I change this number in the sentence? | `Param` |
60
+ | What is the result right now? | `Value` |
61
+ | How does the figure change as I sweep this value? | `ParamSlider`, `ParamChoice`, `ParamToggle` |
62
+ | How does this unfold over time? Can I pause it? | `Playback` with `Transport` |
63
+ | How are these parts connected, and what moves? | `Scene`, `SceneNode`, `SceneWire` |
64
+ | What does this run of things add up to? Why does it matter? | `SceneGroup`, `SceneBracket`, `SceneCallout` |
65
+ | Where should I look now? | `SceneHighlight`, or the scene's `focus` |
66
+ | What is the shape of this function? What if I move the point? | `SceneAxes`, `SceneCurve`, `ScenePoint` |
67
+ | Which way does this push? Where is the threshold? | `SceneVector`, `SceneRule`, `SceneRegion` |
68
+ | What is on the other side, and which comes first? | `SceneCard`, `SceneStack`, `SceneSlot` |
69
+ | What is inside this vector or matrix? | `SceneCells` |
70
+ | How is this text split into tokens? | `SceneTokens`, `SceneToken` |
71
+ | How is this result computed from what I can change? | `LessonFlow`, `SceneFlow` |
72
+ | Is this the same thing, now shown as data? | `MorphScope` |
73
+ | How does the picture change as I read on? | `Scrolly` with `ScrollyStep` |
74
+ | What do I expect before I see it? Can I make it do this? | `Predict`, `Challenge` |
75
+ | Which part of the figure does this word mean? | `Term` |
76
+ | A trend, a distribution, a comparison of measured data | a chart, chosen from `chartGuide` |
77
+
78
+ ## Rules, and why
79
+
80
+ - **No `useState` for what the lesson holds.** A value in component state is invisible to the prose, the sheet, the URL,
81
+ storage and agents. Read it with `useLesson(lesson)` and change it with `set`. A draggable `ScenePoint` writes its
82
+ params through `sets`, which keeps them on their step grid and inside their range; do not round in a handler.
83
+ - **No `requestAnimationFrame`, timer or CSS keyframe for motion.** Change a part's props and it eases on the shared
84
+ clock, which also gives reduced motion its end state. Drive time with `Playback`.
85
+ - **No hand-placed SVG where a scene part exists.** Parts are inspectable, keyboard-reachable and themed. Draw what no
86
+ part draws with `SceneCustom`, which hands you the scene's scales and tones.
87
+ - **Stable ids name things, not slots.** The Queen of Hearts is `queen-hearts` in every state and figure, so it moves
88
+ instead of being replaced, and a `Term` lights it everywhere. Swap the id only when the thing itself changes.
89
+ - **Write `Beat`, `Figure`, `Param`, `Playback`, `Transport`, `Predict` and `Challenge` directly in the article's
90
+ children.** The article reads that markup to build the outline, the sheet and its checks. It does not render your own
91
+ components to look inside them. A `Beat`, `Figure`, `Predict` or `Challenge` inside one shows an inline error in the
92
+ page:
93
+ `… sits inside a component of your own, so the outline, the beat sheet and the tutor miss it. Write it directly in the Article's children.`
94
+ Plain elements and fragments are fine.
95
+ - **Give every `Figure` a `description` and its `reads`.** The description is the static view and the screen reader.
96
+ `reads` lists the lesson names your figure component reads, which the markup cannot show.
97
+ - **A figure takes no props from its parent.** The sheet renders each figure alone under a read-only lesson at each
98
+ state, so everything it shows must come from `useLesson`.
99
+ - **Declare tones once** on `Article` with `tones`, by the ids the figures use. Never write a color.
100
+ - **Prose never copies a number.** Write `<Value name="sum" />`, so the sentence agrees with the figure.
101
+ - **Say synthetic data is synthetic,** in the summary or a figure's description.
102
+ - **Ids of figures differ from beat ids.** Beats, figures, footnotes and references all become element ids in the page,
103
+ and the checks name any two parts that share one.
104
+
105
+ ## References
106
+
107
+ - [Lesson](references/lesson.md): `defineLesson`, `Lesson`, `useLesson`, prose controls, `Playback` and `Transport`.
108
+ - [Scene](references/scene.md): the box, nodes, wires, notes, the camera, `SceneCustom`.
109
+ - [Scene parts](references/scene-parts.md): the plane, cards, cells, tokens, `SceneFlow`, `MorphScope`.
110
+ - [Article and views](references/article.md): beats, figures, asks, notes, math, the four views and their checks.
111
+ - [MDX](references/mdx.md): one `.mdx` file as the essay.
112
+ - [Tutor](references/tutor.md): tutor tools, the learner trace and tours.
@@ -0,0 +1,164 @@
1
+ # Article and views
2
+
3
+ Import from `@mechane-ai/elements/article`. An `Article` renders a lesson as beats of prose, figures and exercises, and
4
+ arranges the same children four ways. It renders the `Lesson`, a `ChartLink` and a `ToneScope` for you.
5
+
6
+ ## `Article`
7
+
8
+ | Prop | What it does |
9
+ | ------------------------------------------------- | -------------------------------------------------------------------------------------- |
10
+ | `lesson`, `locale`, `title` | Required. |
11
+ | `authors`, `date`, `summary` | The byline, an ISO date, and a sentence or two on what the reader will learn. |
12
+ | `tones` | The tone of each id the figures and terms share, declared once. |
13
+ | `view` | `'article'` (default), `'present'`, `'static'` or `'sheet'`. |
14
+ | `math` | `(tex, { isDisplay }) => ReactNode`, the application's typesetter. |
15
+ | `storageKey` | Keeps the values and the reader's progress across visits. |
16
+ | `progress`, `defaultProgress`, `onProgressChange` | The reader's predictions, challenges, hints and visits, if the application holds them. |
17
+ | `lessonProps` | Passed to the `Lesson`: controlled values, beat and step, `shouldSyncUrl`. |
18
+ | `labels` | The article's own words, with English defaults. |
19
+
20
+ ## Markup the article reads
21
+
22
+ The article walks the markup you write to find beats, figures, players and prose params. It does not render your own
23
+ components to look inside them. So:
24
+
25
+ - Write `Beat`, `Figure`, `Param`, `Playback`, `Transport`, `Predict`, `Challenge`, `Footnote` and `References` in the
26
+ article's children or in the MDX file, not inside a component of your own. Plain elements and fragments are fine, so
27
+ the beats can be one exported fragment that `articleOutline` also reads. A `Beat`, `Figure`, `Predict` or `Challenge`
28
+ inside your own component draws an inline error in its place:
29
+ `Figure "vote-scene" sits inside a component of your own, so the outline, the beat sheet and the tutor miss it. Write it directly in the Article's children.`
30
+ - Put each figure's drawing in your component, inside a `Figure`, and list in `reads` every lesson name it reads.
31
+ - Every `<Beat id>` names a beat the lesson declares, and every declared beat is rendered once, in order.
32
+
33
+ ## Parts
34
+
35
+ - `Beat`: `id` and children. Its title, tutor notes, reveal steps and states come from the lesson.
36
+ - `Figure`: `id` (unique, and different from every beat id), `caption`, `description` (the figure in words, printed in
37
+ the static view), `reads`, `size` (`'wide'`, the default, reaches into the margin; `'text'` keeps the column).
38
+ - `FigureReference`: `to`, a figure id. Writes "Figure 2" as a link. Never write a figure number by hand.
39
+ - `Reveal`: `at`, a reveal step from 0 up to the beat's declared `steps`. It hides content only in the present view; the
40
+ other views show everything. `useRevealed(at)` gives the same answer to a figure that reveals its own parts: true in
41
+ the article, static and sheet views and outside a beat, and following the beat's step in the present view.
42
+ - `Scrolly`: a sticky `figure` beside `ScrollyStep`s; each step has an `id` and sets `values` or a beat `state` while it
43
+ is in view. Use it when reading on should change the picture; use controls when the reader should drive.
44
+ - `Predict`: `id`, `prompt`, the explanation as children, and either `options` with an `answer` id, or `min`, `max`,
45
+ `step`, `format` with an `answer` or an `answerFrom` (a lesson value read when the reader commits) and `tolerance`.
46
+ The answer stays hidden, from the reader and from agents, until the reader commits.
47
+ - `Challenge`: `id`, `prompt`, `isReached(values)` reading params and derived values by name, `hints`, and the outcome
48
+ as children. Only the reader's own changes reach it; an agent's never do.
49
+ - `Term`: `inspects` (an id the figures use) and words. Pointing at it or focusing it marks that object in every figure.
50
+ - `DiagramPart`: `inspects` and `label` around hand-drawn SVG shapes, linking them to the figures both ways. Prefer a
51
+ scene part.
52
+ - `Aside` (a margin note), `Footnote` (`id`, one sentence), `Cite` (`id` of a reference), and one `References` with
53
+ `items` of `{ id, authors, title, year, venue?, url? }` after the last beat.
54
+ - `TeX`: TeX source as its child string, `isDisplay` for a block. Without a `math` prop on `Article` it shows its
55
+ source.
56
+
57
+ One beat as a fragment (the rest of the lesson's beats would follow it):
58
+
59
+ ```tsx
60
+ import {
61
+ Article,
62
+ Aside,
63
+ Beat,
64
+ Cite,
65
+ Figure,
66
+ FigureReference,
67
+ Footnote,
68
+ TeX,
69
+ Predict,
70
+ References,
71
+ } from '@mechane-ai/elements/article';
72
+ import type { ArticleMath, ArticleView } from '@mechane-ai/elements/article';
73
+ import { Value } from '@mechane-ai/elements/lesson';
74
+ import type { ReactNode } from 'react';
75
+ import { ConfidenceScene } from './figures.tsx';
76
+ import { lesson } from './lesson.ts';
77
+
78
+ export function BiasArticle({ view, math }: { readonly view: ArticleView; readonly math: ArticleMath }): ReactNode {
79
+ return (
80
+ <Article
81
+ lesson={lesson}
82
+ locale="en-US"
83
+ title="A neuron is a weighted vote"
84
+ authors={['A. Researcher']}
85
+ date="2026-11-24"
86
+ view={view}
87
+ math={math}
88
+ lessonProps={{ shouldSyncUrl: true }}
89
+ >
90
+ <Beat id="bias">
91
+ <p>
92
+ The neuron turns its sum into a chance with the sigmoid, <TeX>{String.raw`\sigma(s) = 1 / (1 + e^{-s})`}</TeX>
93
+ <Cite id="rosenblatt1958" />. At the current sum it says yes with a chance of <Value name="yes" /> (
94
+ <FigureReference to="confidence" />
95
+ ).
96
+ <Footnote id="sigmoid">A perceptron used a hard step instead; the sigmoid is its smooth version.</Footnote>
97
+ </p>
98
+ <Predict
99
+ id="zero-sum"
100
+ prompt="At a weighted sum of exactly zero, how sure is the neuron?"
101
+ min={0}
102
+ max={1}
103
+ step={0.05}
104
+ format={{ style: 'percent', maximumFractionDigits: 0 }}
105
+ answer={0.5}
106
+ tolerance={0.05}
107
+ >
108
+ <p>The sigmoid of zero is one half: no evidence either way.</p>
109
+ </Predict>
110
+ <Figure
111
+ id="confidence"
112
+ caption="The sigmoid turns the sum into a chance."
113
+ description="An S-shaped curve of the chance of yes against the bias, with a point at the current bias."
114
+ reads={['sum', 'yes', 'bias']}
115
+ size="text"
116
+ >
117
+ <ConfidenceScene />
118
+ </Figure>
119
+ <Aside>Real networks use many activation functions; the sigmoid is the oldest.</Aside>
120
+ </Beat>
121
+ <References
122
+ items={[
123
+ {
124
+ id: 'rosenblatt1958',
125
+ authors: ['Frank Rosenblatt'],
126
+ title: 'The perceptron: a probabilistic model for information storage and organization in the brain',
127
+ year: 1958,
128
+ venue: 'Psychological Review',
129
+ },
130
+ ]}
131
+ />
132
+ </Article>
133
+ );
134
+ }
135
+ ```
136
+
137
+ ## The four views
138
+
139
+ The same children, arranged four ways. In the essay starter, `?view=present`, `?view=static` and `?view=sheet` choose
140
+ one.
141
+
142
+ | View | What it is |
143
+ | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
144
+ | `article` | The scrolling essay, with a contents list that follows the reading position and sets the lesson's beat. |
145
+ | `present` | One beat at a time, opened at its first declared state each time the presenter reaches it. Right or Space runs `next` (the next reveal step, then the next beat); Left goes back. A `Scrolly` shows its figure beside its steps, which are walked before the reveal steps. |
146
+ | `static` | Every beat open at its first state, every reveal shown, each figure followed by its description, no motion. |
147
+ | `sheet` | Every beat at each of its states, read-only and scaled to fit its cell, with its tutor notes, then "Checks". |
148
+
149
+ The sheet's checks, and what each means:
150
+
151
+ | Check | Fix |
152
+ | ------------------------------------------------------ | ---------------------------------------------------- |
153
+ | The lesson declares a beat the article does not render | Add the `<Beat>`, or remove the beat from the lesson |
154
+ | The article renders a beat the lesson does not declare | Declare it, or fix the id |
155
+ | A beat has no figure | Give it one, or fold it into the beat before |
156
+ | A figure has no description | Write the figure in words |
157
+ | Two parts share an element id | Rename one (beats, figures, footnotes, references) |
158
+ | A `Predict` or `Challenge` sits outside every `Beat` | Move it into the beat it belongs to |
159
+ | A `Playback` has no `Transport` | Add `<Transport for>` the reader can reach |
160
+ | A `Param` in the prose changes no figure of its beat | Name it in a figure's `reads`, or move the control |
161
+
162
+ `articleChecks(lesson, articleOutline(children))` returns the same list as data, for a test page or an agent. The
163
+ outline also lists the essay's `predictions` and `challenges`; `answerSources(outline)` turns its predictions into the
164
+ `answers` a tutor needs (see the [tutor reference](tutor.md)).
@@ -0,0 +1,148 @@
1
+ # Lesson
2
+
3
+ Import from `@mechane-ai/elements/lesson`. A lesson is one store that every part of an essay reads: prose, controls,
4
+ figures, players and agents. Contract 142 holds the rules.
5
+
6
+ ## `defineLesson`
7
+
8
+ ```ts
9
+ const lesson = defineLesson({ id, title, params, derived, beats });
10
+ ```
11
+
12
+ - `params`: number (`value`, `min`, `max`, `step`, optional `scale: 'log'`, `format`), choice (`value`, `options` of
13
+ `{ id, label }`) and toggle (`value`) params, each with a `label`.
14
+ - `derived`: `{ label, format, from }`. `from` receives the params and the derived values declared above it, typed, and
15
+ returns a number. Keep it pure: no randomness, no time, no fetch.
16
+ - `beats`: `{ id, title, goal?, misconception?, hints?, steps?, states? }`. Goals, misconceptions and hints are tutor
17
+ notes; the reader never sees them. `states` are `{ id, label, values }`, where `values` set params only.
18
+ - It throws a named `Error` for a bad definition, at module load, so a mistake fails before anything renders.
19
+ - The result carries `defaults`, `initial` (params and derived values at the opening), `compute(values)` and `reads`
20
+ (the names each derived value reads, found by running it). `lessonGraph(lesson)` gives the same as nodes and edges.
21
+
22
+ Choice ids and beat ids are literal types: `values.hand` is `'queen-seven' | 'two-king'`, and `set('hand', 'three')`
23
+ does not compile.
24
+
25
+ ## `Lesson`
26
+
27
+ `Article` renders the `Lesson` for you; pass `Lesson` props through its `lessonProps`. Render `Lesson` yourself only for
28
+ a lesson outside an article, or an independent second copy.
29
+
30
+ | Prop | What it does |
31
+ | ------------------------------------------- | ------------------------------------------------------------------------------ |
32
+ | `lesson`, `locale` | Required. The locale writes every value. |
33
+ | `values`, `defaultValues`, `onValuesChange` | Controlled or not. The callback gets the values, then details. |
34
+ | `beat`, `defaultBeat`, `onBeatChange` | The current beat id. |
35
+ | `step`, `defaultStep`, `onStepChange` | The reveal step inside the beat, from 0. |
36
+ | `onPlayingChange` | Hears a player start or stop. |
37
+ | `shouldSyncUrl` | Reads values from the address on mount and writes them back. |
38
+ | `storageKey` | Keeps values across visits. On `Article`, it also keeps the reader's progress. |
39
+ | `isReadOnly` | A frozen copy, as the beat sheet uses. Hidden from agents. |
40
+
41
+ Change details carry `reason` (`drag`, `step-key`, `playback`, `scroll`, `reset`, `imperative` and others), `source`
42
+ (`mouse`, `keyboard`, `touch`, `agent`, `programmatic`) and `cancel()`. An application refuses a change by cancelling:
43
+
44
+ ```tsx
45
+ /** The application holds the values and refuses a bias below −8. */
46
+ export function HeldLesson({ children }: { readonly children: ReactNode }): ReactNode {
47
+ const [values, setValues] = useState<Partial<ParamValues<typeof lesson.params>>>({ bias: 0 });
48
+
49
+ return (
50
+ <Lesson
51
+ lesson={lesson}
52
+ locale="en-US"
53
+ values={values}
54
+ onValuesChange={(next, details) => {
55
+ if (next.bias < -8) {
56
+ details.cancel();
57
+ } else {
58
+ setValues(next);
59
+ }
60
+ }}
61
+ >
62
+ {children}
63
+ </Lesson>
64
+ );
65
+ }
66
+ ```
67
+
68
+ ## `useLesson`
69
+
70
+ `useLesson(lesson)` is typed by the definition and throws outside a `Lesson` that renders it. `useLessonContext()` is
71
+ the untyped form for parts that work in any lesson.
72
+
73
+ | Field | What it is |
74
+ | ------------------------------------------- | ------------------------------------------------------------------------------- |
75
+ | `values` | Every param and derived value now. |
76
+ | `set(name, value, origin?)` | Sets one param. A value outside its range or options **throws**. |
77
+ | `setMany(values, origin?)` | Sets several params in one change. |
78
+ | `show(stateId, origin?)` | Shows a declared state as the whole picture, looking in the current beat first. |
79
+ | `reset()` | Every param back to its opening value. |
80
+ | `beat`, `step` | Where the reader is. |
81
+ | `goTo(beat, step?)`, `next()`, `previous()` | Move. `next` reveals the next step, then goes to the next beat. |
82
+ | `locale`, `lesson` | The lesson's locale and definition. |
83
+
84
+ In the article view, going to a beat does not apply its states: the reader keeps the values they set. The present view
85
+ opens a beat that declares states at its first one, each time the presenter moves to it; the static view and the sheet
86
+ draw states too. Elsewhere, only `show`, a `ScrollyStep` with `state` and a tutor's `show_state` apply a state. A state
87
+ is the whole picture: a param it does not name takes the value the lesson opened with, so a state looks the same live,
88
+ on the sheet and in a tour. To change some params and keep the rest, use `setMany`.
89
+
90
+ A control of yours that calls `set` keeps the value on the param's step and inside its range, and passes the event's
91
+ details as the origin so the change reports a reader's source:
92
+ `set('bias', bias, { reason: details.reason, event: details.event })`. A draggable `ScenePoint` needs no handler: its
93
+ `sets` prop writes the params for it.
94
+
95
+ ```tsx
96
+ /** A button that shows a declared state, and one that resets. */
97
+ export function StateButtons(): ReactNode {
98
+ const { show, reset, beat, next } = useLesson(lesson);
99
+
100
+ return (
101
+ <>
102
+ <Button onClick={() => show('skeptic')}>Show a skeptical neuron</Button>
103
+ <Button onClick={() => reset()}>Start again</Button>
104
+ <Button onClick={() => next()}>{beat === 'learning' ? 'Done' : 'Next'}</Button>
105
+ </>
106
+ );
107
+ }
108
+ ```
109
+
110
+ ## Prose and controls
111
+
112
+ - `<Param name="rate" />` in a sentence: a number the reader drags or steps with the arrow keys, a choice that opens an
113
+ inline picker, a toggle that switches.
114
+ - `<Value name="loss" />`: a param or derived value in its declared format. `labels` names a toggle's on and off.
115
+ - `<ParamSlider name />`, `<ParamChoice name />`, `<ParamToggle name />`: labelled block controls, for under a figure.
116
+ `ParamChoice` suits two to five options.
117
+ - `BoundValue` is the number-in-a-sentence control without a lesson: `value` with `onValueChange` or `defaultValue`,
118
+ `min`, `max`, `step`, optional `scale`, `locale`, `format` and `label`. Inside a lesson, use `Param`.
119
+
120
+ A name the lesson does not declare draws a short inline error in the danger color. Read the page, not only the types.
121
+
122
+ ## Time
123
+
124
+ `<Playback name from? to? pace? isLooping? />` drives a number param one step at a time on the shared clock. It renders
125
+ nothing. `pace` is `'fast'`, `'regular'` or `'slow'`. It pauses when the tab is hidden or the reader moves the value,
126
+ and with reduced motion `play` jumps to the end.
127
+
128
+ `<Transport for="name" labels? />` plays, pauses, steps and scrubs it. Every `Playback` needs a `Transport` the reader
129
+ can reach, or the beat sheet flags it. `usePlayback(name)` returns `{ isPlaying, play, pause, toggle, stepBy, seek }`
130
+ for a control of your own.
131
+
132
+ ```tsx
133
+ /** Plays the bias from −10 to 10 and lets the reader pause and scrub it. */
134
+ export function BiasSweep(): ReactNode {
135
+ const player = usePlayback('bias');
136
+
137
+ return (
138
+ <>
139
+ <Playback name="bias" from={-10} to={10} pace="regular" />
140
+ <Transport for="bias" />
141
+ <Button onClick={() => player.seek(0)}>{player.isPlaying ? 'Playing' : 'Back to zero'}</Button>
142
+ </>
143
+ );
144
+ }
145
+ ```
146
+
147
+ For motion inside your own component, `useTween(target, pace?)` returns an eased copy of a record of numbers on the same
148
+ clock. Prefer a scene part, which already eases.