Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
915a811
test(mobile): cover design and motion tokens (#230)
aditya9515 Dec 6, 2026
1ddb62e
test(core): check the A2A task states table against itself (#223)
aditya9515 Dec 6, 2026
1d16fe2
test(mail): cover how a request picks the email account (#219)
aditya9515 Dec 6, 2026
ffc5577
test(mail): cover the date, base64, forward and batch helpers (#220)
aditya9515 Dec 6, 2026
616a0b5
test(mail): cover decodeCharset and headerParams by name (#221)
aditya9515 Dec 6, 2026
3800c4c
test(night): cover the window and briefing on clock-change nights (#222)
aditya9515 Dec 6, 2026
f0003ca
docs(core): read the agent card version as the card's own (#133, #211)
aditya9515 Dec 6, 2026
2dc1e3a
test(copy,site): keep locale copy free of small slips (#226)
aditya9515 Dec 6, 2026
8d6ff59
docs(copy): explain how copy is added and checked (#225)
aditya9515 Dec 6, 2026
e293cae
test(scripts): check relative links and anchors in the docs (#228)
aditya9515 Dec 6, 2026
af17cf2
test(site): check the download page's release fields (#229)
aditya9515 Dec 6, 2026
43c04fb
test(site): hold the release check either way, published or not (#229)
aditya9515 Dec 6, 2026
6f4cd9d
docs(site): describe the website, its commands and its checks (#224)
aditya9515 Dec 6, 2026
b6510d4
fix(preview): stop early with no build or no matching shot (#227)
aditya9515 Dec 6, 2026
3ab65b5
test(night): cover the bots' news lines and their types (#218)
aditya9515 Dec 6, 2026
336dab1
test(night): assert the bot's quoted words stay out of the lines (#218)
aditya9515 Dec 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ The rules live in [AGENTS.md](AGENTS.md). Read its non-negotiables before your f
- Report a bug, with steps to reproduce and no personal data.
- Propose a feature. Read [VISION.md](VISION.md) first.
- Run Hermit on your phone and send device data: [docs/devices.md](docs/devices.md) explains how.
- Improve the docs, or the Spanish and English copy.
- Improve the docs, or the Spanish and English copy. [How copy works](packages/copy/README.md) explains how to add a
string.
- Review open pull requests. Reading and running someone's change helps too.

## Set up
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "module",
"scripts": {
"build": "node build.mjs",
"test": "node --test device-lab.test.mjs browser.test.mjs",
"test": "node --test device-lab.test.mjs browser.test.mjs pick.test.mjs",
"shoot": "node shoot.mjs",
"compress": "python3 -c \"import glob; from PIL import Image; [Image.open(f).convert('RGB').quantize(colors=256, dither=Image.Dither.NONE).save(f, optimize=True) for f in glob.glob('out/screens/*.png')]\"",
"clips": "node clips.mjs",
Expand Down
16 changes: 16 additions & 0 deletions apps/mobile/preview/pick.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Dev-only and pure: the shots one run of shoot.mjs takes, so the filter can be checked without a browser.
// A shot is taken for each of its themes and languages, as a file named `${shot.file}-${theme}-${lang}.png`;
// a filter keeps only the files that contain it, as the loop in shoot.mjs always did.
export function pickShots(shots, filter) {
const picked = [];
for (const shot of shots) {
for (const theme of shot.themes) {
for (const lang of shot.langs) {
const file = `${shot.file}-${theme}-${lang}.png`;
if (filter && !file.includes(filter)) continue;
picked.push({ shot, theme, lang, file });
}
}
}
return picked;
}
49 changes: 49 additions & 0 deletions apps/mobile/preview/pick.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// #227: which shots a run takes. Pure picking, so the filter can be checked without a browser.
import { test } from "node:test";
import assert from "node:assert/strict";
import { pickShots } from "./pick.mjs";

const shots = [
{ file: "about", themes: ["light", "dark"], langs: ["es-419", "en"] },
{ file: "wallet-home", themes: ["light"], langs: ["es-419"] },
{ file: "bot-chat", themes: ["dark"], langs: ["en", "es-419"] },
];

test("no filter keeps every theme and language of every shot, in order", () => {
const picked = pickShots(shots, undefined);
assert.deepEqual(picked.map((p) => p.file), [
"about-light-es-419.png",
"about-light-en.png",
"about-dark-es-419.png",
"about-dark-en.png",
"wallet-home-light-es-419.png",
"bot-chat-dark-en.png",
"bot-chat-dark-es-419.png",
]);
assert.equal(picked[0].shot, shots[0]);
assert.deepEqual(picked.map((p) => [p.theme, p.lang]), [
["light", "es-419"],
["light", "en"],
["dark", "es-419"],
["dark", "en"],
["light", "es-419"],
["dark", "en"],
["dark", "es-419"],
]);
});

test("an empty filter is no filter, as the loop in shoot.mjs treats it", () => {
assert.equal(pickShots(shots, "").length, 7);
});

test("a filter keeps only the files that contain it", () => {
assert.deepEqual(pickShots(shots, "wallet").map((p) => p.file), ["wallet-home-light-es-419.png"]);
assert.equal(pickShots(shots, "about").length, 4);
// The filter matches the whole file name, theme and language included, as before.
assert.deepEqual(pickShots(shots, "dark-en").map((p) => p.file), ["about-dark-en.png", "bot-chat-dark-en.png"]);
});

test("a filter that matches nothing gives an empty list", () => {
assert.deepEqual(pickShots(shots, "abuot"), []);
assert.deepEqual(pickShots(shots, "nothing-matches-this"), []);
});
87 changes: 46 additions & 41 deletions apps/mobile/preview/shoot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,23 @@ import { fileURLToPath } from "node:url";
import { chromium } from "playwright-core";
import { chromiumPath } from "./browser.mjs";
import { shots } from "./shots.mjs";
import { pickShots } from "./pick.mjs";
import { audit, words } from "./audit.mjs";

const here = dirname(fileURLToPath(import.meta.url));
const dist = join(here, "dist");
const outDir = join(here, "out/screens");

const filter = process.argv[2];
if (!existsSync(join(dist, "index.html"))) {
console.error("No build found. Run pnpm build first.");
process.exit(1);
}
const picks = pickShots(shots, filter);
if (!picks.length) {
console.error(`No shot matches "${filter}". Examples: ${shots.slice(0, 3).map((s) => s.file).join(", ")}.`);
process.exit(1);
}
mkdirSync(outDir, { recursive: true });

const types = { ".html": "text/html", ".js": "text/javascript", ".png": "image/png", ".json": "application/json", ".ttf": "font/ttf" };
Expand All @@ -29,50 +41,43 @@ const server = createServer((req, res) => {
await new Promise((r) => server.listen(0, "127.0.0.1", r));
const base = `http://127.0.0.1:${server.address().port}/`;

const filter = process.argv[2];
const browser = await chromium.launch({ executablePath: chromiumPath() });
const results = [];
for (const shot of shots) {
for (const theme of shot.themes) {
for (const lang of shot.langs) {
const file = `${shot.file}-${theme}-${lang}.png`;
if (filter && !file.includes(filter)) continue;
const ctx = await browser.newContext({ viewport: { width: 412, height: 915 }, deviceScaleFactor: 2, locale: lang, colorScheme: theme });
const page = await ctx.newPage();
const consoleErrors = [];
// React DOM's nesting warnings (a Pressable inside a Pressable becomes <button> in <button>) are web-only.
page.on("console", (m) => m.type() === "error" && !/cannot be a descendant of|cannot contain a nested/.test(m.text()) && consoleErrors.push(m.text()));
page.on("pageerror", (e) => consoleErrors.push(String(e.stack ?? e)));
const q = new URLSearchParams({ screen: shot.route, theme, lang, variant: shot.variant ?? "", params: JSON.stringify(typeof shot.params === "function" ? shot.params(lang) : shot.params ?? {}), fontScale: String(shot.fontScale ?? 1) });
await page.goto(`${base}?${q}`);
await page.waitForTimeout(shot.wait ?? 900);
// The brand faces have loaded before anything is captured (font-display: block, then this wait).
await page.evaluate(() => document.fonts.ready);
if (shot.act) await shot.act(page).catch((e) => consoleErrors.push(`act: ${e.message}`));
await page.screenshot({ path: join(outDir, file) });
// Contrast measured on this very picture, touch targets, and the words on screen (docs/design/polish).
const checks = await audit(page).catch((e) => ({ error: String(e) }));
const text = await words(page).catch(() => []);
// A screen that scrolls also gets a full-length picture: the window is made as tall as its content.
const hidden = await page.evaluate(() => Math.max(0, ...[...document.querySelectorAll("#root *")].map((el) => {
const o = getComputedStyle(el).overflowY;
return o === "auto" || o === "scroll" ? el.scrollHeight - el.clientHeight : 0;
})));
let full = "";
if (hidden > 40) {
full = file.replace(/\.png$/, "-full.png");
await page.setViewportSize({ width: 412, height: Math.min(915 + hidden, 6000) });
await page.waitForTimeout(400);
await page.screenshot({ path: join(outDir, full) });
}
const errors = [...(await page.evaluate(() => window.__errors ?? [])), ...consoleErrors];
results.push({ file, full, id: shot.id, name: shot.name, route: shot.route, variant: shot.variant ?? "", theme, lang, fontScale: shot.fontScale ?? 1, note: shot.note ?? "", mockup: shot.mockup ? `${shot.mockup}-${theme}-${lang}.png` : "", errors, audit: checks, words: text });
const slips = checks.slips ?? [];
const fails = checks.error ? `audit error ${checks.error.slice(0, 80)}` : `${checks.text.length} contrast, ${checks.icons.length} icons, ${checks.targets.length} targets, ${slips.length} slips${slips.length ? ` (${slips.map((x) => `${x.kind}: ${x.text}`).join("; ").slice(0, 200)})` : ""}`;
console.log(`${errors.length || checks.error || checks.text.length || checks.icons.length || checks.targets.length || slips.length ? "!" : " "} ${file} ${fails}${errors.length ? ` ${errors[0].split("\n")[0].slice(0, 160)}` : ""}`);
await ctx.close();
}
for (const { shot, theme, lang, file } of picks) {
const ctx = await browser.newContext({ viewport: { width: 412, height: 915 }, deviceScaleFactor: 2, locale: lang, colorScheme: theme });
const page = await ctx.newPage();
const consoleErrors = [];
// React DOM's nesting warnings (a Pressable inside a Pressable becomes <button> in <button>) are web-only.
page.on("console", (m) => m.type() === "error" && !/cannot be a descendant of|cannot contain a nested/.test(m.text()) && consoleErrors.push(m.text()));
page.on("pageerror", (e) => consoleErrors.push(String(e.stack ?? e)));
const q = new URLSearchParams({ screen: shot.route, theme, lang, variant: shot.variant ?? "", params: JSON.stringify(typeof shot.params === "function" ? shot.params(lang) : shot.params ?? {}), fontScale: String(shot.fontScale ?? 1) });
await page.goto(`${base}?${q}`);
await page.waitForTimeout(shot.wait ?? 900);
// The brand faces have loaded before anything is captured (font-display: block, then this wait).
await page.evaluate(() => document.fonts.ready);
if (shot.act) await shot.act(page).catch((e) => consoleErrors.push(`act: ${e.message}`));
await page.screenshot({ path: join(outDir, file) });
// Contrast measured on this very picture, touch targets, and the words on screen (docs/design/polish).
const checks = await audit(page).catch((e) => ({ error: String(e) }));
const text = await words(page).catch(() => []);
// A screen that scrolls also gets a full-length picture: the window is made as tall as its content.
const hidden = await page.evaluate(() => Math.max(0, ...[...document.querySelectorAll("#root *")].map((el) => {
const o = getComputedStyle(el).overflowY;
return o === "auto" || o === "scroll" ? el.scrollHeight - el.clientHeight : 0;
})));
let full = "";
if (hidden > 40) {
full = file.replace(/\.png$/, "-full.png");
await page.setViewportSize({ width: 412, height: Math.min(915 + hidden, 6000) });
await page.waitForTimeout(400);
await page.screenshot({ path: join(outDir, full) });
}
const errors = [...(await page.evaluate(() => window.__errors ?? [])), ...consoleErrors];
results.push({ file, full, id: shot.id, name: shot.name, route: shot.route, variant: shot.variant ?? "", theme, lang, fontScale: shot.fontScale ?? 1, note: shot.note ?? "", mockup: shot.mockup ? `${shot.mockup}-${theme}-${lang}.png` : "", errors, audit: checks, words: text });
const slips = checks.slips ?? [];
const fails = checks.error ? `audit error ${checks.error.slice(0, 80)}` : `${checks.text.length} contrast, ${checks.icons.length} icons, ${checks.targets.length} targets, ${slips.length} slips${slips.length ? ` (${slips.map((x) => `${x.kind}: ${x.text}`).join("; ").slice(0, 200)})` : ""}`;
console.log(`${errors.length || checks.error || checks.text.length || checks.icons.length || checks.targets.length || slips.length ? "!" : " "} ${file} ${fails}${errors.length ? ` ${errors[0].split("\n")[0].slice(0, 160)}` : ""}`);
await ctx.close();
}
await browser.close();
server.close();
Expand Down
73 changes: 73 additions & 0 deletions apps/mobile/src/tokens.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/// <reference types="node" />
// Hermit's design tokens (docs/design/polish/decisions.md): every color is a docs/brand/tokens.json value, or a mix of
// two of them (mix): the surfaces between the canvas and white, the tonal fills between a surface and an accent, and
// the scrims. Light is Quiet craft; dark is Deep sea. The motion tokens live beside them (docs/design/polish/decisions.md,
// "Motion"): plain numbers, no animation library.
import { test } from "node:test";
import assert from "node:assert/strict";
import { mix } from "./theme.ts";
import { duration, easing, stagger, staggerDelay } from "./motion.ts";

test("mix(a, b, t) holds at a when t is 0 and at b when t is 1", () => {
assert.equal(mix("#F5EDE1", "#B4483A", 0), "#F5EDE1");
assert.equal(mix("#F5EDE1", "#B4483A", 1), "#B4483A");
});

test("mix rounds to a whole hex channel at the midpoint", () => {
// Half of #000000 → #808080: the blend rounds, it does not truncate.
assert.equal(mix("#000000", "#FFFFFF", 0.5), "#808080");
});

test("mix answers in uppercase #RRGGBB even when the inputs are lowercase", () => {
assert.match(mix("#ffffff", "#2b221b", 0.5), /^#[0-9A-F]{6}$/);
});

test("mix keeps every channel between the two inputs while t is between 0 and 1", () => {
const pairs: Array<[string, string]> = [
["#000000", "#FFFFFF"],
["#06121D", "#5EF0CF"],
["#2B221B", "#8A5912"],
];
for (const [a, b] of pairs) {
for (const t of [0.25, 0.5, 0.75]) {
const c = mix(a, b, t);
const blend = [0, 1, 2].map((i) => parseInt(c.slice(1 + i * 2, 3 + i * 2), 16));
const from = [0, 1, 2].map((i) => parseInt(a.slice(1 + i * 2, 3 + i * 2), 16));
const to = [0, 1, 2].map((i) => parseInt(b.slice(1 + i * 2, 3 + i * 2), 16));
for (let i = 0; i < 3; i++) {
assert.ok(
blend[i] >= Math.min(from[i], to[i]) && blend[i] <= Math.max(from[i], to[i]),
`channel ${i} of ${c} should stay between ${a} and ${b} at t=${t}`,
);
}
}
}
});

test("staggerDelay spaces items out by one step and stops at stagger.max", () => {
assert.equal(staggerDelay(0), 0);
assert.equal(staggerDelay(1), stagger.step);
assert.equal(staggerDelay(2), stagger.step * 2);
assert.equal(staggerDelay(stagger.max - 1), (stagger.max - 1) * stagger.step);
assert.equal(staggerDelay(stagger.max), stagger.max * stagger.step);
assert.equal(staggerDelay(stagger.max + 4), stagger.max * stagger.step);
});

test("duration tokens are positive whole milliseconds, a press is instant and sheet is the longest", () => {
const values = Object.values(duration);
for (const v of values) {
assert.ok(Number.isInteger(v), `duration ${v} should be a whole number of milliseconds`);
assert.ok(v > 0, `duration ${v} should be positive`);
}
assert.ok(duration.press < 100, `a press should read as instant, got ${duration.press}`);
assert.equal(duration.sheet, Math.max(...values), `sheet should be the longest duration, got ${duration.sheet}`);
});

test("easing curves are four numbers whose control-x values sit between 0 and 1", () => {
for (const curve of Object.values(easing)) {
assert.equal(curve.length, 4, `a cubic-bezier needs four numbers, got ${curve.length}`);
for (const x of [curve[0], curve[2]]) {
assert.ok(x >= 0 && x <= 1, `a cubic-bezier x value should sit between 0 and 1, got ${x}`);
}
}
});
77 changes: 77 additions & 0 deletions apps/site/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Hermit website

The website at [joinhermit.com](https://joinhermit.com) lives in `apps/site`. It is a
static export: no server functions, cookies, analytics or third-party scripts. English
pages are under `/en/` and Spanish pages under `/es/`, each with a privacy page and a
download page. The root address is a language chooser; on Vercel the browser's language
decides before the chooser is reached.

`next build` writes plain files to `out/`, and no page needs JavaScript.
[`scripts/finalize.mjs`](scripts/finalize.mjs), run at the end of the build, removes every
script tag, preload and JavaScript or payload file Next leaves behind. The only scripts
that stay are the two inline theme scripts in [`lib/theme.mjs`](lib/theme.mjs), which set
the theme before the first paint and run its switch. The content security policy in
[`vercel.json`](vercel.json) allows exactly those two, by hash, and nothing else.

## Commands

From the repository root, after `pnpm install`:

```sh
pnpm --filter @hermit/site build
pnpm --filter @hermit/site check
pnpm --filter @hermit/site test
pnpm --filter @hermit/site typecheck
```

- `build` copies the brand files, builds the static export into `apps/site/out` and
strips Next's scripts from it.
- `check` checks the built `out/` (run `build` first): the pages and styles load nothing
from elsewhere, no JavaScript is left but the two theme scripts, the partners line is as
[`lib/site-config.mjs`](lib/site-config.mjs) says, the brand files and store badges are
unmodified, and a published release has every field filled.
- `test` runs the Vitest tests: copy keys and placeholders, the release fields, badges,
theme and contrast, and the checks above on made-up pages.
- `typecheck` runs TypeScript over the site's source and tests.

These commands are written for macOS and Linux today. The build script sets its telemetry
variable the POSIX way, and `check` assumes forward slashes in file paths, so neither
behaves on Windows yet.

## Look at it

There is no dev script. Serve the built files with any static file server, for example
Python's, from the repository root:

```sh
python3 -m http.server 8000 --directory apps/site/out
```

Then open <http://localhost:8000/> and pick a language, or go straight to
<http://localhost:8000/en/> or <http://localhost:8000/es/>.

## Words

Every string a person sees is a key in [`locales/en.json`](locales/en.json) and
[`locales/es-419.json`](locales/es-419.json), with the same keys and the same
`{placeholders}` in both. The rules are the app copy's rules, from `packages/copy`: plain
words, short sentences, no em or en dashes, and Latin American Spanish that uses tú.
[`test/locales.test.ts`](test/locales.test.ts) holds the keys, placeholders and dashes to
that.

## Brand files

[`docs/brand`](../../docs/brand) is the source of truth, under the logo lock: the drawing
is served as it is, never redrawn or recolored. The build first runs
[`scripts/copy-brand.mjs`](scripts/copy-brand.mjs), which copies the files listed in
[`lib/brand.mjs`](lib/brand.mjs) from there into `public/brand`, byte for byte. `check`
fails if a served copy differs from its source.

## The download page

The download page reads [`lib/release.ts`](lib/release.ts): the APK's file name and link,
its SHA-256, the signing certificate's SHA-256 and the rebuild recipe's link. A maintainer
updates it for each preview release, following the tag and release steps in
[CONTRIBUTING.md, For maintainers](../../CONTRIBUTING.md#for-maintainers). While
`published` is false every field is a placeholder and the page shows its pending notice
instead.
Loading
Loading