GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — facets/scripts at main · agent-facets/facets

Expand file tree

/

scripts

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

scripts

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
lib
lib
 
 
release-cli
release-cli
 
 
release
release
 
 
smoke
smoke
 
 
AGENTS.md
AGENTS.md
 
 
README.md
README.md
 
 
check-bun-version.ts
check-bun-version.ts
 
 
postinstall.ts
postinstall.ts
 
 
postpack.ts
postpack.ts
 
 
prepack-adapters.test.ts
prepack-adapters.test.ts
 
 
prepack.ts
prepack.ts
 
 

README.md

Outline

Release Scripts

This directory contains the release and CI automation scripts for the facets monorepo.

Directory Structure

scripts/
├── release/                    # Library package release pipeline
│   ├── version.ts              # Create/update Version Packages PR
│   ├── tag.ts                  # Create git tags after version PR merge
│   ├── publish.ts              # Publish a library package from a tag
│   └── seed-adapters.ts        # Seed adapter/library package names on npm
│
├── release-cli/                # CLI binary release pipeline
│   ├── build.ts                # Cross-compile 12 platform binaries
│   ├── publish-platform.ts     # Publish one platform binary package
│   ├── publish-cli-package.ts  # Synthesize + publish CLI wrapper
│   ├── finalize.ts             # Orchestrate npm readiness and wrapper publication
│   ├── package-assets.ts        # Create portable GitHub Release archives + checksums
│   ├── upload-assets.ts         # Stage or publish a checksum-verified CLI release draft
│   ├── dispatch-attested-release.ts # Dispatch and await GitHub's attested archive release
│   ├── homebrew-formula.ts          # Render an official-tap formula from verified archive checksums
│   ├── verify.ts               # Wait for CLI packages to be available on npm (20m deadline)
│   ├── seed.ts                 # Seed platform package names on npm
│   └── targets.ts              # Platform target matrix definitions
│
├── lib/                        # Shared utilities
│   ├── io/                     # IO adapter (split by domain, nested namespaces)
│   │   ├── index.ts            # Composes io = { npm, git, gh, circleci, shell, console }
│   │   ├── npm.ts              # npm CLI commands (pack, publishTarball, view, etc.) + packument fetch
│   │   ├── git.ts              # git CLI commands
│   │   ├── github.ts           # GitHub CLI commands
│   │   ├── circleci.ts         # CircleCI API v2 calls
│   │   ├── shell.ts            # Shell, filesystem, build, CI tokens, network
│   │   └── console.ts          # log and error
│   ├── ci.ts                   # Workspace package loading, token minting
│   ├── npm.ts                  # npm registry helpers (whoami, exists, etc.)
│   ├── npm-readiness.ts        # Typed probe: is an exact version available on the public registry?
│   ├── seed-oidc.ts            # Shared OIDC trusted-publishing instructions
│   ├── changesets.ts           # Changeset parsing, PR body building
│   ├── announce.ts             # GitHub Release + Slack notification
│   ├── constants.ts            # Repo name, Slack channels, paths
│   ├── tags.ts                 # Version tag parsing (shared across pipelines)
│   ├── github-app.ts           # GitHub App token minting
│   ├── notify-failure.ts       # Slack failure notification (on_fail step)
│   └── test-helpers.ts         # Test utilities (mock helpers, fixtures)
│
├── smoke/                      # Node-only checks for @agent-facets/protocol
│   ├── protocol-node.mjs       # Manual: exercise the built bundle on plain Node
│   ├── node-only.mjs           # Run a script on Node with Bun provably unreachable
│   └── deny-network.mjs        # Preload: make Node's network entry points throw
│
├── prepack.ts                  # Rewrite workspace:* deps, hoist publishConfig overrides, inject adapter SDK API metadata before npm publish
├── postpack.ts                 # Restore package.json after pack
├── postinstall.ts              # Quiet `bun install` postinstall (lefthook + adapter + facets)
└── check-bun-version.ts        # Verify Bun version matches mise.toml

Smoke checks

Two Node-only checks cover @agent-facets/protocol, at different depths.

Automated — packages/protocol/src/__tests__/public-inventory.e2e.test.ts. Runs in bun check through protocol's test:e2e script. It builds the package, packs a real tarball from a staging copy of the published manifest (lifecycle scripts disabled, so the workspace package.json is never rewritten), extracts it into a fresh project with only its installed dependency closure, and consumes it by package name under Node 22+ with Bun unreachable and network entry points guarded. It then type-checks a strict consumer against the packed declarations with tsgo. It covers the published export map, both entrypoints, and the locked MCP inventory workflow — not the whole API.

Manual — scripts/smoke/protocol-node.mjs. Exercises a broad slice of the public surface (archives, manifests, version dispatch, materialization, lockfile 0.4 inventory) against the built bundle by relative path. It is not a *.test.* file, so nothing runs it for you; update it by hand alongside public-surface changes, and run it after building:

