@mechane-ai/elements 0.47.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 +288 -5
- package/bin/mechane-elements-catalog.mjs +104 -12
- package/dist/article-BXZr10QQ.js +1904 -0
- package/dist/article.js +1 -0
- package/dist/catalog.json +1389 -75
- package/dist/{categorical-values-DdfGIowV.js → categorical-values-BpVq8cFj.js} +1 -1
- package/dist/{cells--Bd1fQFR.js → cells-xVmnQ9oQ.js} +1 -1
- package/dist/charts/cartesian.js +1 -1
- package/dist/charts/cells.js +1 -1
- package/dist/charts/comparison.js +1 -1
- package/dist/charts/distribution.js +1 -1
- package/dist/charts/figure.js +12 -12
- package/dist/charts/graph.js +1 -1
- package/dist/charts/hierarchy.js +1 -1
- package/dist/charts/image.js +1 -1
- package/dist/charts/matrix.js +3 -2
- package/dist/charts/plot.js +4 -4
- package/dist/charts/relationship.js +1 -1
- package/dist/charts/text.js +1 -1
- package/dist/charts/timeline.js +1 -1
- package/dist/charts/trend.js +1 -1
- package/dist/charts.js +2 -2
- package/dist/clock-DSm5lkNE.js +16 -0
- package/dist/collections.js +1 -1
- package/dist/describe-lesson-BmREzDpt.js +175 -0
- package/dist/{dumbbell-plot-B2ZTgQaI.js → dumbbell-plot-DQdTxDeO.js} +6 -5
- package/dist/{embedding-map-CGM_k6lC.js → embedding-map-CF-J-8JW.js} +5 -5
- package/dist/{figure-frame-wRkIEAwe.js → figure-frame-BJ3REgTA.js} +1 -1
- package/dist/forms.js +1 -1
- package/dist/{image-grid-CVA4SOy_.js → image-grid-Dl2sjIMB.js} +3 -3
- package/dist/kits/evaluation.js +5 -5
- package/dist/kits/interpretability.js +9 -9
- package/dist/kits/operations.js +4 -4
- package/dist/kits/training.js +4 -4
- package/dist/lesson/agent.js +811 -0
- package/dist/lesson/spec.js +661 -0
- package/dist/lesson.js +5 -0
- package/dist/mdx.js +227 -0
- package/dist/packages/charts/src/matrix/index.d.ts +1 -0
- package/dist/packages/charts/src/plot/plot-marks.d.ts +7 -3
- 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/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/{kits/src/explainers → teaching/src/article}/term.d.ts +8 -2
- 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/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/{plot-layout-BEuoOHbs.js → plot-layout-CZVSJ-le.js} +2 -1
- package/dist/{plot-marks-A64v7aTw.js → plot-marks-uozcbOIX.js} +15 -12
- package/dist/{plot-surface-CJTIqtck.js → plot-surface-CbVBvgqZ.js} +1 -1
- package/dist/{reference-lines-CWA8VeUR.js → reference-lines-BDcttOp0.js} +2 -2
- package/dist/scene-0z2gbaDE.js +4938 -0
- package/dist/scene.js +1 -0
- package/dist/{slope-chart-DT22h_ym.js → slope-chart-BKVEAVCs.js} +5 -5
- package/dist/{src-1EHkSFS-.js → src-BD6xlvDt.js} +2 -2
- package/dist/{src-D5NXRJZe.js → src-Dcfq8vE4.js} +1 -1
- package/dist/styles2.css +475 -18
- package/dist/{time-series-IB3CB93O.js → time-series-BgzGNOk0.js} +12 -10
- package/dist/{token-heatmap-C00DnoNO.js → token-heatmap-BrW1OsKD.js} +2 -2
- package/dist/{token-predictions-Cxx29iDr.js → token-predictions-yerq_Oet.js} +4 -4
- package/dist/transport-BJweqDPj.js +715 -0
- package/dist/{tree-diagram-DsckNKaW.js → tree-diagram-D09BRqE-.js} +4 -4
- package/dist/{treemap-9_DpLCW9.js → treemap-CW4WsJNL.js} +4 -4
- package/dist/use-tween-5HZ55_9d.js +72 -0
- package/dist/{violin-plot-BhPHKXsN.js → violin-plot-DrtPZ1-T.js} +5 -4
- package/dist/{waterfall-CGksuTy5.js → waterfall-DYLSnGjm.js} +4 -4
- package/package.json +26 -5
- package/recipes/counting-cards.tsx +656 -0
- package/recipes/explorable-essay.tsx +172 -0
- package/skills/extend-elements/SKILL.md +21 -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 +4 -2
- package/skills/review-explainer/SKILL.md +97 -0
- package/skills/upgrade-elements/references/releases.md +65 -0
- package/skills/use-elements/SKILL.md +18 -16
- package/skills/use-elements/references/kits.md +2 -20
- 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/kits/explainers.js +0 -452
- package/dist/packages/kits/src/explainers/figures.d.ts +0 -31
- package/dist/packages/kits/src/explainers/index.d.ts +0 -8
- package/dist/packages/kits/src/explainers/story-steps.d.ts +0 -46
- /package/dist/packages/{kits/src/explainers → teaching/src/article}/linked-target.d.ts +0 -0
- /package/dist/packages/{kits/src/explainers → teaching/src/lesson}/bound-value.d.ts +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-explainer
|
|
3
|
+
description:
|
|
4
|
+
Review an explorable essay built with the Elements teaching layers before it ships. Use after writing or changing an
|
|
5
|
+
essay with `@mechane-ai/elements/lesson`, `/scene`, `/article` or `/mdx`, or when asked whether an explainer teaches.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Review an explainer
|
|
9
|
+
|
|
10
|
+
Review as a learner first and as a programmer second. A passing type check says nothing about whether the reader learns.
|
|
11
|
+
Report what you checked, what failed and what you could not check. Run the `review-elements` skill as well for keyboard,
|
|
12
|
+
themes and widths in general.
|
|
13
|
+
|
|
14
|
+
## 1. Open these
|
|
15
|
+
|
|
16
|
+
- The plan (`plan.json`) and the lesson definition (`defineLesson`): the idea, the beats with their goals, the states.
|
|
17
|
+
- The **sheet view** (`?view=sheet` in the essay starter, or `view="sheet"`): every beat at each declared state, and its
|
|
18
|
+
"Checks" list. Read every cell; it is the fastest way to see the whole essay.
|
|
19
|
+
- The **static view** (`?view=static`): read it start to end as a reader with no script would.
|
|
20
|
+
- The essay itself in the browser, at a desktop width and at 360 pixels, with the pointer and with the keyboard alone.
|
|
21
|
+
- From Node, with `@mechane-ai/elements/lesson/spec`: `lessonWalk(lesson, 'en-US')` (the outline as text, each state
|
|
22
|
+
with its derived values written out), `describeLesson(lesson)` and `checkLesson(lesson)`. The `write-explainer`
|
|
23
|
+
skill's tutor reference has the command.
|
|
24
|
+
|
|
25
|
+
## 2. Does it teach
|
|
26
|
+
|
|
27
|
+
In order of what matters most to a learner:
|
|
28
|
+
|
|
29
|
+
1. **One idea.** State the essay's idea in one sentence after reading it. If you cannot, or it differs from the plan's
|
|
30
|
+
`idea`, that is the first finding.
|
|
31
|
+
2. **One goal per beat, and its figure answers it.** For each beat, read its goal, then look at its sheet row. The
|
|
32
|
+
states should differ in the way the goal describes. A figure that looks the same in every state does not show the
|
|
33
|
+
point.
|
|
34
|
+
3. **The reader acts before being told.** A `Predict` comes before the result it asks about, in the first three beats. A
|
|
35
|
+
`Challenge` asks for something the reader can do with the controls they have, and its hints lead there.
|
|
36
|
+
4. **Every control changes something visible,** in the same beat, within the same screen. Move each `Param`, slider and
|
|
37
|
+
point and watch the figure. The sheet's check catches a prose param no figure reads; it does not catch a figure that
|
|
38
|
+
reads a value and barely changes.
|
|
39
|
+
5. **Concrete before abstract.** The first beat shows a specific case. A symbol appears only after the reader has seen
|
|
40
|
+
the thing it stands for.
|
|
41
|
+
6. **Identity is kept.** Step between states and watch: the same object moves, flips or fades, and is never replaced by
|
|
42
|
+
a look-alike. A `Term` for an object lights it in every figure. A thing has one hue in every figure and sentence.
|
|
43
|
+
7. **The static reading teaches.** In the static view each beat still makes its point from its first state, the prose
|
|
44
|
+
and the figure descriptions. Prose that says "watch it move" fails here. The present view opens each beat at that
|
|
45
|
+
same first state, so it must be the right opening picture.
|
|
46
|
+
8. **Reduced motion.** Turn it on. Every change lands at once, a `Playback` jumps to its end, and nothing waits.
|
|
47
|
+
9. **Honest labels.** Synthetic data is called synthetic. Axes and values carry units. A modelled curve or wire is
|
|
48
|
+
dashed. Numbers in prose are `Value`s, not copies.
|
|
49
|
+
10. **Tutor notes.** Every beat has a `goal`; beats that correct a belief have a `misconception`; challenges have
|
|
50
|
+
`hints`. If the essay has a tutor, its `answers` come from `answerSources(articleOutline(beats))`, not a map written
|
|
51
|
+
by hand, so every number `Predict` with an `answerFrom` is in it.
|
|
52
|
+
11. **Narrow width.** At 360 pixels the prose and controls fit, and a scene scrolls inside its own frame rather than the
|
|
53
|
+
page.
|
|
54
|
+
12. **Keyboard.** Every `Param` takes arrow keys; each scene and chart is one Tab stop whose arrow keys reach every
|
|
55
|
+
labelled object; a draggable `ScenePoint` moves with the arrow keys; in the present view Right, Space and Left move.
|
|
56
|
+
|
|
57
|
+
## 3. Read the code once
|
|
58
|
+
|
|
59
|
+
These mean the layers were bypassed. The canonical case is a 7,000-line essay with 29 `useState` hooks in one component,
|
|
60
|
+
19 `requestAnimationFrame` loops, 124 hand-placed SVG elements, 196 inline style objects and its prose kept as string
|
|
61
|
+
arrays.
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
grep -rnE "useState|requestAnimationFrame|setInterval|setTimeout|@keyframes" src
|
|
65
|
+
grep -rnE "<(svg|rect|circle|line|path|text|g)[ >]" src
|
|
66
|
+
grep -rnE "style=\{\{|#[0-9a-fA-F]{3,6}\b|rgb\(" src
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- `useState` holding a value the reader changes, a beat index or a step: it belongs in the lesson, where prose, the
|
|
70
|
+
sheet, the address and agents can see it.
|
|
71
|
+
- A frame loop, a timer or a keyframe animation for meaning: a scene part or `Playback` does it on the shared clock,
|
|
72
|
+
with reduced motion.
|
|
73
|
+
- Hand-placed SVG where a scene part exists: it is not inspectable, not reachable by keyboard and not themed. Only
|
|
74
|
+
`SceneCustom` should hold raw SVG.
|
|
75
|
+
- Inline styles and color literals: tones come from `Article` `tones`, layout from the parts.
|
|
76
|
+
- Prose as string arrays or numbers in strings: prose is markup with `Param` and `Value`.
|
|
77
|
+
- A figure that takes props from its parent, or `Beat`, `Figure` or `Param` inside a custom component: the sheet and the
|
|
78
|
+
outline cannot see them. A nested `Beat`, `Figure`, `Predict` or `Challenge` shows an inline error saying so.
|
|
79
|
+
- A `ScenePoint` with an `onMove` that rounds or clamps by hand and calls `set`, or that writes component state:
|
|
80
|
+
`sets={{ x: 'name' }}` writes the param on its step grid and inside its range.
|
|
81
|
+
- A card `delay` with an index to deal cards in turn: a `SceneStack`'s `stagger` does it, and moves a lone card at once.
|
|
82
|
+
- Conditional mounting (`{isShown && <SceneNode …/>}`) instead of `isShown`: the object pops instead of fading.
|
|
83
|
+
- A changing id for the same object, such as an index in a list that reorders.
|
|
84
|
+
- A `Figure` without `description` or with `reads` missing names its component reads.
|
|
85
|
+
|
|
86
|
+
## 4. Report
|
|
87
|
+
|
|
88
|
+
Lead with the verdict: ready, ready after the listed fixes, or not ready. Then list findings in the order of section 2,
|
|
89
|
+
each with the beat id, what a reader experiences, and the fix in one sentence:
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
Beat "weights": the vote figure looks the same at both states, because the wire weight is clamped to 0.2.
|
|
93
|
+
Fix: pass values.heartWeight as the wire's weight, and set weightMax to 1.
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Give code smells after the teaching findings, with file and line. Say which views, widths and input modes you checked,
|
|
97
|
+
and name what you did not: a real screen reader, a touch device, a print.
|
|
@@ -2,6 +2,71 @@
|
|
|
2
2
|
|
|
3
3
|
Newest first. Each section lists what an application must change, then what it may adopt.
|
|
4
4
|
|
|
5
|
+
## 0.48
|
|
6
|
+
|
|
7
|
+
Elements has a teaching family: lessons, diagrams with identity, explorable essays and tutor tools. It adds six entries
|
|
8
|
+
and removes one. The only breaking change is that the `/kits/explainers` entry is gone. Its exports moved to the new
|
|
9
|
+
entries or were removed, with no aliases: change each import.
|
|
10
|
+
|
|
11
|
+
### Change
|
|
12
|
+
|
|
13
|
+
- **`/kits/explainers` is removed.** Each export has a new home or is gone, as the table shows. An essay is not a kit
|
|
14
|
+
any more. It is an `Article` on a lesson, from `/article`, `/lesson` and `/scene`.
|
|
15
|
+
|
|
16
|
+
| Old import from `/kits/explainers` | New import | What changed |
|
|
17
|
+
| ------------------------------------------------------------- | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
18
|
+
| `BoundValue` | `BoundValue` from `/lesson` | Nothing. Same props and types (`BoundValueProps`, `BoundValueScale`, `BoundValueChangeDetails`). Inside a lesson, `<Param name="…" />` is the bound value of a declared param. |
|
|
19
|
+
| `Explainer` | `Article` from `/article` | The `figures` list is gone: figures are numbered in reading order from each `Figure`. `Article` needs `lesson` (from `defineLesson`), `locale` and `title`, and renders the lesson, tone scope and chart link. |
|
|
20
|
+
| `NumberedFigure` | `Figure` from `/article` | `id`, `caption` and `children` are the same. It adds `description`, `reads` and `size`. It must sit inside an `Article`; outside one it shows an error. |
|
|
21
|
+
| `FigureReference` | `FigureReference` from `/article` | Same `to` prop. The number comes from the article's `Figure`s. |
|
|
22
|
+
| `Term` | `Term` from `/article` | Same `inspects` and `children`. It adds an optional `labels` prop with the hint text. |
|
|
23
|
+
| `DiagramPart` | `DiagramPart` from `/article` | Same `inspects`, `label` and `children`. It adds an optional `labels` prop. |
|
|
24
|
+
| `StorySteps` | `Scrolly` and `ScrollyStep`, or `Reveal` | Removed with its types `StoryStep`, `StoryStepChangeDetails`, `StoryStepsLabels` and `StoryStepsProps`. `ScrollyStep` sets lesson values (`values` or `state`) as the reader scrolls. It has no `inspected` prop. |
|
|
25
|
+
| types `ExplainerProps`, `NumberedFigureProps` | `ArticleProps`, `FigureProps` | Renamed with their components. |
|
|
26
|
+
| types `TermProps`, `DiagramPartProps`, `FigureReferenceProps` | the same names from `/article` | Moved. `TermProps` and `DiagramPartProps` add `labels`. |
|
|
27
|
+
|
|
28
|
+
An essay that kept its numbers in React state moves them into `defineLesson`, and its prose reads them through `Param`
|
|
29
|
+
and `Value`.
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
// Before
|
|
33
|
+
import { Explainer, NumberedFigure, Term } from '@mechane-ai/elements/kits/explainers';
|
|
34
|
+
<Explainer figures={['loss']}>
|
|
35
|
+
<NumberedFigure id="loss" caption="Loss by step.">
|
|
36
|
+
<CurveChart {...props} />
|
|
37
|
+
</NumberedFigure>
|
|
38
|
+
</Explainer>;
|
|
39
|
+
// After
|
|
40
|
+
import { Article, Beat, Figure } from '@mechane-ai/elements/article';
|
|
41
|
+
<Article lesson={lesson} locale="en-US" title="Loss by step">
|
|
42
|
+
<Beat id="training">
|
|
43
|
+
<Figure id="loss" caption="Loss by step." description="A falling line.">
|
|
44
|
+
<CurveChart {...props} />
|
|
45
|
+
</Figure>
|
|
46
|
+
</Beat>
|
|
47
|
+
</Article>;
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- **Chart marks carry their record id.** Marks a figure draws now write `data-chart-mark`, and `DotMark`, `BarMark` and
|
|
51
|
+
`SymbolMark` from `/charts/plot` take a `mark` prop. A stylesheet or a script that matched marks by their other
|
|
52
|
+
attributes can match this one. The attribute is added to `BarChart`, `ScatterPlot`, `DotPlot` and `StripPlot` marks
|
|
53
|
+
and to every chart item the `Chart` primitive renders.
|
|
54
|
+
|
|
55
|
+
### Adopt
|
|
56
|
+
|
|
57
|
+
- **Six entries.** `/lesson` (`defineLesson`, `Lesson`, `Param`, `Value`, `Playback`, `Transport`, tweens), `/scene`
|
|
58
|
+
(`Scene`, nodes, wires, plane marks, cards, cells, tokens, `SceneFlow`, `MorphScope`), `/article` (`Article`, `Beat`,
|
|
59
|
+
`Figure`, `Scrolly`, `Predict`, `Challenge`, notes, `TeX`), `/mdx` (`Essay`, `essayComponents`), `/lesson/spec`
|
|
60
|
+
(`validateLessonPlan`, `checkLesson`, `explainerGuide`) and `/lesson/agent` (`tutorTools`, `createLearnerTrace`,
|
|
61
|
+
`playTour`).
|
|
62
|
+
- **`heatmapColor`** is exported from `/charts/matrix`, so a scene or an application colors a value on a matrix chart's
|
|
63
|
+
scale.
|
|
64
|
+
- **Start an essay.** `pnpm exec mechane-elements-catalog --new-essay <directory>` copies an MDX essay starter into a
|
|
65
|
+
new or empty directory.
|
|
66
|
+
- **A full example.** `recipes/counting-cards.tsx` (story `Recipes/Counting Cards`) is one essay that uses every layer.
|
|
67
|
+
- **Three skills.** `plan-lesson`, `write-explainer` and `review-explainer` ship in the package, and `--install-skills`
|
|
68
|
+
installs them with the others.
|
|
69
|
+
|
|
5
70
|
## 0.47
|
|
6
71
|
|
|
7
72
|
Elements has a data display system. Every chart is built from one plot kernel and takes the same figure props. This
|
|
@@ -50,21 +50,22 @@ persistence and every asynchronous operation.
|
|
|
50
50
|
|
|
51
51
|
## Pick the component
|
|
52
52
|
|
|
53
|
-
| The page needs | Use
|
|
54
|
-
| ------------------------------------------------- |
|
|
55
|
-
| An app frame, a page, sections, a record page | `AppShell`, `PageLayout`, `PageSection`, `RecordPage`
|
|
56
|
-
| Records compared across columns, search, filters | `DataTable` with a `query`
|
|
57
|
-
| A selected record's fields beside its list | `Inspector`, `Details`
|
|
58
|
-
| Fields, choices, dates, files, a save | `Field`, the `/forms` controls, `FormActions`, `ConfirmButton`
|
|
59
|
-
| A trend, comparison, distribution or relationship | One chart from a `/charts/*` entry
|
|
60
|
-
| A figure an agent or a server writes as JSON | `Figure`, `validateFigureSpec`, `describeFigure` and `chartGuide` from `/charts/figure`
|
|
61
|
-
| A run, evaluation, service
|
|
62
|
-
|
|
|
63
|
-
| A
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
53
|
+
| The page needs | Use | Read |
|
|
54
|
+
| ------------------------------------------------- | --------------------------------------------------------------------------------------------- | -------------------------------------------- |
|
|
55
|
+
| An app frame, a page, sections, a record page | `AppShell`, `PageLayout`, `PageSection`, `RecordPage` | [workspace](references/workspace.md) |
|
|
56
|
+
| Records compared across columns, search, filters | `DataTable` with a `query` | [collections](references/collections.md) |
|
|
57
|
+
| A selected record's fields beside its list | `Inspector`, `Details` | [collections](references/collections.md) |
|
|
58
|
+
| Fields, choices, dates, files, a save | `Field`, the `/forms` controls, `FormActions`, `ConfirmButton` | [forms](references/forms.md) |
|
|
59
|
+
| A trend, comparison, distribution or relationship | One chart from a `/charts/*` entry | [charts](references/charts.md) |
|
|
60
|
+
| A figure an agent or a server writes as JSON | `Figure`, `validateFigureSpec`, `describeFigure` and `chartGuide` from `/charts/figure` | [figures](references/figures.md) |
|
|
61
|
+
| A run, evaluation, service or feature | A kit from `/kits/training`, `/kits/evaluation`, `/kits/operations`, `/kits/interpretability` | [kits](references/kits.md) |
|
|
62
|
+
| An explorable essay, a lesson, a moving diagram | `/lesson`, `/scene`, `/article` and `/mdx`, planned with `/lesson/spec` | [teaching](references/teaching.md) |
|
|
63
|
+
| A first read, a refresh, an empty or failed read | `AsyncRegion`, `LoadingScope`, `EmptyState`, `Notice` | [reports](references/reports.md) |
|
|
64
|
+
| A command menu, a decision, an anchored panel | `Menu`, `AlertDialog`, `Dialog`, `Drawer`, `Popover`, `Tooltip` | the catalog |
|
|
65
|
+
| Route destinations or panels inside one view | `PageNavigation` for links, `Tabs` or `ContentTabs` for panels | [workspace](references/workspace.md) |
|
|
66
|
+
| A transcript, a prompt, tool activity, approvals | `Conversation`, `Message`, `PromptInput`, `Approval` | [conversations](references/conversations.md) |
|
|
67
|
+
| Markdown, source, a diff, a file tree, a log | `/content/markdown`, `/content/code`, `/content/diff`, `/content/tree`, `/content` | the catalog |
|
|
68
|
+
| A model or browser agent that reads and acts | `createAgent` and `registerTools` from `/agent` | [agent access](references/agent.md) |
|
|
68
69
|
|
|
69
70
|
## Start from a recipe
|
|
70
71
|
|
|
@@ -90,4 +91,5 @@ a running Elements Storybook, an MCP client can also discover components and exa
|
|
|
90
91
|
## Before you finish
|
|
91
92
|
|
|
92
93
|
Check the page with the `review-elements` skill: keyboard alone, every read state, a phone width, the dark theme, and
|
|
93
|
-
what an agent sees.
|
|
94
|
+
what an agent sees. Check an explorable essay with the `review-explainer` skill too. After a package upgrade, follow the
|
|
95
|
+
`upgrade-elements` skill.
|
|
@@ -14,35 +14,17 @@ interpretability kits:
|
|
|
14
14
|
- computes nothing. The application supplies means, intervals, ranks and deltas, or calls
|
|
15
15
|
`@mechane-ai/elements/charts/transforms` first. A list may sort and filter the rows it is given.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
An explorable essay is not a kit: it uses the teaching layers in [teaching](teaching.md), which replace the old
|
|
18
|
+
explainers kit. The rules for kits are
|
|
18
19
|
[contract 141](https://github.com/mechane-ai/mechane/blob/main/workspaces/core/.contracts/141-ui-domain-kits/CONTRACT.md).
|
|
19
20
|
|
|
20
21
|
| Kit | Entry | Use it for |
|
|
21
22
|
| ---------------- | ------------------------ | -------------------------------------------------------------------------- |
|
|
22
|
-
| Explainers | `/kits/explainers` | A long page whose prose, figures and diagrams point at each other. |
|
|
23
23
|
| Training | `/kits/training` | Watching and comparing training runs. |
|
|
24
24
|
| Operations | `/kits/operations` | The health, budgets and events of a service. |
|
|
25
25
|
| Evaluation | `/kits/evaluation` | Ranking and comparing models on benchmarks. |
|
|
26
26
|
| Interpretability | `/kits/interpretability` | Reading learned features, attribution, attention, logit lens and steering. |
|
|
27
27
|
|
|
28
|
-
## Explainers
|
|
29
|
-
|
|
30
|
-
For a paper-like page. Give every thing one id and every figure one `id` in the explainer's list.
|
|
31
|
-
|
|
32
|
-
- `Explainer` takes `figures`, the ids of every numbered figure in reading order, and the article as `children`.
|
|
33
|
-
- `NumberedFigure` takes `id`, `caption` and a chart or diagram as `children`. It shows "Figure 2".
|
|
34
|
-
- `FigureReference` takes `to`, a figure id, and writes "Figure 2" as a link.
|
|
35
|
-
- `Term` takes `inspects`, an id the figures use, and words. Hovering or focusing it highlights that record in every
|
|
36
|
-
`ChartLink` figure.
|
|
37
|
-
- `DiagramPart` takes `inspects`, a `label` and SVG shapes, so a hand-drawn diagram links to the figures both ways.
|
|
38
|
-
- `BoundValue` is a number in a sentence the reader changes in place. It takes `value` with `onValueChange` or
|
|
39
|
-
`defaultValue`, `min`, `max`, `step`, optional `scale` (`'linear'` or `'log'`), `locale`, `format` and `label`.
|
|
40
|
-
- `StorySteps` walks through `steps` (`id`, `title`, `body`, optional `inspected`) beside the figures it takes as
|
|
41
|
-
`children`. It takes `step` with `onStepChange` or `defaultStep`, a `label` that names the walk, and `labels` for the
|
|
42
|
-
words of its controls. Each step points the linked figures at its `inspected` record.
|
|
43
|
-
|
|
44
|
-
The application supplies the prose, the figures and the ids. Put a `ChartLink` and a `ToneScope` around the article.
|
|
45
|
-
|
|
46
28
|
## Training
|
|
47
29
|
|
|
48
30
|
For runs of one experiment. A run keeps one id and one hue in the dashboard, the table and every chart.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Teaching layers
|
|
2
|
+
|
|
3
|
+
For an explorable explanation: an essay whose reader changes values in the prose, watches diagrams move between states,
|
|
4
|
+
predicts results and reaches challenges. Five entries work together.
|
|
5
|
+
|
|
6
|
+
| Entry | Holds |
|
|
7
|
+
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
8
|
+
| `@mechane-ai/elements/lesson` | `defineLesson`, `Lesson`, `useLesson`, `Param`, `Value`, block controls, `Playback`, `Transport`, `BoundValue` |
|
|
9
|
+
| `@mechane-ai/elements/scene` | `Scene` and its parts: nodes, wires, notes, the plane, cards, cells, tokens, flows, morphs |
|
|
10
|
+
| `@mechane-ai/elements/article` | `Article`, `Beat`, `Figure`, `FigureReference`, `Reveal`, `useRevealed`, `Scrolly`, `Predict`, `Challenge`, `Term`, `DiagramPart`, notes, `TeX`, `articleOutline`, `answerSources` |
|
|
11
|
+
| `@mechane-ai/elements/mdx` | `Essay` and `essayComponents`, for one `.mdx` file as the essay |
|
|
12
|
+
| `@mechane-ai/elements/lesson/spec` | `validateLessonPlan`, `checkLesson`, `describeLesson`, `lessonWalk`, `explainerGuide` |
|
|
13
|
+
| `@mechane-ai/elements/lesson/agent` | `tutorTools`, `createLearnerTrace`, `summarizeTrace`, `playTour`, `validateTour`, `tourFromTrace` |
|
|
14
|
+
|
|
15
|
+
The ideas, in one breath: one lesson store holds every value the reader, the application or an agent may change; a scene
|
|
16
|
+
object with a stable id eases to its new props by itself, so you describe states and never write an animation; an
|
|
17
|
+
article renders the same beats as a scrolling essay, a presentation, a static page and a beat sheet.
|
|
18
|
+
|
|
19
|
+
## When to switch skills
|
|
20
|
+
|
|
21
|
+
- Asked to explain a topic, a paper or a result interactively: follow the `plan-lesson` skill before writing a
|
|
22
|
+
component.
|
|
23
|
+
- Building or changing the essay: follow the `write-explainer` skill. Start a new one with
|
|
24
|
+
`pnpm exec mechane-elements-catalog --new-essay <directory>`.
|
|
25
|
+
- Checking someone's essay: follow the `review-explainer` skill.
|
|
26
|
+
|
|
27
|
+
## Moved from the explainers kit
|
|
28
|
+
|
|
29
|
+
`/kits/explainers` no longer exists. `BoundValue` is in `/lesson`; inside a lesson, `<Param name>` replaces it. `Term`,
|
|
30
|
+
`DiagramPart` and `FigureReference` are in `/article`. `NumberedFigure` is `Figure`, `StorySteps` is `Scrolly` with
|
|
31
|
+
`ScrollyStep`s, and `Explainer` is `Article`, which numbers figures from the markup instead of a `figures` list.
|
|
32
|
+
|
|
33
|
+
## Name clashes
|
|
34
|
+
|
|
35
|
+
- `/article` exports `Figure`, a numbered figure around a chart or scene. `/charts/figure` exports another `Figure`,
|
|
36
|
+
which draws a JSON figure spec. Alias one when a file needs both.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: write-explainer
|
|
3
|
+
description:
|
|
4
|
+
Write an explorable explanation with the Elements teaching layers from a validated lesson plan. Use when building or
|
|
5
|
+
changing an interactive essay, a lesson, a scene diagram or an MDX essay with `@mechane-ai/elements`.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Write an explainer
|
|
9
|
+
|
|
10
|
+
Start from a lesson plan that `validateLessonPlan` accepts. If there is none, follow the `plan-lesson` skill first.
|
|
11
|
+
|
|
12
|
+
The layers do the work a hand-written essay repeats: one lesson store holds every value, one clock moves everything,
|
|
13
|
+
scenes ease between states, and the article arranges the same children as an essay, a presentation, a static page and a
|
|
14
|
+
beat sheet. You describe states. You never write an animation.
|
|
15
|
+
|
|
16
|
+
## Set up
|
|
17
|
+
|
|
18
|
+
For a new essay, scaffold the starter and run it:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
pnpm exec mechane-elements-catalog --new-essay my-essay
|
|
22
|
+
cd my-essay && pnpm install && pnpm dev
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
It holds `plan.json`, `src/lesson.ts` (the lesson), `src/figures.tsx` (the figures), `src/essay.mdx` (the prose) and
|
|
26
|
+
`src/main.tsx`, which renders the essay with a "Lesson checks" list under it. In an existing application, import
|
|
27
|
+
`@mechane-ai/elements/styles.css` once and render an `Article` in TSX, or an `Essay` for an MDX file.
|
|
28
|
+
|
|
29
|
+
## The procedure
|
|
30
|
+
|
|
31
|
+
1. **Define the lesson.** Copy the plan's params and beats into `defineLesson` in its own file, and write each derived
|
|
32
|
+
value's `from` as a pure function. Every component imports this one definition.
|
|
33
|
+
2. **Write one beat at a time,** in plan order. For each beat:
|
|
34
|
+
- prose with `<Param name>` where the reader changes a value and `<Value name>` where they read one;
|
|
35
|
+
- its figure: a component that reads `useLesson(lesson)` and draws a chart or a `Scene`, wrapped in
|
|
36
|
+
`<Figure id caption description reads>`;
|
|
37
|
+
- its ask: `Predict` before the result, or `Challenge` once the reader has the controls;
|
|
38
|
+
- `Playback` with a `Transport` for anything that unfolds in time, and `Term` for words that name a figure's object.
|
|
39
|
+
3. **Look at the beat sheet after every beat.** Open the `sheet` view (`/?view=sheet` in the starter). It draws every
|
|
40
|
+
beat at each declared state, read-only, with a "Checks" list. It is your eyes: if a state looks the same as another,
|
|
41
|
+
the figure does not show the beat's point. Fix every check before the next beat.
|
|
42
|
+
4. **Read the static view** (`/?view=static`). Every beat opens at its first state with each figure's description after
|
|
43
|
+
it. If the essay does not teach there, the prose leans on motion.
|
|
44
|
+
5. **Run the checks.** `checkLesson(lesson)` from `@mechane-ai/elements/lesson/spec` must return no findings you have
|
|
45
|
+
not decided to keep. Then review with the `review-explainer` skill.
|
|
46
|
+
|
|
47
|
+
[The worked essay](references/worked-essay.md) is a complete essay built this way, type checked against the package. The
|
|
48
|
+
package ships a second, larger one as a recipe: `pnpm exec mechane-elements-catalog counting cards` prints its path
|
|
49
|
+
(`recipes/counting-cards.tsx`) and its Storybook story (`Recipes/Counting Cards`). It deals a deck with `SceneStack`
|
|
50
|
+
stagger, reveals with `useRevealed` and morphs cards into bars; its story builds the tutor `answers` with
|
|
51
|
+
`answerSources`.
|
|
52
|
+
|
|
53
|
+
## Choose the part by the reader's question
|
|
54
|
+
|
|
55
|
+
Take the part from `explainerGuide` (in `@mechane-ai/elements/lesson/spec`), whose examples compile. Do not invent one.
|
|
56
|
+
|
|
57
|
+
| The reader asks | Part |
|
|
58
|
+
| ------------------------------------------------------------- | -------------------------------------------- |
|
|
59
|
+
| What happens if I change this number in the sentence? | `Param` |
|
|
60
|
+
| What is the result right now? | `Value` |
|
|
61
|
+
| How does the figure change as I sweep this value? | `ParamSlider`, `ParamChoice`, `ParamToggle` |
|
|
62
|
+
| How does this unfold over time? Can I pause it? | `Playback` with `Transport` |
|
|
63
|
+
| How are these parts connected, and what moves? | `Scene`, `SceneNode`, `SceneWire` |
|
|
64
|
+
| What does this run of things add up to? Why does it matter? | `SceneGroup`, `SceneBracket`, `SceneCallout` |
|
|
65
|
+
| Where should I look now? | `SceneHighlight`, or the scene's `focus` |
|
|
66
|
+
| What is the shape of this function? What if I move the point? | `SceneAxes`, `SceneCurve`, `ScenePoint` |
|
|
67
|
+
| Which way does this push? Where is the threshold? | `SceneVector`, `SceneRule`, `SceneRegion` |
|
|
68
|
+
| What is on the other side, and which comes first? | `SceneCard`, `SceneStack`, `SceneSlot` |
|
|
69
|
+
| What is inside this vector or matrix? | `SceneCells` |
|
|
70
|
+
| How is this text split into tokens? | `SceneTokens`, `SceneToken` |
|
|
71
|
+
| How is this result computed from what I can change? | `LessonFlow`, `SceneFlow` |
|
|
72
|
+
| Is this the same thing, now shown as data? | `MorphScope` |
|
|
73
|
+
| How does the picture change as I read on? | `Scrolly` with `ScrollyStep` |
|
|
74
|
+
| What do I expect before I see it? Can I make it do this? | `Predict`, `Challenge` |
|
|
75
|
+
| Which part of the figure does this word mean? | `Term` |
|
|
76
|
+
| A trend, a distribution, a comparison of measured data | a chart, chosen from `chartGuide` |
|
|
77
|
+
|
|
78
|
+
## Rules, and why
|
|
79
|
+
|
|
80
|
+
- **No `useState` for what the lesson holds.** A value in component state is invisible to the prose, the sheet, the URL,
|
|
81
|
+
storage and agents. Read it with `useLesson(lesson)` and change it with `set`. A draggable `ScenePoint` writes its
|
|
82
|
+
params through `sets`, which keeps them on their step grid and inside their range; do not round in a handler.
|
|
83
|
+
- **No `requestAnimationFrame`, timer or CSS keyframe for motion.** Change a part's props and it eases on the shared
|
|
84
|
+
clock, which also gives reduced motion its end state. Drive time with `Playback`.
|
|
85
|
+
- **No hand-placed SVG where a scene part exists.** Parts are inspectable, keyboard-reachable and themed. Draw what no
|
|
86
|
+
part draws with `SceneCustom`, which hands you the scene's scales and tones.
|
|
87
|
+
- **Stable ids name things, not slots.** The Queen of Hearts is `queen-hearts` in every state and figure, so it moves
|
|
88
|
+
instead of being replaced, and a `Term` lights it everywhere. Swap the id only when the thing itself changes.
|
|
89
|
+
- **Write `Beat`, `Figure`, `Param`, `Playback`, `Transport`, `Predict` and `Challenge` directly in the article's
|
|
90
|
+
children.** The article reads that markup to build the outline, the sheet and its checks. It does not render your own
|
|
91
|
+
components to look inside them. A `Beat`, `Figure`, `Predict` or `Challenge` inside one shows an inline error in the
|
|
92
|
+
page:
|
|
93
|
+
`… sits inside a component of your own, so the outline, the beat sheet and the tutor miss it. Write it directly in the Article's children.`
|
|
94
|
+
Plain elements and fragments are fine.
|
|
95
|
+
- **Give every `Figure` a `description` and its `reads`.** The description is the static view and the screen reader.
|
|
96
|
+
`reads` lists the lesson names your figure component reads, which the markup cannot show.
|
|
97
|
+
- **A figure takes no props from its parent.** The sheet renders each figure alone under a read-only lesson at each
|
|
98
|
+
state, so everything it shows must come from `useLesson`.
|
|
99
|
+
- **Declare tones once** on `Article` with `tones`, by the ids the figures use. Never write a color.
|
|
100
|
+
- **Prose never copies a number.** Write `<Value name="sum" />`, so the sentence agrees with the figure.
|
|
101
|
+
- **Say synthetic data is synthetic,** in the summary or a figure's description.
|
|
102
|
+
- **Ids of figures differ from beat ids.** Beats, figures, footnotes and references all become element ids in the page,
|
|
103
|
+
and the checks name any two parts that share one.
|
|
104
|
+
|
|
105
|
+
## References
|
|
106
|
+
|
|
107
|
+
- [Lesson](references/lesson.md): `defineLesson`, `Lesson`, `useLesson`, prose controls, `Playback` and `Transport`.
|
|
108
|
+
- [Scene](references/scene.md): the box, nodes, wires, notes, the camera, `SceneCustom`.
|
|
109
|
+
- [Scene parts](references/scene-parts.md): the plane, cards, cells, tokens, `SceneFlow`, `MorphScope`.
|
|
110
|
+
- [Article and views](references/article.md): beats, figures, asks, notes, math, the four views and their checks.
|
|
111
|
+
- [MDX](references/mdx.md): one `.mdx` file as the essay.
|
|
112
|
+
- [Tutor](references/tutor.md): tutor tools, the learner trace and tours.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Article and views
|
|
2
|
+
|
|
3
|
+
Import from `@mechane-ai/elements/article`. An `Article` renders a lesson as beats of prose, figures and exercises, and
|
|
4
|
+
arranges the same children four ways. It renders the `Lesson`, a `ChartLink` and a `ToneScope` for you.
|
|
5
|
+
|
|
6
|
+
## `Article`
|
|
7
|
+
|
|
8
|
+
| Prop | What it does |
|
|
9
|
+
| ------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
10
|
+
| `lesson`, `locale`, `title` | Required. |
|
|
11
|
+
| `authors`, `date`, `summary` | The byline, an ISO date, and a sentence or two on what the reader will learn. |
|
|
12
|
+
| `tones` | The tone of each id the figures and terms share, declared once. |
|
|
13
|
+
| `view` | `'article'` (default), `'present'`, `'static'` or `'sheet'`. |
|
|
14
|
+
| `math` | `(tex, { isDisplay }) => ReactNode`, the application's typesetter. |
|
|
15
|
+
| `storageKey` | Keeps the values and the reader's progress across visits. |
|
|
16
|
+
| `progress`, `defaultProgress`, `onProgressChange` | The reader's predictions, challenges, hints and visits, if the application holds them. |
|
|
17
|
+
| `lessonProps` | Passed to the `Lesson`: controlled values, beat and step, `shouldSyncUrl`. |
|
|
18
|
+
| `labels` | The article's own words, with English defaults. |
|
|
19
|
+
|
|
20
|
+
## Markup the article reads
|
|
21
|
+
|
|
22
|
+
The article walks the markup you write to find beats, figures, players and prose params. It does not render your own
|
|
23
|
+
components to look inside them. So:
|
|
24
|
+
|
|
25
|
+
- Write `Beat`, `Figure`, `Param`, `Playback`, `Transport`, `Predict`, `Challenge`, `Footnote` and `References` in the
|
|
26
|
+
article's children or in the MDX file, not inside a component of your own. Plain elements and fragments are fine, so
|
|
27
|
+
the beats can be one exported fragment that `articleOutline` also reads. A `Beat`, `Figure`, `Predict` or `Challenge`
|
|
28
|
+
inside your own component draws an inline error in its place:
|
|
29
|
+
`Figure "vote-scene" sits inside a component of your own, so the outline, the beat sheet and the tutor miss it. Write it directly in the Article's children.`
|
|
30
|
+
- Put each figure's drawing in your component, inside a `Figure`, and list in `reads` every lesson name it reads.
|
|
31
|
+
- Every `<Beat id>` names a beat the lesson declares, and every declared beat is rendered once, in order.
|
|
32
|
+
|
|
33
|
+
## Parts
|
|
34
|
+
|
|
35
|
+
- `Beat`: `id` and children. Its title, tutor notes, reveal steps and states come from the lesson.
|
|
36
|
+
- `Figure`: `id` (unique, and different from every beat id), `caption`, `description` (the figure in words, printed in
|
|
37
|
+
the static view), `reads`, `size` (`'wide'`, the default, reaches into the margin; `'text'` keeps the column).
|
|
38
|
+
- `FigureReference`: `to`, a figure id. Writes "Figure 2" as a link. Never write a figure number by hand.
|
|
39
|
+
- `Reveal`: `at`, a reveal step from 0 up to the beat's declared `steps`. It hides content only in the present view; the
|
|
40
|
+
other views show everything. `useRevealed(at)` gives the same answer to a figure that reveals its own parts: true in
|
|
41
|
+
the article, static and sheet views and outside a beat, and following the beat's step in the present view.
|
|
42
|
+
- `Scrolly`: a sticky `figure` beside `ScrollyStep`s; each step has an `id` and sets `values` or a beat `state` while it
|
|
43
|
+
is in view. Use it when reading on should change the picture; use controls when the reader should drive.
|
|
44
|
+
- `Predict`: `id`, `prompt`, the explanation as children, and either `options` with an `answer` id, or `min`, `max`,
|
|
45
|
+
`step`, `format` with an `answer` or an `answerFrom` (a lesson value read when the reader commits) and `tolerance`.
|
|
46
|
+
The answer stays hidden, from the reader and from agents, until the reader commits.
|
|
47
|
+
- `Challenge`: `id`, `prompt`, `isReached(values)` reading params and derived values by name, `hints`, and the outcome
|
|
48
|
+
as children. Only the reader's own changes reach it; an agent's never do.
|
|
49
|
+
- `Term`: `inspects` (an id the figures use) and words. Pointing at it or focusing it marks that object in every figure.
|
|
50
|
+
- `DiagramPart`: `inspects` and `label` around hand-drawn SVG shapes, linking them to the figures both ways. Prefer a
|
|
51
|
+
scene part.
|
|
52
|
+
- `Aside` (a margin note), `Footnote` (`id`, one sentence), `Cite` (`id` of a reference), and one `References` with
|
|
53
|
+
`items` of `{ id, authors, title, year, venue?, url? }` after the last beat.
|
|
54
|
+
- `TeX`: TeX source as its child string, `isDisplay` for a block. Without a `math` prop on `Article` it shows its
|
|
55
|
+
source.
|
|
56
|
+
|
|
57
|
+
One beat as a fragment (the rest of the lesson's beats would follow it):
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import {
|
|
61
|
+
Article,
|
|
62
|
+
Aside,
|
|
63
|
+
Beat,
|
|
64
|
+
Cite,
|
|
65
|
+
Figure,
|
|
66
|
+
FigureReference,
|
|
67
|
+
Footnote,
|
|
68
|
+
TeX,
|
|
69
|
+
Predict,
|
|
70
|
+
References,
|
|
71
|
+
} from '@mechane-ai/elements/article';
|
|
72
|
+
import type { ArticleMath, ArticleView } from '@mechane-ai/elements/article';
|
|
73
|
+
import { Value } from '@mechane-ai/elements/lesson';
|
|
74
|
+
import type { ReactNode } from 'react';
|
|
75
|
+
import { ConfidenceScene } from './figures.tsx';
|
|
76
|
+
import { lesson } from './lesson.ts';
|
|
77
|
+
|
|
78
|
+
export function BiasArticle({ view, math }: { readonly view: ArticleView; readonly math: ArticleMath }): ReactNode {
|
|
79
|
+
return (
|
|
80
|
+
<Article
|
|
81
|
+
lesson={lesson}
|
|
82
|
+
locale="en-US"
|
|
83
|
+
title="A neuron is a weighted vote"
|
|
84
|
+
authors={['A. Researcher']}
|
|
85
|
+
date="2026-11-24"
|
|
86
|
+
view={view}
|
|
87
|
+
math={math}
|
|
88
|
+
lessonProps={{ shouldSyncUrl: true }}
|
|
89
|
+
>
|
|
90
|
+
<Beat id="bias">
|
|
91
|
+
<p>
|
|
92
|
+
The neuron turns its sum into a chance with the sigmoid, <TeX>{String.raw`\sigma(s) = 1 / (1 + e^{-s})`}</TeX>
|
|
93
|
+
<Cite id="rosenblatt1958" />. At the current sum it says yes with a chance of <Value name="yes" /> (
|
|
94
|
+
<FigureReference to="confidence" />
|
|
95
|
+
).
|
|
96
|
+
<Footnote id="sigmoid">A perceptron used a hard step instead; the sigmoid is its smooth version.</Footnote>
|
|
97
|
+
</p>
|
|
98
|
+
<Predict
|
|
99
|
+
id="zero-sum"
|
|
100
|
+
prompt="At a weighted sum of exactly zero, how sure is the neuron?"
|
|
101
|
+
min={0}
|
|
102
|
+
max={1}
|
|
103
|
+
step={0.05}
|
|
104
|
+
format={{ style: 'percent', maximumFractionDigits: 0 }}
|
|
105
|
+
answer={0.5}
|
|
106
|
+
tolerance={0.05}
|
|
107
|
+
>
|
|
108
|
+
<p>The sigmoid of zero is one half: no evidence either way.</p>
|
|
109
|
+
</Predict>
|
|
110
|
+
<Figure
|
|
111
|
+
id="confidence"
|
|
112
|
+
caption="The sigmoid turns the sum into a chance."
|
|
113
|
+
description="An S-shaped curve of the chance of yes against the bias, with a point at the current bias."
|
|
114
|
+
reads={['sum', 'yes', 'bias']}
|
|
115
|
+
size="text"
|
|
116
|
+
>
|
|
117
|
+
<ConfidenceScene />
|
|
118
|
+
</Figure>
|
|
119
|
+
<Aside>Real networks use many activation functions; the sigmoid is the oldest.</Aside>
|
|
120
|
+
</Beat>
|
|
121
|
+
<References
|
|
122
|
+
items={[
|
|
123
|
+
{
|
|
124
|
+
id: 'rosenblatt1958',
|
|
125
|
+
authors: ['Frank Rosenblatt'],
|
|
126
|
+
title: 'The perceptron: a probabilistic model for information storage and organization in the brain',
|
|
127
|
+
year: 1958,
|
|
128
|
+
venue: 'Psychological Review',
|
|
129
|
+
},
|
|
130
|
+
]}
|
|
131
|
+
/>
|
|
132
|
+
</Article>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## The four views
|
|
138
|
+
|
|
139
|
+
The same children, arranged four ways. In the essay starter, `?view=present`, `?view=static` and `?view=sheet` choose
|
|
140
|
+
one.
|
|
141
|
+
|
|
142
|
+
| View | What it is |
|
|
143
|
+
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
144
|
+
| `article` | The scrolling essay, with a contents list that follows the reading position and sets the lesson's beat. |
|
|
145
|
+
| `present` | One beat at a time, opened at its first declared state each time the presenter reaches it. Right or Space runs `next` (the next reveal step, then the next beat); Left goes back. A `Scrolly` shows its figure beside its steps, which are walked before the reveal steps. |
|
|
146
|
+
| `static` | Every beat open at its first state, every reveal shown, each figure followed by its description, no motion. |
|
|
147
|
+
| `sheet` | Every beat at each of its states, read-only and scaled to fit its cell, with its tutor notes, then "Checks". |
|
|
148
|
+
|
|
149
|
+
The sheet's checks, and what each means:
|
|
150
|
+
|
|
151
|
+
| Check | Fix |
|
|
152
|
+
| ------------------------------------------------------ | ---------------------------------------------------- |
|
|
153
|
+
| The lesson declares a beat the article does not render | Add the `<Beat>`, or remove the beat from the lesson |
|
|
154
|
+
| The article renders a beat the lesson does not declare | Declare it, or fix the id |
|
|
155
|
+
| A beat has no figure | Give it one, or fold it into the beat before |
|
|
156
|
+
| A figure has no description | Write the figure in words |
|
|
157
|
+
| Two parts share an element id | Rename one (beats, figures, footnotes, references) |
|
|
158
|
+
| A `Predict` or `Challenge` sits outside every `Beat` | Move it into the beat it belongs to |
|
|
159
|
+
| A `Playback` has no `Transport` | Add `<Transport for>` the reader can reach |
|
|
160
|
+
| A `Param` in the prose changes no figure of its beat | Name it in a figure's `reads`, or move the control |
|
|
161
|
+
|
|
162
|
+
`articleChecks(lesson, articleOutline(children))` returns the same list as data, for a test page or an agent. The
|
|
163
|
+
outline also lists the essay's `predictions` and `challenges`; `answerSources(outline)` turns its predictions into the
|
|
164
|
+
`answers` a tutor needs (see the [tutor reference](tutor.md)).
|