Skip to content

Commit a135d25

Browse files
authored
Add skill for addressing comments (#8599)
* Add skill for addressing comments * CCR
1 parent 3b4d1cc commit a135d25

File tree

4 files changed

+94
-4
lines changed

4 files changed

+94
-4
lines changed

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3794,6 +3794,9 @@
37943794
},
37953795
{
37963796
"path": "./src/lm/skills/show-github-search-result/SKILL.md"
3797+
},
3798+
{
3799+
"path": "./src/lm/skills/address-pr-comments/SKILL.md"
37973800
}
37983801
],
37993802
"languageModelTools": [
@@ -3963,7 +3966,16 @@
39633966
"icon": "$(git-pull-request)",
39643967
"canBeReferencedInPrompt": true,
39653968
"userDescription": "%languageModelTools.github-pull-request_activePullRequest.description%",
3966-
"when": "config.githubPullRequests.experimental.chat"
3969+
"when": "config.githubPullRequests.experimental.chat",
3970+
"inputSchema": {
3971+
"type": "object",
3972+
"properties": {
3973+
"refresh": {
3974+
"type": "boolean",
3975+
"description": "Whether to fetch fresh data from GitHub or return cached data. Set to true to ensure the most up-to-date information, especially after recent changes. Set to false to improve performance when up-to-date information is not critical."
3976+
}
3977+
}
3978+
}
39673979
},
39683980
{
39693981
"name": "github-pull-request_pullRequestStatusChecks",
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
name: address-pr-comments
3+
description: "Address review comments (including Copilot comments) on the active pull request. Use when: responding to PR feedback, fixing review comments, resolving PR threads, implementing requested changes from reviewers, addressing code review, fixing PR issues."
4+
argument-hint: "Optionally specify a reviewer name or file to focus on"
5+
---
6+
7+
# Address PR Review Comments
8+
9+
Read the active pull request, identify unresolved review comments and feedback, implement the requested changes, and resolve the threads.
10+
11+
## When to Use
12+
13+
- A reviewer has left comments or change requests on the active PR
14+
- You need to systematically work through all open review threads
15+
- You want to respond to or implement reviewer feedback
16+
17+
## Procedure
18+
19+
### 1. Read the Active PR
20+
21+
Call the `github-pull-request_activePullRequest` tool.
22+
23+
**Refresh logic**: Check whether a refresh is needed before reading:
24+
- Call the tool once *without* `refresh` to get the cached state
25+
- Inspect the `lastUpdatedAt` field in the result
26+
- If the timestamp is **less than 3 minutes ago**, the PR is actively changing - call the tool again with `refresh: true` to ensure you have the latest comments and state
27+
- If the timestamp is older than 3 minutes, proceed with the cached data
28+
29+
### 2. Identify Unresolved Comments
30+
31+
From the tool result, collect all feedback that needs action:
32+
33+
- **`comments`** array: inline review thread comments where `commentState` is `"unresolved"`
34+
- **`timelineComments`** array: general PR comments and reviews where `commentType` is `"CHANGES_REQUESTED"` or `"COMMENTED"`
35+
36+
Group related comments by file (`file` field) to handle them efficiently.
37+
38+
### 3. Plan Changes
39+
40+
Before modifying any files:
41+
1. Read each unresolved comment carefully
42+
2. Identify the file and location each comment refers to
43+
3. Determine the minimal correct fix for each, if a fix is needed (not all comments are worthy of a change)
44+
4. Note dependencies between comments (e.g., a rename that affects multiple files)
45+
46+
### 4. Implement Changes
47+
48+
Work through the grouped comments file by file:
49+
- Read the relevant file section before editing
50+
- Apply the requested change
51+
- Do not refactor or modify code outside the scope of each comment
52+
- If a comment is unclear or contradictory, note it for a follow-up reply rather than guessing
53+
54+
### 5. Verify
55+
56+
After all changes are made:
57+
- Review that each originally unresolved comment has a corresponding code change or a note about why no code change was needed.
58+
- Ensure no unrelated code was modified
59+
60+
### 6. Summarize
61+
62+
Provide a concise summary of:
63+
- Which comments were addressed and what changes were made
64+
- Any comments that were intentionally skipped (with reasoning)
65+
- Any follow-up questions for the reviewer

src/lm/tools/activePullRequestTool.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import { CommentEvent, EventType, ReviewEvent } from '../../common/timelineEvent
1111
import { PullRequestModel } from '../../github/pullRequestModel';
1212
import { RepositoriesManager } from '../../github/repositoriesManager';
1313

14+
interface PullRequestToolParams {
15+
refresh?: boolean;
16+
}
17+
1418
export abstract class PullRequestTool implements vscode.LanguageModelTool<FetchIssueResult> {
1519
constructor(
1620
protected readonly folderManagers: RepositoriesManager
@@ -42,13 +46,21 @@ export abstract class PullRequestTool implements vscode.LanguageModelTool<FetchI
4246
};
4347
}
4448

45-
async invoke(_options: vscode.LanguageModelToolInvocationOptions<any>, _token: vscode.CancellationToken): Promise<vscode.ExtendedLanguageModelToolResult | undefined> {
49+
async invoke(options: vscode.LanguageModelToolInvocationOptions<any>, _token: vscode.CancellationToken): Promise<vscode.ExtendedLanguageModelToolResult | undefined> {
4650
let pullRequest = this._findActivePullRequest();
4751

4852
if (!pullRequest) {
4953
return new vscode.LanguageModelToolResult([new vscode.LanguageModelTextPart('There is no active pull request')]);
5054
}
5155

56+
if ((options.input as PullRequestToolParams | undefined)?.refresh) {
57+
await Promise.all([
58+
pullRequest.githubRepository.getPullRequest(pullRequest.number),
59+
pullRequest.getTimelineEvents(),
60+
pullRequest.initializeReviewThreadCacheAndReviewComments(),
61+
]);
62+
}
63+
5264
const timeline = (pullRequest.timelineEvents && pullRequest.timelineEvents.length > 0) ? pullRequest.timelineEvents : await pullRequest.getTimelineEvents();
5365
const reviewAndCommentEvents = timeline.filter((event): event is ReviewEvent | CommentEvent => event.event === EventType.Reviewed || event.event === EventType.Commented);
5466

@@ -85,7 +97,8 @@ export abstract class PullRequestTool implements vscode.LanguageModelTool<FetchI
8597
} else {
8698
return `File: ${change.fileName} was ${change.status === GitChangeType.ADD ? 'added' : change.status === GitChangeType.DELETE ? 'deleted' : 'modified'}.`;
8799
}
88-
})
100+
}),
101+
lastUpdatedAt: new Date(pullRequest.updatedAt).toLocaleString()
89102
};
90103

91104
const result = new vscode.ExtendedLanguageModelToolResult([new vscode.LanguageModelTextPart(JSON.stringify(pullRequestInfo))]);

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const webpack = require('webpack');
2121
async function resolveTSConfig(configFile) {
2222
const data = await new Promise((resolve, reject) => {
2323
execFile(
24-
'yarn',
24+
'npx',
2525
['tsc', `-p ${configFile}`, '--showConfig'],
2626
{ cwd: __dirname, encoding: 'utf8', shell: true },
2727
function (error, stdout, stderr) {

0 commit comments

Comments
 (0)