@tjakoen/grain 0.1.12
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/LICENSE +202 -0
- package/PLAN.md +27 -0
- package/README.md +243 -0
- package/ai/accepts.test.ts +69 -0
- package/ai/accepts.ts +57 -0
- package/ai/ai.css +127 -0
- package/ai/client-door.test.ts +70 -0
- package/ai/client-door.ts +56 -0
- package/ai/contract.test.ts +158 -0
- package/ai/contract.ts +285 -0
- package/ai/interaction-layer.test.ts +270 -0
- package/ai/interaction-layer.ts +138 -0
- package/ai/manifest-dom.test.ts +176 -0
- package/ai/manifest-dom.ts +187 -0
- package/ai/manifest.test.ts +71 -0
- package/ai/manifest.ts +57 -0
- package/ai/markdown.test.ts +68 -0
- package/ai/markdown.ts +74 -0
- package/ai/model-chat.test.ts +131 -0
- package/ai/model-chat.ts +151 -0
- package/ai/model-reasoner.test.ts +152 -0
- package/ai/model-reasoner.ts +146 -0
- package/ai/model.test.ts +148 -0
- package/ai/model.ts +200 -0
- package/ai/reasoner-kit.test.ts +142 -0
- package/ai/reasoner-kit.ts +159 -0
- package/ai/reasoner.test.ts +227 -0
- package/ai/reasoner.ts +446 -0
- package/ai/timeline-log.test.ts +55 -0
- package/ai/timeline-log.ts +50 -0
- package/ai/vocab-reference.test.ts +43 -0
- package/ai/vocab-reference.ts +107 -0
- package/ai/webllm.test.ts +79 -0
- package/ai/webllm.ts +125 -0
- package/assets/figure-sample.svg +14 -0
- package/assets/sprite.svg +22 -0
- package/catalog/catalog.test.ts +37 -0
- package/catalog/catalog.ts +424 -0
- package/components/atoms/action-badge/action-badge.css +17 -0
- package/components/atoms/action-badge/action-badge.html +6 -0
- package/components/atoms/action-badge/action-badge.md +23 -0
- package/components/atoms/b-badge/b-badge.css +15 -0
- package/components/atoms/b-badge/b-badge.html +2 -0
- package/components/atoms/b-badge/b-badge.md +16 -0
- package/components/atoms/b-button/b-button.ai.md +22 -0
- package/components/atoms/b-button/b-button.css +87 -0
- package/components/atoms/b-button/b-button.html +5 -0
- package/components/atoms/b-button/b-button.md +77 -0
- package/components/atoms/b-icon/b-icon.css +10 -0
- package/components/atoms/b-icon/b-icon.html +5 -0
- package/components/atoms/b-icon/b-icon.md +36 -0
- package/components/atoms/b-icon-button/b-icon-button.ai.md +11 -0
- package/components/atoms/b-icon-button/b-icon-button.css +43 -0
- package/components/atoms/b-icon-button/b-icon-button.html +8 -0
- package/components/atoms/b-icon-button/b-icon-button.md +33 -0
- package/components/atoms/b-input/b-input.css +36 -0
- package/components/atoms/b-input/b-input.html +8 -0
- package/components/atoms/b-input/b-input.md +59 -0
- package/components/atoms/b-kbd/b-kbd.css +11 -0
- package/components/atoms/b-kbd/b-kbd.html +3 -0
- package/components/atoms/b-kbd/b-kbd.md +13 -0
- package/components/atoms/b-list/b-list.css +21 -0
- package/components/atoms/b-list/b-list.html +6 -0
- package/components/atoms/b-list/b-list.md +24 -0
- package/components/atoms/b-meter/b-meter.css +39 -0
- package/components/atoms/b-meter/b-meter.md +44 -0
- package/components/atoms/b-select/b-select.css +35 -0
- package/components/atoms/b-select/b-select.md +75 -0
- package/components/atoms/b-switch/b-switch.css +61 -0
- package/components/atoms/b-switch/b-switch.html +6 -0
- package/components/atoms/b-switch/b-switch.md +40 -0
- package/components/atoms/b-text/b-text.ai.md +29 -0
- package/components/atoms/b-text/b-text.css +2 -0
- package/components/atoms/b-text/b-text.html +3 -0
- package/components/atoms/b-text/b-text.md +23 -0
- package/components/atoms/code-block/code-block.css +42 -0
- package/components/atoms/code-block/code-block.md +23 -0
- package/components/examples.test.ts +23 -0
- package/components/molecules/callout/callout.css +19 -0
- package/components/molecules/callout/callout.md +15 -0
- package/components/molecules/card/card.css +28 -0
- package/components/molecules/card/card.md +30 -0
- package/components/molecules/chat-message/chat-message.css +83 -0
- package/components/molecules/chat-message/chat-message.md +52 -0
- package/components/molecules/chip-group/chip-group.css +35 -0
- package/components/molecules/chip-group/chip-group.md +42 -0
- package/components/molecules/content-index/content-index.css +87 -0
- package/components/molecules/content-index/content-index.md +27 -0
- package/components/molecules/content-source/content-source.css +6 -0
- package/components/molecules/content-source/content-source.md +13 -0
- package/components/molecules/figure/figure.css +19 -0
- package/components/molecules/figure/figure.md +20 -0
- package/components/molecules/lede/lede.css +17 -0
- package/components/molecules/lede/lede.md +17 -0
- package/components/molecules/made-with/made-with.css +25 -0
- package/components/molecules/made-with/made-with.md +35 -0
- package/components/molecules/nav-item/nav-item.css +19 -0
- package/components/molecules/nav-item/nav-item.md +21 -0
- package/components/molecules/stat-tile/stat-tile.css +34 -0
- package/components/molecules/stat-tile/stat-tile.md +50 -0
- package/components/molecules/status-list/status-list.css +47 -0
- package/components/molecules/status-list/status-list.md +62 -0
- package/components/molecules/tab/tab.css +32 -0
- package/components/molecules/tab/tab.md +27 -0
- package/components/molecules/table/table.css +23 -0
- package/components/molecules/table/table.md +18 -0
- package/components/organisms/activity-bar/activity-bar.css +36 -0
- package/components/organisms/activity-bar/activity-bar.md +43 -0
- package/components/organisms/app-shell/app-shell.css +193 -0
- package/components/organisms/app-shell/app-shell.md +58 -0
- package/components/organisms/app-shell/app-shell.test.ts +74 -0
- package/components/organisms/app-window/app-window.css +111 -0
- package/components/organisms/app-window/app-window.md +53 -0
- package/components/organisms/chat-log/chat-log.css +5 -0
- package/components/organisms/chat-log/chat-log.md +14 -0
- package/components/organisms/code-editor/code-editor.ai.md +31 -0
- package/components/organisms/code-editor/code-editor.css +111 -0
- package/components/organisms/code-editor/code-editor.md +122 -0
- package/components/organisms/console/console.css +112 -0
- package/components/organisms/console/console.md +66 -0
- package/components/organisms/file-tree/file-tree.css +85 -0
- package/components/organisms/file-tree/file-tree.md +49 -0
- package/components/organisms/note/note.css +19 -0
- package/components/organisms/note/note.md +20 -0
- package/components/organisms/notepad/notepad.css +60 -0
- package/components/organisms/notepad/notepad.md +40 -0
- package/components/organisms/side-rail/side-rail.css +55 -0
- package/components/organisms/side-rail/side-rail.md +24 -0
- package/components/organisms/sidebar-panel/sidebar-panel.css +69 -0
- package/components/organisms/sidebar-panel/sidebar-panel.md +47 -0
- package/components/organisms/status-bar/status-bar.css +33 -0
- package/components/organisms/status-bar/status-bar.md +28 -0
- package/components/organisms/tab-bar/tab-bar.css +48 -0
- package/components/organisms/tab-bar/tab-bar.md +26 -0
- package/components/organisms/timeline/timeline.css +51 -0
- package/components/organisms/timeline/timeline.md +42 -0
- package/components/organisms/topbar/topbar.css +8 -0
- package/components/organisms/topbar/topbar.md +26 -0
- package/components/responsive-polish.test.ts +43 -0
- package/components/tokens.test.ts +39 -0
- package/fonts/redaction-35-400.woff2 +0 -0
- package/fonts/redaction-400.woff2 +0 -0
- package/fonts/redaction-50-400.woff2 +0 -0
- package/fonts/redaction-70-400.woff2 +0 -0
- package/package.json +46 -0
- package/scripts/ai-dispatch.js +583 -0
- package/scripts/ai-dispatch.test.ts +85 -0
- package/scripts/ai-spotlight.d.ts +23 -0
- package/scripts/ai-spotlight.js +139 -0
- package/scripts/ai-spotlight.test.ts +31 -0
- package/scripts/catalog-peek.js +156 -0
- package/scripts/catalog-peek.test.ts +31 -0
- package/scripts/cmdk.js +159 -0
- package/scripts/demo-box.js +53 -0
- package/scripts/handoff.js +64 -0
- package/scripts/handoff.test.ts +36 -0
- package/scripts/lightbox.js +144 -0
- package/scripts/lightbox.test.ts +23 -0
- package/scripts/made-with.d.ts +2 -0
- package/scripts/made-with.js +22 -0
- package/scripts/made-with.test.ts +25 -0
- package/scripts/notepad.js +100 -0
- package/scripts/shell.js +204 -0
- package/scripts/shell.test.ts +50 -0
- package/scripts/tabs.js +127 -0
- package/scripts/tabs.test.ts +40 -0
- package/scripts/terminal.js +271 -0
- package/scripts/terminal.test.ts +36 -0
- package/scripts/theme-boot.js +15 -0
- package/scripts/theme.js +87 -0
- package/scripts/type-effect.js +25 -0
- package/scripts/xray.js +79 -0
- package/scripts/xray.test.ts +43 -0
- package/styles/cmdk.css +65 -0
- package/styles/global.css +80 -0
- package/styles/grain.css +47 -0
- package/styles/lightbox.css +78 -0
- package/styles/themes/_template.css +48 -0
- package/styles/themes/baguette.css +30 -0
- package/styles/themes/brioche.css +30 -0
- package/styles/variables.css +217 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* atoms/b-switch — a labelled on/off toggle, built on a real <input type="checkbox">
|
|
2
|
+
so it keeps native focus, keyboard (Space), and form semantics. The checkbox is
|
|
3
|
+
visually hidden (not display:none — it stays focusable and hit-testable); the
|
|
4
|
+
track + thumb are the drawn control, driven by :checked / :focus-visible on the
|
|
5
|
+
sibling input. Monochrome by default; ON reaches the accent hue (the one place a
|
|
6
|
+
toggle earns color, matching nav-item[aria-current] / tabs). Use where an action
|
|
7
|
+
is a STATE the user sets (delivered / held, locked / open), not a one-shot verb -
|
|
8
|
+
a button that reads "PUBLISHING" and un-publishes on click is the anti-pattern
|
|
9
|
+
this replaces. */
|
|
10
|
+
|
|
11
|
+
.switch {
|
|
12
|
+
display: inline-flex; align-items: center; gap: var(--space-2);
|
|
13
|
+
cursor: pointer; font-family: var(--type-font); font-size: var(--text-xs);
|
|
14
|
+
line-height: var(--leading-normal); color: var(--ink);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* the real control: visually hidden, still focusable + operable */
|
|
18
|
+
.switch__input {
|
|
19
|
+
position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
|
|
20
|
+
border: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.switch__track {
|
|
24
|
+
--sw-h: 1.25rem; --sw-w: 2.25rem;
|
|
25
|
+
position: relative; flex: none;
|
|
26
|
+
inline-size: var(--sw-w); block-size: var(--sw-h);
|
|
27
|
+
border: var(--border); border-radius: 999px;
|
|
28
|
+
background: var(--paper-2);
|
|
29
|
+
transition: background-color 0.15s, border-color 0.15s;
|
|
30
|
+
}
|
|
31
|
+
.switch__thumb {
|
|
32
|
+
position: absolute; top: 50%; inset-inline-start: 0.125rem;
|
|
33
|
+
inline-size: calc(var(--sw-h) - 0.5rem); block-size: calc(var(--sw-h) - 0.5rem);
|
|
34
|
+
transform: translateY(-50%); border-radius: 50%;
|
|
35
|
+
background: var(--ink);
|
|
36
|
+
transition: inset-inline-start 0.15s, background-color 0.15s;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* ON: accent wash track + accent thumb slid to the end */
|
|
40
|
+
.switch__input:checked ~ .switch__track { background: var(--color-accent-soft); border-color: var(--color-accent); }
|
|
41
|
+
.switch__input:checked ~ .switch__track .switch__thumb { inset-inline-start: calc(100% - var(--sw-h) + 0.375rem); background: var(--color-accent); }
|
|
42
|
+
|
|
43
|
+
/* keyboard focus lands on the hidden input; show the ring on the drawn track */
|
|
44
|
+
.switch__input:focus-visible ~ .switch__track { outline: 2px solid var(--color-accent); outline-offset: 2px; }
|
|
45
|
+
|
|
46
|
+
.switch__input:disabled ~ .switch__track { opacity: 0.5; }
|
|
47
|
+
.switch:has(.switch__input:disabled) { cursor: not-allowed; }
|
|
48
|
+
|
|
49
|
+
.switch__label { color: inherit; }
|
|
50
|
+
.switch__label--off { color: var(--ink-muted); }
|
|
51
|
+
|
|
52
|
+
@media (prefers-reduced-motion: reduce) {
|
|
53
|
+
.switch__track, .switch__thumb { transition: none; }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* AI / in-transit: same grade-as-signal edge the button uses - a dashed track +
|
|
57
|
+
locked out while the writer works (AI-INTERFACE §5). */
|
|
58
|
+
.switch__input[data-commit="pending"] ~ .switch__track,
|
|
59
|
+
[data-grade="grain"] .switch__track {
|
|
60
|
+
border-style: dashed; pointer-events: none;
|
|
61
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<!-- atoms/b-switch — a real checkbox drawn as a track+thumb; ON reaches the accent hue -->
|
|
2
|
+
<label class="switch">
|
|
3
|
+
<input type="checkbox" class="switch__input" checked>
|
|
4
|
+
<span class="switch__track"><span class="switch__thumb"></span></span>
|
|
5
|
+
<span class="switch__label">Delivered</span>
|
|
6
|
+
</label>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Switch
|
|
2
|
+
|
|
3
|
+
A labelled on/off toggle built on a real `<input type="checkbox">`, so it keeps
|
|
4
|
+
native focus, Space to toggle, and form semantics. The checkbox is visually
|
|
5
|
+
hidden but still focusable; the track and thumb are the drawn control. Use it
|
|
6
|
+
where an action is a **state the user sets** (delivered / held, locked / open),
|
|
7
|
+
not a one-shot verb - a button reading "PUBLISHING" that un-publishes on click
|
|
8
|
+
is the anti-pattern this replaces.
|
|
9
|
+
|
|
10
|
+
Monochrome by default; ON reaches the accent hue (the one place a toggle earns
|
|
11
|
+
color, matching `nav-item[aria-current]` and tabs).
|
|
12
|
+
|
|
13
|
+
## States
|
|
14
|
+
|
|
15
|
+
### Off
|
|
16
|
+
```html
|
|
17
|
+
<label class="switch">
|
|
18
|
+
<input type="checkbox" class="switch__input">
|
|
19
|
+
<span class="switch__track"><span class="switch__thumb"></span></span>
|
|
20
|
+
<span class="switch__label switch__label--off">Not delivered</span>
|
|
21
|
+
</label>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### On
|
|
25
|
+
```html
|
|
26
|
+
<label class="switch">
|
|
27
|
+
<input type="checkbox" class="switch__input" checked>
|
|
28
|
+
<span class="switch__track"><span class="switch__thumb"></span></span>
|
|
29
|
+
<span class="switch__label">Delivered</span>
|
|
30
|
+
</label>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Disabled
|
|
34
|
+
```html
|
|
35
|
+
<label class="switch">
|
|
36
|
+
<input type="checkbox" class="switch__input" checked disabled>
|
|
37
|
+
<span class="switch__track"><span class="switch__thumb"></span></span>
|
|
38
|
+
<span class="switch__label">Delivered</span>
|
|
39
|
+
</label>
|
|
40
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Typography
|
|
2
|
+
|
|
3
|
+
Machine-made text reads in the **grain** grade (Redaction 50) — the texture says
|
|
4
|
+
"machine-made". The grain is built into the font (a family swap), not faked. Streaming
|
|
5
|
+
AI output types in at grain with a caret; when it finishes the caret goes but the text
|
|
6
|
+
**stays grain** — grain = AI, so provenance persists (it doesn't masquerade as human).
|
|
7
|
+
|
|
8
|
+
## Grain — AI / in-transit
|
|
9
|
+
|
|
10
|
+
### Body
|
|
11
|
+
```html
|
|
12
|
+
<p class="t">On it — checking your week. You have room on Thursday.</p>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Streaming (caret)
|
|
16
|
+
```html
|
|
17
|
+
<p class="t"><span>Noted: deep-work moved to Thursday</span><span class="caret"></span></p>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Accent — display only
|
|
21
|
+
```html
|
|
22
|
+
<p class="t" data-grade="accent">Sourdough</p>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
> **Provenance is set by an ancestor, never stamped on the text.** Clean is the
|
|
26
|
+
> default (set nothing); grain comes from a state class on a container — `.is-ai` or
|
|
27
|
+
> `data-commit="pending"` — which the whole subtree inherits. To compare human vs. AI
|
|
28
|
+
> here, just flip the **Human / AI** toggle above: the same component re-grades. You
|
|
29
|
+
> never hand-write `data-grade` on a `<p>` in real markup.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Typography
|
|
2
|
+
|
|
3
|
+
One polymorphic type atom — `<b-text as="…">` renders text in any element. Every type
|
|
4
|
+
primitive reads the inherited `--type-font` switch and knows nothing about grades, so a
|
|
5
|
+
single ancestor state flips a whole subtree between **clean** (human / committed) and
|
|
6
|
+
**grain** (AI / in-transit). Toggle to **AI** above to see this component in grain.
|
|
7
|
+
|
|
8
|
+
## Clean — human / committed
|
|
9
|
+
|
|
10
|
+
### Body
|
|
11
|
+
```html
|
|
12
|
+
<p class="t">The AI records what you decided, in your own clean hand.</p>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Display heading
|
|
16
|
+
```html
|
|
17
|
+
<h1 class="t masthead">An AI that writes back.</h1>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Section heading
|
|
21
|
+
```html
|
|
22
|
+
<h2 class="t">Overview</h2>
|
|
23
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* atoms/code-block — a monospace code block (and a .code-inline run) for content prose.
|
|
2
|
+
CSS-only (CONVENTIONS §4): MILL hand-composes <pre class="code-block">, nothing data-binds
|
|
3
|
+
it, so there's no .html template. Reads --font-mono, so code stays mono in either grade. */
|
|
4
|
+
.code-block {
|
|
5
|
+
margin: 0 0 var(--space-4);
|
|
6
|
+
padding: var(--space-4);
|
|
7
|
+
overflow-x: auto; /* long lines scroll, never break the column */
|
|
8
|
+
background: var(--color-surface);
|
|
9
|
+
border: 1px solid var(--color-line);
|
|
10
|
+
border-radius: var(--radius-md);
|
|
11
|
+
font-family: var(--font-mono);
|
|
12
|
+
font-size: var(--text-sm);
|
|
13
|
+
line-height: var(--leading-normal);
|
|
14
|
+
color: var(--color-fg);
|
|
15
|
+
}
|
|
16
|
+
.code-block code { font-family: inherit; }
|
|
17
|
+
|
|
18
|
+
/* optional language tag: `data-lang` renders a quiet eyebrow above the block */
|
|
19
|
+
.code-block[data-lang]::before {
|
|
20
|
+
content: attr(data-lang);
|
|
21
|
+
display: block;
|
|
22
|
+
margin-bottom: var(--space-2);
|
|
23
|
+
font-size: var(--text-xs);
|
|
24
|
+
text-transform: uppercase;
|
|
25
|
+
letter-spacing: 0.06em;
|
|
26
|
+
color: var(--color-muted);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* inline code — a quiet mono run inside prose */
|
|
30
|
+
.code-inline {
|
|
31
|
+
font-family: var(--font-mono);
|
|
32
|
+
font-size: 0.9em;
|
|
33
|
+
padding: 0 var(--space-1);
|
|
34
|
+
background: var(--color-surface);
|
|
35
|
+
border-radius: var(--radius-sm);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* ---- AI / in-transit: same vocabulary as the atoms (CONVENTIONS §4). A code block the AI
|
|
39
|
+
is writing wears the dashed "terminal" edge (non-text grain). MILL output is human-authored,
|
|
40
|
+
so it never triggers this; the catalog grain-flip demonstrates it. */
|
|
41
|
+
.code-block[data-commit="pending"],
|
|
42
|
+
[data-grade="grain"] .code-block { border-style: dashed; border-color: var(--ink); }
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Code block
|
|
2
|
+
|
|
3
|
+
A monospace block for fenced code — plus a `.code-inline` run for inline code. It reads the
|
|
4
|
+
`--font-mono` token, so code stays mono in **either** grade; the AI signal here is the dashed
|
|
5
|
+
edge (non-text grain), not a font swap. CSS-only: composed by hand (by MILL), nothing data-binds
|
|
6
|
+
it, so there is no template. Long lines scroll rather than break the column.
|
|
7
|
+
|
|
8
|
+
## Block
|
|
9
|
+
|
|
10
|
+
### Plain
|
|
11
|
+
```html
|
|
12
|
+
<pre class="code-block"><code>bun run dev</code></pre>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### With a language tag
|
|
16
|
+
```html
|
|
17
|
+
<pre class="code-block" data-lang="ts"><code>export const answer = 42;</code></pre>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Inline
|
|
21
|
+
```html
|
|
22
|
+
<p>Run <code class="code-inline">bun run check</code> before you call it done.</p>
|
|
23
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// grain/components/examples.test.ts — a guardrail on component catalog examples.
|
|
2
|
+
//
|
|
3
|
+
// The catalog renders EVERY component's `.md` examples on one page, so an example that grabs focus
|
|
4
|
+
// or otherwise acts on load misbehaves for the whole catalog. `autofocus` is the known footgun: it
|
|
5
|
+
// stole focus and scroll-jumped /catalog on every load (and hung the e2e). This test keeps that
|
|
6
|
+
// class of mistake out of the examples — a cheap conformance check, colocated with the components.
|
|
7
|
+
import { test, expect } from "bun:test";
|
|
8
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
|
|
11
|
+
function mdFiles(dir: string, out: string[] = []): string[] {
|
|
12
|
+
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
13
|
+
const full = join(dir, e.name);
|
|
14
|
+
if (e.isDirectory()) mdFiles(full, out);
|
|
15
|
+
else if (e.name.endsWith(".md")) out.push(full);
|
|
16
|
+
}
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
test("no component example uses autofocus (it scroll-jumps /catalog on load)", () => {
|
|
21
|
+
const offenders = mdFiles(import.meta.dir).filter((f) => /\bautofocus\b/.test(readFileSync(f, "utf8")));
|
|
22
|
+
expect(offenders).toEqual([]);
|
|
23
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* molecules/callout — a blockquote / margin-note aside for content prose. A quiet ruled
|
|
2
|
+
block, not a coloured box (monochrome, DESIGN-SYSTEM §2). CSS-only (CONVENTIONS §4): MILL
|
|
3
|
+
maps Markdown blockquotes to <blockquote class="callout">; nothing data-binds it. */
|
|
4
|
+
.callout {
|
|
5
|
+
margin: 0 0 var(--space-4);
|
|
6
|
+
padding: var(--space-2) 0 var(--space-2) var(--space-4);
|
|
7
|
+
border-left: 2px solid var(--ink);
|
|
8
|
+
color: var(--color-muted);
|
|
9
|
+
font-style: italic;
|
|
10
|
+
}
|
|
11
|
+
.callout > :last-child { margin-bottom: 0; }
|
|
12
|
+
|
|
13
|
+
/* tone via attribute (not a second class): a stronger note keeps full ink, upright */
|
|
14
|
+
.callout[data-status="strong"] { color: var(--color-fg); font-style: normal; }
|
|
15
|
+
|
|
16
|
+
/* ---- AI / in-transit: dashed terminal edge (non-text grain), same idiom as the atoms.
|
|
17
|
+
MILL output is human-authored → never triggers; the catalog grain-flip demonstrates it. */
|
|
18
|
+
.callout[data-commit="pending"],
|
|
19
|
+
[data-grade="grain"] .callout { border-left-style: dashed; }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Callout
|
|
2
|
+
|
|
3
|
+
A blockquote / margin-note aside — a quiet ruled block, not a coloured box (state reads as
|
|
4
|
+
ink vs muted, not hue). MILL maps Markdown blockquotes to this. Tone is an attribute
|
|
5
|
+
(`data-status`), not a second class.
|
|
6
|
+
|
|
7
|
+
## Note
|
|
8
|
+
```html
|
|
9
|
+
<blockquote class="callout">Provenance persists: only the AI grains.</blockquote>
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Strong
|
|
13
|
+
```html
|
|
14
|
+
<blockquote class="callout" data-status="strong">One human click and one AI decision become the same Intent.</blockquote>
|
|
15
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* molecules/card — a bordered content tile + its companion grid. CSS-only (CONVENTIONS §4):
|
|
2
|
+
composed by hand — a <div> for a plain fact, an <a> for a navigable tile. Monochrome:
|
|
3
|
+
a hairline box, no fill, no shadow (DESIGN-SYSTEM §2). Variants are attributes. */
|
|
4
|
+
.card {
|
|
5
|
+
border: 1px solid var(--color-line);
|
|
6
|
+
border-radius: var(--radius-md);
|
|
7
|
+
padding: var(--space-5);
|
|
8
|
+
}
|
|
9
|
+
.card[data-pad="sm"] { padding: var(--space-4); }
|
|
10
|
+
|
|
11
|
+
.card__title { font-size: var(--text-base); margin: 0 0 var(--space-2); }
|
|
12
|
+
.card__body { color: var(--color-muted); font-size: var(--text-sm);
|
|
13
|
+
line-height: var(--leading-normal); margin: 0; }
|
|
14
|
+
|
|
15
|
+
/* a navigable card: the whole tile is the link — quiet at rest, paper lifts on hover */
|
|
16
|
+
a.card { display: block; text-decoration: none; color: var(--color-fg);
|
|
17
|
+
transition: background-color 0.15s; }
|
|
18
|
+
a.card:hover { background: var(--paper-2); }
|
|
19
|
+
a.card[aria-disabled="true"] { pointer-events: none; opacity: 0.6; }
|
|
20
|
+
|
|
21
|
+
/* the companion grid: auto-fit tiles, min width tunable per use (--card-min) */
|
|
22
|
+
.card-grid { display: grid; gap: var(--space-4);
|
|
23
|
+
grid-template-columns: repeat(auto-fit, minmax(var(--card-min, 15rem), 1fr)); }
|
|
24
|
+
|
|
25
|
+
/* ---- AI / in-transit: the non-text grain — a card the AI is composing wears the dashed
|
|
26
|
+
"terminal" edge (live pending, or any grain ancestor). Same vocabulary as badge + field. */
|
|
27
|
+
.card[data-commit="pending"],
|
|
28
|
+
[data-grade="grain"] .card { border-style: dashed; border-color: var(--ink); }
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Card
|
|
2
|
+
|
|
3
|
+
A bordered content tile — a hairline box, no fill (state is ink, not hue) — plus its
|
|
4
|
+
companion `.card-grid` (auto-fit columns; tune the minimum tile width with `--card-min`,
|
|
5
|
+
default `15rem`). Composed by hand: a `<div>` for a plain fact, an `<a>` for a navigable
|
|
6
|
+
tile (the whole tile is the link). Padding is an attribute (`data-pad="sm"`), not a class.
|
|
7
|
+
|
|
8
|
+
## Fact card
|
|
9
|
+
```html
|
|
10
|
+
<div class="card" data-pad="sm">
|
|
11
|
+
<h3 class="card__title">No build step</h3>
|
|
12
|
+
<p class="card__body">Nothing between source and server: no bundler, no transpiler.</p>
|
|
13
|
+
</div>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Card grid
|
|
17
|
+
```html
|
|
18
|
+
<div class="card-grid">
|
|
19
|
+
<div class="card" data-pad="sm"><h3 class="card__title">One</h3><p class="card__body">First fact.</p></div>
|
|
20
|
+
<div class="card" data-pad="sm"><h3 class="card__title">Two</h3><p class="card__body">Second fact.</p></div>
|
|
21
|
+
</div>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Navigable card
|
|
25
|
+
```html
|
|
26
|
+
<a class="card" href="/grain">
|
|
27
|
+
<h3 class="card__title">GRAIN</h3>
|
|
28
|
+
<p class="card__body">An AI-interaction design system. Built on BATCH.</p>
|
|
29
|
+
</a>
|
|
30
|
+
```
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* molecules/chat-message — one line of the assistant conversation. `data-role="you"` is
|
|
2
|
+
clean and right-aligned (your words, committed); `data-role="ai"` carries data-grade="grain"
|
|
3
|
+
so the AI's speech stays grain (grain = AI, AI-INTERFACE §5). A CSS class composed in a
|
|
4
|
+
flex chat log; the single writer emits matching markup over the door. */
|
|
5
|
+
.chat-message {
|
|
6
|
+
max-width: 88%;
|
|
7
|
+
padding: var(--space-2) var(--space-3);
|
|
8
|
+
border: 1px solid var(--color-line); border-radius: var(--radius-md);
|
|
9
|
+
font-size: var(--text-sm);
|
|
10
|
+
/* Break long unbreakable runs (URLs, code identifiers, hashes) INSIDE the bubble. Without this a
|
|
11
|
+
single long token overflows its own box and pushes the .assistant__log's scrollWidth past its
|
|
12
|
+
width, so the whole conversation scrolls sideways (owner report: the AI chat scrolls
|
|
13
|
+
horizontally). `anywhere` also lets the bubble shrink to fit narrow (mobile-sheet) widths. */
|
|
14
|
+
overflow-wrap: anywhere;
|
|
15
|
+
min-width: 0;
|
|
16
|
+
}
|
|
17
|
+
.chat-message[data-role="you"] { align-self: flex-end; background: var(--color-bg); }
|
|
18
|
+
.chat-message[data-role="ai"] { align-self: flex-start; background: transparent; } /* grain via data-grade */
|
|
19
|
+
/* LEGIBILITY FLOOR (2026-07-14): a bubble is --text-sm — well under the >= --text-2xl floor where
|
|
20
|
+
Redaction 50's texture reads as texture, not roughness (CLAUDE.md lesson 4). grain.css's
|
|
21
|
+
`[data-grade="grain"]`/`[data-commit="pending"]` rules would otherwise hand this element
|
|
22
|
+
`--font-grain` (Redaction 50) at 0-1-0 specificity; this rule is 0-2-0 (class + attribute), so it
|
|
23
|
+
wins regardless of CSS bundle order and swaps in the fine face instead — same mechanism
|
|
24
|
+
(`--type-font`), same idiom as `.field:focus-within` below in grain.css, just a different value.
|
|
25
|
+
The "AI wrote this" signal survives (still a visibly non-smooth Redaction face); only the
|
|
26
|
+
roughest strokes, which just turn to mush at this size, are gone. */
|
|
27
|
+
.chat-message[data-grade="grain"], .chat-message[data-commit="pending"] { --type-font: var(--font-grain-fine); }
|
|
28
|
+
.chat-message__who {
|
|
29
|
+
display: block; margin-bottom: 2px;
|
|
30
|
+
font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint);
|
|
31
|
+
}
|
|
32
|
+
/* the body reads the inherited grade font (a <span> isn't in grain.css's type selector), so the
|
|
33
|
+
AI's line actually renders grain when the message carries data-grade="grain". */
|
|
34
|
+
.chat-message__body { display: block; font-family: var(--type-font); }
|
|
35
|
+
|
|
36
|
+
/* ACTIONABLE CHAT DIALOG: a message may offer action controls — buttons the AI puts in front of
|
|
37
|
+
the person ("add to my notes", "see what's new") that fire an Intent through the ONE door
|
|
38
|
+
(`data-action`/`data-target`, presence-gated with `data-ai-run`; the dispatcher fires them even
|
|
39
|
+
though they live in the chat). They wrap into a row under the body. The offer TEXT stays grain
|
|
40
|
+
(it's the AI speaking), but the affordances are the HUMAN's to click, so the row resets to the
|
|
41
|
+
clean font — a grain-lettered button would misread as AI-authored value (grade doctrine). */
|
|
42
|
+
.chat-message__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2);
|
|
43
|
+
--type-font: var(--font-smooth); }
|
|
44
|
+
/* keep each offer label on ONE line — the ROW wraps between buttons (flex-wrap above), but a label
|
|
45
|
+
must never break mid-phrase ("SEE WHAT'S / NEW") when the bubble is narrow. A short verb phrase is
|
|
46
|
+
an atomic affordance; let a too-wide button overflow-scroll its own text rather than stack words. */
|
|
47
|
+
.chat-message__actions .btn { white-space: nowrap; }
|
|
48
|
+
/* the offered buttons sit inside a grain-graded message, so b-button's `[data-grade="grain"] .btn`
|
|
49
|
+
rule would dash them and kill their pointer events (that rule is for a control the AI is USING,
|
|
50
|
+
not one it's OFFERING). When the AI is ONLINE, undo that — the button is a live, clean, human
|
|
51
|
+
affordance. When OFFLINE (or presence not yet known) we leave the grain/disabled look on
|
|
52
|
+
purpose: the presence gate (`data-ai-run`) still holds, so an offered action reads honestly as
|
|
53
|
+
"not available right now" rather than a dead click. Scoped to online so that gate keeps winning. */
|
|
54
|
+
body[data-ai-online="true"] .chat-message__actions .btn {
|
|
55
|
+
border-style: solid; border-color: var(--color-line); pointer-events: auto;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* CHOICES (pick-one) — an actionable dialog the AI hands over as a decision, not a menu of
|
|
59
|
+
independent verbs. The dispatcher marks the group [data-resolved] and the picked button
|
|
60
|
+
[data-chosen] on the first click, then disables the set. Show the answer: the chosen stays,
|
|
61
|
+
the rest retire. */
|
|
62
|
+
.chat-message__actions[data-choices][data-resolved] .btn { pointer-events: none; }
|
|
63
|
+
.chat-message__actions[data-choices][data-resolved] .btn:not([data-chosen]) { opacity: 0.45; }
|
|
64
|
+
.chat-message__actions[data-choices] .btn[data-chosen] {
|
|
65
|
+
border-color: var(--color-accent); color: var(--color-accent); opacity: 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* THINKING — three pulsing dots for a pending AI bubble that has no token to show yet (model load,
|
|
69
|
+
retrieval), so it's never a blank rectangle (reasoner-kit thinkingDots/thinkingOp). */
|
|
70
|
+
.chat-thinking { display: inline-flex; gap: 0.28em; align-items: center; padding: 0.15em 0; }
|
|
71
|
+
.chat-thinking > span {
|
|
72
|
+
width: 0.4em; height: 0.4em; border-radius: 50%; background: var(--ink-faint);
|
|
73
|
+
animation: chat-thinking-pulse 1.1s ease-in-out infinite;
|
|
74
|
+
}
|
|
75
|
+
.chat-thinking > span:nth-child(2) { animation-delay: 0.18s; }
|
|
76
|
+
.chat-thinking > span:nth-child(3) { animation-delay: 0.36s; }
|
|
77
|
+
@keyframes chat-thinking-pulse {
|
|
78
|
+
0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
|
|
79
|
+
40% { opacity: 1; transform: translateY(-0.16em); }
|
|
80
|
+
}
|
|
81
|
+
@media (prefers-reduced-motion: reduce) {
|
|
82
|
+
.chat-thinking > span { animation: none; opacity: 0.6; }
|
|
83
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Chat message
|
|
2
|
+
|
|
3
|
+
One line of the assistant conversation. `data-role="you"` is clean and right-aligned (your
|
|
4
|
+
words, committed); `data-role="ai"` carries `data-grade="grain"` — the AI's speech stays
|
|
5
|
+
grain (grain = AI, AI-INTERFACE §5). The single writer emits matching markup over the door
|
|
6
|
+
(`chat.send`), streaming the reply into the `__body`.
|
|
7
|
+
|
|
8
|
+
**Parent context (required):** a message positions itself with `align-self`, which only works in a
|
|
9
|
+
flex column — so **compose messages inside a [`chat-log`](#chat-log)**. In a bare `div` the
|
|
10
|
+
alignment silently does nothing.
|
|
11
|
+
|
|
12
|
+
**Legibility floor.** A bubble renders at `--text-sm`, under the `>= --text-2xl` floor where
|
|
13
|
+
Redaction 50's grade texture reads as texture rather than roughness (CLAUDE.md lesson 4). So an
|
|
14
|
+
AI message (`data-grade="grain"` or mid-stream `data-commit="pending"`) renders in
|
|
15
|
+
`--font-grain-fine` (Redaction 35 only) instead of the sitewide `--font-grain` (Redaction 50) — the
|
|
16
|
+
grain signal still reads, just without the roughest strokes turning to mush at bubble size.
|
|
17
|
+
|
|
18
|
+
## Roles
|
|
19
|
+
|
|
20
|
+
### You (human — clean)
|
|
21
|
+
```html
|
|
22
|
+
<div class="chat-message" data-role="you"><span class="chat-message__who">You</span><span class="chat-message__body">Plan my Thursday.</span></div>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### The AI (grain)
|
|
26
|
+
```html
|
|
27
|
+
<div class="chat-message" data-role="ai" data-grade="grain"><span class="chat-message__who">GRAIN</span><span class="chat-message__body">On it — three deep-work blocks, review at 2.</span></div>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Actionable chat dialog (the AI offers a follow-up)
|
|
31
|
+
|
|
32
|
+
An AI message can put **action controls** in front of the person — buttons that fire an `Intent`
|
|
33
|
+
through the one door, exactly like a control on the page. Add a `chat-message__actions` row of
|
|
34
|
+
`b-button`s carrying the vocabulary: `data-action` (the verb), `data-target` (the surface),
|
|
35
|
+
`data-ai-run` (so they're presence-gated — disabled + honest when the AI is offline). The
|
|
36
|
+
dispatcher fires them even though they live in the chat (the chat is exempt from the "click =
|
|
37
|
+
interrupt" rule, not from the vocabulary). The offer text stays grain (the AI is speaking); the
|
|
38
|
+
buttons render clean, because clicking them is the **human's** move, not AI-authored value.
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<div class="chat-message" data-role="ai" data-grade="grain">
|
|
42
|
+
<span class="chat-message__who">GRAIN</span>
|
|
43
|
+
<span class="chat-message__body">I read your three newest notes and wrote a digest.</span>
|
|
44
|
+
<div class="chat-message__actions">
|
|
45
|
+
<button class="btn" data-variant="soft" data-ai-run data-action="note.append" data-target="notepad" type="button">Add to my notes</button>
|
|
46
|
+
<button class="btn" data-variant="outline" data-ai-run data-action="demo.run" data-target="screen" type="button">See what's new</button>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Every verb here must exist in `ai/contract.ts` and walk the usual alignment row — an action button
|
|
52
|
+
in the chat is a door client like any other, so a new verb needs its reasoner branch + tests.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* molecules/chip-group — one class per element; a set of selectable pills acting as a form
|
|
2
|
+
control (single- or multi-select). Native inputs inside labels → zero JS, form-postable,
|
|
3
|
+
keyboard + AX for free; checked state styled via :has()/:checked. Monochrome: a hairline pill,
|
|
4
|
+
no fill — state is carried by ink vs muted, not by hue (DESIGN-SYSTEM §2), same doctrine as
|
|
5
|
+
b-badge's "active". */
|
|
6
|
+
.chips {
|
|
7
|
+
border: 0; margin: 0; padding: 0; min-inline-size: 0;
|
|
8
|
+
display: flex; flex-wrap: wrap; gap: var(--space-2);
|
|
9
|
+
}
|
|
10
|
+
.chips__chip {
|
|
11
|
+
display: inline-flex; align-items: center; gap: var(--space-1);
|
|
12
|
+
padding: var(--space-1) var(--space-3); font-size: var(--text-sm);
|
|
13
|
+
border: 1px solid var(--line-soft); border-radius: var(--radius-pill);
|
|
14
|
+
color: var(--color-muted); cursor: pointer; user-select: none;
|
|
15
|
+
}
|
|
16
|
+
/* the native input stays focusable/keyboard-operable — sr-only, never display:none (that kills
|
|
17
|
+
keyboard). The label is the visible target. */
|
|
18
|
+
.chips__chip input {
|
|
19
|
+
position: absolute; width: 1px; height: 1px; opacity: 0; margin: 0;
|
|
20
|
+
}
|
|
21
|
+
/* selected (monochrome, like badge "active") */
|
|
22
|
+
.chips__chip:has(:checked) { color: var(--ink); border-color: var(--ink); }
|
|
23
|
+
/* focus ring (keyboard) */
|
|
24
|
+
.chips__chip:has(:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 1px; }
|
|
25
|
+
/* hover (subtle, muted → fg) */
|
|
26
|
+
.chips__chip:hover { color: var(--ink); }
|
|
27
|
+
|
|
28
|
+
/* data-select="single" (radios) needs no separate CSS — radios vs checkboxes are a markup
|
|
29
|
+
swap; the :has(:checked) rule above covers both. Do not invent per-variant classes. */
|
|
30
|
+
|
|
31
|
+
/* ---- AI / in-transit: the non-text grain. A chip the AI is toggling (live pending, or any
|
|
32
|
+
grain ancestor) wears the dashed "terminal" edge; the label already swaps to the grain family
|
|
33
|
+
via --type-font. Same vocabulary as the button + field + badge. */
|
|
34
|
+
.chips[data-commit="pending"] .chips__chip,
|
|
35
|
+
[data-grade="grain"] .chips__chip { border-style: dashed; border-color: var(--ink); }
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Chip group
|
|
2
|
+
|
|
3
|
+
A set of selectable pills acting as a form control (single- or multi-select) — a filter
|
|
4
|
+
bar / tag picker / facet control. Native inputs → zero JS, form-postable, keyboard + AX
|
|
5
|
+
for free. Monochrome selected state: ink vs muted, not hue.
|
|
6
|
+
|
|
7
|
+
Parent-context note: a chip is a `<label class="chips__chip">` child of a
|
|
8
|
+
`<fieldset class="chips">` — the checkbox/radio + a `<span>` for the visible text live
|
|
9
|
+
inside the label; the fieldset owns the layout (`display: flex; flex-wrap: wrap`) and the
|
|
10
|
+
`data-select` attribute. A `chips__chip` outside a `.chips` fieldset has no layout context.
|
|
11
|
+
|
|
12
|
+
A chip's value may carry `data-surface="…"` so an AI can address one selection later —
|
|
13
|
+
this is a plain attribute hook only; it does not add a surface kind or action to
|
|
14
|
+
`ai/contract.ts`.
|
|
15
|
+
|
|
16
|
+
## Multi-select
|
|
17
|
+
```html
|
|
18
|
+
<fieldset class="chips" data-select="multi">
|
|
19
|
+
<label class="chips__chip"><input type="checkbox" name="env" value="staging" checked><span>staging</span></label>
|
|
20
|
+
<label class="chips__chip"><input type="checkbox" name="env" value="prod"><span>prod</span></label>
|
|
21
|
+
<label class="chips__chip"><input type="checkbox" name="env" value="local"><span>local</span></label>
|
|
22
|
+
</fieldset>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Single-select
|
|
26
|
+
```html
|
|
27
|
+
<fieldset class="chips" data-select="single">
|
|
28
|
+
<label class="chips__chip"><input type="radio" name="priority" value="low"><span>Low</span></label>
|
|
29
|
+
<label class="chips__chip"><input type="radio" name="priority" value="medium" checked><span>Medium</span></label>
|
|
30
|
+
<label class="chips__chip"><input type="radio" name="priority" value="high"><span>High</span></label>
|
|
31
|
+
</fieldset>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Selected + focus
|
|
35
|
+
The checked chip reads ink vs faint (monochrome, no hue); a keyboard focus on a chip's
|
|
36
|
+
hidden input shows the same accent focus ring as the rest of the field family.
|
|
37
|
+
```html
|
|
38
|
+
<fieldset class="chips" data-select="multi">
|
|
39
|
+
<label class="chips__chip"><input type="checkbox" name="tag" value="urgent" checked><span>urgent</span></label>
|
|
40
|
+
<label class="chips__chip"><input type="checkbox" name="tag" value="backlog"><span>backlog</span></label>
|
|
41
|
+
</fieldset>
|
|
42
|
+
```
|