repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

Add the capture skill for TUI screenshots and recordings

68c8b40dc60930c68c920a07c5f8c43f25a83a0a

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

PR evidence, QA repros, and debugging all want visuals, and a TUI capture
fails in its own way: a full-size terminal grid rendered small leaves the
text illegible. The skill pins a vhs tape workflow whose legibility
defaults were validated headless in a root agent container (VHS_NO_SANDBOX
required; a tmux+freeze path covers browserless stills), and pushes all
verbose material into references/ and examples/ so the core stays terse.
Evidence publishes as release assets, never into the git object store.

A .agents/skills symlink to .claude/skills lets harnesses that discover
skills there load the same definitions instead of a parallel copy.

The skill lives in .claude/skills/capture/ with a thin .pi adapter.

Changed files (10)

+301 / −3 text lines · 1 metadata-only

Diff layout

.agents/skills

Added
new file mode 120000

Link change (old → new): absent → target: ../.claude/skills.

.claude/skills/capture/SKILL.md

Added
new file mode 100644

+60 / −0 text lines

1---
2name: capture
3description: Capture legible screenshots (PNG) and recordings (GIF/MP4) of TUI runs for PRs, QA, and debugging. Invoke with a target, e.g. /capture prototypes/p27 layout demo.
4---
5
6# capture — TUI screenshots and recordings
7
8Produce a legible still or recording of a terminal run, as evidence: what a
9PR achieved, what a bug looks like, what a prototype does.
11Focus on the target given with the invocation — what to run and what
12behavior to show. If none was given, ask for one.
14## Workflow
161. **Tools.** Needs `vhs`, `ttyd`, `ffmpeg` (plus `freeze` for the
17 fallback still path). Any missing → `references/setup.md`.
182. **Write a tape.** Copy from `examples/`, keep the sizing defaults
19 (`FontSize 20`, `Width 1200`, `Height 700`, `Padding 12` — legibility
20 comes from font size, not canvas size). Full syntax and sizing math →
21 `references/tape.md`.
223. **Run.** `VHS_NO_SANDBOX=true vhs the.tape` (`VHS_NO_SANDBOX` is
23 required when running as root, which agent sandboxes usually are).
244. **Look at it.** Read the PNG (and GIF) yourself before delivering.
25 Illegible text, mistimed frames, wrong state on screen → fix the tape,
26 rerun. Never ship a capture you have not seen.
275. **Deliver.** GIF for anything that must render inline on GitHub; how and
28 where to put files → `references/publishing.md`.
30## Rules
32- **Capture, don't fabricate.** The image must be a render of a real
33 terminal session (vhs, or tmux + freeze). Never fake a "screenshot" by
34 drawing command output into an image with an image library — that is
35 fabricated evidence, and colors/attributes/interaction state are lost.
36- **One capture, one claim.** Show exactly the behavior the PR or issue is
37 about. Trim scope with terminal size and tape length, never by editing
38 the image afterwards.
39- **Deterministic tapes.** Drive the app with `Type`/`Enter`/key commands and
40 fixed `Sleep`s; no wall-clock-dependent content in the frame if you can
41 avoid it (clocks, PIDs, load averages make diffs and reruns noisy).
42- **Stills are tapes too.** Use the `Screenshot` command inside a tape; it
43 captures at an exact scripted moment.
44- **No browser or ffmpeg available?** Use the tmux + `freeze` still path
45 in `references/setup.md`. Recordings need vhs; stills do not.
47## Status block
49End with Markdown, not JSON:
51```markdown
52## Status
53complete | blocked
55## Artifacts
56- `path/to/capture.gif` — what it shows
58## Actions
59- ...
60```

.claude/skills/capture/examples/demo.tape

Added
new file mode 100644

+23 / −0 text lines

1# Short interaction demo → GIF (+ still of the end state).
2# Replace `top` and the keystrokes with the app under capture.
3Require top
4Output demo.gif
5Set FontSize 20
6Set Width 1200
7Set Height 700
8Set Padding 12
9Set Theme "Catppuccin Mocha"
10Set TypingSpeed 50ms
11Set Framerate 24
12Env LANG "C.UTF-8"
13Type "top"
14Enter
15Sleep 3s
16# drive the app: sort by memory, then back
17Type "M"
18Sleep 2s
19Type "P"
20Sleep 2s
21Screenshot end-state.png
22Type "q"
23Sleep 500ms

.claude/skills/capture/examples/screenshot.tape

Added
new file mode 100644

+15 / −0 text lines

1# Single still of a TUI. Replace `top` with the app under capture.
2# No Output line: a tape with only Screenshot renders no gif.
3Require top
4Set FontSize 20
5Set Width 1200
6Set Height 700
7Set Padding 12
8Set Theme "Catppuccin Mocha"
9Env LANG "C.UTF-8"
10Type "top"
11Enter
12Sleep 3s
13Screenshot shot.png
14Type "q"
15Sleep 500ms

.claude/skills/capture/references/publishing.md

Added
new file mode 100644

+61 / −0 text lines

