feat!: consolidate and rename CLI environment variables#180
Conversation
Reduce env-var sprawl in the CLI: - Derive the LLM gateway and CLI telemetry URLs from WORKOS_API_URL instead of separate WORKOS_LLM_GATEWAY_URL / WORKOS_TELEMETRY_URL vars, so api.workos.com is no longer hardcoded in multiple places. - Remove the redundant WORKOS_NO_PROMPT alias; WORKOS_MODE=agent is the single, self-documenting way to force agent interaction + JSON output. - Standardize the INSTALLER_* prefix to WORKOS_* (WORKOS_DEV, WORKOS_DISABLE_PROXY). - Fix the rotted `workos debug env` catalog (it was missing several vars) and add a test that scans src/ for WORKOS_* env reads and fails if any is missing from the catalog, preventing future drift. BREAKING CHANGE: WORKOS_LLM_GATEWAY_URL and WORKOS_TELEMETRY_URL are removed (derived from WORKOS_API_URL); WORKOS_NO_PROMPT is removed (use WORKOS_MODE=agent); INSTALLER_DEV is renamed to WORKOS_DEV and INSTALLER_DISABLE_PROXY to WORKOS_DISABLE_PROXY.
Greptile SummaryThis PR consolidates the CLI's environment-variable surface by removing
Confidence Score: 5/5The change is safe to merge — it is a well-scoped rename/consolidation with no functional regressions in the env-var resolution logic. All five removed/renamed variables have correct callsite updates throughout the codebase. The new URL-derivation logic in urls.ts is simple and covered by the integration test. The resolveEffectiveOutputMode coupling correctly replicates the WORKOS_NO_PROMPT behavior for WORKOS_MODE=agent. The anti-drift guard closes a real maintenance gap. No new issues were found beyond what the prior review thread already identified. src/commands/debug.ts — the raw-value exposure of WORKOS_API_KEY in workos debug env output is a pre-existing concern raised in the prior thread that remains unaddressed. Important Files Changed
|
Address code review on the env-var cleanup: - Move getLlmGatewayUrl/getTelemetryUrl from settings.ts into urls.ts so the derived endpoints sit next to their base (getWorkOSApiUrl). This removes the backwards settings->urls import and makes urls.ts a dependency-free leaf that is the single home for WorkOS endpoint resolution. getAuthkitDomain stays in settings.ts since it's config-backed, not API-host-derived. - Normalize the trailing slash once inside getWorkOSApiUrl instead of repeating the strip at each derivation site. - Scope the env-var-catalog guard test's claim to dot-access reads and document the forms it doesn't cover (bracket access, destructuring). - Fix a stale docstring on getCliAuthClientId (it is not env-overridable).
- Replace the hand-rolled recursive file walk with fast-glob, the pattern already used across src/ (environment.ts, validator.ts, integrations). - Read source files concurrently instead of in a sequential await loop. - Make the catalog check bidirectional: it now also fails on stale entries (cataloged vars no longer read anywhere), not just missing ones, with an explicit CATALOG_ONLY escape hatch for any future non-dot-access reads. This subsumes the old WORKOS_-prefix assertion.
WORKOS_SECRET_KEY is only written (migrations.ts sets it for the downstream migrations SDK), never read by the CLI. The guard's regex matched the assignment's left-hand side and "discovered" it, so it was catalogued as an input credential — misleading, since the CLI ignores any user-provided value. Tighten the discovery regex to exclude assignment targets (with an end-anchor so the greedy capture can't backtrack to a truncated name), and drop the write-only WORKOS_SECRET_KEY entry. The catalog now means exactly what its docstring claims: WORKOS_ vars the CLI reads.
What & why
The CLI's environment-variable surface had grown large and inconsistent. This consolidates it.
Removed (derived instead)
WORKOS_LLM_GATEWAY_URL→ derived as${WORKOS_API_URL}/llm-gatewayWORKOS_TELEMETRY_URL→ derived as${WORKOS_API_URL}/cliBoth endpoints live under the WorkOS API host, so they're now derived from the single
WORKOS_API_URLbase.api.workos.comis no longer hardcoded in three places, and settingWORKOS_API_URLalone reroutes the API, gateway, and telemetry together.Removed (redundant)
WORKOS_NO_PROMPT→ useWORKOS_MODE=agentIt was a legacy alias that mapped to agent interaction + JSON output.
WORKOS_MODE=agentalready does exactly that (JSON is forced viaresolveEffectiveOutputMode), and it's self-documenting —NO_PROMPTdescribed one side effect and hid the other.Renamed (prefix consistency)
INSTALLER_DEV→WORKOS_DEVINSTALLER_DISABLE_PROXY→WORKOS_DISABLE_PROXYAnti-drift guard
The
workos debug envcatalog had already rotted (missingWORKOS_AGENT,WORKOS_SECRET_KEY,WORKOS_CLIENT_ID, and others). Fixed it, and added a test that scanssrc/forprocess.env.WORKOS_*/ destructuredenv.WORKOS_*reads and fails if any isn't cataloged — so the list can't silently drift again.Breaking change
feat!:→ release-please will cut0.18.0(minor, perbump-minor-pre-major) with a BREAKING CHANGES changelog entry. Real-world risk is low: 4 of the 5 vars are internal/developer-only, andWORKOS_NO_PROMPTis largely redundant with non-TTY auto-detection.Verification
pnpm typecheck✅pnpm test✅ (2092 passing)pnpm build✅process.env.Xand destructuredenv.Xreads.