Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Docs

# The docs held to the code (design/build.md), on every pull request and push to main, whatever it
# changes: ci.yml starts no run for a change to the docs alone.

on:
push:
branches:
- main
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
pull_request:
branches:
- main

permissions:
contents: read
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 22
# package.json names pnpm, which the action would look for to cache its store.
package-manager-cache: false
# No install: the script needs Node and git alone.
- run: node scripts/docs.mjs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ coverage

# local agent skills
.agents/
.claude/
skills-lock.json

# Generated by the runtime's build from its stylesheet's font list; `pnpm build` in packages/runtime.
Expand Down
7 changes: 4 additions & 3 deletions ACCESSIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ keyboard-only run found.
| The player (`<h5p-player>`) | one iframe and no controls of its own: whether focus can get into the content and out again, the frame's accessible name, fullscreen, how failures are reported | this project |
| The content type | every control, label, focus order, keyboard interaction, live region, caption and colour inside the frame | H5P, per content type and **per library version** |

The player does not change the content's markup: it serves the files in the package to the
H5P runtime unmodified. A content type behaves the same here as it does on h5p.com, Moodle or
WordPress with the same library version. H5P's own
The player serves the files in the package to the H5P runtime unmodified. Played untrusted, the
default, the content goes through the check an H5P site runs on it, which strips the markup its
libraries' semantics do not allow. A content type behaves the same here as it does on h5p.com,
Moodle or WordPress with the same library version. H5P's own
[accessibility report](https://h5p.com/pdfs/h5p-vpat-april-2026.pdf) and
[content-type recommendations](https://help.h5p.com/hc/en-us/articles/7505649072797-Content-types-recommendations)
are the reference for that part. They cover the content types upgraded to H5P's new look and
Expand Down
11 changes: 7 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ The player, by area:

Across the repository: build shape, types, publishing and Node versions (22 LTS or 24 LTS) in
[`design/build.md`](design/build.md), with the two rules for writing: **a comment is two lines at
most, and says why** (`pnpm comments` checks it), and **a doc is short, and true to the code**; tests and CI in [`design/testing.md`](design/testing.md);
licensing and names in [`design/licensing.md`](design/licensing.md), where the player is MIT and
carries no GPL code, reaching `@missing-elements/h5p-runtime` only over HTTP and `postMessage`; what
is not built yet in [`design/scope.md`](design/scope.md).
most, and says why** (`pnpm comments` checks it), and **a doc is short, and true to the code**
(`pnpm docs:check` checks what a script can read, and the
[`docs-check` skill](skills/docs-check/SKILL.md) reads the rest after a change); tests and CI in [`design/testing.md`](design/testing.md); licensing and names in
[`design/licensing.md`](design/licensing.md), where the player is MIT and carries no GPL code,
reaching `@missing-elements/h5p-runtime` only over HTTP and `postMessage`; what is not built yet
in [`design/scope.md`](design/scope.md).

## Commands

Expand All @@ -91,6 +93,7 @@ pnpm test:unit # fast, no browser
pnpm test:browser
pnpm typecheck # every package
pnpm lint # oxlint with type-aware rules; after typecheck
pnpm docs:check # where a doc and the code disagree; --changed lists the docs to read again
pnpm build # the player: types, element, both workers; builds the runtime package on the way
pnpm verify course.h5p # play a package in a headless browser and report whether it works
pnpm author build source.json course.h5p # after pnpm build, or the player's build:plan
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pnpm test:browser
pnpm typecheck
pnpm lint # after typecheck, whose declarations it reads
pnpm comments # a comment is two lines at most
pnpm docs:check # the docs say what the code does
pnpm build
```

Expand Down
8 changes: 6 additions & 2 deletions apps/skills/tests/front-matter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ describe("the skills' front matter", () => {
const front = /^---\n([\s\S]*?)\n---\n/.exec(text)?.[1]
expect(front, 'front matter between two --- lines').toBeDefined()
const fields = new Map<string, string>()
let nests = false
for (const line of front!.split('\n')) {
const [, key, value] = /^([a-z-]+): (.+)$/.exec(line) ?? []
// `metadata:` opens a map of indented lines: its `internal` keeps a skill out of an install.
if (line === 'metadata:') { nests = true; continue }
const [, indent, key, value] = /^( {2})?([a-z-]+): (.+)$/.exec(line) ?? []
expect(key, `"${line.slice(0, 40)}" is a key and a value`).toBeDefined()
expect(!indent || nests, `${key}: an indented line belongs under metadata:`).toBe(true)
expect(value, `${key}: a colon followed by a space or the line's end ends a plain value`).not.toMatch(/:(?: |$)/)
expect(value, `${key}: a space followed by # starts a comment`).not.toMatch(/ #/)
expect(value, `${key}: a plain value cannot start with an indicator`).not.toMatch(/^[-?:,[\]{}#&*!|>'"%@`]/)
fields.set(key, value)
if (!indent) fields.set(key, value)
}
expect(fields.get('name')).toBe(name)
expect(name).toMatch(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)
Expand Down
113 changes: 109 additions & 4 deletions design/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,115 @@ checkout, run `pnpm typecheck` first.

## Docs

**A doc is short, and true to the code** (#289). The READMEs, `docs/` and the demo's pages are for
people integrating the packages: what to do and what happens, with no history and no retelling of
this folder. Every claim is checked by running the command or reading the source; where a doc looks
wrong, the code settles it, never a comment or this folder's account of it.
**A doc is short, and true to the code** (#289). The READMEs, the licence notices, `docs/` and the
demo's pages are for people integrating the packages: what to do and what happens, with no history
and no retelling of this folder. Every claim is checked by running the command or reading the
source; where a doc looks wrong, the code settles it, never a comment or this folder's account of
it.

**The docs come from the code, never the other way round.** A doc that disagrees with the code is
changed. Code that looks wrong is reported and left alone: a sentence in a doc is not evidence of
what the code should do.

**`pnpm docs:check` holds the docs to what a script can read from the code** (#350).
`scripts/docs.mjs` lists each place where they disagree, and `docs.yml` runs it on every change, a
change to the docs alone included, which `ci.yml` starts no run for. It needs Node and git, no
install. It checks that:

- a link into the repository reaches a file, and its fragment a heading there;
- no file names the repository as it was before its rename;
- every package is in the README, `SECURITY.md`, both issue templates and `AGENTS.md`, and a count
of the packages and apps is right;
- a `pnpm` script, a package of ours or a skill that a doc names exists;
- a command's README and its usage text name the same options;
- `docs/libraries.md` and the embed command give the pack's sizes as `parts/index.json` has them;
- a version a doc or a page pins one of our packages at is the one its `package.json` has, so a
bump changes the pins in `docs/setup.md`, the runtime's README and the demo's setup page in the
same commit. A pin on main then names a version npm does not serve until `publish.yml` has run;
by hand, the pins were left a version behind twice in a month (2564304, 950f152);
- `docs/api.md` names every attribute the element reads, and every state, progress phase and
error code.

It skips vendored code, build output and the changelog. The skill's type files are read, since
only their second half is generated and the first is written by hand. A check
that can no longer read its source, as when a type is renamed or a file moved, is a miss that
names it, never a pass.

**What a script cannot read, a reader checks, against the sources `scripts/docs.json` gives each
doc.** The map names, for every README, `docs/` page, policy and skill, the files that decide what
it says: a path, a path ending in `/` for all below it, or `*` for one name. The check fails for
such a doc with no entry and for a path that is gone, so the map cannot go stale unseen.
`pnpm docs:check --changed [commit]` lists each source a change touched since the branch left
`origin/main`, or since the commit given, tests left out, with the command that shows its change
and the docs that describe it. A change already pushed to main is not after that line, so an
answer of nothing names the commit it looked from. With no `origin/main` and no commit given it
refuses, since `HEAD` in its place would answer nothing for a branch's commits. `--all [doc...]`
lists every doc with its sources, or the docs named, and refuses a name the map has no doc for.
The reading itself is the `docs-check` skill, in `skills/` beside the
ones for people integrating the packages, since `.claude/` is each person's own and not in the
repository: each finding cites the line of source that decides it, and is checked a second time
before a doc is changed. A copy of a claim under `design/` is reported, not changed, since there
the design may be what is right. The skill is marked `metadata.internal`, since `npx skills add`
offers what `skills/` holds: `skills` 1.10.1 offers it to people integrating the packages without
the mark, and with it only when asked for by name.

**A scan goes one doc at a time, each finished before the next.** Every doc with its sources is
292 KB of docs and 1.6 MB of code, more than one reader holds at once, so the skill's scan reads,
checks and changes a doc before it opens the next, and takes the docs to scan by name. A scan of
the whole repository is several such scans, a package or a folder each.

The reasons, from 2026-12-04. Two scans by hand found 9 stale claims and then 15 more, so a scan
finds what it happens to read; the second reading is there because 4 of those 15 were wrong. The
script checks what both scans checked by hand each time: links, names, lists, options and sizes.
Phrases of history ("up to 0.9", "no longer") stay with the reader: a pattern for them flagged 16
lines, 7 of them wrongly (another library's version, "loaded now") and the other 9 kept on purpose.

The skill's wording was measured on the weakest model, in a clone seeded with a changed default,
a changed option default and a removed option, beside a refactor nobody could notice, and scored
by the files each run left. Two wordings:

- Docs first, each with its sources, and a finding dropped where the code looked wrong. Of 2
runs, one read the docs of one source and passed over the six of the other; both left the check
failing over an option that the seed declared and never read, which they judged unfinished.
- Source by source, a line for each change a person could notice before any doc is read, a line
for each doc read, and the code never judged. 2 of 2 changed all five docs, left the copy under
`design/` and the code alone and ended with the check passing, in 22 and 32 tool calls. The
refactor changed nothing under either wording, in 5 tool calls and then 4.

A third round measured the commit to look from and the scan. The same change left uncommitted,
and committed and pushed and asked of as "my last commit", had all five docs changed each time,
in 24 tool calls. Two scans of five named docs, seeded with four wrong numbers and a sentence of
history, with one doc left clean, each put the five right, in 45 and 58 tool calls. One of them
changed two claims more, both true to the code and neither seeded: a statement released while
the page is hidden carries no revision, and the message for a package missing some of its
libraries.

The map was held against the history: 203 times a `feat`, `fix` or `perf` commit changed a doc
beside code, four docs at most. The code was a source the map gives that doc in 163 of them, and
in 172 once the sources that showed were added: the runtime's boot script for the API and resume
pages, the element for `docs/untrusted.md`, the author's library for both MCP servers. The other
31 are version numbers, folders since moved and docs changed in passing.

The docs those tests had not read were then scanned whole: ten scans of one to seven docs each,
21 to 56 tool calls a scan. Four found nothing. The other six raised 20 findings, each then held
against its source line by hand. 14 were drift and are fixed: a title's limit in bytes and not
characters, media formats a list left out, an encrypted entry said to be noted where it stops the
run. Five were history, and four of them went, the notices' too. The fifth stays, since it says
what happens now: npm on an older Node still installs an embed from before 1.0. One finding said
the same as the doc in other words, and was dropped. Two scans named sources the map lacked for a
doc, since added.

A review of the pull request raised 14 comments, 11 apart from repeats, and ten held. The check
took `1.2 MB` as said by a line saying `11.2 MB`, `--all` passed over a name the map lacks, and
`--changed` answered nothing where `HEAD` stood in for a missing `origin/main`. Three docs gave
the normalizer's `revision` as the whole of `context.revision`, which the libraries' part follows,
and two said a damaged entry stops a run that never reads it. The skill's first step said to
change the file a line names, and a line can name code: with a pack size seeded, a run on the
weakest model changed the doc, left the embed command's usage text and reported it, in 23 tool
calls. The eleventh asked for a run on every branch's push, which checks a pull request twice.
Its second review held three more: the skill's type files were out of every check, so a change to
the author's media list listed none of the four that name its formats; a map that has moved, and
a fragment such as `#%`, stopped the check with a stack trace.

**The README shows the product in pictures, each one re-made when what it shows changes.** They are
in `docs/media/`. Those of the site's pages, `player.png` and `scorm.png`, are rendered from the
Expand Down
7 changes: 5 additions & 2 deletions design/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ pnpm dev # vendors assets, builds fixtures, serves the demo on :51
pnpm test # every package: the player's unit + browser suites, the normalizer's and verifier's tests
pnpm test:unit # fast, no browser
pnpm test:browser
H5P_TEST_BROWSER=firefox pnpm test:engine # the player's browser suite and the app's tests in
# Firefox, or webkit; after `playwright install firefox webkit` in the player
H5P_TEST_BROWSER=firefox pnpm test:engine # the player's browser suite, the app's tests and the journeys
# in Firefox, or webkit; after `playwright install firefox webkit` in the player
pnpm typecheck # every package
pnpm lint # oxlint, with its type-aware rules, after the type check: design/build.md
pnpm comments # every comment past two lines: design/build.md
pnpm docs:check # where a doc and the code disagree in what a script can read; --changed
# lists the docs a change calls for reading again: design/build.md
pnpm build # the player: types, element, both workers; builds the runtime package on the way
pnpm normalize course.h5p # rewrite a package so it streams: media stored, mp4 index first
pnpm verify course.h5p # play a package in a headless browser and report whether it works
Expand Down
3 changes: 2 additions & 1 deletion design/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ is one of the docs below. The player, the verifier, the skills, the embed packag
journeys take most of the time, so each tests in a job of its own, side by side, and the rest in
one more. Every package that has a `typecheck` script runs it whatever the change, since each
package's check writes the types the next one reads. A change to `design/`, `docs/`, a root `.md`, `LICENSE` or `.coderabbit.yaml` alone starts
no run. The `scope` job in `ci.yml` decides.
no run of `ci.yml`, whose `scope` job decides. `docs.yml` runs for every pull request and push to main, whatever it changes: it is
`pnpm docs:check` alone, the docs held to the code (`design/build.md`).

**The costly checks run weekly and by hand.** These are Firefox and WebKit, the player's browser
files that wait out real time, the content-type sweep, and the VS Code extension in a real editor,
Expand Down
11 changes: 7 additions & 4 deletions docs/revision.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Which build a learner completed

Every `xapi` and `finished` statement carries two xAPI fields, filled in unless the content set
them itself:
Every `xapi` and `finished` statement about an Activity carries two xAPI fields, filled in unless
the content set them itself:

```json
"context": {
Expand All @@ -10,6 +10,9 @@ them itself:
}
```

On a host without `Range`, statements wait for the archive's index to be read, and go out without
`revision` if the load ends or the page is hidden first, rather than be lost with the tab.

`revision` is a SHA-256 over the archive's index: each entry's name, CRC, sizes and compression
method, in archive order. A change to any of those, or to the order, gives a new value; a change to an entry's date alone
does not. The same file always gives the same one. When `libraries` supplied libraries, what supplied them follows:
Expand All @@ -19,8 +22,8 @@ library, sorted and a line each. So the libraries a package carries but played a
version count, and a pack release that changes none of a package's libraries leaves its revision
as it was. The element's `revision` property holds it once the package is indexed.

**At release**, record it: the normalizer prints the revision of the file it writes. Keep the
published `.h5p`, from which anyone can recompute it.
**At release**, record it: the normalizer prints the file's own part, the one before
`; libraries`. Keep the published `.h5p`, from which anyone can recompute it.

The recipe does not change within a major version of the player, and a major that changes it
gives the new value a prefix of its own ([Compatibility](https://github.com/missing-elements/h5p-toolkit/blob/main/docs/compatibility.md)).
Expand Down
2 changes: 1 addition & 1 deletion docs/verify.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The check cannot say whether the content is right; a person decides that by play
`--preview` checks nothing and opens the package in the real player in the person's own
browser, served from their computer with `Range`, as a static host serves it. It works for any
content type, and a large video starts at once. Its page has a Download button for the file. It
ends a few seconds after its last tab closes:
ends ten seconds after its last tab closes:

```bash
npx @missing-elements/h5p-verify@latest course.h5p --preview
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"test:engine": "pnpm --filter @missing-elements/h5p-offline-player test:engine && pnpm --filter @missing-elements/h5p-demo test && pnpm --filter @missing-elements/h5p-journeys test",
"typecheck": "pnpm -r typecheck",
"comments": "node scripts/comments.mjs",
"docs:check": "node scripts/docs.mjs",
"lint": "oxlint --type-aware --deny-warnings",
"normalize": "node packages/normalize/bin/h5p-normalize.mjs",
"verify": "node packages/verify/bin/h5p-verify.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/author/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ is the workflow around it.
| Field | Meaning |
|---|---|
| `type` | The content type's machine name, such as `H5P.Blanks`; the pack's newest version is used |
| `title` | The title, at most 255 characters |
| `title` | The title, on one line and at most 255 bytes in UTF-8 |
| `language` | A BCP 47 tag, `en`, `de-AT`; it picks the libraries' translation of their interface texts |
| `license` | An H5P licence code: `U` (undisclosed), `CC BY`, `CC BY-SA`, `CC BY-ND`, `CC BY-NC`, `CC BY-NC-SA`, `CC BY-NC-ND`, `CC0 1.0`, `CC PDM`, `GNU GPL`, `PD`, `ODC PDDL`, `C`; `licenseVersion` for a CC BY one |
| `authors` | `[{ "name": "…", "role": "Author" }]`, the role one of Author, Editor, Licensee, Originator |
Expand Down
Loading