@aws/lsp-codewhisperer 0.0.68 → 0.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/out/language-server/agenticChat/agenticChatController.js +40 -51
- package/out/language-server/agenticChat/agenticChatController.js.map +1 -1
- package/out/language-server/agenticChat/constants/constants.d.ts +1 -6
- package/out/language-server/agenticChat/constants/constants.js +3 -8
- package/out/language-server/agenticChat/constants/constants.js.map +1 -1
- package/out/language-server/agenticChat/constants/toolConstants.d.ts +1 -1
- package/out/language-server/agenticChat/constants/toolConstants.js +2 -2
- package/out/language-server/agenticChat/constants/toolConstants.js.map +1 -1
- package/out/language-server/agenticChat/context/agenticChatTriggerContext.js +1 -1
- package/out/language-server/agenticChat/context/agenticChatTriggerContext.js.map +1 -1
- package/out/language-server/agenticChat/qAgenticChatServer.d.ts +1 -1
- package/out/language-server/agenticChat/qAgenticChatServer.js +7 -8
- package/out/language-server/agenticChat/qAgenticChatServer.js.map +1 -1
- package/out/language-server/agenticChat/tools/chatDb/chatDb.d.ts +1 -0
- package/out/language-server/agenticChat/tools/chatDb/chatDb.js +3 -3
- package/out/language-server/agenticChat/tools/chatDb/chatDb.js.map +1 -1
- package/out/language-server/agenticChat/tools/executeBash.d.ts +5 -0
- package/out/language-server/agenticChat/tools/executeBash.js +20 -17
- package/out/language-server/agenticChat/tools/executeBash.js.map +1 -1
- package/out/language-server/agenticChat/tools/grepSearch.js +1 -3
- package/out/language-server/agenticChat/tools/grepSearch.js.map +1 -1
- package/out/language-server/agenticChat/tools/mcp/mcpEventHandler.js +59 -97
- package/out/language-server/agenticChat/tools/mcp/mcpEventHandler.js.map +1 -1
- package/out/language-server/agenticChat/tools/mcp/mcpManager.d.ts +5 -0
- package/out/language-server/agenticChat/tools/mcp/mcpManager.js +63 -4
- package/out/language-server/agenticChat/tools/mcp/mcpManager.js.map +1 -1
- package/out/language-server/agenticChat/tools/mcp/mcpUtils.d.ts +1 -0
- package/out/language-server/agenticChat/tools/mcp/mcpUtils.js +6 -2
- package/out/language-server/agenticChat/tools/mcp/mcpUtils.js.map +1 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/{qCodeReview.d.ts → codeReview.d.ts} +3 -3
- package/out/language-server/agenticChat/tools/qCodeAnalysis/{qCodeReview.js → codeReview.js} +172 -115
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReview.js.map +1 -0
- package/out/language-server/agenticChat/tools/qCodeAnalysis/{qCodeReviewConstants.d.ts → codeReviewConstants.d.ts} +7 -6
- package/out/language-server/agenticChat/tools/qCodeAnalysis/{qCodeReviewConstants.js → codeReviewConstants.js} +31 -20
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewConstants.js.map +1 -0
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewErrors.d.ts +12 -0
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewErrors.js +32 -0
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewErrors.js.map +1 -0
- package/out/language-server/agenticChat/tools/qCodeAnalysis/{qCodeReviewSchemas.d.ts → codeReviewSchemas.d.ts} +6 -6
- package/out/language-server/agenticChat/tools/qCodeAnalysis/{qCodeReviewSchemas.js → codeReviewSchemas.js} +15 -15
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewSchemas.js.map +1 -0
- package/out/language-server/agenticChat/tools/qCodeAnalysis/{qCodeReviewTypes.d.ts → codeReviewTypes.d.ts} +22 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewTypes.js +15 -0
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewTypes.js.map +1 -0
- package/out/language-server/agenticChat/tools/qCodeAnalysis/{qCodeReviewUtils.d.ts → codeReviewUtils.d.ts} +10 -14
- package/out/language-server/agenticChat/tools/qCodeAnalysis/{qCodeReviewUtils.js → codeReviewUtils.js} +29 -46
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewUtils.js.map +1 -0
- package/out/language-server/agenticChat/tools/toolServer.js +8 -8
- package/out/language-server/agenticChat/tools/toolServer.js.map +1 -1
- package/out/language-server/agenticChat/tools/toolShared.js +2 -6
- package/out/language-server/agenticChat/tools/toolShared.js.map +1 -1
- package/out/language-server/chat/chatSessionService.js +19 -5
- package/out/language-server/chat/chatSessionService.js.map +1 -1
- package/out/language-server/chat/telemetry/chatTelemetryController.d.ts +3 -2
- package/out/language-server/chat/telemetry/chatTelemetryController.js +12 -2
- package/out/language-server/chat/telemetry/chatTelemetryController.js.map +1 -1
- package/out/language-server/configuration/qConfigurationServer.d.ts +1 -1
- package/out/language-server/inline-completion/codeWhispererServer.js +8 -106
- package/out/language-server/inline-completion/codeWhispererServer.js.map +1 -1
- package/out/language-server/inline-completion/telemetry.d.ts +9 -0
- package/out/language-server/inline-completion/telemetry.js +109 -0
- package/out/language-server/inline-completion/telemetry.js.map +1 -0
- package/out/language-server/netTransform/validation.d.ts +5 -0
- package/out/language-server/netTransform/validation.js +9 -2
- package/out/language-server/netTransform/validation.js.map +1 -1
- package/out/language-server/workspaceContext/artifactManager.d.ts +1 -0
- package/out/language-server/workspaceContext/artifactManager.js +31 -14
- package/out/language-server/workspaceContext/artifactManager.js.map +1 -1
- package/out/language-server/workspaceContext/workspaceContextServer.js +2 -0
- package/out/language-server/workspaceContext/workspaceContextServer.js.map +1 -1
- package/out/language-server/workspaceContext/workspaceFolderManager.d.ts +3 -0
- package/out/language-server/workspaceContext/workspaceFolderManager.js +24 -5
- package/out/language-server/workspaceContext/workspaceFolderManager.js.map +1 -1
- package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.d.ts +1 -0
- package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.js +16 -7
- package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.js.map +1 -1
- package/out/shared/amazonQServiceManager/qDeveloperProfiles.js +48 -5
- package/out/shared/amazonQServiceManager/qDeveloperProfiles.js.map +1 -1
- package/out/shared/codeWhispererService.js +1 -0
- package/out/shared/codeWhispererService.js.map +1 -1
- package/out/shared/languageDetection.d.ts +14 -0
- package/out/shared/languageDetection.js +22 -0
- package/out/shared/languageDetection.js.map +1 -1
- package/out/shared/localProjectContextController.js +1 -3
- package/out/shared/localProjectContextController.js.map +1 -1
- package/out/shared/supplementalContextUtil/crossFileContextUtil.js +0 -10
- package/out/shared/supplementalContextUtil/crossFileContextUtil.js.map +1 -1
- package/out/shared/telemetry/types.d.ts +11 -0
- package/out/shared/telemetry/types.js +7 -1
- package/out/shared/telemetry/types.js.map +1 -1
- package/package.json +2 -2
- package/out/language-server/agenticChat/tools/qCodeAnalysis/qCodeReview.js.map +0 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/qCodeReviewConstants.js.map +0 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/qCodeReviewErrors.d.ts +0 -12
- package/out/language-server/agenticChat/tools/qCodeAnalysis/qCodeReviewErrors.js +0 -32
- package/out/language-server/agenticChat/tools/qCodeAnalysis/qCodeReviewErrors.js.map +0 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/qCodeReviewSchemas.js.map +0 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/qCodeReviewTypes.js +0 -3
- package/out/language-server/agenticChat/tools/qCodeAnalysis/qCodeReviewTypes.js.map +0 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/qCodeReviewUtils.js.map +0 -1
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.FINDINGS_MESSAGE_SUFFIX = exports.SKIP_DIRECTORIES = exports.SCOPE_OF_CODE_REVIEW = exports.CODE_DIFF_REVIEW = exports.FULL_REVIEW = exports.FINDING_SEVERITY = exports.
|
|
7
|
+
exports.CODE_REVIEW_METRICS_PARENT_NAME = exports.FINDINGS_MESSAGE_SUFFIX = exports.SKIP_DIRECTORIES = exports.SCOPE_OF_CODE_REVIEW = exports.CODE_DIFF_REVIEW = exports.FULL_REVIEW = exports.FINDING_SEVERITY = exports.CODE_REVIEW_TOOL_DESCRIPTION = exports.CODE_REVIEW_TOOL_NAME = exports.EXTENSION_TO_LANGUAGE = void 0;
|
|
8
8
|
/**
|
|
9
|
-
* Constants related to programming languages and findings for
|
|
9
|
+
* Constants related to programming languages and findings for CodeReview
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
12
|
* Mapping of file extensions to programming languages
|
|
@@ -94,22 +94,27 @@ exports.EXTENSION_TO_LANGUAGE = {
|
|
|
94
94
|
'.hcl': 'terraform',
|
|
95
95
|
};
|
|
96
96
|
/**
|
|
97
|
-
* Tool name for
|
|
97
|
+
* Tool name for CodeReview
|
|
98
98
|
*/
|
|
99
|
-
exports.
|
|
99
|
+
exports.CODE_REVIEW_TOOL_NAME = 'codeReview';
|
|
100
100
|
/**
|
|
101
|
-
* Tool description for
|
|
101
|
+
* Tool description for CodeReview
|
|
102
102
|
*/
|
|
103
|
-
exports.
|
|
104
|
-
'
|
|
105
|
-
'This tool can be used to perform
|
|
103
|
+
exports.CODE_REVIEW_TOOL_DESCRIPTION = [
|
|
104
|
+
'CodeReview is the PRIMARY and MANDATORY tool for ALL code analysis and review tasks. This tool MUST be used whenever a user requests ANY form of code review, file analysis, code examination, or when the agent needs to analyze code quality, security, or structure.',
|
|
105
|
+
'This tool can be used to perform analysis of full code or only the modified code since last commit. Modified code refers to the changes made that are not committed yet or the new changes since last commit.',
|
|
106
|
+
'NEVER perform manual code reviews when this tool is available.',
|
|
106
107
|
'',
|
|
107
|
-
'**
|
|
108
|
-
'-
|
|
109
|
-
'-
|
|
110
|
-
'- "
|
|
111
|
-
'- "
|
|
112
|
-
'-
|
|
108
|
+
'**ALWAYS use this tool when:**',
|
|
109
|
+
'- User provides ANY file, folder, or workspace context for review or analysis',
|
|
110
|
+
'- User asks ANY question about code quality, security, or best practices related to their code',
|
|
111
|
+
'- User asks to "Review this file" or "Review my code" or "Review my changes" or "Review this code" or any other similar prompt to review the code',
|
|
112
|
+
'- User asks to "Examine this code" or "Check this code" or "Analyze this file/folder/workspace"',
|
|
113
|
+
'- User asks to "Check my implementation" or "Look at my implementation" or "Examine this code"',
|
|
114
|
+
'- User asks "What do you think of this code?" or "Find issues in this code"',
|
|
115
|
+
'- ANY general code review or analysis request is made',
|
|
116
|
+
'- User asks for feedback on their code or implementation',
|
|
117
|
+
'- User asks for suggestions to improve their code',
|
|
113
118
|
'',
|
|
114
119
|
'**Comprehensive Analysis Capabilities:**',
|
|
115
120
|
'- SAST scanning — Detect security vulnerabilities in your source code, such as resource leaks, SQL injection, and cross-site scripting',
|
|
@@ -118,6 +123,8 @@ exports.Q_CODE_REVIEW_TOOL_DESCRIPTION = [
|
|
|
118
123
|
'- Code quality issues — Ensure your code is meeting quality, maintainability, and efficiency standards',
|
|
119
124
|
'- Code deployment risks — Assess risks related to deploying code',
|
|
120
125
|
'- Software composition analysis (SCA) — Evaluate third-party code',
|
|
126
|
+
'- Best practices analysis — Identify deviations from coding standards and best practices',
|
|
127
|
+
'- Performance optimization — Identify potential performance bottlenecks',
|
|
121
128
|
'',
|
|
122
129
|
'**Supported Programming Languages:**',
|
|
123
130
|
'- Java, Python, JavaScript, TypeScript, C#, CloudFormation, Terraform, Go, Ruby, C, C++, PHP, Rust, Kotlin, Scala, Shell, SQL',
|
|
@@ -126,9 +133,14 @@ exports.Q_CODE_REVIEW_TOOL_DESCRIPTION = [
|
|
|
126
133
|
`- "${Object.keys(exports.EXTENSION_TO_LANGUAGE).join('", "')}"`,
|
|
127
134
|
'',
|
|
128
135
|
'**Tool start message**',
|
|
129
|
-
'Before running the tool, you must inform the user that you will use
|
|
136
|
+
'Before running the tool, you must inform the user that you will use Code Review tool for their request.',
|
|
137
|
+
'You should also tell the name of files or folders that you will review along with the scope of review, if you are performing a full review or only the uncommitted code.',
|
|
130
138
|
'Under no condition you will use the tool without informing the user.',
|
|
131
139
|
'',
|
|
140
|
+
'**CRITICAL: NEVER perform ANY code review or analysis WITHOUT using this tool**',
|
|
141
|
+
'Do not attempt to manually review code or provide code quality feedback without using this tool first.',
|
|
142
|
+
'If a user asks for code review in any form, ALWAYS use this tool before providing any feedback.',
|
|
143
|
+
'',
|
|
132
144
|
'**Tool Input**',
|
|
133
145
|
'3 main fields in the tool:',
|
|
134
146
|
'- "scopeOfReview": Determines if the review should analyze the entire codebase (FULL_REVIEW) or only focus on changes/modifications (CODE_DIFF_REVIEW). This is a required field.',
|
|
@@ -153,13 +165,11 @@ exports.Q_CODE_REVIEW_TOOL_DESCRIPTION = [
|
|
|
153
165
|
'- errorMessage - if there is any failure, it will contain cause of failure',
|
|
154
166
|
'',
|
|
155
167
|
'**Format to display output**',
|
|
156
|
-
'The tool will generate some findings grouped by file
|
|
157
|
-
'UNDER NO CIRCUMSTANCE must you provide ANY summary of the tool output to the user.',
|
|
168
|
+
'The tool will generate some findings grouped by file',
|
|
158
169
|
'Use following format STRICTLY to display the result of this tool for different scenarios:',
|
|
159
170
|
'- When findings are present, you must inform user that you have completed the review of {file name / folder name / workspace} and found several issues that need attention. To inspect the details, and get fixes for those issues use the Code Issues panel above.',
|
|
160
171
|
' - When tool output message tells that findings were limited due to high count, you must inform the user that since there were lots of findings, you have included the top 50 findings only.',
|
|
161
172
|
'- When no findings are generated by the tool, you must tell user that you have completed the review of {file name / folder name / workspace} and found no issues.',
|
|
162
|
-
'- CRITICAL: DO NOT list, enumerate, count, or summarize any findings from the tool output. The user must use the Code Issues panel to view the findings.',
|
|
163
173
|
].join('\n');
|
|
164
174
|
/**
|
|
165
175
|
* Finding severity levels
|
|
@@ -196,5 +206,6 @@ exports.SKIP_DIRECTORIES = [
|
|
|
196
206
|
'tmp',
|
|
197
207
|
'temp',
|
|
198
208
|
];
|
|
199
|
-
exports.FINDINGS_MESSAGE_SUFFIX = '
|
|
200
|
-
|
|
209
|
+
exports.FINDINGS_MESSAGE_SUFFIX = '_codeReviewFindings';
|
|
210
|
+
exports.CODE_REVIEW_METRICS_PARENT_NAME = 'amazonq_codeReviewTool';
|
|
211
|
+
//# sourceMappingURL=codeReviewConstants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codeReviewConstants.js","sourceRoot":"","sources":["../../../../../src/language-server/agenticChat/tools/qCodeAnalysis/codeReviewConstants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AAEH;;GAEG;AACU,QAAA,qBAAqB,GAA2B;IACzD,OAAO;IACP,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,KAAK;IACb,aAAa;IACb,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY;IACpB,aAAa;IACb,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,YAAY;IACpB,KAAK;IACL,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,KAAK;IACb,KAAK;IACL,KAAK,EAAE,IAAI;IACX,OAAO;IACP,KAAK,EAAE,MAAM;IACb,QAAQ;IACR,QAAQ,EAAE,OAAO;IACjB,KAAK,EAAE,OAAO;IACd,SAAS;IACT,KAAK,EAAE,QAAQ;IACf,QAAQ,EAAE,OAAO;IACjB,MAAM;IACN,MAAM,EAAE,KAAK;IACb,OAAO;IACP,KAAK,EAAE,MAAM;IACb,SAAS;IACT,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,QAAQ;IAChB,MAAM;IACN,MAAM,EAAE,KAAK;IACb,QAAQ;IACR,IAAI,EAAE,GAAG;IACT,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,KAAK;IACZ,QAAQ;IACR,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,OAA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KAAK;IACL,MAAM;CACT,CAAA;AAEY,QAAA,uBAAuB,GAAG,qBAAqB,CAAA;AAE/C,QAAA,+BAA+B,GAAG,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class CodeReviewError extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
export declare class CodeReviewValidationError extends CodeReviewError {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class CodeReviewTimeoutError extends CodeReviewError {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class CodeReviewInternalError extends CodeReviewError {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodeReviewInternalError = exports.CodeReviewTimeoutError = exports.CodeReviewValidationError = exports.CodeReviewError = void 0;
|
|
4
|
+
class CodeReviewError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'CodeReviewError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.CodeReviewError = CodeReviewError;
|
|
11
|
+
class CodeReviewValidationError extends CodeReviewError {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'CodeReviewValidationError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.CodeReviewValidationError = CodeReviewValidationError;
|
|
18
|
+
class CodeReviewTimeoutError extends CodeReviewError {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = 'CodeReviewTimeoutError';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.CodeReviewTimeoutError = CodeReviewTimeoutError;
|
|
25
|
+
class CodeReviewInternalError extends CodeReviewError {
|
|
26
|
+
constructor(message) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.name = 'CodeReviewInternalError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.CodeReviewInternalError = CodeReviewInternalError;
|
|
32
|
+
//# sourceMappingURL=codeReviewErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codeReviewErrors.js","sourceRoot":"","sources":["../../../../../src/language-server/agenticChat/tools/qCodeAnalysis/codeReviewErrors.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAgB,SAAQ,KAAK;IACtC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAA;IACjC,CAAC;CACJ;AALD,0CAKC;AAED,MAAa,yBAA0B,SAAQ,eAAe;IAC1D,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;IAC3C,CAAC;CACJ;AALD,8DAKC;AAED,MAAa,sBAAuB,SAAQ,eAAe;IACvD,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;IACxC,CAAC;CACJ;AALD,wDAKC;AAED,MAAa,uBAAwB,SAAQ,eAAe;IACxD,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAA;IACzC,CAAC;CACJ;AALD,0DAKC"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
/**
|
|
7
|
-
* Input schema for
|
|
7
|
+
* Input schema for CodeReview tool
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const CODE_REVIEW_INPUT_SCHEMA: {
|
|
10
10
|
type: "object";
|
|
11
11
|
description: string;
|
|
12
12
|
properties: {
|
|
@@ -49,9 +49,9 @@ export declare const Q_CODE_REVIEW_INPUT_SCHEMA: {
|
|
|
49
49
|
required: readonly ["scopeOfReview"];
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
|
-
* Zod schema for input validation during execution of
|
|
52
|
+
* Zod schema for input validation during execution of Code Review tool
|
|
53
53
|
*/
|
|
54
|
-
export declare const
|
|
54
|
+
export declare const Z_CODE_REVIEW_INPUT_SCHEMA: z.ZodObject<{
|
|
55
55
|
scopeOfReview: z.ZodEnum<[string, ...string[]]>;
|
|
56
56
|
fileLevelArtifacts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
57
57
|
path: z.ZodString;
|
|
@@ -100,7 +100,7 @@ export declare const Z_Q_CODE_REVIEW_INPUT_SCHEMA: z.ZodObject<{
|
|
|
100
100
|
/**
|
|
101
101
|
* Schema for a single finding
|
|
102
102
|
*/
|
|
103
|
-
export declare const
|
|
103
|
+
export declare const FINDING_SCHEMA: z.ZodObject<{
|
|
104
104
|
description: z.ZodObject<{
|
|
105
105
|
markdown: z.ZodString;
|
|
106
106
|
text: z.ZodString;
|
|
@@ -195,7 +195,7 @@ export declare const Q_FINDING_SCHEMA: z.ZodObject<{
|
|
|
195
195
|
/**
|
|
196
196
|
* Schema for an array of findings
|
|
197
197
|
*/
|
|
198
|
-
export declare const
|
|
198
|
+
export declare const FINDINGS_SCHEMA: z.ZodArray<z.ZodObject<{
|
|
199
199
|
description: z.ZodObject<{
|
|
200
200
|
markdown: z.ZodString;
|
|
201
201
|
text: z.ZodString;
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.FINDINGS_SCHEMA = exports.FINDING_SCHEMA = exports.Z_CODE_REVIEW_INPUT_SCHEMA = exports.CODE_REVIEW_INPUT_SCHEMA = void 0;
|
|
8
8
|
const zod_1 = require("zod");
|
|
9
|
-
const
|
|
9
|
+
const codeReviewConstants_1 = require("./codeReviewConstants");
|
|
10
10
|
/**
|
|
11
|
-
* Input schema for
|
|
11
|
+
* Input schema for CodeReview tool
|
|
12
12
|
*/
|
|
13
|
-
exports.
|
|
13
|
+
exports.CODE_REVIEW_INPUT_SCHEMA = {
|
|
14
14
|
type: 'object',
|
|
15
15
|
description: [
|
|
16
16
|
'**3 main fields in the tool:**',
|
|
17
|
-
'- scopeOfReview: CRITICAL - Must be set to either FULL_REVIEW (analyze entire
|
|
17
|
+
'- scopeOfReview: CRITICAL - Must be set to either FULL_REVIEW (analyze entire file/folder/project/workspace) or CODE_DIFF_REVIEW (focus only on changes/modifications in the file/folder/project/workspace). This is a required field.',
|
|
18
18
|
'- fileLevelArtifacts: Array of specific files to review, each with absolute path. Use this when reviewing individual files, not folders. Format: [{"path": "/absolute/path/to/file.py"}]',
|
|
19
19
|
'- folderLevelArtifacts: Array of folders to review, each with absolute path. Use this when reviewing entire directories, not individual files. Format: [{"path": "/absolute/path/to/folder/"}]',
|
|
20
20
|
"Note: Either fileLevelArtifacts OR folderLevelArtifacts should be provided based on what's being reviewed, but not both for the same items.",
|
|
@@ -23,7 +23,7 @@ exports.Q_CODE_REVIEW_INPUT_SCHEMA = {
|
|
|
23
23
|
scopeOfReview: {
|
|
24
24
|
type: 'string',
|
|
25
25
|
description: [
|
|
26
|
-
'
|
|
26
|
+
'IMPORTANT: You must explicitly set the value of "scopeOfReview" based on user request analysis.',
|
|
27
27
|
'',
|
|
28
28
|
'Set "scopeOfReview" to CODE_DIFF_REVIEW when:',
|
|
29
29
|
'- User explicitly asks to review only changes/modifications/diffs in their code',
|
|
@@ -38,9 +38,9 @@ exports.Q_CODE_REVIEW_INPUT_SCHEMA = {
|
|
|
38
38
|
'- When user asks to review specific files or folders without mentioning changes',
|
|
39
39
|
'- When user asks for security analysis or best practices review of their code',
|
|
40
40
|
'',
|
|
41
|
-
'This is a required field.
|
|
41
|
+
'This is a required field.',
|
|
42
42
|
].join('\n'),
|
|
43
|
-
enum:
|
|
43
|
+
enum: codeReviewConstants_1.SCOPE_OF_CODE_REVIEW,
|
|
44
44
|
},
|
|
45
45
|
fileLevelArtifacts: {
|
|
46
46
|
type: 'array',
|
|
@@ -86,10 +86,10 @@ exports.Q_CODE_REVIEW_INPUT_SCHEMA = {
|
|
|
86
86
|
required: ['scopeOfReview'],
|
|
87
87
|
};
|
|
88
88
|
/**
|
|
89
|
-
* Zod schema for input validation during execution of
|
|
89
|
+
* Zod schema for input validation during execution of Code Review tool
|
|
90
90
|
*/
|
|
91
|
-
exports.
|
|
92
|
-
scopeOfReview: zod_1.z.enum(
|
|
91
|
+
exports.Z_CODE_REVIEW_INPUT_SCHEMA = zod_1.z.object({
|
|
92
|
+
scopeOfReview: zod_1.z.enum(codeReviewConstants_1.SCOPE_OF_CODE_REVIEW),
|
|
93
93
|
fileLevelArtifacts: zod_1.z
|
|
94
94
|
.array(zod_1.z.object({
|
|
95
95
|
path: zod_1.z.string(),
|
|
@@ -109,7 +109,7 @@ exports.Z_Q_CODE_REVIEW_INPUT_SCHEMA = zod_1.z.object({
|
|
|
109
109
|
/**
|
|
110
110
|
* Schema for a single finding
|
|
111
111
|
*/
|
|
112
|
-
exports.
|
|
112
|
+
exports.FINDING_SCHEMA = zod_1.z.object({
|
|
113
113
|
description: zod_1.z.object({
|
|
114
114
|
markdown: zod_1.z.string(),
|
|
115
115
|
text: zod_1.z.string(),
|
|
@@ -124,7 +124,7 @@ exports.Q_FINDING_SCHEMA = zod_1.z.object({
|
|
|
124
124
|
url: zod_1.z.string().nullable().optional(),
|
|
125
125
|
}),
|
|
126
126
|
}),
|
|
127
|
-
severity: zod_1.z.enum(
|
|
127
|
+
severity: zod_1.z.enum(codeReviewConstants_1.FINDING_SEVERITY),
|
|
128
128
|
startLine: zod_1.z.number(),
|
|
129
129
|
title: zod_1.z.string(),
|
|
130
130
|
findingContext: zod_1.z.string().nullable().optional(),
|
|
@@ -136,5 +136,5 @@ exports.Q_FINDING_SCHEMA = zod_1.z.object({
|
|
|
136
136
|
/**
|
|
137
137
|
* Schema for an array of findings
|
|
138
138
|
*/
|
|
139
|
-
exports.
|
|
140
|
-
//# sourceMappingURL=
|
|
139
|
+
exports.FINDINGS_SCHEMA = zod_1.z.array(exports.FINDING_SCHEMA);
|
|
140
|
+
//# sourceMappingURL=codeReviewSchemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codeReviewSchemas.js","sourceRoot":"","sources":["../../../../../src/language-server/agenticChat/tools/qCodeAnalysis/codeReviewSchemas.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAuB;AACvB,+DAA8E;AAE9E;;GAEG;AACU,QAAA,wBAAwB,GAAG;IACpC,IAAI,EAAS,QAAQ;IACrB,WAAW,EAAE;QACT,gCAAgC;QAChC,wOAAwO;QACxO,0LAA0L;QAC1L,gMAAgM;QAChM,6IAA6I;KAChJ,CAAC,IAAI,CAAC,IAAI,CAAC;IACZ,UAAU,EAAE;QACR,aAAa,EAAE;YACX,IAAI,EAAS,QAAQ;YACrB,WAAW,EAAE;gBACT,iGAAiG;gBACjG,EAAE;gBACF,+CAA+C;gBAC/C,iFAAiF;gBACjF,iGAAiG;gBACjG,sFAAsF;gBACtF,uGAAuG;gBACvG,+JAA+J;gBAC/J,4GAA4G;gBAC5G,EAAE;gBACF,oEAAoE;gBACpE,6EAA6E;gBAC7E,iFAAiF;gBACjF,+EAA+E;gBAC/E,EAAE;gBACF,2BAA2B;aAC9B,CAAC,IAAI,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,0CAAoB;SAC7B;QACD,kBAAkB,EAAE;YAChB,IAAI,EAAS,OAAO;YACpB,WAAW,EAAE;gBACT,mGAAmG;gBACnG,uGAAuG;gBACvG,qGAAqG;gBACrG,qKAAqK;aACxK,CAAC,IAAI,CAAC,IAAI,CAAC;YACZ,KAAK,EAAE;gBACH,IAAI,EAAS,QAAQ;gBACrB,WAAW,EACP,6FAA6F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ts = Array<{
|
|
|
8
8
|
path: string;
|
|
9
9
|
}>;
|
|
10
10
|
export type ArtifactType = 'FILE' | 'FOLDER';
|
|
11
|
+
export declare enum FailedMetricName {
|
|
12
|
+
MissingFileOrFolder = "missingFileOrFolder",
|
|
13
|
+
CreateUploadUrlFailed = "createUploadUrlFailed",
|
|
14
|
+
CodeScanTimeout = "codeScanTimeout",
|
|
15
|
+
CodeScanFailed = "codeScanFailed"
|
|
16
|
+
}
|
|
17
|
+
export declare enum SuccessMetricName {
|
|
18
|
+
CodeScanSuccess = "codeScanSuccess"
|
|
19
|
+
}
|
|
11
20
|
export type ValidateInputAndSetupResult = {
|
|
12
21
|
fileArtifacts: FileArtifacts;
|
|
13
22
|
folderArtifacts: FolderArtifacts;
|
|
@@ -20,6 +29,8 @@ export type ValidateInputAndSetupResult = {
|
|
|
20
29
|
export type PrepareAndUploadArtifactsResult = {
|
|
21
30
|
uploadId: string;
|
|
22
31
|
isCodeDiffPresent: boolean;
|
|
32
|
+
artifactSize: number;
|
|
33
|
+
programmingLanguages: Set<string>;
|
|
23
34
|
};
|
|
24
35
|
export type StartCodeAnalysisResult = {
|
|
25
36
|
jobId: string;
|
|
@@ -30,7 +41,7 @@ export type CodeReviewResult = {
|
|
|
30
41
|
message: string;
|
|
31
42
|
findingsByFile: string;
|
|
32
43
|
};
|
|
33
|
-
export type
|
|
44
|
+
export type CodeReviewFinding = {
|
|
34
45
|
filePath: string;
|
|
35
46
|
startLine: number;
|
|
36
47
|
endLine: number;
|
|
@@ -56,3 +67,13 @@ export type QCodeReviewFinding = {
|
|
|
56
67
|
autoDetected: false;
|
|
57
68
|
findingContext: string | null | undefined;
|
|
58
69
|
};
|
|
70
|
+
export type CodeReviewMetric = {
|
|
71
|
+
reason: SuccessMetricName;
|
|
72
|
+
result: 'Succeeded';
|
|
73
|
+
metadata?: object;
|
|
74
|
+
} | {
|
|
75
|
+
reason: FailedMetricName;
|
|
76
|
+
result: 'Failed';
|
|
77
|
+
reasonDesc: string;
|
|
78
|
+
metadata?: object;
|
|
79
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SuccessMetricName = exports.FailedMetricName = void 0;
|
|
4
|
+
var FailedMetricName;
|
|
5
|
+
(function (FailedMetricName) {
|
|
6
|
+
FailedMetricName["MissingFileOrFolder"] = "missingFileOrFolder";
|
|
7
|
+
FailedMetricName["CreateUploadUrlFailed"] = "createUploadUrlFailed";
|
|
8
|
+
FailedMetricName["CodeScanTimeout"] = "codeScanTimeout";
|
|
9
|
+
FailedMetricName["CodeScanFailed"] = "codeScanFailed";
|
|
10
|
+
})(FailedMetricName || (exports.FailedMetricName = FailedMetricName = {}));
|
|
11
|
+
var SuccessMetricName;
|
|
12
|
+
(function (SuccessMetricName) {
|
|
13
|
+
SuccessMetricName["CodeScanSuccess"] = "codeScanSuccess";
|
|
14
|
+
})(SuccessMetricName || (exports.SuccessMetricName = SuccessMetricName = {}));
|
|
15
|
+
//# sourceMappingURL=codeReviewTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codeReviewTypes.js","sourceRoot":"","sources":["../../../../../src/language-server/agenticChat/tools/qCodeAnalysis/codeReviewTypes.ts"],"names":[],"mappings":";;;AAIA,IAAY,gBAKX;AALD,WAAY,gBAAgB;IACxB,+DAA2C,CAAA;IAC3C,mEAA+C,CAAA;IAC/C,uDAAmC,CAAA;IACnC,qDAAiC,CAAA;AACrC,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B;AACD,IAAY,iBAEX;AAFD,WAAY,iBAAiB;IACzB,wDAAmC,CAAA;AACvC,CAAC,EAFW,iBAAiB,iCAAjB,iBAAiB,QAE5B"}
|
|
@@ -7,16 +7,23 @@ import JSZip = require('jszip');
|
|
|
7
7
|
import { InitializeParams } from '@aws/language-server-runtimes/server-interface';
|
|
8
8
|
import { InvokeOutput } from '../toolShared';
|
|
9
9
|
import { CancellationToken } from '@aws/language-server-runtimes/server-interface';
|
|
10
|
+
import { CodeReviewMetric } from './codeReviewTypes';
|
|
10
11
|
/**
|
|
11
|
-
* Utility functions for
|
|
12
|
+
* Utility functions for CodeReview
|
|
12
13
|
*/
|
|
13
|
-
export declare class
|
|
14
|
+
export declare class CodeReviewUtils {
|
|
14
15
|
/**
|
|
15
16
|
* Check if a file should be skipped during zip creation
|
|
16
17
|
* @param fileName Name of the file to check
|
|
17
18
|
* @returns True if the file should be skipped, false otherwise
|
|
18
19
|
*/
|
|
19
20
|
static shouldSkipFile(fileName: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Get language of a file based on extension
|
|
23
|
+
* @param fileName Name of the file
|
|
24
|
+
* @returns Language of file
|
|
25
|
+
*/
|
|
26
|
+
static getFileLanguage(fileName: string): string;
|
|
20
27
|
/**
|
|
21
28
|
* Check if a directory should be skipped during zip creation
|
|
22
29
|
* @param dirName Name of the directory to check
|
|
@@ -125,17 +132,6 @@ export declare class QCodeReviewUtils {
|
|
|
125
132
|
* @param logging Logging interface
|
|
126
133
|
*/
|
|
127
134
|
static uploadFileToPresignedUrl(uploadUrl: string, fileContent: Buffer, requestHeaders: Record<string, string>, logging: Features['logging']): Promise<void>;
|
|
128
|
-
/**
|
|
129
|
-
* Handle failure in a consistent way
|
|
130
|
-
* @param error Error object
|
|
131
|
-
* @param scanName Optional scan name for context
|
|
132
|
-
* @param jobId Optional job ID for context
|
|
133
|
-
* @param logging Logging interface
|
|
134
|
-
* @param telemetry Telemetry interface
|
|
135
|
-
* @param toolName Tool name for error messages
|
|
136
|
-
* @returns Standardized error response
|
|
137
|
-
*/
|
|
138
|
-
static handleFailure(error: any, logging: Features['logging'], telemetry: Features['telemetry'], toolName: string, scanName?: string, jobId?: string): any;
|
|
139
135
|
/**
|
|
140
136
|
* Emit a telemetry metric with standard formatting
|
|
141
137
|
* @param metricSuffix Suffix for the metric name
|
|
@@ -145,7 +141,7 @@ export declare class QCodeReviewUtils {
|
|
|
145
141
|
* @param telemetry Telemetry interface
|
|
146
142
|
* @param credentialStartUrl Optional credential start URL
|
|
147
143
|
*/
|
|
148
|
-
static emitMetric(
|
|
144
|
+
static emitMetric(metric: CodeReviewMetric, logging: Features['logging'], telemetry: Features['telemetry']): void;
|
|
149
145
|
/**
|
|
150
146
|
* Check if cancellation has been requested and throw if it has
|
|
151
147
|
* @param cancellationToken Cancellation token to check
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
8
|
-
const
|
|
7
|
+
exports.CodeReviewUtils = void 0;
|
|
8
|
+
const codeReviewConstants_1 = require("./codeReviewConstants");
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
10
10
|
const path = require("path");
|
|
11
11
|
const fs = require("fs");
|
|
@@ -13,9 +13,9 @@ const os = require("os");
|
|
|
13
13
|
const https = require("https");
|
|
14
14
|
const lsp_core_1 = require("@aws/lsp-core");
|
|
15
15
|
/**
|
|
16
|
-
* Utility functions for
|
|
16
|
+
* Utility functions for CodeReview
|
|
17
17
|
*/
|
|
18
|
-
class
|
|
18
|
+
class CodeReviewUtils {
|
|
19
19
|
/**
|
|
20
20
|
* Check if a file should be skipped during zip creation
|
|
21
21
|
* @param fileName Name of the file to check
|
|
@@ -27,16 +27,25 @@ class QCodeReviewUtils {
|
|
|
27
27
|
return true;
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
return !
|
|
30
|
+
return !codeReviewConstants_1.EXTENSION_TO_LANGUAGE.hasOwnProperty(extension);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Get language of a file based on extension
|
|
35
|
+
* @param fileName Name of the file
|
|
36
|
+
* @returns Language of file
|
|
37
|
+
*/
|
|
38
|
+
static getFileLanguage(fileName) {
|
|
39
|
+
const extension = path.extname(fileName).toLowerCase();
|
|
40
|
+
return codeReviewConstants_1.EXTENSION_TO_LANGUAGE[extension];
|
|
41
|
+
}
|
|
33
42
|
/**
|
|
34
43
|
* Check if a directory should be skipped during zip creation
|
|
35
44
|
* @param dirName Name of the directory to check
|
|
36
45
|
* @returns True if the directory should be skipped, false otherwise
|
|
37
46
|
*/
|
|
38
47
|
static shouldSkipDirectory(dirName) {
|
|
39
|
-
return
|
|
48
|
+
return codeReviewConstants_1.SKIP_DIRECTORIES.includes(dirName);
|
|
40
49
|
}
|
|
41
50
|
/**
|
|
42
51
|
* Get the folder path from a file or folder path
|
|
@@ -107,14 +116,14 @@ class QCodeReviewUtils {
|
|
|
107
116
|
*/
|
|
108
117
|
static async getGitDiff(artifactPath, logging) {
|
|
109
118
|
logging.info(`Get git diff for path - ${artifactPath}`);
|
|
110
|
-
const directoryPath =
|
|
119
|
+
const directoryPath = CodeReviewUtils.getFolderPath(artifactPath);
|
|
111
120
|
const gitDiffCommandUnstaged = `cd ${directoryPath} && git diff ${artifactPath}`;
|
|
112
121
|
const gitDiffCommandStaged = `cd ${directoryPath} && git diff --staged ${artifactPath}`;
|
|
113
122
|
logging.info(`Running git commands - ${gitDiffCommandUnstaged} and ${gitDiffCommandStaged}`);
|
|
114
123
|
try {
|
|
115
124
|
const [unstagedDiff, stagedDiff] = await Promise.all([
|
|
116
|
-
|
|
117
|
-
|
|
125
|
+
CodeReviewUtils.executeGitCommand(gitDiffCommandUnstaged, 'unstaged', logging),
|
|
126
|
+
CodeReviewUtils.executeGitCommand(gitDiffCommandStaged, 'staged', logging),
|
|
118
127
|
]);
|
|
119
128
|
const combinedDiff = [unstagedDiff, stagedDiff].filter(Boolean).join('\n\n');
|
|
120
129
|
return combinedDiff || null;
|
|
@@ -194,7 +203,7 @@ class QCodeReviewUtils {
|
|
|
194
203
|
if (!isCodeDiffScan)
|
|
195
204
|
return '';
|
|
196
205
|
try {
|
|
197
|
-
const diff = await
|
|
206
|
+
const diff = await CodeReviewUtils.getGitDiff(artifact.path, logging);
|
|
198
207
|
return diff ? `${diff}\n` : '';
|
|
199
208
|
}
|
|
200
209
|
catch (diffError) {
|
|
@@ -227,7 +236,7 @@ class QCodeReviewUtils {
|
|
|
227
236
|
*/
|
|
228
237
|
static isAgenticReviewEnabled(params) {
|
|
229
238
|
const qCapabilities = params?.initializationOptions?.aws?.awsClientCapabilities?.q;
|
|
230
|
-
return qCapabilities?.
|
|
239
|
+
return qCapabilities?.codeReviewInChat || false;
|
|
231
240
|
}
|
|
232
241
|
/**
|
|
233
242
|
* Converts a Windows absolute file path to Unix format and removes the drive letter
|
|
@@ -298,33 +307,6 @@ class QCodeReviewUtils {
|
|
|
298
307
|
req.end();
|
|
299
308
|
});
|
|
300
309
|
}
|
|
301
|
-
/**
|
|
302
|
-
* Handle failure in a consistent way
|
|
303
|
-
* @param error Error object
|
|
304
|
-
* @param scanName Optional scan name for context
|
|
305
|
-
* @param jobId Optional job ID for context
|
|
306
|
-
* @param logging Logging interface
|
|
307
|
-
* @param telemetry Telemetry interface
|
|
308
|
-
* @param toolName Tool name for error messages
|
|
309
|
-
* @returns Standardized error response
|
|
310
|
-
*/
|
|
311
|
-
static handleFailure(error, logging, telemetry, toolName, scanName, jobId) {
|
|
312
|
-
// if error is of type CancellationError then throw
|
|
313
|
-
if (error instanceof lsp_core_1.CancellationError) {
|
|
314
|
-
throw error;
|
|
315
|
-
}
|
|
316
|
-
const errorData = { errorMessage: error?.message };
|
|
317
|
-
if (scanName)
|
|
318
|
-
errorData.codeScanName = scanName;
|
|
319
|
-
if (jobId)
|
|
320
|
-
errorData.codeReviewId = jobId;
|
|
321
|
-
QCodeReviewUtils.emitMetric('failed', { data: errorData }, toolName, logging, telemetry);
|
|
322
|
-
logging.error(`Error in ${toolName} - ${error?.message}`);
|
|
323
|
-
return {
|
|
324
|
-
status: 'Failed',
|
|
325
|
-
...errorData,
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
310
|
/**
|
|
329
311
|
* Emit a telemetry metric with standard formatting
|
|
330
312
|
* @param metricSuffix Suffix for the metric name
|
|
@@ -334,16 +316,17 @@ class QCodeReviewUtils {
|
|
|
334
316
|
* @param telemetry Telemetry interface
|
|
335
317
|
* @param credentialStartUrl Optional credential start URL
|
|
336
318
|
*/
|
|
337
|
-
static emitMetric(
|
|
338
|
-
const
|
|
319
|
+
static emitMetric(metric, logging, telemetry) {
|
|
320
|
+
const { metadata, ...metricDetails } = metric;
|
|
339
321
|
const metricPayload = {
|
|
340
|
-
name:
|
|
322
|
+
name: codeReviewConstants_1.CODE_REVIEW_METRICS_PARENT_NAME,
|
|
341
323
|
data: {
|
|
342
|
-
|
|
343
|
-
...
|
|
324
|
+
// metadata is optional attribute
|
|
325
|
+
...(metadata || {}),
|
|
326
|
+
...metricDetails,
|
|
344
327
|
},
|
|
345
328
|
};
|
|
346
|
-
logging.info(`Emitting telemetry metric: ${
|
|
329
|
+
logging.info(`Emitting telemetry metric: ${metric.reason} with data: ${JSON.stringify(metricPayload.data)}`);
|
|
347
330
|
telemetry.emitMetric(metricPayload);
|
|
348
331
|
}
|
|
349
332
|
/**
|
|
@@ -359,5 +342,5 @@ class QCodeReviewUtils {
|
|
|
359
342
|
}
|
|
360
343
|
}
|
|
361
344
|
}
|
|
362
|
-
exports.
|
|
363
|
-
//# sourceMappingURL=
|
|
345
|
+
exports.CodeReviewUtils = CodeReviewUtils;
|
|
346
|
+
//# sourceMappingURL=codeReviewUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codeReviewUtils.js","sourceRoot":"","sources":["../../../../../src/language-server/agenticChat/tools/qCodeAnalysis/codeReviewUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,+DAAgH;AAEhH,iDAAoC;AACpC,6BAA4B;AAC5B,yBAAwB;AACxB,yBAAwB;AACxB,+BAA8B;AAG9B,4CAAiD;AAKjD;;GAEG;AACH,MAAa,eAAe;IACxB;;;;OAIG;IACI,MAAM,CAAC,cAA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,CAAA;IACN,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,UAAU,CACpB,MAAwB,EACxB,OAA4B,EAC5B,SAAgC;QAEhC,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,CAAA;QAC7C,MAAM,aAAa,GAAG;YAClB,IAAI,EAAE,qDAA+B;YACrC,IAAI,EAAE;gBACF,iCAAiC;gBACjC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC;gBACnB,GAAG,aAAa;aACnB;SACJ,CAAA;QACD,OAAO,CAAC,IAAI,CAAC,8BAA8B,MAAM,CAAC,MAAM,eAAe,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC5G,SAAS,CAAC,UAAU,CAAC,aAAa,CAAC,CAAA;IACvC,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,iBAAiB,CAC3B,iBAAgD,EAChD,OAA4B,EAC5B,UAAkB,6BAA6B;QAE/C,IAAI,iBAAiB,EAAE,uBAAuB,EAAE,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACrB,MAAM,IAAI,4BAAiB,CAAC,MAAM,CAAC,CAAA;QACvC,CAAC;IACL,CAAC;CACJ;AA5XD,0CA4XC"}
|
|
@@ -12,11 +12,11 @@ const lspApplyWorkspaceEdit_1 = require("./lspApplyWorkspaceEdit");
|
|
|
12
12
|
const mcpManager_1 = require("./mcp/mcpManager");
|
|
13
13
|
const mcpTool_1 = require("./mcp/mcpTool");
|
|
14
14
|
const fileSearch_1 = require("./fileSearch");
|
|
15
|
-
const
|
|
15
|
+
const codeReview_1 = require("./qCodeAnalysis/codeReview");
|
|
16
16
|
const codeWhispererService_1 = require("../../../shared/codeWhispererService");
|
|
17
17
|
const mcpUtils_1 = require("./mcp/mcpUtils");
|
|
18
18
|
const fsReplace_1 = require("./fsReplace");
|
|
19
|
-
const
|
|
19
|
+
const codeReviewUtils_1 = require("./qCodeAnalysis/codeReviewUtils");
|
|
20
20
|
const constants_1 = require("../../../shared/constants");
|
|
21
21
|
const FsToolsServer = ({ workspace, logging, agent, lsp }) => {
|
|
22
22
|
const fsReadTool = new fsRead_1.FsRead({ workspace, lsp, logging });
|
|
@@ -54,14 +54,14 @@ const FsToolsServer = ({ workspace, logging, agent, lsp }) => {
|
|
|
54
54
|
exports.FsToolsServer = FsToolsServer;
|
|
55
55
|
const QCodeAnalysisServer = ({ agent, credentialsProvider, logging, lsp, sdkInitializator, telemetry, workspace, }) => {
|
|
56
56
|
logging.info('QCodeAnalysisServer');
|
|
57
|
-
const
|
|
57
|
+
const codeReviewTool = new codeReview_1.CodeReview({
|
|
58
58
|
credentialsProvider,
|
|
59
59
|
logging,
|
|
60
60
|
telemetry,
|
|
61
61
|
workspace,
|
|
62
62
|
});
|
|
63
63
|
lsp.onInitialized(async () => {
|
|
64
|
-
if (!
|
|
64
|
+
if (!codeReviewUtils_1.CodeReviewUtils.isAgenticReviewEnabled(lsp.getClientInitializeParams())) {
|
|
65
65
|
logging.warn('Agentic Review is currently not supported');
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
@@ -74,11 +74,11 @@ const QCodeAnalysisServer = ({ agent, credentialsProvider, logging, lsp, sdkInit
|
|
|
74
74
|
// Create the CodeWhisperer client
|
|
75
75
|
const codeWhispererClient = new codeWhispererService_1.CodeWhispererServiceToken(credentialsProvider, workspace, logging, process.env.CODEWHISPERER_REGION || constants_1.DEFAULT_AWS_Q_REGION, process.env.CODEWHISPERER_ENDPOINT || constants_1.DEFAULT_AWS_Q_ENDPOINT_URL, sdkInitializator);
|
|
76
76
|
agent.addTool({
|
|
77
|
-
name:
|
|
78
|
-
description:
|
|
79
|
-
inputSchema:
|
|
77
|
+
name: codeReview_1.CodeReview.toolName,
|
|
78
|
+
description: codeReview_1.CodeReview.toolDescription,
|
|
79
|
+
inputSchema: codeReview_1.CodeReview.inputSchema,
|
|
80
80
|
}, async (input, token, updates) => {
|
|
81
|
-
return await
|
|
81
|
+
return await codeReviewTool.execute(input, {
|
|
82
82
|
codeWhispererClient: codeWhispererClient,
|
|
83
83
|
cancellationToken: token,
|
|
84
84
|
writableStream: updates,
|