Skip to content

h5p-author: any content type in the pack, from a package and a file per type - #101

Merged
alekswebnet merged 5 commits into
mainfrom
feat/h5p-author-package
Nov 1, 2026
Merged

alekswebnet merged 5 commits into
mainfrom
feat/h5p-author-package

Conversation

@alekswebnet

@alekswebnet alekswebnet commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #100.

The h5p-author skill now builds 28 content types instead of two. The agent chooses the type with the user first, reads one short file for it, and writes a source holding only what differs from the type's defaults. A new package, @missing-elements/h5p-author, does the rest and checks every field the way H5P's editor would.

What changed

  • packages/author, published as a command: build <source> <output> and schema <Type>. It replaces the skill's bundled build-quiz.mjs. The library pack is a pinned dependency, so npx @missing-elements/h5p-author@latest build … needs no project setup; --libraries names another parts/ folder.
  • The engine is the sweep's ContentGenerator, moved into the package so there is one copy. The sweep runs it lenient with its own sample fill. Its 55 generated types came out byte for byte the same after the move.
  • Authoring checks what the editor checks. A misspelt field, an unknown option, a list of the wrong size, a required field left out, a tag a field does not take: all reported at once, each by its path, and nothing is written. The rules come from h5p-editor-php-library's widgets: a new list's starting items, showWhen conditions, whole numbers only where the editor shows its number field, <p> or <div> by enterMode.
  • Types with an editor widget of their own get its work done in code: Course Presentation's elements stacked on the slide, Interactive Video's interactions placed apart and its posters sized to what they hold, Branching Scenario's paths checked for dead ends and loops, Game Map's stages joined by label, Find the Hotspot's areas checked.
  • Media come from files beside the source or web addresses, copied in with their type and an image's size. YouTube, Vimeo, Panopto and Echo360 stay where they are, at an address H5P.Video plays: a Short's is written as its video's watch address, and any other address on those sites is refused by name. A package with media goes through the normalizer, so it streams.
  • The skill is a router now: a catalogue of 28 types, the source shape, build, verify, preview. Each type has references/types/<Type>.md with notes, an example and its fields; the fields section is generated from the pack, and the weekly pack refresh rewrites it. Four parts other content holds (Text, Image, Video and Interactive Video's Text) have files too.
  • The quiz format stays: the build maps it onto the general shape, so published quiz sources keep working.

Checked

What Result
Package tests: generator, text, translations, schema, layouts, media from disk and a local server, hosted video against H5P.Video's own patterns, slow and silent downloads, the command 103 passed
Every type file's example, built with sample media and verified trusted and untrusted 32 of 32 pass, no warnings
Every type file's fields section against the pack 32 of 32 current
The quiz format: both kinds, eight scenarios, Ukrainian, punctuation; and the playback test 9 passed
The demo's tests, the app's included 21 passed
pnpm sweep, 55 types × 2 modes, on the moved generator 110 of 110 plays passed
pnpm typecheck clean

I also looked at the screenshots of the slide layout, the game map, the hotspots and the interactive video.

After the first push

  • 236e086 fixes CodeQL's four polynomial-backtracking alerts in the markup reader. Over 244,358 inputs the output is the same except after a comment left open, and 2 million characters take 8 ms where 40,000 took 3 s.
  • 26ed82a fixes what reviewing the PR by hand found. Hosted video is accepted only at an address H5P.Video plays; Shorts, player.vimeo.com and any panopto.com address used to build and then not play. A JPEG's size is read past a large colour profile. An existing output is refused before any work. The Game Map layout test now reaches its assertions without the network. Two unused functions are gone.
  • 5865804 fixes the rest. An Interactive Video poster is sized by what it holds: H5P's editor starts every interaction at 10 × 10 em for the author to resize, and in Chrome that showed two of a question's four answers and hid Check behind a scroll. A question now gets 17 × 16, a text its lines, a picture its shape; interactions shown together are kept apart by size. Quiz-format problems are listed all at once as a SourceError. A download is given up after a minute with no byte rather than two minutes in all. Echo360 addresses are taken as the editor takes them. A widget's list keeps its decimals. The skill again says the libraries come under their own licences.
  • 7cc345b pins the editor the build follows, as the content check is pinned. The code names h5p-editor-php-library at 3bec259, H5PEditor.ShowWhen 1.0.9, and for the layouts the editor versions the pack's content types name: Interactive Video 1.26.3, Branching Scenario 1.5.13 and Game Map 1.2.5. Each rule names the script it follows, and the code lists where it departs; AGENTS.md says how to move to a newer editor. Checking against those commits fixed two rules: a number's steps now count from 0, as the editor's do, and a showWhen path climbs through lists and one-field groups as the editor's does. Neither changes anything the pack builds today. It also corrected two comments that credited the editor with fields it doesn't set. The weekly pack refresh now runs h5p-author's tests and the skills' against the new pack, and its pull request says whether every example still builds and plays.

Tokens

At four characters a token, against the published skill:

Read or written per session Before After
SKILL.md, read every time ~2,050 ~1,430
Core references read once ~1,600 (quiz format, example) ~660 (the brief)
A type's knowledge 3,900 to 9,500 of semantics, for any type but the two quiz kinds 210 to 2,960, one file
The source written ~1,050 to 1,380 ~1,000 to 1,800

SKILL.md is 5.7 kB, above the issue's 3 kB estimate: the catalogue table is about half of it.

Before and after merging

  • The skill is installed from main and calls npx @missing-elements/h5p-author@latest, so 0.1.0 needs publishing right after the merge; until then the skill's build step fails. Then npx skills update -g.
  • prepublishOnly refuses to publish while the pinned pack version is not on npm with this checkout's index, as the player's does.

Not done

Layout for Drag and Drop and Crossword, editing an existing package, and any judgement of whether content is right, which stays the person's, in the preview.

🤖 Generated with Claude Code

…file per type (#100)

The h5p-author skill built Multiple Choice and Question Set from a bundled
script. It now builds 28 content types: the agent chooses the type with the
user, reads one file for it, and writes a source of only what differs from
the type's defaults.

- packages/author, @missing-elements/h5p-author 0.1.0: `build` and `schema`,
  the library pack pinned, every written value checked as H5P's editor would,
  media copied and described, layouts for the types the editor gives a widget
  of their own (Course Presentation, Interactive Video, Branching Scenario,
  Game Map, Find the Hotspot).
- The sweep's ContentGenerator moved into the package; the sweep runs it
  lenient with its own fill, and generates the same bytes for all 55 types.
- The skill: a router SKILL.md, references/authoring.md, and
  references/types/<Type>.md with notes, a tested example and the fields,
  generated from the pack and kept current by the weekly refresh.
- The quiz format stays a source the build takes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread packages/author/lib/generator.mjs Fixed
Comment thread packages/author/lib/generator.mjs Fixed
Comment thread packages/author/lib/text.mjs Fixed
Comment thread packages/author/lib/text.mjs Fixed
alekswebnet and others added 2 commits November 1, 2026 02:43
CodeQL flagged four patterns on the pull request: polynomial backtracking in
the markup reader's comment, in its tag pattern and in the tag stripper, and
the emptiness check's tag-removing replace. A comment left open now runs to
the end, as a browser reads it; the tag pattern's spaces and name have one
reading each, and the slash of `<br />` comes off the attributes as the
content check takes it off; the strippers stop at the next `<`; the emptiness
check uses stripTags.

Over 244,358 inputs (the type files' examples, written cases and a fuzz) and
three fields, the stored text and the problems are the old ones except after
a comment left open. The sweep's content for its 55 types is byte for byte
the same, and 2 million characters take 8 ms where 40,000 took 3 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ut check (#100)

Found reviewing the pull request by hand.

- A hosted video is taken only at an address H5P.Video plays. It chooses a
  player by its own pattern for each host and hands an address none matches
  to its HTML5 player, so `youtube.com/shorts/`, `player.vimeo.com` and
  `panopto.com` addresses outside `/Panopto/…?id=` built and then did not
  play. A Short's or a live stream's address is written as its video's watch
  address; any other address on those hosts is refused, naming the form.
  The test holds each accepted address to the patterns read from H5P.Video's
  scripts in the pack.
- A JPEG's segments are walked to its frame header through the file. Reading
  the first 64 kB refused a picture whose colour profile or XMP put the frame
  header further in.
- An existing output, or a missing folder for it, is refused before any
  work, with a message that says so; the error keeps its EEXIST code.
- The Game Map layout test reached its assertions only with the network: its
  map was a web address. It is a picture beside the source now, and passes.
- isFaststart and slowStart went, read by nothing since the normalizer moves
  the index; fieldAt lost a line the next one overwrote. The test helpers
  that write pictures and video are one file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alekswebnet alekswebnet self-assigned this Nov 1, 2026
alekswebnet and others added 2 commits November 1, 2026 14:17
… downloads, Echo360 (#100)

The rest of what reviewing the pull request by hand found.

- An Interactive Video poster is sized by what it holds. H5P's editor
  starts every interaction at 10 by 10 em and leaves the rest to the
  author's mouse; seen in Chrome, 10 by 10 showed two of a question's four
  answers and hid its Check button behind a scroll. A question now gets 17
  by 16, a text as much width as keeps it short, a picture its own shape as
  the editor gives one; a link, a label and a hotspot keep 10 by 10.
  Interactions nobody placed are kept a gap apart from what shows at the
  same time, by their sizes, and a note says when the video has no room
  left. The type file says how to size a poster by hand.
- A quiz in the quiz format has all its problems listed at once, each by
  its path, as a SourceError, where it stopped at the first as a plain
  Error.
- A download is given up after a minute with no byte, not after two
  minutes in all, which a large video over a slow link outlasts.
- An Echo360 address is kept as the editor keeps it, video/Echo360, when
  H5P.Video plays it, and any other on Echo360 is refused by name. The
  checks for an address on a host are now plain tests of its host name:
  a pattern written for Echo360 took quadratic time on a long name.
- A list's item keeps the marker of a widget's field, so a number in such
  a list takes decimals, as one outside a list does.
- The skill says again that the package carries the libraries under their
  own licences, listed in the pack's libraries.txt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ack refresh (#100)

The rules taken from H5P's editor now name where they come from: h5p-editor-php-library at
3bec259 and H5PEditor.ShowWhen 1.0.9 in generator.mjs, and for the layouts the editors the
pack's content types name in editorDependencies, at the newest release of that minor:
H5PEditor.InteractiveVideo 1.26.3, H5PEditor.BranchingScenario 1.5.13, H5PEditor.GameMap 1.2.5.
Each rule names the script it follows, and the two files list where they depart from it.
AGENTS.md says how to move them to a newer editor.

Checking the rules against those commits found:
- a number's steps were counted from min; the editor's value % step counts from 0;
- a showWhen path skipped the level the editor gives a list and a group of one field, which
  only Advent Calendar's door cover reached (optional either way; the pack's other 98 rules
  resolve alike);
- two comments said the editor sets what it does not: a Branching Question's own
  nextContentId, which it deletes, and a Game Map stage's type, which it keeps out of the
  content. Both are still written, being hidden and required fields.

The weekly pack refresh now runs h5p-author's tests and apps/skills' against the new pack and
says in its pull request whether every type file's example still builds and plays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alekswebnet
alekswebnet merged commit f83f23e into main Nov 1, 2026
9 checks passed
@alekswebnet
alekswebnet deleted the feat/h5p-author-package branch November 3, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

h5p-author: the content type chosen first, a schema and notes for each type, one package for the whole pack

2 participants