Dashboard › cli › Distillation
5cf4cf1f-f7c8-483e-a1c2-464ae3bb9add["lore_tm_v1_DAoH6cX6vwdjbdfHxW4fvcVrVbGjSMRAlhcsnbadnjQ","lore_tm_v1_quL4zhuGSXmMxrEHTRJpLDG8hx3hiAt-EFbw_GogDTI","lore_tm_v1_DLWNe0Afy0CEKSiAapH5pHRc3FZSmPJ_o6eoM84Kj10","lore_tm_v1_liXCmkclLR3MYiIHs5e-OZC7T0CLZ4S7RIF-6OhMpgo","lore_tm_v1_nEqijMs38MHyUFveLfmtbCmZVGGAVnHeRLwgh5qMgwc","lore_tm_v1_XLU9ERBKYbLzN-ruIo7cfvLoYTK642sbzq01iiu5lgQ"]
packages/cli/src/lib/command.ts defines all command functions as async generators: non-streaming commands yield one CommandOutput<T> and may return { hint }; streaming yields render immediately, but --json commands must yield one aggregate value when callers require a single parseable JSON document because individual chunks are pretty-printed rather than JSONL; void commands return without yielding. Hints live exclusively on the generator return value—never on individual yields.LocalCommandBuilderArguments in packages/cli/src/lib/command.ts supports output?: OutputConfig<any>, auth?: boolean | "dsn", and skipRcUrlCheck?: boolean; auth defaults to requiring credentials, auth: false opts out, and auth: "dsn" bypasses both Bearer-token guarding and the .sentryclirc URL trust check.buildCommand() treats credentials as present when either a token or refresh token exists in the DB or environment; expired tokens with a valid refresh token pass the guard for silent API-client refresh. Missing credentials produce AuthError("not_authenticated"), which the auto-auth middleware in cli.ts can turn into login flow.LOG_LEVEL_FLAG is hidden, optional, accepts LOG_LEVEL_NAMES, and is injected into every command as --log-level; VERBOSE_FLAG is hidden, defaults to false, and makes --verbose equivalent to --log-level debug. --log-level takes priority over --verbose.LOG_LEVEL_KEY = "log-level" is the injected flag key and is always stripped. ALWAYS_STRIP = new Set([LOG_LEVEL_KEY]) identifies flags that are always stripped—the command never sees them.JSON_FLAG is a boolean --json flag with default false; FIELDS_FLAG is a parsed --fields flag accepting comma-separated dot-notation field paths. Its raw value is pre-parsed by the wrapper into string[], is silently ignored unless JSON output is active, and commands type it as fields?: string[], not string.mergeGlobalFlags() in packages/cli/src/lib/command.ts injects missing global flags from GLOBAL_FLAG_DEFAULTS: log-level, verbose, org, and project; injected keys are added to stripKeys, while command-owned flags are preserved and passed to the command.mergeGlobalFlags() injects --json only if the command does not own a json flag, while --fields is always injected when output: { human: ... } is configured.-v → --verbose are derived from shared GLOBAL_FLAGS and injected unless the command owns the corresponding long flag or the short alias already exists.--org and --project are injected into commands for recovery from older sentry-cli syntax commonly generated by LLMs. applyOrgProjectFlags() trims and writes them to SENTRY_ORG and SENTRY_PROJECT, overriding existing environment values because explicit CLI flags have highest-priority intent; empty or whitespace-only values are ignored.--org or --project flags retain ownership: those values are passed through to func() and are not mapped by applyOrgProjectFlags() into compatibility environment variables.buildFieldsFlag() enriches the --fields brief with Available: ${fieldNames} when outputConfig.schema yields schema fields; enrichDocsWithSchema() appends formatSchemaForHelp(schemaFields) to fullDescription, using docs.fullDescription ?? docs.brief as the base.handleYieldedValue() ignores void, undefined, Error, and other non-CommandOutput values. A ClearScreen token sets deferred pendingClear only outside plain and JSON modes; the next render receives clearPrefix: "\x1b[H\x1b[J", after which pendingClear resets.cleanRawFlags() removes every key in stripKeys before invoking the original command and converts fields from a string to parseFieldsList(clean.fields) whenever output configuration is active.writeFinalization() suppresses all finalization in JSON mode; otherwise it prefers renderer.finalize(hint) and writes nonempty returned text, falling back to writeFooter(stdout, hint) when no renderer finalizer exists.buildCommand() enables environment-driven JSON output for library invocation: when output configuration exists, the parsed command did not request JSON, and context env.SENTRY_OUTPUT_FORMAT === "json", it sets cleanFlags.json = true.json, yes, or "dry-run" is exactly true; this parsed-flag check avoids confusing aliases such as list command -n for limit with init command -n for dry-run.pendingClear, traces core execution as withTracing("exec", "cli.command.exec", ...), and traces finalization as withTracing("render", "cli.command.render", ...).buildCommand() uses manual .next() calls rather than for await...of so the wrapper can capture the done: true return value containing CommandReturn.hint.finalHint = returned ? appendCacheHint(returned.hint) : undefined, automatically adding cache-age messaging such as “cached · 3m ago · use -f to refresh”; bare return; paths such as --web produce no footer.OutputError handling renders non-null/non-undefined err.data through new CommandOutput(err.data) and the normal output system, then rethrows the same error so bin.ts and index.ts can propagate its exit code.maybeRecoverWithHelp() treats positional values "help", "--h", or "-help" as likely help intent only after a command throws a CliError; it excludes OutputError, requires ctx.commandPrefix, dynamically imports introspectCommand and formatHelpHuman from ./help.js, prints a Tip: use --help warning to stderr, and writes formatted help to stdout.CliError subclasses—including AuthError, ResolutionError, ValidationError, and ContextError—but only on failure, so a successful command using a legitimate resource named "help" never triggers the recovery path.try block so an invocation such as sentry issue list help can recover to command help instead of triggering authentication flow before help recovery..sentryclirc trust validation is deferred until command execution and invokes dynamically imported assertRcUrlTrusted(this.cwd) unless skipRcUrlCheck is enabled or authentication mode is "dsn".buildCommand() attaches outputConfig.schema to the built command as non-standard __jsonSchema metadata and exposes the original unwrapped generator as __rawFunc for internal dispatchers such as bare sentry auth, avoiding re-entry into telemetry, authentication, rc-trust, and output pipelines.packages/cli/src/lib/introspect.ts defines extractPositionals(): tuple entries preserve placeholder, brief, and optional (default false), while array positionals become one optional entry whose placeholder ends in ..., defaulting to args....extractFlags() in packages/cli/src/lib/introspect.ts normalizes each flag’s name, brief, kind, default, optional, variadic, and hidden; boolean flags default to optional, while variadic and hidden default to false.resolveCommandPath() returns command, group, unresolved, or null results; unresolved path segments receive up to MAX_SUGGESTIONS = 3 suggestions from fuzzyMatch(), and nested recursion rewrites command paths by replacing the leading sentry prefix with the accumulated parent route.packages/cli/src/commands/help.ts defines unauthenticated helpCommand with output: { human: formatHelpHuman }, an array positional placeholder command, and no command-owned flags.helpCommand behavior is: sentry help or bare sentry yields new CommandOutput(introspectAllCommands()); sentry help <command> yields structured introspectCommand(commandPath) output; unresolved/error results are thrown as OutputError(result) so they render through the output system and exit nonzero.formatHelpHuman; sentry help --json never triggers the sixel probe or any terminal banner I/O that JSON output would discard.