1# Getting captures into PRs and issues
2
3## The iron rule
4
5**No capture ever enters the git object store.** Not on a branch, not
6"temporarily", not on an orphan ref — blobs in git history are permanent
7bloat (owner ruling). The only exception is an asset that *ships* as
8product content (docs site, book), which is committed deliberately like
9any other source file.
11## Format choice
13- **GIF** — the default. It is the only motion format GitHub renders
14 inline from a markdown image link, and it is all an agent can publish
15 (the drag-and-drop attachment upload that accepts MP4 is web-UI-only,
16 with no API).
17- **MP4** — smaller for long demos, but only a human can attach it to a
18 PR body. Emit as a secondary `Output` when the GIF would bust 10 MB,
19 hand it over, and say so.
20- **PNG** — stills; always fine.
22## Where evidence goes: release assets, not git
24Release assets live outside git (they add zero objects and don't count
25toward repo size), are uploadable by the bot via API, and their URLs
26render inline in PR/issue bodies.
281. Ensure the rolling evidence prerelease exists (first use only):
29 `gh release create captures --prerelease --title "capture evidence"
30 --notes "PR/issue evidence uploads; not a product release."`
31 The tag points at an existing commit — no new git objects.
32 **Bootstrap proof, once:** the inline-render claim below is an
33 assumption until demonstrated on this repo. On first use, upload one
34 PNG, embed it in a comment, and look at the rendered result. If it
35 renders, delete this paragraph and carry on. If it only links, change
36 step 3's guidance to plain links and note the finding here.
372. Upload with a unique, traceable name:
38 `gh release upload captures pr53-fold-demo.gif`
393. Embed:
40 ```markdown
41 ![fold demo](https://github.com/bugabinga/smith/releases/download/captures/pr53-fold-demo.gif)
42 ```
434. Fetch the URL once to confirm it resolves before posting.
45Evidence for a closed/merged PR can be deleted later
46(`gh release delete-asset captures <name>`) — or kept; either way git
47history is untouched.
49Throwaway QA/debug captures stay in the scratchpad and get Read there;
50publish only what a human needs to see.
52## Checklist before embedding
54- You Read the image and the text is legible at PR-body width (~900 px).
55- **No secrets in any frame** — keys, tokens, private paths, provider
56 responses. Captures are secret sinks like logs; a frame is published
57 forever once fetched. When in doubt, re-capture with a scrubbed
58 environment.
59- File ≤ 10 MB (GitHub stops inlining above that).
60- The frame shows the claim — not a prompt, not build output.
61- Asset name carries its origin (`pr<N>-` / `issue<N>-` prefix).

.claude/skills/capture/references/setup.md

Added
new file mode 100644

+48 / −0 text lines

1# Tool setup
2
3All steps verified on Ubuntu 24.04 (noble) inside a root agent container.
4
5## Recording stack (vhs)
6
7`vhs` scripts a real headless terminal (ttyd + Chromium) and renders
8GIF/MP4/PNG via ffmpeg.
9
10```sh
11apt-get update
12apt-get install -y ffmpeg ttyd # noble ships ttyd 1.7.4
13go install github.com/charmbracelet/vhs@latest
14export PATH="$PATH:$HOME/go/bin"
15```
17No Go toolchain? Use the release binaries:
18<https://github.com/charmbracelet/vhs/releases> and
19<https://github.com/tsl0922/ttyd/releases> (static `ttyd.x86_64`).
21Notes:
23- First run downloads a Chromium into `~/.cache/rod/` (needs network).
24- Running as root: set `VHS_NO_SANDBOX=true` or the browser refuses to
25 start (`Running as root without --no-sandbox is not supported`).
26- A pre-installed Playwright Chromium does not help; vhs uses its own.
28## Still-only fallback (tmux + freeze)
30When no browser/ffmpeg is possible, capture the pane's ANSI and render it
31to PNG. No recordings on this path, stills only.
33```sh
34go install github.com/charmbracelet/freeze@latest
36tmux new-session -d -s cap -x 120 -y 30 'the-tui-command'
37sleep 3 # let the UI settle
38# optional: drive it — tmux send-keys -t cap j j Enter
39tmux capture-pane -t cap -ep > pane.ansi # -e keeps colors
40tmux kill-session -t cap
41freeze pane.ansi --output shot.png --font.size 16
42```
44## Health check
46```sh
47for t in vhs ttyd ffmpeg freeze; do command -v "$t" || echo "$t missing"; done
48```

.claude/skills/capture/references/tape.md

Added
new file mode 100644

+79 / −0 text lines

