-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat(init): add init command for guided Sentry project setup #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
81 commits
Select commit
Hold shift + click to select a range
4d6ddde
feat(init): add init command for guided Sentry project setup
betegon 8146d8b
feat(init): pass tracing options to Mastra workflow runs
betegon 57f902f
feat(init): generate unique trace ID for each wizard run
betegon 0c5e440
fix(init): flatten nested workflow spans with shared parent span ID
betegon d60e3b2
fix(init): remove unnecessary parentSpanId from tracing options
betegon 3d39f61
feat(init): show ASCII banner and make error monitoring required
betegon 11cdf6c
fix(init): improve wizard UX for already-installed case, feature prom…
betegon 049fc95
feat(init): add AI transparency note and review reminder to wizard
betegon 1e76a55
fix: added auth headers in the mastra client (#264)
MathurAditya724 077119a
fix(init): update MASTRA_API_URL to production worker endpoint
betegon 350530f
feat(init): add eval test dependencies and biome config
betegon 4e1269f
feat(init): add init-eval test suite
betegon 476bcbc
ci: add workflow_dispatch CI job for init-eval tests
betegon 193a467
fix(init): use .md URL conversion in eval docs-fetcher
betegon bcb10f2
feat(init): add flask and python profiling doc URLs
betegon 129e7b7
feat(init): add nextjs doc URLs for eval ground truth
betegon b6c10b7
feat(init): add sveltekit doc URLs for eval ground truth
betegon a8156c0
feat(init): add react-vite doc URLs for eval ground truth
betegon 1d29ebd
fix(init): use venv for flask build check and remove opencode-lore dep
betegon ce9614f
feat(init): add python-fastapi eval test and gitignore package-lock
betegon 3227619
style(init): fix lint formatting in eval test files
betegon 04ae63d
ci(init): add minimal permissions to init-eval workflow
betegon 4d7787c
fix(init): update sveltekit template and use python3 in eval tests
betegon 102baa6
ci(init): run init-eval on PRs and main pushes
betegon 51f8968
Revert "ci(init): run init-eval on PRs and main pushes"
betegon d5d0b22
ci(init): remove init-eval workflow for now
betegon 1308035
feat(init): enforce --dry-run flag in local operations
betegon 00417d6
fix(init): use HTTPS for default API URL
betegon d41cbb8
fix(init): add @clack/prompts as direct dependency
betegon 2dd7f47
feat(init): add command execution guardrails to local-ops
betegon a8a10a4
docs(init): add init command page to cli.sentry.dev
betegon b8cddd5
refactor(init): extract magic values into named constants
betegon b20089e
Merge remote-tracking branch 'origin/main' into claude/funny-jang
betegon 441ea88
fix: resolve lint and format errors in local-ops
betegon 184dff6
test(init): add comprehensive tests for init wizard coverage
betegon 9fb739d
merge: resolve conflicts with main branch
betegon 20a4431
Merge branch 'feat/init-command' of https://github.com/getsentry/cli …
betegon 068663d
test(init): improve patch coverage by including isolated tests in CI …
betegon 7488e86
fix(ci): run isolated tests separately to avoid mock.module() leakage
betegon 2124e99
fix(test): move init-command test out of isolated to avoid mock leakage
betegon 0f0f61a
fix(test): run each isolated test file in its own bun process
betegon 07905aa
fix(test): merge duplicate LCOV entries from per-file isolated runs
betegon 864fef6
refactor(test): replace mock.module() with spyOn() for init tests
betegon 8cfa8f5
fix(test): keep wizard-runner isolated (spyOn fails on local ESM in CI)
betegon 241eb0c
fix: close file descriptor on readSync failure in readFiles
betegon a1a1629
fix: block redirection/background metacharacters and use cross-platfo…
betegon b5cce8e
fix: validate remote-supplied cwd against project directory
betegon 6ca341e
fix: set process.exitCode on wizard failure paths
betegon b6b4525
fix: harden wizard runner error handling and command validation
betegon dee9c53
fix: block subshell bypass via parentheses and set exitCode on missin…
betegon b5bc811
Merge remote-tracking branch 'origin/main' into feat/init-command
betegon c1461d3
refactor: split skill docs into reference files and improve skill loader
betegon 037382b
Revert "refactor: split skill docs into reference files and improve s…
betegon 89e98ca
refactor: remove merge-lcov and simplify test/CI coverage pipeline
betegon cae38bb
fix: reset process.exitCode in test resetAllMocks to prevent CI exit …
betegon b5a8c8f
test: add wizard-runner unit tests to improve patch coverage to >= 80%
betegon 39e4b5a
fix: lint errors in wizard-runner test and imports
betegon bc4ca1d
fix: address PR review issues in interactive and local-ops
betegon 6ffca44
fix: block env var injection in commands and fix resume step ID mismatch
betegon aa04148
refactor: add DirEntry type and precomputeDirListing returning DirEnt…
betegon d1b5fc8
Revert "refactor: add DirEntry type and precomputeDirListing returnin…
betegon 5313a92
perf(init): pre-compute dir listing and send _prevPhases for cross-ph…
betegon be2e9ad
fix(init): address PR review comments — block # metachar, document fi…
betegon c69da8b
refactor(init): add typed interfaces, validate-all-then-execute, and …
betegon 914995f
fix(init): add symlink bypass protection, API timeout, and cleanup
betegon af67578
fix(init): restore production API URL and validate-all-then-execute f…
betegon ba6bd73
Merge branch 'main' into feat/init-command
betegon 30eb4e8
feat(init): add create-sentry-project local op with org resolution fa…
betegon 4803bbf
fix: use org-as-subdomain pattern for SaaS, path-based for self-hoste…
betegon 1313877
refactor(init): remove add-example-trigger step (#357)
betegon 6bdb9ff
fix(init): reject unknown patch actions in both dry-run and real patc…
betegon 32cb8bd
fix(init): use "Error" spinner label for non-cancellation failures
betegon 4ab3d5f
Merge remote-tracking branch 'origin/main' into feat/init-command
betegon 61bdb09
fix(ci): restore working bun.lock to fix quansync peer dependency error
betegon 7abb381
fix(init): prevent double spinner stop and move precomputeDirListing …
betegon 08a8689
fix(init): add dry-run guard to createSentryProject
betegon cda7aef
fix(init): include applied patches in applyPatchset error responses
betegon 4d4f650
fix(init): surface API error details in project creation failures
betegon 2328b0f
Merge remote-tracking branch 'origin/main' into resolve-conflicts
betegon 320cf38
fix: reorder `&` metacharacter check after multi-char operators
betegon b5b8cec
Merge branch 'main' into feat/init-command
betegon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| --- | ||
| title: init | ||
| description: AI-powered project setup wizard for the Sentry CLI | ||
| --- | ||
|
|
||
| Set up Sentry in your project with an AI-powered wizard. The `init` command detects your platform and framework, installs the Sentry SDK, and instruments your code for error monitoring, tracing, and more. | ||
|
|
||
| **Prerequisites:** You must be authenticated first. Run `sentry auth login` if you haven't already. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```bash | ||
| sentry init [directory] | ||
| ``` | ||
|
|
||
| **Arguments:** | ||
|
|
||
| | Argument | Description | | ||
| |----------|-------------| | ||
| | `[directory]` | Project directory (default: current directory) | | ||
|
|
||
| **Options:** | ||
|
|
||
| | Option | Description | | ||
| |--------|-------------| | ||
| | `--force` | Continue even if Sentry is already installed | | ||
| | `-y, --yes` | Non-interactive mode (accept defaults) | | ||
| | `--dry-run` | Preview changes without applying them | | ||
| | `--features <list>` | Comma-separated features: `errors`, `tracing`, `logs`, `replay`, `metrics` | | ||
|
|
||
| ## Examples | ||
|
|
||
| ```bash | ||
| # Run the wizard in the current directory | ||
| sentry init | ||
|
|
||
| # Target a subdirectory | ||
| sentry init ./my-app | ||
|
|
||
| # Preview what changes would be made | ||
| sentry init --dry-run | ||
|
|
||
| # Select specific features | ||
| sentry init --features errors,tracing,logs | ||
|
|
||
| # Non-interactive mode (accept all defaults) | ||
| sentry init --yes | ||
| ``` | ||
|
|
||
| ## What the wizard does | ||
|
|
||
| 1. **Detects your framework** — scans your project files to identify the platform and framework | ||
| 2. **Installs the SDK** — adds the appropriate Sentry SDK package to your project | ||
| 3. **Instruments your code** — configures error monitoring, tracing, and any selected features | ||
|
|
||
| ## Supported platforms | ||
|
|
||
| The wizard currently supports: | ||
|
|
||
| - **JavaScript / TypeScript** — Next.js, Express, SvelteKit, React | ||
| - **Python** — Flask, FastAPI | ||
|
|
||
| More platforms and frameworks are coming soon. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,10 @@ | |
| "url": "git+https://github.com/getsentry/cli.git" | ||
| }, | ||
| "devDependencies": { | ||
| "@anthropic-ai/sdk": "^0.39.0", | ||
| "@biomejs/biome": "2.3.8", | ||
| "@clack/prompts": "^0.11.0", | ||
| "@mastra/client-js": "^1.4.0", | ||
| "@sentry/api": "^0.21.0", | ||
| "@sentry/bun": "10.39.0", | ||
| "@sentry/esbuild-plugin": "^2.23.0", | ||
|
|
@@ -27,6 +30,7 @@ | |
| "http-cache-semantics": "^4.2.0", | ||
| "ignore": "^7.0.5", | ||
| "marked": "^15", | ||
| "openai": "^6.22.0", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this? |
||
| "p-limit": "^7.2.0", | ||
| "pretty-ms": "^9.3.0", | ||
| "qrcode-terminal": "^0.12.0", | ||
|
|
@@ -66,6 +70,7 @@ | |
| "test:unit": "bun test --timeout 15000 test/lib test/commands test/types --coverage --coverage-reporter=lcov", | ||
| "test:isolated": "bun test --timeout 15000 test/isolated", | ||
| "test:e2e": "bun test --timeout 15000 test/e2e", | ||
| "test:init-eval": "bun test test/init-eval --timeout 600000 --concurrency 6", | ||
| "generate:skill": "bun run script/generate-skill.ts", | ||
| "check:skill": "bun run script/check-skill.ts", | ||
| "check:deps": "bun run script/check-no-deps.ts" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /** | ||
| * sentry init | ||
| * | ||
| * Initialize Sentry in a project using the remote wizard workflow. | ||
| * Communicates with the Mastra API via suspend/resume to perform | ||
| * local filesystem operations and interactive prompts. | ||
| */ | ||
|
|
||
| import path from "node:path"; | ||
| import type { SentryContext } from "../context.js"; | ||
| import { buildCommand } from "../lib/command.js"; | ||
| import { runWizard } from "../lib/init/wizard-runner.js"; | ||
|
|
||
| type InitFlags = { | ||
| readonly force: boolean; | ||
| readonly yes: boolean; | ||
| readonly "dry-run": boolean; | ||
| readonly features?: string; | ||
| }; | ||
|
|
||
| export const initCommand = buildCommand<InitFlags, [string?], SentryContext>({ | ||
| docs: { | ||
| brief: "Initialize Sentry in your project", | ||
| fullDescription: | ||
| "Runs the Sentry setup wizard to detect your project's framework, " + | ||
| "install the SDK, and configure error monitoring. Uses a remote " + | ||
| "workflow that coordinates local file operations through the CLI.", | ||
betegon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| parameters: { | ||
| positional: { | ||
| kind: "tuple", | ||
| parameters: [ | ||
| { | ||
| placeholder: "directory", | ||
| brief: "Project directory (default: current directory)", | ||
| parse: String, | ||
| optional: true, | ||
| }, | ||
| ], | ||
| }, | ||
| flags: { | ||
| force: { | ||
| kind: "boolean", | ||
| brief: "Continue even if Sentry is already installed", | ||
| default: false, | ||
| }, | ||
betegon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| yes: { | ||
| kind: "boolean", | ||
| brief: "Non-interactive mode (accept defaults)", | ||
| default: false, | ||
| }, | ||
| "dry-run": { | ||
| kind: "boolean", | ||
| brief: "Preview changes without applying them", | ||
| default: false, | ||
| }, | ||
| features: { | ||
| kind: "parsed", | ||
| parse: String, | ||
| brief: "Comma-separated features: errors,tracing,logs,replay,metrics", | ||
betegon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| optional: true, | ||
| placeholder: "list", | ||
| }, | ||
| }, | ||
| aliases: { | ||
| y: "yes", | ||
| }, | ||
| }, | ||
| async func(this: SentryContext, flags: InitFlags, directory?: string) { | ||
| const targetDir = directory ? path.resolve(this.cwd, directory) : this.cwd; | ||
| const featuresList = flags.features | ||
| ?.split(",") | ||
| .map((f) => f.trim()) | ||
| .filter(Boolean); | ||
|
|
||
| await runWizard({ | ||
| directory: targetDir, | ||
| force: flags.force, | ||
| yes: flags.yes, | ||
| dryRun: flags["dry-run"], | ||
| features: featuresList, | ||
| }); | ||
| }, | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /** | ||
| * Banner Formatting | ||
| * | ||
| * Standalone module for the Sentry ASCII banner. | ||
| * Extracted to avoid circular imports (wizard-runner → help → app → init → wizard-runner). | ||
| */ | ||
|
|
||
| import chalk from "chalk"; | ||
|
|
||
| /** ASCII art banner rows for gradient coloring */ | ||
| const BANNER_ROWS = [ | ||
| " ███████╗███████╗███╗ ██╗████████╗██████╗ ██╗ ██╗", | ||
| " ██╔════╝██╔════╝████╗ ██║╚══██╔══╝██╔══██╗╚██╗ ██╔╝", | ||
| " ███████╗█████╗ ██╔██╗ ██║ ██║ ██████╔╝ ╚████╔╝ ", | ||
| " ╚════██║██╔══╝ ██║╚██╗██║ ██║ ██╔══██╗ ╚██╔╝ ", | ||
| " ███████║███████╗██║ ╚████║ ██║ ██║ ██║ ██║ ", | ||
| " ╚══════╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ", | ||
| ]; | ||
|
|
||
| /** Purple gradient colors from bright to dark (Sentry brand-inspired) */ | ||
| const BANNER_GRADIENT = [ | ||
| "#B4A4DE", | ||
| "#9C84D4", | ||
| "#8468C8", | ||
| "#6C4EBA", | ||
| "#5538A8", | ||
| "#432B8A", | ||
| ]; | ||
|
|
||
| /** | ||
| * Format the banner with a vertical gradient effect. | ||
| * Each row gets progressively darker purple. | ||
| */ | ||
| export function formatBanner(): string { | ||
| return BANNER_ROWS.map((row, i) => { | ||
| const color = BANNER_GRADIENT[i] ?? "#B4A4DE"; | ||
| return chalk.hex(color)(row); | ||
| }).join("\n"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know I'm not a fan but why not Vercel AI SDK as I assume that's more established?