Skip to content

Commit ac6dced

Browse files
Vonngclaude
andcommitted
feat(home): show a recorded Barn 1.0 first run in the quick start
- Replace the sparse command panel with an asciinema recording of a real first run on an Ubuntu 26.04 host: install.sh, `barn version`, `barn up` with its one-row plan and confirmation, the image download and boot, `barn ssh`, and `barn status`. Output bytes are untouched; only the download and boot waits are compressed and each command's echo is spread over its typing time. - Lay the section out as facts beside the recording, with the macOS and Linux commands in matching columns underneath; the installer line fits without scrolling. - Keep the recording tooling in `bin/first-run-cast/` with re-recording steps. - Tutorial: describe the first-run plan rows `barn up` actually prints (install, network, config, sudo) and show a real sample. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e211df5 commit ac6dced

13 files changed

Lines changed: 634 additions & 47 deletions

File tree

‎AGENTS.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ These are Barn site code, not OINK features:
1616

1717
- `layouts/_partials/landing/barn-quickstart.html` renders the home quick start
1818
(`{type: markdown, key: quickstart, partial: …}` in `data/home/<lang>.yaml`):
19-
default-node facts beside a Markdown body whose code tabs use the
20-
`barn-host` group.
19+
default-node facts beside the `demo` recording, with the macOS and Linux
20+
commands from `body` in a row underneath.
21+
- `static/images/barn-first-run.cast` is a real first run recorded on `m3`;
22+
`bin/first-run-cast/` holds the driver, timing scripts, and re-recording
23+
steps. Re-record it when the first-run output changes, and keep the typed
24+
commands identical to the Linux commands in `body`.
2125
- Home-page styles in `assets/scss/_styles_project.scss` are scoped under
2226
`.td-home` or `.barn-quickstart`. Capability transcripts on the home page
2327
must match real Barn 1.0 output; check them against `cmd/barn` before

‎assets/scss/_styles_project.scss‎

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@
169169
gap: clamp(28px, 4vw, 56px);
170170
align-items: center;
171171

172-
// The Linux installer URL is 75 columns; side by side only where it fits.
173-
@media (min-width: 1280px) {
174-
grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
172+
// The 80-column recording needs about 640px to stay readable, so the
173+
// columns sit side by side only from 1100px.
174+
@media (min-width: 1100px) {
175+
grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
175176
}
176177
}
177178

@@ -251,24 +252,61 @@
251252
}
252253
}
253254

