From deeefc5980b09076d1a071b8986138d9cc5b75be Mon Sep 17 00:00:00 2001 From: Aiday Marlen Kyzy Date: Thu, 31 Oct 2024 10:37:55 +0100 Subject: [PATCH] marking all return types as optional --- src/lm/tools/fetchIssueTool.ts | 33 ++++++++++++---------- src/lm/tools/fetchNotificationTool.ts | 25 ++++++++-------- src/lm/tools/summarizeIssueTool.ts | 12 +++++--- src/lm/tools/summarizeNotificationsTool.ts | 6 ++-- 4 files changed, 44 insertions(+), 32 deletions(-) diff --git a/src/lm/tools/fetchIssueTool.ts b/src/lm/tools/fetchIssueTool.ts index e922fc84f3..78c212c1b7 100644 --- a/src/lm/tools/fetchIssueTool.ts +++ b/src/lm/tools/fetchIssueTool.ts @@ -10,27 +10,27 @@ import { PullRequestModel } from '../../github/pullRequestModel'; import { RepoToolBase } from './toolsUtils'; interface FetchIssueToolParameters { - issueNumber: number; + issueNumber?: number; repo?: { - owner: string; - name: string; + owner?: string; + name?: string; }; } interface FileChange { - fileName: string; - patch: string; + fileName?: string; + patch?: string; } export interface FetchIssueResult { - title: string; - body: string; - comments: { - author: string; - body: string; + title?: string; + body?: string; + comments?: { + author?: string; + body?: string; }[]; - owner: string; - repo: string; + owner?: string; + repo?: string; fileChanges?: FileChange[]; } @@ -38,10 +38,14 @@ export class FetchIssueTool extends RepoToolBase { public static readonly toolId = 'github-pull-request_issue_fetch'; async invoke(options: vscode.LanguageModelToolInvocationOptions, _token: vscode.CancellationToken): Promise { + const issueNumber = options.input.issueNumber; + if (!issueNumber) { + throw new Error('No issue/PR number provided.'); + } const { owner, name, folderManager } = await this.getRepoInfo({ owner: options.input.repo?.owner, name: options.input.repo?.name }); - const issueOrPullRequest = await folderManager.resolveIssueOrPullRequest(owner, name, options.input.issueNumber); + const issueOrPullRequest = await folderManager.resolveIssueOrPullRequest(owner, name, issueNumber); if (!issueOrPullRequest) { - throw new Error(`No issue or PR found for ${owner}/${name}/${options.input.issueNumber}. Make sure the issue or PR exists.`); + throw new Error(`No issue or PR found for ${owner}/${name}/${issueNumber}. Make sure the issue or PR exists.`); } const result: FetchIssueResult = { owner, @@ -79,6 +83,5 @@ export class FetchIssueTool extends RepoToolBase { return { 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), }; - } } \ No newline at end of file diff --git a/src/lm/tools/fetchNotificationTool.ts b/src/lm/tools/fetchNotificationTool.ts index 67c9efc070..4437298359 100644 --- a/src/lm/tools/fetchNotificationTool.ts +++ b/src/lm/tools/fetchNotificationTool.ts @@ -11,26 +11,26 @@ import { getNotificationKey } from '../../github/utils'; import { RepoToolBase } from './toolsUtils'; interface FetchNotificationToolParameters { - thread_id: number; + thread_id?: number; } interface FileChange { - fileName: string; - patch: string; + fileName?: string; + patch?: string; } export interface FetchNotificationResult { lastReadAt?: string; - lastUpdatedAt: string; - unread: boolean; - title: string; - body: string; + lastUpdatedAt?: string; + unread?: boolean; + title?: string; + body?: string; comments?: { - author: string; - body: string; + author?: string; + body?: string; }[]; - owner: string; - repo: string; + owner?: string; + repo?: string; itemNumber?: string; itemType?: 'issue' | 'pr'; fileChanges?: FileChange[]; @@ -53,6 +53,9 @@ export class FetchNotificationTool extends RepoToolBase