Skip to content

feat(init): rewrite init CLI transport for Vercel Workflows#779

Draft
betegon wants to merge 1 commit intomainfrom
feat/vercel-workflows-init-rewrite
Draft

feat(init): rewrite init CLI transport for Vercel Workflows#779
betegon wants to merge 1 commit intomainfrom
feat/vercel-workflows-init-rewrite

Conversation

@betegon
Copy link
Copy Markdown
Member

@betegon betegon commented Apr 20, 2026

Summary

This rewrites the sentry init CLI transport to talk to the new Vercel Workflows backend.

Instead of the old Mastra createRun/startAsync/resumeAsync flow, the CLI now starts a Workflow run, reads a resumable NDJSON stream, dispatches local prompt/tool actions, posts hook results back to the API, and reconnects with startIndex when needed.

This intentionally does not preserve the old Mastra client contract.

Why

  • match the backend rewrite in cli-init-api
  • simplify the init transport to a durable workflow run plus streamed events
  • keep local side effects in the CLI while letting the backend own workflow state and progress
  • remove the need to upload eager file caches / directory listings as workflow inputs

What Changed

  • replaces the old init transport with:
    • POST /api/init
    • GET /api/init/:runId/stream
    • POST /api/init/actions/:actionId
  • adds NDJSON event parsing and resumable stream reconnect support via startIndex
  • deduplicates replayed action_request events so reconnects do not rerun local mutations
  • keeps local prompts, file edits, command execution, and Sentry auth/project work on the CLI side
  • removes authToken, dirListing, and fileCache from the initial workflow payload
  • updates spinner/rendering logic for the new structured event stream
  • removes the old MASTRA_API_URL fallback and uses the new init transport directly
  • adds transport-focused tests for start, reconnect, action resume, and NDJSON parsing

Paired Change

Paired API PR: getsentry/cli-init-api#100

These two PRs are a pair.

  • Do not merge or release this CLI PR without the paired API PR.
  • Prefer landing these together.
  • If deployment sequencing is unavoidable, deploy the API PR first and only then merge/release this CLI PR.

How To Run Locally

Check out this PR and the paired API PR together.

  1. Start the API from the paired cli-init-api checkout:
    cd /path/to/cli-init-api/apps/server
    bun run dev
  2. In the target app shell, point the CLI at the local API:
    export INIT_API_URL=http://localhost:3000
  3. Run sentry init from this checkout:
    cd /path/to/target-app
    bun run /path/to/cli/src/bin.ts init

Verification

  • bun test test/lib/init/transport.test.ts test/lib/init/wizard-runner.test.ts test/commands/init.test.ts
  • bun run typecheck
  • local dry-run and real-run against the Next.js fixture with the paired API PR

Notes

  • This PR intentionally assumes the new API contract and is not meant to ship before the paired backend rewrite.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 20, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (init) Rewrite init CLI transport for Vercel Workflows by betegon in #779
  • (issue) Add resolve, unresolve (reopen), and merge commands by BYK in #778

Bug Fixes 🐛

Init

  • Use isatty(0) for TTY detection and add diagnostic probe by BYK in #767
  • Reuse detected existing project data by betegon in #766
  • Ensure project reuse and spinner states by MathurAditya724 in #763

Other

Internal Changes 🔧

  • Regenerate docs by github-actions[bot] in 58a84035
  • Regenerate docs by github-actions[bot] in b0243668
  • Regenerate docs by github-actions[bot] in e02799c1

Other


🤖 This preview updates automatically when you update the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant