@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.
- package/README.md +590 -34
- package/bin/mechane-elements-catalog.mjs +104 -12
- package/dist/ai.js +4 -4
- package/dist/article-BXZr10QQ.js +1904 -0
- package/dist/article.js +1 -0
- package/dist/catalog.json +3696 -33
- package/dist/categorical-values-BpVq8cFj.js +107 -0
- package/dist/cells-xVmnQ9oQ.js +384 -0
- package/dist/chart-link-AE_xuxiP.js +35 -0
- package/dist/chart-tones-ei3BC2AL.js +27 -0
- package/dist/charts/cartesian.js +1 -2958
- package/dist/charts/cells.js +1 -0
- package/dist/charts/comparison.js +1 -0
- package/dist/charts/distribution.js +1 -781
- package/dist/charts/figure.js +3404 -0
- package/dist/charts/graph.js +1 -655
- package/dist/charts/hierarchy.js +1 -121
- package/dist/charts/image.js +1 -0
- package/dist/charts/matrix.js +4 -644
- package/dist/charts/plot.js +15 -0
- package/dist/charts/relationship.js +1 -0
- package/dist/charts/text.js +1 -0
- package/dist/charts/timeline.js +1 -266
- package/dist/charts/transforms.js +677 -0
- package/dist/charts/trend.js +1 -0
- package/dist/charts.js +8 -3
- package/dist/clock-DSm5lkNE.js +16 -0
- package/dist/collections.js +1 -2195
- package/dist/color-legend-CIo7DhXB.js +62 -0
- package/dist/dates-Cww8UR_n.js +810 -0
- package/dist/describe-lesson-BmREzDpt.js +175 -0
- package/dist/dumbbell-plot-DQdTxDeO.js +509 -0
- package/dist/embedding-map-CF-J-8JW.js +1929 -0
- package/dist/feedback.js +1 -1
- package/dist/figure-format-B8kRZMlo.js +36 -0
- package/dist/figure-frame-BJ3REgTA.js +270 -0
- package/dist/forms/dates.js +1 -810
- package/dist/forms.js +1 -1
- package/dist/heatmap-scale-Zte6Ya-g.js +20 -0
- package/dist/image-grid-Dl2sjIMB.js +598 -0
- package/dist/kits/evaluation.js +431 -0
- package/dist/kits/interpretability.js +1033 -0
- package/dist/kits/operations.js +239 -0
- package/dist/kits/training.js +335 -0
- package/dist/label-place-Z0fryBZb.js +42 -0
- package/dist/lesson/agent.js +811 -0
- package/dist/lesson/spec.js +661 -0
- package/dist/lesson.js +5 -0
- package/dist/locate-Bcg3QcP4.js +11 -0
- package/dist/mdx.js +227 -0
- package/dist/packages/charts/src/cartesian/bar-chart.d.ts +40 -21
- package/dist/packages/charts/src/cartesian/bar-data.d.ts +15 -4
- package/dist/packages/charts/src/cartesian/bar-overlays.d.ts +7 -3
- package/dist/packages/charts/src/cartesian/breakdown-bar.d.ts +10 -8
- package/dist/packages/charts/src/cartesian/bridge-chart.d.ts +20 -16
- package/dist/packages/charts/src/cartesian/bridge-data.d.ts +5 -4
- package/dist/packages/charts/src/cartesian/composition-bars.d.ts +8 -4
- package/dist/packages/charts/src/cartesian/index.d.ts +5 -5
- package/dist/packages/charts/src/cartesian/reference-lines.d.ts +25 -18
- package/dist/packages/charts/src/cartesian/scatter-plot.d.ts +30 -25
- package/dist/packages/charts/src/cartesian/sparkline.d.ts +14 -2
- package/dist/packages/charts/src/cartesian/time-series-bands.d.ts +3 -2
- package/dist/packages/charts/src/cartesian/time-series-data.d.ts +12 -2
- package/dist/packages/charts/src/cartesian/time-series-line.d.ts +2 -2
- package/dist/packages/charts/src/cartesian/time-series-overlays.d.ts +6 -4
- package/dist/packages/charts/src/cartesian/time-series.d.ts +60 -36
- package/dist/packages/charts/src/cartesian/value-labels.d.ts +22 -0
- package/dist/packages/charts/src/categorical-values.d.ts +1 -1
- package/dist/packages/charts/src/cells/bar-cell.d.ts +13 -0
- package/dist/packages/charts/src/cells/cell-layout.d.ts +81 -0
- package/dist/packages/charts/src/cells/change-cell.d.ts +17 -0
- package/dist/packages/charts/src/cells/heat-cell.d.ts +19 -0
- package/dist/packages/charts/src/cells/index.d.ts +11 -0
- package/dist/packages/charts/src/cells/interval-cell.d.ts +16 -0
- package/dist/packages/charts/src/cells/spark-cell.d.ts +22 -0
- package/dist/packages/charts/src/chart-frame.d.ts +14 -7
- package/dist/packages/charts/src/chart-grid.d.ts +19 -0
- package/dist/packages/charts/src/chart-input.d.ts +1 -9
- package/dist/packages/charts/src/chart-link.d.ts +56 -0
- package/dist/packages/charts/src/chart.d.ts +0 -8
- package/dist/packages/charts/src/comparison/bullet-bar.d.ts +34 -0
- package/dist/packages/charts/src/comparison/comparison-plot.d.ts +54 -0
- package/dist/packages/charts/src/comparison/dot-plot.d.ts +41 -0
- package/dist/packages/charts/src/comparison/dumbbell-plot.d.ts +33 -0
- package/dist/packages/charts/src/comparison/index.d.ts +6 -0
- package/dist/packages/charts/src/distribution/box-plot.d.ts +40 -0
- package/dist/packages/charts/src/distribution/distribution-input.d.ts +5 -3
- package/dist/packages/charts/src/distribution/distribution-plot.d.ts +28 -161
- package/dist/packages/charts/src/distribution/ecdf.d.ts +16 -15
- package/dist/packages/charts/src/distribution/group-plot-input.d.ts +35 -0
- package/dist/packages/charts/src/distribution/group-plot-layout.d.ts +79 -0
- package/dist/packages/charts/src/distribution/group-plot.d.ts +73 -0
- package/dist/packages/charts/src/distribution/histogram.d.ts +16 -16
- package/dist/packages/charts/src/distribution/index.d.ts +11 -0
- package/dist/packages/charts/src/distribution/interval-plot.d.ts +16 -13
- package/dist/packages/charts/src/distribution/ranked-bars.d.ts +17 -14
- package/dist/packages/charts/src/distribution/ridgeline.d.ts +34 -0
- package/dist/packages/charts/src/distribution/strip-plot.d.ts +37 -0
- package/dist/packages/charts/src/distribution/violin-plot.d.ts +34 -0
- package/dist/packages/charts/src/figure/figure-format.d.ts +34 -0
- package/dist/packages/charts/src/figure/figure-frame.d.ts +47 -0
- package/dist/packages/charts/src/figure/figure-props.d.ts +54 -0
- package/dist/packages/charts/src/figure/tone-scope.d.ts +32 -0
- package/dist/packages/charts/src/graph/attribution-graph.d.ts +62 -0
- package/dist/packages/charts/src/graph/attribution-layout.d.ts +88 -0
- package/dist/packages/charts/src/graph/flow-diagram.d.ts +14 -15
- package/dist/packages/charts/src/graph/flow-layout.d.ts +4 -2
- package/dist/packages/charts/src/graph/graph-canvas.d.ts +33 -0
- package/dist/packages/charts/src/graph/index.d.ts +6 -2
- package/dist/packages/charts/src/graph/relation-graph.d.ts +24 -13
- package/dist/packages/charts/src/graph/tree-diagram.d.ts +41 -0
- package/dist/packages/charts/src/graph/tree-layout.d.ts +71 -0
- package/dist/packages/charts/src/hierarchy/area-mark.d.ts +17 -0
- package/dist/packages/charts/src/hierarchy/icicle.d.ts +35 -0
- package/dist/packages/charts/src/hierarchy/index.d.ts +2 -0
- package/dist/packages/charts/src/hierarchy/partition-layout.d.ts +25 -0
- package/dist/packages/charts/src/hierarchy/treemap-layout.d.ts +26 -0
- package/dist/packages/charts/src/hierarchy/treemap.d.ts +11 -9
- package/dist/packages/charts/src/image/attribution-legend.d.ts +13 -0
- package/dist/packages/charts/src/image/attribution-overlay.d.ts +50 -0
- package/dist/packages/charts/src/image/attribution-ramp.d.ts +16 -0
- package/dist/packages/charts/src/image/image-atlas.d.ts +37 -0
- package/dist/packages/charts/src/image/image-fill.d.ts +9 -0
- package/dist/packages/charts/src/image/image-grid.d.ts +26 -0
- package/dist/packages/charts/src/image/image-input.d.ts +27 -0
- package/dist/packages/charts/src/image/image-tile.d.ts +27 -0
- package/dist/packages/charts/src/image/index.d.ts +7 -0
- package/dist/packages/charts/src/index.d.ts +15 -1
- package/dist/packages/charts/src/matrix/attention-matrix.d.ts +41 -0
- package/dist/packages/charts/src/matrix/calendar-heatmap.d.ts +37 -0
- package/dist/packages/charts/src/matrix/color-legend.d.ts +9 -2
- package/dist/packages/charts/src/matrix/confusion-matrix.d.ts +36 -0
- package/dist/packages/charts/src/matrix/correlation-matrix.d.ts +34 -0
- package/dist/packages/charts/src/matrix/heatmap-scale.d.ts +8 -2
- package/dist/packages/charts/src/matrix/index.d.ts +15 -3
- package/dist/packages/charts/src/matrix/matrix-cells.d.ts +27 -3
- package/dist/packages/charts/src/matrix/matrix-figure.d.ts +50 -0
- package/dist/packages/charts/src/matrix/matrix-mark.d.ts +34 -0
- package/dist/packages/charts/src/matrix/matrix-presets.d.ts +20 -0
- package/dist/packages/charts/src/matrix/matrix-range.d.ts +45 -0
- package/dist/packages/charts/src/matrix/matrix-strip.d.ts +13 -14
- package/dist/packages/charts/src/matrix/matrix-types.d.ts +40 -0
- package/dist/packages/charts/src/matrix/matrix.d.ts +13 -11
- package/dist/packages/charts/src/matrix/token-heatmap.d.ts +16 -10
- package/dist/packages/charts/src/plot/contours.d.ts +45 -0
- package/dist/packages/charts/src/plot/index.d.ts +49 -0
- package/dist/packages/charts/src/plot/label-place.d.ts +35 -0
- package/dist/packages/charts/src/plot/locate.d.ts +18 -0
- package/dist/packages/charts/src/plot/path.d.ts +39 -0
- package/dist/packages/charts/src/plot/plot-axes.d.ts +20 -0
- package/dist/packages/charts/src/plot/plot-layout.d.ts +221 -0
- package/dist/packages/charts/src/plot/plot-marks.d.ts +128 -0
- package/dist/packages/charts/src/plot/plot-surface.d.ts +32 -0
- package/dist/packages/charts/src/plot/render/density-layer.d.ts +17 -0
- package/dist/packages/charts/src/plot/render/hit-index.d.ts +37 -0
- package/dist/packages/charts/src/plot/render/plot-viewport.d.ts +39 -0
- package/dist/packages/charts/src/plot/render/point-layer.d.ts +41 -0
- package/dist/packages/charts/src/plot/render/theme-colors.d.ts +15 -0
- package/dist/packages/charts/src/plot/scale.d.ts +48 -0
- package/dist/packages/charts/src/plot/ticks.d.ts +34 -0
- package/dist/packages/charts/src/plot-width.d.ts +3 -2
- package/dist/packages/charts/src/relationship/contour-plot.d.ts +61 -0
- package/dist/packages/charts/src/relationship/density-map.d.ts +45 -0
- package/dist/packages/charts/src/relationship/embedding-map.d.ts +75 -0
- package/dist/packages/charts/src/relationship/index.d.ts +11 -0
- package/dist/packages/charts/src/relationship/level-legend.d.ts +11 -0
- package/dist/packages/charts/src/relationship/measures.d.ts +85 -0
- package/dist/packages/charts/src/relationship/parallel-coordinates.d.ts +30 -0
- package/dist/packages/charts/src/relationship/range-controls.d.ts +20 -0
- package/dist/packages/charts/src/relationship/scatter-matrix.d.ts +20 -0
- package/dist/packages/charts/src/spec/chart-guide.d.ts +21 -0
- package/dist/packages/charts/src/spec/figure-registry.d.ts +44 -0
- package/dist/packages/charts/src/spec/figure-spec.d.ts +147 -0
- package/dist/packages/charts/src/spec/figure-text.d.ts +8 -0
- package/dist/packages/charts/src/spec/figure.d.ts +12 -0
- package/dist/packages/charts/src/spec/guide-data.d.ts +85 -0
- package/dist/packages/charts/src/spec/index.d.ts +10 -0
- package/dist/packages/charts/src/spec/validate-figure.d.ts +15 -0
- package/dist/packages/charts/src/text/index.d.ts +11 -0
- package/dist/packages/charts/src/text/token-examples.d.ts +42 -0
- package/dist/packages/charts/src/text/token-grid.d.ts +47 -0
- package/dist/packages/charts/src/text/token-links.d.ts +49 -0
- package/dist/packages/charts/src/text/token-predictions.d.ts +38 -0
- package/dist/packages/charts/src/text/token-scale.d.ts +20 -0
- package/dist/packages/charts/src/text/token-text.d.ts +39 -0
- package/dist/packages/charts/src/timeline/event-strip.d.ts +70 -0
- package/dist/packages/charts/src/timeline/index.d.ts +3 -1
- package/dist/packages/charts/src/timeline/waterfall.d.ts +24 -13
- package/dist/packages/charts/src/transforms/bins.d.ts +91 -0
- package/dist/packages/charts/src/transforms/density.d.ts +53 -0
- package/dist/packages/charts/src/transforms/fits.d.ts +50 -0
- package/dist/packages/charts/src/transforms/index.d.ts +19 -0
- package/dist/packages/charts/src/transforms/matrices.d.ts +49 -0
- package/dist/packages/charts/src/transforms/quantiles.d.ts +96 -0
- package/dist/packages/charts/src/transforms/ranks.d.ts +44 -0
- package/dist/packages/charts/src/transforms/runs.d.ts +47 -0
- package/dist/packages/charts/src/transforms/sampling.d.ts +75 -0
- package/dist/packages/charts/src/transforms/smoothing.d.ts +41 -0
- package/dist/packages/charts/src/transforms/values.d.ts +70 -0
- package/dist/packages/charts/src/trend/bump-chart.d.ts +33 -0
- package/dist/packages/charts/src/trend/column-figure.d.ts +38 -0
- package/dist/packages/charts/src/trend/column-positions.d.ts +21 -0
- package/dist/packages/charts/src/trend/curve-chart.d.ts +69 -0
- package/dist/packages/charts/src/trend/end-labels.d.ts +40 -0
- package/dist/packages/charts/src/trend/horizon-chart.d.ts +37 -0
- package/dist/packages/charts/src/trend/index.d.ts +10 -0
- package/dist/packages/charts/src/trend/line-locate.d.ts +21 -0
- package/dist/packages/charts/src/trend/runs-chart.d.ts +50 -0
- package/dist/packages/charts/src/trend/slope-chart.d.ts +35 -0
- package/dist/packages/kits/src/evaluation/evaluation-data.d.ts +31 -0
- package/dist/packages/kits/src/evaluation/index.d.ts +8 -0
- package/dist/packages/kits/src/evaluation/leaderboard-cells.d.ts +62 -0
- package/dist/packages/kits/src/evaluation/leaderboard.d.ts +59 -0
- package/dist/packages/kits/src/evaluation/model-comparison.d.ts +59 -0
- package/dist/packages/kits/src/evaluation/score-breakdown.d.ts +33 -0
- package/dist/packages/kits/src/interpretability/attention-head-grid.d.ts +56 -0
- package/dist/packages/kits/src/interpretability/attribution-workbench.d.ts +29 -0
- package/dist/packages/kits/src/interpretability/embedding-atlas.d.ts +41 -0
- package/dist/packages/kits/src/interpretability/feature-card.d.ts +33 -0
- package/dist/packages/kits/src/interpretability/feature-list.d.ts +51 -0
- package/dist/packages/kits/src/interpretability/feature-logits.d.ts +23 -0
- package/dist/packages/kits/src/interpretability/features.d.ts +70 -0
- package/dist/packages/kits/src/interpretability/index.d.ts +16 -0
- package/dist/packages/kits/src/interpretability/kit-styles.d.ts +118 -0
- package/dist/packages/kits/src/interpretability/logit-lens.d.ts +50 -0
- package/dist/packages/kits/src/interpretability/node-panel.d.ts +32 -0
- package/dist/packages/kits/src/interpretability/shared-link.d.ts +8 -0
- package/dist/packages/kits/src/interpretability/steering-panel.d.ts +52 -0
- package/dist/packages/kits/src/operations/budget-board.d.ts +49 -0
- package/dist/packages/kits/src/operations/incident-timeline.d.ts +30 -0
- package/dist/packages/kits/src/operations/index.d.ts +6 -0
- package/dist/packages/kits/src/operations/service-health.d.ts +66 -0
- package/dist/packages/kits/src/training/index.d.ts +8 -0
- package/dist/packages/kits/src/training/run-dashboard.d.ts +49 -0
- package/dist/packages/kits/src/training/run-legend.d.ts +21 -0
- package/dist/packages/kits/src/training/run-marker.d.ts +5 -0
- package/dist/packages/kits/src/training/run-state.d.ts +7 -0
- package/dist/packages/kits/src/training/run-table.d.ts +63 -0
- package/dist/packages/kits/src/training/runs-overview.d.ts +20 -0
- package/dist/packages/kits/src/training/runs.d.ts +34 -0
- package/dist/packages/teaching/src/agent/index.d.ts +11 -0
- package/dist/packages/teaching/src/agent/learner-trace.d.ts +84 -0
- package/dist/packages/teaching/src/agent/lesson-bridge.d.ts +59 -0
- package/dist/packages/teaching/src/agent/lesson-tour.d.ts +63 -0
- package/dist/packages/teaching/src/agent/tutor-tools.d.ts +86 -0
- package/dist/packages/teaching/src/article/article-checks.d.ts +9 -0
- package/dist/packages/teaching/src/article/article-context.d.ts +49 -0
- package/dist/packages/teaching/src/article/article-error.d.ts +12 -0
- package/dist/packages/teaching/src/article/article-labels.d.ts +54 -0
- package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +14 -0
- package/dist/packages/teaching/src/article/article-outline.d.ts +9 -0
- package/dist/packages/teaching/src/article/article.d.ts +42 -0
- package/dist/packages/teaching/src/article/beat-steps.d.ts +18 -0
- package/dist/packages/teaching/src/article/beat.d.ts +16 -0
- package/dist/packages/teaching/src/article/challenge.d.ts +29 -0
- package/dist/packages/teaching/src/article/exercise-styles.d.ts +76 -0
- package/dist/packages/teaching/src/article/figure.d.ts +51 -0
- package/dist/packages/teaching/src/article/index.d.ts +31 -0
- package/dist/packages/teaching/src/article/lesson-values.d.ts +5 -0
- package/dist/packages/teaching/src/article/linked-target.d.ts +22 -0
- package/dist/packages/teaching/src/article/notes.d.ts +36 -0
- package/dist/packages/teaching/src/article/outline-types.d.ts +73 -0
- package/dist/packages/teaching/src/article/predict.d.ts +58 -0
- package/dist/packages/teaching/src/article/progress-store.d.ts +64 -0
- package/dist/packages/teaching/src/article/scrolly.d.ts +26 -0
- package/dist/packages/teaching/src/article/term.d.ts +35 -0
- package/dist/packages/teaching/src/article/tex.d.ts +12 -0
- package/dist/packages/teaching/src/article/view-essay.d.ts +13 -0
- package/dist/packages/teaching/src/article/view-present.d.ts +8 -0
- package/dist/packages/teaching/src/article/view-sheet.d.ts +7 -0
- package/dist/packages/teaching/src/article/view-static.d.ts +7 -0
- package/dist/packages/teaching/src/article/walk.d.ts +34 -0
- package/dist/packages/teaching/src/lesson/bound-value.d.ts +29 -0
- package/dist/packages/teaching/src/lesson/define-lesson.d.ts +136 -0
- package/dist/packages/teaching/src/lesson/index.d.ts +24 -0
- package/dist/packages/teaching/src/lesson/inline-choice.d.ts +12 -0
- package/dist/packages/teaching/src/lesson/lesson-context.d.ts +18 -0
- package/dist/packages/teaching/src/lesson/lesson-error.d.ts +12 -0
- package/dist/packages/teaching/src/lesson/lesson-locale.d.ts +4 -0
- package/dist/packages/teaching/src/lesson/lesson-persistence.d.ts +17 -0
- package/dist/packages/teaching/src/lesson/lesson-player.d.ts +51 -0
- package/dist/packages/teaching/src/lesson/lesson-store.d.ts +84 -0
- package/dist/packages/teaching/src/lesson/lesson.d.ts +39 -0
- package/dist/packages/teaching/src/lesson/param-controls.d.ts +14 -0
- package/dist/packages/teaching/src/lesson/param.d.ts +34 -0
- package/dist/packages/teaching/src/lesson/playback.d.ts +42 -0
- package/dist/packages/teaching/src/lesson/transport.d.ts +19 -0
- package/dist/packages/teaching/src/lesson/use-lesson.d.ts +36 -0
- package/dist/packages/teaching/src/mdx/essay-components.d.ts +79 -0
- package/dist/packages/teaching/src/mdx/essay-markdown.d.ts +41 -0
- package/dist/packages/teaching/src/mdx/essay.d.ts +32 -0
- package/dist/packages/teaching/src/mdx/index.d.ts +9 -0
- package/dist/packages/teaching/src/mdx/requested-view.d.ts +6 -0
- package/dist/packages/teaching/src/scene/flow/flow-layout.d.ts +38 -0
- package/dist/packages/teaching/src/scene/flow/flow-pulse.d.ts +16 -0
- package/dist/packages/teaching/src/scene/flow/scene-flow.d.ts +81 -0
- package/dist/packages/teaching/src/scene/index.d.ts +77 -0
- package/dist/packages/teaching/src/scene/morph/morph-scope.d.ts +28 -0
- package/dist/packages/teaching/src/scene/plane/plane-hit.d.ts +22 -0
- package/dist/packages/teaching/src/scene/plane/plane-label.d.ts +23 -0
- package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +42 -0
- package/dist/packages/teaching/src/scene/plane/plane-math.d.ts +45 -0
- package/dist/packages/teaching/src/scene/plane/scene-axes.d.ts +30 -0
- package/dist/packages/teaching/src/scene/plane/scene-curve.d.ts +42 -0
- package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +59 -0
- package/dist/packages/teaching/src/scene/plane/scene-projection.d.ts +27 -0
- package/dist/packages/teaching/src/scene/plane/scene-region.d.ts +38 -0
- package/dist/packages/teaching/src/scene/plane/scene-rule.d.ts +35 -0
- package/dist/packages/teaching/src/scene/plane/scene-vector.d.ts +39 -0
- package/dist/packages/teaching/src/scene/scene-bracket.d.ts +24 -0
- package/dist/packages/teaching/src/scene/scene-callout.d.ts +26 -0
- package/dist/packages/teaching/src/scene/scene-context.d.ts +179 -0
- package/dist/packages/teaching/src/scene/scene-custom.d.ts +31 -0
- package/dist/packages/teaching/src/scene/scene-geometry.d.ts +181 -0
- package/dist/packages/teaching/src/scene/scene-group.d.ts +28 -0
- package/dist/packages/teaching/src/scene/scene-highlight.d.ts +19 -0
- package/dist/packages/teaching/src/scene/scene-layer.d.ts +16 -0
- package/dist/packages/teaching/src/scene/scene-node.d.ts +67 -0
- package/dist/packages/teaching/src/scene/scene-obstacles.d.ts +27 -0
- package/dist/packages/teaching/src/scene/scene-registry.d.ts +79 -0
- package/dist/packages/teaching/src/scene/scene-stagger.d.ts +43 -0
- package/dist/packages/teaching/src/scene/scene-style.d.ts +14 -0
- package/dist/packages/teaching/src/scene/scene-validate.d.ts +65 -0
- package/dist/packages/teaching/src/scene/scene-wire.d.ts +45 -0
- package/dist/packages/teaching/src/scene/scene.d.ts +36 -0
- package/dist/packages/teaching/src/scene/shapes/cell-color.d.ts +11 -0
- package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +69 -0
- package/dist/packages/teaching/src/scene/shapes/scene-card.d.ts +114 -0
- package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +84 -0
- package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +37 -0
- package/dist/packages/teaching/src/scene/shapes/scene-stack.d.ts +46 -0
- package/dist/packages/teaching/src/scene/shapes/scene-token.d.ts +63 -0
- package/dist/packages/teaching/src/scene/shapes/scene-tokens.d.ts +40 -0
- package/dist/packages/teaching/src/scene/shapes/stack-book.d.ts +35 -0
- package/dist/packages/teaching/src/scene/shapes/stack-layout.d.ts +63 -0
- package/dist/packages/teaching/src/scene/shapes/token-layout.d.ts +39 -0
- package/dist/packages/teaching/src/spec/advice.d.ts +23 -0
- package/dist/packages/teaching/src/spec/chart-names.d.ts +2 -0
- package/dist/packages/teaching/src/spec/describe-lesson.d.ts +85 -0
- package/dist/packages/teaching/src/spec/explainer-guide.d.ts +21 -0
- package/dist/packages/teaching/src/spec/findings.d.ts +39 -0
- package/dist/packages/teaching/src/spec/index.d.ts +14 -0
- package/dist/packages/teaching/src/spec/lesson-plan.d.ts +43 -0
- package/dist/packages/teaching/src/spec/validate-plan.d.ts +11 -0
- package/dist/packages/teaching/src/time/clock.d.ts +7 -0
- package/dist/packages/teaching/src/time/tween.d.ts +19 -0
- package/dist/packages/teaching/src/time/use-tween.d.ts +6 -0
- package/dist/param-CqKUTHaO.js +450 -0
- package/dist/path-BglsXpnO.js +59 -0
- package/dist/plot-axes-DJkLW4wk.js +100 -0
- package/dist/plot-layout-CZVSJ-le.js +912 -0
- package/dist/plot-marks-uozcbOIX.js +229 -0
- package/dist/plot-surface-CbVBvgqZ.js +51 -0
- package/dist/plot-width-DcqtSgzb.js +124 -0
- package/dist/point-layer-C-EYETAt.js +655 -0
- package/dist/reference-lines-BDcttOp0.js +82 -0
- package/dist/scale-C2xgZyZN.js +63 -0
- package/dist/scene-0z2gbaDE.js +4938 -0
- package/dist/scene.js +1 -0
- package/dist/slope-chart-BKVEAVCs.js +1279 -0
- package/dist/{src-1EHkSFS-.js → src-BD6xlvDt.js} +2 -2
- package/dist/{src-DVHlknB6.js → src-CExIrXPC.js} +169 -193
- package/dist/src-DIS0YOj0.js +44 -0
- package/dist/src-Dcfq8vE4.js +2195 -0
- package/dist/styles2.css +907 -59
- package/dist/time-series-BgzGNOk0.js +2670 -0
- package/dist/token-heatmap-BrW1OsKD.js +1354 -0
- package/dist/token-predictions-yerq_Oet.js +1093 -0
- package/dist/tone-scope-DKiSw-JR.js +32 -0
- package/dist/transport-BJweqDPj.js +715 -0
- package/dist/tree-diagram-D09BRqE-.js +1629 -0
- package/dist/treemap-CW4WsJNL.js +472 -0
- package/dist/use-tween-5HZ55_9d.js +72 -0
- package/dist/values-963L6n1m.js +65 -0
- package/dist/violin-plot-DrtPZ1-T.js +1292 -0
- package/dist/waterfall-DYLSnGjm.js +576 -0
- package/package.json +78 -4
- package/recipes/allocation-report.tsx +15 -7
- package/recipes/counting-cards.tsx +656 -0
- package/recipes/explorable-essay.tsx +172 -0
- package/skills/extend-elements/SKILL.md +81 -0
- package/skills/plan-lesson/SKILL.md +86 -0
- package/skills/plan-lesson/references/plan-format.md +114 -0
- package/skills/plan-lesson/references/worked-plan.md +171 -0
- package/skills/review-elements/SKILL.md +47 -3
- package/skills/review-explainer/SKILL.md +97 -0
- package/skills/upgrade-elements/SKILL.md +3 -1
- package/skills/upgrade-elements/references/releases.md +249 -0
- package/skills/use-elements/SKILL.md +22 -14
- package/skills/use-elements/references/charts.md +362 -41
- package/skills/use-elements/references/figures.md +173 -0
- package/skills/use-elements/references/kits.md +180 -0
- package/skills/use-elements/references/teaching.md +36 -0
- package/skills/write-explainer/SKILL.md +112 -0
- package/skills/write-explainer/references/article.md +164 -0
- package/skills/write-explainer/references/lesson.md +148 -0
- package/skills/write-explainer/references/mdx.md +78 -0
- package/skills/write-explainer/references/scene-parts.md +273 -0
- package/skills/write-explainer/references/scene.md +168 -0
- package/skills/write-explainer/references/tutor.md +104 -0
- package/skills/write-explainer/references/worked-essay.md +459 -0
- package/templates/essay/AGENTS.md +14 -0
- package/templates/essay/README.md +59 -0
- package/templates/essay/index.html +17 -0
- package/templates/essay/package.template.json +21 -0
- package/templates/essay/plan.json +96 -0
- package/templates/essay/src/essay.mdx +97 -0
- package/templates/essay/src/figures.tsx +92 -0
- package/templates/essay/src/lesson.ts +83 -0
- package/templates/essay/src/main.tsx +53 -0
- package/templates/essay/src/mdx.d.ts +7 -0
- package/templates/essay/tsconfig.template.json +15 -0
- package/templates/essay/vite.config.template.txt +8 -0
- package/dist/categorical-values-BXi-rJuv.js +0 -74
- package/dist/chart-data-CIJVWCYt.js +0 -21
- package/dist/chart-frame-BaxKn_MB.js +0 -236
- package/dist/chart-input-Bm82_9Rd.js +0 -22
- package/dist/chart-theme-4zprJ3rW.js +0 -404
- package/dist/plot-width-v2c_rA20.js +0 -63
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# MDX
|
|
2
|
+
|
|
3
|
+
Import from `@mechane-ai/elements/mdx`. One `.mdx` file is the essay: Markdown prose with the teaching parts written as
|
|
4
|
+
tags. `Essay` renders the compiled file as an `Article`, and `essayComponents` lets the file use every part without
|
|
5
|
+
imports: `Beat`, `Figure`, `Param`, `Value`, `Predict`, `Challenge`, `Scrolly`, `Term`, `TeX`, `Scene` and the scene
|
|
6
|
+
parts. Markdown headings, lists, code and tables map to Elements typography. The essay starter is set up this way.
|
|
7
|
+
|
|
8
|
+
## Set up
|
|
9
|
+
|
|
10
|
+
The application brings its own MDX compiler. With Vite and `@mdx-js/rollup`, MDX runs before the React plugin:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import mdx from '@mdx-js/rollup';
|
|
14
|
+
import react from '@vitejs/plugin-react';
|
|
15
|
+
import { defineConfig } from 'vite';
|
|
16
|
+
|
|
17
|
+
export default defineConfig({ plugins: [{ enforce: 'pre', ...mdx() }, react()] });
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Declare the module so TypeScript checks the import, in `src/mdx.d.ts`:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
declare module '*.mdx' {
|
|
24
|
+
import type { EssayContent, EssayMeta } from '@mechane-ai/elements/mdx';
|
|
25
|
+
|
|
26
|
+
const Content: EssayContent;
|
|
27
|
+
export const meta: EssayMeta;
|
|
28
|
+
export default Content;
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Render it. Without a `view` prop, the address decides with `?view=present|static|sheet`:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { Essay } from '@mechane-ai/elements/mdx';
|
|
36
|
+
import Content, { meta } from './essay.mdx';
|
|
37
|
+
import { lesson } from './lesson.ts';
|
|
38
|
+
|
|
39
|
+
<Essay lesson={lesson} content={Content} locale="en-US" storageKey={lesson.id} {...meta} />;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`Essay` takes every `Article` prop except `children`, plus `content` and `components` (extra or replacement tags).
|
|
43
|
+
|
|
44
|
+
## The file
|
|
45
|
+
|
|
46
|
+
`export const meta = { title, authors?, date?, summary? }` at the top. Import your figures, then write beats. Leave a
|
|
47
|
+
blank line after an opening tag and before a closing one, so the Markdown inside is parsed as Markdown:
|
|
48
|
+
|
|
49
|
+
```mdx
|
|
50
|
+
export const meta = { title: 'Why a big learning rate blows up', summary: 'The numbers are synthetic.' };
|
|
51
|
+
|
|
52
|
+
import { LossCurve } from './figures.tsx';
|
|
53
|
+
|
|
54
|
+
<Beat id="rate">
|
|
55
|
+
|
|
56
|
+
Every step multiplies the loss by <Value name="factor" />. Press play to run ten steps.
|
|
57
|
+
|
|
58
|
+
<Playback name="steps" pace="slow" />
|
|
59
|
+
|
|
60
|
+
<Figure id="loss-curve" caption="Loss at each step." description="A line falling toward zero." reads={['rate']}>
|
|
61
|
+
<LossCurve />
|
|
62
|
+
<Transport for="steps" />
|
|
63
|
+
</Figure>
|
|
64
|
+
|
|
65
|
+
</Beat>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Never start a line of prose with a tag such as `<Value />`: put a word before it. A line that starts with a tag reads as
|
|
69
|
+
a block, and a formatter splits the paragraph there.
|
|
70
|
+
|
|
71
|
+
The rules of the `write-explainer` skill hold unchanged: figures are components in a `.tsx` file that read
|
|
72
|
+
`useLesson(lesson)`, and every `Figure` names what they read.
|
|
73
|
+
|
|
74
|
+
## Math
|
|
75
|
+
|
|
76
|
+
To write `$…$` and `$$…$$`, add `remark-math` to the MDX plugins (`mdx({ remarkPlugins: [remarkMath] })`) and pass a
|
|
77
|
+
typesetter as `math={(tex, { isDisplay }) => …}` to `Essay`, for example KaTeX's MathML output. Without a typesetter,
|
|
78
|
+
`TeX` shows the TeX source. Elements adds no typesetting dependency.
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# Scene parts
|
|
2
|
+
|
|
3
|
+
Every part below is exported from `@mechane-ai/elements/scene`, sits inside a `Scene`, takes a stable `id`, and eases
|
|
4
|
+
when its props change. The samples type check; they read a lesson defined in the same module (the worked essay's for the
|
|
5
|
+
plane and the cards).
|
|
6
|
+
|
|
7
|
+
## The plane
|
|
8
|
+
|
|
9
|
+
For a scene whose box is a coordinate plane. All positions and values are in data units.
|
|
10
|
+
|
|
11
|
+
- `SceneAxes`: `x` and `y` as `{ label, format?, ticks? }`, `grid` (`'x'`, `'y'`, `'both'` or none). Put the unit in the
|
|
12
|
+
label. Leave the axes out of a diagram whose positions mean nothing.
|
|
13
|
+
- `SceneCurve`: `of` (a function of x) or `points` (`[x, y]` pairs, x increasing), `resolution`, `fillTo`, `isDashed`
|
|
14
|
+
for a modelled curve, `thickness`. A new `of` eases from the old shape.
|
|
15
|
+
- `ScenePoint`: `at`, `text`, and `sets` to make it draggable and movable by the arrow keys. `sets` names the number
|
|
16
|
+
params its position writes, as `{ x: 'bias' }`; a move sets them in one change, on each param's step grid and inside
|
|
17
|
+
its range. `along` (`'x'`, `'y'` or a function of x) limits the move, and a point bound on one axis moves along it.
|
|
18
|
+
`snap` sets the step of an axis no param owns. The point stays at `at`, read from the lesson. Reach for
|
|
19
|
+
`onMove(position, details)` only when a move is not a plain param write, and set a lesson param there, never component
|
|
20
|
+
state.
|
|
21
|
+
- `SceneVector`: `to`, `from` (defaults to the origin), `text`, `isDashed` for a step not yet taken.
|
|
22
|
+
- `SceneProjection`: `of` (a point's id) or `at`, dashed lines to both axes with the values written there.
|
|
23
|
+
- `SceneRegion`: one of `between` (two x values), `above`, `below` (a y value) or `points` (a polygon). Keep it pale.
|
|
24
|
+
- `SceneRule`: `x` or `y`, a dashed threshold or asymptote with a short `text`.
|
|
25
|
+
|
|
26
|
+
A draggable point that moves a param. `sets` keeps the bias on its step and inside its range, so there is no handler to
|
|
27
|
+
write:
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
/** How sure the neuron is at each bias, for the cards and weights it has. Dragging the point sets the bias. */
|
|
31
|
+
export function ConfidenceScene(): ReactNode {
|
|
32
|
+
const { values, locale } = useLesson(lesson);
|
|
33
|
+
const fromCards = values.sum - values.bias;
|
|
34
|
+
const chance = (bias: number): number => sigmoid(fromCards + bias);
|
|
35
|
+
const bias = formatValue({ value: values.bias, locale, format: ONE_DECIMAL });
|
|
36
|
+
const yes = formatValue({ value: values.yes, locale, format: { style: 'percent', maximumFractionDigits: 0 } });
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Scene
|
|
40
|
+
title="How sure the neuron is"
|
|
41
|
+
description="The chance of saying yes at each bias, for the current cards and weights. The curve shifts when a weight changes."
|
|
42
|
+
locale={locale}
|
|
43
|
+
x={[-10, 10]}
|
|
44
|
+
y={[0, 1]}
|
|
45
|
+
>
|
|
46
|
+
<SceneAxes x={{ label: 'Bias' }} y={{ label: 'Chance of yes', format: { style: 'percent' } }} />
|
|
47
|
+
<SceneCurve id="chance" of={chance} resolution="fine" label="The chance of yes at each bias" />
|
|
48
|
+
<SceneRule id="even" y={0.5} text="even" label="An even chance" />
|
|
49
|
+
<ScenePoint
|
|
50
|
+
id="now"
|
|
51
|
+
at={[values.bias, values.yes]}
|
|
52
|
+
along={chance}
|
|
53
|
+
sets={{ x: 'bias' }}
|
|
54
|
+
label={`Bias ${bias}, chance of yes ${yes}. Move it to change the bias.`}
|
|
55
|
+
/>
|
|
56
|
+
</Scene>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Cards
|
|
62
|
+
|
|
63
|
+
- `SceneCard`: `rank` (`'A'`, `'2'` to `'10'`, `'J'`, `'Q'`, `'K'`) with `suit` (`'heart'`, `'diamond'`, `'spade'`,
|
|
64
|
+
`'club'`) for a playing card, or `text` for a generic card. `isFaceUp` turns it over (default true), `lift` raises it,
|
|
65
|
+
`tilt` leans it, `size` is `'small'`, `'medium'` or `'large'`, and `children` go on the face, even a chart. Its tone
|
|
66
|
+
defaults to its suit's (`suitTones`), and its back stays neutral so it hides the suit. A face-down playing card reads
|
|
67
|
+
"A card, face down" unless you give it a `label`. Place it with `at`, or list it in one `SceneStack`.
|
|
68
|
+
- `SceneStack`: `id`, `at`, `cards` (ids, bottom of a pile first), `layout` (`'pile'`, `'fan'`, `'row'`, `'column'`),
|
|
69
|
+
`gap`, `size`, `stagger`. Move a card between stacks by moving its id from one list to the other. `stagger`
|
|
70
|
+
(`'short'`, `'regular'`, `'long'`) deals in turn: cards that arrive or move in the same update start that step apart,
|
|
71
|
+
in stack order, and a lone card starts at once. Use it, not a card's `delay`, to deal. A card in two stacks, or a card
|
|
72
|
+
with no place, shows an error.
|
|
73
|
+
- `SceneSlot`: an empty bay a card is dealt to, with `text`, `size` and `isActive` for the one that matters now.
|
|
74
|
+
|
|
75
|
+
A deal is two lists of ids. Changing the hand moves the cards, flips them and deals them in turn, with no motion code:
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
/** The deck and the hand. Changing `hand` deals two cards out of the deck, face up, in turn. */
|
|
79
|
+
export function HandScene(): ReactNode {
|
|
80
|
+
const { values, locale } = useLesson(lesson);
|
|
81
|
+
const dealt: ReadonlyArray<string> = hands[values.hand];
|
|
82
|
+
const deck = cards.flatMap((card) => (dealt.includes(card.id) ? [] : [card.id]));
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<Scene
|
|
86
|
+
title="The hand"
|
|
87
|
+
description="Four synthetic cards: two dealt face up into the hand, two face down in the deck."
|
|
88
|
+
locale={locale}
|
|
89
|
+
x={[0, 4]}
|
|
90
|
+
y={[0, 2]}
|
|
91
|
+
height="tall"
|
|
92
|
+
>
|
|
93
|
+
<SceneStack id="deck" at={[0.8, 1]} cards={deck} stagger="short" label="The deck, two cards face down" />
|
|
94
|
+
<SceneStack
|
|
95
|
+
id="dealt"
|
|
96
|
+
at={[2.8, 1]}
|
|
97
|
+
layout="row"
|
|
98
|
+
cards={dealt}
|
|
99
|
+
stagger="regular"
|
|
100
|
+
label="The hand, two cards face up"
|
|
101
|
+
/>
|
|
102
|
+
{cards.map((card) => (
|
|
103
|
+
<SceneCard key={card.id} id={card.id} rank={card.rank} suit={card.suit} isFaceUp={dealt.includes(card.id)} />
|
|
104
|
+
))}
|
|
105
|
+
</Scene>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Cells
|
|
111
|
+
|
|
112
|
+
`SceneCells` draws a small vector or matrix: `values` (a flat list is one row; a list of lists is a matrix) or `cells`
|
|
113
|
+
(`{ id?, text?, value?, label? }` rows), `direction`, `format`, `palette` (`'sequential'` or `'diverging'`) with
|
|
114
|
+
`domain`, `rowLabels`, `columnLabels`, `highlight` (`{ row?, column? }`) and `size`. A cell's id is
|
|
115
|
+
`${id}.${row}.${column}`, so a wire or callout can name one. Changed values ease. For a large grid with axes, use the
|
|
116
|
+
`Matrix` chart.
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
/** The weights and the bias as cells, shaded around zero. */
|
|
120
|
+
export function WeightCells(): ReactNode {
|
|
121
|
+
const { values, locale } = useLesson(lesson);
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<Scene
|
|
125
|
+
title="What training changes"
|
|
126
|
+
description="The two weights and the bias, shaded one hue above zero and another below."
|
|
127
|
+
locale={locale}
|
|
128
|
+
x={[0, 2]}
|
|
129
|
+
y={[0, 1]}
|
|
130
|
+
height="compact"
|
|
131
|
+
>
|
|
132
|
+
<SceneCells
|
|
133
|
+
id="weights"
|
|
134
|
+
at={[1, 0.5]}
|
|
135
|
+
values={[values.heartWeight, values.spadeWeight, values.bias / 10]}
|
|
136
|
+
columnLabels={['heart weight', 'spade weight', 'bias ÷ 10']}
|
|
137
|
+
palette="diverging"
|
|
138
|
+
domain={[-1, 1]}
|
|
139
|
+
format={ONE_DECIMAL}
|
|
140
|
+
label="The heart weight, the spade weight and the bias"
|
|
141
|
+
/>
|
|
142
|
+
</Scene>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Tokens
|
|
148
|
+
|
|
149
|
+
- `SceneToken`: one token in monospace, with `text` (spaces show as faint marks), `tokenId`, `probability` (a bar and a
|
|
150
|
+
percent that ease) and `format`. Move it with `at`.
|
|
151
|
+
- `SceneTokens`: a sequence, `tokens` of `{ text, tokenId?, probability?, tone?, label? }`, wrapping at `wrapWidth`
|
|
152
|
+
pixels. Token `n` has the id `${id}.${n}`.
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
const reveal = defineLesson({
|
|
156
|
+
id: 'reveal',
|
|
157
|
+
title: 'Tokens and counts',
|
|
158
|
+
params: {
|
|
159
|
+
isPredicted: { kind: 'toggle', label: 'Show the prediction', value: false },
|
|
160
|
+
isCounted: { kind: 'toggle', label: 'Count by suit', value: false },
|
|
161
|
+
},
|
|
162
|
+
derived: {
|
|
163
|
+
score: { label: 'Score', format: { maximumFractionDigits: 1 }, from: ({ isPredicted }) => (isPredicted ? 1 : 0) },
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
/** A prompt as tokens, and the predicted next token travelling to the end of it. */
|
|
168
|
+
export function PromptScene(): ReactNode {
|
|
169
|
+
const { values, locale } = useLesson(reveal);
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<Scene
|
|
173
|
+
title="The next token"
|
|
174
|
+
description="Synthetic prompt and probability. The model's guess joins the prompt once it is chosen."
|
|
175
|
+
locale={locale}
|
|
176
|
+
x={[0, 4]}
|
|
177
|
+
y={[0, 2]}
|
|
178
|
+
>
|
|
179
|
+
<SceneTokens
|
|
180
|
+
id="prompt"
|
|
181
|
+
at={[1.6, 1.4]}
|
|
182
|
+
tokens={[{ text: 'The' }, { text: ' cat' }, { text: ' sat' }]}
|
|
183
|
+
label="The prompt, three tokens"
|
|
184
|
+
/>
|
|
185
|
+
<SceneToken
|
|
186
|
+
id="guess"
|
|
187
|
+
at={values.isPredicted ? [3.2, 1.4] : [2, 0.4]}
|
|
188
|
+
text=" on"
|
|
189
|
+
probability={0.42}
|
|
190
|
+
label="The predicted token, on, 42%"
|
|
191
|
+
/>
|
|
192
|
+
</Scene>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## The derivation
|
|
198
|
+
|
|
199
|
+
`LessonFlow` is a figure of its own that draws the lesson's derived values as a graph: each param and derived value is a
|
|
200
|
+
node wired to what it reads, params are inline controls, and a change glows through what it touched. It takes `names`
|
|
201
|
+
(draw these and what they read), `formula` (plain text per derived value), `layout` (`'across'` or `'down'`) and the
|
|
202
|
+
scene's figure props; `title` defaults to the lesson's. `SceneFlow` is the same inside a hand-placed `Scene`, in the
|
|
203
|
+
part of the box given by `at`:
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
/** The lesson's derivation beside a hand-placed node, inside one scene. */
|
|
207
|
+
export function ForwardScene(): ReactNode {
|
|
208
|
+
return (
|
|
209
|
+
<Scene title="The forward pass" description="Each value, wired to what it reads." x={[0, 6]} y={[0, 3]}>
|
|
210
|
+
<SceneNode id="stage" at={[0, 1.5]} text="Forward" label="The forward pass" />
|
|
211
|
+
<SceneFlow at={{ x: [1, 6], y: [0, 3] }} names={['score']} formula={{ score: 'one when the prediction shows' }} />
|
|
212
|
+
</Scene>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Morph
|
|
218
|
+
|
|
219
|
+
`MorphScope` shows one of several figures that draw the same things. When `show` changes, everything drawn in both,
|
|
220
|
+
matched by id, travels from its place in one figure to its place in the other while the figures cross-fade. It takes
|
|
221
|
+
`figures` (by name), `show`, `pace` (defaults to `'slow'`) and `tones`. Use it once or twice per essay, for the moment
|
|
222
|
+
an object becomes data: a card becomes a bar, a neuron a dot.
|
|
223
|
+
|
|
224
|
+
The ids must match. A scene node's id is its `id`. A chart mark's id is its record's id: in a `BarChart` with one series
|
|
225
|
+
it is the category id, and with several it is `category:series`.
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
/** The two hearts and two spades as nodes; each id is the bar segment it becomes. */
|
|
229
|
+
function Hand(): ReactNode {
|
|
230
|
+
return (
|
|
231
|
+
<Scene title="The four cards" description="Synthetic cards, as dealt." locale="en-US" x={[0, 3]} y={[0, 1]}>
|
|
232
|
+
<SceneNode id="hearts:queen" at={[0, 0.5]} text="Q♥" label="Queen of Hearts" size="small" />
|
|
233
|
+
<SceneNode id="hearts:two" at={[1, 0.5]} text="2♥" label="Two of Hearts" size="small" />
|
|
234
|
+
<SceneNode id="spades:seven" at={[2, 0.5]} text="7♠" label="Seven of Spades" size="small" />
|
|
235
|
+
<SceneNode id="spades:king" at={[3, 0.5]} text="K♠" label="King of Spades" size="small" />
|
|
236
|
+
</Scene>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const cardsBySuit = [
|
|
241
|
+
{ id: 'queen', label: 'Q♥', values: [1, 0] },
|
|
242
|
+
{ id: 'two', label: '2♥', values: [1, 0] },
|
|
243
|
+
{ id: 'seven', label: '7♠', values: [0, 1] },
|
|
244
|
+
{ id: 'king', label: 'K♠', values: [0, 1] },
|
|
245
|
+
] as const;
|
|
246
|
+
|
|
247
|
+
/** The same cards counted by suit: one series per card, so each segment's id is `suit:card`. */
|
|
248
|
+
function Counts(): ReactNode {
|
|
249
|
+
return (
|
|
250
|
+
<BarChart
|
|
251
|
+
title="Cards per suit"
|
|
252
|
+
description="The same synthetic cards, stacked by suit."
|
|
253
|
+
locale="en-US"
|
|
254
|
+
categories={[
|
|
255
|
+
{ id: 'hearts', label: 'Hearts' },
|
|
256
|
+
{ id: 'spades', label: 'Spades' },
|
|
257
|
+
]}
|
|
258
|
+
series={cardsBySuit.map((card) => ({ id: card.id, label: card.label, values: card.values }))}
|
|
259
|
+
mode="stacked"
|
|
260
|
+
domain={[0, 2]}
|
|
261
|
+
valueFormat={{ maximumFractionDigits: 0 }}
|
|
262
|
+
valueLabel="Cards"
|
|
263
|
+
/>
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** A toggle param of the lesson decides which figure shows; every card travels to its bar segment. */
|
|
268
|
+
export function CountMorph(): ReactNode {
|
|
269
|
+
const { values } = useLesson(reveal);
|
|
270
|
+
|
|
271
|
+
return <MorphScope figures={{ hand: <Hand />, counts: <Counts /> }} show={values.isCounted ? 'counts' : 'hand'} />;
|
|
272
|
+
}
|
|
273
|
+
```
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Scene
|
|
2
|
+
|
|
3
|
+
Import from `@mechane-ai/elements/scene`. A `Scene` is a diagram with identity, drawn on the chart kernel: every object
|
|
4
|
+
has an id, and when its props change it eases to the new state. Describe each state; the scene does the motion.
|
|
5
|
+
|
|
6
|
+
## The example
|
|
7
|
+
|
|
8
|
+
A choice param picks the stage, and the scene describes what each stage shows. The camera zooms on one stage, the output
|
|
9
|
+
fades in on the last, and the wires stay attached while their nodes move.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { defineLesson, useLesson } from '@mechane-ai/elements/lesson';
|
|
13
|
+
import {
|
|
14
|
+
Scene,
|
|
15
|
+
SceneBracket,
|
|
16
|
+
SceneCallout,
|
|
17
|
+
SceneCustom,
|
|
18
|
+
SceneGroup,
|
|
19
|
+
SceneHighlight,
|
|
20
|
+
SceneNode,
|
|
21
|
+
SceneWire,
|
|
22
|
+
} from '@mechane-ai/elements/scene';
|
|
23
|
+
import type { ReactNode } from 'react';
|
|
24
|
+
|
|
25
|
+
const inputs = [
|
|
26
|
+
{ id: 'x1', name: 'x₁', row: 2.5, weight: 0.6 },
|
|
27
|
+
{ id: 'x2', name: 'x₂', row: 1.5, weight: -0.9 },
|
|
28
|
+
{ id: 'x3', name: 'x₃', row: 0.5, weight: 0.3 },
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
31
|
+
export const neuron = defineLesson({
|
|
32
|
+
id: 'neuron',
|
|
33
|
+
title: 'Building a neuron',
|
|
34
|
+
params: {
|
|
35
|
+
stage: {
|
|
36
|
+
kind: 'choice',
|
|
37
|
+
label: 'Stage',
|
|
38
|
+
value: 'inputs',
|
|
39
|
+
options: [
|
|
40
|
+
{ id: 'inputs', label: 'Inputs' },
|
|
41
|
+
{ id: 'weights', label: 'Weights' },
|
|
42
|
+
{ id: 'output', label: 'Output' },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/** One scene, three states. Nothing here says how anything moves. */
|
|
49
|
+
export function NeuronScene(): ReactNode {
|
|
50
|
+
const { values, locale } = useLesson(neuron);
|
|
51
|
+
const hasWeights = values.stage !== 'inputs';
|
|
52
|
+
const hasOutput = values.stage === 'output';
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Scene
|
|
56
|
+
title="Building a neuron"
|
|
57
|
+
description="Synthetic values. Each input is multiplied by its weight; thickness shows the weight's size and hue its sign."
|
|
58
|
+
locale={locale}
|
|
59
|
+
x={[0, 4]}
|
|
60
|
+
y={[0, 3]}
|
|
61
|
+
focus={values.stage === 'weights' ? ['sum', 'x1', 'x2', 'x3'] : null}
|
|
62
|
+
pace="slow"
|
|
63
|
+
>
|
|
64
|
+
{inputs.map((input) => (
|
|
65
|
+
<SceneNode key={input.id} id={input.id} at={[0, input.row]} text={input.name} label={`Input ${input.name}`} />
|
|
66
|
+
))}
|
|
67
|
+
<SceneNode id="sum" at={[2, 1.5]} shape="circle" text="Σ" label="Weighted sum" tone="series1" />
|
|
68
|
+
<SceneNode id="out" at={[4, 1.5]} shape="pill" text="ŷ" label="Output" isShown={hasOutput} />
|
|
69
|
+
{inputs.map((input) => (
|
|
70
|
+
<SceneWire
|
|
71
|
+
key={input.id}
|
|
72
|
+
from={input.id}
|
|
73
|
+
to="sum"
|
|
74
|
+
weight={hasWeights ? input.weight : 0.2}
|
|
75
|
+
text={hasWeights ? String(input.weight) : undefined}
|
|
76
|
+
label={`Weight from ${input.name} to the sum`}
|
|
77
|
+
/>
|
|
78
|
+
))}
|
|
79
|
+
<SceneWire from="sum" to="out" shape="curve" isShown={hasOutput} label="The sum becomes the output" />
|
|
80
|
+
<SceneGroup id="layer" label="The input layer" text="inputs" around={['x1', 'x2', 'x3']} />
|
|
81
|
+
<SceneBracket of={['x1', 'x2', 'x3']} side="left" label="Three inputs" text="3" />
|
|
82
|
+
<SceneCallout to="sum" side="top" isShown={hasWeights}>
|
|
83
|
+
Each wire multiplies its input by a weight.
|
|
84
|
+
</SceneCallout>
|
|
85
|
+
<SceneHighlight of="out" isShown={hasOutput} />
|
|
86
|
+
<SceneCustom layer="back">
|
|
87
|
+
{({ x, y, color, tone }) => (
|
|
88
|
+
<line
|
|
89
|
+
x1={x.position(2)}
|
|
90
|
+
x2={x.position(2)}
|
|
91
|
+
y1={y.position(0)}
|
|
92
|
+
y2={y.position(3)}
|
|
93
|
+
stroke={color(tone({ id: 'sum', index: 0 }))}
|
|
94
|
+
strokeDasharray="4 4"
|
|
95
|
+
/>
|
|
96
|
+
)}
|
|
97
|
+
</SceneCustom>
|
|
98
|
+
</Scene>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## `Scene`
|
|
104
|
+
|
|
105
|
+
| Prop | What it does |
|
|
106
|
+
| -------------------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
107
|
+
| `title` | Required. The figure's title, as for a chart. |
|
|
108
|
+
| `description`, `source`, `actions`, `status` | The kernel's figure props. |
|
|
109
|
+
| `locale` | Left out, the nearest `Lesson`'s. |
|
|
110
|
+
| `x`, `y` | The data box, such as `[0, 4]`. Every position is in these units, and y grows upward. |
|
|
111
|
+
| `height` or `aspect` | A named height (`'compact'`, `'regular'`, `'tall'`), or width divided by height. |
|
|
112
|
+
| `focus` | The camera: an id or ids to zoom to, or `null` for the whole box. |
|
|
113
|
+
| `pace` | `'instant'`, `'fast'`, `'regular'` or `'slow'`. Reduced motion always jumps. |
|
|
114
|
+
| `weightMax` | The wire weight drawn thickest. Every weight must lie within plus or minus it. Defaults to 1. |
|
|
115
|
+
| `selected`, `onSelectedChange` | Selection, as on a chart. |
|
|
116
|
+
| `minWidth`, `labels` | Rarely needed. Below its width the scene scrolls inside its own frame. |
|
|
117
|
+
|
|
118
|
+
An object placed outside the box, a weight beyond `weightMax`, or a wire to an id that does not exist shows an error in
|
|
119
|
+
the figure instead of a guess.
|
|
120
|
+
|
|
121
|
+
## Objects
|
|
122
|
+
|
|
123
|
+
Every object takes `isShown` (false fades it out and takes it out of the keyboard order), and most take `isActive`
|
|
124
|
+
(keeps it bright while unrelated objects recede), `tone`, `emphasis` and `label`. A `label` is the full sentence for the
|
|
125
|
+
readout and assistive technology, and makes the object an item the arrow keys reach. `text` is what is drawn.
|
|
126
|
+
|
|
127
|
+
- `SceneNode`: `id`, `at` (`[across, up]`), `text`, `isCode` for token text or code, `size` (`'small'`, `'medium'`,
|
|
128
|
+
`'large'` or `{ width, height }` in pixels), `shape` (`'box'`, `'pill'`, `'circle'`, `'plain'`), `offset` in pixels,
|
|
129
|
+
`turn` (0 front to 1 back, with `back` as the other face and `backTone` as its hue), `lift` (0 to 1), `tilt` and
|
|
130
|
+
`rotate` in degrees, `order`, `stagger`, `delay`, `pace`, and `children` for rich content such as a compact chart that
|
|
131
|
+
keeps its state as the node moves.
|
|
132
|
+
- `SceneWire`: `from`, `to`, `id` (defaults to `from>to`), `weight` (thickness by size, hue by sign), `text`, `textSide`
|
|
133
|
+
(`'auto'` above a level wire and right of an upright one, or a side), `shape` (`'straight'`, `'curve'`, `'elbow'`),
|
|
134
|
+
`isDashed` for a modelled connection, `hasArrow` (default true).
|
|
135
|
+
- `SceneGroup`: `id`, `around` (ids), `label`, `text`, `padding`. An outline that follows its members.
|
|
136
|
+
- `SceneBracket`: `of` (ids), `side` (`'top'`, `'right'`, `'bottom'`, `'left'`), `label`, `text`.
|
|
137
|
+
- `SceneCallout`: `to` (an id), `side` (`'auto'` or a side), `width`, and one sentence of prose as children.
|
|
138
|
+
- `SceneHighlight`: `of` (an id or ids), `tone`, `padding`. A halo; the objects themselves are not changed.
|
|
139
|
+
|
|
140
|
+
`stagger` deals objects in turn. On a node it is `{ group, index, step? }`: nodes of one group that change in the same
|
|
141
|
+
update start one `step` apart (`'short'`, `'regular'` or `'long'`, default `'regular'`) in `index` order, and a node
|
|
142
|
+
that changes alone starts at once. Cards take it from their `SceneStack`. `delay` is a fixed wait on every change, in
|
|
143
|
+
milliseconds or as `{ index, step }`; it also delays a lone move, so prefer `stagger` for a deal or a cascade.
|
|
144
|
+
|
|
145
|
+
## Identity
|
|
146
|
+
|
|
147
|
+
An id names a thing, not a place. Keep it while the thing moves, turns or changes value, and change it only when the
|
|
148
|
+
thing itself is different: dealing a new card is a new id, moving a card is the same id. An object that appears after
|
|
149
|
+
the first paint fades in, and one with `isShown={false}` fades out. Render every object of every state and toggle
|
|
150
|
+
`isShown`, rather than mounting objects conditionally, so a disappearance eases.
|
|
151
|
+
|
|
152
|
+
The same id in a scene, a chart and a `Term` of one article is the same record: inspecting it in one marks it in the
|
|
153
|
+
others, and `tones` on `Article` gives it one hue everywhere.
|
|
154
|
+
|
|
155
|
+
## `SceneCustom`
|
|
156
|
+
|
|
157
|
+
The escape hatch for a drawing no part provides. Its child is a function that receives
|
|
158
|
+
`{ x, y, box, view, tone, color }` and returns SVG in plot pixels: `x.position(value)` and `y.position(value)` map data
|
|
159
|
+
units through the camera, `tone({ id, index })` resolves a tone through the scope, and `color(tone)` gives the colour
|
|
160
|
+
for `fill` or `stroke`. `layer` is `'back'` (under the wires) or `'front'` (the default). It is called on every camera
|
|
161
|
+
frame. What it draws is not inspectable or reachable by keyboard, so prefer a part when one exists, and put the meaning
|
|
162
|
+
in a labelled part.
|
|
163
|
+
|
|
164
|
+
## Writing a new part
|
|
165
|
+
|
|
166
|
+
A part an essay needs and the scene lacks belongs in Elements, under contract 142 and the `extend-elements` skill:
|
|
167
|
+
`useSceneObject` registers an id with its target geometry and returns the eased values, and `useSceneContext` gives the
|
|
168
|
+
scales, box, registry and pace.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Tutor
|
|
2
|
+
|
|
3
|
+
Import from `@mechane-ai/elements/lesson/agent`. A tutor is a model beside the reader that reads the lesson and moves it
|
|
4
|
+
through the UI SDK agent bridge, as `createAgent` from `@mechane-ai/elements/agent` exposes it. It acts with the same
|
|
5
|
+
actions a person's controls use, so the page cannot tell its changes apart except by their `agent` source.
|
|
6
|
+
|
|
7
|
+
## What an agent can and cannot do
|
|
8
|
+
|
|
9
|
+
- It reads the lesson's values, beat, step and player, the reader's progress, and each beat's tutor notes.
|
|
10
|
+
- It sets params, shows states, moves between beats, plays and pauses.
|
|
11
|
+
- It never commits a prediction, never reaches a challenge, and does not see a prediction's answer until the reader
|
|
12
|
+
commits it. That is what keeps the reader's own guesses honest.
|
|
13
|
+
- Tutor notes (`goal`, `misconception`, `hints`) reach the tutor and never the reader. Write them for a tutor: what the
|
|
14
|
+
reader should be able to say, the wrong belief to probe, and hints in the order to give them.
|
|
15
|
+
|
|
16
|
+
## Tools
|
|
17
|
+
|
|
18
|
+
`tutorTools({ agent, lesson, locale, article?, answers? })` returns tools a model calls: `read_outline`, `read_place`,
|
|
19
|
+
`set_param`, `set_params`, `show_state`, `go_to_beat`, `next`, `previous`, `play`, `pause` and `inspect_figure`. Each
|
|
20
|
+
has a `name`, a `description`, an `inputSchema` (JSON Schema) and `run(input)`, which resolves to
|
|
21
|
+
`{ kind: 'ok', changed?, at?, place?, outline?, note? }` or `{ kind: 'error', message }`.
|
|
22
|
+
|
|
23
|
+
`answers` maps each number `Predict` id to the lesson value it takes its answer from (its `answerFrom`), such as
|
|
24
|
+
`{ 'entropy-guess': 'entropy' }`. The tools withhold that value until the reader commits. Build it from the essay with
|
|
25
|
+
`answerSources(articleOutline(beats))`, both from `@mechane-ai/elements/article`, so it cannot drift from the markup; a
|
|
26
|
+
missing entry lets the tutor read the answer. The outline also lists the essay's `predictions` and `challenges`.
|
|
27
|
+
|
|
28
|
+
## The learner trace and tours
|
|
29
|
+
|
|
30
|
+
- `createLearnerTrace({ agent, lesson, article?, limit? })` records what the reader did: param moves, beat and step
|
|
31
|
+
changes, plays, predictions, hints and challenges. Changes an agent makes are left out. `read()` returns a
|
|
32
|
+
`LearnerRecord`; `subscribe`, `clear` and `stop` manage it.
|
|
33
|
+
- `summarizeTrace({ record, lesson, locale, answers? })` writes the record as a few sentences of facts for a prompt.
|
|
34
|
+
- A `LessonTour` is a list of steps `{ beat?, step?, state?, values?, say?, hold? }` with `hold` one of `'short'`,
|
|
35
|
+
`'regular'`, `'long'`. `validateTour(tour, lesson)` checks it; `playTour({ agent, lesson, tour, onSay })` plays it on
|
|
36
|
+
the shared clock and pauses when the reader acts. `tourFromTrace(record)` turns a recorded demonstration into a tour
|
|
37
|
+
to edit.
|
|
38
|
+
|
|
39
|
+
This sample takes `lesson` and the `cardNeuronBeats` fragment from the [worked essay](worked-essay.md).
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const agent = createAgent();
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The value each `Predict` takes its answer from, read from the beats, so the tools withhold it until the reader
|
|
46
|
+
* commits.
|
|
47
|
+
*/
|
|
48
|
+
const answers = answerSources(articleOutline(cardNeuronBeats));
|
|
49
|
+
|
|
50
|
+
/** The tools a tutor model calls. */
|
|
51
|
+
export const tools = tutorTools({ agent, lesson, locale: 'en-US', answers });
|
|
52
|
+
|
|
53
|
+
/** Hand each tool to the model as a definition, and run the one it calls. */
|
|
54
|
+
export const definitions = tools.map(({ name, description, inputSchema }) => ({ name, description, inputSchema }));
|
|
55
|
+
|
|
56
|
+
export async function callTool(name: string, input: unknown): Promise<string> {
|
|
57
|
+
const tool = tools.find((item) => item.name === name);
|
|
58
|
+
const result = tool === undefined ? { kind: 'error', message: `No tool ${name}.` } : await tool.run(input);
|
|
59
|
+
|
|
60
|
+
return JSON.stringify(result);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** What the reader did, as facts for the tutor's prompt. */
|
|
64
|
+
export const trace = createLearnerTrace({ agent, lesson });
|
|
65
|
+
|
|
66
|
+
export function readerFacts(): string {
|
|
67
|
+
return summarizeTrace({ record: trace.read(), lesson, locale: 'en-US', answers });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** A guided walk. Check it before it plays; it pauses when the reader acts. */
|
|
71
|
+
export const tour: LessonTour = [
|
|
72
|
+
{ beat: 'hand', state: 'queen-seven', say: 'Two cards: the queen counts 12, the seven 7.', hold: 'regular' },
|
|
73
|
+
{ beat: 'weights', state: 'against', say: 'A negative weight makes the queen count against.', hold: 'long' },
|
|
74
|
+
{ beat: 'bias', values: { bias: -8 }, say: 'Now the neuron needs stronger evidence.' },
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
export function startTour(onSay: (line: string) => void): void {
|
|
78
|
+
const findings = validateTour(tour, lesson);
|
|
79
|
+
|
|
80
|
+
if (findings.length > 0) {
|
|
81
|
+
throw new Error(findings.map((finding) => `${finding.path}: ${finding.message}`).join('\n'));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
playTour({ agent, lesson, tour, onSay });
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The tutor's own words go to the reader through your page, not through these tools. Show `onSay` lines and the model's
|
|
89
|
+
replies in a `Conversation` from `@mechane-ai/elements/ai`.
|
|
90
|
+
|
|
91
|
+
## From Node, without a page
|
|
92
|
+
|
|
93
|
+
`describeLesson(lesson)` (the lesson as JSON), `lessonWalk(lesson, locale)` (the lesson as text, every state with its
|
|
94
|
+
derived values written out) and `checkLesson(lesson)` come from `@mechane-ai/elements/lesson/spec` and need no browser.
|
|
95
|
+
A lesson file that imports only `defineLesson` loads in Node 22 directly:
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
node --input-type=module -e "
|
|
99
|
+
import { checkLesson, lessonWalk } from '@mechane-ai/elements/lesson/spec';
|
|
100
|
+
import { lesson } from './src/lesson.ts';
|
|
101
|
+
console.log(lessonWalk(lesson, 'en-US'));
|
|
102
|
+
for (const finding of checkLesson(lesson)) console.log(finding.severity, finding.path, finding.message);
|
|
103
|
+
"
|
|
104
|
+
```
|