@@ -105,9 +105,9 @@ function isCommentEditedEvent(payload) {
105
105
function run ( ) {
106
106
return __awaiter ( this , void 0 , void 0 , function ( ) {
107
107
var now , zonedDate , formattedDate , octokit , payload , prompt , assistantResponse , parsedAssistantResponse , _a , _b , action , _c , message , isNoAction , isActionEdit , isActionRequired , formattedResponse , formattedResponse ;
108
- var _d , _e , _f , _g , _h , _j , _k , _l , _m , _o , _p , _q , _r , _s , _t , _u , _v , _w ;
109
- return __generator ( this , function ( _x ) {
110
- switch ( _x . label ) {
108
+ var _d , _e , _f , _g , _h , _j , _k , _l , _m , _o , _p , _q , _r , _s , _t , _u , _v , _w , _x ;
109
+ return __generator ( this , function ( _y ) {
110
+ switch ( _y . label ) {
111
111
case 0 :
112
112
now = Date . now ( ) ;
113
113
zonedDate = ( 0 , date_fns_tz_1 . utcToZonedTime ) ( now , 'UTC' ) ;
@@ -144,7 +144,7 @@ function run() {
144
144
: "I NEED HELP WITH CASE (2.) WHEN A USER THAT POSTED AN INITIAL PROPOSAL OR COMMENT (UNEDITED) THEN EDITS THE COMMENT - WE NEED TO CLASSIFY THE COMMENT BASED IN THE GIVEN INSTRUCTIONS AND IF TEMPLATE IS FOLLOWED AS PER INSTRUCTIONS. IT IS MANDATORY THAT YOU RESPOND ONLY WITH \"" . concat ( CONST_1 . default . NO_ACTION , "\" IN CASE THE COMMENT IS NOT A PROPOSAL. \n\nPrevious comment content: " ) . concat ( ( _o = payload . changes . body ) === null || _o === void 0 ? void 0 : _o . from , ".\n\nEdited comment content: " ) . concat ( ( _p = payload . comment ) === null || _p === void 0 ? void 0 : _p . body ) ;
145
145
return [ 4 /*yield*/ , OpenAIUtils_1 . default . prompt ( prompt ) ] ;
146
146
case 1 :
147
- assistantResponse = _x . sent ( ) ;
147
+ assistantResponse = _y . sent ( ) ;
148
148
parsedAssistantResponse = JSON . parse ( sanitizeJSONStringValues ( assistantResponse ) ) ;
149
149
console . log ( 'parsedAssistantResponse: ' , parsedAssistantResponse ) ;
150
150
_a = parsedAssistantResponse !== null && parsedAssistantResponse !== void 0 ? parsedAssistantResponse : { } , _b = _a . action , action = _b === void 0 ? "" : _b , _c = _a . message , message = _c === void 0 ? "" : _c ;
@@ -157,33 +157,30 @@ function run() {
157
157
return [ 2 /*return*/ ] ;
158
158
}
159
159
if ( ! ( isCommentCreatedEvent ( payload ) && isActionRequired ) ) return [ 3 /*break*/ , 3 ] ;
160
+ console . log ( 'payload.comment?.url' , ( _q = payload . comment ) === null || _q === void 0 ? void 0 : _q . url ) ;
161
+ console . log ( 'payload.comment?.html_url' , ( _r = payload . comment ) === null || _r === void 0 ? void 0 : _r . html_url ) ;
160
162
formattedResponse = message
161
- // replace {user} from response template with @username
162
- // @ts -ignore - process is not imported
163
- . replaceAll ( '{user}' , "@" . concat ( ( _q = payload . comment ) === null || _q === void 0 ? void 0 : _q . user . login ) )
164
- // replace {proposalLink} from response template with the link to the comment
165
- . replaceAll ( '{proposalLink}' , ( _r = payload . comment ) === null || _r === void 0 ? void 0 : _r . html_url )
166
- // remove any double quotes from the final comment because sometimes the assistant's
167
- // response contains double quotes / sometimes it doesn't
168
- . replaceAll ( '"' , '' ) ;
163
+ // replace {user} from response template with GH @username
164
+ // @ts -ignore - replaceAll exists
165
+ . replaceAll ( '{user}' , "@" . concat ( ( _s = payload . comment ) === null || _s === void 0 ? void 0 : _s . user . login ) ) ;
169
166
// Create a comment with the assistant's response
170
167
console . log ( 'ProposalPolice™ commenting on issue...' ) ;
171
168
return [ 4 /*yield*/ , octokit . issues . createComment ( __assign ( __assign ( { } , github_1 . context . repo ) , {
172
169
/* eslint-disable @typescript-eslint/naming-convention */
173
- issue_number : ( _t = ( _s = payload . issue ) === null || _s === void 0 ? void 0 : _s . number ) !== null && _t !== void 0 ? _t : - 1 , body : formattedResponse } ) ) ] ;
170
+ issue_number : ( _u = ( _t = payload . issue ) === null || _t === void 0 ? void 0 : _t . number ) !== null && _u !== void 0 ? _u : - 1 , body : formattedResponse } ) ) ] ;
174
171
case 2 :
175
- _x . sent ( ) ;
172
+ _y . sent ( ) ;
176
173
return [ 3 /*break*/ , 5 ] ;
177
174
case 3 :
178
175
if ( ! isActionEdit ) return [ 3 /*break*/ , 5 ] ;
179
176
formattedResponse = message . replace ( '{updated_timestamp}' , formattedDate ) ;
180
177
console . log ( 'ProposalPolice™ editing issue comment...' , payload . comment . id ) ;
181
178
return [ 4 /*yield*/ , octokit . issues . updateComment ( __assign ( __assign ( { } , github_1 . context . repo ) , {
182
179
/* eslint-disable @typescript-eslint/naming-convention */
183
- comment_id : ( _v = ( _u = payload . comment ) === null || _u === void 0 ? void 0 : _u . id ) !== null && _v !== void 0 ? _v : - 1 , body : "" . concat ( formattedResponse , "\n\n" ) . concat ( ( _w = payload . comment ) === null || _w === void 0 ? void 0 : _w . body ) } ) ) ] ;
180
+ comment_id : ( _w = ( _v = payload . comment ) === null || _v === void 0 ? void 0 : _v . id ) !== null && _w !== void 0 ? _w : - 1 , body : "" . concat ( formattedResponse , "\n\n" ) . concat ( ( _x = payload . comment ) === null || _x === void 0 ? void 0 : _x . body ) } ) ) ] ;
184
181
case 4 :
185
- _x . sent ( ) ;
186
- _x . label = 5 ;
182
+ _y . sent ( ) ;
183
+ _y . label = 5 ;
187
184
case 5 : return [ 2 /*return*/ ] ;
188
185
}
189
186
} ) ;
0 commit comments