@@ -60,6 +60,34 @@ import {
6060 isRouteMap ,
6161} from "../src/lib/introspect.js" ;
6262
63+ /**
64+ * Resolve the default subcommand name for a route map, if configured.
65+ *
66+ * Hidden dispatcher routes (e.g. auth's `default`) map bare group examples
67+ * onto the user-facing command they primarily document (login).
68+ */
69+ function findDefaultCommandName ( routeMap : RouteMap ) : string | undefined {
70+ if ( ! routeMap . getDefaultCommand ) {
71+ return ;
72+ }
73+ const defaultCmd = routeMap . getDefaultCommand ( ) ;
74+ if ( ! defaultCmd ) {
75+ return ;
76+ }
77+ for ( const sub of routeMap . getAllEntries ( ) ) {
78+ if ( sub . target === defaultCmd ) {
79+ const name = sub . name . original ;
80+ // Auth uses a hidden "default" dispatcher; bare `sentry auth` examples
81+ // document the login path.
82+ if ( name === "default" ) {
83+ return "login" ;
84+ }
85+ return name ;
86+ }
87+ }
88+ return ;
89+ }
90+
6391const SKILL_DIR = "plugins/sentry-cli/skills/sentry-cli" ;
6492const OUTPUT_PATH = `${ SKILL_DIR } /SKILL.md` ;
6593const REFERENCES_DIR = `${ SKILL_DIR } /references` ;
@@ -290,10 +318,10 @@ npm install -g sentry
290318
291319\`\`\`bash
292320# OAuth login (recommended)
293- sentry auth login
321+ sentry auth
294322
295323# Or use an API token
296- sentry auth login --token YOUR_SENTRY_API_TOKEN
324+ sentry auth --token YOUR_SENTRY_API_TOKEN
297325
298326# Check auth status
299327sentry auth status
@@ -341,10 +369,14 @@ function collectCommandPaths(
341369 */
342370function associateCodeBlocks (
343371 tokens : Token [ ] ,
344- commandPaths : string [ ] ,
345- commandGroup : string ,
346- examples : Map < string , string [ ] >
372+ context : {
373+ commandPaths : string [ ] ;
374+ commandGroup : string ;
375+ examples : Map < string , string [ ] > ;
376+ defaultCommandPath ?: string ;
377+ }
347378) : void {
379+ const { commandPaths, commandGroup, examples, defaultCommandPath } = context ;
348380 const groupFallback = `sentry ${ commandGroup } ` ;
349381 let currentCmd : string | null = null ;
350382
@@ -359,7 +391,12 @@ function associateCodeBlocks(
359391 if ( currentCmd && examples . has ( currentCmd ) ) {
360392 appendExample ( examples , currentCmd , code ) ;
361393 } else {
362- const target = matchExampleToCommand ( code , commandPaths , groupFallback ) ;
394+ const target = matchExampleToCommand (
395+ code ,
396+ commandPaths ,
397+ groupFallback ,
398+ defaultCommandPath
399+ ) ;
363400 if ( target ) {
364401 appendExample ( examples , target , code ) ;
365402 }
@@ -377,7 +414,8 @@ function associateCodeBlocks(
377414 * by matching code blocks to commands via heading context or content analysis.
378415 */
379416async function loadCommandExamples (
380- commandGroup : string
417+ commandGroup : string ,
418+ defaultCommandName ?: string
381419) : Promise < Map < string , string [ ] > > {
382420 const docContent = await loadDoc ( `commands/${ commandGroup } .md` ) ;
383421 if ( ! docContent ) {
@@ -387,7 +425,15 @@ async function loadCommandExamples(
387425 const tokens = marked . lexer ( docContent ) ;
388426 const examples = new Map < string , string [ ] > ( ) ;
389427 const commandPaths = collectCommandPaths ( tokens , examples ) ;
390- associateCodeBlocks ( tokens , commandPaths , commandGroup , examples ) ;
428+ const defaultCommandPath = defaultCommandName
429+ ? `sentry ${ commandGroup } ${ defaultCommandName } `
430+ : undefined ;
431+ associateCodeBlocks ( tokens , {
432+ commandPaths,
433+ commandGroup,
434+ examples,
435+ defaultCommandPath,
436+ } ) ;
391437 return examples ;
392438}
393439
@@ -435,7 +481,13 @@ async function extractRoutes(routeMap: RouteMap): Promise<RouteInfo[]> {
435481 }
436482 const routeName = entry . name . original ;
437483 const target = entry . target ;
438- const docExamples = await loadCommandExamples ( routeName ) ;
484+ const defaultCommandName = isRouteMap ( target )
485+ ? findDefaultCommandName ( target )
486+ : undefined ;
487+ const docExamples = await loadCommandExamples (
488+ routeName ,
489+ defaultCommandName
490+ ) ;
439491 if ( isRouteMap ( target ) ) {
440492 result . push ( {
441493 name : routeName ,
0 commit comments