Dashboard › cli › Distillation
66a578a1-9477-4a66-a34d-d18856315495["lore_tm_v1_Cs2XY087u0znIATYbUOZ7CkBVXeLdk5bd5TPxXqUM44"]
packages/cli/src/lib/help.ts:347-358, introspectAllCommands() casts routes to RouteMap and returns { routes: extractAllRoutes(routeMap), envVars: buildTopLevelEnvVars(), flags: buildCommonFlags() }; its documented contract is all visible routes with all flags plus top-level environment variables and common CLI flags.packages/cli/src/lib/help.ts:365-381, introspectCommand(commandPath) resolves a command/group with resolveCommandPath(routeMap, commandPath). A missing resolution returns { error: \Command not found: ${commandPath.join(" ")}` }; an "unresolved"result returns the same error plussuggestionsonly whensuggestions.length > 0; a successful resolution returns resolved.info`.packages/cli/src/lib/help.ts:406-428, renderJsonHelp(prefix, unprocessedInputs) calls parseHelpJsonFlags(unprocessedInputs) to obtain { hasJson, fields, extraPath } and returns undefined immediately when hasJson is false.renderJsonHelp() constructs commandPath as [...prefix.slice(1), ...extraPath], dropping the app name from prefix and retaining unrouted non-flag tokens such as nope from sentry issue nope --help --json; this allows introspectCommand() to emit an unknown-command { error } rather than silently showing the parent group.renderJsonHelp() uses introspectAllCommands() when commandPath.length === 0, otherwise introspectCommand(commandPath); when nonempty fields were supplied it applies filterFields(data, fields), then returns ${formatJson(final)}\n with a trailing newline.packages/cli/src/lib/help.ts:447-457, isVersionRequest(argv) scans raw arguments in order: it returns false upon reaching --, returns true upon finding --version before that separator, and otherwise returns false.isVersionRequest() intentionally excludes -v because GLOBAL_FLAGS maps -v to --verbose, consistent with the scanner patch removing Stricliβs -v version alias; tokens after -- are treated as wrapped-command arguments and ignored.isVersionRequest() exists as post-run recovery for scanner behavior where versionRequested is only set if the patched scanner consumes --version; for example, sentry cli nope --version can abort as UnknownCommand before consuming the version flag, while legacy behavior expects any bare --version before -- to print the version.packages/cli/src/lib/help.ts:472-478, isRecoverableUnknownCommand(argv) returns true for exactly three recovery shapes: isVersionRequest(argv), a defined result from rewriteHelpJsonToHelpCommand(argv), or argv.length >= 2 && argv.at(-1) === "help".unknown_command telemetry event to avoid noise from help/version requests, including sentry cli nope --help --json, whose final token is --json rather than help.packages/cli/src/lib/help.ts:500-519, rewriteHelpJsonToHelpCommand(argv) scans only until -- for --help or its -h alias, while parseHelpJsonFlags(argv) supplies { hasJson, fields, extraPath }; it returns undefined unless both help and JSON flags occur before the escape separator.rewriteHelpJsonToHelpCommand() rewrites a qualifying request to ["help", "--json", ...extraPath]; when fields is nonempty, it appends "--fields" and fields.join(",").rewriteHelpJsonToHelpCommand() is a post-run fallback for unknown route tokens in groups without default commands, where the scanner fails before renderHelp runs. Re-dispatching the rewritten arguments through the help command produces structured unknown-command { error } JSON and preserves --fields, matching the prior pre-scanner behavior.