@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
package/README.md
CHANGED
|
@@ -19,13 +19,16 @@ pnpm exec mechane-elements-catalog --install-skills .claude/skills
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Use `.agents/skills` or another directory for an agent that reads skills from there. Run the command again after each
|
|
22
|
-
upgrade; it replaces the
|
|
22
|
+
upgrade; it replaces the six skills with the new version's copies.
|
|
23
23
|
|
|
24
24
|
| Skill | Use it to |
|
|
25
25
|
| ---------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
26
26
|
| [use-elements](skills/use-elements/SKILL.md) | Choose components and build a page, with a guide for each family. |
|
|
27
27
|
| [review-elements](skills/review-elements/SKILL.md) | Check a page by keyboard, read state, width, theme and agent access. |
|
|
28
28
|
| [upgrade-elements](skills/upgrade-elements/SKILL.md) | Move an app to a new version, with the changes each release needs. |
|
|
29
|
+
| [plan-lesson](skills/plan-lesson/SKILL.md) | Plan an explorable essay as a checked lesson plan before writing code. |
|
|
30
|
+
| [write-explainer](skills/write-explainer/SKILL.md) | Write the essay from a valid plan with the teaching layers. |
|
|
31
|
+
| [review-explainer](skills/review-explainer/SKILL.md) | Review an essay as a learner, in all four views. |
|
|
29
32
|
| [extend-elements](skills/extend-elements/SKILL.md) | Change the library itself. It stays in the package and is not installed. |
|
|
30
33
|
|
|
31
34
|
An agent without skills can read the same files in place. Add one line to its instructions file, such as `AGENTS.md`:
|
|
@@ -115,38 +118,57 @@ emitted layers and selector specificity.
|
|
|
115
118
|
|
|
116
119
|
Every path below belongs to `@mechane-ai/elements`. There is one package, version, and stylesheet.
|
|
117
120
|
|
|
118
|
-
| Entry
|
|
119
|
-
|
|
|
120
|
-
| Root
|
|
121
|
-
| `/forms`
|
|
122
|
-
| `/forms/dates`
|
|
123
|
-
| `/overlays`
|
|
124
|
-
| `/feedback`
|
|
125
|
-
| `/navigation`
|
|
126
|
-
| `/navigation/commands`
|
|
127
|
-
| `/layout`
|
|
128
|
-
| `/collections`
|
|
129
|
-
| `/content`
|
|
130
|
-
| `/content/link`
|
|
131
|
-
| `/content/markdown`
|
|
132
|
-
| `/content/code`
|
|
133
|
-
| `/content/diff`
|
|
134
|
-
| `/content/tree`
|
|
135
|
-
| `/ai`
|
|
136
|
-
| `/charts`
|
|
137
|
-
| `/charts/cartesian`
|
|
138
|
-
| `/charts/distribution`
|
|
139
|
-
| `/charts/matrix`
|
|
140
|
-
| `/charts/graph`
|
|
141
|
-
| `/charts/hierarchy`
|
|
142
|
-
| `/charts/timeline`
|
|
143
|
-
| `/
|
|
144
|
-
| `/
|
|
145
|
-
| `/
|
|
146
|
-
| `/
|
|
147
|
-
| `/
|
|
148
|
-
| `/
|
|
149
|
-
| `/
|
|
121
|
+
| Entry | Responsibility |
|
|
122
|
+
| ------------------------ | -------------------------------------------------------------------------------------------------------------- |
|
|
123
|
+
| Root | Buttons, text, surfaces, disclosure, avatars, and CopyValue. |
|
|
124
|
+
| `/forms` | Fields, inputs, selection, appearance picking, file picking, and settings sections. |
|
|
125
|
+
| `/forms/dates` | Civil-date pickers, range selection, and a controlled event month. |
|
|
126
|
+
| `/overlays` | Dialog, Drawer, Menu, Popover, Preview, Tooltip, and AlertDialog. |
|
|
127
|
+
| `/feedback` | Async regions, skeletons, progress, meters, notices, empty states, and toasts. |
|
|
128
|
+
| `/navigation` | Tabs, page navigation, breadcrumbs, skip links, and shortcut labels. |
|
|
129
|
+
| `/navigation/commands` | Command palette and scoped application-owned shortcuts. |
|
|
130
|
+
| `/layout` | Application shell, sidebar, toolbars, compound record pages, and resizable panes. |
|
|
131
|
+
| `/collections` | Tables, inspectors, collection controls, timelines, metrics, and timestamps. |
|
|
132
|
+
| `/content` | Trace, JSON, recorded logs, and stack traces. |
|
|
133
|
+
| `/content/link` | Safe content links without a renderer dependency. |
|
|
134
|
+
| `/content/markdown` | Completed and streaming Markdown, embedded headings, and inert previews. |
|
|
135
|
+
| `/content/code` | Source-preserving code highlighting. |
|
|
136
|
+
| `/content/diff` | File changes and patches. |
|
|
137
|
+
| `/content/tree` | File paths, statuses, and controlled selection. |
|
|
138
|
+
| `/ai` | Conversations, messages, prompts, approvals, sources, and citations. |
|
|
139
|
+
| `/charts` | Figure props, formats, tone scope, linked inspection, frames, legends, and grids. |
|
|
140
|
+
| `/charts/cartesian` | Lines, ranges, areas, sparklines, small multiples, bars, bridges, and scatter plots. |
|
|
141
|
+
| `/charts/distribution` | Histograms, cumulative distributions, intervals, ranked values, box, violin, strip, and ridgeline plots. |
|
|
142
|
+
| `/charts/matrix` | Matrices and their confusion, correlation, attention, and calendar presets, token heatmaps, and color legends. |
|
|
143
|
+
| `/charts/graph` | Supplied relationships, weighted flows, attribution graphs, and tree diagrams. |
|
|
144
|
+
| `/charts/hierarchy` | Treemaps and icicles. |
|
|
145
|
+
| `/charts/timeline` | Waterfall intervals and instants, and lanes of events. |
|
|
146
|
+
| `/charts/trend` | Curves over a step or layer, many runs, slopes, rank changes, and horizon rows. |
|
|
147
|
+
| `/charts/comparison` | Dot plots, dumbbells, and bullet bars. |
|
|
148
|
+
| `/charts/relationship` | Contours, scatter matrices, parallel coordinates, embedding maps, and density maps. |
|
|
149
|
+
| `/charts/text` | Token examples, next-token predictions, layer by position token grids, and token links. |
|
|
150
|
+
| `/charts/image` | Image grids, attribution overlays, and image atlases. |
|
|
151
|
+
| `/charts/cells` | Bar, heat, change, interval, and spark graphics for table cells. |
|
|
152
|
+
| `/charts/transforms` | Bins, densities, fits, quantiles, ranks, smoothing, and sampling that an application calls before drawing. |
|
|
153
|
+
| `/charts/plot` | The plot kernel: scales, ticks, axes, marks, and states for a chart the library lacks. |
|
|
154
|
+
| `/charts/figure` | Figure specs as JSON: validate a spec, draw it, describe it, and read the chart guide. |
|
|
155
|
+
| `/lesson` | Lessons: named values with ranges, controls in prose, players, one shared clock, and tweens. |
|
|
156
|
+
| `/lesson/spec` | Lesson plans and defined lessons as data: checks, outlines, teaching advice, and the explainer guide. |
|
|
157
|
+
| `/lesson/agent` | Tutor tools, a learner trace, and guided tours over the agent bridge. |
|
|
158
|
+
| `/scene` | Diagrams whose objects keep their identity: nodes, wires, plane marks, cards, cells, tokens, and flows. |
|
|
159
|
+
| `/article` | Explorable essays: beats, figures, predictions, challenges, notes, and four views of one essay. |
|
|
160
|
+
| `/mdx` | An essay written as one MDX file, with every teaching part available without imports. |
|
|
161
|
+
| `/kits/training` | A run dashboard, a run table, and a sweep overview. |
|
|
162
|
+
| `/kits/operations` | Service health, budgets against objectives, and an incident timeline. |
|
|
163
|
+
| `/kits/evaluation` | A model leaderboard, a score breakdown, and a two-model comparison. |
|
|
164
|
+
| `/kits/interpretability` | Feature cards and lists, an attribution workbench, attention heads, a logit lens, a feature map, and steering. |
|
|
165
|
+
| `/theme` | Light and dark theme props. |
|
|
166
|
+
| `/agent` | Optional UI SDK bridge for a host that enables component inspection and actions. |
|
|
167
|
+
| `/csp` | Application-supplied content security policy configuration. |
|
|
168
|
+
| `/tokens` | Compiled token references for runtime styles. |
|
|
169
|
+
| `/tokens.stylex` | Variable definitions for StyleX authoring and themes. |
|
|
170
|
+
| `/constants.stylex` | Compile-time conditions, palette values, layers, and shared geometry. |
|
|
171
|
+
| `/styles.css` | Component styles and token defaults. |
|
|
150
172
|
|
|
151
173
|
Focused entries keep renderer and chart dependencies out of basic controls. There is no all-components barrel. Renderers
|
|
152
174
|
initialize when used, without a consumer-managed worker pool or grammar CDN. The
|
|
@@ -206,7 +228,7 @@ selection; Escape dismisses the readout while retaining the cursor.
|
|
|
206
228
|
Change callbacks receive the UI SDK's change details after the value. `details.reason` names what happened, such as
|
|
207
229
|
`input-change`, `clear-press` or `item-press`, and `details.source` says whether a pointer, the keyboard, an agent or
|
|
208
230
|
code caused it. `Input` and `Textarea` `onValueChange`, a collection's `search.onChange` and `search.onSubmit`, a
|
|
209
|
-
filter's `onChange`, `FilterChips` `onRemove`, a chart's `
|
|
231
|
+
filter's `onChange`, `FilterChips` `onRemove`, a chart's `onSelectedChange` and a table's `onSortChange` and
|
|
210
232
|
`onSelectionChange` all pass them.
|
|
211
233
|
|
|
212
234
|
`Workbench` accepts an optional `inspector={{ label: 'Workspace', content: <WorkspaceFiles /> }}`. The application
|
|
@@ -350,6 +372,540 @@ Build placeholders from the same layouts as their destinations. `DataTablePlaceh
|
|
|
350
372
|
`DataTableColumnLayout` definitions and optional decorative cells. The async region owns the loading announcement; its
|
|
351
373
|
placeholders must not contain interactive controls, invented records, or independent status announcements.
|
|
352
374
|
|
|
375
|
+
## Charts and figures
|
|
376
|
+
|
|
377
|
+
Every chart is built from one plot kernel and takes the same figure props. This is the idea:
|
|
378
|
+
|
|
379
|
+
- **One kernel.** Scales, ticks, axes, marks, readout and keyboard cursor come from `/charts/plot`, so charts behave
|
|
380
|
+
alike. A chart owns its input and the arrangement of parts.
|
|
381
|
+
- **Shared figure props.** Each chart takes `title`, `description`, `locale`, `source`, `coverage`, `transforms`,
|
|
382
|
+
`status` and `emptyLabel`. Selection is `selected` with `onSelectedChange`. `Waterfall` takes a subset of these.
|
|
383
|
+
`Sparkline`, `ColorLegend` and the table cells are compact graphics and do not take them.
|
|
384
|
+
- **Declared formats and locale.** A number is written from `Intl` options and the figure's required `locale`. There is
|
|
385
|
+
no formatter-function prop. Axes are `{ label, domain?, scale?, format, tickFormat? }`, and heights are `'compact'`,
|
|
386
|
+
`'regular'` or `'tall'`.
|
|
387
|
+
- **One meaning per visual channel.** Hue names a thing, lightness is a magnitude, two hues around a middle are a signed
|
|
388
|
+
value, a dashed stroke is modelled, a pale band is uncertainty, a hollow mark is missing and gray is context.
|
|
389
|
+
- **States.** Each figure has loading, empty, invalid and partial states. A figure that draws part of its data says how
|
|
390
|
+
much beside its title. The footnote names the source and each transform.
|
|
391
|
+
|
|
392
|
+
Statistics stay outside charts. Compute bins, quantiles, densities and fits with `/charts/transforms` and name them in
|
|
393
|
+
`transforms`.
|
|
394
|
+
|
|
395
|
+
### Choose a chart
|
|
396
|
+
|
|
397
|
+
The table is the library's own `chartGuide`: one entry per registered chart, grouped by family, with the question the
|
|
398
|
+
chart answers. Each family is the import entry `@mechane-ai/elements/charts/<family>`. The
|
|
399
|
+
[chart guide](https://github.com/mechane-ai/mechane/blob/main/workspaces/core/docs/ui-charts.md#choose-a-chart) adds
|
|
400
|
+
when to use each chart and when another is better. Use a table when exact comparison matters more than shape.
|
|
401
|
+
|
|
402
|
+
| Family entry | Chart | The reader asks |
|
|
403
|
+
| ---------------------- | --------------------- | ------------------------------------------------------------------------ |
|
|
404
|
+
| `/charts/trend` | `CurveChart` | How did a metric change over training steps or another ordered variable? |
|
|
405
|
+
| `/charts/trend` | `RunsChart` | How does one run compare with the whole sweep it belongs to? |
|
|
406
|
+
| `/charts/trend` | `SlopeChart` | How did each item move between two to six conditions? |
|
|
407
|
+
| `/charts/trend` | `BumpChart` | How did the ranking of items change across stages? |
|
|
408
|
+
| `/charts/trend` | `HorizonChart` | Which of many series run above or below normal, and when? |
|
|
409
|
+
| `/charts/comparison` | `DotPlot` | How do a few models compare on each of several measures? |
|
|
410
|
+
| `/charts/comparison` | `DumbbellPlot` | How much did each row change between two measurements? |
|
|
411
|
+
| `/charts/comparison` | `BulletBar` | Is each measure meeting its target? |
|
|
412
|
+
| `/charts/cartesian` | `BarChart` | How large is each amount, by category and series? |
|
|
413
|
+
| `/charts/cartesian` | `BridgeChart` | Which changes add up to the difference between two totals? |
|
|
414
|
+
| `/charts/cartesian` | `BreakdownBar` | How does one total split into parts? |
|
|
415
|
+
| `/charts/cartesian` | `ScatterPlot` | How do two measures of the same records relate? |
|
|
416
|
+
| `/charts/cartesian` | `LineChart` | How did a measure change over time? |
|
|
417
|
+
| `/charts/cartesian` | `AreaChart` | How did a total and its parts change over time? |
|
|
418
|
+
| `/charts/cartesian` | `SmallMultiples` | How do several related measures move together over the same time? |
|
|
419
|
+
| `/charts/cartesian` | `Sparkline` | Which way is one measure trending, at a glance? |
|
|
420
|
+
| `/charts/distribution` | `Histogram` | How are the values of one measure distributed? |
|
|
421
|
+
| `/charts/distribution` | `ECDF` | What share of values falls below a given level? |
|
|
422
|
+
| `/charts/distribution` | `IntervalPlot` | What is each estimate, and how uncertain is it? |
|
|
423
|
+
| `/charts/distribution` | `RankedBars` | Which items rank highest on one measure? |
|
|
424
|
+
| `/charts/distribution` | `BoxPlot` | How do the distributions of several groups compare? |
|
|
425
|
+
| `/charts/distribution` | `ViolinPlot` | How does the shape of a distribution differ between groups? |
|
|
426
|
+
| `/charts/distribution` | `StripPlot` | Where does every single value of each group fall? |
|
|
427
|
+
| `/charts/distribution` | `Ridgeline` | How does a distribution shift across many ordered groups? |
|
|
428
|
+
| `/charts/matrix` | `Matrix` | What is the value for every pair of two categories? |
|
|
429
|
+
| `/charts/matrix` | `TokenHeatmap` | Which tokens of a text carry the most of a score? |
|
|
430
|
+
| `/charts/matrix` | `ConfusionMatrix` | Which classes does a classifier confuse with which? |
|
|
431
|
+
| `/charts/matrix` | `CorrelationMatrix` | Which measures move together? |
|
|
432
|
+
| `/charts/matrix` | `AttentionMatrix` | Which earlier tokens does each token attend to? |
|
|
433
|
+
| `/charts/matrix` | `CalendarHeatmap` | How does a daily measure vary by week and weekday? |
|
|
434
|
+
| `/charts/graph` | `RelationGraph` | How are a few named things connected? |
|
|
435
|
+
| `/charts/graph` | `FlowDiagram` | Where does a quantity go between stages? |
|
|
436
|
+
| `/charts/graph` | `AttributionGraph` | Which features carry a model’s answer from the prompt to the output? |
|
|
437
|
+
| `/charts/graph` | `TreeDiagram` | How is a hierarchy structured? |
|
|
438
|
+
| `/charts/hierarchy` | `Treemap` | Which parts make up most of a total? |
|
|
439
|
+
| `/charts/hierarchy` | `Icicle` | How does a total split through nested levels? |
|
|
440
|
+
| `/charts/timeline` | `Waterfall` | When did each step of a request or run start and end? |
|
|
441
|
+
| `/charts/timeline` | `EventStrip` | What happened when, across a few kinds of events? |
|
|
442
|
+
| `/charts/relationship` | `ContourPlot` | What does a value look like over two continuous inputs? |
|
|
443
|
+
| `/charts/relationship` | `ScatterMatrix` | How do several measures relate to each other, pair by pair? |
|
|
444
|
+
| `/charts/relationship` | `ParallelCoordinates` | Which records do well on many measures at once? |
|
|
445
|
+
| `/charts/relationship` | `EmbeddingMap` | How do many items cluster in a learned embedding space? |
|
|
446
|
+
| `/charts/relationship` | `DensityMap` | Where are points concentrated over two measures? |
|
|
447
|
+
| `/charts/text` | `TokenExamples` | On which passages, and which tokens, does a feature fire? |
|
|
448
|
+
| `/charts/text` | `TokenPredictions` | Which tokens does the model expect next, and how did that change? |
|
|
449
|
+
| `/charts/text` | `TokenGrid` | How does a per-token value change across layers or conditions? |
|
|
450
|
+
| `/charts/text` | `TokenLinks` | Which tokens most influence which later tokens? |
|
|
451
|
+
| `/charts/image` | `ImageGrid` | What do a set of images look like, with a value for each? |
|
|
452
|
+
| `/charts/image` | `AttributionOverlay` | Which parts of an image drove the model’s output? |
|
|
453
|
+
| `/charts/image` | `ImageAtlas` | How do images arrange over a two-dimensional layout? |
|
|
454
|
+
|
|
455
|
+
`ColorLegend`, the table cells in `/charts/cells`, the placeholders and the kits are not registered charts, so the guide
|
|
456
|
+
does not list them. `chartGuide` is exported from `@mechane-ai/elements/charts/figure`, so an application or an agent
|
|
457
|
+
can read the same guidance at run time. Each entry has `chart`, `family`, `question`, `use`, `avoid` and `example`, a
|
|
458
|
+
small valid figure spec.
|
|
459
|
+
|
|
460
|
+
```ts
|
|
461
|
+
import { chartGuide } from '@mechane-ai/elements/charts/figure';
|
|
462
|
+
|
|
463
|
+
const entry = chartGuide.find((item) => item.chart === 'Histogram');
|
|
464
|
+
// entry?.question, entry?.use, entry?.avoid, entry?.example
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### Link figures and keep one hue per thing
|
|
468
|
+
|
|
469
|
+
Give a thing one id in every figure. `ToneScope` gives each id one hue. `ChartLink` shares one inspected id between the
|
|
470
|
+
figures inside it: pointing at a record in one figure marks the record with the same id in the others. `ChartGrid` is a
|
|
471
|
+
`ChartLink` and a `ToneScope` laid out as panels with one title.
|
|
472
|
+
|
|
473
|
+
```tsx
|
|
474
|
+
import { ChartLink, ToneScope } from '@mechane-ai/elements/charts';
|
|
475
|
+
import { DotPlot } from '@mechane-ai/elements/charts/comparison';
|
|
476
|
+
import { CurveChart } from '@mechane-ai/elements/charts/trend';
|
|
477
|
+
|
|
478
|
+
export function Runs() {
|
|
479
|
+
return (
|
|
480
|
+
<ToneScope ids={['base', 'wide']}>
|
|
481
|
+
<ChartLink>
|
|
482
|
+
<CurveChart
|
|
483
|
+
title="Validation loss"
|
|
484
|
+
locale="en-US"
|
|
485
|
+
series={[
|
|
486
|
+
{
|
|
487
|
+
id: 'base',
|
|
488
|
+
label: 'Base',
|
|
489
|
+
points: [
|
|
490
|
+
{ x: 100, y: 4.2 },
|
|
491
|
+
{ x: 1000, y: 2.6 },
|
|
492
|
+
],
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
id: 'wide',
|
|
496
|
+
label: 'Wide',
|
|
497
|
+
points: [
|
|
498
|
+
{ x: 100, y: 4.1 },
|
|
499
|
+
{ x: 1000, y: 2.2 },
|
|
500
|
+
],
|
|
501
|
+
},
|
|
502
|
+
]}
|
|
503
|
+
x={{ label: 'Training step', scale: 'log', format: { maximumFractionDigits: 0 } }}
|
|
504
|
+
y={{ label: 'Loss (nats)', format: { maximumFractionDigits: 2 } }}
|
|
505
|
+
/>
|
|
506
|
+
<DotPlot
|
|
507
|
+
title="Score by task"
|
|
508
|
+
locale="en-US"
|
|
509
|
+
rows={[{ id: 'code', label: 'Code' }]}
|
|
510
|
+
series={[
|
|
511
|
+
{ id: 'base', label: 'Base', values: { code: 0.61 } },
|
|
512
|
+
{ id: 'wide', label: 'Wide', values: { code: 0.68 } },
|
|
513
|
+
]}
|
|
514
|
+
value={{ label: 'Accuracy', domain: [0, 1], format: { style: 'percent' } }}
|
|
515
|
+
/>
|
|
516
|
+
</ChartLink>
|
|
517
|
+
</ToneScope>
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
A figure that draws series can also take emphasis from outside, which never changes selection:
|
|
523
|
+
|
|
524
|
+
- `CurveChart`, `DotPlot` and `BarChart` take `highlighted`, the id of the one series drawn at full strength while the
|
|
525
|
+
others fade, or `null` for none. Left out on `CurveChart` and `DotPlot`, it follows the enclosing `ChartLink`, so
|
|
526
|
+
hovering a table row that inspects a series id lights that series. `RunsChart` takes `featured`, a required list of
|
|
527
|
+
the run ids drawn in their hue, and no `highlighted`.
|
|
528
|
+
- `CurveChart` takes `labels`: `'legend'` (the default) names the series in a legend, `'inline'` writes each name at the
|
|
529
|
+
end of its line when there is room, and `'none'` leaves them out when a legend beside a grid already names them.
|
|
530
|
+
- `useScopedTone(id)` returns the hue the enclosing `ToneScope` gives an id, or `undefined` outside a scope. Use it so a
|
|
531
|
+
word or a diagram part matches its chart.
|
|
532
|
+
- `useChartLinkControl()` returns `{ inspected, inspect }` for the enclosing `ChartLink`, or `undefined` outside one.
|
|
533
|
+
Call `inspect(id, { reason, event })` from prose or a diagram to point every linked figure at a record.
|
|
534
|
+
|
|
535
|
+
### Describe a figure as JSON
|
|
536
|
+
|
|
537
|
+
A figure spec is `{ chart, props }` as plain JSON. `chart` is the name of a registered chart, and `props` are its props
|
|
538
|
+
without callbacks and React content, such as `actions`. An agent or a server writes it. The entry
|
|
539
|
+
`@mechane-ai/elements/charts/figure` exports:
|
|
540
|
+
|
|
541
|
+
| Export | What it does |
|
|
542
|
+
| ----------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
543
|
+
| `FigureSpec` | The type of a spec. `FigureSpecOf<'Histogram'>` is the spec of one chart. |
|
|
544
|
+
| `validateFigureSpec(x)` | Returns `{ kind: 'ok', spec }` or `{ kind: 'invalid', message }`. It checks the structure and never throws. |
|
|
545
|
+
| `Figure` | Draws a spec. It takes `selected`, `onSelectedChange` and `status` beside it. |
|
|
546
|
+
| `describeFigure(spec)` | Returns the figure as one short text for a place that cannot draw it. |
|
|
547
|
+
| `figureCharts` | `{ chart, family }` for every registered chart. |
|
|
548
|
+
| `chartGuide` | The guide above, as data. |
|
|
549
|
+
|
|
550
|
+
`validateFigureSpec` checks that the input is an object, that `chart` is registered, that `props` is an object holding
|
|
551
|
+
every required prop with the right JSON kind, that no function is inside, and that `locale` is not empty. Each chart
|
|
552
|
+
then checks its own values. `Figure` runs the same check. For a bad spec it draws the shared invalid figure with the
|
|
553
|
+
reason in place of the chart, so a spec an agent got wrong is visible and nothing throws. `selected` and
|
|
554
|
+
`onSelectedChange` reach only the charts that take a selection, and `status` replaces the spec's own while newer data
|
|
555
|
+
loads.
|
|
556
|
+
|
|
557
|
+
```tsx
|
|
558
|
+
import { Figure, describeFigure, validateFigureSpec } from '@mechane-ai/elements/charts/figure';
|
|
559
|
+
|
|
560
|
+
const spec = {
|
|
561
|
+
chart: 'Histogram',
|
|
562
|
+
props: {
|
|
563
|
+
title: 'Request latency',
|
|
564
|
+
description: 'Synthetic requests over one hour, in 25 ms bins.',
|
|
565
|
+
locale: 'en-US',
|
|
566
|
+
source: 'Synthetic trace',
|
|
567
|
+
transforms: ['Binned at 25 ms'],
|
|
568
|
+
value: { label: 'Latency (ms)', format: { maximumFractionDigits: 0 } },
|
|
569
|
+
count: { label: 'Requests', format: { maximumFractionDigits: 0 } },
|
|
570
|
+
bins: [
|
|
571
|
+
{ id: 'b0', label: '0 to 25 ms', lowerBound: 0, upperBound: 25, count: 120 },
|
|
572
|
+
{ id: 'b1', label: '25 to 50 ms', lowerBound: 25, upperBound: 50, count: 340 },
|
|
573
|
+
],
|
|
574
|
+
},
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
const result = validateFigureSpec(spec);
|
|
578
|
+
|
|
579
|
+
export function Latency() {
|
|
580
|
+
return result.kind === 'ok' ? <Figure spec={result.spec} /> : null;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// For this spec, describeFigure(result.spec) returns:
|
|
584
|
+
// A histogram, "Request latency", with 2 bins. Synthetic requests over one hour, in 25 ms bins. Source: Synthetic trace. Transforms: Binned at 25 ms.
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
`describeFigure` names the chart and its title, then the description, how much of the data is drawn when `coverage` is
|
|
588
|
+
set, the source, the transforms, and how many records the spec holds. It does not restate the values.
|
|
589
|
+
|
|
590
|
+
A misspelt chart name is refused with the close names:
|
|
591
|
+
|
|
592
|
+
```ts
|
|
593
|
+
validateFigureSpec({ chart: 'Histogramm', props: { title: 'Request latency', locale: 'en-US' } });
|
|
594
|
+
// { kind: 'invalid', message: '"Histogramm" is not a registered chart. Did you mean Histogram?' }
|
|
595
|
+
|
|
596
|
+
validateFigureSpec({ chart: 'Bar', props: {} });
|
|
597
|
+
// { kind: 'invalid', message: '"Bar" is not a registered chart. Did you mean BarChart, BreakdownBar, RankedBars?' }
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
The `use-elements` skill's [figures guide](skills/use-elements/references/figures.md) has the rules for an agent that
|
|
601
|
+
writes specs.
|
|
602
|
+
|
|
603
|
+
### Build a chart the library lacks
|
|
604
|
+
|
|
605
|
+
`@mechane-ai/elements/charts/plot` is the kernel every chart uses. It exports the scales, ticks and paths, the plot
|
|
606
|
+
layout, `PlotSurface`, `PlotAxes` and `PlotClip`, the marks (`LineMark`, `AreaMark`, `BandMark`, `DotMark`, `BarMark`,
|
|
607
|
+
`RuleMark`, `IntervalMark`, `LabelMark`, `SymbolMark`, `RingMark`, `LinkMark`, `ConnectorMark` and `GuideMark`), the
|
|
608
|
+
`Chart` primitive with `ChartCursor`, `ChartInspection` and `ChartData`, the frame and its states (`FigureFrame`,
|
|
609
|
+
`FigureLoading`, `FigureEmpty`, `FigureInvalid`), `useTones`, the tick helpers (`axisTicks`, `timeAxisTicks`,
|
|
610
|
+
`tickTexts`, `ticksMinimum`), the label placement helpers (`freeLabelSpot`, `labelBox`), and the canvas and WebGL
|
|
611
|
+
layers. `FigureFrame` takes `seriesLegend`, a legend that names things, above the plot, and `scaleLegend`, a color or
|
|
612
|
+
size scale, below it. A custom chart that is built from these has the same axes, readout, keyboard cursor, states and
|
|
613
|
+
tones as the others. Take `FigureProps`, `formatValue` and `useLinkedInspection` from `/charts`. Do not draw your own
|
|
614
|
+
scale or axis.
|
|
615
|
+
|
|
616
|
+
### Kits
|
|
617
|
+
|
|
618
|
+
A kit composes charts into a page for one domain: `/kits/training` for runs, `/kits/evaluation` for model comparison,
|
|
619
|
+
`/kits/operations` for service health, `/kits/interpretability` for features, attribution, attention and steering. A kit
|
|
620
|
+
adds no marks. It decides which figures answer the question and shares one tone scope and one linked inspection between
|
|
621
|
+
them. The application supplies every value. The `use-elements` skill's
|
|
622
|
+
[kits guide](skills/use-elements/references/kits.md) lists each component and the data it takes.
|
|
623
|
+
|
|
624
|
+
### Renderer limits
|
|
625
|
+
|
|
626
|
+
Marks a reader inspects one by one draw as SVG. Most charts export a limits object, such as `scatterLimits`, and refuse
|
|
627
|
+
input above it with a message that names the limit. `BarChart`, `BridgeChart`, `BreakdownBar` and `Treemap` share
|
|
628
|
+
`categoricalLimits`, exported from `/charts`. `Histogram`, `ECDF`, `IntervalPlot` and `RankedBars` share
|
|
629
|
+
`distributionLimits`, exported from `/charts/distribution`. `EmbeddingMap` draws on canvas up to 100,000 points and with
|
|
630
|
+
WebGL up to 1,000,000, and `DensityMap` draws its grid on canvas. A canvas or WebGL plot keeps the same inspection,
|
|
631
|
+
selection, readout and text alternative as an SVG plot. The WebGL figure was measured in a headless software renderer,
|
|
632
|
+
not on a GPU.
|
|
633
|
+
|
|
634
|
+
## Explorable explanations
|
|
635
|
+
|
|
636
|
+
A lesson is a set of named values a reader can change, such as a batch size or a temperature, and everything that reads
|
|
637
|
+
them: the sentences, the controls, the figures and an agent. Six entries build an essay in layers. `/lesson` holds the
|
|
638
|
+
values, `/scene` draws diagrams, `/article` arranges beats of prose and figures, and `/mdx` lets one file hold the
|
|
639
|
+
essay. `/lesson/spec` checks a plan before any component exists, and `/lesson/agent` lets a tutor model read and move
|
|
640
|
+
the lesson. The idea:
|
|
641
|
+
|
|
642
|
+
- **One store.** `defineLesson` declares each param with its range, step and format, each derived value as a pure
|
|
643
|
+
function of the values before it, and each beat with its states as plain data. `Lesson` holds the values in one UI SDK
|
|
644
|
+
primitive. A number in a sentence, a slider, a figure, a player and an agent read and set the same names. A value
|
|
645
|
+
outside a param's range is refused with an error that names the param and its bounds.
|
|
646
|
+
- **States, not animations.** You say where things are. A `Scene` object given new props eases to them, a wire follows
|
|
647
|
+
its ends, and an object with the same `id` is the same thing in every state. Every move runs on one shared clock
|
|
648
|
+
(`createTween` and `useTween`), and a reader who asked for reduced motion gets the end state at once.
|
|
649
|
+
- **One kernel.** A `Scene` draws with the plot kernel, so a diagram has the chart's tones, readout and keyboard cursor.
|
|
650
|
+
Every labelled object is an item the arrow keys reach.
|
|
651
|
+
- **Four views of one essay.** An `Article` renders the same children as a scrolling essay, a presentation, a static
|
|
652
|
+
page or a beat sheet. The views differ in arrangement only.
|
|
653
|
+
- **Only the reader's acts count.** Predictions, challenges and hints change the reader's progress only when the reader
|
|
654
|
+
makes them. A change an agent makes never commits a prediction or reaches a challenge.
|
|
655
|
+
- **Agents use the bridge.** The lesson and the reader's progress appear in the UI SDK agent snapshot. Tutor tools, the
|
|
656
|
+
learner trace and tours read and act through `createAgent` and nothing else.
|
|
657
|
+
|
|
658
|
+
Define a lesson, then put its values in a sentence and a diagram. `Param` is a number the reader drags in place, and
|
|
659
|
+
`Value` writes a value in its declared format:
|
|
660
|
+
|
|
661
|
+
```tsx
|
|
662
|
+
import { defineLesson, Lesson, Param, ParamSlider, useLesson, Value } from '@mechane-ai/elements/lesson';
|
|
663
|
+
import { Scene, SceneNode, SceneWire } from '@mechane-ai/elements/scene';
|
|
664
|
+
|
|
665
|
+
const lesson = defineLesson({
|
|
666
|
+
id: 'batch-noise',
|
|
667
|
+
title: 'Why a bigger batch is quieter',
|
|
668
|
+
params: {
|
|
669
|
+
batch: {
|
|
670
|
+
kind: 'number',
|
|
671
|
+
label: 'Batch size',
|
|
672
|
+
value: 4,
|
|
673
|
+
min: 1,
|
|
674
|
+
max: 256,
|
|
675
|
+
step: 1,
|
|
676
|
+
scale: 'log',
|
|
677
|
+
format: { maximumFractionDigits: 0 },
|
|
678
|
+
},
|
|
679
|
+
},
|
|
680
|
+
derived: {
|
|
681
|
+
noise: {
|
|
682
|
+
label: 'Gradient noise',
|
|
683
|
+
format: { style: 'percent', maximumFractionDigits: 0 },
|
|
684
|
+
from: ({ batch }) => 1 / Math.sqrt(batch),
|
|
685
|
+
},
|
|
686
|
+
},
|
|
687
|
+
beats: [
|
|
688
|
+
{
|
|
689
|
+
id: 'noise',
|
|
690
|
+
title: 'Noise falls with the square root',
|
|
691
|
+
goal: 'Find that four times the examples halves the noise.',
|
|
692
|
+
states: [
|
|
693
|
+
{ id: 'four', label: 'Four examples', values: { batch: 4 } },
|
|
694
|
+
{ id: 'sixty-four', label: 'Sixty-four examples', values: { batch: 64 } },
|
|
695
|
+
],
|
|
696
|
+
},
|
|
697
|
+
],
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
function BatchScene() {
|
|
701
|
+
const { values } = useLesson(lesson);
|
|
702
|
+
|
|
703
|
+
return (
|
|
704
|
+
<Scene title="From a batch to a gradient" x={[0, 2]} y={[0, 1]} height="compact">
|
|
705
|
+
<SceneNode id="batch" at={[0.5, 0.5]} text={`${values.batch} examples`} />
|
|
706
|
+
<SceneNode
|
|
707
|
+
id="gradient"
|
|
708
|
+
at={[1.5, 0.5]}
|
|
709
|
+
shape="pill"
|
|
710
|
+
text="gradient"
|
|
711
|
+
label={`The averaged gradient, ${Math.round(values.noise * 100)}% as noisy as one example`}
|
|
712
|
+
tone={values.noise > 0.5 ? 'negative' : 'positive'}
|
|
713
|
+
/>
|
|
714
|
+
<SceneWire from="batch" to="gradient" label="The examples are averaged" />
|
|
715
|
+
</Scene>
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
export function BatchPage() {
|
|
720
|
+
return (
|
|
721
|
+
<Lesson lesson={lesson} locale="en-US" shouldSyncUrl>
|
|
722
|
+
<p>
|
|
723
|
+
A gradient from <Param name="batch" /> examples is <Value name="noise" /> as noisy as one example.
|
|
724
|
+
</p>
|
|
725
|
+
<BatchScene />
|
|
726
|
+
<ParamSlider name="batch" />
|
|
727
|
+
</Lesson>
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
A state is the whole picture. `showState` (and `show` from `useLesson`) sets every param the state does not name back to
|
|
733
|
+
the lesson's opening value, so a state looks the same live, on the beat sheet and in a tour. `setMany` changes some
|
|
734
|
+
params and keeps the rest.
|
|
735
|
+
|
|
736
|
+
`useLesson(lesson)` types the values from the definition, so `values.noise` is a number and `set('batch', 'high')` does
|
|
737
|
+
not compile. `shouldSyncUrl` keeps the values in the address bar, and `storageKey` keeps them across visits. A `Scene`
|
|
738
|
+
without a `locale` takes the locale of the `Lesson` around it.
|
|
739
|
+
|
|
740
|
+
An `Article` renders the `Lesson` for you and arranges its children as beats. A `Beat` takes the id of a beat the lesson
|
|
741
|
+
declares, so its title, tutor notes, reveal steps and states stay in the definition. `Figure` numbers a figure, gives it
|
|
742
|
+
a caption and a text description, and `Predict` asks the reader to commit a guess before the answer shows:
|
|
743
|
+
|
|
744
|
+
```tsx
|
|
745
|
+
import { Article, Beat, Figure, Predict } from '@mechane-ai/elements/article';
|
|
746
|
+
|
|
747
|
+
export function BatchEssay() {
|
|
748
|
+
return (
|
|
749
|
+
<Article
|
|
750
|
+
lesson={lesson}
|
|
751
|
+
locale="en-US"
|
|
752
|
+
title="Why a bigger batch is quieter"
|
|
753
|
+
summary="The gradient of a batch is an average. See how its noise falls as the batch grows."
|
|
754
|
+
storageKey="batch-noise"
|
|
755
|
+
>
|
|
756
|
+
<Beat id="noise">
|
|
757
|
+
<p>
|
|
758
|
+
With <Param name="batch" /> examples, the gradient is <Value name="noise" /> as noisy as one example.
|
|
759
|
+
</p>
|
|
760
|
+
<Predict
|
|
761
|
+
id="quadruple"
|
|
762
|
+
prompt="Four times the examples: how does the noise change?"
|
|
763
|
+
options={[
|
|
764
|
+
{ id: 'quarter', label: 'It falls to a quarter' },
|
|
765
|
+
{ id: 'half', label: 'It halves' },
|
|
766
|
+
]}
|
|
767
|
+
answer="half"
|
|
768
|
+
>
|
|
769
|
+
<p>Noise falls with the square root of the batch size, so four times the examples halves it.</p>
|
|
770
|
+
</Predict>
|
|
771
|
+
<Figure
|
|
772
|
+
id="batch-scene"
|
|
773
|
+
caption="A batch of examples is averaged into one gradient."
|
|
774
|
+
description="Two boxes joined by an arrow: the batch of examples and the gradient they average into."
|
|
775
|
+
>
|
|
776
|
+
<BatchScene />
|
|
777
|
+
</Figure>
|
|
778
|
+
</Beat>
|
|
779
|
+
</Article>
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
Give `Article` a `view` of `'article'` (the default scrolling essay with a contents list), `'present'` (one beat at a
|
|
785
|
+
time; Right or Space goes on, and a beat opens at its first declared state), `'static'` (every beat open at its first
|
|
786
|
+
state, each figure followed by its description, no script needed) or `'sheet'` (every beat in each declared state, each
|
|
787
|
+
figure scaled to fit, its tutor notes, and a list of checks). The sheet names a beat with no figure, a figure with no
|
|
788
|
+
description, a player with no `Transport` and a sentence control that changes no figure.
|
|
789
|
+
|
|
790
|
+
`recipes/counting-cards.tsx` (story `Recipes/Counting Cards`) is a full example on every layer, and
|
|
791
|
+
`recipes/explorable-essay.tsx` is a short one.
|
|
792
|
+
|
|
793
|
+
### Choose an entry
|
|
794
|
+
|
|
795
|
+
Every part has a question it answers; `explainerGuide` from `/lesson/spec` lists them with when to use each and an
|
|
796
|
+
example. The
|
|
797
|
+
[teaching guide](https://github.com/mechane-ai/mechane/blob/main/workspaces/core/docs/ui-teaching.md#choose-a-part)
|
|
798
|
+
writes the guide out.
|
|
799
|
+
|
|
800
|
+
| Entry | Main exports | The author asks |
|
|
801
|
+
| --------------- | ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------- |
|
|
802
|
+
| `/lesson` | `defineLesson`, `Lesson`, `useLesson`, `Param`, `Value`, `ParamSlider`, `Playback`, `Transport`, `createTween` | Which values can the reader change, and who reads them? |
|
|
803
|
+
| `/scene` | `Scene`, `SceneNode`, `SceneWire`, `SceneAxes`, `SceneCurve`, `SceneCard`, `SceneCells`, `SceneFlow`, `MorphScope` | What is where, and what moves when a value changes? |
|
|
804
|
+
| `/article` | `Article`, `Beat`, `Figure`, `Scrolly`, `Predict`, `Challenge`, `Term`, `DiagramPart`, `Footnote`, `References` | What is the order of the argument, and what does the reader do? |
|
|
805
|
+
| `/mdx` | `Essay`, `essayComponents` | Is the essay mostly prose? |
|
|
806
|
+
| `/lesson/spec` | `validateLessonPlan`, `checkLesson`, `describeLesson`, `lessonWalk`, `explainerGuide` | Is the plan sound before any component exists? |
|
|
807
|
+
| `/lesson/agent` | `tutorTools`, `createLearnerTrace`, `summarizeTrace`, `playTour`, `validateTour`, `tourFromTrace` | What can a tutor read and do beside the reader? |
|
|
808
|
+
|
|
809
|
+
### Write an essay as MDX
|
|
810
|
+
|
|
811
|
+
`/mdx` is for an essay that is mostly prose. `Essay` renders a compiled `.mdx` file inside an `Article`, and
|
|
812
|
+
`essayComponents` lets the file use Markdown and every teaching part with no imports. The application brings its own MDX
|
|
813
|
+
compiler, such as `@mdx-js/rollup`, and a math typesetter if it wants one. Start from the starter:
|
|
814
|
+
|
|
815
|
+
```sh
|
|
816
|
+
pnpm exec mechane-elements-catalog --new-essay my-essay
|
|
817
|
+
cd my-essay
|
|
818
|
+
pnpm install
|
|
819
|
+
pnpm dev
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
The command copies the starter into a new or empty directory, names the package after it and pins `^` this version of
|
|
823
|
+
Elements. It writes `package.json`, `tsconfig.json`, `vite.config.ts`, `index.html`, `plan.json` (the lesson as plain
|
|
824
|
+
data), `AGENTS.md`, `README.md` and a `src` folder with `lesson.ts`, `figures.tsx`, `essay.mdx`, `main.tsx` and
|
|
825
|
+
`mdx.d.ts`. `pnpm dev` serves the essay at `/`, and `?view=present`, `?view=static` and `?view=sheet` show the other
|
|
826
|
+
views of the same file. In `main.tsx`, `<Essay lesson={lesson} content={Content} locale="en-US" {...meta} />` renders
|
|
827
|
+
the file, and `Content` and `meta` come from `import Content, { meta } from './essay.mdx'`.
|
|
828
|
+
|
|
829
|
+
For math, an essay file uses `<TeX>` (the article's math part, exported as `TeX`), and `Article` typesets it through its
|
|
830
|
+
`math` prop. In the file, a sentence reads `At a rate of <Param name="rate" /> the loss is <Value name="loss" />.` and a
|
|
831
|
+
figure is `<Figure id="curve" caption="…" description="…">…</Figure>` inside `<Beat id="…">`. The `view` address
|
|
832
|
+
parameter chooses the view unless `Essay` gets a `view` prop.
|
|
833
|
+
|
|
834
|
+
### Plan and check
|
|
835
|
+
|
|
836
|
+
Draft the lesson as plain JSON before writing components. A `LessonPlan` names the audience, the one idea, the params,
|
|
837
|
+
the derived values and the beats, and each beat may name the figure it shows and what it asks of the reader.
|
|
838
|
+
`validateLessonPlan` returns every finding with a path and a sentence, and `checkLesson` gives teaching advice on a
|
|
839
|
+
defined lesson. An error means `defineLesson` would refuse it. Advice, such as a beat with no goal or a beat that
|
|
840
|
+
introduces two params at once, you may decline:
|
|
841
|
+
|
|
842
|
+
```ts
|
|
843
|
+
import { checkLesson, validateLessonPlan } from '@mechane-ai/elements/lesson/spec';
|
|
844
|
+
|
|
845
|
+
const result = validateLessonPlan(plan);
|
|
846
|
+
|
|
847
|
+
for (const finding of [...result.findings, ...checkLesson(lesson)]) {
|
|
848
|
+
console.log(`${finding.severity} at ${finding.path}: ${finding.message}`);
|
|
849
|
+
}
|
|
850
|
+
```
|
|
851
|
+
|
|
852
|
+
Three skills cover this work: `plan-lesson`, `write-explainer` and `review-explainer`. `--install-skills` installs them
|
|
853
|
+
with the others.
|
|
854
|
+
|
|
855
|
+
### Teach with an agent
|
|
856
|
+
|
|
857
|
+
The lesson appears in the UI SDK agent snapshot as a `lesson` entry named by the lesson's title, with the values, the
|
|
858
|
+
beat, the reveal step and the running player. Its actions are `setParam`, `setParams`, `showState`, `reset`, `setBeat`,
|
|
859
|
+
`next`, `previous`, `play` and `pause`. An `Article` adds a `lesson-progress` entry that an agent can read and cannot
|
|
860
|
+
change. `/lesson/agent` builds on that bridge:
|
|
861
|
+
|
|
862
|
+
- `tutorTools({ agent, lesson, locale, article, answers })` returns tools a model can call: `read_outline`,
|
|
863
|
+
`read_place`, `set_param`, `set_params`, `show_state`, `go_to_beat`, `next`, `previous`, `play`, `pause` and
|
|
864
|
+
`inspect_figure`. Each has a name, a description, an `inputSchema` as JSON Schema and an async `run` that returns a
|
|
865
|
+
plain result.
|
|
866
|
+
- `answerSources(articleOutline(children))` from `/article` maps each `Predict` that takes its answer from a lesson
|
|
867
|
+
value (`answerFrom`) to that value. Pass it as `answers`, and the tools leave the value out until the reader commits.
|
|
868
|
+
- `createLearnerTrace` records what the reader did, and `summarizeTrace` writes it as plain facts for a tutor prompt.
|
|
869
|
+
Changes an agent makes are left out.
|
|
870
|
+
- `playTour` plays a list of steps (`beat`, `step`, `state`, `values`, `say`, `hold`) through the bridge and pauses when
|
|
871
|
+
the reader acts. `validateTour` checks a tour against its lesson, and `tourFromTrace` turns a recorded demonstration
|
|
872
|
+
into one.
|
|
873
|
+
|
|
874
|
+
```ts
|
|
875
|
+
import { createAgent } from '@mechane-ai/elements/agent';
|
|
876
|
+
import { answerSources, articleOutline } from '@mechane-ai/elements/article';
|
|
877
|
+
import type { LessonTour } from '@mechane-ai/elements/lesson/agent';
|
|
878
|
+
import {
|
|
879
|
+
createLearnerTrace,
|
|
880
|
+
playTour,
|
|
881
|
+
summarizeTrace,
|
|
882
|
+
tutorTools,
|
|
883
|
+
validateTour,
|
|
884
|
+
} from '@mechane-ai/elements/lesson/agent';
|
|
885
|
+
|
|
886
|
+
const agent = createAgent();
|
|
887
|
+
const title = 'Why a bigger batch is quieter';
|
|
888
|
+
|
|
889
|
+
// `essay` is the node passed as the children of the `Article`.
|
|
890
|
+
const answers = answerSources(articleOutline(essay));
|
|
891
|
+
const tools = tutorTools({ agent, lesson, locale: 'en-US', article: title, answers });
|
|
892
|
+
const trace = createLearnerTrace({ agent, lesson, article: title });
|
|
893
|
+
|
|
894
|
+
const tour: LessonTour = [
|
|
895
|
+
{ beat: 'noise', state: 'four', say: 'Four examples give a noisy gradient.', hold: 'regular' },
|
|
896
|
+
{ beat: 'noise', values: { batch: 64 }, say: 'Sixty-four examples cut the noise to an eighth.', hold: 'long' },
|
|
897
|
+
];
|
|
898
|
+
|
|
899
|
+
const findings = validateTour(tour, lesson);
|
|
900
|
+
const player = playTour({ agent, lesson, tour, onSay: (line) => console.log(line) });
|
|
901
|
+
const facts = summarizeTrace({ record: trace.read(), lesson, locale: 'en-US', answers });
|
|
902
|
+
```
|
|
903
|
+
|
|
904
|
+
A tutor model calls `tools[0].run()` to read the outline and the others to act. The model never receives a `Predict`
|
|
905
|
+
answer before the reader commits it. The
|
|
906
|
+
[teaching guide](https://github.com/mechane-ai/mechane/blob/main/workspaces/core/docs/ui-teaching.md) has the full
|
|
907
|
+
reference for every entry.
|
|
908
|
+
|
|
353
909
|
## Develop and release
|
|
354
910
|
|
|
355
911
|
From `workspaces/core`:
|