You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add experimental headless mode for published, non-interactive runs (#732)
Adds a non-interactive run path that works in the *published* package, for
PostHog's cloud setup runs and CI/CD. Until now --ci was the only headless
path and it is stripped from published builds.
Flag & routing
- New global flag --headless-DONOTUSE-EXPERIMENTAL: hidden from --help and
declared unconditionally so it survives in the shipped package (unlike --ci).
Intentionally ugly-named and undocumented — the contract is still unstable.
Its name + detection live in one place, src/lib/headless-mode.ts
(HEADLESS_FLAG + isHeadless).
- basic-integration dispatch routes the flag to its own entry point with a
plain `if (isHeadless(argv))` check, separate from the `if (argv.ci)` check.
CI / headless division (shared now, easy to diverge later)
- runHeadlessInstall / runWizardHeadless are siblings of runCIInstall /
runWizardCI. Both delegate to one shared pipeline,
runNonInteractive(config, options, mode), parameterized by an explicit
NonInteractiveMode ('ci' | 'headless'). To diverge: branch on mode, or give
the headless functions their own body — no CI-path or caller changes needed.
Auth
- Headless accepts a pha_ OAuth access token as first-class (PostHog mints one
under the wizard's OAuth app for cloud runs) in addition to a phx_ personal
key; CI still warns on pha_. keyPrefixWarning extracted as a pure predicate.
- The token is passed via POSTHOG_WIZARD_API_KEY (already wired through yargs
.env), never on the command line.
Analytics / instrumentation
- runNonInteractive tags the analytics build type by mode ('headless' vs 'ci').
That tag rides on every analytics event and on LLM-gateway trace tags (via
buildRunTags reading analytics.build), so headless cloud runs segment cleanly
from prod / dev / ci everywhere.
Other
- --ci stays dev/test-only; its published-build rejection is unchanged and
failNonInteractive still points at --ci (headless is not advertised).
- README untouched (flag is undocumented); smoke test verifies the flag is
accepted in published builds and reaches the headless install path.
- Tests: keyPrefixWarning unit tests, headless routing + build-tag tests,
flag parsing tests, and a gateway-trace build-tag case.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments