Dashboard › cli › Distillation
8606c387-5f5e-4181-a5d2-d3959f79088a["lore_tm_v1_NqTGFQac3Qu0dY7gBLjE7Br44CWrErEgs84kQ8uXIeA","lore_tm_v1_iCkL-q3iXF-nSuF8D1Bo8p85EmbBRTHvqfgFPAONgP4"]
packages/cli/src/lib/introspect.ts is 496 lines and provides shared Stricli route-tree introspection for runtime sentry help --json and build-time generate-skill.ts.packages/cli/src/lib/introspect.ts defines simplified introspection types because @stricli/core types require complex CommandContext generics and do not export internals such as RouteMapEntry or FlagParameter: RouteMapEntry, RouteTarget, RouteMap, Command, PositionalParams, PositionalParam, PositionalInfo, FlagDef, CommandInfo, FlagInfo, RouteInfo, ResolvedPath, and UnresolvedPath.Command type supports non-standard metadata __jsonSchema?: import("valibot").GenericSchema, __primaryUsage?: string, and __examples?: readonly CommandExample[]; CommandInfo contains path, brief, optional fullDescription, flags, positional, structured positionals, aliases, examples, and optional jsonFields.isRouteMap(target) accepts unknown and identifies objects containing getAllEntries; isCommand(target) accepts unknown and identifies objects containing parameters but not getAllEntries.getPositionalString() formats tuple positionals as required <placeholder> or optional [<placeholder>], falling back to arg${i}; array positionals become <placeholder...>, falling back to <args...>.extractPositionals() maps tuple parameters to { placeholder, brief, optional }, using arg${i}, an empty brief, and false as defaults; array parameters produce one optional entry whose placeholder ends in ..., with args... as the fallback.extractFlags() normalizes each flag into FlagInfo; missing briefs become "", missing variadic/hidden become false, and missing optional defaults to whether kind === "boolean".buildCommandInfo() extracts JSON fields with extractSchemaFields(cmd.__jsonSchema), prefers cmd.__primaryUsage over generated positional syntax, and prefers canonical cmd.__examples over externally supplied examples. Canonical examples are rendered as # ${description}\n${command}.extractRouteGroupCommands() recursively walks visible nested route maps, constructs paths beginning with sentry, loads optional examples from Map<string, string[]>, and omits hidden entries.extractAllRoutes() preserves route-tree iteration order, omits hidden top-level entries, returns groups with recursively extracted commands, and represents standalone commands as a route containing one CommandInfo.resolveCommandPath() returns null for an empty path, resolves either a command or group recursively, and returns UnresolvedPath when a segment is unmatched. Suggestions use fuzzyMatch(input, names, { maxResults: MAX_SUGGESTIONS }), where MAX_SUGGESTIONS is 3, and only visible entries are candidates.resolveCommandPath() prepends parent segments by replacing the leading /^sentry / prefix; nested group names are also prefixed. Supplying additional segments after reaching a command returns null.packages/cli/script/generate-command-docs.ts is a 471-line tsx script that generates docs/src/content/docs/commands/{route}.md, docs/src/content/docs/commands/index.md, and docs/src/content/docs/configuration.md.generate-command-docs.ts checks for src/generated/skill-content.ts; if absent, it creates src/generated/ and writes the exact stub export const SKILL_FILES: [string, string][] = [];\n. This avoids failure from the transitive agent-skills.ts → skill-content.ts import on fresh checkouts or CI; generate:skill later overwrites the stub.docs/src/fragments/commands/; generated content is separated from preserved custom content by <!-- GENERATED:END -->.GLOBAL_FLAG_NAMES in generate-command-docs.ts contains "json", "fields", "help", "helpAll", and "log-level"; these and hidden flags are excluded from per-command option tables. SKIP_ROUTES contains "help".formatFlagRow() renders aliases as -q, --query, adds <flag-name> for non-variadic parsed/enum flags and <flag-name>... for variadic flags, and appends (default: ${JSON.stringify(flag.default)}) only for non-boolean defaults whose brief does not already include "default:".formatPositionalsTable() renders an Arguments markdown table, uses <placeholder> for required and [<placeholder>] for optional positionals, and escapes </> in descriptions to </>.generateCommandSection() emits a level-three heading containing the command path plus positional signature, the command brief, optional argument and options tables, and examples formatted by formatCommandExamples(cmd.examples).isStandaloneCommand() considers a route standalone only when it has exactly one command whose path equals sentry ${route.name}.generatePage() emits YAML frontmatter, a singular or plural description ("${Capitalize(name)} command(s) for the Sentry CLI"), the route brief, ## Usage for standalone commands or ## Commands for groups, all command sections, and the footer: All commands support \--json` for machine-readable output and `--fields` to select specific JSON fields.`capitalize() uppercases the known acronyms "api" and "cli" completely; other route names receive an uppercase first character.generateCommandsTable() preserves the route order returned by extractAllRoutes() and creates rows in the form | [`route`](./route/) | brief |.generateConfigurationPage() generates frontmatter, an intro explaining config files/environment variables/local database and sentry auth login, an ## Environment Variables section, and one ### \VAR_NAME`section perEnvVarEntry; entries with examples include a bash block containing export ${entry.name}=${entry.example}`.readCustomContent() reads docs/src/fragments/commands/${fragmentName}.md, while readTopLevelFragment() reads docs/src/fragments/${fragmentName}.md; both currently catch every read error and return "" without logging.mkdirSync(DOCS_DIR, { recursive: true }), then removes the legacy docs/src/content/docs/commands/cli/ directory using rmSync(..., { recursive: true, force: true }); that cleanup is wrapped in a catch that only contains the comment Directory may not exist.${DOCS_DIR}/${route.name}.md; custom fragment content is concatenated directly after generated content when present, otherwise one trailing newline is added. The command index and configuration page follow the same generated-plus-fragment pattern.Commands, description Available commands in the Sentry CLI, intro The Sentry CLI provides commands for interacting with various Sentry resources., and section heading ## Available Commands.generate-command-docs.ts logs the exact shape Generated ${generatedFiles.length} command doc pages + ${INDEX_PATH} + ${CONFIG_PATH}.