@@ -6,15 +6,15 @@ use std::path::Path;
66use std:: process:: { Command , Stdio } ;
77
88use crate :: gh:: issues:: ExistingGithubIssue ;
9- use crate :: templates:: Updates ;
9+ use crate :: templates:: { Updates , UpdatesGoal } ;
1010use crate :: {
1111 gh:: {
1212 issue_id:: { IssueId , Repository } ,
1313 issues:: { list_issue_titles_in_milestone, ExistingGithubComment , ExistingIssueState } ,
1414 } ,
1515 json:: checkboxes,
1616 llm:: LargeLanguageModel ,
17- templates:: { self , UpdatesFlagshipGoal , UpdatesFlagshipGoalUpdate , UpdatesOtherGoal } ,
17+ templates,
1818 util:: comma,
1919} ;
2020
@@ -114,8 +114,8 @@ async fn prepare_flagship_goals(
114114 repository : & Repository ,
115115 issues : & BTreeMap < String , ExistingGithubIssue > ,
116116 filter : & Filter < ' _ > ,
117- _llm : & LargeLanguageModel ,
118- _quick : bool ,
117+ llm : & LargeLanguageModel ,
118+ quick : bool ,
119119 updates : & mut Updates ,
120120) -> anyhow:: Result < ( ) > {
121121 // First process the flagship goals, for which we capture the full text of comments.
@@ -133,7 +133,36 @@ async fn prepare_flagship_goals(
133133
134134 let progress = checkboxes ( & issue) ;
135135
136- updates. flagship_goals . push ( UpdatesFlagshipGoal {
136+ let mut comments = issue. comments . clone ( ) ;
137+ comments. sort_by_key ( |c| c. created_at . clone ( ) ) ;
138+ comments. retain ( |c| filter. matches ( c) ) ;
139+
140+ let summary: String = if comments. len ( ) == 0 {
141+ format ! ( "No updates in this period." )
142+ } else if quick {
143+ QUICK_UPDATES . iter ( ) . copied ( ) . collect ( )
144+ } else {
145+ let prompt = format ! (
146+ "The following comments are updates to a project goal entitled '{title}'. \
147+ The goal is assigned to {people} ({assignees}). \
148+ Summarize the major developments, writing for general Rust users. \
149+ Write the update in the third person and do not use pronouns when referring to people. \
150+ Do not respond with anything but the summary paragraphs. \
151+ ",
152+ people = if issue. assignees. len( ) == 1 {
153+ "1 person" . to_string( )
154+ } else {
155+ format!( "{} people" , issue. assignees. len( ) )
156+ } ,
157+ assignees = comma( & issue. assignees) ,
158+ ) ;
159+ let updates: String = comments. iter ( ) . map ( |c| format ! ( "\n {}\n " , c. body) ) . collect ( ) ;
160+ llm. query ( & prompt, & updates)
161+ . await
162+ . with_context ( || format ! ( "making request to LLM failed" ) ) ?
163+ } ;
164+
165+ updates. flagship_goals . push ( UpdatesGoal {
137166 title : title. clone ( ) ,
138167 issue_number : issue. number ,
139168 issue_assignees : comma ( & issue. assignees ) ,
@@ -144,17 +173,7 @@ async fn prepare_flagship_goals(
144173 . url ( ) ,
145174 progress,
146175 is_closed : issue. state == ExistingIssueState :: Closed ,
147- updates : issue
148- . comments
149- . iter ( )
150- . filter ( |c| filter. matches ( c) )
151- . map ( |c| UpdatesFlagshipGoalUpdate {
152- author : c. author . clone ( ) ,
153- date : c. created_at_date ( ) . format ( "%m %d" ) . to_string ( ) ,
154- update : c. body . clone ( ) ,
155- url : c. url . clone ( ) ,
156- } )
157- . collect ( ) ,
176+ updates_markdown : summary,
158177 } ) ;
159178
160179 progress_bar:: inc_progress_bar ( ) ;
@@ -219,7 +238,7 @@ async fn prepare_other_goals(
219238 llm. query ( & prompt, & updates) . await ?
220239 } ;
221240
222- let goal = UpdatesOtherGoal {
241+ let goal = UpdatesGoal {
223242 title : title. clone ( ) ,
224243 issue_number : issue. number ,
225244 issue_assignees : comma ( & issue. assignees ) ,
0 commit comments