255+
// The recording uses the theme's asciinema player; drop the window lights
256+
// as the home codeplates do, and keep its caption quiet.
257+
&__demo {
258+
width: 100%;
259+
max-width: 760px;
260+
min-width: 0;
261+
justify-self: center;
262+
263+
.td-asciinema {
264+
margin: 0;
265+
}
266+
267+
.td-asciinema__lights {
268+
display: none;
269+
}
270+
271+
p {
272+
margin: 0.55rem 0 0;
273+
color: var(--td-soft);
274+
font-size: 0.82rem;
275+
text-wrap: balance;
276+
}
277+
}
278+
279+
// macOS commands sit under the facts and Linux commands under the Linux
280+
// recording, on the same column ratio. Side by side only from 1320px,
281+
// where the 75-column installer line fits without scrolling.
254282
&__code {
255283
min-width: 0;
256-
background: transparent;
284+
margin-block-start: clamp(24px, 3vw, 40px);
257285

258-
> :last-child {
259-
margin-block-end: 0;
286+
> .td-content {
287+
display: grid;
288+
gap: 1rem clamp(28px, 4vw, 56px);
289+
290+
@media (min-width: 1320px) {
291+
grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
292+
}
260293
}
261294

262-
// data-bs-theme="dark" scopes Bootstrap and Chroma; plain code text
263-
// still reads the page's --td tokens, so pin it to the codeplate ink.
264-
pre,
265-
pre code {
266-
color: #c9d6e8;
295+
.td-code {
296+
display: flex;
297+
min-width: 0;
298+
flex-direction: column;
299+
margin: 0;
300+
301+
> :last-child {
302+
flex: 1 1 auto;
303+
}
267304
}
268305

269306
pre {
270-
font-size: 0.86rem;
271-
line-height: 1.75;
307+
height: 100%;
308+
font-size: 0.84rem;
309+
line-height: 1.7;
272310
}
273311
}
274312
}

‎bin/first-run-cast/README.md‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# First-run recording
2+
3+
`static/images/barn-first-run.cast` is the terminal recording on the home
4+
page quick start. It is a real Barn first run on an Ubuntu 26.04 x86_64 host
5+
(`m3`), driven from a Mac with `expect` and captured with `asciinema`.
6+
7+
## What the recording shows
8+
9+
The typed commands are exactly the Linux commands under it on the home page:
10+
`curl … install.sh`, `bash install.sh`, `export PATH=…`, `barn version`,
11+
`barn up` (answering the one `[Y/n]` prompt), `barn ssh` with `df -h /data`,
12+
and `barn status`.
13+
14+
The Barn host network was installed beforehand with
15+
`barn network install --yes` over SSH without a terminal. On a terminal,
16+
Barn 1.0.0 authenticates with `sudo -v`, which asks for a password on hosts
17+
whose sudo policy mixes `NOPASSWD: ALL` with a password rule, so a scripted
18+
take cannot pass that step. The recording therefore starts from a host whose
19+
network is ready, and the `barn up` plan shows only the `config` row.
20+
21+
`demo.rc` sets the prompt, terminal size, a local HTTP proxy for GitHub, and
22+
`BARN_REPO=https://repo.pigsty.cc/barn` so the image downloads from the China
23+
mirror. None of it appears in the recording.
24+
25+
## Re-recording
26+
27+
1. Reset the host: destroy the demo lab, delete the cached image under
28+
`~/.barn/images/`, remove the `~/.local/bin` install, and leave
29+
`~/barn-lab` empty. Copy `demo.rc` to `/tmp/barn-demo.rc` on the host.
30+
2. Record (`BARN_CAST_HOST` defaults to `m3`):
31+
32+
```bash
33+
asciinema rec --headless --overwrite --window-size 80x24 -f asciicast-v2 \
34+
-c "expect demo.exp" --return take.cast
35+
```
36+
37+
3. Spread each command's echo over its typing time, then cap pauses and
38+
compress the download and boot waits. Output bytes are unchanged:
39+
40+
```bash
41+
python3 typing.py take.cast typed.cast
42+
python3 retime.py typed.cast barn-first-run.cast --max-gap 1.5 \
43+
--squeeze "Downloading image u24:Verifying downloaded image:6" \
44+
--squeeze "0/1 nodes ready:1 node ready:3" \
45+
--title "Barn 1.0.0 first run on Ubuntu 26.04"
46+
```
47+
48+
4. Check the file for secrets (`retime.py` drops the `command` and `env`
49+
header keys), copy it to `static/images/`, and set the `poster` time in
50+
`data/home/*.yaml` to a frame just after `1 node ready`.

‎bin/first-run-cast/demo.exp‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/expect -f
2+
# Drive a real Barn 1.0 first run on m3 for the home-page recording.
3+
# Typing is simulated; every command and its output are real.
4+
set timeout 60
5+
set send_human {.05 .09 1 .03 .22}
6+
log_user 1
7+
set host_prompt {barn-lab\x1b\[0m\$ $}
8+
set guest_prompt {\$ $}
9+
10+
proc type_line {text} {
11+
send -h -- $text
12+
sleep 0.45
13+
send -- "\r"
14+
}
15+
16+
proc run {text wait} {
17+
global host_prompt timeout
18+
type_line $text
19+
set timeout $wait
20+
expect {
21+
-re $host_prompt {}
22+
timeout { send_user "\n!! timeout after: $text\n"; exit 3 }
23+
}
24+
sleep 1.3
25+
}
26+
27+
set host [expr {[info exists env(BARN_CAST_HOST)] ? $env(BARN_CAST_HOST) : "m3"}]
28+
spawn -noecho ssh -q -tt -o BatchMode=yes $host "bash --rcfile /tmp/barn-demo.rc -i"
29+
expect -re $host_prompt
30+
sleep 1.5
31+
32+
run {curl -fLO https://github.com/pgsty/barn/releases/latest/download/install.sh} 120
33+
run {bash install.sh} 300
34+
run {export PATH="$HOME/.local/bin:$PATH"} 20
35+
run {barn version} 30
36+
37+
type_line {barn up}
38+
set timeout 1500
39+
expect {
40+
-ex {[Y/n]} {
41+
sleep 1.6
42+
send -h -- "y"
43+
sleep 0.3
44+
send -- "\r"
45+
exp_continue
46+
}
47+
-ex {Password:} { send_user "\n!! unexpected sudo prompt\n"; exit 3 }
48+
-re $host_prompt {}
49+
timeout { send_user "\n!! barn up timeout\n"; exit 3 }
50+
}
51+
sleep 1.6
52+
53+
type_line {barn ssh}
54+
set timeout 120
55+
expect {
56+
-re {meta.*\$ $} {}
57+
timeout { send_user "\n!! no guest prompt\n"; exit 3 }
58+
}
59+
sleep 1.2
60+
type_line {df -h /data}
61+
expect -re {meta.*\$ $}
62+
sleep 1.4
63+
type_line {exit}
64+
expect -re $host_prompt
65+
sleep 1.2
66+
67+
run {barn status} 60
68+
sleep 2.5
69+
send -- "exit\r"
70+
expect eof

‎bin/first-run-cast/demo.rc‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export PS1='\[\e[1;32m\]vonng@m3\[\e[0m\]:\[\e[1;34m\]\w\[\e[0m\]$ '
2+
export http_proxy=http://127.0.0.1:8888 https_proxy=http://127.0.0.1:8888
3+
export HTTP_PROXY=$http_proxy HTTPS_PROXY=$https_proxy
4+
export no_proxy=localhost,127.0.0.1,.pigsty.cc,repo.pigsty.cc,10.10.10.0/24 NO_PROXY=localhost,127.0.0.1,.pigsty.cc,repo.pigsty.cc,10.10.10.0/24
5+
export BARN_REPO=https://repo.pigsty.cc/barn
6+
export TERM=xterm-256color
7+
cd ~/barn-lab
8+
stty cols 80 rows 24
9+
clear

‎bin/first-run-cast/retime.py‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env python3
2+
"""Retime an asciicast v2 recording without changing any output bytes.
3+
4+
- Every gap between events is capped at --max-gap seconds.
5+
- Each --squeeze START:END:SECONDS window (START/END are substrings of the
6+
output stream; END is searched after START) is rescaled so that the
7+
events between them span at most SECONDS. Use it for long progress bars
8+
and boot waits.
9+
"""
10+
import argparse
11+
import json
12+
import sys
13+
14+
15+
def main():
16+
parser = argparse.ArgumentParser()
17+
parser.add_argument("src")
18+
parser.add_argument("dst")
19+
parser.add_argument("--max-gap", type=float, default=1.4)
20+
parser.add_argument("--squeeze", action="append", default=[])
21+
parser.add_argument("--title")
22+
args = parser.parse_args()
23+
24+
with open(args.src, encoding="utf-8") as handle:
25+
header = json.loads(handle.readline())
26+
events = [json.loads(line) for line in handle if line.strip()]
27+
28+
outputs = [e for e in events if e[1] == "o"]
29+
times = [e[0] for e in outputs]
30+
gaps = [times[0]] + [b - a for a, b in zip(times, times[1:])]
31+
32+
# Locate squeeze windows by output substrings (on the cumulative stream).
33+
stream, offsets = "", []
34+
for event in outputs:
35+
offsets.append(len(stream))
36+
stream += event[2]
37+
38+
def index_at(char_pos):
39+
lo, hi = 0, len(offsets) - 1
40+
while lo < hi:
41+
mid = (lo + hi + 1) // 2
42+
if offsets[mid] <= char_pos:
43+
lo = mid
44+
else:
45+
hi = mid - 1
46+
return lo
47+
48+
scale = [1.0] * len(gaps)
49+
cursor = 0
50+
for spec in args.squeeze:
51+
start, end, seconds = spec.rsplit(":", 2) if spec.count(":") >= 2 else (None, None, None)
52+
start_pos = stream.find(start, cursor)
53+
end_pos = stream.find(end, start_pos + len(start)) if start_pos >= 0 else -1
54+
if start_pos < 0 or end_pos < 0:
55+
sys.exit(f"squeeze window not found: {spec!r}")
56+
first, last = index_at(start_pos) + 1, index_at(end_pos)
57+
span = sum(min(g, args.max_gap) for g in gaps[first:last + 1])
58+
factor = min(1.0, float(seconds) / span) if span > 0 else 1.0
59+
for i in range(first, last + 1):
60+
scale[i] = factor
61+
print(f"squeeze {start!r}..{end!r}: {span:.1f}s -> {span * factor:.1f}s", file=sys.stderr)
62+
cursor = end_pos
63+
64+
clock, retimed = 0.0, []
65+
for event, gap, factor in zip(outputs, gaps, scale):
66+
clock += min(gap, args.max_gap) * factor
67+
retimed.append([round(clock, 4), "o", event[2]])
68+
69+
header.pop("idle_time_limit", None)
70+
if args.title:
71+
header["title"] = args.title
72+
header.pop("env", None)
73+
header.pop("command", None)
74+
with open(args.dst, "w", encoding="utf-8") as handle:
75+
handle.write(json.dumps(header, ensure_ascii=False) + "\n")
76+
for event in retimed:
77+
handle.write(json.dumps(event, ensure_ascii=False) + "\n")
78+
print(f"{len(retimed)} events, {times[-1]:.1f}s -> {clock:.1f}s", file=sys.stderr)
79+
80+
81+
if __name__ == "__main__":
82+
main()

‎bin/first-run-cast/typing.py‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env python3
2+
"""Spread each typed command's echo across the time it was typed.
3+
4+
The driver typed every command character by character, but the local pty
5+
delivered the echo in one burst on Enter. For each output event that starts
6+
with a typed command and follows a prompt, split the command text into
7+
per-character events ending at the original event time. No bytes change.
8+
"""
9+
import json
10+
import sys
11+
12+
TYPED = [
13+
"curl -fLO https://github.com/pgsty/barn/releases/latest/download/install.sh",
14+
"bash install.sh",
15+
'export PATH="$HOME/.local/bin:$PATH"',
16+
"barn version",
17+
"barn up",
18+
"barn ssh",
19+
"df -h /data",
20+
"barn status",
21+
"exit",
22+
"y",
23+
]
24+
PROMPTS = ("$ ", "[Y/n] ")
25+
STEP = 0.065
26+
27+
28+
def main(src, dst):
29+
with open(src, encoding="utf-8") as handle:
30+
header = handle.readline()
31+
events = [json.loads(line) for line in handle if line.strip()]
32+
out = []
33+
for index, event in enumerate(events):
34+
previous = events[index - 1] if index else None
35+
text = event[2] if event[1] == "o" else ""
36+
command = next((c for c in TYPED if text.startswith(c)), None)
37+
if command and previous and previous[1] == "o" and previous[2].endswith(PROMPTS):
38+
rest = text[len(command):]
39+
gap = event[0] - previous[0]
40+
step = min(STEP, max(gap - 0.4, 0.0) / max(len(command), 1))
41+
start = event[0] - step * (len(command) - 1)
42+
for offset, char in enumerate(command):
43+
piece = char + (rest if offset == len(command) - 1 else "")
44+
out.append([round(start + step * offset, 6), "o", piece])
45+
continue
46+
out.append(event)
47+
with open(dst, "w", encoding="utf-8") as handle:
48+
handle.write(header)
49+
for event in out:
50+
handle.write(json.dumps(event, ensure_ascii=False) + "\n")
51+
print(f"{len(events)} -> {len(out)} events", file=sys.stderr)
52+
53+
54+
if __name__ == "__main__":
55+
main(sys.argv[1], sys.argv[2])

‎content/docs/start/tutorial.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,16 @@ mkdir -p ~/barn-lab && cd ~/barn-lab
5656
barn up
5757
```
5858

59-
When neither an inventory file nor an active deployment exists, `barn up` prints a setup plan before it changes anything: `config` names the one-node `barn.yml` it writes, `dependencies` lists the QEMU, UEFI firmware, and OpenSSH packages to install, `network` shows the fixed-IP host network, and `privileges` lists the steps that use `sudo`. Answer `Continue with this setup? [Y/n]` once; Barn then downloads and verifies the base image and waits until SSH is ready:
59+
When neither an inventory file nor an active deployment exists, `barn up` prints a short setup plan before it changes anything. Only the rows that apply appear: `install` lists missing packages (QEMU, UEFI firmware, OpenSSH) and the package manager, `network` names the fixed-IP subnet it prepares, `config` names the one-node `barn.yml` it writes, and `sudo` says which steps need root. On a host that already has QEMU:
60+
61+
```text
62+
network prepare 10.10.10.0/24
63+
config create /home/alice/barn-lab/barn.yml
64+
sudo network (root-owned barn0 bridge)
65+
Continue with this setup? [Y/n]
66+
```
67+
68+
Answer once; `sudo` may then ask for your password. Barn downloads and verifies the base image and waits until SSH is ready:
6069

6170
```text
6271
✓ 1 node ready

0 commit comments

Comments
 (0)