From 8ab63db0194e9e94f3a06a845eed8d9a3ed35971 Mon Sep 17 00:00:00 2001 From: Aleksandr Shevchuk Date: Tue, 10 Nov 2026 20:40:15 +0200 Subject: [PATCH] feat(author): the package carries the skill's text, and the skill gives a type file's address off GitHub (#178) The Claude app, given a link to the h5p-author skill on GitHub, answered that GitHub's rate limit kept it out: GitHub limits anonymous requests per address on github.com and raw.githubusercontent.com, and a chat app's addresses are shared. The skill then sent a chat that had its text back to raw.githubusercontent.com for a type's file. - `prepack` copies the skill's `SKILL.md` and `references/authoring.md` beside its type files (copy-type-files.mjs is now copy-skill.mjs), each an export, so the organisation's site can serve the skill from the release it pins. - The skill's address for a type's file is the site's, `/h5p/build/types/.md`, live since the build page carries the type files. Installing the skill stays the way: nothing is fetched while the chat works. The package test holds the copies to the skill's files and finds them through the exports; dropping either copy fails it. The tarball gains SKILL.md and references/authoring.md and nothing else. 179 author tests and 77 skills tests pass. --- .gitignore | 3 +++ design/author.md | 8 ++++++- design/layout.md | 7 +++--- packages/author/README.md | 5 ++++- packages/author/package.json | 7 ++++-- packages/author/scripts/copy-skill.mjs | 22 ++++++++++++++++++ packages/author/scripts/copy-type-files.mjs | 16 ------------- packages/author/tests/build.test.ts | 25 +++++++++++++-------- skills/h5p-author/SKILL.md | 2 +- 9 files changed, 62 insertions(+), 33 deletions(-) create mode 100644 packages/author/scripts/copy-skill.mjs delete mode 100644 packages/author/scripts/copy-type-files.mjs diff --git a/.gitignore b/.gitignore index 52072b77..97dec9fc 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,9 @@ packages/player/LICENSE packages/normalize/LICENSE packages/verify/LICENSE packages/author/LICENSE +# The h5p-author skill's text, which the author's `prepack` copies beside its type files (#178). +packages/author/SKILL.md +packages/author/references/authoring.md packages/cmi5/LICENSE packages/embed/LICENSE diff --git a/design/author.md b/design/author.md index 1362f22c..f30b5785 100644 --- a/design/author.md +++ b/design/author.md @@ -370,7 +370,13 @@ to 3,000. Nineteen things the code does not say by itself: `skills/h5p-author/references/types/*.md` into the package, `references/types/.md`, each an export, for the page to hand over with a source's problems. They stay the skill's, at the repository's root where `npx skills add` looks, written by `sync:skill` as before; the copy is - not in git, and `build.test.ts` holds it to the skill's files, file for file. + not in git, and `build.test.ts` holds it to the skill's files, file for file. Since #178 the + skill's text travels with them, `SKILL.md` and `references/authoring.md`, each an export too: + the Claude app, given a link to the skill on GitHub, answered that GitHub's rate limit kept it + out, since GitHub limits anonymous requests per address and a chat app's are shared. The + organisation's site serves the skill from the release its build page pins, and the skill gives + a chat the site's address for a type's file, not raw.githubusercontent.com's. Installing the + skill stays the way: nothing is fetched while the chat works. The same test on the 23 other content types the skill lists says how far each thing reaches: two runs each, 46 first replies, each built package checked against what its task asked for. diff --git a/design/layout.md b/design/layout.md index 48bafebf..30c1b138 100644 --- a/design/layout.md +++ b/design/layout.md @@ -206,9 +206,10 @@ packages/author/ @missing-elements/h5p-author — a playable .h5p of an scripts/ sync-skill.mjs writes the skill's type files' generated sections from the pack (`pnpm --filter @missing-elements/h5p-author sync:skill`); check-pack-published.mjs, the publish guard for the pinned pack and player, - and the normalizer's `./crc32`; copy-type-files.mjs, `prepack`'s copy of - the skill's type files into `references/types/`, which the package - carries and git does not (#172) + and the normalizer's `./crc32`; copy-skill.mjs, `prepack`'s copy of + the skill's text and type files, `SKILL.md`, `references/authoring.md` + and `references/types/`, which the package carries and git does not + (#172, #178) tests/ node tests: the generator, text and translations, layouts and schema, the loader, builds with media from disk and a local server, the command, the quiz format, the check of saved content, the demo's packages among it, and diff --git a/packages/author/README.md b/packages/author/README.md index 6fa0f1af..af743e97 100644 --- a/packages/author/README.md +++ b/packages/author/README.md @@ -135,7 +135,10 @@ An unknown name lists the pack's content types. The package carries those type files too, as the release has them: `@missing-elements/h5p-author/references/types/H5P.TrueFalse.md` is the type's notes, an example and these fields. A page that builds for a chat with no skill beside it hands them over with a source's -problems, as the [build page](https://missing-elements.github.io/h5p/build/) does. +problems, as the [build page](https://missing-elements.github.io/h5p/build/) does. The skill's text +travels with them, `@missing-elements/h5p-author/SKILL.md` and its brief, +`references/authoring.md`, for a site to serve to a chat given a link to the skill: GitHub limits +the requests of an address many users share, as a chat app's is. ## A content type's bundle diff --git a/packages/author/package.json b/packages/author/package.json index 1a6eaed4..9b656a9c 100644 --- a/packages/author/package.json +++ b/packages/author/package.json @@ -33,13 +33,16 @@ "default": "./lib/browser.mjs" }, "./references/types/*.md": "./references/types/*.md", + "./references/authoring.md": "./references/authoring.md", + "./SKILL.md": "./SKILL.md", "./package.json": "./package.json" }, "files": [ "bin", "lib", "references", - "types" + "types", + "SKILL.md" ], "keywords": [ "h5p", @@ -56,7 +59,7 @@ "test:unit": "pnpm --filter @missing-elements/h5p-offline-player build:plan && vitest run --project node", "typecheck": "pnpm types && tsc -p tsconfig.json", "sync:skill": "pnpm --filter @missing-elements/h5p-offline-player build:plan && node scripts/sync-skill.mjs", - "prepack": "node -e \"require('node:fs').copyFileSync('../../LICENSE', 'LICENSE')\" && node scripts/copy-type-files.mjs && pnpm types", + "prepack": "node -e \"require('node:fs').copyFileSync('../../LICENSE', 'LICENSE')\" && node scripts/copy-skill.mjs && pnpm types", "prepublishOnly": "node -e \"if (!/^pnpm\\//.test(process.env.npm_config_user_agent || '')) { console.error('Publish with pnpm publish: npm would ship the workspace: dependency ranges as they are, and the package would not install.'); process.exit(1) }\" && node scripts/check-pack-published.mjs && pnpm typecheck && pnpm test", "types": "pnpm --filter @missing-elements/h5p-offline-player exec tsc -b && node -e \"require('node:fs').rmSync('types', { recursive: true, force: true })\" && tsc -p tsconfig.types.json" }, diff --git a/packages/author/scripts/copy-skill.mjs b/packages/author/scripts/copy-skill.mjs new file mode 100644 index 00000000..72e5dc21 --- /dev/null +++ b/packages/author/scripts/copy-skill.mjs @@ -0,0 +1,22 @@ +// The h5p-author skill's text, copied into the package as `prepack` runs: `SKILL.md`, its brief, +// `references/authoring.md`, and its type files, each content type's notes, an example and its +// fields, as the release has them. A page that builds, with no skill beside it, hands the type +// files to a chat whose source had problems (#172), and serves the skill to a chat given a link to +// it rather than GitHub's, which limits the requests of addresses many users share (#178). They are +// the skill's, at the repository's root, where `npx skills add` looks; the copy is not in git. +import { cp, mkdir, readdir, rm } from 'node:fs/promises' +import { fileURLToPath } from 'node:url' + +const skill = new URL('../../../skills/h5p-author/', import.meta.url) +const from = fileURLToPath(new URL('references/types/', skill)) +const to = fileURLToPath(new URL('../references/types/', import.meta.url)) + +await rm(fileURLToPath(new URL('../references/', import.meta.url)), { recursive: true, force: true }) +await rm(fileURLToPath(new URL('../SKILL.md', import.meta.url)), { force: true }) +await mkdir(to, { recursive: true }) +const files = (await readdir(from)).filter((name) => name.endsWith('.md')) +if (!files.length) throw new Error(`No type files in ${from}`) +for (const name of files) await cp(`${from}${name}`, `${to}${name}`) +await cp(fileURLToPath(new URL('references/authoring.md', skill)), fileURLToPath(new URL('../references/authoring.md', import.meta.url))) +await cp(fileURLToPath(new URL('SKILL.md', skill)), fileURLToPath(new URL('../SKILL.md', import.meta.url))) +console.log(`Copied SKILL.md, references/authoring.md and ${files.length} type files to references/types/`) diff --git a/packages/author/scripts/copy-type-files.mjs b/packages/author/scripts/copy-type-files.mjs deleted file mode 100644 index 05f52e2b..00000000 --- a/packages/author/scripts/copy-type-files.mjs +++ /dev/null @@ -1,16 +0,0 @@ -// The h5p-author skill's type files, copied into the package as `prepack` runs: each content -// type's notes, an example and its fields, as the release has them. A page that builds, with no -// skill beside it, hands them to a chat whose source had problems (#172). They are the skill's, at -// the repository's root, where `npx skills add` looks; the copy is not in git. -import { cp, mkdir, readdir, rm } from 'node:fs/promises' -import { fileURLToPath } from 'node:url' - -const from = fileURLToPath(new URL('../../../skills/h5p-author/references/types/', import.meta.url)) -const to = fileURLToPath(new URL('../references/types/', import.meta.url)) - -await rm(fileURLToPath(new URL('../references/', import.meta.url)), { recursive: true, force: true }) -await mkdir(to, { recursive: true }) -const files = (await readdir(from)).filter((name) => name.endsWith('.md')) -if (!files.length) throw new Error(`No type files in ${from}`) -for (const name of files) await cp(`${from}${name}`, `${to}${name}`) -console.log(`Copied ${files.length} type files to references/types/`) diff --git a/packages/author/tests/build.test.ts b/packages/author/tests/build.test.ts index d5167cf0..6805a8ea 100644 --- a/packages/author/tests/build.test.ts +++ b/packages/author/tests/build.test.ts @@ -784,20 +784,27 @@ describe('the build', () => { }) describe('the package', () => { - it('carries the skill\'s type files, copied as it is packed, for a page to hand to a chat (#172)', async () => { - const skill = resolve(import.meta.dirname, '../../../skills/h5p-author/references/types') + it('carries the skill\'s text and type files, copied as it is packed, for a page to hand to a chat (#172, #178)', async () => { + const skill = resolve(import.meta.dirname, '../../../skills/h5p-author') const copied = resolve(import.meta.dirname, '../references/types') - const { stdout } = await exec(process.execPath, [resolve(import.meta.dirname, '../scripts/copy-type-files.mjs')]) - const names = (await readdir(skill)).filter(name => name.endsWith('.md')).sort() + const { stdout } = await exec(process.execPath, [resolve(import.meta.dirname, '../scripts/copy-skill.mjs')]) + const names = (await readdir(join(skill, 'references/types'))).filter(name => name.endsWith('.md')).sort() expect(names).toContain('H5P.InteractiveBook.md') - expect(stdout).toContain(`Copied ${names.length} type files`) + expect(stdout).toContain(`Copied SKILL.md, references/authoring.md and ${names.length} type files`) expect((await readdir(copied)).sort()).toEqual(names) - for (const name of names) expect(await readFile(join(copied, name), 'utf8'), name).toBe(await readFile(join(skill, name), 'utf8')) + for (const name of names) expect(await readFile(join(copied, name), 'utf8'), name).toBe(await readFile(join(skill, 'references/types', name), 'utf8')) + // The skill's text beside them, as it is, for a site to serve to a chat given a link. + for (const name of ['SKILL.md', 'references/authoring.md']) { + expect(await readFile(resolve(import.meta.dirname, '..', name), 'utf8'), name).toBe(await readFile(join(skill, name), 'utf8')) + } // Packed and found: in `files`, copied by `prepack`, and each one an export of its own. const manifest = JSON.parse(await readFile(resolve(import.meta.dirname, '../package.json'), 'utf8')) - expect(manifest.files).toContain('references') - expect(manifest.scripts.prepack).toContain('node scripts/copy-type-files.mjs') - expect(createRequire(import.meta.url).resolve('@missing-elements/h5p-author/references/types/H5P.InteractiveBook.md')).toBe(join(copied, 'H5P.InteractiveBook.md')) + expect(manifest.files).toEqual(expect.arrayContaining(['references', 'SKILL.md'])) + expect(manifest.scripts.prepack).toContain('node scripts/copy-skill.mjs') + const require = createRequire(import.meta.url) + expect(require.resolve('@missing-elements/h5p-author/references/types/H5P.InteractiveBook.md')).toBe(join(copied, 'H5P.InteractiveBook.md')) + expect(require.resolve('@missing-elements/h5p-author/SKILL.md')).toBe(resolve(import.meta.dirname, '../SKILL.md')) + expect(require.resolve('@missing-elements/h5p-author/references/authoring.md')).toBe(resolve(import.meta.dirname, '../references/authoring.md')) }) }) diff --git a/skills/h5p-author/SKILL.md b/skills/h5p-author/SKILL.md index bd91220f..03e6902d 100644 --- a/skills/h5p-author/SKILL.md +++ b/skills/h5p-author/SKILL.md @@ -60,7 +60,7 @@ the same package. Read the type's file, `references/types/.md`: notes, an example, its fields. Parts other content holds have files too: H5P.AdvancedText, H5P.Image, H5P.Video, H5P.Text. With this text alone and no file beside it, open the file at -`https://raw.githubusercontent.com/missing-elements/h5p-offline-player/main/skills/h5p-author/references/types/.md`; +`https://missing-elements.github.io/h5p/build/types/.md`; where nothing opens, write the source from what you know of the type: the build says, for each place that is wrong, what to write there.