bun run --cwd packages/protocol build
node scripts/smoke/node-only.mjs scripts/smoke/protocol-node.mjs

scripts/smoke/node-only.mjs is the isolation both checks share. Filtering bun out of $PATH is not enough — a tool-manager shim directory serves node and bun alike — so it gives the child a $PATH holding only a link to the real Node executable, and refuses to run unless Node is 22+ and bun fails to resolve. Pass --deny-network to preload scripts/smoke/deny-network.mjs, which makes Node's standard network entry points throw. That is a regression guard against code reaching for the network, not an operating-system sandbox.

Two Pipelines

CLI archive release delivery is completed by .github/workflows/release-cli-assets.yml. CircleCI dispatches it only after npm publication has finalized. GitHub Actions rebuilds the archives from the exact tag, checks their SHA-256 values, publishes GitHub/Sigstore provenance attestations, verifies those attestations, and only then publishes the draft GitHub Release. This keeps the provenance build inside the CI provider that supplies the OIDC identity used by GitHub attestations. GitHub Actions uses its scoped workflow token for release delivery; CircleCI uses its freshly minted GitHub App token only for the dispatch and watches the run ID returned by GitHub, never the latest run for a tag. The GitHub CLI runner explicitly inherits that process environment, so the token is available to the dispatch subprocess. After that exact run succeeds, CircleCI sends the successful-release Slack notification using its existing Slack context; GitHub Actions never receives Slack credentials.

There are two independent release-pipeline workflows, both triggered by git tag patterns:

┌──────────────────────────────────────────────────────────────────┐
│  Developer merges changesets to main                             │
│                                                                  │
│  main-pipeline CI job:                                           │
│    1. bun run check                                              │
│    2. release/version.ts  → create/update Version Packages PR    │
│    3. release/tag.ts      → (no-op unless version PR just merged)│
└──────────────────────────────────────────────────────────────────┘
                                │
                        Version PR merged
                                │
                                ▼
┌──────────────────────────────────────────────────────────────────┐
│  main-pipeline runs again:                                       │
│    release/tag.ts detects the merge and creates git tags:        │
│                                                                  │
│    @agent-facets/[email protected]   ─── library tag                │
│    @agent-facets/[email protected]  ─── library tag                    │
│    [email protected]         ─── CLI tag                        │
└──────────────────────────────────────────────────────────────────┘
             │                                       │
             ▼                                       ▼
    ┌─────────────────┐                  ┌──────────────────────┐
    │ Library Release │                  │ CLI Release          │
    │ (release/ dir)  │                  │ (release-cli/ dir)   │
    │                 │                  │                      │
    │ See release/    │                  │ See release-cli/     │
    │ README.md       │                  │ README.md            │
    └─────────────────┘                  └──────────────────────┘

Why is the CLI package private?

The CLI package (agent-facets) is marked "private": true in its package.json. This is not because it's unpublished — it IS published to npm. It's private because:

  1. The CLI is cross-compiled into 12 standalone binaries for different platforms
  2. These are published as individual @agent-facets/cli-* platform packages
  3. A synthesized wrapper package (agent-facets) is published last with optionalDependencies pointing to all 12 platform packages
  4. This custom flow cannot use changeset publish or standard npm publish from the source directory
  5. Marking it private prevents changeset publish from attempting to publish the raw source package — the custom release-cli/ pipeline handles it instead

Workspace-only packages

Some workspace packages — @agent-facets/engine, @agent-facets/common — are private helpers that are never published and have no companion release pipeline. "private": true alone isn't enough to skip them: the CLI package is also private but MUST be tagged (its tag triggers the binary release pipeline).