1# Tape writing and sizing
2
3A `.tape` is a deterministic script: settings first, then keystrokes and
4sleeps. Full grammar: `vhs manual`.
5
6## The commands that matter
7
8| Command | Use |
9|---|---|
10| `Output demo.gif` | render target; repeat for more formats (`.mp4`, `.webm`); omit entirely for still-only tapes |
11| `Require cmd` | fail fast if `cmd` is not installed |
12| `Set <option> <val>` | see sizing below; must precede all actions |
13| `Type "text"` / `Enter` / `Down 3` / `Ctrl+C` | drive the app; every special key is a bare command (`Space`, `Tab`, `Escape`, `PageDown`, arrows with optional repeat count) — there is no `Key` prefix |
14| `Sleep 2s` | fixed wait — the only timing primitive; be generous after launch |
15| `Screenshot shot.png` | still frame at exactly this point in the script |
16| `Hide` / `Show` | exclude setup noise (cd, build output) from the render |
18## Sizing for legibility — the TUI-specific part
20A TUI screenshot fails by being a huge terminal with ant-sized text.
21Fix the *font* size, then give the app only the columns it needs:
23- `FontSize` ≥ 16; **20 is the default here**.
24- Columns ≈ `(Width − 2·Padding) / (FontSize × 0.6)`. The defaults
25 (`Width 1200`, `Padding 12`, `FontSize 20`) yield a ~98×27 grid — about
26 right for a full-screen TUI rendered into a ~900 px-wide PR body.
27- Wider app? Prefer 1600×800 @ FontSize 18 (~145 cols) over shrinking the
28 font further. Below 14 pt, text in a PR is decoration, not evidence.
29- `Set Theme "Catppuccin Mocha"` (or any high-contrast dark theme) and
30 `Set Padding 12` keep edges and colors readable.
32## Two environment traps
34- **No UTF-8 locale in the vhs shell.** Non-ASCII text (§, em-dashes,
35 box-drawing) renders as raw bytes like `<C2><A7>`. Put
36 `Env LANG "C.UTF-8"` in every tape (add `Env LESSCHARSET "utf-8"` when
37 driving `less`), and when verifying the output, check a non-ASCII glyph
38 specifically.
39- **Absolute `Output` paths can be rejected** by the tape parser (e.g.
40 deep paths with hyphen-leading components). Keep `Output` and
41 `Screenshot` paths relative and run `vhs` from the directory the files
42 belong in.
44## Keeping recordings small
46GitHub renders inline images up to ~10 MB; aim well under.
48- Shortest tape that proves the claim; ≤ 30 s of footage.
49- `Set PlaybackSpeed 2` to compress long waits; `Set TypingSpeed 50ms`
50 so typing does not dominate.
51- `Set Framerate 24` (default 50) roughly halves GIF size.
52- Long or high-motion demo → also emit `Output demo.mp4` and let a human
53 attach it (see publishing.md); keep the GIF as the inline version.
55## Skeleton
57```tape
58Require cargo
59Output demo.gif
60Set FontSize 20
61Set Width 1200
62Set Height 700
63Set Padding 12
64Set Theme "Catppuccin Mocha"
65Env LANG "C.UTF-8"
66Hide
67Type "cd prototypes/p27-per-frame-layout && cargo build -q"
68Enter
69Sleep 30s
70Show
71Type "cargo run -q"
72Enter
73Sleep 3s
74Screenshot startup.png
75Down 3
76Sleep 1s
77Type "q"
78Sleep 500ms
79```

.pi/prompts/capture.md

Added
new file mode 100644

+10 / −0 text lines

1---
2name: capture
3description: Capture TUI screenshots and recordings for PRs, QA, debugging.
4argument-hint: "[target]"
5---
6
7Read `.claude/skills/capture/SKILL.md` and follow it as your instructions.
8It is the canonical, harness-agnostic definition of this command.
9
10Where it says "the target given with the invocation", use: $ARGUMENTS

CLAUDE.md

Modified

+4 / −2 text lines

67674. Open questions: stop and ask. No guessing.
68685. Invoke spec work: `/smith <topic>`. Commands are defined once,
6969 harness-agnostically, in `.claude/skills/<name>/SKILL.md`
70 (smith, pioneer, handmade, sabotnik); `.pi/prompts/` holds thin pi
71 adapters that defer to them.
70 (smith, pioneer, handmade, sabotnik, capture); `.pi/prompts/` holds thin
71 pi adapters that defer to them. `.agents/skills` symlinks to
72 `.claude/skills` so harnesses that discover skills there (codex-style)
73 read the same definitions; smith's own CI wiring does not consume it.
72746. Cargo is the sole build system. See `docs/PROJECT-INVARIANTS.md` §1.
73757. Agents must not modify `docs/SPEC.md` or `docs/PROJECT-INVARIANTS.md` without approval.

docs/plans/AGENTIC-DEVELOPMENT.md

Modified

+1 / −1 text lines

8989in the agent files — an agent doesn't need to know what woke it; the trigger is a
9090property of the workflow that runs it (the encoding surface), and is listed here
9191only for the reader's map. The craft skills (`sabotnik`, `handmade`, `pioneer`,
92`smith`) are *verbs the agents wield*, not agents.
92`smith`, `capture`) are *verbs the agents wield*, not agents.
9494Two axes set each agent: a **model** (intelligence) and a **reasoning effort**
9595(how hard it thinks). Effort runs `off · low · medium · high · xhigh · max`, and