feat: add zero-auth install flow with claim command#91
feat: add zero-auth install flow with claim command#91
Conversation
Phase 1 core infrastructure for one-shot mode: - One-shot provisioning API client (provisionOneShotEnvironment) - Claim nonce API client (createClaimNonce) - Cookie password generator (generateCookiePassword) - OneShotApiError with status code, timeout, rate limit handling - Config store: add unclaimed environment type and claimToken field - isUnclaimedEnvironment() helper - 30 new tests covering all API scenarios and config round-trips
Add warnIfUnclaimed() module that shows a non-blocking stderr warning when management commands run against an unclaimed environment. Lazily checks claimed status via createClaimNonce() once per session and auto-upgrades config when claimed. Wired into all management command handlers in bin.ts. Updated env list to show (unclaimed) label.
nicknisi
left a comment
There was a problem hiding this comment.
Code Review Findings
Warnings
-
Missing test coverage for unclaimed label display —
env.spec.tslacks tests for the(unclaimed)label inrunEnvList(src/commands/env.ts:221-237). Consider adding tests that verify the label renders correctly for unclaimed environments. -
Missing test for claim command registration —
help-json.spec.tsdoes not explicitly verify theclaimcommand appears in the help registry (src/utils/help-json.ts:1037-1051). A targeted assertion would prevent silent regressions. -
Duplicate
generateCookiePassword— The same function exists in bothsrc/lib/one-shot-api.ts:196andsrc/lib/env-writer.ts:45. Consider extracting to a shared utility module to reduce duplication.
Info
-
False positive in
.case-tested—fail_indicators: 1is a grep heuristic false positive; confirmed 1098/1098 tests passing. -
Pre-existing large files —
run-with-core.ts(541 lines) andhelp-json.ts(1259 lines) were already above the 300-line threshold; changes in this PR are minimal additions.
Automated review by case/reviewer agent
Summary
Implements one-shot mode — zero-friction
workos installthat works without prior authentication. When no credentials are found, the CLI silently provisions an "unclaimed" environment via the one-shot API, writes all credentials to.env.local, and proceeds with the install. Users can later link the environment to their WorkOS account viaworkos claim. Management commands on unclaimed environments show a non-blocking warning.This is a 3-phase implementation from the one-shot-mode ideation contract:
one-shot-api.ts) and config store type extension (unclaimedenv type +claimToken)resolveInstallCredentials),workos claimcommand with nonce-based browser auth + polling, env-writerCLAIM_TOKENsupport, help-json registration(unclaimed)label, and claimed detectionWhat was tested
Automated
pnpm typecheck— PASSpnpm build— PASSone-shot-api.spec.ts— 22 tests (provisioning, claim initiation, claim polling, error handling)one-shot-provision.spec.ts— 11 tests (happy path, API failure fallback, config store writes)claim.spec.ts— 15 tests (nonce generation, browser open, polling, timeout, JSON mode)unclaimed-warning.spec.ts— 12 tests (warning display, dedup, JSON suppression, claimed detection)config-store.spec.ts— +13 tests (unclaimed type, claimToken field, type guard)login.spec.ts— +8 tests (one-shot passthrough)Manual
Full code review of all 17 changed files across 3 implementation commits. Each acceptance criterion verified against source code and tests:
(unclaimed)label with hint to runworkos claimmaybeWarnUnclaimed()across 80+ command handlersKey design decisions
tryOneShotProvision()catches all errors and returnsfalse, allowing seamless fallback to the existingensureAuthenticated()login flowmaybeWarnUnclaimed()uses a module-level flag to prevent repeated warnings across multiple commands in a sessionFiles changed (17)
src/lib/one-shot-api.tssrc/lib/one-shot-api.spec.tssrc/lib/one-shot-provision.tstryOneShotProvision()helpersrc/lib/one-shot-provision.spec.tssrc/lib/unclaimed-warning.tssrc/lib/unclaimed-warning.spec.tssrc/commands/claim.tsworkos claimcommandsrc/commands/claim.spec.tssrc/lib/config-store.tsunclaimedtype,claimTokenfieldsrc/lib/config-store.spec.tssrc/commands/login.tssrc/commands/login.spec.tssrc/commands/env.tssrc/lib/env-writer.tssrc/lib/run-with-core.tsmaybeWarnUnclaimed()wiringsrc/bin.tsresolveInstallCredentials(), claim command registrationsrc/utils/help-json.tsFollow-ups
env.spec.tslacks tests for unclaimed label display inrunEnvList— should be addedhelp-json.spec.tsdoes not explicitly verify claim command registration — should be addedgenerateCookiePasswordexists inone-shot-api.tsandenv-writer.ts— consider extracting to a shared utilityScreenshots
Unclaimed environment created

Warning about taking actions on an unclaimed environment
