@@ -425,165 +425,6 @@ IMPORTANT RULES:
4254257. Prefer stable areas over high-churn areas for safety` ;
426426}
427427
428- /**
429- * Builds prompt for Issue Triage Report
430- */
431- export function buildIssueTriagePrompt (
432- snapshot : RepoSnapshot ,
433- tone : 'concise' | 'detailed'
434- ) : string {
435- const allIssues = snapshot . allIssues || [ ] ;
436-
437- if ( allIssues . length === 0 ) {
438- return `No open issues found in repository ${ snapshot . repo . full_name } . Generate a brief message explaining that there are no issues to triage.` ;
439- }
440-
441- // Calculate issue age
442- const now = new Date ( ) ;
443- const issuesWithAge = allIssues . map ( issue => {
444- const created = new Date ( issue . created_at ) ;
445- const ageInDays = Math . floor ( ( now . getTime ( ) - created . getTime ( ) ) / ( 1000 * 60 * 60 * 24 ) ) ;
446- return { ...issue , ageInDays } ;
447- } ) ;
448-
449- // Sort by reactions + comments (engagement) for prioritization hints
450- const sortedByEngagement = [ ...issuesWithAge ] . sort ( ( a , b ) =>
451- ( ( b . reactions || 0 ) + b . comments ) - ( ( a . reactions || 0 ) + a . comments )
452- ) ;
453-
454- // Find stale issues (>90 days with no recent activity)
455- const staleIssues = issuesWithAge . filter ( i => i . ageInDays > 90 ) ;
456-
457- // Recent commit patterns to understand current focus
458- const recentCommitMessages = snapshot . commits . slice ( 0 , 20 )
459- . map ( c => c . message . split ( '\n' ) [ 0 ] )
460- . join ( '\n' ) ;
461-
462- return `You are an expert project manager analyzing GitHub issues to help maintainers prioritize their backlog.
463-
464- Repository: ${ snapshot . repo . full_name }
465- Language: ${ snapshot . repo . language || 'Multiple' }
466- Total Open Issues: ${ allIssues . length }
467- Stale Issues (>90 days): ${ staleIssues . length }
468-
469- ===== ALL OPEN ISSUES =====
470-
471- ${ issuesWithAge . slice ( 0 , 50 ) . map ( issue => `
472- #${ issue . number } : ${ issue . title }
473- - Labels: ${ issue . labels . length > 0 ? issue . labels . join ( ', ' ) : 'none' }
474- - Age: ${ issue . ageInDays } days
475- - Comments: ${ issue . comments }
476- - Reactions: ${ issue . reactions || 0 }
477- - Author: @${ issue . author || 'unknown' }
478- ${ issue . body ? `- Description: ${ issue . body . slice ( 0 , 300 ) } ${ issue . body . length > 300 ? '...' : '' } ` : '- No description' }
479- ` ) . join ( '\n---\n' ) }
480-
481- ===== RECENT DEVELOPMENT CONTEXT =====
482-
483- Recent commits show the team is working on:
484- ${ recentCommitMessages }
485-
486- Recent PRs:
487- ${ snapshot . prs . slice ( 0 , 10 ) . map ( pr => `- #${ pr . number } : ${ pr . title } ` ) . join ( '\n' ) }
488-
489- ===== HIGHEST ENGAGEMENT ISSUES =====
490-
491- Top issues by community interest (reactions + comments):
492- ${ sortedByEngagement . slice ( 0 , 5 ) . map ( i => `- #${ i . number } : ${ i . title } (${ ( i . reactions || 0 ) + i . comments } engagement)` ) . join ( '\n' ) }
493-
494- ===== GENERATE THIS EXACT FORMAT =====
495-
496- # Issue Triage Report
497-
498- > **${ allIssues . length } open issues analyzed** • Generated ${ new Date ( ) . toLocaleDateString ( ) }
499-
500- ---
501-
502- ## 🔴 Critical Priority
503- [Issues that are blocking, security-related, or affecting many users]
504- [For each issue, explain WHY it's critical]
505-
506- ${ tone === 'detailed' ? 'Include 3-5 issues with full reasoning' : 'Include 2-3 issues' }
507-
508- Format for each:
509- ### #[number]: [title]
510- **Why Critical:** [1-2 sentences explaining impact]
511- **Suggested Action:** [What maintainer should do]
512- **Labels to Add:** [Suggest appropriate labels if missing]
513-
514- ---
515-
516- ## 🟠 High Priority
517- [Important issues that should be addressed soon - feature requests with high demand, significant bugs]
518-
519- ${ tone === 'detailed' ? 'Include 4-6 issues' : 'Include 2-4 issues' }
520-
521- Format for each:
522- ### #[number]: [title]
523- **Why Important:** [1 sentence]
524- **Effort Estimate:** Low/Medium/High
525- **Suggested Action:** [Brief action]
526-
527- ---
528-
529- ## 🟡 Medium Priority
530- [Good to fix but not urgent - smaller bugs, enhancements, documentation]
531-
532- ${ tone === 'detailed' ? 'Include 5-8 issues' : 'Include 3-5 issues' }
533-
534- Format for each:
535- - **#[number]**: [title] — [1 sentence summary] • Effort: [Low/Med/High]
536-
537- ---
538-
539- ## ⚪ Low Priority / Backlog
540- [Nice to have, long-term ideas, minor improvements]
541-
542- ${ tone === 'detailed' ? 'Include remaining issues' : 'Include 3-5 issues' }
543-
544- Format: Brief list with issue numbers and titles
545-
546- ---
547-
548- ## 🗑️ Recommend Closing
549- [Issues that should be closed - stale with no activity, duplicates, won't fix, already resolved]
550-
551- ${ staleIssues . length > 0 ? `
552- Found ${ staleIssues . length } stale issues (>90 days old). Review these for closure:
553- ` : 'No obviously stale issues found.' }
554-
555- For each:
556- - **#[number]**: [title] — **Reason:** [duplicate of #X / stale / wont fix / resolved]
557-
558- ---
559-
560- ## 📊 Backlog Health Summary
561-
562- | Metric | Value |
563- |--------|-------|
564- | Total Open | ${ allIssues . length } |
565- | Critical | [count] |
566- | Stale (>90d) | ${ staleIssues . length } |
567- | Unlabeled | [count issues with no labels] |
568- | Avg Age | [calculate] days |
569-
570- **Recommendations:**
571- 1. [Top recommendation based on analysis]
572- 2. [Second recommendation]
573- 3. [Third recommendation]
574-
575- ---
576-
577- IMPORTANT RULES:
578- 1. Every issue you mention MUST use the exact issue number from the data
579- 2. Base priority on: user impact, engagement (reactions+comments), alignment with recent development
580- 3. Be specific about WHY each issue has its priority level
581- 4. If an issue seems like a duplicate, mention it
582- 5. Consider issue age - very old issues with no activity may need closure
583- 6. Look at labels to understand existing categorization
584- 7. Suggest missing labels where appropriate` ;
585- }
586-
587428/**
588429 * Helper: Analyze file churn
589430 */
0 commit comments