@aws/lsp-codewhisperer 0.0.82 → 0.0.83

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/out/language-server/agenticChat/agenticChatController.js +44 -27
  3. package/out/language-server/agenticChat/agenticChatController.js.map +1 -1
  4. package/out/language-server/agenticChat/constants/constants.d.ts +7 -0
  5. package/out/language-server/agenticChat/constants/constants.js +13 -1
  6. package/out/language-server/agenticChat/constants/constants.js.map +1 -1
  7. package/out/language-server/agenticChat/context/memorybank/memoryBankController.js +4 -3
  8. package/out/language-server/agenticChat/context/memorybank/memoryBankController.js.map +1 -1
  9. package/out/language-server/agenticChat/tools/chatDb/chatDb.d.ts +3 -25
  10. package/out/language-server/agenticChat/tools/chatDb/chatDb.js +12 -107
  11. package/out/language-server/agenticChat/tools/chatDb/chatDb.js.map +1 -1
  12. package/out/language-server/agenticChat/tools/chatDb/util.js +1 -2
  13. package/out/language-server/agenticChat/tools/chatDb/util.js.map +1 -1
  14. package/out/language-server/agenticChat/tools/fsRead.d.ts +3 -1
  15. package/out/language-server/agenticChat/tools/fsRead.js +12 -7
  16. package/out/language-server/agenticChat/tools/fsRead.js.map +1 -1
  17. package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReview.js +30 -14
  18. package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReview.js.map +1 -1
  19. package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewConstants.js +1 -1
  20. package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewConstants.js.map +1 -1
  21. package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewTypes.d.ts +8 -0
  22. package/out/language-server/chat/chatSessionService.d.ts +1 -1
  23. package/out/language-server/chat/chatSessionService.js +1 -1
  24. package/out/language-server/chat/chatSessionService.js.map +1 -1
  25. package/out/language-server/chat/telemetry/chatTelemetryController.d.ts +1 -1
  26. package/out/language-server/chat/telemetry/chatTelemetryController.js +1 -1
  27. package/out/language-server/chat/telemetry/chatTelemetryController.js.map +1 -1
  28. package/out/language-server/inline-completion/codeWhispererServer.js +7 -7
  29. package/out/language-server/inline-completion/codeWhispererServer.js.map +1 -1
  30. package/out/language-server/inline-completion/contants/constants.js.map +1 -0
  31. package/out/language-server/inline-completion/editCompletionHandler.js +2 -2
  32. package/out/language-server/inline-completion/editCompletionHandler.js.map +1 -1
  33. package/out/language-server/inline-completion/{telemetry.d.ts → telemetry/telemetry.d.ts} +2 -2
  34. package/out/language-server/inline-completion/{telemetry.js → telemetry/telemetry.js} +2 -2
  35. package/out/language-server/inline-completion/telemetry/telemetry.js.map +1 -0
  36. package/out/language-server/inline-completion/{codeDiffTracker.d.ts → tracker/codeDiffTracker.d.ts} +2 -2
  37. package/out/language-server/inline-completion/{codeDiffTracker.js → tracker/codeDiffTracker.js} +1 -1
  38. package/out/language-server/inline-completion/tracker/codeDiffTracker.js.map +1 -0
  39. package/out/language-server/inline-completion/tracker/codeEditTracker.js +1 -1
  40. package/out/language-server/inline-completion/tracker/codeEditTracker.js.map +1 -1
  41. package/out/language-server/inline-completion/{codePercentage.d.ts → tracker/codePercentageTracker.d.ts} +1 -1
  42. package/out/language-server/inline-completion/{codePercentage.js → tracker/codePercentageTracker.js} +1 -1
  43. package/out/language-server/inline-completion/tracker/codePercentageTracker.js.map +1 -0
  44. package/out/language-server/inline-completion/{diffUtils.d.ts → utils/diffUtils.d.ts} +1 -1
  45. package/out/language-server/inline-completion/{diffUtils.js → utils/diffUtils.js} +1 -1
  46. package/out/language-server/inline-completion/utils/diffUtils.js.map +1 -0
  47. package/out/language-server/inline-completion/{mergeRightUtils.d.ts → utils/mergeRightUtils.d.ts} +3 -11
  48. package/out/language-server/inline-completion/utils/mergeRightUtils.js +95 -0
  49. package/out/language-server/inline-completion/utils/mergeRightUtils.js.map +1 -0
  50. package/out/language-server/netTransform/artifactManager.d.ts +2 -2
  51. package/out/language-server/netTransform/artifactManager.js +6 -10
  52. package/out/language-server/netTransform/artifactManager.js.map +1 -1
  53. package/out/shared/amazonQServiceManager/AmazonQIAMServiceManager.d.ts +1 -1
  54. package/out/shared/amazonQServiceManager/AmazonQIAMServiceManager.js +8 -2
  55. package/out/shared/amazonQServiceManager/AmazonQIAMServiceManager.js.map +1 -1
  56. package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.js +1 -0
  57. package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.js.map +1 -1
  58. package/out/shared/amazonQServiceManager/BaseAmazonQServiceManager.js +6 -0
  59. package/out/shared/amazonQServiceManager/BaseAmazonQServiceManager.js.map +1 -1
  60. package/out/shared/codeWhispererService.js +33 -2
  61. package/out/shared/codeWhispererService.js.map +1 -1
  62. package/out/shared/streamingClientService.d.ts +1 -0
  63. package/out/shared/streamingClientService.js +20 -3
  64. package/out/shared/streamingClientService.js.map +1 -1
  65. package/out/shared/testUtils.d.ts +0 -3
  66. package/out/shared/testUtils.js +1 -22
  67. package/out/shared/testUtils.js.map +1 -1
  68. package/out/shared/utils.d.ts +1 -1
  69. package/out/shared/utils.js +5 -1
  70. package/out/shared/utils.js.map +1 -1
  71. package/package.json +3 -4
  72. package/out/language-server/inline-completion/codeDiffTracker.js.map +0 -1
  73. package/out/language-server/inline-completion/codePercentage.js.map +0 -1
  74. package/out/language-server/inline-completion/constants.js.map +0 -1
  75. package/out/language-server/inline-completion/diffUtils.js.map +0 -1
  76. package/out/language-server/inline-completion/mergeRightUtils.js +0 -114
  77. package/out/language-server/inline-completion/mergeRightUtils.js.map +0 -1
  78. package/out/language-server/inline-completion/telemetry.js.map +0 -1
  79. /package/out/language-server/inline-completion/{constants.d.ts → contants/constants.d.ts} +0 -0
  80. /package/out/language-server/inline-completion/{constants.js → contants/constants.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.83](https://github.com/aws/language-servers/compare/lsp-codewhisperer/v0.0.82...lsp-codewhisperer/v0.0.83) (2025-10-01)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **amazonq:** escaping user input to mitigate xss issue ([#2360](https://github.com/aws/language-servers/issues/2360)) ([45b86be](https://github.com/aws/language-servers/commit/45b86bef1a93cf9ced6fbf0c222cf5410de04c81))
9
+ * **amazonq:** fix to add opt-out header to streaming client ([#2365](https://github.com/aws/language-servers/issues/2365)) ([692e77b](https://github.com/aws/language-servers/commit/692e77bc99770ac7d676928e95e3dc43bb91e7f0))
10
+ * **amazonq:** handle IAM credentials expiration field to be aws sdk versions compatible and add refresh logic to codewhisperer IAM client ([#2349](https://github.com/aws/language-servers/issues/2349)) ([5eb3768](https://github.com/aws/language-servers/commit/5eb3768bf020d61d0ade767d62e13839048146e4))
11
+ * **amazonq:** send full finding details to plugin, partial to agent ([#2356](https://github.com/aws/language-servers/issues/2356)) ([961e6ca](https://github.com/aws/language-servers/commit/961e6ca11b122481685f9f65b3da14c6a2497cc4))
12
+ * improve history management ([#2312](https://github.com/aws/language-servers/issues/2312)) ([#2357](https://github.com/aws/language-servers/issues/2357)) ([e7aa2a6](https://github.com/aws/language-servers/commit/e7aa2a6545bcb1a8238abfde69a05432be0b6615))
13
+ * optimize memory bank token usage and add new tab support ([#2366](https://github.com/aws/language-servers/issues/2366)) ([3057d56](https://github.com/aws/language-servers/commit/3057d56e4a3047d1715d6e3560e9f934d1de469c))
14
+ * private package mapping during artifact generation ([#2348](https://github.com/aws/language-servers/issues/2348)) ([d56bfa1](https://github.com/aws/language-servers/commit/d56bfa191954fac8068e2bf390c2d0b88ef8b168))
15
+ * trim new line when emitting error message ([#2359](https://github.com/aws/language-servers/issues/2359)) ([d8733a7](https://github.com/aws/language-servers/commit/d8733a75487f74815302b838802eccbf3ffec55e))
16
+
17
+
18
+ ### Reverts
19
+
20
+ * fix to add opt-out header to streaming client ([#2365](https://github.com/aws/language-servers/issues/2365)) ([#2370](https://github.com/aws/language-servers/issues/2370)) ([b29478f](https://github.com/aws/language-servers/commit/b29478fa1ecc58e331ff330ff79f46b0d8c38d9e))
21
+
22
+
23
+ ### Dependencies
24
+
25
+ * The following workspace dependencies were updated
26
+ * dependencies
27
+ * @aws/lsp-core bumped from ^0.0.15 to ^0.0.16
28
+
3
29
  ## [0.0.82](https://github.com/aws/language-servers/compare/lsp-codewhisperer/v0.0.81...lsp-codewhisperer/v0.0.82) (2025-09-24)
4
30
 
5
31
 
@@ -66,7 +66,6 @@ const activeUserTracker_1 = require("../../shared/activeUserTracker");
66
66
  const displayFindings_1 = require("./tools/qCodeAnalysis/displayFindings");
67
67
  const constants_3 = require("../../shared/constants");
68
68
  const IdleWorkspaceManager_1 = require("../workspaceContext/IdleWorkspaceManager");
69
- const escapeHTML = require("escape-html");
70
69
  const semanticSearch_1 = require("./tools/workspaceContext/semanticSearch");
71
70
  const memoryBankController_1 = require("./context/memorybank/memoryBankController");
72
71
  class AgenticChatController {
@@ -565,11 +564,17 @@ class AgenticChatController {
565
564
  }
566
565
  async onChatPrompt(params, token) {
567
566
  // Phase 1: Initial Setup - This happens only once
568
- params.prompt.prompt = (0, utils_2.sanitizeInput)(params.prompt.prompt || '');
567
+ params.prompt.prompt = (0, utils_2.sanitizeInput)(params.prompt.prompt || '', true);
569
568
  IdleWorkspaceManager_1.IdleWorkspaceManager.recordActivityTimestamp();
569
+ const sessionResult = this.#chatSessionManagementService.getSession(params.tabId);
570
+ const { data: session, success } = sessionResult;
571
+ if (!success) {
572
+ return new server_interface_1.ResponseError(protocol_1.ErrorCodes.InternalError, sessionResult.error);
573
+ }
570
574
  // Memory Bank Creation Flow - Delegate to MemoryBankController
571
575
  if (this.#memoryBankController.isMemoryBankCreationRequest(params.prompt.prompt)) {
572
576
  this.#features.logging.info(`Memory Bank creation request detected for tabId: ${params.tabId}`);
577
+ session.isMemoryBankGeneration = true;
573
578
  // Store original prompt to prevent data loss on failure
574
579
  const originalPrompt = params.prompt.prompt;
575
580
  try {
@@ -639,17 +644,14 @@ class AgenticChatController {
639
644
  this.#features.logging.error(`Memory Bank preparation failed: ${error}`);
640
645
  // Restore original prompt to ensure no data loss
641
646
  params.prompt.prompt = originalPrompt;
647
+ // Reset memory bank flag since preparation failed
648
+ session.isMemoryBankGeneration = false;
642
649
  }
643
650
  }
644
651
  const maybeDefaultResponse = !params.prompt.command && (0, utils_1.getDefaultChatResponse)(params.prompt.prompt);
645
652
  if (maybeDefaultResponse) {
646
653
  return maybeDefaultResponse;
647
654
  }
648
- const sessionResult = this.#chatSessionManagementService.getSession(params.tabId);
649
- const { data: session, success } = sessionResult;
650
- if (!success) {
651
- return new server_interface_1.ResponseError(protocol_1.ErrorCodes.InternalError, sessionResult.error);
652
- }
653
655
  const compactIds = session.getAllDeferredCompactMessageIds();
654
656
  await this.#invalidateCompactCommand(params.tabId, compactIds);
655
657
  session.rejectAllDeferredToolExecutions(new toolShared_1.ToolApprovalException('Command ignored: new prompt', false));
@@ -791,8 +793,7 @@ class AgenticChatController {
791
793
  * Runs the compaction, making requests and processing tool uses until completion
792
794
  */
793
795
  #shouldCompact(currentRequestCount) {
794
- // 80% of 570K limit
795
- if (currentRequestCount > 456_000) {
796
+ if (currentRequestCount > constants_2.COMPACTION_CHARACTER_THRESHOLD) {
796
797
  this.#debug(`Current request total character count is: ${currentRequestCount}, prompting user to compact`);
797
798
  return true;
798
799
  }
@@ -821,7 +822,7 @@ class AgenticChatController {
821
822
  if (currentMessage) {
822
823
  // Get and process the messages from history DB to maintain invariants for service requests
823
824
  try {
824
- const { history: historyMessages, historyCount: historyCharCount } = this.#chatHistoryDb.fixAndGetHistory(tabId, conversationIdentifier ?? '', currentMessage, []);
825
+ const { history: historyMessages, historyCount: historyCharCount } = this.#chatHistoryDb.fixAndGetHistory(tabId, currentMessage, []);
825
826
  messages = historyMessages;
826
827
  characterCount = historyCharCount;
827
828
  }
@@ -939,7 +940,7 @@ class AgenticChatController {
939
940
  if (currentMessage) {
940
941
  // Get and process the messages from history DB to maintain invariants for service requests
941
942
  try {
942
- const { history: historyMessages, historyCount: historyCharacterCount, currentCount: currentInputCount, } = this.#chatHistoryDb.fixAndGetHistory(tabId, conversationId, currentMessage, pinnedContextMessages);
943
+ const { history: historyMessages, historyCount: historyCharacterCount, currentCount: currentInputCount, } = this.#chatHistoryDb.fixAndGetHistory(tabId, currentMessage, pinnedContextMessages);
943
944
  messages = historyMessages;
944
945
  currentRequestCount = currentInputCount + historyCharacterCount;
945
946
  this.#debug(`Request total character count: ${currentRequestCount}`);
@@ -980,7 +981,7 @@ class AgenticChatController {
980
981
  }
981
982
  else {
982
983
  this.#chatHistoryDb.addMessage(tabId, 'cwc', conversationIdentifier, {
983
- body: escapeHTML(currentMessage.userInputMessage?.content ?? ''),
984
+ body: currentMessage.userInputMessage?.content ?? '',
984
985
  type: 'prompt',
985
986
  userIntent: currentMessage.userInputMessage?.userIntent,
986
987
  origin: currentMessage.userInputMessage?.origin,
@@ -1322,7 +1323,9 @@ class AgenticChatController {
1322
1323
  [toolConstants_1.FILE_SEARCH]: { Tool: fileSearch_1.FileSearch },
1323
1324
  };
1324
1325
  const { Tool } = toolMap[toolUse.name];
1325
- const tool = new Tool(this.#features);
1326
+ const tool = toolUse.name === toolConstants_1.FS_READ && session.isMemoryBankGeneration
1327
+ ? new Tool(this.#features, constants_2.FSREAD_MEMORY_BANK_MAX_PER_FILE, constants_2.FSREAD_MEMORY_BANK_MAX_TOTAL)
1328
+ : new Tool(this.#features);
1326
1329
  // For MCP tools, get the permission from McpManager
1327
1330
  // const permission = McpManager.instance.getToolPerm('Built-in', toolUse.name)
1328
1331
  // If permission is 'alwaysAllow', we don't need to ask for acceptance
@@ -1428,6 +1431,25 @@ class AgenticChatController {
1428
1431
  const ws = this.#getWritableStream(chatResultStream, toolUse);
1429
1432
  const result = await this.#features.agent.runTool(toolUse.name, toolUse.input, token, ws);
1430
1433
  let toolResultContent;
1434
+ if (toolUse.name === codeReview_1.CodeReview.toolName) {
1435
+ // no need to write tool result for code review, this is handled by model via chat
1436
+ // Push result in message so that it is picked by IDE plugin to show in issues panel
1437
+ const codeReviewResult = result;
1438
+ if (codeReviewResult?.output?.kind === 'json' &&
1439
+ codeReviewResult.output.success &&
1440
+ codeReviewResult.output.content?.findingsByFile) {
1441
+ await chatResultStream.writeResultBlock({
1442
+ type: 'tool',
1443
+ messageId: toolUse.toolUseId + codeReviewConstants_1.CODE_REVIEW_FINDINGS_MESSAGE_SUFFIX,
1444
+ body: codeReviewResult.output.content.findingsByFile,
1445
+ });
1446
+ codeReviewResult.output.content = {
1447
+ codeReviewId: codeReviewResult.output.content.codeReviewId,
1448
+ message: codeReviewResult.output.content.message,
1449
+ findingsByFileSimplified: codeReviewResult.output.content.findingsByFileSimplified,
1450
+ };
1451
+ }
1452
+ }
1431
1453
  if (typeof result === 'string') {
1432
1454
  toolResultContent = { text: result };
1433
1455
  }
@@ -1499,18 +1521,6 @@ class AgenticChatController {
1499
1521
  await chatResultStream.writeResultBlock(chatResult);
1500
1522
  break;
1501
1523
  case codeReview_1.CodeReview.toolName:
1502
- // no need to write tool result for code review, this is handled by model via chat
1503
- // Push result in message so that it is picked by IDE plugin to show in issues panel
1504
- const codeReviewResult = result;
1505
- if (codeReviewResult?.output?.kind === 'json' &&
1506
- codeReviewResult.output.success &&
1507
- codeReviewResult.output.content?.findingsByFile) {
1508
- await chatResultStream.writeResultBlock({
1509
- type: 'tool',
1510
- messageId: toolUse.toolUseId + codeReviewConstants_1.CODE_REVIEW_FINDINGS_MESSAGE_SUFFIX,
1511
- body: codeReviewResult.output.content.findingsByFile,
1512
- });
1513
- }
1514
1524
  break;
1515
1525
  case displayFindings_1.DisplayFindings.toolName:
1516
1526
  // no need to write tool result for code review, this is handled by model via chat
@@ -2017,7 +2027,7 @@ class AgenticChatController {
2017
2027
  body: constants_2.COMPACTION_HEADER_BODY,
2018
2028
  buttons,
2019
2029
  };
2020
- const body = (0, constants_2.COMPACTION_BODY)(Math.round((characterCount / chatDb_1.MaxOverallCharacters) * 100));
2030
+ const body = (0, constants_2.COMPACTION_BODY)(Math.round((characterCount / constants_2.MAX_OVERALL_CHARACTERS) * 100));
2021
2031
  return {
2022
2032
  type: 'tool',
2023
2033
  messageId,
@@ -2568,13 +2578,15 @@ class AgenticChatController {
2568
2578
  .filter(prompt => prompt.length > 0)),
2569
2579
  },
2570
2580
  });
2581
+ // Reset memory bank flag after completion
2582
+ session.isMemoryBankGeneration = false;
2571
2583
  return chatResultStream.getResult();
2572
2584
  }
2573
2585
  /**
2574
2586
  * Handles errors that occur during the request
2575
2587
  */
2576
2588
  async #handleRequestError(conversationId, err, errorMessageId, tabId, metric, agenticCodingMode) {
2577
- const errorMessage = (0, utils_2.getErrorMsg)(err) ?? constants_2.GENERIC_ERROR_MS;
2589
+ const errorMessage = ((0, utils_2.getErrorMsg)(err) ?? constants_2.GENERIC_ERROR_MS).replace(/[\r\n]+/g, ' '); // replace new lines with empty space
2578
2590
  const requestID = (0, utils_2.getRequestID)(err) ?? '';
2579
2591
  metric.setDimension('cwsprChatResponseCode', (0, utils_2.getHttpStatusCode)(err) ?? 0);
2580
2592
  metric.setDimension('languageServerVersion', this.#features.runtime.serverInfo.version);
@@ -2585,6 +2597,11 @@ class AgenticChatController {
2585
2597
  metric.metric.cwsprChatConversationId = conversationId;
2586
2598
  const errorCode = err.code ?? '';
2587
2599
  await this.#telemetryController.emitAddMessageMetric(tabId, metric.metric, 'Failed', errorMessage, errorCode);
2600
+ // Reset memory bank flag on request error
2601
+ const sessionResult = this.#chatSessionManagementService.getSession(tabId);
2602
+ if (sessionResult.success) {
2603
+ sessionResult.data.isMemoryBankGeneration = false;
2604
+ }
2588
2605
  if ((0, utils_2.isUsageLimitError)(err)) {
2589
2606
  if (this.#paidTierMode !== 'paidtier') {
2590
2607
  this.setPaidTierMode(tabId, 'freetier-limit');