From 2c3049e967230b7efa26e0289136735c086ee4e0 Mon Sep 17 00:00:00 2001 From: Willie Chalmers III Date: Tue, 3 Nov 2026 16:26:25 -0800 Subject: [PATCH 1/2] fix(dx): Reuse package access across fresh worktrees A scoped registry mapping does not attach the GitHub CLI credential to package requests. Fresh checkouts repeatedly needed separate token exports before the ordinary dependency install could succeed. Expose the shared package setup and check commands through the pinned bootstrap engine. The user helper keeps authentication available across worktrees while CI retains its explicit token and package grants. Add executable entrypoint regressions and document the machine setup. Correct stale shared-package versions in the setup guide against the existing manifest and frozen lock without changing dependency policy. Co-authored-by: Codex --- README.md | 3 + bootstrap | 7 ++- docs/configuration.md | 6 +- scripts/bootstrap-worktree-engine | 98 ++++++++++++++++--------------- tests/unit/bootstrap.test.ts | 31 +++++++++- 5 files changed, 94 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 86dc563..e44e294 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,13 @@ The company website for Hypertext Studio: Docket, LogDate, Curfew, company infor ## Start here ```sh +./bootstrap packages setup ./bootstrap worktree prepare pnpm dev ``` +Package authentication setup runs once per machine after GitHub CLI login with package-read access. Fresh worktrees reuse it without token exports. + Node is pinned in `.nvmrc`; pnpm and the shared frontend packages are pinned in `package.json` and `pnpm-lock.yaml`. See [configuration](docs/configuration.md) for registry authentication and optional values. ## Common commands diff --git a/bootstrap b/bootstrap index a3134c6..d9ea320 100755 --- a/bootstrap +++ b/bootstrap @@ -3,6 +3,9 @@ set -eu root=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) cd "$root" case "${1:-}" in - worktree) exec "$root/scripts/bootstrap-worktree-engine" "$@" ;; - *) printf '%s\n' 'Usage: ./bootstrap worktree prepare|check|plan [--json] [--offline] [--no-install]' >&2; exit 2 ;; + worktree | packages) exec "$root/scripts/bootstrap-worktree-engine" "$@" ;; + *) + printf '%s\n' 'Usage: ./bootstrap worktree prepare|check|plan [--json] [--offline] [--no-install]' ' ./bootstrap packages setup' ' ./bootstrap packages check [@thehypertextstudio/package]' >&2 + exit 2 + ;; esac diff --git a/docs/configuration.md b/docs/configuration.md index 031d592..e9cdc35 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -2,11 +2,13 @@ Use `.nvmrc` for Node 24.20.0, `package.json` for pnpm 11.9.0 and Wrangler 4.127.1, and `pnpm-lock.yaml` for dependencies. The existing shared worktree bootstrap prepares local dependencies; package scripts invoke the actual framework and provider tools. -The shared frontend configuration package is the private GitHub Package `@thehypertextstudio/web-config`, pinned to `0.0.1` in `package.json` and resolved through `pnpm-lock.yaml`. Refresh it through the ordinary package workflow with approved registry access. Keep registry dependencies reproducible across local setup and CI; do not commit local package overrides or use a local tarball checksum as registry integrity. +The shared frontend configuration package is the private GitHub Package `@thehypertextstudio/web-config`, pinned to `0.0.3` in `package.json` and resolved through `pnpm-lock.yaml`. Refresh it through the ordinary package workflow with approved registry access. Keep registry dependencies reproducible across local setup and CI; do not commit local package overrides or use a local tarball checksum as registry integrity. + +Run `./bootstrap packages setup` once per machine after `gh auth login --hostname github.com` with package-read access. The shared setup verifies access and installs a user-level GitHub CLI credential helper without saving a token. Fresh worktrees reuse the helper without shell exports. Repeat setup preserves unchanged files and unrelated npm settings. Use `./bootstrap packages check @thehypertextstudio/web-config` to verify effective access. Online `worktree prepare` checks every private Studio package in its frozen lockfile before installing dependencies. `pnpm-workspace.yaml` explicitly permits install scripts only for `esbuild`, `sharp`, and `workerd`, the same native dependencies already rebuilt by `scripts/bootstrap-worktree`. This checked-in policy lets fresh pnpm 11 installs prepare those tools without relying on machine-local build approvals. Dependency scripts outside this allowlist remain blocked. -pnpm 11's default 24-hour release-age policy remains active. The only immediate-install exception is the exact reviewed internal version `@thehypertextstudio/web-config@0.0.1`. New package versions require their own review; no organization-wide age exception is configured. +pnpm 11's default 24-hour release-age policy remains active. The only immediate-install exceptions are the exact reviewed internal versions `@thehypertextstudio/web-config@0.0.3` and `@thehypertextstudio/format-config@0.0.1`. New package versions require their own review; no organization-wide age exception is configured. CI uses each repository's short-lived `GITHUB_TOKEN` with `packages: read` and explicit package read grants. Install authentication uses a temporary trusted pnpm user configuration containing only an environment placeholder; the install step removes it on exit. Keep credentials outside repository files and build artifacts. diff --git a/scripts/bootstrap-worktree-engine b/scripts/bootstrap-worktree-engine index 854f78c..7a519a3 100755 --- a/scripts/bootstrap-worktree-engine +++ b/scripts/bootstrap-worktree-engine @@ -1,68 +1,74 @@ #!/bin/sh # Generated by Hypertext Studio bootstrap. Update pins with render-launcher.py. set -eu -version='v0.1.0' -repo='TheHypertextStudio/release-engineering' -fail() { printf '%s\n' "bootstrap: $*" >&2; exit 1; } -[ "${1:-}" = worktree ] || fail 'Only worktree prepare, check, and plan are supported.' -case "${2:-}" in prepare) writable=yes ;; check|plan) writable=no ;; *) fail 'Expected worktree prepare, check, or plan.' ;; esac +version='v0.1.3' +repo='TheHypertextStudio/bootstrap' +fail() { + printf '%s\n' "bootstrap: $*" >&2 + exit 1 +} +case "${1:-}:${2:-}" in + worktree:prepare | packages:setup) writable=yes ;; + worktree:check | worktree:plan | packages:check) writable=no ;; + *) fail 'Use worktree prepare|check|plan or packages setup|check.' ;; +esac offline=no for argument in "$@"; do [ "$argument" != --offline ] || offline=yes; done case "$(uname -s)" in Darwin) os=darwin ;; Linux) os=linux ;; *) fail 'Unsupported operating system.' ;; esac -case "$(uname -m)" in arm64|aarch64) arch=arm64 ;; x86_64|amd64) arch=x86_64 ;; *) fail 'Unsupported architecture.' ;; esac +case "$(uname -m)" in arm64 | aarch64) arch=arm64 ;; x86_64 | amd64) arch=x86_64 ;; *) fail 'Unsupported architecture.' ;; esac platform="$os-$arch" case "$platform" in - darwin-arm64) expected='e9bf82f425f46222c48f52bc81223ca1e74c51abba7b8029817b8326f2e563fa' ;; - darwin-x86_64) expected='0e3257e19f3e7e34bf55b5822b6e0c02f8c6c8433e7fb0351099bd403fdfe305' ;; - linux-arm64) expected='eb89f9336a3f7148dfac99913a6a74bc9958d00c75a01e44a08d197d8bd5724c' ;; - linux-x86_64) expected='d3800739ac58c463d9febc5ed7501f03ad64fccec525953d7427386affff1c4f' ;; + darwin-arm64) expected='3f3323a44cfe1bab5b41ebf44d924c9caae780dee91e6d6b22ee076562621369' ;; + darwin-x86_64) expected='df8c09194cddf531101f1eb232f04f87951476ae4cd3995e11aacc8e2789aef5' ;; + linux-arm64) expected='6675db0dd4d8e9df1224cd0acb62ab3ca757bb978c738bd1b3af2c301b693848' ;; + linux-x86_64) expected='5133f4e0d49e20049fad68bdd31c49f68be80835e4c07f4c0d6d38cecf8e2141' ;; esac asset="hypertext-bootstrap-$platform.tar.gz" cache="${XDG_CACHE_HOME:-${HOME:?HOME is required}/.cache}/hypertext-studio/bootstrap/$version/$platform" archive="$cache/$asset" engine="$cache/hypertext-bootstrap" -command -v tar >/dev/null 2>&1 || fail 'tar is required.' -if command -v sha256sum >/dev/null 2>&1; then - digest() { sha256sum | cut -d ' ' -f 1; } -elif command -v shasum >/dev/null 2>&1; then - digest() { shasum -a 256 | cut -d ' ' -f 1; } +command -v tar > /dev/null 2>&1 || fail 'tar is required.' +if command -v sha256sum > /dev/null 2>&1; then + digest() { sha256sum | cut -d ' ' -f 1; } +elif command -v shasum > /dev/null 2>&1; then + digest() { shasum -a 256 | cut -d ' ' -f 1; } else - fail 'sha256sum or shasum is required.' + fail 'sha256sum or shasum is required.' fi valid_cache() { - [ -f "$archive" ] && [ -x "$engine" ] || return 1 - [ "$(digest < "$archive")" = "$expected" ] || return 1 - wanted=$(tar -xOf "$archive" hypertext-bootstrap | digest) || return 1 - [ "$(digest < "$engine")" = "$wanted" ] + [ -f "$archive" ] && [ -x "$engine" ] || return 1 + [ "$(digest < "$archive")" = "$expected" ] || return 1 + wanted=$(tar -xOf "$archive" hypertext-bootstrap | digest) || return 1 + [ "$(digest < "$engine")" = "$wanted" ] } if ! valid_cache; then - [ "$writable" = yes ] || fail 'Engine cache is missing or corrupt; run ./bootstrap worktree prepare first.' - [ "$offline" = no ] || fail 'Engine cache is missing or corrupt and --offline prohibits downloads.' - mkdir -p "$cache" - staging=$(mktemp -d "$cache/.download.XXXXXXXX") - trap 'rm -rf "$staging"' EXIT HUP INT TERM - downloaded=no - if command -v curl >/dev/null 2>&1; then - if curl --fail --location --silent --show-error --connect-timeout 20 --max-time 300 \ - "https://github.com/$repo/releases/download/$version/$asset" -o "$staging/$asset"; then - downloaded=yes - fi + [ "$writable" = yes ] || fail 'Engine cache is missing or corrupt; run ./bootstrap worktree prepare or ./bootstrap packages setup first.' + [ "$offline" = no ] || fail 'Engine cache is missing or corrupt and --offline prohibits downloads.' + mkdir -p "$cache" + staging=$(mktemp -d "$cache/.download.XXXXXXXX") + trap 'rm -rf "$staging"' EXIT HUP INT TERM + downloaded=no + if command -v curl > /dev/null 2>&1; then + if curl --fail --location --silent --show-error --connect-timeout 20 --max-time 300 \ + "https://github.com/$repo/releases/download/$version/$asset" -o "$staging/$asset"; then + downloaded=yes fi - if [ "$downloaded" = no ] && command -v gh >/dev/null 2>&1; then - rm -f "$staging/$asset" - if gh release download "$version" --repo "$repo" --pattern "$asset" --dir "$staging"; then - downloaded=yes - fi + fi + if [ "$downloaded" = no ] && command -v gh > /dev/null 2>&1; then + rm -f "$staging/$asset" + if gh release download "$version" --repo "$repo" --pattern "$asset" --dir "$staging"; then + downloaded=yes fi - [ "$downloaded" = yes ] || fail 'Download failed. Install curl, or authenticate gh for private GitHub releases.' - [ "$(digest < "$staging/$asset")" = "$expected" ] || fail 'Downloaded archive SHA-256 does not match its release pin.' - tar -xOf "$staging/$asset" hypertext-bootstrap > "$staging/hypertext-bootstrap" - [ -s "$staging/hypertext-bootstrap" ] || fail 'Release archive contains an empty engine.' - chmod 755 "$staging/hypertext-bootstrap" - # Each concurrent writer installs identical verified bytes through atomic renames. - mv -f "$staging/$asset" "$archive" - mv -f "$staging/hypertext-bootstrap" "$engine" - rm -rf "$staging" - trap - EXIT HUP INT TERM + fi + [ "$downloaded" = yes ] || fail 'Download failed. Install curl, or authenticate gh for private GitHub releases.' + [ "$(digest < "$staging/$asset")" = "$expected" ] || fail 'Downloaded archive SHA-256 does not match its release pin.' + tar -xOf "$staging/$asset" hypertext-bootstrap > "$staging/hypertext-bootstrap" + [ -s "$staging/hypertext-bootstrap" ] || fail 'Release archive contains an empty engine.' + chmod 755 "$staging/hypertext-bootstrap" + # Each concurrent writer installs identical verified bytes through atomic renames. + mv -f "$staging/$asset" "$archive" + mv -f "$staging/hypertext-bootstrap" "$engine" + rm -rf "$staging" + trap - EXIT HUP INT TERM fi exec "$engine" "$@" diff --git a/tests/unit/bootstrap.test.ts b/tests/unit/bootstrap.test.ts index a77ec1c..4c09b18 100644 --- a/tests/unit/bootstrap.test.ts +++ b/tests/unit/bootstrap.test.ts @@ -1,5 +1,8 @@ import { describe, expect, test } from 'vitest'; -import { readFileSync } from 'node:fs'; +import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; +import { spawnSync } from 'node:child_process'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; describe('common setup entrypoint', () => { test('declares only the native dependency builds already owned by bootstrap', () => { @@ -11,4 +14,30 @@ describe('common setup entrypoint', () => { const bootstrap = readFileSync('scripts/bootstrap-worktree', 'utf8'); expect(bootstrap).toContain('exec pnpm rebuild esbuild workerd sharp'); }); + + test.each([ + { args: ['packages', 'setup'] }, + { args: ['packages', 'check', '@thehypertextstudio/web-config'] }, + { args: ['worktree', 'plan', '--json'] }, + ])('forwards $args to the shared engine and preserves its exit status', ({ args }) => { + const root = mkdtempSync(join(tmpdir(), 'studio-bootstrap-')); + try { + mkdirSync(join(root, 'scripts')); + copyFileSync('bootstrap', join(root, 'bootstrap')); + writeFileSync( + join(root, 'scripts/bootstrap-worktree-engine'), + '#!/bin/sh\npwd\nprintf "%s\\n" "$@"\nexit 7\n', + { mode: 0o755 }, + ); + const result = spawnSync(join(root, 'bootstrap'), args, { + cwd: tmpdir(), + encoding: 'utf8', + }); + expect(result.status).toBe(7); + expect(result.stdout.trim().split('\n')).toEqual([root, ...args]); + expect(result.stderr).toBe(''); + } finally { + rmSync(root, { recursive: true, force: true }); + } + }); }); From 81e300ff2091e84075bd71e10ec36597e935273e Mon Sep 17 00:00:00 2001 From: Willie Chalmers III Date: Tue, 3 Nov 2026 17:01:18 -0800 Subject: [PATCH 2/2] fix(dx): Migrate legacy package authentication during setup Pin the reviewed Studio bootstrap 0.1.4 so an unset legacy token placeholder cannot hide the local credential helper. Preserve explicit token priority and use the selected user file when pnpm protects its config-list output. The shared native matrix passes all 12 configurations on pnpm 10.33.0 and 11.9.0 with two real frozen preparations per case. It verifies config and lock preservation and checkout-local dependency ownership. The release also passes 25 Rust and 50 Python tests on all four native platforms. CI keeps its explicit workflow credential and package read grants. Local setup continues through the normal repository bootstrap command. Co-authored-by: Codex --- scripts/bootstrap-worktree-engine | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/bootstrap-worktree-engine b/scripts/bootstrap-worktree-engine index 7a519a3..cbd34ce 100755 --- a/scripts/bootstrap-worktree-engine +++ b/scripts/bootstrap-worktree-engine @@ -1,7 +1,7 @@ #!/bin/sh # Generated by Hypertext Studio bootstrap. Update pins with render-launcher.py. set -eu -version='v0.1.3' +version='v0.1.4' repo='TheHypertextStudio/bootstrap' fail() { printf '%s\n' "bootstrap: $*" >&2 @@ -18,10 +18,10 @@ case "$(uname -s)" in Darwin) os=darwin ;; Linux) os=linux ;; *) fail 'Unsupport case "$(uname -m)" in arm64 | aarch64) arch=arm64 ;; x86_64 | amd64) arch=x86_64 ;; *) fail 'Unsupported architecture.' ;; esac platform="$os-$arch" case "$platform" in - darwin-arm64) expected='3f3323a44cfe1bab5b41ebf44d924c9caae780dee91e6d6b22ee076562621369' ;; - darwin-x86_64) expected='df8c09194cddf531101f1eb232f04f87951476ae4cd3995e11aacc8e2789aef5' ;; - linux-arm64) expected='6675db0dd4d8e9df1224cd0acb62ab3ca757bb978c738bd1b3af2c301b693848' ;; - linux-x86_64) expected='5133f4e0d49e20049fad68bdd31c49f68be80835e4c07f4c0d6d38cecf8e2141' ;; + darwin-arm64) expected='a5c6c6ad47923cc45e6b1fe72b0f605916b72e3be7e992f1ebec25127ba1685a' ;; + darwin-x86_64) expected='16b2a6077c43e4d4afcb012174169a6e0f8ed621475355157d75b2ec7b7324ad' ;; + linux-arm64) expected='946582f93a615c92f173e31fad1e3c4af099c2a0d84b185d7e83acd5b0ba6908' ;; + linux-x86_64) expected='75a769e3e69178364665298afd83bd534c51e3347149c500fc62270ecf676883' ;; esac asset="hypertext-bootstrap-$platform.tar.gz" cache="${XDG_CACHE_HOME:-${HOME:?HOME is required}/.cache}/hypertext-studio/bootstrap/$version/$platform"