Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/@types/vscode.proposed.chatParticipantAdditions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ declare module 'vscode' {
isComplete?: boolean;
toolSpecificData?: ChatTerminalToolInvocationData;
fromSubAgent?: boolean;
presentation?: 'hidden' | 'hiddenAfterComplete' | undefined;

constructor(toolName: string, toolCallId: string, isError?: boolean);
}
Expand Down
7 changes: 6 additions & 1 deletion src/lm/tools/fetchIssueTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export interface FetchIssueResult {
author?: string;
assignees?: string[];
reviewers?: string[];
issueNumber?: number;
itemType?: 'issue' | 'pr';
}

export class FetchIssueTool extends RepoToolBase<FetchIssueToolParameters> {
Expand All @@ -51,6 +53,7 @@ export class FetchIssueTool extends RepoToolBase<FetchIssueToolParameters> {
if (!issueOrPullRequest) {
throw new Error(`No issue or pull request found for ${owner}/${name}/${issueNumber}. Make sure the issue or pull request exists.`);
}
const itemType = issueOrPullRequest instanceof PullRequestModel ? 'pr' : 'issue';
const result: FetchIssueResult = {
owner,
repo: name,
Expand All @@ -59,7 +62,9 @@ export class FetchIssueTool extends RepoToolBase<FetchIssueToolParameters> {
comments: issueOrPullRequest.item.comments?.map(c => ({ body: c.body, author: c.author.login })) ?? [],
author: issueOrPullRequest.author?.login,
assignees: issueOrPullRequest.assignees?.map(a => a.login),
reviewers: issueOrPullRequest instanceof PullRequestModel ? issueOrPullRequest.reviewers?.map(r => isITeam(r) ? r.name : r.login).filter((login): login is string => !!login) : undefined
reviewers: issueOrPullRequest instanceof PullRequestModel ? issueOrPullRequest.reviewers?.map(r => isITeam(r) ? r.name : r.login).filter((login): login is string => !!login) : undefined,
issueNumber,
itemType
};
if (issueOrPullRequest instanceof PullRequestModel && issueOrPullRequest.isResolved()) {
const fileChanges = await issueOrPullRequest.getFileChangesInfo();
Expand Down
23 changes: 20 additions & 3 deletions src/lm/tools/summarizeIssueTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import * as vscode from 'vscode';
import { FetchIssueResult } from './fetchIssueTool';
import { concatAsyncIterable } from './toolsUtils';
import { concatAsyncIterable, TOOL_COMMAND_RESULT } from './toolsUtils';

export class IssueSummarizationTool implements vscode.LanguageModelTool<FetchIssueResult> {
public static readonly toolId = 'github-pull-request_issue_summarize';
Expand Down Expand Up @@ -58,17 +58,34 @@ Body: ${comment.body}
const model = models[0];
const repo = options.input.repo;
const owner = options.input.owner;
const content: vscode.LanguageModelTextPart[] = [];

// Add Open command if we have the necessary information
const issueNumber = options.input.issueNumber;
const itemType = options.input.itemType;
if (owner && repo && issueNumber && itemType) {
const type = itemType === 'issue' ? 'issues' : 'pull';
const url = `https://github.com/${owner}/${repo}/${type}/${issueNumber}`;
const openCommand: vscode.Command = {
title: 'Open',
command: 'vscode.open',
arguments: [vscode.Uri.parse(url)]
};
content.push(new vscode.LanguageModelTextPart(TOOL_COMMAND_RESULT));
content.push(new vscode.LanguageModelTextPart(JSON.stringify(openCommand)));
}

if (model && repo && owner) {
const messages = [vscode.LanguageModelChatMessage.User(this.summarizeInstructions(repo, owner))];
messages.push(vscode.LanguageModelChatMessage.User(`The issue or pull request information is as follows:`));
messages.push(vscode.LanguageModelChatMessage.User(issueOrPullRequestInfo));
const response = await model.sendRequest(messages, {});
const responseText = await concatAsyncIterable(response.text);
return new vscode.LanguageModelToolResult([new vscode.LanguageModelTextPart(responseText)]);
content.push(new vscode.LanguageModelTextPart(responseText));
} else {
return new vscode.LanguageModelToolResult([new vscode.LanguageModelTextPart(issueOrPullRequestInfo)]);
content.push(new vscode.LanguageModelTextPart(issueOrPullRequestInfo));
}
return new vscode.LanguageModelToolResult(content);
}

private summarizeInstructions(repo: string, owner: string): string {
Expand Down
20 changes: 18 additions & 2 deletions src/lm/tools/summarizeNotificationsTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ Body: ${comment.body}
const content: vscode.LanguageModelTextPart[] = [];
const threadId = options.input.threadId;
const notificationKey = options.input.notificationKey;
const owner = options.input.owner;
const repo = options.input.repo;
const itemNumber = options.input.itemNumber;
const itemType = options.input.itemType;

if (threadId && notificationKey) {
const markAsReadCommand = {
title: 'Mark As Read',
Expand All @@ -85,9 +90,20 @@ Body: ${comment.body}
content.push(new vscode.LanguageModelTextPart(JSON.stringify(markAsReadCommand)));
content.push(new vscode.LanguageModelTextPart(TOOL_COMMAND_RESULT));
content.push(new vscode.LanguageModelTextPart(JSON.stringify(markAsDoneCommand)));

// Add Open command
if (owner && repo && itemNumber && itemType) {
const type = itemType === 'issue' ? 'issues' : 'pull';
const url = `https://github.com/${owner}/${repo}/${type}/${itemNumber}`;
const openCommand: vscode.Command = {
title: 'Open',
command: 'vscode.open',
arguments: [vscode.Uri.parse(url)]
};
content.push(new vscode.LanguageModelTextPart(TOOL_COMMAND_RESULT));
content.push(new vscode.LanguageModelTextPart(JSON.stringify(openCommand)));
}
}
const owner = options.input.owner;
const repo = options.input.repo;
if (model && owner && repo) {
const messages = [vscode.LanguageModelChatMessage.User(this.summarizeInstructions(owner, repo))];
messages.push(vscode.LanguageModelChatMessage.User(`The notification information is as follows:`));
Expand Down