This directory contains the release and CI automation scripts for the facets monorepo.
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
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.
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 │
└─────────────────┘ └──────────────────────┘
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:
- The CLI is cross-compiled into 12 standalone binaries for different platforms
- These are published as individual
@agent-facets/cli-*platform packages - A synthesized wrapper package (
agent-facets) is published last withoptionalDependenciespointing to all 12 platform packages - This custom flow cannot use
changeset publishor standardnpm publishfrom the source directory - Marking it
privatepreventschangeset publishfrom attempting to publish the raw source package — the customrelease-cli/pipeline handles it instead
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:
- Listed in
.changeset/config.jsonignore— changesets never bumps the package's version or includes it in the Version Packages PR. This is the authoritative mechanism. - No
versionfield inpackage.json—release/tag.tsandlib/changesets.ts#hasUnpublishedVersionsdefensively skip any package without a version. Without this fallback, an accidental removal from theignorelist would causetag.tsto try creating@pkg@undefinedtags, andhasUnpublishedVersionswould perpetually report the package as "unpublished" (sincenull !== undefined). prepackstripsdevDependenciesoutright viastripDevDependenciesinscripts/lib/prepack.ts— this is the load-bearing protection that lets published packages keepworkspace:*devDep references to versionless workspace-only packages (e.g.@agent-facets/commonincore/adapter/clidevDeps).bun pm pack(used by the publish pipeline since PR #206) validates everyworkspace:*specifier — including those indevDependencies— and refuses to pack when one is unresolvable.npm publishstrips devDeps from the tarball regardless, so deleting them at pack time has no effect on the published artifact, andpostpackrestores the original manifest.DEP_FIELDSexcludesdevDependenciesfrom rewriting as belt-and-suspenders so the helper stays safe on any input shape.prepackandpostpackwrite all diagnostic output to stderr (not stdout) sobun pm pack --quiet's stdout stays parseable byextractPackFilename— 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.
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.
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.
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.
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.
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.