~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/hud

A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts

0
0

HUD's checks run on the runner: check, test, web, lexicons and e2e

Merged chadtmiller.com asked to merge into main from chadtmiller.com/hud:repo/workflows
.knotless/workflows/check.ymlnew+34−0
@@ -0,0 +1,34 @@
# Formatting and lints, as `just check` runs them for the Rust: rustfmt,
# then clippy over the workspace, warnings denied. hud-server embeds the
# built pages (its build.rs reads web/dist), so they are built first; test.yml
# runs the tests.
#
# The image is the Rust `rustup run stable` gives locally, so a newer
# release's new lints land on purpose. The build, the toolchain's
# components, Node and the pages' packages are kept between runs, so a push
# lints only what it changed.
image: rust:1.100
# A pre-flight: the merge queue takes a pull into a batch only once this
# has passed at its head, so one that does not build fails no batch.
queue: first
runners: [runner.knotless.dev]
# Pushes to main, and pulls into it or a feature/ branch, at their heads
# merged with their base.
on:
push: {refs: [refs/heads/main]}
pull: {base: [refs/heads/main, refs/heads/feature/*]}
cache: [target, /usr/local/cargo/registry, /usr/local/rustup, /opt/node, web/node_modules]
env:
# The image's version: the cached /usr/local/rustup hides the image's own
# and keeps the default of the first image that filled it, so rustup
# installs this one into the cache on the first run that names it.
RUSTUP_TOOLCHAIN: "1.100.0"
steps:
- uses: chadtmiller.com/steps/node@1
with: {version: 24.22.1}
- uses: chadtmiller.com/steps/npm-ci@1
name: pages' packages
with: {dir: web}
- name: pages
run: cd web && npm run build
- uses: chadtmiller.com/steps/rust-lint@1
.knotless/workflows/e2e.ymlnew+66−0
@@ -0,0 +1,66 @@
# The workspace used as people use it, as `just e2e` runs it: in Chromium,
# signed in through the reference PDS's own pages, over a world seeded for
# the run (harness/e2e/world.mjs): the launcher, tiles, the strip, the
# player, an agent's tile over MCP, sharing. The other checks hold the code
# to its types and tests; this, that what a person does lands. Each flow
# that fails leaves the page as it was then among the check's outputs, as a
# picture.
#
# Node, the packages, Chromium, the libraries it needs and the build are
# kept between runs: nothing is fetched again until what it is made from
# changes.
image: rust:1.100
runners: [runner.knotless.dev]
# Every push to main, and pulls into it or a feature/ branch, at their
# heads merged with their base, that change the pages, the server, its
# views and lexicons, the world and harness the flows run over, or this
# file. A pull changing none passes at once, noted as skipped.
on:
push: {refs: [refs/heads/main]}
pull:
base: [refs/heads/main, refs/heads/feature/*]
paths: [web/**, crates/**, views/**, schemas/**, lexicons/**, Cargo.toml, Cargo.lock, harness/e2e/**, harness/pds.mjs, harness/tls-proxy.mjs, harness/package.json, harness/package-lock.json, .knotless/workflows/e2e.yml, .knotless/uses.lock]
cache: [target, /usr/local/cargo/registry, /usr/local/rustup, /opt/node, /opt/browsers, /var/cache/apt/archives, web/node_modules, harness/node_modules]
env:
# The image's toolchain, over the cached rustup's default (check.yml).
RUSTUP_TOOLCHAIN: "1.100.0"
PLAYWRIGHT_BROWSERS_PATH: /opt/browsers
steps:
- uses: chadtmiller.com/steps/node@1
with: {version: 24.22.1}
- uses: chadtmiller.com/steps/npm-ci@1
name: pages' packages
with: {dir: web}
- uses: chadtmiller.com/steps/npm-ci@1
name: harness
with: {dir: harness}
- name: chromium
run: |
cd harness
# The browser, into /opt/browsers once for each Playwright version.
npx playwright install chromium
# The libraries it needs, as Playwright installs them with apt. Its
# .debs are kept in the cache, so a run after the first downloads
# none, only apt's lists; the image deletes them after each install
# (docker-clean) unless told not to. (Playwright's --dry-run, which
# knotless's e2e reads the packages from, now asks apt itself, and
# fails before any lists are fetched.)
rm -f /etc/apt/apt.conf.d/docker-clean
npx playwright install-deps chromium > /tmp/deps.log 2>&1 || { cat /tmp/deps.log; exit 1; }
tail -1 /tmp/deps.log
- name: build
run: |
# The pages first: hud-server embeds them.
(cd web && npm run build)
cargo build -p hud --locked
- name: flows
run: |
status=0
(cd harness && npx playwright test -c e2e/playwright.config.mjs) || status=$?
# The page each failed flow ended on, named for the flow.
if [ -n "${KNOTLESS_RUN_OUTPUTS:-}" ] && [ -d target/e2e/results ]; then
for shot in target/e2e/results/*/test-failed-*.png; do
[ -f "$shot" ] && cp "$shot" "$KNOTLESS_RUN_OUTPUTS/$(basename "$(dirname "$shot")").png"
done
fi
exit $status
.knotless/workflows/lexicons.ymlnew+22−0
@@ -0,0 +1,22 @@
# HUD's own lexicons (schemas/), as `just lex` checks them: goat's lint,
# less the warnings kept on purpose, what it does not see, and that each
# only grows from main's (harness/lexicons.mjs). The answers hud-server's
# tests receive are held to them in test.yml. goat is kept between runs.
image: node:24.22.1
runners: [runner.knotless.dev]
# Every push to main, and pulls into it or a feature/ branch, at their
# heads merged with their base, that change the lexicons, their check or
# this file. A pull changing none passes at once, noted as skipped.
on:
push: {refs: [refs/heads/main]}
pull:
base: [refs/heads/main, refs/heads/feature/*]
paths: [schemas/**, harness/lexicons.mjs, .knotless/workflows/lexicons.yml]
cache: [/opt/goat]
steps:
- name: goat
run: |
[ -x /opt/goat/goat ] || { mkdir -p /opt/goat && curl -fsSL https://github.com/bluesky-social/goat/releases/download/v0.2.6/goat_Linux_x86_64.tar.gz | tar -xz -C /opt/goat goat; }
/opt/goat/goat --version
- name: lexicons
run: PATH=/opt/goat:$PATH node harness/lexicons.mjs
.knotless/workflows/lexicons.ymlline 22
review.knotless.dev

With no argument, harness/lexicons.mjs works out its base by running git merge-base HEAD main. If that fails, for example on a detached checkout with no local main, it silently uses no base and skips both the "only grown" check and the bare-array check. Check that this run's log ends with "only grown since <sha>". If it doesn't, pass the base commit explicitly.

.knotless/workflows/test.ymlnew+38−0
@@ -0,0 +1,38 @@
# The tests, as `just check` and `just lex` run them: every crate's, then
# every XRPC answer hud-server's tests received, held to its method's
# lexicon (harness/answers.mjs), as the workspace's types are made from
# them. hud-server embeds the built pages, so they are built first.
#
# The build, the toolchain, Node, the pages' packages and @atproto/lexicon
# are kept between runs.
image: rust:1.100
# A pre-flight, as check is: the merge queue takes a pull into a batch only
# once this has passed at its head.
queue: first
runners: [runner.knotless.dev]
on:
push: {refs: [refs/heads/main]}
pull: {base: [refs/heads/main, refs/heads/feature/*]}
cache: [target, /usr/local/cargo/registry, /usr/local/rustup, /opt/node, /opt/lexicon, web/node_modules]
env:
# The image's toolchain, over the cached rustup's default (check.yml).
RUSTUP_TOOLCHAIN: "1.100.0"
steps:
- uses: chadtmiller.com/steps/node@1
with: {version: 24.22.1}
- uses: chadtmiller.com/steps/npm-ci@1
name: pages' packages
with: {dir: web}
- name: pages
run: cd web && npm run build
- name: test
run: |
rm -rf target/answers
HUD_ANSWERS="$PWD/target/answers" cargo test --workspace --locked
- name: answers
run: |
# With the harness's @atproto/lexicon alone, rather than all of its
# packages (a PDS among them).
v=$(node -p "require('./harness/package.json').dependencies['@atproto/lexicon']")
[ -d "/opt/lexicon/$v/node_modules/@atproto/lexicon" ] || npm install --prefix "/opt/lexicon/$v" --no-audit --no-fund "@atproto/lexicon@$v"
NODE_PATH="/opt/lexicon/$v/node_modules" node harness/answers.mjs target/answers
.knotless/workflows/web.ymlnew+31−0
@@ -0,0 +1,31 @@
# The workspace's pages, as `just check` and `just lint` check them:
# svelte-check, which fails on any warning, over types made from HUD's
# lexicons; each component using only its own layer and those below
# (harness/layers.mjs); and every text colour at WCAG AA on what it is
# drawn on, in light and dark (harness/contrast.mjs). The packages are kept
# between runs and installed again only when the lockfile changes.
image: node:24.22.1
# A pre-flight: the merge queue takes a pull into a batch only once this
# has passed at its head. It takes seconds.
queue: first
runners: [runner.knotless.dev]
# Every push to main, and pulls into it or a feature/ branch, at their
# heads merged with their base, that change the pages, the lexicons their
# types are made from, the checks, or this file. A pull changing none
# passes at once, noted as skipped.
on:
push: {refs: [refs/heads/main]}
pull:
base: [refs/heads/main, refs/heads/feature/*]
paths: [web/**, schemas/**, harness/layers.mjs, harness/contrast.mjs, harness/contrast.json, .knotless/workflows/web.yml, .knotless/uses.lock]
cache: [web/node_modules]
steps:
- uses: chadtmiller.com/steps/npm-ci@1
name: packages
with: {dir: web}
- name: layers
run: node harness/layers.mjs
- name: contrast
run: node harness/contrast.mjs
- name: svelte-check
run: cd web && npm run check
.knotless/uses.locknew+13−0
@@ -0,0 +1,13 @@
# Written by `knotless workflow pin`. Commit it: runs read it.
chadtmiller.com/steps/node@1:
version: 1.0.0
commit: 686cdbb38978730bb1ba5d1c999967e48497ce15
release: at://did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.release/3mza7iq7tundv.qespbvwvof6xwjdaedpzq3koia.sjjb7q6l3fsl3spvqsuzdoe73w
chadtmiller.com/steps/npm-ci@1:
version: 1.0.0
commit: 686cdbb38978730bb1ba5d1c999967e48497ce15
release: at://did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.release/3mza7iq7tundv.dzyz2ceqihhxzgk2f2637ygpfw.sjjb7q6l3fsl3spvqsuzdoe73w
chadtmiller.com/steps/rust-lint@1:
version: 1.0.0
commit: 686cdbb38978730bb1ba5d1c999967e48497ce15
release: at://did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.release/3mza7iq7tundv.zvxvlxa6fe7s4pnwsnmgmm63aj.sjjb7q6l3fsl3spvqsuzdoe73w
harness/e2e/launcher.spec.mjs+6−4
@@ -1,6 +1,7 @@
// The launcher's apps: the queries bundled views offer (their `launch`),
// listed by app beside the person's collections. Picking one turns the
// launcher into that query's tile, its params the person's. The world's
// which a search finds, listed under their app (unsearched, it shows the
// person's apps and feeds). Picking one turns the launcher into that
// query's tile, its params the person's. The world's
// accounts are on no knotless appview, so this holds the tile to its call
// (getCanvas), not its drawing; and it takes the tile off again, leaving
// carol's canvas as the flows after it find it.
@@ -12,9 +13,10 @@ test('a launcher row of an app opens its query as a tile, as the person', async
const page = await context.newPage();
await signIn(page, 'carol');
const launcher = page.getByRole('main', { name: 'Columns' }).getByRole('region', { name: 'Open' });
await expect(launcher.getByRole('heading', { name: 'knotless' })).toBeVisible();
// Search finds it.
await expect(launcher.getByRole('heading', { name: 'Your apps' })).toBeVisible();
// Search finds it, under its app.
await launcher.getByRole('searchbox').fill('repositories');
await expect(launcher.getByRole('heading', { name: 'knotless' })).toBeVisible();
await launcher.getByRole('option', { name: /Repositories/ }).click();
await expect(launcher).toHaveCount(0);
const xrpc = (method, params) =>
harness/e2e/workspace.spec.mjs+46−41
@@ -1,7 +1,8 @@
// The workspace's acceptance flows, in order, as alice and then bob use
// it: signing in, the launcher, a thread opened beside its source, what a
// reload keeps, an agent's tile over MCP, a canvas shared to a viewer, and
// opening what is open already: written otherwise, or on another canvas.
// it: signing in, an app's page from the launcher, a thread opened beside
// its source, what a reload keeps, an agent's tile over MCP, a canvas
// shared to a viewer, and opening what is open already: written
// otherwise, or on another canvas.
import { expect, mcpCall, mcpToken, signIn, test, who, world } from './pages.mjs';
@@ -38,10 +39,26 @@ const columns = (p = page) =>
const technical = /\b[a-z]+\.[a-z]+\.[a-z.]+\b|did:|at:\/\/|\b(?=[a-z2-7]*[2-7])[a-z2-7]{13}\b/;
/** The tiles the flows open, by id. */
let profileId = '';
let pageId = '';
let postsId = '';
/** A posts tile's link to alice's first post, as a reply of hers names it. */
const firstPost = (posts) => posts.getByRole('button', { name: world.posts[0], exact: true }).first();
const tabs = (p = page) => p.getByRole('tablist', { name: 'Canvases' }).getByRole('tab');
const launcher = (p = page) => strip(p).getByRole('region', { name: 'Open' });
/** Add a tile to a canvas as the page does, its answer. */
const addTile = (canvas, tool, args, title) =>
page.evaluate(
async (body) => {
const res = await fetch('/xrpc/place.hud.addTile', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/json', 'X-HUD': '1' },
body: JSON.stringify(body),
});
return res.json();
},
{ canvas, tool, arguments: args, title },
);
test('signing in as alice lands on the workspace, one tab and a launcher', async () => {
await signIn(page, 'alice');
@@ -50,22 +67,23 @@ test('signing in as alice lands on the workspace, one tab and a launcher', async
await expect(launcher().getByText('Alice', { exact: true })).toBeVisible();
});
test('a collection picked in the launcher turns its column into that tile, its details a click away', async () => {
await launcher().getByText(/^All collections/).click();
await launcher().getByRole('option', { name: /actor\.profile/ }).click();
test('an app picked in the launcher turns its column into its page, its details a click away', async () => {
// Your apps: Bluesky, the one alice's repository holds.
await launcher().getByRole('listbox', { name: 'Your apps' }).getByRole('option', { name: 'Bluesky' }).click();
await expect(launcher()).toHaveCount(0);
const profile = strip().locator('article[data-tile]');
await expect(profile).toHaveCount(1);
profileId = await profile.getAttribute('data-tile');
expect((await columns()).map((c) => c.tiles)).toEqual([[profileId]]);
await expect(profile.getByText('Testing HUD')).toBeVisible();
// Its header: a title as people read it, and the account by its handle, never its DID (a `.test` handle resolves nowhere, so none shows here); the call is in its details.
const head = profile.locator(':scope > header');
const app = strip().locator('article[data-tile]');
await expect(app).toHaveCount(1);
pageId = await app.getAttribute('data-tile');
expect((await columns()).map((c) => c.tiles)).toEqual([[pageId]]);
// Where to go in it. (Bluesky's AppView knows no account of this world's: the profile and posts it draws stay empty.)
await expect(app.getByRole('button', { name: 'Open app.bsky.feed.getTimeline' })).toBeVisible();
// Its header: a title as people read it, and whose it is, never a DID; the call is in its details.
const head = app.locator(':scope > header');
await expect(head.getByRole('heading')).not.toHaveText(technical);
await expect(head).not.toContainText('did:', { useInnerText: true });
await head.locator('summary[aria-label="Details"]').click();
const details = head.locator('details[open]');
await expect(details).toContainText('"collection": "app.bsky.actor.profile"');
await expect(details).toContainText('"domain": "bsky.app"');
await expect(details).toContainText(who.alice.did);
await expect(details.getByRole('button', { name: 'Copy call' })).toBeVisible();
await page.keyboard.press('Escape');
@@ -73,23 +91,25 @@ test('a collection picked in the launcher turns its column into that tile, its d
});
test('a thread opened from a posts tile lands right of its source', async () => {
// Alice's posts, a column of their own, moved left of her profile.
await page.keyboard.press('t');
await launcher().getByRole('option', { name: /Bluesky posts/ }).click();
const posts = tile('Bluesky posts');
// Alice's posts as her repository holds them, a column of their own, moved left of Bluesky's page. The launcher offers her posts as Bluesky's AppView has them, which knows no account of this world's, and never a collection: they are put on the canvas by their call, as the page does.
const canvas = await tabs().first().getAttribute('data-tab');
const added = await addTile(canvas, 'list_records', { actor: who.alice.did, collection: 'app.bsky.feed.post' });
postsId = added.tile.key;
const posts = tileById(postsId);
await expect(posts.getByText('Hello from the harness')).toBeVisible();
postsId = await posts.getAttribute('data-tile');
await posts.locator(':scope > header').getByRole('heading').click();
await expect(posts).toHaveClass(/\bfocused\b/);
await page.keyboard.press('Shift+ArrowLeft');
await expect.poll(async () => (await columns()).map((c) => c.tiles[0])).toEqual([postsId, profileId]);
await posts.getByRole('button', { name: `Open app.bsky.feed.getPostThread ${world.posts[0]}` }).click();
await expect.poll(async () => (await columns()).map((c) => c.tiles[0])).toEqual([postsId, pageId]);
await firstPost(posts).click();
await expect.poll(async () => (await columns()).length).toBe(3);
const [, thread] = await columns();
expect(thread.tiles).toHaveLength(1);
const opened = tileById(thread.tiles[0]);
await expect(opened.locator(':scope > header').getByRole('heading')).not.toHaveText(technical);
// It says where it came from by its source's title.
await expect(opened.getByRole('button', { name: `← from ${await posts.getAttribute('aria-label')}` })).toBeVisible();
expect((await columns()).map((c) => c.tiles[0])).toEqual([postsId, thread.tiles[0], profileId]);
// It says where it came from by its source's title (its name begins with the "·" drawn before it).
await expect(opened.getByRole('button', { name: new RegExp(`from ${await posts.getAttribute('aria-label')}$`) })).toBeVisible();
expect((await columns()).map((c) => c.tiles[0])).toEqual([postsId, thread.tiles[0], pageId]);
});
test('a reload keeps the columns’ order and widths, and the open tabs', async () => {
@@ -125,7 +145,7 @@ test('opening a tile that is open already brings its column into view, adding no
});
await expect(posts).toBeInViewport({ ratio: 0.9 });
await expect(opened).not.toBeInViewport({ ratio: 0.5 });
await posts.getByRole('button', { name: `Open app.bsky.feed.getPostThread ${world.posts[0]}` }).click();
await firstPost(posts).click();
await expect(opened).toBeInViewport({ ratio: 0.9 });
expect(await columns()).toEqual(before);
} finally {
@@ -224,21 +244,6 @@ test('a new canvas’s name is typed in its tab straight away', async () => {
await expect(tabs().filter({ hasText: 'Typed at once' })).toHaveAttribute('aria-selected', 'true');
});
/** Add a tile to a canvas as the page does, its answer. */
const addTile = (canvas, tool, args, title) =>
page.evaluate(
async (body) => {
const res = await fetch('/xrpc/place.hud.addTile', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/json', 'X-HUD': '1' },
body: JSON.stringify(body),
});
return res.json();
},
{ canvas, tool, arguments: args, title },
);
/** A tile whose one link names alice as `href`: by handle or by DID. */
const linkTo = (href, label) => ({
uri: `at://${who.alice.did}/app.bsky.actor.profile/self`,
harness/e2e/world.mjs+8−5
@@ -34,15 +34,18 @@ function firstLine(child, what) {
});
}
/// A port nothing listens on, from `from` up.
/// A port nothing listens on, from `from` up: free on IPv6's any address
/// as on IPv4's loopback, as a server elsewhere on `::` takes loopback's
/// connections too, and would answer for HUD.
async function freePort(from) {
for (let port = from; port < from + 100; port++) {
const free = await new Promise((done) => {
const free = (port, host) =>
new Promise((done) => {
const server = createServer();
server.once('error', () => done(false));
server.listen(port, '127.0.0.1', () => server.close(() => done(true)));
server.listen(port, host, () => server.close(() => done(true)));
});
if (free) return port;
for (let port = from; port < from + 100; port++) {
if ((await free(port, '127.0.0.1')) && (await free(port, '::'))) return port;
harness/e2e/world.mjsline 48
review.knotless.dev

On a host with IPv6 disabled, listen(port, '::') fails with EAFNOSUPPORT on every port, so this throws "no free port". Treating that error code as free (nothing can listen on :: there anyway) would keep just e2e working on such hosts. Not blocking: it passes on the runner.

}
throw new Error(`no free port from ${from}`);
}
AGENTS.md+7−1
@@ -83,7 +83,13 @@ versions in the root `Cargo.toml`'s `[workspace.dependencies]`.
- Cargo through rustup: `rustup run stable cargo` (the Justfile's `cargo`).
Node is the version `.node-version` names; `cd web && npm ci` once.
- `just check` is what a change must pass: rustfmt, clippy with warnings
denied, the tests, svelte-check, `just lint` and `just lex`.
denied, the tests, svelte-check, `just lint` and `just lex`. The runner
(runner.knotless.dev) runs the same on pushes to main and pulls into it
(`.knotless/workflows/`): `check`, `test` and `web` as the merge queue's
pre-flights, `lexicons`, and `e2e` (`just e2e`). `main` takes pulls
only through the merge queue, each once review.knotless.dev has
reviewed its head. A workflow's shared steps are pinned in
`.knotless/uses.lock` (`knotless workflow pin`).
- A lexicon in `schemas/` follows the Lexicon Style Guide
(https://atproto.com/guides/lexinomicon) and passes `just lex`: goat's
lint (less the warnings `harness/lexicons.mjs` keeps, each with why),