@@ -10,38 +10,42 @@ import { PullRequestModel } from '../../github/pullRequestModel';
1010import { RepoToolBase } from './toolsUtils' ;
1111
1212interface FetchIssueToolParameters {
13- issueNumber : number ;
13+ issueNumber ? : number ;
1414 repo ?: {
15- owner : string ;
16- name : string ;
15+ owner ? : string ;
16+ name ? : string ;
1717 } ;
1818}
1919
2020interface FileChange {
21- fileName : string ;
22- patch : string ;
21+ fileName ? : string ;
22+ patch ? : string ;
2323}
2424
2525export interface FetchIssueResult {
26- title : string ;
27- body : string ;
28- comments : {
29- author : string ;
30- body : string ;
26+ title ? : string ;
27+ body ? : string ;
28+ comments ? : {
29+ author ? : string ;
30+ body ? : string ;
3131 } [ ] ;
32- owner : string ;
33- repo : string ;
32+ owner ? : string ;
33+ repo ? : string ;
3434 fileChanges ?: FileChange [ ] ;
3535}
3636
3737export class FetchIssueTool extends RepoToolBase < FetchIssueToolParameters > {
3838 public static readonly toolId = 'github-pull-request_issue_fetch' ;
3939
4040 async invoke ( options : vscode . LanguageModelToolInvocationOptions < FetchIssueToolParameters > , _token : vscode . CancellationToken ) : Promise < vscode . LanguageModelToolResult > {
41+ const issueNumber = options . input . issueNumber ;
42+ if ( ! issueNumber ) {
43+ throw new Error ( 'No issue/PR number provided.' ) ;
44+ }
4145 const { owner, name, folderManager } = await this . getRepoInfo ( { owner : options . input . repo ?. owner , name : options . input . repo ?. name } ) ;
42- const issueOrPullRequest = await folderManager . resolveIssueOrPullRequest ( owner , name , options . input . issueNumber ) ;
46+ const issueOrPullRequest = await folderManager . resolveIssueOrPullRequest ( owner , name , issueNumber ) ;
4347 if ( ! issueOrPullRequest ) {
44- throw new Error ( `No issue or PR found for ${ owner } /${ name } /${ options . input . issueNumber } . Make sure the issue or PR exists.` ) ;
48+ throw new Error ( `No issue or PR found for ${ owner } /${ name } /${ issueNumber } . Make sure the issue or PR exists.` ) ;
4549 }
4650 const result : FetchIssueResult = {
4751 owner,
@@ -79,6 +83,5 @@ export class FetchIssueTool extends RepoToolBase<FetchIssueToolParameters> {
7983 return {
8084 invocationMessage : url ? vscode . l10n . t ( 'Fetching item [#{0}]({1}) from GitHub' , options . input . issueNumber , url ) : vscode . l10n . t ( 'Fetching item #{0} from GitHub' , options . input . issueNumber ) ,
8185 } ;
82-
8386 }
8487}
0 commit comments