From 57a389f19ff84d59fca852d580aa282b5bc46873 Mon Sep 17 00:00:00 2001 From: Roman Zaiev Date: Sat, 21 Nov 2026 23:11:36 +0000 Subject: [PATCH 1/2] Write agents/ with starlight-hypha-agents starlight-theme-hypha 0.8.0 is a look alone: what agents read moved to starlight-hypha-agents, which every Hypha Stack library's docs now use. It writes the same agents/ from the same pages, so the installed docs do not change. Its check moves from `make lint`, which asked the theme to compare the folder without a build, to the docs workflow, which now builds every pull request and fails if agents/ differs from what the pages write. --- .github/workflows/docs.yml | 35 ++++++++++++++++++++++--------- AGENTS.md | 18 ++++++++-------- Makefile | 14 +++++-------- bun.lock | 7 +++++-- docs/astro.config.mjs | 43 +++++++++++++++++++------------------- docs/package.json | 3 ++- 6 files changed, 68 insertions(+), 52 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d0f1bc34..78ef7ab6 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,4 +1,5 @@ -# The documentation site on GitHub Pages, rebuilt on every push to main: +# The documentation site on GitHub Pages: built on every pull request, which +# fails if agents/ is not what the pages write, and deployed from main. # odoc's reference from the .mli files and the islands compiled by Melange, # then Starlight's pages around them. name: docs @@ -6,24 +7,23 @@ name: docs on: push: branches: [main] + pull_request: +# A build reads the repository and nothing more; the deploy job alone is +# given the rights to publish. permissions: contents: read - pages: write - id-token: write +# A newer push to a pull request replaces its build; main's deploys queue +# and always finish. concurrency: - group: pages - cancel-in-progress: true + group: pages-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - deploy: + build: runs-on: ubuntu-24.04 - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} steps: - - uses: actions/configure-pages@v6 - uses: actions/checkout@v5 - uses: ocaml/setup-ocaml@v3 with: @@ -42,8 +42,23 @@ jobs: # the token, past its limit for a runner's shared address. env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # The build writes agents/ from the pages: a page changed without it + # differs here. + - run: git add --intent-to-add agents/ && git diff --exit-code agents/ - uses: actions/upload-pages-artifact@v5 with: path: _build/docs + deploy: + needs: build + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-24.04 + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - uses: actions/configure-pages@v6 - uses: actions/deploy-pages@v5 id: deployment diff --git a/AGENTS.md b/AGENTS.md index ec523063..0149d423 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -23,8 +23,7 @@ make setup # once: the switch solidtype, all dependencies, and make test # the ppx's lowering, the plugin's rewrite, the # libraries' tests and the example's make lint # formatting, the plugin's and the generators' types, - # litany, the release build, the generated bindings, and - # agents/ against the pages + # litany, the release build and the generated bindings make fmt # format in place make example # the board, built by Vite into _build/example-dist, and # its Astro page, into _build/example-astro @@ -35,7 +34,8 @@ make docs # the documentation site, odoc's reference copied into # as .github/workflows/docs.yml publishes it from main make docs-serve # the documentation site built, served on DOCS_PORT with # search -make agents # agents/ written from the documentation's pages +make agents # agents/ written from the documentation's pages, by + # building them make release VERSION=1.2.3 # tag and release ``` @@ -191,7 +191,7 @@ docs/ the documentation, a Starlight site in Hypha's look, under a basket the client router keeps; the page imports their sources as @demo/?raw agents/ the documentation for a user's agent, generated by - starlight-theme-hypha from the pages, `make agents`: + starlight-hypha-agents from the pages, `make agents`: llms.txt, the catalogue; pages/, each page as Markdown, its examples written in; skills/solidtype/, the skill that sends an agent there; installed by the @@ -705,15 +705,15 @@ break. `_ Jsx.component`, never a function type, and an OCaml component is `Jsx.component make`. Why: Melange wraps an external function used as a value in a closure, which no JSX tag can name. -- **`agents/` is generated, never edited.** starlight-theme-hypha writes it - from the documentation's pages, `docs/agents.md` and the `agents` options - in `docs/astro.config.mjs`: a page changed is `make agents` run in the +- **`agents/` is generated, never edited.** starlight-hypha-agents writes it + from the documentation's pages, `docs/agents.md` and its options in + `docs/astro.config.mjs`: a page changed is `make agents` run in the same commit. A module with a page of its own names the page's installed path, `$(opam var solidtype:doc)/pages/.md`, in its `.mli`'s opening comment, and `generate/rhp.ts` writes it for rhp's generated components. Why: a user's agent reads what the release installs, offline, and a page - it reads must be the release's. Test: `make lint` runs `HYPHA_AGENTS=check - astro sync`, which fails on each file that differs from the pages. + it reads must be the release's. Test: the docs workflow builds the + pages on every pull request and fails if `agents/` then differs. - **Tests of what runs in a browser are OCaml, run by vitest.** Alcotest does not build for Melange; `melange-jest` reaches the globals vitest shares with Jest. The ppx, native, is tested by its expectations. Why: diff --git a/Makefile b/Makefile index 9decb42a..4caedc0e 100644 --- a/Makefile +++ b/Makefile @@ -30,10 +30,8 @@ test: build node_modules ## run the tests $(OPAM) dune test --force $(OPAM) bun run test -# Release is the profile opam installs with. agents/ is checked from docs/, -# where Astro finds its config, by reading the pages without building the -# site. -lint: node_modules ## check formatting, types, litany, the release build, bindings and agents/ +# Release is the profile opam installs with. +lint: node_modules ## check formatting, types, litany, the release build and bindings $(OPAM) dune build @all @fmt $(OPAM) dune build --profile release @all $(OPAM) litany check @@ -45,7 +43,6 @@ lint: node_modules ## check formatting, types, litany, the release build, bindin $(OPAM) bun generate/rhp.ts --check $(OPAM) bun generate/internationalized_date.ts --check $(OPAM) bun generate/gravity_icons.ts --check - cd docs && HYPHA_AGENTS=check bunx astro sync fmt: ## format the code $(OPAM) dune fmt @@ -77,10 +74,9 @@ docs: build node_modules ## build the documentation site docs-serve: docs ## serve the built documentation site cd docs && bun --bun astro preview --open --port $(DOCS_PORT) -# Each page as Markdown, llms.txt and the skill, from the documentation's -# pages, for the solidtype package to install. -agents: node_modules ## write agents/ from the documentation's pages - cd docs && HYPHA_AGENTS=write bunx astro sync +# Each page as Markdown, llms.txt and the skill, written by the docs' build +# for the solidtype package to install. +agents: docs ## write agents/ from the documentation's pages generate: node_modules ## write the generated bindings $(OPAM) bun generate/html.ts diff --git a/bun.lock b/bun.lock index b028c910..3a3238de 100644 --- a/bun.lock +++ b/bun.lock @@ -63,8 +63,9 @@ "react-dom": "^19.2.0", "solid-js": "~1.9.17", "solid-motionone": "~1.0.4", + "starlight-hypha-agents": "github:hyphatech/starlight-hypha-agents#v0.1.0", "starlight-links-validator": "^0.27.0", - "starlight-theme-hypha": "github:hyphatech/starlight-theme-hypha#v0.7.0", + "starlight-theme-hypha": "github:hyphatech/starlight-theme-hypha#v0.8.0", "tailwindcss": "^4.3.3", "tw-animate-css": "1.4.0", "vite-plugin-solidtype": "workspace:*", @@ -1150,9 +1151,11 @@ "space-separated-tokens": ["space-separated-tokens@2.0.2", "", {}, "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q=="], + "starlight-hypha-agents": ["starlight-hypha-agents@github:hyphatech/starlight-hypha-agents#f4d5889", { "dependencies": { "mdast-util-from-markdown": "^2.0.2", "mdast-util-mdx": "^3.0.0", "micromark-extension-mdxjs": "^3.0.0", "yaml": "^2.9.1" }, "peerDependencies": { "@astrojs/starlight": "~0.42.6", "astro": "^7.3.3" } }, "hyphatech-starlight-hypha-agents-f4d5889", "sha512-VWfTEY3oEtdyrAukv4KDIj1uVJxhCopxE6l5FeQvFqCd9nJ8unBff9hbw3DdLu/E15RZX8Qz7nck8BO/h8NcEA=="], + "starlight-links-validator": ["starlight-links-validator@0.27.0", "", { "dependencies": { "@astrojs/markdown-satteri": "^0.4.0", "github-slugger": "^2.0.0", "hast-util-from-html": "^2.0.3", "is-absolute-url": "^5.0.0", "mdast-util-mdx-jsx": "^3.2.0", "mdast-util-to-hast": "^13.2.1", "picomatch": "^4.0.3", "satteri": "^0.10.3", "terminal-link": "^5.0.0", "unist-util-visit": "^5.1.0", "yaml": "^2.8.3" }, "peerDependencies": { "@astrojs/starlight": ">=0.42.0", "astro": ">=7.2.10" } }, "sha512-UvPl8L9hfWR+yWbLOEtljLmpJCGcM6AVseVy5IO9dmqdOjW4R+Y8FaYyVA5axCC8RvxM5xU7M1WTerpwU8rYbw=="], - "starlight-theme-hypha": ["starlight-theme-hypha@github:hyphatech/starlight-theme-hypha#48e6341", { "dependencies": { "@fontsource-variable/roboto-slab": "^5.3.0", "@fontsource/inter-tight": "^5.3.0", "@lucide/astro": "1.48.0", "@tailwindcss/vite": "^4.3.3", "mdast-util-from-markdown": "^2.0.2", "mdast-util-mdx": "^3.0.0", "micromark-extension-mdxjs": "^3.0.0", "tailwindcss": "^4.3.3", "yaml": "^2.9.1" }, "peerDependencies": { "@astrojs/starlight": "~0.42.6", "astro": "^7.3.3" } }, "hyphatech-starlight-theme-hypha-48e6341", "sha512-i/dC9Q1Bnmxyh0mvFcNCPea0EjzTPbUTBbZrssevaXqVj2VqaaMHO2uEfjY50oqe62NegZ+Tm65JyGuC+kamOA=="], + "starlight-theme-hypha": ["starlight-theme-hypha@github:hyphatech/starlight-theme-hypha#a105fa6", { "dependencies": { "@fontsource-variable/roboto-slab": "^5.3.0", "@fontsource/inter-tight": "^5.3.0", "@lucide/astro": "1.48.0", "@tailwindcss/vite": "^4.3.3", "tailwindcss": "^4.3.3" }, "peerDependencies": { "@astrojs/starlight": "~0.42.6", "astro": "^7.3.3" } }, "hyphatech-starlight-theme-hypha-a105fa6", "sha512-1lDTrqupxaVND5rueaGZVy2mokekMHaaDHAI3d4TBW8KujgEMRQ3Ftec3+CeXz4vG0NCEd8HCjyW13GBY/eUtQ=="], "std-env": ["std-env@4.3.0", "", {}, "sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag=="], diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 10c7dbf6..2458e77e 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -6,6 +6,7 @@ import solid from "@astrojs/solid-js"; import starlight from "@astrojs/starlight"; import tailwindcss from "@tailwindcss/vite"; import links from "starlight-links-validator"; +import agents from "starlight-hypha-agents"; import hypha from "starlight-theme-hypha"; import solidtype from "vite-plugin-solidtype"; import astro from "@shikijs/langs/astro"; @@ -51,27 +52,27 @@ export default defineConfig({ github: "hyphatech/solidtype", tabs: { "Start here": "rocket", Solid: "zap", Kobalte: "blocks", HeroUI: "component", Charts: "waves-horizontal", Reference: "library" }, links: [{ label: "Hypha Stack", href: "https://hyphatech.io/stack", icon: "layers" }], - // Each page as Markdown, llms.txt and a skill, written into - // agents/ for the solidtype package to install, and held to the - // pages by `make lint`. agents.md is what an agent knows before any - // page. - agents: { - dir: "../agents", - preamble: readFileSync(new URL("./agents.md", import.meta.url), "utf-8"), - groups: { - HeroUI: "Each component's page gives HeroUI's own examples in OCaml, and a table of its props with the name HeroUI's React component gives each.", - Charts: "Each page links to the page of rhp's documentation it follows.", - Reference: "Each module's interface, its `.mli`, is its contract: what each function does, refuses and defaults to.", - }, - skill: { - name: "solidtype", - package: "solidtype", - description: - "Use before writing or changing OCaml code that uses solidtype or its packages: Solid's components, signals and stores in OCaml's JSX (.mlx), Kobalte's components, HeroUI's ported onto them (buttons, fields, lists, tabs, overlays, tables), rhp's charts, Gravity UI's icons and @internationalized/date.", - instead: [ - "a raw `