@@ -17,44 +17,51 @@ import {
1717 type RepoPRState ,
1818} from 'sentry/views/seerExplorer/types' ;
1919
20- export function artifactToMarkdown ( artifact : AutofixArtifact ) : string | null {
20+ export function artifactToMarkdown (
21+ artifact : AutofixArtifact ,
22+ headingLevel : 1 | 2 | 3 = 1
23+ ) : string | null {
2124 if ( isRootCauseArtifact ( artifact ) ) {
22- return rootCauseArtifactToMarkdown ( artifact ) ;
25+ return rootCauseArtifactToMarkdown ( artifact , headingLevel ) ;
2326 }
2427
2528 if ( isSolutionArtifact ( artifact ) ) {
26- return solutionArtifactToMarkdown ( artifact ) ;
29+ return solutionArtifactToMarkdown ( artifact , headingLevel ) ;
2730 }
2831
2932 if ( isCodeChangesArtifact ( artifact ) ) {
30- return filePatchesToMarkdown ( artifact ) ;
33+ return filePatchesToMarkdown ( artifact , headingLevel ) ;
3134 }
3235
3336 if ( isPullRequestsArtifact ( artifact ) ) {
34- return repoPRStatesToMarkdown ( artifact ) ;
37+ return repoPRStatesToMarkdown ( artifact , headingLevel ) ;
3538 }
3639
3740 if ( isCodingAgentsArtifact ( artifact ) ) {
38- return codingAgentsToMarkdown ( artifact ) ;
41+ return codingAgentsToMarkdown ( artifact , headingLevel ) ;
3942 }
4043
4144 return null ; // unknown artifact
4245}
4346
4447function rootCauseArtifactToMarkdown (
45- artifact : Artifact < RootCauseArtifact >
48+ artifact : Artifact < RootCauseArtifact > ,
49+ headingLevel : number
4650) : string | null {
4751 const rootCause = artifact . data ;
4852 if ( ! defined ( rootCause ) ) {
4953 return null ;
5054 }
5155
52- const parts : string [ ] = [ '# Root Cause' , '' , rootCause . one_line_description ] ;
56+ const h1 = '#' . repeat ( headingLevel ) ;
57+ const h2 = '#' . repeat ( headingLevel + 1 ) ;
58+
59+ const parts : string [ ] = [ `${ h1 } Root Cause` , '' , rootCause . one_line_description ] ;
5360
5461 if ( rootCause . five_whys . length ) {
5562 parts . push (
5663 '' ,
57- '## Why did this happen?' ,
64+ ` ${ h2 } Why did this happen?` ,
5865 '' ,
5966 ...rootCause . five_whys . map ( why => `- ${ why } ` )
6067 ) ;
@@ -63,7 +70,7 @@ function rootCauseArtifactToMarkdown(
6370 if ( rootCause . reproduction_steps ?. length ) {
6471 parts . push (
6572 '' ,
66- '## Reproduction Steps' ,
73+ ` ${ h2 } Reproduction Steps` ,
6774 '' ,
6875 ...rootCause . reproduction_steps . map ( ( step , index ) => `${ index + 1 } . ${ step } ` )
6976 ) ;
@@ -72,21 +79,28 @@ function rootCauseArtifactToMarkdown(
7279 return parts . join ( '\n' ) ;
7380}
7481
75- function solutionArtifactToMarkdown ( artifact : Artifact < SolutionArtifact > ) : string | null {
82+ function solutionArtifactToMarkdown (
83+ artifact : Artifact < SolutionArtifact > ,
84+ headingLevel : number
85+ ) : string | null {
7686 const solution = artifact . data ;
7787 if ( ! defined ( solution ) ) {
7888 return null ;
7989 }
8090
81- const parts : string [ ] = [ '# Plan' , '' , solution . one_line_summary ] ;
91+ const h1 = '#' . repeat ( headingLevel ) ;
92+ const h2 = '#' . repeat ( headingLevel + 1 ) ;
93+ const h3 = '#' . repeat ( headingLevel + 2 ) ;
94+
95+ const parts : string [ ] = [ `${ h1 } Plan` , '' , solution . one_line_summary ] ;
8296
8397 if ( solution . steps . length ) {
8498 parts . push (
8599 '' ,
86- '## Steps to Resolve' ,
100+ ` ${ h2 } Steps to Resolve` ,
87101 '' ,
88102 ...solution . steps . flatMap ( ( step , index ) => [
89- `### ${ index + 1 } . ${ step . title } ` ,
103+ `${ h3 } ${ index + 1 } . ${ step . title } ` ,
90104 step . description ,
91105 ] )
92106 ) ;
@@ -95,17 +109,23 @@ function solutionArtifactToMarkdown(artifact: Artifact<SolutionArtifact>): strin
95109 return parts . join ( '\n' ) ;
96110}
97111
98- function filePatchesToMarkdown ( artifact : ExplorerFilePatch [ ] ) : string | null {
112+ function filePatchesToMarkdown (
113+ artifact : ExplorerFilePatch [ ] ,
114+ headingLevel : number
115+ ) : string | null {
99116 if ( ! artifact . length ) {
100117 return null ;
101118 }
102119
103- const parts : string [ ] = [ '# Code Changes' ] ;
120+ const h1 = '#' . repeat ( headingLevel ) ;
121+ const h2 = '#' . repeat ( headingLevel + 1 ) ;
122+
123+ const parts : string [ ] = [ `${ h1 } Code Changes` ] ;
104124
105125 parts . push (
106126 ...artifact . flatMap ( filePatch => [
107127 '' ,
108- `## Repository: ${ filePatch . repo_name } ` ,
128+ `${ h2 } Repository: ${ filePatch . repo_name } ` ,
109129 '' ,
110130 '```diff' ,
111131 filePatch . diff ,
@@ -116,12 +136,17 @@ function filePatchesToMarkdown(artifact: ExplorerFilePatch[]): string | null {
116136 return parts . join ( '\n' ) ;
117137}
118138
119- function repoPRStatesToMarkdown ( artifact : RepoPRState [ ] ) : string | null {
139+ function repoPRStatesToMarkdown (
140+ artifact : RepoPRState [ ] ,
141+ headingLevel : number
142+ ) : string | null {
120143 if ( ! artifact . length ) {
121144 return null ;
122145 }
123146
124- const parts : string [ ] = [ '# Pull Requests' , '' ] ;
147+ const h1 = '#' . repeat ( headingLevel ) ;
148+
149+ const parts : string [ ] = [ `${ h1 } Pull Requests` , '' ] ;
125150
126151 parts . push (
127152 ...artifact
@@ -137,12 +162,18 @@ function repoPRStatesToMarkdown(artifact: RepoPRState[]): string | null {
137162 return parts . join ( '\n' ) ;
138163}
139164
140- function codingAgentsToMarkdown ( artifact : ExplorerCodingAgentState [ ] ) : string | null {
165+ function codingAgentsToMarkdown (
166+ artifact : ExplorerCodingAgentState [ ] ,
167+ headingLevel : number
168+ ) : string | null {
141169 if ( ! artifact . length ) {
142170 return null ;
143171 }
144172
145- const parts : string [ ] = [ '# Coding Agents' , '' ] ;
173+ const h1 = '#' . repeat ( headingLevel ) ;
174+ const h2 = '#' . repeat ( headingLevel + 1 ) ;
175+
176+ const parts : string [ ] = [ `${ h1 } Coding Agents` , '' ] ;
146177
147178 parts . push (
148179 ...artifact
@@ -152,7 +183,7 @@ function codingAgentsToMarkdown(artifact: ExplorerCodingAgentState[]): string |
152183 }
153184
154185 return [
155- `## ${ getCodingAgentName ( codingAgent . provider ) } ` ,
186+ `${ h2 } ${ getCodingAgentName ( codingAgent . provider ) } ` ,
156187 '' ,
157188 `[${ codingAgent . name } ](${ codingAgent . agent_url } )` ,
158189 ] ;
0 commit comments