Skip to content

feat(cli): route fern sdk preview through remote generation, add --local and --push-diff#14856

Merged
lifanzou merged 24 commits intomainfrom
devin/1775761146-sdk-preview-remote-routing
Apr 10, 2026
Merged

feat(cli): route fern sdk preview through remote generation, add --local and --push-diff#14856
lifanzou merged 24 commits intomainfrom
devin/1775761146-sdk-preview-remote-routing

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented Apr 9, 2026

Description

Routes fern sdk preview through remote generation by default (matching fern generate), adds --local flag to opt into local Docker execution, and adds --push-diff flag for pushing preview branches to SDK repos.

Command Generation Publish
fern sdk preview Remote Preview registry
fern sdk preview --output ./path Remote Disk only (downloaded from S3)
fern sdk preview --local --output ./path --output https://registry Local Docker Disk + custom registry
fern sdk preview --push-diff Remote Preview registry + push preview branch
fern sdk preview --local Local Docker Preview registry
fern sdk preview --local --output ./path Local Docker Disk only

Key design: decoupled preview semantics

The CLI needs preview mode internally (lenient env var substitution, skip version check, skip dynamic IR upload), but sending preview: true to the generation service causes dry-run mode which prevents actual publishing.

Solution: New fiddlePreview parameter that overrides what's sent to the generation service as the preview field. For fern sdk preview, we send fiddlePreview: false so the service doesn't dry-run. For fern generate --preview, fiddlePreview is undefined and falls back to the existing behavior (absolutePathToPreview != null, which is true for preview — preserving dry-run exactly as-is).

This avoids any server-side dry-run logic changes, eliminating regression risk for fern generate --preview.

Changes Made

  • cli.ts: Add --local and --push-diff boolean options. --local opts into local Docker generation; --push-diff cannot be combined with --local. Pass both to sdkPreview().
  • sdkPreview.ts: Route based on --local flag (useRemoteGeneration = !local) instead of presence of --output. Pass absolutePathToPreview: absolutePathToOutput to remote generation so --output downloads files from S3. Validate --push-diff + --local incompatibility. Warn when --push-diff falls back due to missing github config.
  • overrideOutputForPreview.ts: Consolidate local/remote output override into single function with optional pushDiff param. Extract createNpmOverrideOutputMode helper. When pushDiff=true and generator has github config, use githubV2(push) with npm publishInfo. Add unit tests for getGithubOwnerRepo, overrideGroupOutputForDownload, and overrideGroupOutputForPreview.
  • createAndStartJob.ts: Add fiddlePreview and pushPreviewBranch params. Override preview field sent to the generation service via fiddlePreview ?? absolutePathToPreview != null. pushPreviewBranch is threaded but commented out until the server-side SDK is bumped.
  • runRemoteGenerationForAPIWorkspace.ts / runRemoteGenerationForGenerator.ts: Thread fiddlePreview and pushPreviewBranch through the remote generation chain.
  • versions.yml: Add 4.66.0 changelog entry.

Safety

  • --push-diff is gated with an error until the server-side SDK is bumped — prevents sending a github push job without the preview branch flag, which would write to the default branch.
  • fern generate --preview is completely unaffected — fiddlePreview is only set in the sdkPreview.ts code path.

