Skip to content
Open
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
8 changes: 6 additions & 2 deletions apps/skills/tests/author-verify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ describe.concurrent('every type file', () => {
for (const path of paths(source.params)) if (!/^https?:/.test(path)) await writeFile(join(folder, path), sample(path))
const output = join(folder, 'example.h5p')
const result = await buildPackage(source, output, { base: folder })
// The demo's clip, every video's sample, has no sound, and the build says so (#218).
expect(result.notes.filter(({ message }) => !/\.mp4 has no sound$/.test(message))).toEqual([])
// The demo's clip, every video's sample, has no sound, and the build says so (#218). And what
// an example places on its picture or times on its video by numbers alone is noted in every
// build, for whoever looks at the preview (#260).
const expected = (message: string) => /\.mp4 has no sound$/.test(message) ||
/^holds \d+ \w+ (?:placed by numbers, which a build cannot hold to the (?:picture|map): look at (?:it|each) in the preview|shown at the times written, which a build cannot hold to what the video shows then: play it through in the preview)$/.test(message)
expect(result.notes.filter(({ message }) => !expected(message))).toEqual([])
await checksAsSaved(output)
await playsBothWays(output)
}, 180_000)
Expand Down
46 changes: 45 additions & 1 deletion design/author.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,50 @@ text to the content check's rules, and `apps/skills` plays every example untrust
media goes through the normalizer's `normalizeArchive`, stored and laid out to stream. An addon
whose pattern the text matches, H5P.MathDisplay for LaTeX, is carried as a site with it
installed exports it.
- **A file's facts are one command away, and what only eyes can check is a note** (#260). For five
types a source holds numbers that mean something only against a file: an Interactive Video's
times, and the places of Image Hotspots' hotspots, of Find the Hotspot's and Find Multiple
Hotspots' areas and of Game Map's stages.
- `h5p-author media <file or address>…`, `describeMedia` and the local MCP server's
`h5p_media` say what a file is before a source names it, by the build's own readers
(`MediaStore.describe`): a picture's size, a played file's container, an mp4's length and
what a build notes of its tracks, a hosted video's host and the length it says; a file at a
web address is downloaded as a check downloads it. `mediaLine` is each in a line. It needs
no pack. Measured on 2026-11-25 in Claude Code, a 10 s mp4 attached and nothing said of its
length: with the skill's "know the video's length" alone, Haiku and Sonnet each wrote an mp4
parser of their own before the source in 6 of 6 runs, over routes 1 to 3; with `media`
named in the skill, they ran it and wrote none in 4 of 4 on route 1.
- **Vimeo says a video's length, and an Interactive Video's times are held to it.** Its oEmbed
answer for a video it has carries `duration` in whole seconds (`length` in `HOSTED`);
YouTube's carries none, and Panopto and Echo360 are not asked. It counts only as JSON that
names Vimeo with a length above zero, so a box that answers 200 for the host says none. A
time is past such a video's end only a second beyond the length, for the rounding, and the
problem says whose word the length is.
- **A build says the length it held the times to.** A result's `lengths` has it for each
Interactive Video's video, by the name the source gives it, and the command line and both
servers say each (`lengthLine`), so that whoever changes the times next starts from it.
- **What is placed or timed by numbers alone is a note of the build's**, one for each list of
hotspots, areas, stages or an Interactive Video's interactions (not its bookmarks or end
screens), saying how many and to look at them in the preview (`byNumber` in `types.mjs`). It
is said whether or not a model looked at the file, since only a person's eyes check a place
or a moment; and by the build, not `checkContent`, so a check of saved content says none.
The skill passes a build's notes on. Its own sentence in the brief, to ask the user to check
them, reached the reply in 6 of 16 runs; with the note, in 8 of 8.
- Not built: the length of a WebM, an Ogg, a WAV or an MP3; asking the person for a video's
moments; a grid drawn over a picture. Shown a picture of five shapes 5 % of its width
across, Haiku and Sonnet placed a hotspot on each within one percent in 14 of 14 runs with
no grid, and opened a picture named only by its path in 5 of 5; other chats' models were not
measured.
- **A chat's attachment is copied beside the source and named by its name** (#266). Measured on
2026-11-25 in Claude Code as a chat with a code sandbox, the attachment's folder said as a
chat's sandbox says it, with a picture for an Image Hotspots and a 10 s mp4 for an Interactive
Video, on routes 1 to 3, and with a picture named only by its path on route 2: Haiku and Sonnet built
in 16 of 16 runs, 14 at the first build, each
copying the file beside its source and naming it by its name alone, none by a path made up.
The build's line said "1 media file" in all, and the verifier, where npm answered, passed.
The two that lost a round: an Interactive Video's text written as H5P.AdvancedText, which its
field does not take, as the type file now says; and a bundle unzipped into `parts/`, leaving
the index at `parts/parts`.
- **A build that acts on what a model wrote can be confined** (#220, for the local MCP server of
#219). The command line reads any path a source names and fetches any address, which is right
for a person's own command.
Expand Down Expand Up @@ -480,7 +524,7 @@ text to the content check's rules, and `apps/skills` plays every example untrust
`poolSize` is set, Memory Game draws pairs, at least 2, and Crossword keeps the words fixed on
the grid and draws only among the rest. Not looked for: a select tied to the
content, as Multiple Choice's single or multiple answers; Advanced Blanks' gaps against its
list and its snippets by name; a Game Map restriction's stage id; video times (#260).
list and its snippets by name; a Game Map restriction's stage id.
Each says what to write. `lib/mistakes.mjs` runs in `checkContent`, so a build says them and so
does a check of saved content, and every type file's example says none. Of the owner's 88 real
packages, the 79 checked against their own libraries give 36 notes of a picture with no alt
Expand Down
18 changes: 13 additions & 5 deletions design/mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ below.
`previewPackage`, `openBrowser`) are h5p-verify's. A rule a tool needs goes into those packages
first, exported, so the author package and the verifier are published before a server that uses
something new of theirs.
- **Four tools, and the skill's flow as the instructions.** `h5p_types` lists the pack's content
- **Five tools, and the skill's flow as the instructions.** `h5p_types` lists the pack's content
types, those with a type file marked, and the skill's brief; given a type, read as a build reads
one (`sourceType`, so "true false" works), it answers with the type's file, or with `schemaOf` for
a type with none. `h5p_build` builds a source, `h5p_preview` opens a package, and `h5p_read`
reads one back into its source. The instructions are the flow in a few lines: the type is the one
reads one back into its source. `h5p_media` says what a file is before a source names it, an
mp4's or a Vimeo video's length first (`describeMedia`, author's #260): an app with no shell cannot read one
another way. It reads as a build reads a source's files, a name alone from the first folder, a
local file only in the folders, a web address only on the public internet, and answers in
words alone. Asked for an Interactive Video of a 10 s clip in the folder, Haiku in Claude Code
with these tools alone built twice in 3 of 3 runs without it, once after a refusal and twice
leaving a first package whose question started as the clip ended; with it, it asked the
length first and built once in 3 of 3 (2026-11-25). The instructions are the flow in a few lines: the type is the one
question, its answer is read before the source is written, then the build, where the file is and
what the check found, and the preview offered; a package the person has is read, its source
changed, and built. Not `SKILL.md`, which is served as a skill instead (below): it is mostly
Expand Down Expand Up @@ -63,7 +70,8 @@ below.
goes its source, `<name>.source.json`, which the build page opens to change and build again; it
is made new, never written over or through a link, and where it cannot be, the answer says so.
- **A build answers with the content, the check and a picture.** The build's line, the H5P core a
site needs (`coreApiLine`), its notes, the
site needs (`coreApiLine`), the length an Interactive Video's times were held to
(`lengthLine`), its notes, the
outline (80 lines at most) and, with `verify`, the default, the verifier's summary of a check run
in a temporary folder, with its screenshot as an image. Where neither Chrome, Edge nor
Playwright's Chromium is found, the answer says "Not verified" and why. A source with problems
Expand All @@ -86,8 +94,8 @@ below.
- **Tested as an app runs it.** `tests/server.test.ts` starts the command over standard input and
output with the SDK's own client, given one folder, and calls each tool: the list, a type by a
loose name and one with no file, a build checked in Chromium, a taken name and a link at one,
two builds at once, a source with a problem, an output outside the folder, a preview served and
one refused. Each test builds what it needs, so each runs alone. The test script first copies
two builds at once, a source with a problem, an output outside the folder, a file's facts and
one outside the folder, a preview served and one refused. Each test builds what it needs, so each runs alone. The test script first copies
the skill's type files into the author package, as the author's `prepack` does.

Not built yet: the MCP registry's `server.json` and Claude Desktop's one-click bundle.
Expand Down
31 changes: 31 additions & 0 deletions packages/author/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,31 @@ styles pasted from Word, is said, to fix before building. It never writes over a
is untrusted: only the files its content names are written, only under the folder, and a file
named by a path that could lead out of it is left out of the source.

## What a file is

```bash
npx @missing-elements/h5p-author@latest media clip.mp4 delta.png https://vimeo.com/76979871
```

```
clip.mp4: an MP4 video, 10 s long
delta.png: a PNG picture, 1200 by 800 pixels
https://vimeo.com/76979871: a video on Vimeo, about 62 s long
```

For whoever writes a source that names a file: an Interactive Video's starts have to be within its
video's length, and an agent with no way to learn it wrote a parser of its own, or guessed. Each
file is read as a build reads it: a picture's size from its header, an mp4's length and whether it
has sound from its index, a Vimeo video's length as Vimeo gives it, in whole seconds. A WebM's, an
Ogg's, a WAV's or an MP3's length is not read, and YouTube says none. A file that no source can
name is said on standard error, and the command then exits with 1. It needs no libraries.

A build of an Interactive Video says the length it held the times to, and refuses a start, a
bookmark or an end screen past it (for a Vimeo video, more than a second past the length Vimeo
gives, which is whole seconds); an interaction may end past it. What a source places on a picture or times on a video by
numbers alone, hotspots, areas, stages and interactions, it notes, since only a look at the preview
says whether a hotspot sits on what it names.

## A content type's bundle

```bash
Expand Down Expand Up @@ -272,6 +297,12 @@ source, the media written beside it by the paths it names them by, and what was
not come back as it is, each `{ path, message }`. With `within`, the package and the folder must be
inside those folders, on their real paths.

`describeMedia(sources, { base, within, fetch })` says what files are, as `h5p-author media`
does: for each path or web address, in their order, `{ source, kind, format, width, height,
seconds, host, notes, problem }`, with only what was read, and `mediaLine(facts)` is one in a
line. A result's `lengths` is the length each Interactive Video's times were held to, `{ file,
seconds, host }` by the name the source gives the video, and `lengthLine(length)` says one.

A result's `builtWith` is the content type and the pack's version of it, `H5P.Blanks 1.14`, and
its `source` the source as built, naming it: what to keep with the package, as the command line
writes it beside one; `buildPackage` writes the package alone. A result's `libraries` are the
Expand Down
14 changes: 13 additions & 1 deletion packages/author/bin/h5p-author.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
import { lstat, readFile, realpath, rename, rm, writeFile } from 'node:fs/promises'
import { dirname, relative, resolve } from 'node:path'
import { parseArgs } from 'node:util'
import { buildPackage, coreApiLine, readPackage, schemaOf, SourceError, writeBundle, writeBundles } from '../lib/author.mjs'
import { buildPackage, coreApiLine, describeMedia, lengthLine, mediaLine, readPackage, schemaOf, SourceError, writeBundle, writeBundles } from '../lib/author.mjs'
import { packVersion } from '../lib/node.mjs'

const USAGE = `Usage:
h5p-author build <source.json> <output.h5p> [--libraries <parts folder>]
h5p-author build --check <source.json> [--libraries <parts folder>]
h5p-author read <package.h5p> <folder> [--libraries <parts folder>]
h5p-author media <file or web address>...
h5p-author schema <machine name> [--markdown] [--all] [--libraries <parts folder>]
h5p-author bundle <machine name> <output.zip> [--libraries <parts folder>]
h5p-author bundle --all <folder> [--libraries <parts folder>]
Expand All @@ -21,6 +22,9 @@ build Makes a playable .h5p from a source: { "type", "title", "language", "lic
read Writes the source a build would take to make a package again into a folder,
with the package's media beside it: to change it and build it again. Reads
content made for the pack's versions of its libraries; never writes over a file.
media Says what each file is before a source names it: a picture's size, a video's
length and whether it has sound; of a video on Vimeo, the length Vimeo gives.
Run it before writing an Interactive Video's times. Needs no libraries.
schema Prints a content type's fields as a source writes them: --markdown as a skill's
type file carries them, --all with the interface texts.
bundle Writes the libraries a build of one content type reads, as a zip of a parts/
Expand Down Expand Up @@ -147,6 +151,8 @@ try {
const install = result.install.length ? `, ${result.install.length} more for installing on an H5P site` : ''
console.log(`${check ? 'Checked, no package written' : `Built ${result.output}`}: ${result.manifest.mainLibrary}, ${result.libraries.length} libraries from ${from}${install}${result.media.length ? `, ${result.media.length} media file${result.media.length === 1 ? '' : 's'}` : ''}.`)
if (!check) console.log(coreApiLine(result.coreApi))
// The length an Interactive Video's times were held to, for whoever changes them next (#260).
for (const length of result.lengths) console.log(lengthLine(length))
if (kept) console.log(`Its source, naming ${result.builtWith} as what it was built with, is ${kept}: hand it over with the package.`)
const language = String(result.manifest.language)
if (!/^en(?:-|$)/i.test(language)) {
Expand All @@ -161,6 +167,12 @@ try {
}
for (const { path, message } of result.notes) console.warn(`Note: ${path} ${message}`)
if (!check) console.log('Not verified: run npx @missing-elements/h5p-verify@latest on it and look at its screenshot before handing it over.')
} else if (command === 'media') {
if (!rest.length) throw new Error('media takes the files to look at: h5p-author media clip.mp4 map.png')
for (const flag of Object.keys(flags)) throw new Error(`media does not take --${flag}`)
const facts = await describeMedia(rest)
for (const each of facts) (each.problem ? console.error : console.log)(mediaLine(each))
if (facts.some((each) => each.problem)) process.exitCode = 1
} else if (command === 'read') {
if (rest.length !== 2) throw new Error('read takes a package and a folder to write its source in: h5p-author read quiz.h5p quiz')
for (const flag of Object.keys(flags)) if (flag !== 'libraries') throw new Error(`read does not take --${flag}`)
Expand Down
7 changes: 5 additions & 2 deletions packages/author/lib/author.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* loads them (`openPack`, `loadLibraries`, and `packageLibraries` for a package's own), its rules
* for text (`markupText`, `plainText`, `allowedTags`), and the check it runs last on what it writes,
* for saved content (`checkContent`). `readPackage` reads a package back into its source, to change
* it and build it again. A content type's bundle (`writeBundle`) carries the parts a
* it and build it again. `describeMedia` says what a picture, a video or a recording is before a
* source names it: a video's length, a picture's size. A content type's bundle (`writeBundle`) carries the parts a
* build of it reads, for a build where the pack cannot be installed. This is the entry for Node:
* `./core` is what of it needs no Node, and `./browser` builds in a page.
*/
Expand All @@ -17,12 +18,14 @@ import { schemaLines, schemaMarkdown } from './schema.mjs'
import { LAYOUTS } from './types.mjs'

export * from './core.mjs'
export { buildPackage, inside, openPack, publicFetch, readPackage, writeBundle, writeBundles } from './node.mjs'
export { buildPackage, describeMedia, inside, openPack, publicFetch, readPackage, writeBundle, writeBundles } from './node.mjs'

/**
* @typedef {import('./node.mjs').BuildResult} BuildResult
* @typedef {import('./node.mjs').BuildOptions} BuildOptions
* @typedef {import('./node.mjs').BundleResult} BundleResult
* @typedef {import('./node.mjs').DescribeOptions} DescribeOptions
* @typedef {import('./node.mjs').MediaFacts} MediaFacts
* @typedef {import('./node.mjs').ReadResult} ReadResult
* @typedef {import('./node.mjs').ReadOptions} ReadOptions
*/
Expand Down
Loading