Skip to content

h5p-author: a library bundle per content type, for a build where npm is unreachable - #167

Merged
alekswebnet merged 3 commits into
mainfrom
feat/author-type-bundles
Nov 9, 2026
Merged

alekswebnet merged 3 commits into
mainfrom
feat/author-type-bundles

Conversation

@alekswebnet

@alekswebnet alekswebnet commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #166.

Where npx cannot install, as in ChatGPT's sandbox, the h5p-author skill handed the user a link to the build page and left the rest to them. ChatGPT's sandbox runs Node and can download a file its browsing tool has opened, so with the libraries and the build tool as files the chat builds, and fixes its own source, itself. The skill chooses the content type first, so the files come one bundle per type.

What changes

  • bundleLibraries(pack, type) (./core): the parts a build of one content type can read, whatever its source holds. It applies the build's own rules to the most a source of the type can name: the type and every library its library fields offer or default to, recursively; then planPack, the player's plan, over all of them as roots, as the build plans one package; then installClosure over that. Both rules only ever add for more roots, so any one source's libraries are within. contentTypes(pack) lists the pack's content types, and schemaOf now uses it for its unknown-name message.
  • h5p-author bundle <type> <out.zip> and bundle --all <folder> (writeBundle, writeBundles): a zip of parts/, the parts folder build --libraries parts reads, plus libraries.txt. The output is the same bytes every time (fixed entry dates), never written over an existing file, and refused for a pack with no licence list beside its parts. --all writes every bundle or none: one that fails takes those written before it away again, each only while its name still holds the file this call made, so a file another process has put there since stays.
  • The Node pack reader names a part missing from a given folder: The parts folder … has no H5P.MathDisplay-1.0.h5p, which this build needs: add it from the library pack's parts/.
  • The skill, step 3: where npm is unreachable, fetch https://embed-my.github.io/bundles/h5p-author.mjs and …/bundles/<type>.zip, unzip, then node h5p-author.mjs build source.json course.h5p --libraries parts. A missing part comes from …/bundles/parts/. The package is handed over unverified, with the build page's link for the user to play it. The link stays the fallback where nothing can be fetched.
  • design/author.md gains a rule; the README documents the command and the API.

Where it differs from the issue

  • Each bundle carries the pack's whole index (63 kB), not its own entries. A build from a bundle then plans exactly as from the pack. It either writes the same package or stops and names the part it lacks. With a cut-down index, a source with math built in silence without its addon.
  • No addon is in a bundle. H5P.MathDisplay is 2.8 MB, joins wherever text holds math, and would more than double most bundles. A source that needs it fetches that one part.
  • --all writes every content type in the pack, 55 of them, not only the types with a layout or a type file. A chat may build any of them.

Checked

  • The author package's Node suite passes: 162 tests, 10 of them new. The full suite with its browser test, and CI, passed on the first commit. The new tests/bundle.test.ts covers: Question Set's bundle holds every question it offers and its editor libraries; every content type's bundle is complete for the upload check (missingForInstall empty) and holds no addon; a bundle builds what the pack builds; the math source stops at MathDisplay, then builds with it; the byte-identical rewrite; a failed --all leaves nothing behind (and fails on the first commit's code, with 32 zips left); a rollback spares a file another process has replaced (and fails with the guard taken out); the refusals; and the command.
  • Not committed: every one of the skill's 32 type-file examples, built from its type's bundle and from the whole pack, gives the same libraries, install parts, manifest and content. Only the ids a build draws at random differ.
  • Not committed, for embed-my#14: esbuild turns the command line into one 558 kB file, which builds a Question Set from an unzipped bundle with no node_modules anywhere.
  • Sizes with pack 1.1.0: a question type's bundle 0.6–1.5 MB, Question Set 2.6 MB, the containers 4.3–8.4 MB, all 55 together 99 MB, written in under a second.

Order

The skill's new step points at files embed-my#14 will serve. Until then a download fails and the skill falls back to the build page's link, as today. After merge: release author 0.6.0, then embed-my#14 deploys the bundles, then a test in ChatGPT (the three checks listed in #166).


Summary by cubic

Adds a bundle command to h5p-author so a build can run where npm is unreachable, as in ChatGPT's sandbox (#166). The skill now fetches the build tool and a content type's bundle and builds from them, with the build page's link as the fallback.

What changed

  • h5p-author bundle <type> <out.zip> (and bundle --all <folder>, one per content type) writes a zip of parts/, buildable with --libraries parts, plus the pack's whole index.json and libraries.txt; it never writes over an existing file, and a failed --all rolls back only the files this call made, leaving a file another process has put at a name since.
  • bundleLibraries applies the build's own rules — the type's library fields, the player's planPack, installClosure — to everything a source of the type can name.
  • The bundle carries the pack's whole index, not trimmed entries, so a build plans exactly as from the pack: it either writes the same package or stops naming the part it lacks. A trimmed index would build a source with math silently without its addon.
  • No addon is in a bundle; a build that needs one (H5P.MathDisplay for math) now names the part to fetch into parts/.
  • The skill hands the package over unverified, with the build page's link to play it.

Deployment depends on embed-my.github.io serving the bundles (embed-my/embed-my.github.io#14); until then the download fails and the skill falls back to today's behavior.

Written for commit c480fc2. Summary will update on new commits.

View guided diff Turn on auto-fix

…m is unreachable

`h5p-author bundle <type> <out.zip>` writes the parts a build of one content type can read: what
the type can hold, as the build's own rules plan it (planPack, installClosure), with the pack's
whole index and its licence list, and no addon. `bundle --all <folder>` writes one per content
type. Where npx cannot install, as in ChatGPT's sandbox, the skill builds from a type's bundle and
the command line as one file, served by embed-my.github.io (embed-my/embed-my.github.io#14), and
falls back to the build page's link.

Closes #166

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 11 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/author/lib/node.mjs Resolved
Comment thread skills/h5p-author/SKILL.md Resolved
Comment thread packages/author/README.md Resolved
…s the source's own type

A later content type that failed left the bundles before it in the folder, and running the
command again then refused them: those this call wrote are now taken away again. The skill's
step 3 wrote H5P.QuestionSet.zip as if every source were a quiz; it now writes <type>, the
source's own, since another type's bundle lacks what this one needs. The README's and the
design note's "stops naming the part" now say the build stops and names it.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/author/lib/node.mjs Resolved
…l made

The rollback removed each earlier bundle by its name, so a file another process had put at
that name since was taken away with them. Each bundle's device and inode are now recorded as
it is created, and the rollback, like a single bundle's own cleanup, removes a name only while
it still holds that file.
@alekswebnet
alekswebnet merged commit b756419 into main Nov 9, 2026
10 checks passed
@alekswebnet
alekswebnet deleted the feat/author-type-bundles branch November 12, 2026 09:26
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: a library bundle per content type, and a build from it where npm is unreachable

1 participant