@@ -14,7 +14,6 @@ import { ICAPIClientService } from '../../../platform/endpoint/common/capiClient
1414import { IDomainService } from '../../../platform/endpoint/common/domainService' ;
1515import { IEnvService } from '../../../platform/env/common/envService' ;
1616import { IGitExtensionService } from '../../../platform/git/common/gitExtensionService' ;
17- import { normalizeFetchUrl } from '../../../platform/git/common/gitService' ;
1817import { Repository } from '../../../platform/git/vscode/git' ;
1918import { IIgnoreService } from '../../../platform/ignore/common/ignoreService' ;
2019import { ILogService } from '../../../platform/log/common/logService' ;
@@ -317,8 +316,6 @@ function parseLine(line: string): ResponseReference[] {
317316}
318317
319318async function fetchComments ( logService : ILogService , authService : IAuthenticationService , capiClientService : ICAPIClientService , fetcherService : IFetcherService , envService : IEnvService , customInstructionsService : ICustomInstructionsService , workspaceService : IWorkspaceService , kind : 'selection' | 'diff' , repository : Repository | undefined , baseFileContents : FileState [ ] , headFileContents : FileState [ ] , cancellationToken : CancellationToken ) {
320- const codingGuidlines = repository ? await loadCodingGuidelines ( logService , authService , capiClientService , repository ) : [ ] ;
321-
322319 // Collect languageId to file patterns mapping
323320 const languageIdToFilePatterns = new Map < string , Set < string > > ( ) ;
324321 for ( const file of [ ...baseFileContents , ...headFileContents ] ) {
@@ -331,7 +328,7 @@ async function fetchComments(logService: ILogService, authService: IAuthenticati
331328 }
332329 }
333330
334- const customInstructions = await loadCustomInstructions ( customInstructionsService , workspaceService , kind , languageIdToFilePatterns , codingGuidlines . length + 2 ) ;
331+ const customInstructions = await loadCustomInstructions ( customInstructionsService , workspaceService , kind , languageIdToFilePatterns , 2 ) ;
335332
336333 const requestBody = {
337334 messages : [ {
@@ -358,7 +355,6 @@ async function fetchComments(logService: ILogService, authService: IAuthenticati
358355 baseFileContents : baseFileContents . map ( ( { path, content } ) => ( { path, content } ) ) ,
359356 } ,
360357 } ,
361- ...codingGuidlines ,
362358 ...customInstructions ,
363359 ] ,
364360 } ]
@@ -473,58 +469,6 @@ interface CodingGuideline {
473469 } ;
474470}
475471
476- async function loadCodingGuidelines ( logService : ILogService , authService : IAuthenticationService , capiClientService : ICAPIClientService , repository : Repository ) : Promise < CodingGuideline [ ] > {
477- const { state } = repository ;
478- const remote = state . HEAD ?. upstream ?. remote || state . HEAD ?. remote ;
479- const pushUrl = remote && state . remotes . find ( r => r . name === remote ) ?. pushUrl || state . remotes . find ( r => r . pushUrl ) ?. pushUrl ;
480- if ( ! pushUrl ) {
481- return [ ] ;
482- }
483- const normalized = new URL ( normalizeFetchUrl ( pushUrl ) ) ;
484- if ( normalized . hostname !== 'github.com' ) {
485- return [ ] ;
486- }
487- const pathSegments = normalized . pathname . split ( '/' ) ;
488- const owner = pathSegments [ 1 ] ;
489- const repo = pathSegments [ 2 ] . endsWith ( '.git' ) ? pathSegments [ 2 ] . substring ( 0 , pathSegments [ 2 ] . length - 4 ) : pathSegments [ 2 ] ;
490- const ghToken = ( await authService . getAnyGitHubSession ( ) ) ?. accessToken ;
491- if ( ! ghToken ) {
492- logService . info ( `Failed to fetch coding guidelines for ${ owner } /${ repo } : Not signed in.` ) ;
493- return [ ] ;
494- }
495- const response = await capiClientService . makeRequest < Response > ( {
496- headers : {
497- 'Authorization' : `Bearer ${ ghToken } `
498- } ,
499- } , { type : RequestType . CodingGuidelines , repoWithOwner : `${ owner } /${ repo } ` } ) ;
500-
501- const requestId = response . headers . get ( 'x-github-request-id' ) || undefined ;
502- logService . info ( `[github review agent] coding guidelines request id: ${ requestId } ` ) ;
503-
504- if ( ! response . ok ) {
505- if ( response . status !== 404 ) { // 404: No coding guidelines or user not part of coding guidelines feature flag.
506- logService . info ( `Failed to fetch coding guidelines for ${ owner } /${ repo } : ${ response . statusText } ` ) ;
507- }
508- return [ ] ;
509- }
510-
511- const text = await response . text ( ) ;
512- logService . debug ( `[github review agent] coding guidelines: ${ text } ` ) ;
513- const codingGuidelines = JSON . parse ( text ) as { name : string ; description : string ; filePatterns : string [ ] } [ ] ;
514- const codingGuidelineRefs = codingGuidelines . map ( ( input , index ) => ( {
515- type : 'github.coding_guideline' ,
516- id : `${ index + 2 } ` ,
517- data : {
518- id : index + 2 ,
519- type : 'coding-guideline' ,
520- name : input . name ,
521- description : input . description ,
522- filePatterns : input . filePatterns ,
523- } ,
524- } ) ) ;
525- return codingGuidelineRefs ;
526- }
527-
528472async function loadCustomInstructions ( customInstructionsService : ICustomInstructionsService , workspaceService : IWorkspaceService , kind : 'selection' | 'diff' , languageIdToFilePatterns : Map < string , Set < string > > , firstId : number ) : Promise < CodingGuideline [ ] > {
529473 const customInstructionRefs = [ ] ;
530474 let nextId = firstId ;
0 commit comments