diff --git a/.changes/next-release/feature-8e3cb633-c82d-4e35-ab8e-0ab0e1d41294.json b/.changes/next-release/feature-8e3cb633-c82d-4e35-ab8e-0ab0e1d41294.json new file mode 100644 index 00000000000..b028ea9d881 --- /dev/null +++ b/.changes/next-release/feature-8e3cb633-c82d-4e35-ab8e-0ab0e1d41294.json @@ -0,0 +1,4 @@ +{ + "type" : "feature", + "description" : "Improve the explain and apply fix messages" +} \ No newline at end of file diff --git a/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/commands/codescan/actions/HandleIssueCommandAction.kt b/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/commands/codescan/actions/HandleIssueCommandAction.kt index 11254eef553..4c85ebbe808 100644 --- a/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/commands/codescan/actions/HandleIssueCommandAction.kt +++ b/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/commands/codescan/actions/HandleIssueCommandAction.kt @@ -24,6 +24,13 @@ class HandleIssueCommandAction : AnAction(), DumbAware { val contextDataKey = DataKey.create>("amazonq.codescan.handleIssueCommandContext") val actionDataKey = DataKey.create("amazonq.codescan.handleIssueCommandAction") + private val explainContextPrompt = "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. " + + "You must start with the information stored in the recommendation.text field if it is present." + private val applyFixContextPrompt = "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." + override fun getActionUpdateThread() = ActionUpdateThread.BGT override fun update(e: AnActionEvent) { @@ -62,11 +69,11 @@ class HandleIssueCommandAction : AnAction(), DumbAware { // https://github.com/aws/aws-toolkit-vscode/blob/master/packages/amazonq/src/lsp/chat/commands.ts#L30 val codeSelection = "\n```\n${context["code"]?.trimIndent()?.trim()}\n```\n" val actionString = if (action == "explainIssue") "Explain" else "Fix" + val contextPrompt = if (action == "explainIssue") explainContextPrompt else applyFixContextPrompt val prompt = "$actionString ${context["title"]} issue in ${context["fileName"]} at ${createLineRangeText(context)}" - val modelPrompt = "$actionString ${context["title"]} issue in ${context["fileName"]} at ${createLineRangeText(context)}" + - "Issue: \"${context}\" \n" + val modelPrompt = "$contextPrompt Issue: \"${context}\" \n" val params = SendToPromptParams( selection = codeSelection,