Dashboard › cli › Distillation
8b851732-dcbe-4b2e-a333-1aa32f052adb["lore_tm_v1_V22iXvy_RLZeF7rNuFiAbEl9gFSzuTNks_kxUmm0cKc","lore_tm_v1_xuiTEBAtX5iTMAJ_aBsBglZkIPr1JVR1c3gQeaQYXy8"]
Date: Sep 9, 2026
/home/byk/Code/getsentry/cli-pr-1558/packages/cli/script/generate-skill.ts generates 4 artifact categories: compact plugins/sentry-cli/skills/sentry-cli/SKILL.md, full per-route plugins/sentry-cli/skills/sentry-cli/references/*.md, discovery manifest docs/public/.well-known/skills/index.json, and embedded binary content in src/generated/skill-content.ts.generate-skill.ts bootstraps src/generated/skill-content.ts before dynamically importing ../src/app.js; when absent, it creates src/generated/ recursively and writes the exact stub export const SKILL_FILES: ReadonlyMap<string, string> = new Map();\n, avoiding the app.ts β agent-skills.ts β skill-content.ts fresh-checkout module-resolution failure.generate-skill.ts imports marked and Token; shared helpers extractCommandPathFromHeading, formatCommandExamples, and matchExampleToCommand from ./generate-skill-markdown.js; DOCS_CONTENT and DOCS_PUBLIC from ./paths.js; and introspection artifacts CommandInfo, FlagInfo, RouteInfo, RouteMap, buildCommandInfo, extractRouteGroupCommands, isCommand, and isRouteMap.findDefaultCommandName(routeMap) returns undefined when there is no configured/default command, otherwise finds the matching entry in routeMap.getAllEntries() and returns its original name. It special-cases a hidden command named default to return login, mapping bare sentry auth examples to sentry auth login.generate-skill.ts constants are SKILL_DIR = "plugins/sentry-cli/skills/sentry-cli", OUTPUT_PATH = ${SKILL_DIR}/SKILL.md, REFERENCES_DIR = ${SKILL_DIR}/references, INDEX_JSON_PATH = ${DOCS_PUBLIC}/.well-known/skills/index.json, and DOCS_PATH = DOCS_CONTENT.getPackageVersion() reads package.json as UTF-8, parses its JSON, and returns pkg.version for generated YAML frontmatter.generate-skill.ts uses exact patterns FRONTMATTER_REGEX = /^---\n[\s\S]*?\n---\n/, CODE_BLOCK_REGEX = /```(\w*)\n([\s\S]*?)```/g, and PACKAGE_MANAGER_REGEX = /<PackageManagerCode[\s\S]*?npm="([^"]+)"/.SKILL_DESCRIPTION is exactly Guide for using the Sentry CLI to interact with Sentry from the command line. Use when the user asks about viewing issues, events, projects, organizations, making API calls, or authenticating with Sentry via CLI.; it is reused in SKILL.md frontmatter and index.json.SKILL.md route order is ["help", "auth", "org", "project", "issue", "event", "api"]. sortRoutes() assigns unlisted routes order 999; its comparator preserves their existing relative order rather than explicitly alphabetizing them, despite the nearby comment saying they appear alphabetically.generate-skill.ts omits globally injected flags from compact/per-command flag detail through GLOBAL_FLAG_NAMES = new Set(["json", "fields", "help", "helpAll", "log-level"]).stripFrontmatter() removes only matching leading YAML frontmatter. stripMdxComponents() removes single-line import and export statements, self-closing capitalized JSX components, paired capitalized JSX components and their contents, collapses 3 or more newlines to 2, and trims the result.extractSection(markdown, heading) locates a level-1-through-level-6 heading using escaped literal heading text, then returns trimmed content until the next heading of equal or higher rank; escapeRegex() escapes regex-special characters with \\$&.extractCodeBlocks(markdown, language?) clones CODE_BLOCK_REGEX, returns ordered { code, lang } entries with trimmed code, treats an omitted language as "", and optionally filters by exact language equality.loadDoc(relativePath) resolves under DOCS_PATH, tests existence with access(), returns null when absent, and otherwise reads UTF-8 content and applies stripFrontmatter() followed by stripMdxComponents().extractPackageManagerCommand(rawContent) extracts the npm="..." value from a potentially multiline <PackageManagerCode> component, returning null if unmatched.generateInstallSection(installSection, rawContent) emits ### Installation; combines every Bash block from the install section into one Bash fence; adds the extracted package-manager npm command; and, when both sources exist, separates that command with a blank line and # Or install via npm/pnpm/bun.generateAuthSection(authSection) emits ### Authentication and combines all Bash blocks from that section into one Bash fence.loadPrerequisites() reads docs/src/content/docs/getting-started.mdx; if present, it emits ## Prerequisites, states that the CLI must be installed and authenticated, derives installation from the Install Script section and authentication from the Authentication section, and otherwise falls back to getDefaultPrerequisites().curl https://cli.sentry.dev/install -fsS | bash or npm install -g sentry; authentication examples are sentry auth for recommended OAuth login, sentry auth --token YOUR_SENTRY_API_TOKEN for an API token, and sentry auth status to check status.appendExample(map, key, code) appends code to the existing string array or creates a new one. collectCommandPaths(tokens, examples) recognizes only depth-3 heading tokens accepted by extractCommandPathFromHeading(), preserves their order, and initializes each discovered command path in the examples map.associateCodeBlocks() walks marked tokens sequentially, updates heading context only on depth-3 headings, considers only exact bash code tokens, and associates each trimmed block either with the current recognized command or through matchExampleToCommand(code, commandPaths, groupFallback, defaultCommandPath), where groupFallback is sentry ${commandGroup}.loadCommandExamples(commandGroup, defaultCommandName?) loads commands/${commandGroup}.md, returns an empty Map if absent, tokenizes with marked.lexer(), collects command headings, constructs optional default path sentry ${commandGroup} ${defaultCommandName}, and associates generated-reference and hand-written examples by heading context or command-content matching.loadCommandsOverview() reads commands/index.md and returns Global Options, JSON Output, and Opening in Browser section bodies as globalOptions, jsonOutput, and webFlag, substituting "" for missing sections; it returns null if the page is absent.loadAgentGuidance() loads docs/src/content/docs/agent-guidance.md via loadDoc(), thereby returning content with frontmatter and MDX components removed.extractRoutes(routeMap) skips hidden top-level entries, loads each visible routeβs documentation examples, detects a route-map default command through findDefaultCommandName(), uses extractRouteGroupCommands(target, routeName, docExamples) for groups, and uses buildCommandInfo(target, \sentry ${routeName}`, examples)` for standalone commands.formatFlag(flag, aliases) uses the first alias whose target equals flag.name, renders -x, --name when present, adds <value> for non-variadic parsed/enum flags or <value>... for variadic flags, appends the brief, and appends (default: ${JSON.stringify(flag.default)}) for every defined non-boolean default.getVisibleFlags(cmd) filters out flags that are hidden or whose names occur in GLOBAL_FLAG_NAMES.generateFullCommandDoc(cmd) emits a depth-3 backticked signature including cmd.positional when present, the command brief, a **Flags:** bullet list of visible flags, optional JSON field documentation, and canonical examples from formatCommandExamples(cmd.examples).generateFullCommandDoc() says **JSON Fields** (use \--json --fields` to select specific fields):, then renders Field, Type, and Descriptioncolumns; pipe characters in field types and descriptions are escaped as|, missing descriptions become ""`.TITLE_ACRONYMS = new Set(["api", "cli"]), rendering API and CLI; other names receive uppercase first character plus the unchanged remainder.generateReferenceFile(refName, groupRoutes, version) assumes groupRoutes[0], derives title ${capitalize(refName)} Commands and description from route.brief, and emits frontmatter with name: sentry-cli-${refName}, package version, route description, requires.bins: ["sentry"], and requires.auth: true.All commands also support \--json`, `--fields`, `--help`, `--log-level`, and `--verbose` flags.`generateCompactCommandLine(cmd) renders - \${signature}` β ${cmd.brief}without flags or examples.generateCompactCommandsSection()emits## Command Reference, skips the helproute, includes each routeβs capitalized heading, brief, ordered command list, and pointerβ Full flags and examples: `references/${refFile}``.generateSupplementarySections() copies Global Options, JSON Output, and Opening in Browser content from commands/index.md when present. Its JSON fallback says most commands support --json; its browser fallback says view commands support -w or --web.groupRoutesByReference(routeInfos) implements a 1:1 route-to-reference mapping, skips help, and maps each remaining route name to a single-element RouteInfo[], eliminating a manual mapping that could go stale.generateAllSkillFiles(routeMap) reads the package version, extracts routes and documentation examples, loads prerequisites/supplementary content/agent guidance, creates ${route}.md reference files, and stores generated content in a Map<string, string> keyed by relative paths.SKILL.md frontmatter uses name: sentry-cli, the package version, SKILL_DESCRIPTION, requires.bins: ["sentry"], and requires.auth: true; its title is # Sentry CLI Usage Guide and intro is Help users interact with Sentry from the command line using the \sentry` CLI.`SKILL.md includes the exact core agent rule to βjust run the commandβ: the CLI auto-detects org/project from .sentryclirc, DSNs in .env/source, and the directory name; agents should not list organizations and projects manually, and should pass explicit <org>/<project> only if detection fails or selects the wrong target.generateAllSkillFiles() adds ## Agent Guidance and nests its headings by one level using /^(#{2,6})\s/gm, transforming each matched heading prefix by prepending one #.generateIndexJson(generatedFiles) sorts SKILL.md first and all other paths via localeCompare(), then writes pretty-printed JSON with a trailing newline and one skill containing name: "sentry-cli", SKILL_DESCRIPTION, and the complete sorted file list.generate-skill.ts main routine calls generateAllSkillFiles(routes as unknown as RouteMap), removes plugins/sentry-cli/skills/sentry-cli/references recursively with force: true to eliminate stale files, creates parent directories recursively, and writes every generated skill file.docs/public/.well-known/skills/index.json after recursively creating its parent directory.src/generated/skill-content.ts, the script sorts all generated-file entries by relative path, escapes backslashes, backticks, and ${ inside each file body, and emits each as ["${path}", \${escaped}`]inexport const SKILL_FILES: ReadonlyMap<string, string> = new Map([...])`.src/generated/skill-content.ts includes an auto-generated/do-not-edit header and documents SKILL_FILES as a map of relative path to file content, embedding all skill files into the binary so agent-skills.ts can install them without network fetching.generate-skill.ts counts keys beginning with references/ and logs Generated ${OUTPUT_PATH} + ${refCount} reference files + ${INDEX_JSON_PATH} + ${SKILL_CONTENT_PATH}.