Human review checklist

  • Confirm RemoteTaskHandler correctly downloads generated files to absolutePathToOutput when set — verified end-to-end with fern sdk preview --output ./out.
  • The --local flag is independent of --output: --local alone still publishes to the preview registry via Docker. Verify this matches product intent.
  • fiddlePreview: false is the critical behavioral change — it prevents the generation service from setting dryRun=true. If the service's dry-run logic changes in the future, this coupling should be revisited.
  • Multi-output (--output ./path --output https://registry) is fully stubbed and routed for both local and remote paths, but the custom-registry-URL flow through remote generation has not been verified end-to-end.

Testing

  • fern sdk preview → package published to preview registry via remote (no dry-run)
  • fern sdk preview --output ./out → remote generation, files downloaded to disk
  • fern sdk preview --local → local Docker, package published to preview registry
  • fern sdk preview --local --output ./out → local Docker, files on disk
  • fern sdk preview --local --output ./out --output https://registry → local Docker, files on disk + custom registry
  • fern sdk preview --push-diff → errors with "not yet available" (gated until server update)
  • fern generate --preview → existing behavior preserved (dry-run)
  • fern generate → completely unaffected

Link to Devin session: https://app.devin.ai/sessions/92d936472d7a4bf187ae6b52721f36fd

…default

Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

🌱 Seed Test Selector

Select languages to run seed tests for:

  • Python
  • TypeScript
  • Java
  • Go
  • Ruby
  • C#
  • PHP
  • Swift
  • Rust
  • OpenAPI

How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR.

…n by default

Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
devin-ai-integration Bot added a commit to fern-api/actions that referenced this pull request Apr 9, 2026
…eration

Remove fern-api.ts (installation token client) and push-diff.ts (diff branch
pushing) — Fiddle now handles npm publishing and diff branch pushing server-side.

The action now just runs `fern sdk preview --json --group <group>` which routes
through Fiddle by default (no --output flag), then posts a PR comment with
install links and diff URLs from the CLI JSON output.

Depends on:
- fern-api/fiddle#682 (preview diff branch push in GithubFiddleTask)
- fern-api/fern#14856 (remote Fiddle routing in fern sdk preview)

Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
devin-ai-integration Bot and others added 3 commits April 9, 2026 19:27
…te preview

- Default fern sdk preview (no flags): publishV2(npmOverride) → registry-only publish, safe to merge independently
- With --push-diff: githubV2(push) + preview=true → Fiddle publishes AND pushes diff branch to SDK repo
- Added explicit isPreview param to remote generation chain (createAndStartJob, runRemoteGenerationForGenerator, runRemoteGenerationForAPIWorkspace) so preview flag can be set independently of absolutePathToPreview

Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
@devin-ai-integration devin-ai-integration Bot changed the title feat: route fern sdk preview through Fiddle for remote generation by default feat(cli): route fern sdk preview through Fiddle for remote generation by default Apr 9, 2026
devin-ai-integration Bot and others added 7 commits April 9, 2026 22:30
…lish

In Fiddle, preview=true causes dryRun=true in the generator config,
which makes the generator run 'npm publish --dry-run' instead of
actually publishing. For sdk preview via publishV2(npmOverride),
we want the generator to actually publish to the registry.

Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
…ditional on pushDiff, clarify JSDoc

Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
…-diff

Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
…ndle dryRun

Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
…port

- Add `fiddlePreview` param to decouple what's sent to Fiddle as `preview`
  from CLI-internal `isPreview` behavior. For sdk preview, isPreview=true
  (lenient env vars, skip version check) while fiddlePreview=false (so
  Fiddle doesn't set dryRun=true). This preserves fern generate --preview
  behavior exactly as-is.
- Add `pushPreviewBranch` param threaded through the remote generation
  chain. Will be sent to Fiddle once fiddle-sdk is bumped.
- Add `--push-diff` CLI flag for pushing preview branches to SDK repos.
- Add `getGithubOwnerRepo` helper and pushDiff support to
  `overrideGroupOutputForRemotePreview` — uses githubV2(push) with npm
  publishInfo when --push-diff is set and generator has github config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lifanzou lifanzou changed the title feat(cli): route fern sdk preview through Fiddle for remote generation by default feat(cli): route fern sdk preview through Fiddle, add --push-diff Apr 10, 2026
Barry and others added 2 commits April 9, 2026 18:00
…ction

Merge the local-Docker-only overrideGroupOutputForPreview and remote-only
overrideGroupOutputForRemotePreview into a single exported function with an
optional pushDiff param. Extract createNpmOverrideOutputMode helper to
deduplicate the publishV2(npmOverride) construction.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Error out on --push-diff until fiddle-sdk is bumped with
  pushPreviewBranch support — without it, Fiddle would treat the
  githubV2(push) job as a normal push to the default branch.
- Error on --push-diff combined with --output (incompatible flags).
- Warn when --push-diff falls back to registry-only publish because
  the generator has no github output configuration.
- Clarify the dryRun comment in createAndStartJob.ts explaining
  that fiddlePreview is the sole mechanism preventing dryRun for
  sdk preview jobs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lifanzou lifanzou changed the title feat(cli): route fern sdk preview through Fiddle, add --push-diff feat(cli): route fern sdk preview through remote generation, add --push-diff Apr 10, 2026
Document the behavior differences between modes: omitting --output
uses remote generation, providing it uses local Docker. Add examples
for --output combinations. Clarify --push-diff branch naming, GitHub
App requirement, and incompatibility with --output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…mote generation

Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
@devin-ai-integration devin-ai-integration Bot changed the title feat(cli): route fern sdk preview through remote generation, add --push-diff feat(cli): route fern sdk preview through remote generation, add --local and --push-diff Apr 10, 2026
devin-ai-integration Bot and others added 4 commits April 10, 2026 11:59
…of --output

Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
Co-Authored-By: barry.zou <barry.zou@buildwithfern.com>
…preview

When --output is provided without a registry URL and without --local,
remote generation was using the generator's original output mode (e.g.
npm publish to registry.npmjs.org) which fails. Override to
downloadFiles so the generator produces files without publishing,
and the CLI downloads them from S3 to the specified path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cover getGithubOwnerRepo, overrideGroupOutputForDownload, and
overrideGroupOutputForPreview including pushDiff routing logic.
Add clarifying comment on publishV2 being registry-only.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
isPreview was threaded to createAndStartJob only to participate in the
fallback chain for the Fiddle preview flag, but no caller needed it —
fern sdk preview already passes fiddlePreview explicitly, and fern
generate --preview relies on absolutePathToPreview != null. Simplify
the fallback to: fiddlePreview ?? absolutePathToPreview != null.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Barry and others added 3 commits April 10, 2026 11:10
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
automationMode and autoMerge are in the type signature but not
destructured on main (they're commented out in the createJobV3 call).
The merge conflict resolution incorrectly added them to the
destructuring.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lifanzou lifanzou merged commit b9a86a1 into main Apr 10, 2026
56 checks passed
@lifanzou lifanzou deleted the devin/1775761146-sdk-preview-remote-routing branch April 10, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants