Copy the type file of a type named as a chat with no skill text names it

Merged
AL
1d ago
+75-27

Closes #13.

Copy the problems for the chat carried the type file of the source's type as written. A chat with no skill text writes the type as it is spoken of, "interactive-book", or under contentType, as Gemini in Chrome did from a link to the skill, and its first copy had no type file. Now the page asks h5p-author for the source's type, sourceType (new in 0.8.0, h5p-offline-player#176): its type as written or as it is spoken of, or with none the one under contentType or library, as the build reads it. Below it, a library counts by its listed machine name under any key, so a slide's element { "type": "text" } is no H5P.Text.

The page asks the build it ships instead of keeping a copy of its rule: sourceType was exported from h5p-author for this.

Measured

In h5p-offline-player#174 on the weakest Claude model, Haiku 5.5, with no skill text: the request as Gemini was given it, six content types, two runs each, this page's copy pasted back.

By round 2By round 3By round 4Never
h5p-author 0.7.0, this page's rule before3 of 12684
h5p-author 0.7.1, the type as the build reads it10 of 12120

What changes

  • src/h5p/build/build-source.ts: typesNamed(source, listed) takes the source's own type from sourceType, then every listed machine name below it, alone or with a major and minor, under any key.
  • src/h5p/build/build-page.ts: typeFilesOf fetches index.json first, since a name is read against that list.
  • package.json: h5p-author 0.8.0. The player stays at 1.6.0, the version 0.8.0 names.
  • README.md: The type files says how the type is found, and what the second test measured.

Tested

  • pnpm e2e: 12 pass, one of them new: a book as Haiku wrote one (the content's fields beside "type": "interactive-book") and one as Gemini did (contentType, metadata) each copy the book's type file and those of the libraries they name; a type named under a key the build does not read, and a slide element's "type": "text", copy none. Three mutations of typesNamed (the type as written, names read loosely below it, nothing read below it) each fail it.
  • The 14 rounds that failed in the no-skill test were built again on this page, and each copied byte for byte what the model had been given.
  • The 39 sources the type-file test replayed before: 36 copy byte for byte as measured. The other three carry the same type files and differ in their problems only, which read better since h5p-author 0.7.0 (a Game Map) and 0.7.1 (two books whose chapters had a title beside them, 13 problems now 7).
  • pnpm install --frozen-lockfile, tsc and pnpm build pass; /h5p/build/types/index.json says author 0.8.0.

Summary by cubic

Fixes the copy for the chat carrying no type file when a source names its type as a chat without skill text writes it — as spoken ("interactive-book") or under contentType or library — rather than as the type field writes it. The copy now carries the type file of the type the build reads the source as.

  • The source's own type comes from h5p-author 0.8.0's sourceType, and the copy fetches index.json first so names are read against the actual list.
  • The 14 previously failing no-skill rounds now copy byte for byte; 3 of 39 replayed sources carry the same type files and their problems read better since 0.7.0/0.7.1.