diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1911cded..007501d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,6 +44,14 @@ jobs: - uses: jdx/mise-action@d5574b52816a478f9d4e6529a3f6ff17a8a36785 # v5.2.8 with: version: 2026.11.8 + # npm's downloads for the docs' diagrams (lint:docs runs docs:diagrams), keyed on the lock. npm ci + # checks each package against the lock's integrity, and the Docs workflow, which publishes, keeps + # no cache. + - name: Cache npm downloads + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ~/.npm + key: npm-${{ runner.os }}-${{ hashFiles('docs/package-lock.json') }} - run: mise run lint - run: mise run test env: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 8db113d3..e7132ee5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -63,6 +63,7 @@ jobs: install_args: go hugo-extended node markdownlint-cli2 vale lychee # The workflow publishes, so no job in it reads a cache another run could have written. cache: false + # It draws the diagrams first (docs:diagrams), which the build below uses too. - run: mise run lint:docs # The site's address is baseURL in docs/hugo.yaml. - run: hugo -s docs --minify @@ -91,9 +92,11 @@ jobs: - uses: jdx/mise-action@d5574b52816a478f9d4e6529a3f6ff17a8a36785 # v5.2.8 with: version: 2026.11.8 - install_args: go hugo-extended + install_args: go hugo-extended node # What's published is built from no cache. cache: false + # The diagrams, drawn before the build (docs/render-diagrams.mjs). + - run: mise run docs:diagrams # docs/next.yaml over docs/hugo.yaml: next.devvm.dev's address, the banner and noindex. - run: hugo -s docs --minify --config hugo.yaml,next.yaml -d "$RUNNER_TEMP/next" # The key is checked out only after the build, which never sees it. @@ -157,9 +160,15 @@ jobs: - uses: jdx/mise-action@d5574b52816a478f9d4e6529a3f6ff17a8a36785 # v5.2.8 with: version: 2026.11.8 - install_args: go hugo-extended + install_args: go hugo-extended node # What's published is built from no cache. cache: false + # The tag's diagrams, drawn before the build, when its docs draw them (docs/render-diagrams.mjs); + # an older tag's pages load Mermaid instead. + - run: | + if [ -f docs/render-diagrams.mjs ]; then + mise run docs:diagrams + fi # The tag's docs/hugo.yaml, whose baseURL is devvm.dev. - run: hugo -s docs --minify - uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 diff --git a/.gitignore b/.gitignore index 92db0536..a836a74d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ dist/ docs/public/ docs/resources/ docs/.hugo_build.lock +docs/.build/ +docs/node_modules/ /devvm diff --git a/AGENTS.md b/AGENTS.md index 620b2118..95419df4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -67,6 +67,7 @@ Each package's concerns and identifiers: [The packages](docs/content/docs/contri - **Pin every download** in `assets/`'s `layers/`, `features/`, `shared-tools/build.sh`, `oci/build.sh`: `_version` and `_sha256_arm64`/`_amd64` at the top, picked with the prelude's `devvm_sha`, fetched with `devvm-fetch` (`oci/build.sh`: `sha256sum`). No `curl | sh`, no "latest". Upstream-checked exceptions: shared tools (`MISE_LOCKED=1`), Ubuntu's signed `SHA256SUMS`, Lima in `install.sh`. Go checks a download's SHA-256 before use. - **Shared tools are read-only in VMs:** whatever writes into a tool's folder (global installs, self-updates, `corepack enable`, `rustup component add`) is redirected (`~/.npm-global`, `go_set_gobin = false`), done in `assets/shared-tools/build.sh`, or off. - **In-VM scripts are bash 3.2-safe and shellcheck-clean** (`assets/`, `install.sh`): guard empty arrays (`${a[@]+"${a[@]}"}`), no associative arrays. Everything else is Go. +- **The one exception, the docs build's Node script:** `docs/render-diagrams.mjs` (`mise run docs:diagrams`) draws the site's diagrams with pele, pinned in `docs/package.json` and its lock and installed with `npm ci --ignore-scripts`; no other build script is JavaScript, and no other npm package is installed outside mise's tools. - **Docs:** an easy-to-follow guide in full, joined sentences, every fact kept, written with the docs-voice skill; every behavior change updates its page in the same task, and the README stays high level ([Writing docs](docs/content/docs/contributing/docs.md#writing-docs)). - **Adding or changing a command** follows the cli skill (`.agents/skills/cli/`): its checklist, then its review. - **Adding or changing a shared tool** updates its page and follows Contributing's checklist: `using/toolchains.md` for a toolchain ([Adding a toolchain](docs/content/docs/contributing/extending.md#adding-a-toolchain)), `using/coding-agents.md`'s Supported agents for an agent ([Adding a coding agent](docs/content/docs/contributing/extending.md#adding-a-coding-agent)). diff --git a/docs/assets/css/custom.css b/docs/assets/css/custom.css index 6f32626b..1ed8db5e 100644 --- a/docs/assets/css/custom.css +++ b/docs/assets/css/custom.css @@ -1165,31 +1165,69 @@ html.dark .highlight .chroma .go { } } -/* Diagrams (mermaid code blocks, themed in layouts/_partials/scripts/mermaid.html): at their own size, - centered, scrolled sideways when wider than the page. */ -.content pre.mermaid { +/* Diagrams (mermaid code blocks, drawn before the build by render-diagrams.mjs and inlined by + layouts/_markup/render-codeblock-mermaid.html): at their own size, centered. One wider than the + text reaches into the article's padding on the right, the page's right margin, as far as it needs, + and when that's not enough, into the padding on the left for the rest; the hook sets its width + (--devvm-diagram-width), and 100% in a margin is the text's width. One wider than the text and both + paddings scrolls sideways. The browser skips drawing one until it nears the screen + (content-visibility), and keeps its place at its height, which the hook sets + (contain-intrinsic-block-size), so the page doesn't jump. pele's variables give them the palette: + panels on the surface color with blue borders, lime lines and arrows, and text in Departure Mono, + which render-diagrams.mjs measures. */ +.content .devvm-diagram { + /* Hextra's article padding: 1.5rem, and 3rem from its md breakpoint. */ + --devvm-diagram-reach: 1.5rem; + --devvm-diagram-over: max(0px, calc(var(--devvm-diagram-width, 0px) - 100%)); display: flex; justify-content: safe center; overflow-x: auto; - margin: 1.5rem 0; - padding: 0; - font-family: var(--devvm-font-pixel); - font-size: 14px; + margin-block: 1.5rem; + margin-inline-end: calc(-1 * min(var(--devvm-diagram-reach), var(--devvm-diagram-over))); + margin-inline-start: calc(-1 * min(var(--devvm-diagram-reach), max(0px, calc(var(--devvm-diagram-over) - var(--devvm-diagram-reach))))); + content-visibility: auto; font-synthesis: none; + --pele-bg: var(--devvm-bg); + --pele-fg: var(--devvm-text); + --pele-fg-on-dark: var(--devvm-text); + --pele-muted: var(--devvm-text-secondary); + --pele-line: var(--devvm-accent); + --pele-accent: var(--devvm-accent); + --pele-surface: var(--devvm-surface); + --pele-surface-alt: var(--devvm-bg); + --pele-border: var(--devvm-blue); + --pele-font: var(--devvm-font-pixel); + --pele-font-mono: var(--devvm-font-pixel); + --pele-radius: 0; } -.content pre.mermaid svg { +@media (min-width: 768px) { + .content .devvm-diagram { + --devvm-diagram-reach: 3rem; + } +} + +.content .devvm-diagram svg { flex: none; } -/* Labels' lines on the font's cell, 18px at 14px, not the page's line height. Mermaid measures them in - the page, so their boxes fit. */ -.content pre.mermaid foreignObject p { - margin: 0; - line-height: 18px; +/* Subgraphs and sequence diagrams' lifelines in the darker border color. */ +.content .devvm-diagram .pele-cluster > rect, +.content .devvm-diagram .pele-lifeline { + stroke: var(--devvm-border); } -.content pre.mermaid rect { +/* Notes on black, in that border, with secondary text. */ +.content .devvm-diagram .pele-note > rect { + fill: var(--devvm-bg); + stroke: var(--devvm-border); +} + +.content .devvm-diagram .pele-note > text { + fill: var(--devvm-text-secondary); +} + +.content .devvm-diagram rect { shape-rendering: crispEdges; } diff --git a/docs/content/docs/contributing/_index.md b/docs/content/docs/contributing/_index.md index 38800044..b76aed87 100644 --- a/docs/content/docs/contributing/_index.md +++ b/docs/content/docs/contributing/_index.md @@ -38,7 +38,7 @@ mise installs every tool at the version pinned in `mise.toml`, checked against ` | goreleaser | release builds ([Maintaining](maintaining.md#releasing)) | | hugo-extended | the docs site | | vale, markdownlint-cli2, lychee | linting the docs | -| node | running markdownlint-cli2 | +| node | running markdownlint-cli2, and drawing the docs site's diagrams with pele, which `docs/package.json` pins ([diagrams](docs.md#writing-docs)) | | shellcheck | linting shell scripts | | actionlint, zizmor | linting the GitHub workflows, and checking them for security problems | | minisign | signing releases | @@ -50,14 +50,15 @@ Run the tasks with `mise run `: | `fmt` | formats Go code | | `lint` | runs `lint:code` and `lint:docs` | | `lint:code` | runs golangci-lint, shellcheck, actionlint and zizmor | -| `lint:docs` | runs the docs linters, the message link check, the command line check and the user pages' prose check, and builds the site, which fails on any warning | +| `lint:docs` | draws the diagrams (`docs:diagrams`), runs the docs linters, the message link check, the command line check and the user pages' prose check, and builds the site, which fails on any warning | | `test` | runs the tests with the race detector, then checks each package's coverage against its [baseline](tests.md#coverage) | | `coverage` | runs the tests, then raises each package's coverage baseline to what they reach (`scripts/test.sh --raise`) | | `vuln` | runs govulncheck on the code as built for Linux and as built for macOS | | `nilaway` | reports where a nil value may be dereferenced in devvm's own code, not the tests', and the findings that `testdata/nilaway-baseline.txt` hasn't triaged ([Nil checks](#nil-checks)) | | `deadcode` | lists functions nothing calls outside the tests: only `backendtest`'s, `stubtest`'s, `upgradetest`'s, `msg.IDOf`, `msg.NamesOf`, `msg.Recorder` and `msg.Fake`, which the tests use, and anything else it lists gets a caller or goes | | `cli-docs` | generates the CLI reference | -| `docs` | generates the CLI reference, then serves the docs site | +| `docs:diagrams` | installs pele with `npm ci` and draws the docs site's diagrams, which every build of the site needs first; it's skipped when no page, the script or pele's pins changed, reinstalls pele only when the lock changed and draws only the diagrams that changed ([diagrams](docs.md#writing-docs)) | +| `docs` | generates the CLI reference and draws the diagrams, then serves the docs site | | `e2e` | runs the end-to-end tests against real VMs | `mise run test` needs a C compiler for the race detector: Xcode Command Line Tools on macOS, gcc on Linux. It gives each package 30 minutes rather than go test's 10, because the CLI tests run the built binary against many stubs and take far longer on a busy machine. Both test tasks run `scripts/test.sh`, which gives the tests a throwaway `HOME`. diff --git a/docs/content/docs/contributing/docs.md b/docs/content/docs/contributing/docs.md index 46dd3769..11ddfb9a 100644 --- a/docs/content/docs/contributing/docs.md +++ b/docs/content/docs/contributing/docs.md @@ -13,7 +13,17 @@ The site is [Hugo](https://gohugo.io) with the [Hextra](https://imfing.github.io - **User pages lead with doing:** a task on a user page, in `getting-started/`, `using/`, `safety/`, `backends/` or `compared/`, shows its command, in a copyable block or numbered steps, and a short explanation follows. One paragraph of why next to its command is fine, but two or more paragraphs back to back mean the mechanism belongs on the How it works page, under a heading that the user page links to, with every fact moved rather than dropped. The docs-voice skill's [SKILL.md](https://github.com/devvmhq/devvm/blob/main/.agents/skills/docs-voice/SKILL.md) has the rule, under Commands first on user pages, with an example, and its `scan.sh -p paras` and `scan.sh -p long` list the runs and the long paragraphs. - **Front matter** sets `title`, shown as the page's heading, `weight`, the page's place in its section, or a section's place in the sidebar for an `_index.md`, and `explainer`, the line under the title on the page's social card, which Social cards below describes. Start the body at `##`. - **Links** to other pages point at their files (`[Contributing](_index.md)`), so the linters can check them. -- **Diagrams** are Mermaid code blocks, fenced with `mermaid`, which the browser draws when the page loads. `docs/layouts/_partials/scripts/mermaid.html` takes the place of Hextra's partial of the same name. It loads the Mermaid version that `hugo.yaml` pins in `params.mermaid.base`, which Hugo fetches when it builds the site, and it gives every diagram the same theme, so a diagram never sets its own colors or font. The theme uses the site's palette: panels on the surface color with blue borders, lime arrows, and text in Departure Mono at 14px, larger than the home page's art so labels read easily. It uses Mermaid's classic look, because its newer neo look draws a decision's hexagon 70px taller than its label. A diagram can set its own layout in front matter, as Staying safe's three columns set `minNodeWidth`, but never its own colors or font. Mermaid draws each diagram at its own size and never scales it to fit, and a diagram wider than the page scrolls sideways. Keep labels short, and break a long one with `
`. In a label, write `<` as `#lt;` and `>` as `#gt;`. A diagram goes where it helps the reader follow the text, with at most one sentence to introduce it, and the text keeps every fact the diagram shows. +- **Diagrams** are Mermaid code blocks, fenced with `mermaid`, which are drawn as SVGs before Hugo builds the site, so no page loads Mermaid or any other diagram JavaScript. A diagram goes where it helps the reader follow the text, with at most one sentence to introduce it, and the text keeps every fact the diagram shows. + - **Drawing them:** `mise run docs:diagrams` installs [pele](https://pele.run) with `npm ci --ignore-scripts`, at the version and integrity that `docs/package.json` and `docs/package-lock.json` pin, and then runs `docs/render-diagrams.mjs`. The script draws each block in `docs/content` as an SVG in `docs/.build/diagrams/`, which git ignores, with a JSON file of the diagram's size beside it. It names both for the block's key, a hash of the salt and the block's text, where the salt is a hash of pele's version and the script itself, and it writes the salt to that folder too. `mise run docs` and `mise run lint:docs` run it first, and so do the Docs workflow's builds. + - **Caching:** a run with nothing changed takes a few hundredths of a second. mise skips the task when the drawings' folder is newer than every page in `docs/content`, the script, `docs/package.json` and the lock, so the script updates the folder's time on every run. The task runs `npm ci` only when the lock's SHA-256 differs from the one it wrote to `docs/node_modules/.devvm-lock-sha256` after its last install. The script keeps every drawing that's already there, draws only the blocks it has no drawing of, and deletes the files no block's key names, so a changed diagram is drawn again on its own, and a new pele or a change to the script draws them all again. The CI workflow's check job caches npm's downloads, keyed on the lock, and the Docs workflow, which publishes, keeps no cache and draws every diagram. + - **Putting them in pages:** `hugo.yaml` mounts that folder at `assets/diagrams`, and the render hook, `docs/layouts/_markup/render-codeblock-mermaid.html`, which takes the place of Hextra's, reads the salt, computes each block's key from it and the block's text, and puts the SVG in the page. A block without its SVG fails the build, so run `mise run docs:diagrams` again after you change a diagram, even while `mise run docs` serves the site, because the server doesn't redraw them. + - **The theme** is in `custom.css`, which sets pele's `--pele-*` variables from the site's palette, so a diagram never sets its own colors or font. Panels are on the surface color with blue borders, lines and arrows are lime, subgraphs, lifelines and notes use the border color, and text is in Departure Mono at 14px, larger than the home page's art so labels read easily. + - **The layout** is pele's own, with the Mermaid settings that `render-diagrams.mjs` passes, such as right-angled edges. A diagram can set its own layout in front matter, as Staying safe's three columns set `minNodeWidth`, but never its own colors or font. pele lays subgraphs out from left to right in the order they're written. + - **Measuring labels:** the script measures each label by Departure Mono's metrics, where every character is 350/550 of the font size wide, so labels fit their boxes. pele draws edge labels, messages and notes at seven-eighths of the size, 12px, and has no option to change it, so the measurer gives that text its width at 14px and the script then writes it at 14px. A self-check, before anything is drawn, fails the run when pele no longer measures and writes that text as the script expects, and every group of small text that pele draws must carry the 12px size the script replaces. The script also puts a newline after each label, where the SVG draws nothing, so the site's search sees one label's last word apart from the next label's first. + - **Size:** each diagram is drawn at its own size and never scaled to fit. The hook sets each diagram's width on it, and a diagram wider than the text reaches into the page's right margin, the article's padding, as far as it needs, and into the padding on the left for whatever the right margin can't hold, so it never covers the table of contents. A diagram wider than the text and both paddings scrolls sideways, as the widest ones do on a narrow screen. `custom.css` gives each one `content-visibility: auto`, so the browser draws it only when it nears the screen, and the hook sets the diagram's height as its `contain-intrinsic-block-size`, so the page doesn't jump while you scroll. + - **Accessibility:** every diagram has an `accTitle` and a one-line `accDescr`, which become the SVG's title and description that screen readers read, and the script fails on a diagram without them. The description says in full sentences what the diagram shows. + - **Labels:** keep labels short, and break a long one with `
`. In a label, write `<` as `#lt;` and `>` as `#gt;`. + - **pele's version** is pinned exactly, and `scripts/bump.sh pele` moves it ([updating pinned versions](maintaining.md#updating-pinned-versions)). - **Style:** succinct and direct. Commands are written as devvm x or in backticks, never in quotes. No `please`, `simply` or `note that`. - **The home page** is `docs/content/_index.md`, on Hextra's `hextra-home` layout: its hero shortcodes, then plain Markdown. `custom.css` styles it through the one `div` that the layout wraps its content in. After the hero, the page has a quick start, what's supported, why to use devvm with its feature cards, a short FAQ, and a closing call to action with the hero's buttons. It keeps a marketing tone, but each of its claims matches the docs page it links to, it uses the same terms, and it says each thing once. - **The quick start** shows the three commands to run first, each after a comment short enough to fit a phone's width, because a comment after its command would scroll out of view there. @@ -23,7 +33,7 @@ The site is [Hugo](https://gohugo.io) with the [Hextra](https://imfing.github.io - **Other content per operating system** goes in `{{}}`, with a `{{}}` and then a `{{}}` inside it, each holding Markdown, as Installing's requirements tables do. It uses the same tabs, styles and script as the install commands, so the visitor's system is selected, and the build fails unless the tabs are macOS's, then Linux's. - **Colors:** the site is dark only (`hugo.yaml`'s `params.theme`). Its palette is in `docs/assets/css/custom.css`: a black background and one lime accent, `#7fff00`, which sets Hextra's primary color. The home page's illustrations also use `#0086b3`, the blue that Hextra's syntax highlighting gives commands like `cd`, and `#ff5370` (`--devvm-red`), the JustBlack theme's red, which marks only what an attack has compromised. The red's contrast is 6.7:1 on the black and 6.0:1 on the surface color, and it's much darker than the lime, so the two stay apart for readers who can't tell red from green. - **Fonts:** the site uses Instrument Sans for text, Martian Mono for code, and Departure Mono, a pixel font, for the logo and the home page's headings, badge and buttons. All three are in `docs/static/fonts/`, each in its own folder with its license, and `docs/layouts/_partials/custom/head-end.html` declares them. Instrument Sans and Martian Mono are upstream's variable WOFF2 files, so one file holds every weight, and the partial's comment records where each font came from, at which commit or release, and its SHA-256. To update a font, download the new version from the same place, check its SHA-256, and update the comment. Departure Mono is sharp at multiples of 11px and has one weight. -- **No third-party requests:** devvm.dev and next.devvm.dev load every script, stylesheet, font and image from the site itself, so a visitor's browser asks no other host for anything. `mise run lint:docs` checks this after it builds the site: `TestNoThirdPartyLoads` in `internal/cli/docgen/site_test.go` reads every page and stylesheet and fails on a link, script, image, frame or CSS `url()` that points at a host other than the ones in `hugo.yaml`'s and `next.yaml`'s `baseURL`. Hugo fetches FlexSearch, which Hextra's search uses, and the Mermaid version that `hugo.yaml` pins when it builds the site, and the site serves both itself, so they pass. Links that a visitor clicks, such as GitHub's, aren't loads, and the check ignores them. The social cards draw it from `docs/assets/fonts/departure-mono/`, which has the same release's OTF and license, because Hugo can't draw text from a WOFF2. +- **No third-party requests:** devvm.dev and next.devvm.dev load every script, stylesheet, font and image from the site itself, so a visitor's browser asks no other host for anything. `mise run lint:docs` checks this after it builds the site: `TestNoThirdPartyLoads` in `internal/cli/docgen/site_test.go` reads every page and stylesheet and fails on a link, script, image, frame or CSS `url()` that points at a host other than the ones in `hugo.yaml`'s and `next.yaml`'s `baseURL`. Hugo fetches FlexSearch, which Hextra's search uses, when it builds the site, and the site serves it itself, so it passes. Diagrams are SVGs inside the pages, so they load nothing. Links that a visitor clicks, such as GitHub's, aren't loads, and the check ignores them. The social cards draw it from `docs/assets/fonts/departure-mono/`, which has the same release's OTF and license, because Hugo can't draw text from a WOFF2. - **The logo** in the navbar is the branding page's `devvm-logo-on-dark.svg` at its own size, which `hugo.yaml`'s `params.navbar.logo` names, with the site's title as its alt text. Right-clicking it opens the branding page instead of the browser's menu, through a script in `docs/layouts/_partials/custom/footer.html`. A left click, or Enter on the focused logo, still goes to the home page. - **The branding page** is `docs/content/branding.md`, at `/branding/`, on its own layout, `docs/layouts/branding.html`, which is Hextra's home layout with the home page's look and the script that copies a swatch's hex. Its front matter keeps it out of the sidebar. It has the logo as box-drawing text in a code block, the logo's SVGs and PNGs, the icons, the social card, the palette, the fonts, how to use the logo and the credits. - **Its downloads** are in `docs/static/branding/`, and `{{}}` tiles inside `{{}}` show each one on its background, with a link to each file. The build fails when a file doesn't exist, and it reads each PNG's size for its link. `devvm-logo-on-dark.svg` and `devvm-logo-on-light.svg` are the logo, drawn on a pixel grid as the favicon is, made from Departure Mono's 11px glyphs. The prompt and devvm are at twice the glyphs' size, the box is in 1-pixel lines, and the lock, a block with a keyhole under a 2-pixel arch, sits on the box's bottom-right corner, with the box's lines stopping short of it so that the arch stands clear. The version for light backgrounds is black, with its prompt in the dark lime, `#408000` (`--devvm-accent-dark`), which is the lime's hue at half its lightness, with a contrast of 4.9:1 on white, where the lime has 1.2:1. Each logo's PNG is its SVG at four times its size on a transparent background, and `devvm-icon-64.png` to `devvm-icon-1024.png` are `docs/static/favicon.svg` at 4 to 64 times its size. After changing an SVG, render its PNGs again with headless Chrome's `--screenshot` at the exact size, passing `--default-background-color=00000000` for the logos' transparency, and look at each one. @@ -89,4 +99,4 @@ The tests fail when the checked-in pages are stale: `TestReferenceIsCurrent` in ### Building the site -`mise run docs` serves the site at `http://localhost:1313/` and reloads on every change. `mise exec -- hugo -s docs --minify` builds it into `docs/public/`, as the Docs workflow does for devvm.dev, and `mise exec -- hugo -s docs --minify --config hugo.yaml,next.yaml` builds the site as next.devvm.dev has it, with its banner and its noindex ([the docs sites](maintaining.md#the-docs-sites)). +`mise run docs` draws the diagrams, then serves the site at `http://localhost:1313/` and reloads on every change but a diagram's, which needs `mise run docs:diagrams` again. After `mise run docs:diagrams`, `mise exec -- hugo -s docs --minify` builds it into `docs/public/`, as the Docs workflow does for devvm.dev, and `mise exec -- hugo -s docs --minify --config hugo.yaml,next.yaml` builds the site as next.devvm.dev has it, with its banner and its noindex ([the docs sites](maintaining.md#the-docs-sites)). diff --git a/docs/content/docs/contributing/maintaining.md b/docs/content/docs/contributing/maintaining.md index a2386e33..98164cde 100644 --- a/docs/content/docs/contributing/maintaining.md +++ b/docs/content/docs/contributing/maintaining.md @@ -13,13 +13,13 @@ For maintainers: version bumps and releases. Run the scripts with mise, which pu ```sh scripts/bump.sh --check # every pin, by group, against upstream; changes nothing scripts/bump.sh # every patch and minor bump, then a summary for the commit message -scripts/bump.sh docker mermaid # only these tools, with a named images or e2e tool's major +scripts/bump.sh docker pele # only these tools, with a named images or e2e tool's major ``` - `--check` prints each group's pins under its name in brackets, such as `[go]`, with each pin's current version and upstream's newest, and whether a bump would be a patch, a minor or a major, or a new digest, commit, checksum or release for a pin that isn't a version. A held pin says which version holds it, and a line that the run wouldn't apply says how to apply it. When upstream's latest is older than a pin, as when a release marker hasn't moved yet, `--check` says the pin is newer and `bump.sh` leaves it as it is. - With no tools named, `bump.sh` applies every patch and minor bump, and never a major, a held pin or a tool that it applies only when named. Naming an images or e2e tool applies its major too. `e2e-tools` always applies one, because users get the shared tools' new majors as well, and `assets/shared-tools/mise.toml` holds what stays. -- It writes a value only if it has the shape of a pin (a version, a 64-hex checksum, a dated release, a commit, an image digest), since some of the edited files run on the host, and it edits nothing unless every value is good. Then it runs the commands that finish a bump: `mise lock` for Go and the dev tools, `go get` and `go mod tidy` for the modules, `go get` and `hugo mod tidy` in `docs/` for Hextra, and actionlint and zizmor for the workflows. If one of those fails, the pins are already edited, and it says so. -- It needs `curl` and `jq`, `mise` for Go, the dev tools and the end-to-end lock, `go` to apply the modules and Hextra, and `gh` for the actions. +- It writes a value only if it has the shape of a pin (a version, a 64-hex checksum, a dated release, a commit, an image digest), since some of the edited files run on the host, and it edits nothing unless every value is good. Then it runs the commands that finish a bump: `mise lock` for Go and the dev tools, `go get` and `go mod tidy` for the modules, `go get` and `hugo mod tidy` in `docs/` for Hextra, `npm install --ignore-scripts` in `docs/` and then `mise run docs:diagrams` for pele, and actionlint and zizmor for the workflows. If one of those fails, the pins are already edited, and it says so. +- It needs `curl` and `jq`, `mise` for Go, the dev tools, the end-to-end lock and pele, `go` to apply the modules and Hextra, and `gh` for the actions. - Every Monday the Pins workflow (`.github/workflows/pins.yml`) runs `scripts/bump.sh --check` and opens or updates one issue, "Pinned versions to bump", which lists the outdated pins under their groups, and closes it once none is left. It never bumps anything: you run `scripts/bump.sh`, then the `--from` tier of the [end-to-end tests](tests.md#end-to-end-tests) when an images or e2e pin moved, because those bumps change images. The tools, by group, as `--check` prints them: @@ -32,16 +32,16 @@ The tools, by group, as `--check` prints them: | `go` | `go`, `go-minor` only when named, `go-mods`, `deadcode` | Go, its modules and the deadcode task | | `dev-tools` | `dev-tools` | `mise.toml`'s tools but Go, with their `mise.lock` entries | | `ci` | `ci-mise`, `actions` | the mise the workflows install, and their actions | -| `docs` | `hextra`, `mermaid` only when named | the docs site's theme and Mermaid | +| `docs` | `hextra`, `pele` only when named | the docs site's theme, and pele, which draws its diagrams | - `go` moves Go to its newest patch release of the minor that `go.mod` names: the `go` lines of `go.mod` and `docs/go.mod`, `mise.toml`'s `go`, and its `mise.lock` entries, from `go.dev/dl`. `--check` reports a newer minor on the `go-minor` line, and `scripts/bump.sh go-minor` moves the same files to it. - `go-mods` moves `go.mod`'s direct modules, the ones the depguard allowlist allows and the tests' own, to their newest patch or minor release from the Go module proxy, with `go get` and `go mod tidy`. The indirect ones move as `go mod tidy` needs them. A module's next major has a new path, so `--check` reports it and you move it by hand. `deadcode` moves the deadcode task's version in `mise.toml` to golang.org/x/tools' newest release. - `dev-tools` moves each of `mise.toml`'s tools but Go to mise's newest version of it, edits its line and runs `mise lock`, so `mise.lock` keeps every platform's checksum, and markdownlint-cli2's lock folder in `.mise/locks/` moves with it. nilaway has no releases, so its pin is a pseudo-version, and `dev-tools` moves it to the one for its newest commit. - `ci-mise` moves the `version` that the workflows give jdx/mise-action to base's mise, as the run leaves it, so `scripts/bump.sh mise ci-mise` moves both. `actions` moves each workflow's `uses:` to its newest release's tag, as the tag's commit from `gh api`, with the tag in the comment after it, and reports a newer major without applying it. -- `hextra` moves the docs site's theme in `docs/go.mod`, and it reminds you to compare the copies of Hextra's files in `docs/layouts/` with the new release's. `mermaid` moves the Mermaid version in `docs/hugo.yaml`, only when named, because its diagrams need a look on the built site. +- `hextra` moves the docs site's theme in `docs/go.mod`, and it reminds you to compare the copies of Hextra's files in `docs/layouts/` with the new release's. `pele` moves pele, only when named, because the diagrams need a look on the built site: it runs `npm install` in `docs/` with the exact version and no install scripts, which writes `docs/package.json` and `docs/package-lock.json`, and then draws the diagrams again with `mise run docs:diagrams`. The drawing script's self-check fails that step when the new pele no longer measures and writes its small text, such as edge labels, as the script expects ([diagrams](docs.md#writing-docs)). - `cursor` moves Cursor's CLI, only when named, to the release that Cursor's install script fetches, with each platform's SHA-256 computed from its download, because Cursor publishes no checksums. devvm's login and proxy code was read against the pinned release, so read the new one where that code names it, then run `e2e-tools`. - A hold keeps a pin below a version, and `--check` shows the newest version beside it. Go modules and actions take Dependabot's ignore list in `.github/dependabot.yml`, which keeps pflag below 1.1.0, because pflag 1.1 prints every boolean flag with `[=true|false]` in the help. The other holds are in `bump.sh`'s `holds`, which keeps Node, the one in `mise.toml`, on its major. -- `bump.sh`'s header lists every pin with the tool that moves it, or with `-` and the reason it's left, as `# pin` lines. `TestBumpCoversPins` in `internal/structure` finds the pins in `assets/`, `mise.toml`, both `go.mod` files, the workflows, `tests/e2e-mise.lock`, `tests/e2e`'s consts and `docs/hugo.yaml`, without the network, and fails on a pin that no line covers or on a line that covers nothing, so a new pin gets a tool or a reason. The header also says why the pins outside those files are left as they are, such as the Lima that `install.sh` installs, which is the newest release checked against its `SHA256SUMS`, and the Homebrew formula, whose URLs and checksums `release.sh` fills in. +- `bump.sh`'s header lists every pin with the tool that moves it, or with `-` and the reason it's left, as `# pin` lines. `TestBumpCoversPins` in `internal/structure` finds the pins in `assets/`, `mise.toml`, both `go.mod` files, the workflows, `tests/e2e-mise.lock`, `tests/e2e`'s consts, `docs/hugo.yaml` and `docs/package.json`'s dependencies, without the network, and fails on a pin that no line covers or on a line that covers nothing, so a new pin gets a tool or a reason. The header also says why the pins outside those files are left as they are, such as the Lima that `install.sh` installs, which is the newest release checked against its `SHA256SUMS`, and the Homebrew formula, whose URLs and checksums `release.sh` fills in. - base's Ubuntu cloud image and its apt packages have nothing to bump: devvm pins the newest image on each machine at its first build of base, and records the newest packages for each key of base at its first build ([Ubuntu's cloud image](../internals/images.md#ubuntus-cloud-image), [base's packages](../internals/images.md#bases-packages)). `docker` moves Docker's packages (`assets/layers/docker.sh`), read from its repository for base's Ubuntu release, and its signing key. Packages added to `assets/layers/base.sh` or `assets/features/` need no pin of their own: they change base's key, whose first build records them. - `mise` moves base's mise (`assets/layers/base.sh`) and devvm's host mise (`internal/tools/mise.go`) together: the host one writes the lock base's installs from. `TestMisePins` fails when their versions or Linux checksums differ, and base's mise version is in the key of each tool image mise installs, so a bump builds them again. - The shared tools aren't pinned for users, but for Cursor's CLI: holds go in `assets/shared-tools/mise.toml` (`node = "24"` stays on that major). `testdata/mise.lock` is a fixed lock for the tests. @@ -128,5 +128,6 @@ The docs have two sites, and the Docs workflow (`.github/workflows/docs.yml`) de - **devvm.dev** is GitHub Pages, in the repo's `github-pages` environment, which accepts deployments from `main` and from `v*` tags, and only admins can create a `v*` tag. When a release is published, and it isn't a prerelease, the workflow builds the docs in that release's tag and deploys them. A release event runs the workflow file that the tag has, so a release whose tag predates this workflow doesn't deploy on its own. Pushes to `main` never change devvm.dev. - **To deploy a release's docs by hand,** for a release that didn't deploy on its own or to put devvm.dev back on a release, run the Docs workflow from `main` in the repo's Actions tab, or with `gh workflow run docs.yml --repo devvmhq/devvm -f site=devvm.dev -f ref=v0.1.0`. The site is `devvm.dev` unless you choose another one, and the ref is the release's tag, which has to look like `v0.1.0`, so a prerelease's tag is refused. Without a ref, the workflow deploys the latest release, as `gh release view` names it. - **next.devvm.dev** is Cloudflare Pages, serving the files on the `main` branch of the repo `devvmhq/docs-next`, and Cloudflare builds nothing. On each push to `main` that touches the docs, the workflow lints and builds `main`'s docs for next.devvm.dev, then replaces everything in `devvmhq/docs-next` but its `README.md` with the build, and commits it as `Build from devvm `. When the build is the same as the last one, it commits nothing. `gh workflow run docs.yml --repo devvmhq/devvm -f site=next.devvm.dev` runs it by hand. Nobody edits `devvmhq/docs-next` by hand, because the next build replaces it. +- **Every build draws the diagrams first,** with `mise run docs:diagrams`, so each of the workflow's jobs installs Node through mise. A release whose tag predates the drawing script, `docs/render-diagrams.mjs`, loads Mermaid in its pages instead, so the release job draws them only when the tag has that script. - **The deploy key** that pushes to `devvmhq/docs-next` is the secret `DOCS_NEXT_DEPLOY_KEY` in the `docs-next` environment, which only `main` can deploy from. It's an ed25519 key with write access to `devvmhq/docs-next` and to nothing else. The workflow checks that repo out with it only after the site is built, so the build never sees the key. To rotate it, make a new key, add its public half to `devvmhq/docs-next` as a deploy key with write access, put its private half in the secret, then delete the old deploy key. - **The next build** is `hugo -s docs --minify --config hugo.yaml,next.yaml`, which reads `docs/next.yaml` over `docs/hugo.yaml`. It sets the site's address to `https://next.devvm.dev/` and puts a banner on every page that says these docs are for the next devvm and links to devvm.dev. It also sets `noindex`, so Hextra gives every page a `noindex, nofollow` robots meta tag, and `docs/layouts/robots.txt` disallows everything, so search engines don't index the site. devvm.dev's build, `hugo -s docs --minify`, never reads `docs/next.yaml`, so it has no banner, its pages say `index, follow`, and its `robots.txt` allows everything. diff --git a/docs/content/docs/internals/backends.md b/docs/content/docs/internals/backends.md index 045cb8b8..ffc9eaaf 100644 --- a/docs/content/docs/internals/backends.md +++ b/docs/content/docs/internals/backends.md @@ -71,6 +71,8 @@ devvm checks each feature an image or a VM needs this way: ```mermaid flowchart TD + accTitle: How devvm checks a feature + accDescr: A feature that the image or the VM needs is allowed when the backend has it natively, or emulates it and the emulation is reviewed. An unreviewed emulation, or none, is refused, and devvm stops and names the VM, the feature and the backend, except egress-proxy for a new open VM, which is made open, as asked. need["a feature the image
or the VM needs"] --> how{{"how the backend has it"}} how -- "native" --> ok["allowed"] how -- "emulated, reviewed" --> ok diff --git a/docs/content/docs/internals/images.md b/docs/content/docs/internals/images.md index 61034899..d85b44db 100644 --- a/docs/content/docs/internals/images.md +++ b/docs/content/docs/internals/images.md @@ -37,6 +37,8 @@ Each key hashes its parent's, so a new key anywhere in the chain changes the key ```mermaid flowchart TD + accTitle: Image keys in a chain + accDescr: Each image's key hashes its parent's key, as in base, then foo, then foo+bar. After foo.sh is edited, or devvm rebuild foo, base keeps its key and is reused, and foo and foo+bar get new keys and are built again. subgraph next["after foo.sh is edited,
or devvm rebuild foo"] b2["base
key 1a2b3c4d5e6f
reused"] -- "its key" --> f2["foo
key 9a0b1c2d3e4f
built again"] f2 -- "its key" --> fb2["foo+bar
key 5a6b7c8d9e0f
built again"] diff --git a/docs/content/docs/internals/install.md b/docs/content/docs/internals/install.md index f4c52b50..bc9a4c04 100644 --- a/docs/content/docs/internals/install.md +++ b/docs/content/docs/internals/install.md @@ -25,6 +25,8 @@ At the end, when `~/.local/bin` is on `PATH`, the script looks up which devvm `P ```mermaid flowchart TD + accTitle: How each install checks the release + accDescr: In the GitHub release, install.sh, with the public key, checks the signature on SHA256SUMS, signed in .minisig, and SHA256SUMS checks the archive for this machine. Homebrew's formula, in a repository of its own, checks the same archive against its own checksum. subgraph release["the GitHub release"] script["install.sh, with
the public key"] -- "checks the signature" --> sums["SHA256SUMS,
signed in .minisig"] sums -- "checks the checksum" --> archive["the archive
for this machine"] diff --git a/docs/content/docs/internals/lima.md b/docs/content/docs/internals/lima.md index 4b1ee457..bd007187 100644 --- a/docs/content/docs/internals/lima.md +++ b/docs/content/docs/internals/lima.md @@ -44,6 +44,8 @@ On each host, the VM's traffic passes through one process that devvm confines: ```mermaid flowchart TD + accTitle: The process that confines a VM's traffic + accDescr: On Linux, the VM's traffic goes through QEMU, with restrict=on, which reaches only its proxy at 192.168.5.4:3128. On macOS, it goes through its Lima hostagent, which is sandboxed, so it reaches only its ssh port, its proxy, its Lima sockets and its SSH agent, and everything else is denied. subgraph linux["Linux"] vm2["the VM"] --> q["QEMU,
restrict=on"] end diff --git a/docs/content/docs/internals/network.md b/docs/content/docs/internals/network.md index ccc11afe..efedec90 100644 --- a/docs/content/docs/internals/network.md +++ b/docs/content/docs/internals/network.md @@ -50,6 +50,8 @@ A `CONNECT` tunnel meets the proxy's checks in this order: ```mermaid flowchart TD + accTitle: The proxy's checks on a CONNECT tunnel + accDescr: The proxy checks a CONNECT tunnel from the VM in order: the VM's password, else 407, a host name or an address, else 400, and fewer than 1024 tunnels open, else 503. transparent.devvm.proxy takes the host from its first bytes, TLS's SNI or each HTTP Host, and closes the tunnel when there's none, and devvm.proxy, its names and 198.18.0.1 get 403. One of the VM's links goes to the link's socket untouched, and a transparent connection to one is refused. Any other host must be on the allowlist and not denied, else 403, which a transparent TLS connection gets over the VM's CA, and it must be public and not this machine's or an address a rule names, and on port 443 when rules judge its requests, else 403. A bound host, on port 443, or one whose requests are judged, is intercepted with the VM's CA, where each request must name the host, else 421, and be allowed by the rules, else 403, before its placeholder is swapped for the real value. Any other tunnel passes untouched when its TLS SNI names the CONNECT host, or it isn't TLS. conn["CONNECT host:port from the VM"] --> pw["the VM's password?
no: 407"] pw --> name["a host name or an address?
no: 400"] name --> room["fewer than 1024 tunnels open?
no: 503"] @@ -59,7 +61,7 @@ flowchart TD reserved -- "no" --> own["devvm.proxy or under it,
or 198.18.0.1?
yes: 403"] own --> link{{"one of the VM's links?"}} link -- "yes" --> linked["the link's socket,
tunneled untouched
(transparent: refused)"] - link -- "no" --> allow["on the allowlist, and not denied?
no: 403
(transparent TLS: 403 over the VM's CA)"] + link -- "no" --> allow["on the allowlist, and not denied?
no: 403
(transparent TLS: 403
over the VM's CA)"] allow --> floor["public and not this machine's,
or an address a rule names?
no: 403"] floor --> narrowed["rules by method and path
judge its requests:
on port 443?
no: 403"] narrowed --> bound{{"a bound host, on port 443,
or its requests judged?"}} @@ -389,6 +391,8 @@ This is the check, and what devvm does when it fails: ```mermaid flowchart TD + accTitle: The self-check on every launch + accDescr: On every launch, devvm checks that the VM runs on the process devvm started and that a direct connection from it fails. If either isn't so, the check is unenforced. A VM started confined is then stopped, because it has another way out. Otherwise, without a terminal, devvm stops the VM without a shell, and the next devvm starts it confined. In a terminal, devvm offers to restart it confined, and warns and goes on if you say no, or stops it if the check still fails after the restart. launch["every launch"] --> proc["on the process
devvm started?"] proc -- "yes" --> direct["a direct connection
from the VM fails?"] direct -- "yes" --> ok["check: ok"] diff --git a/docs/content/docs/internals/overview.md b/docs/content/docs/internals/overview.md index 947dc7de..7a2b31d4 100644 --- a/docs/content/docs/internals/overview.md +++ b/docs/content/docs/internals/overview.md @@ -12,6 +12,8 @@ When you run `devvm` in a folder that has no VM, devvm makes one in these steps: ```mermaid flowchart TD + accTitle: How devvm makes a VM + accDescr: Until the first shell opens, devvm checks everything first, checks the shared tools for newer versions if due, builds the image if it isn't built, writes the VM's state, makes the VM from its image, locks .git unless --clone, starts its proxy and then the VM, runs the self-check, and sets the VM up, then the clone and devcontainer.json's commands. Then it opens the shell. If it's interrupted before then, devvm deletes the VM and what it made for it, and unlocks .git. subgraph before["until the first shell opens"] check["checks everything first:
image, size, ports,
network tier, SSH agent,
features, devcontainer.json"] --> tools["checks the shared tools
for newer versions, if due"] tools --> build["builds the image,
if it isn't built"] diff --git a/docs/content/docs/internals/ports.md b/docs/content/docs/internals/ports.md index a7100018..93b5028a 100644 --- a/docs/content/docs/internals/ports.md +++ b/docs/content/docs/internals/ports.md @@ -45,6 +45,8 @@ A connection to a forwarded port, such as 5173, takes this path: ```mermaid flowchart TD + accTitle: A connection to a forwarded port + accDescr: Your browser on this machine connects to localhost:5173, where devvm's forwarder, on this machine, takes it over ssh, with a key and a host key devvm pins, to the VM's sshd, which connects to your server on the VM's own loopback, 127.0.0.1:5173. browser["your browser, on this machine,
where every connection starts"] -- "localhost:5173" --> fwd["devvm's forwarder,
on this machine"] fwd -- "ssh, with a key and
a host key devvm pins" --> sshd["the VM's sshd"] sshd -- "127.0.0.1:5173,
its own loopback" --> server["your server, in the VM"] @@ -104,6 +106,8 @@ A program in the client that connects to `db:5432` takes this path: ```mermaid flowchart TD + accTitle: A connection over a link + accDescr: Your program in the client connects to db:5432, which /etc/hosts names as 127.77.0.1. The client's sshd passes it over the link session's ssh, which this machine opened, to devvm _links on this machine, which connects over ssh, with the target's key and pinned host key, to the target's sshd, and so to the server on the target's own loopback, 127.0.0.1:5432. app["your program, in the client"] -- "db:5432, which /etc/hosts
names as 127.77.0.1" --> csshd["the client's sshd"] csshd -- "the link session's ssh,
which this machine opened" --> links["devvm _links,
on this machine"] links -- "ssh, with the target's key
and pinned host key" --> tsshd["the target's sshd"] diff --git a/docs/content/docs/safety/_index.md b/docs/content/docs/safety/_index.md index 7b4c1808..7f74ff9c 100644 --- a/docs/content/docs/safety/_index.md +++ b/docs/content/docs/safety/_index.md @@ -29,15 +29,15 @@ config: minNodeWidth: 0 --- flowchart TB + accTitle: What a VM can do with what's on this machine + accDescr: The VM reaches the project folder, read-write, or its own clone with --clone, and what its network tier allows, through the proxy. It gets the shared tools and devvm's agent store's folders read-only, and copies of its settings files, minus your secrets. Out of its reach are the rest of your home folder, the .git hooks and config, which are locked, your SSH agent, unless you turn it on, and your secrets, which stay on this machine. %% Narrower nodes than other diagrams' and labels of at most 12 characters a line, so three - %% columns fit the page. Mermaid lays the columns out from right to left, so the last one comes first. - subgraph out["Out of reach"] + %% columns fit the page. The columns are laid out from left to right in the order they're written. + subgraph reach["The VM reaches"] direction TB - home["the rest of
your home
folder"] - git[".git hooks
and config,
locked"] - agent["your SSH
agent,
unless you
turn it on"] - secrets["your secrets
stay on this
machine"] - home ~~~ git ~~~ agent ~~~ secrets + folder["the project
folder,
read-write,
or its own
clone with
--clone"] + hosts["what its
network tier
allows,
through the
proxy"] + folder ~~~ hosts end subgraph copied["Read-only or copied"] direction TB @@ -46,11 +46,13 @@ flowchart TB files["copies of
its settings
files, minus
your secrets"] tools ~~~ folders ~~~ files end - subgraph reach["The VM reaches"] + subgraph out["Out of reach"] direction TB - folder["the project
folder,
read-write,
or its own
clone with
--clone"] - hosts["what its
network tier
allows,
through the
proxy"] - folder ~~~ hosts + home["the rest of
your home
folder"] + git[".git hooks
and config,
locked"] + agent["your SSH
agent,
unless you
turn it on"] + secrets["your secrets
stay on this
machine"] + home ~~~ git ~~~ agent ~~~ secrets end ``` diff --git a/docs/content/docs/safety/network.md b/docs/content/docs/safety/network.md index 6bf1ea84..2d23b969 100644 --- a/docs/content/docs/safety/network.md +++ b/docs/content/docs/safety/network.md @@ -8,6 +8,8 @@ Every VM goes through a proxy that devvm runs for it on this machine, and the VM ```mermaid sequenceDiagram + accTitle: A VM's requests through its proxy + accDescr: The VM sends GET /user with a placeholder to its proxy on this machine, which finds api.github.com on the allowlist and sends the request on with your GitHub token, then passes the response back. A CONNECT to example.com:443 gets a 403, because that host isn't on the allowlist. participant P as The VM participant X as Its proxy,
on this machine participant H as api.github.com diff --git a/docs/content/docs/using/clone.md b/docs/content/docs/using/clone.md index f3f040f2..ddd91fe1 100644 --- a/docs/content/docs/using/clone.md +++ b/docs/content/docs/using/clone.md @@ -14,6 +14,8 @@ git log -p main..devvm/main ```mermaid sequenceDiagram + accTitle: A clone's life + accDescr: devvm --clone copies your repo into the VM, where you or an agent commit. devvm clone fetch brings the VM's commits into your repo as a devvm/ branch, for you to review and merge. devvm rm looks for commits not fetched and fetches them into a saved/devvm/ branch, then deletes the VM and removes its remote. participant R as Your repo participant V as The VM's clone R->>V: devvm --clone copies
your repo diff --git a/docs/content/docs/using/coding-agents.md b/docs/content/docs/using/coding-agents.md index f0daf3ff..3faca8ca 100644 --- a/docs/content/docs/using/coding-agents.md +++ b/docs/content/docs/using/coding-agents.md @@ -73,6 +73,8 @@ Each VM gets its agents' settings and logins from the store, but never your hist ```mermaid flowchart TD + accTitle: The agent store and a VM + accDescr: devvm agent import copies the agents' files from your home folder into devvm's agent store, but never your history. The store's settings folders are mounted into each VM read-only, and its settings files and logins are copied in on every launch, without your secrets. devvm agent save brings changed copies back after a diff and a yes. Each VM's own history goes to a .tar.gz on this machine with devvm history export or devvm rm, and comes back with devvm history import, or with yes when a new VM offers it. home["the agents' files
in your home folder"] subgraph store["devvm's agent store"] folders["settings folders:
skills, plugins…"] diff --git a/docs/content/docs/using/devcontainer.md b/docs/content/docs/using/devcontainer.md index 8e995287..0307a852 100644 --- a/docs/content/docs/using/devcontainer.md +++ b/docs/content/docs/using/devcontainer.md @@ -29,6 +29,8 @@ A new VM takes each of these from the first place that sets it. ```mermaid flowchart TD + accTitle: Where a new VM's ports and base come from + accDescr: A new VM's ports are --ports, or else your ports with the file's forwardPorts added. Its base starts from --from, or else the file's image, or else $DEVVM_FROM, or else Ubuntu's cloud image. subgraph ports["Its ports"] direction TB flag["--ports"] -- "or else" --> fwd["your ports, with
forwardPorts added"] diff --git a/docs/content/docs/using/images.md b/docs/content/docs/using/images.md index da48c6a8..8cedfe88 100644 --- a/docs/content/docs/using/images.md +++ b/docs/content/docs/using/images.md @@ -8,6 +8,8 @@ Every VM is a copy of an image. An image is `base` with your choice of layers on ```mermaid flowchart TD + accTitle: Images, VMs and the shared tools + accDescr: Ubuntu's cloud image, or a --from image, is the start of base, with the features you chose, and docker is a layer on base. Each VM is a copy of one image, and the shared tools, such as node and claude, are mounted into each VM read-only. ubuntu["Ubuntu's cloud image,
or a --from image"] --> base["base, with
the features you chose"] base --> docker["docker, a layer
on base"] base -. "a copy" .-> vm1["VM of base,
with node"] @@ -19,6 +21,8 @@ flowchart TD ```mermaid flowchart TD + accTitle: What a new VM gets + accDescr: devvm starts from the defaults, the folder's toolchains and devvm setup's agents and layers, each flag given replaces its part, and the summary says what the VM gets. In a terminal, without --no-input and with something left to choose, devvm asks whether to customize it, and y opens the list, the tier, the CPUs, memory and disk. Then devvm builds the image if it isn't built and makes the VM as a copy of it, with its shared tools mounted. run["devvm in a folder
without a VM"] --> defaults["the defaults: the folder's toolchains,
devvm setup's agents and layers"] defaults --> flags["each flag given replaces its part:
--tools, --agents, --layers, --network, --cpus, --memory"] flags --> summary["the summary says what the VM gets"] diff --git a/docs/content/docs/using/ssh.md b/docs/content/docs/using/ssh.md index b534d5a6..ad4d4fdf 100644 --- a/docs/content/docs/using/ssh.md +++ b/docs/content/docs/using/ssh.md @@ -99,6 +99,8 @@ devvm ssh-agent off # stop forwarding from the VM's next sta ```mermaid flowchart TD + accTitle: The SSH agent a VM gets + accDescr: With devvm ssh-agent off, the default, the VM has no agent, so git over SSH fails. With on, it has your agent while you're connected, and with devvm, it has devvm's own agent, with only the keys you added. choice{{"devvm ssh-agent"}} choice -- "off, the default" --> off["no agent:
git over SSH fails"] choice -- "on" --> on["your agent, while
you're connected"] diff --git a/docs/content/docs/using/vms.md b/docs/content/docs/using/vms.md index 72c56b92..600c1269 100644 --- a/docs/content/docs/using/vms.md +++ b/docs/content/docs/using/vms.md @@ -14,6 +14,8 @@ A VM is running or stopped from the time devvm makes it until you delete it. ```mermaid flowchart TD + accTitle: A VM's states + accDescr: devvm makes a VM, which is then running. devvm restart and devvm update keep it running, devvm stop stops it, and devvm, devvm restart or devvm update start it again. devvm rm deletes it, running or stopped. When its image changes, a VM is outdated, and it keeps its image until devvm update. none(["no VM"]) -- "devvm" --> running(["running"]) running -- "devvm restart,
devvm update" --> running running -- "devvm stop" --> stopped(["stopped"]) diff --git a/docs/hugo.yaml b/docs/hugo.yaml index 837e4426..f43d6264 100644 --- a/docs/hugo.yaml +++ b/docs/hugo.yaml @@ -15,6 +15,14 @@ module: min: "0.146.0" imports: - path: github.com/imfing/hextra + # The diagrams that render-diagrams.mjs draws before the build (mise run docs:diagrams), which git + # ignores, as assets/diagrams for the mermaid render hook. A mount of assets replaces Hugo's own, so + # assets is mounted too. + mounts: + - source: assets + target: assets + - source: .build/diagrams + target: assets/diagrams markup: highlight: @@ -71,9 +79,6 @@ params: editURL: enable: true base: https://github.com/devvmhq/devvm/edit/main/docs/content - # Mermaid, for diagrams: a pinned version, fetched when the site is built (layouts/_partials/scripts/mermaid.html). - mermaid: - base: https://cdn.jsdelivr.net/npm/mermaid@12.2.0/dist highlight: copy: enable: true diff --git a/docs/layouts/_markup/render-codeblock-mermaid.html b/docs/layouts/_markup/render-codeblock-mermaid.html new file mode 100644 index 00000000..dd7484b4 --- /dev/null +++ b/docs/layouts/_markup/render-codeblock-mermaid.html @@ -0,0 +1,21 @@ +{{- /* A mermaid code block: the SVG that render-diagrams.mjs drew for it before the build, inlined, in + place of Hextra's hook, so no page loads Mermaid. hugo.yaml mounts the drawings' folder at + assets/diagrams. Each one's files are named for its key, the first 16 hex digits of the SHA-256 of + the salt the script wrote there (a hash of pele's version and the script), a newline and the + block's text. A missing one fails the build: run mise run docs:diagrams first. The wrapper gets the + diagram's height, for custom.css's content-visibility, which skips drawing a diagram until it nears + the screen, and its width, with which custom.css lets a wide one reach into the page's margin. */ -}} +{{- $salt := resources.Get "diagrams/salt" -}} +{{- if not $salt -}} + {{- errorf "%s: no drawings of the diagrams (diagrams/salt): run mise run docs:diagrams" .Position -}} +{{- else -}} + {{- $key := substr (sha256 (printf "%s\n%s" $salt.Content .Inner)) 0 16 -}} + {{- $svg := resources.Get (printf "diagrams/%s.svg" $key) -}} + {{- $size := resources.Get (printf "diagrams/%s.json" $key) -}} + {{- if not (and $svg $size) -}} + {{- errorf "%s: no drawing of this diagram (diagrams/%s.svg): run mise run docs:diagrams" .Position $key -}} + {{- else -}} + {{- $m := $size | transform.Unmarshal -}} +
{{ $svg.Content | safeHTML }}
+ {{- end -}} +{{- end -}} diff --git a/docs/layouts/_partials/scripts/mermaid.html b/docs/layouts/_partials/scripts/mermaid.html deleted file mode 100644 index a68d646c..00000000 --- a/docs/layouts/_partials/scripts/mermaid.html +++ /dev/null @@ -1,98 +0,0 @@ -{{- /* Mermaid, for pages with a mermaid code block: Hextra's partial of the same name, with the version - pinned in hugo.yaml (params.mermaid.base) and one theme, the site's palette, in place of Hextra's light - and dark ones. Every diagram gets it, so no diagram sets its own. */ -}} -{{- $url := urls.JoinPath site.Params.mermaid.base "mermaid.min.js" -}} -{{- with try (resources.GetRemote $url) -}} - {{- with .Err -}} - {{- errorf "Could not retrieve Mermaid from %s: %s" $url . -}} - {{- else with .Value -}} - {{- with resources.Copy "js/mermaid.min.js" . | fingerprint -}} - - {{- end -}} - {{- end -}} -{{- end -}} - - diff --git a/docs/package-lock.json b/docs/package-lock.json new file mode 100644 index 00000000..d1f24d88 --- /dev/null +++ b/docs/package-lock.json @@ -0,0 +1,21 @@ +{ + "name": "docs", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "pele": "1.13.0" + } + }, + "node_modules/pele": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/pele/-/pele-1.13.0.tgz", + "integrity": "sha512-Ie8UKY9x00MsuR3jO6AzUwzK2Z6MIV3Tf4EDdITiuk8Uaz8K7g0R082WqsqNaSU8DdgkrRvZThzhit83mi/uiw==", + "license": "MIT", + "engines": { + "node": ">=20" + } + } + } +} diff --git a/docs/package.json b/docs/package.json new file mode 100644 index 00000000..fca0f94e --- /dev/null +++ b/docs/package.json @@ -0,0 +1,8 @@ +{ + "private": true, + "description": "The docs site's build: render-diagrams.mjs draws its diagrams with pele. Installed with npm ci by mise run docs:diagrams; scripts/bump.sh pele moves the pin.", + "type": "module", + "dependencies": { + "pele": "1.13.0" + } +} diff --git a/docs/render-diagrams.mjs b/docs/render-diagrams.mjs new file mode 100644 index 00000000..1594a21e --- /dev/null +++ b/docs/render-diagrams.mjs @@ -0,0 +1,188 @@ +// Draws every mermaid code block in docs/content as an SVG, with pele (docs/package.json), before Hugo +// builds the site, so its pages load no diagram JavaScript. Each block's files go in +// docs/.build/diagrams/, which git ignores, named for its key: .svg, and .json with its +// width and height. The render hook (layouts/_markup/render-codeblock-mermaid.html) computes the same +// key and inlines the SVG. +// +// A key is a hash of the block's text and of the salt, which is itself a hash of pele's version and +// this script's text, its render settings included; the salt is written to the folder's salt file for +// the hook. A drawing whose files are already there is kept, only the missing ones are drawn, and +// files no block's key names are deleted, so a run with nothing changed draws nothing, and a new pele +// or a change here draws them all again. +// +// The theme is CSS: custom.css sets pele's --pele-* variables. The layout is set here: Departure Mono +// at 14px, measured from the font's metrics, and the Mermaid settings below. +// +// Run it with mise run docs:diagrams, which installs pele first (npm ci). +import { createHash } from "node:crypto"; +import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, utimesSync, writeFileSync } from "node:fs"; +import { dirname, join, relative } from "node:path"; +import { fileURLToPath } from "node:url"; +import { render } from "pele"; + +const script = fileURLToPath(import.meta.url); +const docs = dirname(script); +const out = join(docs, ".build", "diagrams"); +const SALT_FILE = "salt"; + +// Departure Mono: 550 units to the em and every glyph 350 wide, so a character's width is its size +// times 350/550, and the measurer counts characters. +const FONT = '"Departure Mono", monospace'; +const ADVANCE = 350 / 550; +const SIZE = 14; +// pele draws edge labels, sequence messages, notes and boxes smaller than the rest, at +// round(size * 0.875), 12px, with no option to change it. The measurer gives that text the width it +// has at 14px, so pele lays it out for 14px, and grow() then draws it at 14px. +const SMALL = Math.round(SIZE * 0.875); +const measured = []; +const measurer = { + width(text, size) { + measured.push([text, size]); + return Array.from(text).length * (size === SMALL ? SIZE : size) * ADVANCE; + }, +}; + +const options = (key) => ({ + measurer, + fontFamily: FONT, + fontFamilyMono: FONT, + fontSize: SIZE, + idPrefix: `d${key}-`, + // At their own size, never scaled to fit or turned: custom.css scrolls a wide one sideways. + responsive: false, + autoDirection: false, + links: false, + images: false, + // Defaults a diagram's front matter can override. step draws edges with right angles. + config: { + flowchart: { curve: "step", wrappingWidth: 340, nodeSpacing: 45, rankSpacing: 45 }, + sequence: { mirrorActors: false, actorMargin: 45, diagramMarginX: 1 }, + }, +}); + +// grow: the small text's font-size, which pele writes on each group of it, at 14px. Every such group +// must carry font-size="SMALL", and a diagram with small text but none of those groups means pele has +// changed how it writes it. +const SMALL_GROUP = /]*>/g; +const SMALL_ITEM = /class="pele-(edge-label|note|box|frame)/; +const SMALL_SIZE = new RegExp(`\\sfont-size="${SMALL}"`); +function grow(svg, where) { + const groups = svg.match(SMALL_GROUP) ?? []; + if (SMALL_ITEM.test(svg) && !groups.length) { + throw new Error(`${where}: pele drew small text outside its groups: check grow() against this pele`); + } + for (const g of groups) { + if (!SMALL_SIZE.test(g)) { + throw new Error(`${where}: pele drew ${g} without font-size="${SMALL}": check grow() against this pele`); + } + } + return svg.replace(SMALL_GROUP, (g) => g.replace(SMALL_SIZE, ` font-size="${SIZE}"`)); +} + +// A newline after each text element, outside it, where SVG draws nothing, so the site's search index, +// which reads a page's text without its tags, sees each label's last word apart from the next label's +// first. The lines of one label are tspans in one text element, where a newline would be a space +// that moves a centered line, so they stay joined. +const searchable = (svg) => svg.replaceAll("", "\n"); + +// Checks the things about pele that grow() relies on, which its docs don't promise: an edge label, a +// message and a note are measured at SMALL, and drawn in a group with font-size="SMALL". +function selfCheck() { + const cases = [ + ["flowchart", "flowchart TD\n a --> |edge label| b", "edge label", "edge-labels"], + ["sequence", "sequenceDiagram\n A->>B: a message", "a message", "edge-labels"], + ["note", "sequenceDiagram\n A->>B: hi\n Note right of B: a note", "a note", "notes"], + ]; + for (const [name, source, label, group] of cases) { + measured.length = 0; + const { svg } = render(source, options(`check-${name}`)); + const sizes = measured.filter(([t]) => t === label).map(([, s]) => s); + if (!sizes.length || sizes.some((s) => s !== SMALL)) { + throw new Error(`self-check: pele measured the ${name}'s "${label}" at ${sizes.join(", ") || "no size"}, not ${SMALL}px`); + } + const tag = (svg.match(new RegExp(`]*>`)) ?? [""])[0]; + if (!SMALL_SIZE.test(tag)) { + throw new Error(`self-check: pele's ${name} has no `); + } + } +} + +// A diagram's accessible name and description: pele makes its accTitle and accDescr the SVG's +// and <desc>, which screen readers read, so every diagram needs both. +function accessible(svg, where) { + if (!/aria-labelledby="[^"]*-title"/.test(svg) || !/aria-describedby="[^"]*-desc"/.test(svg)) { + throw new Error(`${where}: give the diagram an accTitle and an accDescr, which screen readers read`); + } +} + +function* markdownFiles(dir) { + for (const e of readdirSync(dir, { withFileTypes: true })) { + const p = join(dir, e.name); + if (e.isDirectory()) yield* markdownFiles(p); + else if (e.name.endsWith(".md")) yield p; + } +} + +// The blocks, fenced at the start of a line; an indented one would reach the hook with other text. +function diagrams() { + const found = []; + for (const file of markdownFiles(join(docs, "content"))) { + const text = readFileSync(file, "utf8"); + const where = (index) => `${relative(docs, file)}:${text.slice(0, index).split("\n").length}`; + for (const m of text.matchAll(/^[ \t]+```mermaid/gm)) { + throw new Error(`${where(m.index)}: an indented mermaid block; start its fence at the line's start`); + } + for (const m of text.matchAll(/^```mermaid[ \t]*\n([\s\S]*?)\n```[ \t]*$/gm)) { + found.push({ where: where(m.index), inner: m[1] }); + } + } + return found; +} + +const sha256 = (text) => createHash("sha256").update(text).digest("hex").slice(0, 16); + +// The salt: the first 16 hex digits of the SHA-256 of pele's installed version and this script. +function salt() { + const pele = JSON.parse(readFileSync(join(docs, "node_modules", "pele", "package.json"), "utf8")); + return sha256(`pele ${pele.version}\n${readFileSync(script, "utf8")}`); +} + +// The key the render hook computes: the first 16 hex digits of the SHA-256 of the salt, a newline and +// the block's text, which is Hugo's .Inner, the lines between the fences without the last newline. +const key = (s, inner) => sha256(`${s}\n${inner}`); + +// Written beside its final name and renamed, so a run stopped halfway leaves no partial drawing that a +// later run would keep. +function put(name, data) { + writeFileSync(join(out, `${name}.tmp`), data); + renameSync(join(out, `${name}.tmp`), join(out, name)); +} + +try { + const s = salt(); + const all = diagrams().map((d) => ({ ...d, key: key(s, d.inner) })); + mkdirSync(out, { recursive: true }); + const missing = all.filter((d) => !existsSync(join(out, `${d.key}.svg`)) || !existsSync(join(out, `${d.key}.json`))); + // Only when there's something to draw, as a drawing already there passed it when it was drawn. + if (missing.length) selfCheck(); + for (const d of missing) { + const { svg, width, height } = render(d.inner, options(d.key)); + accessible(svg, d.where); + // The size first: the hook needs both, and the SVG's presence is what says it's drawn. + put(`${d.key}.json`, JSON.stringify({ width: Math.ceil(width), height: Math.ceil(height) }) + "\n"); + put(`${d.key}.svg`, searchable(grow(svg, d.where))); + } + put(SALT_FILE, s); + const keep = new Set([SALT_FILE, ...all.flatMap((d) => [`${d.key}.svg`, `${d.key}.json`])]); + const unused = readdirSync(out).filter((f) => !keep.has(f)); + for (const f of unused) rmSync(join(out, f), { force: true }); + // The folder is mise's output for docs:diagrams, which it compares with the sources' times. + const now = new Date(); + utimesSync(out, now, now); + console.log( + `render-diagrams: ${all.length} diagrams in ${relative(process.cwd(), out) || "."}, ${missing.length} drawn, ${unused.length} files deleted`, + ); +} catch (e) { + console.error(`render-diagrams: ${e.message}`); + process.exit(1); +} diff --git a/internal/structure/pins_test.go b/internal/structure/pins_test.go index cc8e524d..d1e12786 100644 --- a/internal/structure/pins_test.go +++ b/internal/structure/pins_test.go @@ -49,6 +49,9 @@ func pinPatterns() []pinPattern { {"tests/e2e/*.go", "", "", regexp.MustCompile(`(?m)^const (\w+) = ".*(?:sha256:[0-9a-f]{64}|release-[0-9]{8}|[0-9]+\.[0-9]+\.[0-9]+).*"$`)}, {"docs/hugo.yaml", "", "", regexp.MustCompile(`([A-Za-z0-9_.-]+)@` + version)}, {"docs/hugo.yaml", "", "", regexp.MustCompile(`(?m)^\s*([A-Za-z_]+): ["']?` + version + `\.[0-9]+["']?\s*$`)}, + // The docs build's npm packages: each "name": "version" in + // docs/package.json (its lock follows npm install). + {"docs/package.json", "", "npm:", regexp.MustCompile(`(?m)^\s*"([^"]+)": "[~^]?[0-9]+\.[0-9]+[^"]*",?$`)}, } } diff --git a/mise.toml b/mise.toml index cc4ab840..5c73f02f 100644 --- a/mise.toml +++ b/mise.toml @@ -59,6 +59,8 @@ run = [ [tasks."lint:docs"] description = "Lint the docs" +# The site's build needs its diagrams drawn. +depends = ["docs:diagrams"] run = [ # Every Markdown file but the vendored security-audit skill's. "markdownlint-cli2 'docs/content/**/*.md' '*.md' 'assets/**/*.md' 'internal/**/*.md' '.agents/skills/docs-voice/*.md' '.agents/skills/cli/*.md'", @@ -115,9 +117,28 @@ run = "go run golang.org/x/tools/cmd/deadcode@v0.52.0 ./..." description = "Generate the CLI reference (docs/content/docs/cli) and the pages' generated blocks" run = "go run ./internal/cli/docgen ." +[tasks."docs:diagrams"] +description = "Draw the docs site's diagrams (docs/render-diagrams.mjs), which every build of the site needs first" +# Skipped when the drawings' folder is newer than every source; the script then draws only the +# diagrams it has no drawing of. +sources = ["docs/content/**/*.md", "docs/render-diagrams.mjs", "docs/package.json", "docs/package-lock.json"] +outputs = ["docs/.build/diagrams"] +run = [ + # pele, at the version and integrity docs/package-lock.json pins, and no package's install scripts: + # installed again only when the lock's SHA-256 differs from the one node_modules records. + ''' + lock=$({ sha256sum docs/package-lock.json 2>/dev/null || shasum -a 256 docs/package-lock.json; } | cut -c1-64) + stamp=docs/node_modules/.devvm-lock-sha256 + if [ -z "$lock" ] || [ "$(cat "$stamp" 2>/dev/null)" != "$lock" ]; then + npm ci --prefix docs --ignore-scripts --no-audit --no-fund && printf '%s\n' "$lock" > "$stamp" + fi + ''', + "node docs/render-diagrams.mjs", +] + [tasks.docs] description = "Serve the docs site" -depends = ["cli-docs"] +depends = ["cli-docs", "docs:diagrams"] run = "hugo server -s docs" [tasks.e2e] diff --git a/scripts/bump.sh b/scripts/bump.sh index 87a0d4d9..45940a83 100755 --- a/scripts/bump.sh +++ b/scripts/bump.sh @@ -1,7 +1,7 @@ #!/bin/bash # Update every version and checksum pinned in the repo: the downloads in assets/ and devvm's host mise, # the end-to-end tests' own pins, Go and its modules, the dev tools in mise.toml, the workflows' actions -# and the docs site's theme and Mermaid. +# and the docs site's theme and pele, which draws its diagrams. # scripts/bump.sh --check show current and latest for every pin, by group, with whether a bump is # a patch, minor or major; change nothing # scripts/bump.sh apply every safe bump: patches and minors, never a major or a held pin, @@ -31,9 +31,10 @@ # ci: ci-mise actions # ci-mise: the mise the workflows install (jdx/mise-action's version), base's mise # actions: every workflow's uses:, by its release's tag's commit, then actionlint and zizmor -# docs: hextra mermaid +# docs: hextra pele # hextra: the docs site's theme, docs/go.mod -# mermaid (only when named): docs/hugo.yaml's Mermaid; its diagrams need a look after a bump +# pele (only when named): docs/package.json's pele, which draws the site's diagrams, through npm +# install, then draws them again; they need a look after a bump # Holds: a pin that never moves past a version. Go modules and actions take Dependabot's ignore # list (.github/dependabot.yml: pflag stays below 1.1.0, whose help prints every boolean flag with # [=true|false]); the rest are holds below. @@ -46,16 +47,17 @@ holds="node 25" # NAME BOUND...: node stays on its major, 24, which is an LTS re # testdata/mise.lock and testdata/v<release>/: fixed for the tests, and frozen # skills-lock.json: the vendored security-audit skill's hash, from the skills tool # docs/static's fonts and docs/assets/icons: files copied in, with their versions in comments -# docs/layouts' copies of Hextra's files (the hero button, Mermaid's partial): checked by hand -# against Hextra's after a hextra bump +# docs/layouts' copy of Hextra's hero button: checked by hand against Hextra's after a hextra bump; +# its mermaid render hook replaces Hextra's mermaid hook: check it still has that name # assets/layers/ubuntu-*.gpg and internal/ubuntu's Series: keys and a release, moved by hand # (contributing/maintaining.md) # tests/e2e/tools_test.go's cowsay@1.6.0: any version works, it only installs one # Pins: each pin internal/structure's TestBumpCoversPins finds (assets/'s <tool>_version, _commit and # _sha256 lines and its mise.toml's versions, mise.toml, the go.mod files, the workflows' uses: and -# version values, tests/e2e-mise.lock, tests/e2e's pinned consts and docs/hugo.yaml), as KEY and the -# tool that moves it, or "-" and why it's left. A KEY ending in * is every key it starts. A pin -# found and not here fails the test, and so does a line here that finds nothing. +# version values, tests/e2e-mise.lock, tests/e2e's pinned consts, docs/hugo.yaml and +# docs/package.json's dependencies), as KEY and the tool that moves it, or "-" and why it's left. A KEY +# ending in * is every key it starts. A pin found and not here fails the test, and so does a line here +# that finds nothing. # pin assets/features/cli-tools.sh:eza eza # pin assets/features/cli-tools.sh:tealdeer tealdeer # pin assets/features/omb.sh:omb omb @@ -92,17 +94,17 @@ holds="node 25" # NAME BOUND...: node stays on its major, 24, which is an LTS re # pin tests/e2e:fromUbuntuDigest e2e-from # pin tests/e2e:curlImage e2e-curl # pin tests/e2e:dotnetOther - an SDK other than the shared one for a global.json to ask for: any older one works -# pin docs/hugo.yaml:mermaid mermaid +# pin docs/package.json:npm:pele pele # pin docs/hugo.yaml:min - Hextra's oldest Hugo, which Hugo checks; mise.toml pins the Hugo that builds the site -# Needs curl and jq, and per group mise (dev-tools, go, e2e lock checks), go (go-mods, hextra when -# applied) and gh (actions). Checksums come from upstream's published sums where there are any; +# Needs curl and jq, and per group mise (dev-tools, go, e2e lock checks, pele when applied), go +# (go-mods, hextra when applied) and gh (actions). Checksums come from upstream's published sums where there are any; # otherwise they're computed from the download (said so in the output). Edited scripts change image # keys, so the affected images rebuild on next use: test with `devvm build <image>`, then `devvm gc`. set -euo pipefail root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -every="docker nix direnv nix-direnv mise git-lfs rustup crane omb eza tealdeer cursor e2e-tools e2e-from e2e-curl e2e-ubuntu e2e-lima go go-minor go-mods deadcode dev-tools ci-mise actions hextra mermaid" +every="docker nix direnv nix-direnv mise git-lfs rustup crane omb eza tealdeer cursor e2e-tools e2e-from e2e-curl e2e-ubuntu e2e-lima go go-minor go-mods deadcode dev-tools ci-mise actions hextra pele" # Applied only when named: --check reports them. -named_only="cursor go-minor mermaid" +named_only="cursor go-minor pele" # Naming one of these applies its major too. legacy="docker nix direnv nix-direnv mise git-lfs rustup crane omb eza tealdeer e2e-tools e2e-from e2e-curl e2e-ubuntu e2e-lima" @@ -699,18 +701,20 @@ bump_hextra() { mod_bump hextra "$mod" "$cur" || return 0 valid hextra_version "$target" docs_gets+=("$mod@$target") - notes+=("hextra: compare docs/layouts' copies of Hextra's files (the hero button, Mermaid's partial) with $target's, and build the site: mise run docs") + notes+=("hextra: compare docs/layouts' copy of Hextra's hero button with $target's; docs/layouts' mermaid render hook replaces Hextra's mermaid hook: check it still has that name; then build the site: mise run docs") } -# docs/hugo.yaml's Mermaid, npm's newest, only when named: its diagrams need a look. -bump_mermaid() { +# docs/package.json's pele, npm's newest, only when named, through npm install in docs/, which writes +# package.json and package-lock.json, then mise run docs:diagrams, whose self-check fails when pele no +# longer draws small text as render-diagrams.mjs expects. Its diagrams need a look. +bump_pele() { local cur new - cur=$(sed -n 's|.*/npm/mermaid@\([0-9.]*\)/.*|\1|p' "$root/docs/hugo.yaml") - new=$(fetch https://registry.npmjs.org/mermaid/latest | jq -r .version) - report mermaid "$cur" "$new" || return 0 - valid mermaid_version "$new" - set_text docs/hugo.yaml text "/npm/mermaid@$cur/" "/npm/mermaid@$new/" - notes+=("mermaid: look at the diagrams on the docs site (mise run docs) before committing") + cur=$(jq -r '.dependencies.pele' "$root/docs/package.json") + new=$(fetch https://registry.npmjs.org/pele/latest | jq -r .version) + report pele "$cur" "$new" || return 0 + valid pele_version "$new" + npm_installs+=("pele@$new") + notes+=("pele: look at every diagram on the docs site (mise run docs) before committing") } # mise_spec TOOL: mise.toml's version for TOOL in [tools], an inline table's version included. @@ -775,7 +779,7 @@ bump_actions() { done < <(sed -n 's/^ *\(- \)\{0,1\}uses: \([^@ ]*\)@\([0-9a-f]\{40\}\) # \([^ ]*\)$/\2 \3 \4/p' "$root"/.github/workflows/*.yml | sort -u) } -mise_locks=() go_gets=() docs_gets=() workflows_changed=false +mise_locks=() go_gets=() docs_gets=() npm_installs=() workflows_changed=false # run_logged STEP CMD...: run CMD in the repo, its output shown only when it fails. run_logged() { local step=$1 @@ -793,7 +797,7 @@ for cur_tool in $tools; do go | go-minor | go-mods | deadcode) g=go ;; dev-tools) g=dev-tools ;; ci-mise | actions) g=ci ;; - hextra | mermaid) g=docs ;; + hextra | pele) g=docs ;; *) g=images ;; esac [[ $g == "$group" ]] || { group=$g; echo "[$g]"; } @@ -822,6 +826,12 @@ if (( ${#docs_gets[@]} > 0 )); then # go.sum keeps the old version's lines; Hugo's tidy, not Go's, which would drop the module. run_logged "hugo mod tidy (docs)" sh -c 'cd docs && exec mise exec -- hugo mod tidy' fi +if (( ${#npm_installs[@]} > 0 )); then + need mise + # The exact version, and no package's install scripts. + run_logged "npm install ${npm_installs[*]} (docs)" mise exec -- npm install --prefix docs --save-exact --ignore-scripts --no-audit --no-fund "${npm_installs[@]}" + run_logged "mise run docs:diagrams" mise run docs:diagrams +fi if $workflows_changed; then need mise run_logged actionlint mise exec -- actionlint diff --git a/testdata/script/bump.txtar b/testdata/script/bump.txtar index af254e2c..31d4b394 100644 --- a/testdata/script/bump.txtar +++ b/testdata/script/bump.txtar @@ -171,9 +171,18 @@ grep 'uses: actions/checkout@cccccccccccccccccccccccccccccccccccccccc # v[0-9]\. grep '^mise exec -- actionlint$' mise.calls grep '^mise exec -- zizmor --offline \.$' mise.calls -# mermaid, only when named, takes its major too. -exec repo/scripts/bump.sh mermaid -grep '/npm/mermaid@99\.0\.0/' repo/docs/hugo.yaml +# pele, only when named, takes its major too: npm install writes it into +# docs/package.json and its lock, without install scripts, then the +# diagrams are drawn again, whose self-check catches a pele that draws +# them differently. --check reports it and installs nothing. +exec bash repo.sh +exec repo/scripts/bump.sh --check pele +stdout '^\[docs\]$' +stdout '^ pele +1\.13\.0 +-> 99\.0\.0 \(major\)$' +! exists mise.calls +exec repo/scripts/bump.sh pele +grep '^mise exec -- npm install --prefix docs --save-exact --ignore-scripts --no-audit --no-fund pele@99\.0\.0$' mise.calls +grep '^mise run docs:diagrams$' mise.calls -- repo.sh -- # A copy of the files bump.sh edits, and upstream's good answers. @@ -185,6 +194,7 @@ cp "$DEVVM_REPO"/.github/workflows/*.yml repo/.github/workflows/ cp "$DEVVM_REPO/.github/dependabot.yml" repo/.github/ cp "$DEVVM_REPO/mise.toml" repo/ cp "$DEVVM_REPO/docs/hugo.yaml" repo/docs/ +cp "$DEVVM_REPO/docs/package.json" repo/docs/ cp go.mod.fixture repo/go.mod cp docs-go.mod.fixture repo/docs/go.mod mkdir up/latest @@ -226,20 +236,20 @@ for a in "$@"; do case $a in https://proxy.golang.org/github.com/spf13/pflag/@v/list) printf 'v1.0.10\nv1.1.0\n'; exit ;; https://proxy.golang.org/golang.org/x/tools/@v/list) printf 'v0.52.0\nv0.999.0\n'; exit ;; https://proxy.golang.org/github.com/imfing/hextra/@v/list) printf 'v0.13.0\nv0.999.0\n'; exit ;; - https://registry.npmjs.org/mermaid/latest) echo '{"version":"99.0.0"}'; exit ;; + https://registry.npmjs.org/pele/latest) echo '{"version":"99.0.0"}'; exit ;; esac; done exit 22 -- bin/mise -- #!/bin/bash -# mise latest from $WORK/up/latest/, else mise.toml's own version; lock and -# exec succeed. Every call goes in $WORK/mise.calls. +# mise latest from $WORK/up/latest/, else mise.toml's own version; lock, +# exec and run succeed. Every call goes in $WORK/mise.calls. echo "mise $*" >> "$WORK/mise.calls" case $1 in latest) f=$WORK/up/latest/${2//[@\/:]/_} if [[ -f $f ]]; then cat "$f"; exit; fi awk -F' = ' -v k="${2%@*}" '{ g = $1; gsub(/"/, "", g) } g == k { v = $2; gsub(/"/, "", v); print v; exit }' "$WORK/repo/mise.toml" ;; - lock | exec) ;; + lock | exec | run) ;; *) exit 1 ;; esac -- bin/go --