@@ -375,6 +375,9 @@ export const GithubRunCommand = cmd({
375375 const runUrl = `/${ owner } /${ repo } /actions/runs/${ runId } `
376376 const shareBaseUrl = isMock ? "https://dev.opencode.ai" : "https://opencode.ai"
377377
378+ // TODO
379+ console . log ( "payload" , payload )
380+
378381 let appToken : string
379382 let octoRest : Octokit
380383 let octoGraph : typeof graphql
@@ -386,14 +389,14 @@ export const GithubRunCommand = cmd({
386389 type PromptFiles = Awaited < ReturnType < typeof getUserPrompt > > [ "promptFiles" ]
387390
388391 try {
389- const { userPrompt, promptFiles } = await getUserPrompt ( )
390392 const actionToken = isMock ? args . token ! : await getOidcToken ( )
391393 appToken = await exchangeForAppToken ( actionToken )
392394 octoRest = new Octokit ( { auth : appToken } )
393395 octoGraph = graphql . defaults ( {
394396 headers : { authorization : `token ${ appToken } ` } ,
395397 } )
396398
399+ const { userPrompt, promptFiles } = await getUserPrompt ( )
397400 await configureGit ( appToken )
398401 await assertPermissions ( )
399402
@@ -531,20 +534,31 @@ export const GithubRunCommand = cmd({
531534 } [ ] = [ ]
532535
533536 // Search for files
537+ // ie. <img alt="Image" src="https://github.com/user-attachments/assets/xxxx" />
534538 // ie. [api.json](https://github.com/user-attachments/files/21433810/api.json)
535539 // ie. 
536- const imgTags = prompt . matchAll ( / ! ? \[ .* ?\] \( ( h t t p s : \/ \/ g i t h u b \. c o m \/ u s e r - a t t a c h m e n t s \/ [ ^ ) ] + ) \) / gi)
540+ const mdMatches = prompt . matchAll ( / ! ? \[ .* ?\] \( ( h t t p s : \/ \/ g i t h u b \. c o m \/ u s e r - a t t a c h m e n t s \/ [ ^ ) ] + ) \) / gi)
541+ const tagMatches = prompt . matchAll ( / < i m g .* ?s r c = " ( h t t p s : \/ \/ g i t h u b \. c o m \/ u s e r - a t t a c h m e n t s \/ [ ^ " ] + ) " \/ > / gi)
542+ const matches = [ ...mdMatches , ...tagMatches ] . sort ( ( a , b ) => a . index - b . index )
537543
538544 let offset = 0
539- for ( const imgTag of imgTags ) {
540- const tag = imgTag [ 0 ]
541- const url = imgTag [ 1 ]
542- const start = imgTag . index
545+ for ( const m of matches ) {
546+ const tag = m [ 0 ]
547+ const url = m [ 1 ]
548+ const start = m . index
543549 const filename = path . basename ( url )
544550
545551 // Download image
546- const res = await fetch ( url )
552+ const res = await fetch ( url , {
553+ headers : {
554+ Authorization : `Bearer ${ appToken } ` ,
555+ Accept : "application/vnd.github.v3+json" ,
556+ } ,
557+ } )
547558 if ( ! res . ok ) {
559+ // TODO
560+ //console.log(res)
561+ //throw new Error("manual")
548562 console . error ( `Failed to download image: ${ url } ` )
549563 continue
550564 }
0 commit comments