hax-importer-dev
Skill2 starsChanged 22 days agoApache-2.0View on GitHub
Build a new site importer (a platform-to-HAXcms converter such as Quarto, VitePress, GitBook or OpenStax) end to end: Node and PHP converters, dispatcher, OpenAPI spec, API error codes, client service and chooser card, i18n, and tests. Use when asked to add or change an importer, or to support migrating a new format or CMS into HAX.
In this repository56 other files it gives its agents.
- AGENTS.mdAGENTS.md
- llms.txtllms.txt
- audio-program-haxSkill
- audio-program-transcribeSkill
- grad-bloomsSkill
- hax-a11y-auditSkill
- hax-backend-devSkill
- haxcms-lrs-raterSkill
- haxcms-prototypeSkill
- hax-content-authoringSkill
- hax-content-chunking-auditSkill
- hax-design-system-ingestSkill
- hax-design-systemSkill
- hax-design-system-syncSkill
- hax-element-demoSkill
- hax-feedback-designSkill
- hax-i18n-translateSkill
- hax-instructional-elementSkill
- hax-instructional-events-auditSkill
- hax-issue-analysisSkill
- hax-issue-researchSkill
- hax-managed-filesSkill
- hax-mental-modelSkill
- hax-multimedia-principles-auditSkill
- hax-openstax2haxSkill
- hax-parity-agent-legSkill
- hax-pattern-library-auditSkill
- hax-practice-and-retrievalSkill
- hax-proficiency-scaffoldingSkill
- hax-reflection-promptsSkill
- hax-release-prepSkill
- hax-rule-managementSkill
- hax-site-generatorSkill
- hax-site-structureSkill
- hax-testingSkill
- hax-theme-builderSkill
- hax-tutorial-siteSkill
- hax-ubd-backward-designSkill
- hax-ubd-essential-questionsSkill
- hax-ubd-graspsSkill
- hax-ubd-six-facetsSkill
- hax-ubd-stage1Skill
- hax-ubd-stage2Skill
- hax-ubd-stage3Skill
- hax-ubd-unit-auditSkill
- hax-udl-auditSkill
- hax-url-migrationSkill
- hax-ux-studySkill
- heosat-report-siteSkill
- heosatSkill
- oerschema-auditSkill
- oerschema-integration-finderSkill
- praw-connection-ingestSkill
- reading-notesSkill
- siip-course-alignmentSkill
- youtube-vttSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 7 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 56
If an issue plan says to mirror an older converter, compare it with the VitePress reference and say where the plan is out of date.
- Very specific: line 68
Only extensions createSite accepts are importable.
- Very specific: line 117
Never execute the source's code: Do not require, eval, or run a repo's config.
- Very specific: line 189
Do not run the ubiquity script or a top-level monorepo build.
- Very specific: line 204
Run npm run test:unit. npm run precheck can report an error in code you did not touch (a constant interpolated into exec near …
- Very specific: line 220
Run the tier from hax-testing: npm run test:unit, npm run test:api-conformance, and precheck in Node.
- Distinctive: line 228
Run the converter locally and inspect the output.
- Distinctive: line 232
Prefer sources whose license allows derivatives when choosing a demo target.
- Very specific: line 235
If the sandbox cannot reach the GitHub API (HTTP 403), clone the repo read-only into a scratch directory and run the converter with …
- Distinctive: line 237
Keep the script and its output outside the repository.
- Distinctive: line 241
Check the converted output with counts, not eyeballs: leftover fences, attribute blocks, shortcodes, cross-reference keys and broken links …
- Distinctive: line 246
Read the issue in https://github.com/haxtheweb/issues and any plan comment.
- Distinctive: line 250
Write the Node converter and its tests against the synthetic fixture.
- Very specific: line 254
Run each repo's tests and pre-submission check.
- Very specific: line 262
Do not add @haxcms/ registrations or touch the CLI's legacy --import-structure path.
- Very specific: line 263
Do not hand-edit generated files, build/, or node_modules/.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
HAX importer development
An importer turns an outside source (a git repo, a site URL, an uploaded file) into HAXcms JSON Outline
Schema items plus a map of files to download. HAX ships many of them, and each new one touches the same
places in four repos (two backends, the client, and the hax CLI). This skill is the checklist, the contract, and the security posture, so an agent
spends its effort on parsing the source format and not on rediscovering the wiring.
Everything resolves through public URLs, so it works from a local clone or a cloud agent:
- Node backend: https://github.com/haxtheweb/haxcms-nodejs
- PHP backend: https://github.com/haxtheweb/haxcms-php
- Client (app-hax, micro-frontend-registry): https://github.com/haxtheweb/webcomponents
- CLI (
hax site --import-structure): https://github.com/haxtheweb/create - Rules: https://github.com/haxtheweb/praw/blob/main/RULES.md
- Work queue: https://github.com/haxtheweb/issues
When to use
- Adding an importer for a new platform or format.
- Extending an existing importer (new source shape, new content transforms).
- Reviewing an importer plan someone drafted. Check it against the contract below first.
For backend parity in general, load hax-backend-dev. For test commands, load hax-testing. This skill only
covers what is specific to importers.
Read the current code before you design
Layouts and conventions move, and plans drift. Before writing a plan or code, read, from main:
- The reference converter closest to your source (below), in both backends.
siteImportin each backend (the dispatcher).- The matching entries for that reference in the OpenAPI spec, the API-code file, the client registry, the chooser card, and the tests.
Pick the reference by source shape, not by familiarity:
| Source shape | Reference | Why |
| Git repo with a config file declaring the outline plus markdown pages | convertVitepressToSite (Node src/systemRoutes/v1/routes/imports/, PHP system/backend/php/lib/systemRoutes/v1/imports/) | Current best practice: config read as data, safe fetch and YAML, limits, asset map, license attribution, fixture-based tests, exact Node/PHP parity |
| Markdown repo with an index file (SUMMARY.md style) | convertGitbookToSite | Simple, but older: it predates several of the hardening conventions below. Do not copy its fetch or error handling |
| Structured book with parts and chapters from an API | convertOpenstaxToSite | Hierarchy built from a remote table of contents |
| CMS or site URL | convertWordpressToSite, convertDrupalToSite, convertPloneToSite | Discovery, pagination, metadata |
| Single uploaded file | importDocx, importPdf, and similar | File inputs go through a different route family |
If an issue plan says to mirror an older converter, compare it with the VitePress reference and say where the plan is out of date.
The output contract
A converter returns { status: 200, data: { items, filename, files, ... } }:
items:JSONOutlineSchemaItemobjects withtitle,slug,order,indent,parent(the parent item'sid, or null for top level),contents(sanitized HTML), andmetadata. Setmetadata.sourceTypeto the platform and keep source details (repo, branch, path, license, author, accessed date) under a namespaced key. Setmetadata.sourceto the page's public URL when it is known.files: a map offiles/<name>to the source URL.files/is flat, so keep basenames unique. Only extensionscreateSiteaccepts are importable; anything else keeps its source URL in the content. The file map carries URLs, andcreateSitedownloads them behind its own SSRF guard. The converter never downloads assets itself.filename: the site name.- Optional:
site: { license },truncated, a list of unmapped source components, andwarnings(a list of{ code, message }notices), so the client can tell the user what did not convert and what to check before publishing. See "License handling". - Errors use
{ status, data: { error, items: [], filename: null, files: {} } }. 400 for a bad request, 422 when the source is readable but is not what the importer expects or has no pages, 403 for authorization.
Each page: split front matter, render markdown with markdown-it, map source-specific syntax to HAX
elements where one exists (media-image, video-player, license-element, oer-schema), unwrap what has no
equivalent, and report it. Rewrite in-book links to the imported slugs, and rewrite image and file
references into the file map. A page that cannot be read gets a link back to the source, never an empty
page that looks successful.
Titles resolve in this order: an explicit outline label from the source's own navigation, then front matter
title, then the first heading, then file name. The outline label wins because it is what the author chose to show
in the table of contents, and it keeps slugs stable. Slugs derive from the outline
path (parent slug plus title slug), never from file basenames alone, because ch1/index and ch2/index
collide.
License handling
The source's license is part of the content. An importer carries it onto the site and the pages, and tells the person what it implies. It never decides whether the import is allowed; that is theirs.
- Use the shared list, not a private one:
src/lib/licenses.jsin haxcms-nodejs andHAXCMSLicensesin haxcms-php (the same list is inlicense-element). It holds Creative Commons 4.0, CC0 and the Public Domain Mark, and the common software licenses, as lower case codes. Do not copy the list into an importer. - Resolve in this order: the license the source's own config declares, then the repository's license file
(
identifyLicense/identify: SPDX tags, Creative Commons names and URLs, and the standard texts of the software licenses), then nothing. A page's own front matter license overrides the site's for that page. - Never guess. A Creative Commons license at a version other than 4.0 gets no code (the links and badges are for 4.0, and relabeling 3.0 work as 4.0 misstates its terms). A statement that cannot be identified is reported, not mapped to the nearest license.
- Report notices in
warnings, with these stable codes:license:no-derivatives,license:non-commercial,license:share-alike(from the code's terms),license:from-file(read from a file, so confirm it covers the written content and not only the code),license:unrecognizedandlicense:not-found. Each has a plain message. They are information; the import still returns. - Keep attribution: a
license-elementon each page with the license code, title, creator and source URL. - Both backends return identical codes, order and messages. Cover each case in tests with synthetic license text, never a real project's file.
Security posture (non-negotiable)
repoUrl and every file the converter reads are caller-controlled. These apply to both backends:
- Never execute the source's code. Do not
require,eval, or run a repo's config. Read configuration as data. If it cannot be read as plain data, fall back to the file tree, the way VitePress does. - Network only through the safe fetchers:
safeFetchin Node andSsrfGuardin PHP. No barefetch,curl, orfile_get_contentson caller-influenced URLs. SendUser-Agent: HAXcms-Import/1.0to GitHub; without it every call 403s and a swallowed error looks like an empty repo. - Parse YAML with
loadYamlSafely(Nodesrc/lib/safeYaml.js), which caps size and rejects anchors and aliases. Do not calljs-yamldirectly. Front matter that fails to parse falls back to{}. - Escape everything written into HTML:
escapeHTMLAttributefor attributes, and sanitize rendered content. Content from the source is untrusted. - Bound the work. Define a
LIMITSobject (max pages, max files, total fetch budget in seconds, delay between requests, and for formats with includes or transclusion a max include count and depth), mark the resulttruncatedwhen a limit hits, and exportLIMITSso tests can lower them. Keep the PHP values identical. - Return client-safe errors with
clientSafeErrorDetail. No paths or stack traces reach the response. - GitHub limits apply. Unauthenticated API calls are rate-limited. Fetch the tree once and read file
contents from
raw.githubusercontent.com.
Wiring checklist
Nothing is discovered automatically. Miss one of these and the importer is unreachable or untested. (OpenStax shipped unreachable once for exactly that reason; see haxtheweb/issues#2912.)
haxcms-nodejs
- New converter
src/systemRoutes/v1/routes/imports/convert<Name>ToSite.js. CommonJS,async function convert<Name>ToSite(req, res), exports the function andLIMITS. No optional chaining (?.) anywhere; the toolchain does not allow it. - Dispatcher
src/systemRoutes/v1/routes/siteImport.js:require, acase '<platform>', and the supported-platforms doc comment. - Spec
src/openapi/system-spec.yaml: a/system/api/v1/site/import/<platform>path withoperationId: <platform>ToSite(that id becomes the@system/<platform>ToSiteservice name), request schema (repoUrl), and 200/400/403/422 responses. Also update the platform list in the generic{platform}description and the importer list in theImportDataschema description. - API codes
src/lib/haxcmsApiCodes.json: add regexes for the converter's error strings to the right code (IMPORT_EMPTY,IMPORT_SOURCE_INVALID,IMPORT_FETCH_FAILED,IMPORT_FAILED). An uncoded error reaches the client as raw English. Add one example per new message to theEXAMPLESlist intest/unit/api-message-codes.test.cjs. - Test
test/unit/convert<Name>ToSite.test.cjs.
haxcms-php
Same contract, same outline, slugs, file map, status codes and error strings.
system/backend/php/lib/systemRoutes/v1/imports/convert<Name>ToSite.php, wrapped infunction_existsguards, with limits overridable through a$GLOBALShook for tests.system/backend/php/lib/systemRoutes/v1/siteImport.php:include_onceand acase.system/backend/php/lib/systemRoutes/openapi/system-spec.yaml: the same spec edits.system/backend/php/lib/haxcms-api-codes.json: the same code edits.system/backend/php/tests/run.php: add the platform to the platform list and the file map.system/backend/php/tests/Unit/Convert<Name>ToSiteTest.php.
webcomponents
elements/micro-frontend-registry/lib/microServices.js: aMicroFrontendRegistry.addentry withendpoint,name: "@system/<platform>ToSite",title,description,params.elements/micro-frontend-registry/test/micro-frontend-registry.test.js: add the pair to the importer list.elements/app-hax/lib/v2/app-hax-use-case-filter.js: strings in thethis.tblock (<platform>ImportDescription,<platform>ImportPrompt, and a tooltip if the icon needs one) and a card ingetImportItems()withimportKind: "url",importType,callback,param: "repoUrl",prompt,useCaseTitle,useCaseDescription,useCaseIcon,useCaseTag: ["Import", "<Name>"].elements/app-hax/locales/: nothing. Only the English strings from step 3 go in this PR. The locale guard blocks other locale files, and the nightly translation PR adds the new keys to every language.elements/app-hax/test/app-hax-use-case-filter.test.js: a card test next to the existing ones.elements/haxcms-elements/lib/haxcms-api-codes.json: the bundled copy of the API-code catalog (it is the stated source of truth; the backends mirror it). Apply the same regex additions as in the backends. The per-languagehaxcms-api.<lang>.jsonfiles key on the existing codes, so they need no change.
In a blobless or sparse clone of webcomponents, never git grep across history: it fetches blobs one at a
time. List paths with git ls-tree -r HEAD --name-only, read one file with git show HEAD:<path>, and add
only the directory you need with git sparse-checkout add. Also check that your prettier version matches the
repo's before running --write; a different major version reformats unrelated lines.
Do not run the ubiquity script or a top-level monorepo build. After the PR merges, a maintainer runs it
(see hax-release-prep).
create (the hax CLI)
An importer is not finished until the CLI can reach it, so this repo is part of the work and its PR is opened
with the others, without waiting to be asked. The CLI calls the backend's site/import/:platform dispatcher
in-process (the v1 path, not the retired open-apis broker), so this is a small change:
src/lib/programs/site.js: add<platform>ToSite: { platform: "<platform>" }toIMPORT_STRUCTURE_MAP.src/create.js: add<platform>ToSiteto the--import-structurehelp text. It appears twice; edit both.src/docs/hax.1: add it to the man page list.README.md: add it to the--import-structureoption list.test/unit/site-imports.test.cjs: add it to the expected platform table and add a mapping test.
Run npm run test:unit. npm run precheck can report an error in code you did not touch (a constant interpolated
into exec near HAXCMS_NODEJS_FALLBACK_SPEC); note it in the PR rather than changing it.
The CLI loads the backend from the published @haxtheweb/haxcms-nodejs package. Until a backend release that
contains the importer is published and the CLI's dependency picks it up, the new name answers "unsupported
import platform". Say so in the PR description, and do not bump the dependency yourself; releases are the
maintainer's step.
Testing
- The network is stubbed at
safeFetch; the suite never leaves the machine. Build a small synthetic fixture repository in memory (an object of path to contents, plus a tree listing) that carries every shape the importer handles. Do not commit third-party content as a fixture. - Cover: outline from config, nested groups, the file-tree fallback, each page transform, front matter
title override, asset registration and unique names, link rewriting, unmapped components, each limit, and
each error path (missing
repoUrl, bad host, no config, no pages, unreadable page). - Run the tier from
hax-testing:npm run test:unit,npm run test:api-conformance, andprecheckin Node; PHPUnit andyarn testin PHP; the registry and app-hax tests in webcomponents. If a tier cannot run in your environment, say which and why in the PR.
Trying it on a real source
A real repository is good for finding gaps, and only for that.
- Run the converter locally and inspect the output. Do not publish, deploy, or commit converted content, and do not put it in a PR, a test fixture or a demo site.
- Many sources are not openly licensed or restrict derivatives. A test run is not permission to redistribute, so check the repo's license before using it for anything beyond a local check.
- Prefer sources whose license allows derivatives when choosing a demo target.
- Record what the real run revealed (shapes the fixture missed) by adding a synthetic case to the fixture, not the real content.
- If the sandbox cannot reach the GitHub API (HTTP 403), clone the repo read-only into a scratch directory
and run the converter with
safeFetchreplaced by a stub that serves the tree and raw files from disk. Keep the script and its output outside the repository. - A first real run typically reveals syntax that straddles another construct, for example a figure caption that contains inline code and so splits across the code-span pass. Run inline rewrites that can contain code spans before the code-span protection pass, and guard against matches that start inside a code span.
- Check the converted output with counts, not eyeballs: leftover fences, attribute blocks, shortcodes, cross-reference keys and broken links across every page.
Workflow
- Read the issue in https://github.com/haxtheweb/issues and any plan comment. Check the plan against the reference converter; flag anything stale.
- Inventory the source format: where the outline lives, page file types, front matter, special syntax, asset conventions, and the license signals it carries.
- Write the Node converter and its tests against the synthetic fixture.
- Wire the dispatcher, spec, API codes.
- Port to PHP, structure for structure, then mirror the tests.
- Wire the client: registry service, chooser card, strings, locales.
- Run each repo's tests and pre-submission check.
7a. Wire the CLI (
create): the import map, help text, man page, README and test. - Open one PR per repo (all four, including
create), cross-linked and referencing the issue. Each description says what the PR touches and which commands you ran with their results. Do not merge; maintainers review.
Guardrails
- Link between repos by public URL, never by a local filesystem path.
- Do not add
@haxcms/registrations or touch the CLI's legacy--import-structurepath. - Do not hand-edit generated files,
build/, ornode_modules/; loadhax-managed-filesfirst. - A change that lands in only one backend is a bug in the other.
Checklist before opening the PRs
- Converter follows the output contract and security posture, in Node and PHP.
- Dispatcher, spec (path, platform list,
ImportDatanote), and API codes updated in both backends. - Client service, chooser card and English strings updated (no non-English locale files; those come nightly).
- Tests added in all four repos and passing, or the gap stated in the PR.
- The source's license is resolved with the shared list, unrecognized or non-4.0 licenses are reported
rather than guessed, and
warningscarries the notices; both backends match. - The
createCLI lists the importer (IMPORT_STRUCTURE_MAP, help text, man page, README, test), and its PR is open. - No optional chaining in Node; no direct network calls; no code from the source executed.
- No third-party content committed or published.
- PRs cross-link and reference the issue; nothing merged.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

