6
6
import { Commands , globals } from 'aws-core-vscode/shared'
7
7
import { window } from 'vscode'
8
8
import { AmazonQChatViewProvider } from './webviewProvider'
9
- import { CodeScanIssue } from 'aws-core-vscode/codewhisperer'
9
+ import { CodeScanIssue , AuthUtil } from 'aws-core-vscode/codewhisperer'
10
10
import { getLogger } from 'aws-core-vscode/shared'
11
11
import * as vscode from 'vscode'
12
12
import * as path from 'path'
13
+ import { codeReviewInChat } from '../../app/amazonqScan/models/constants'
14
+ import { telemetry , AmazonqCodeReviewTool } from 'aws-core-vscode/telemetry'
13
15
14
16
/**
15
17
* TODO: Re-enable these once we can figure out which path they're going to live in
@@ -29,7 +31,8 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
29
31
filePath ,
30
32
'Explain' ,
31
33
'Provide a small description of the issue. You must not attempt to fix the issue. You should only give a small summary of it to the user.' ,
32
- provider
34
+ provider ,
35
+ 'explainIssue'
33
36
)
34
37
) ,
35
38
Commands . register ( 'aws.amazonq.generateFix' , ( issue : CodeScanIssue , filePath : string ) =>
@@ -38,7 +41,8 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
38
41
filePath ,
39
42
'Fix' ,
40
43
'Generate a fix for the following code issue. You must not explain the issue, just generate and explain the fix. The user should have the option to accept or reject the fix before any code is changed.' ,
41
- provider
44
+ provider ,
45
+ 'applyFix'
42
46
)
43
47
) ,
44
48
Commands . register ( 'aws.amazonq.sendToPrompt' , ( data ) => {
@@ -64,14 +68,20 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
64
68
registerShellCommandShortCut ( 'aws.amazonq.rejectCmdExecution' , 'reject-shell-command' , provider ) ,
65
69
registerShellCommandShortCut ( 'aws.amazonq.stopCmdExecution' , 'stop-shell-command' , provider )
66
70
)
71
+ if ( codeReviewInChat ) {
72
+ globals . context . subscriptions . push (
73
+ registerGenericCommand ( 'aws.amazonq.security.scan-statusbar' , 'Review' , provider )
74
+ )
75
+ }
67
76
}
68
77
69
78
async function handleIssueCommand (
70
79
issue : CodeScanIssue ,
71
80
filePath : string ,
72
81
action : string ,
73
82
contextPrompt : string ,
74
- provider : AmazonQChatViewProvider
83
+ provider : AmazonQChatViewProvider ,
84
+ metricName : string
75
85
) {
76
86
await focusAmazonQPanel ( )
77
87
@@ -95,6 +105,16 @@ async function handleIssueCommand(
95
105
autoSubmit : true ,
96
106
} ,
97
107
} )
108
+
109
+ telemetry . amazonq_codeReviewTool . emit ( {
110
+ findingId : issue . findingId ,
111
+ detectorId : issue . detectorId ,
112
+ ruleId : issue . ruleId ,
113
+ credentialStartUrl : AuthUtil . instance . startUrl ,
114
+ autoDetected : issue . autoDetected ,
115
+ result : 'Succeeded' ,
116
+ reason : metricName ,
117
+ } as AmazonqCodeReviewTool )
98
118
}
99
119
100
120
async function openFileWithSelection ( issue : CodeScanIssue , filePath : string ) {
0 commit comments