The contract for marking a package as "workspace-only, never release" has three parts:

  1. Listed in .changeset/config.json ignore — changesets never bumps the package's version or includes it in the Version Packages PR. This is the authoritative mechanism.
  2. No version field in package.json — release/tag.ts and lib/changesets.ts#hasUnpublishedVersions defensively skip any package without a version. Without this fallback, an accidental removal from the ignore list would cause tag.ts to try creating @pkg@undefined tags, and hasUnpublishedVersions would perpetually report the package as "unpublished" (since null !== undefined).
  3. prepack strips devDependencies outright via stripDevDependencies in scripts/lib/prepack.ts — this is the load-bearing protection that lets published packages keep workspace:* devDep references to versionless workspace-only packages (e.g. @agent-facets/common in core / adapter / cli devDeps). bun pm pack (used by the publish pipeline since PR #206) validates every workspace:* specifier — including those in devDependencies — and refuses to pack when one is unresolvable. npm publish strips devDeps from the tarball regardless, so deleting them at pack time has no effect on the published artifact, and postpack restores the original manifest. DEP_FIELDS excludes devDependencies from rewriting as belt-and-suspenders so the helper stays safe on any input shape. prepack and postpack write all diagnostic output to stderr (not stdout) so bun pm pack --quiet's stdout stays parseable by extractPackFilename — see "Why pack-then-upload?" below.

Together these keep workspace-only packages out of the release pipeline entirely — no tags, no npm publishes, no lingering "unpublished" state, and no prepack failures.

Adapter SDK API metadata injection

For packages under packages/adapters/, prepack injects the facetAdapterApiVersion field into the packed package.json via injectAdapterApiVersion in scripts/lib/prepack.ts. The field name and value are imported from the Adapter SDK's canonical constants (packages/adapter/src/api-version.ts) — the single source of truth; neither string is hardcoded in the scripts. The facet CLI reads this field from the npm registry to select a compatible adapter release before downloading it. Non-adapter packages are untouched, and postpack restores the source manifest as usual. Packed-tarball coverage lives in scripts/prepack-adapters.test.ts.

Hard guard: changesets must not bump ignored or unknown packages

The Changesets UI sometimes adds a bump for a package in the ignore list, or for a fake/misnamed package (a typo'd name that isn't in the workspace). Either one breaks the release pipeline if merged — an ignored bump is silently dropped by changeset version (so the bump never ships), and an unknown package makes changeset version fail outright. bun check includes a hard guard against both: the repository changeset guard test in scripts/lib/changesets.test.ts reads the ignore list from .changeset/config.json, enumerates the valid workspace package names via loadWorkspacePackages(), parses every pending .changeset/*.md file's front-matter (parseChangesetBumps), and runs findForbiddenBumps (all in scripts/lib/changesets.ts). It fails with a per-file violation list — grouped into ignored vs unknown classes via formatForbiddenBumps — if any bump targets a package that is either in the ignore list or not a workspace package at all. ignore takes precedence over the workspace set, so an ignored package classifies as ignored, not unknown. The guard passes when there are no pending changesets.

Note: changeset status already errors on unknown packages, but it is blind to ignored-package bumps (it reports "NO packages to be bumped" and exits 0). This guard is the only check that catches the ignored case, and it folds in the unknown case too so both live in one fast, pure, unit-tested place.

turbo.json's //#test:scripts task includes .changeset/** in its inputs so adding or editing a changeset reliably reruns the guard instead of serving a stale cache hit.

Why pack-then-upload?

Both the library publish path and the CLI matrix path go through one helper — packAndPublish in scripts/lib/npm.ts — which does bun pm pack --quiet followed by npm publish <filename>. This avoids an npm lifecycle race: when npm publish builds its own tarball, the registry packument (the JSON metadata served by npm view) is derived from a different package.json snapshot than the tarball contents. Our prepack/postpack rewrite/restore dance leaves the packument with the original (un-rewritten) manifest, so installs fail with ENOLOCAL errors trying to resolve workspace:* deps the registry shouldn't have advertised.

Pre-building the tarball with bun pm pack and uploading it with npm publish <filename> makes npm derive the packument from the package.json inside the tarball — tarball and packument match by construction. The filename is parsed out of bun pm pack --quiet's stdout via extractPackFilename (which splits on newlines, filters to .tgz lines, and throws on zero or multiple matches) — bun pm pack runs prepack/postpack lifecycle scripts inline and forwards their stdout, so naive trimming would forward a multi-line blob to npm publish and trip EUNSUPPORTEDPROTOCOL (CircleCI job 782). The companion fix is sending those lifecycle diagnostics to stderr so stdout stays single-line in practice; extractPackFilename is the second line of defense. The captured filename is passed to npm publish as a single arg, never a *.tgz glob — npm publish accepts exactly one <package-spec>, so a leftover tarball from a prior local pack would otherwise fail with EUSAGE.

bun pm pack is stricter than npm publish about workspace:* specifiers — it validates every workspace reference at pack time, including those in devDependencies. That's why prepack deletes devDependencies outright before pack runs (see "Workspace-only packages" above). Without that strip, packing any package with a workspace:* devDep on a versionless workspace-only package would fail.

Per-package release queueing

release/tag.ts parses the package name out of scoped tags (@agent-facets/<pkg>@<version> → <pkg>) and forwards it as the package pipeline parameter when triggering CircleCI. The release workflow uses that parameter in its serial-group key so releases of different packages (core, adapter, etc.) can run in parallel while repeat releases of the same package serialize. The CLI tag (agent-facets@<version>) routes to the release-cli workflow, which doesn't use the parameter — we pass undefined there and the pipeline default ("") applies. See .circleci/AGENTS.md for the full serial-group layout across workflows.

IO Adapter

All external side effects (shell commands, file operations, network calls) go through the io object exported from lib/io/. The adapter is split into domain files and exposed as nested namespaces — one per domain.

Import it as:

import { io } from '../lib/io'

await io.npm.publishTarball(pkgDir, filename)
await io.git.pushAllTags('origin')
await io.gh.prCreate('main', head, title, body)
await io.circleci.triggerPipelineForTag(slug, defId, tag, packageName)
await io.shell.readFile(path)
io.console.log('hello')

Tests mock individual methods via the domain: spyOn(io.npm, 'publish'), spyOn(io.git, 'tagAt'), etc.

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.