Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "feature",
"description" : "Amazon Q /test, /doc, and /dev capabilities integrated into Agentic coding."
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
@file:Suppress("BannedImports")
package software.aws.toolkits.jetbrains.services.cwc.commands

import com.google.gson.Gson
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.Project
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.runBlocking
import software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat.AsyncChatUiListener
import software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat.FlareUiMessage
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.GENERIC_COMMAND
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.GenericCommandParams
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.SEND_TO_PROMPT
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.SendToPromptParams
import software.aws.toolkits.jetbrains.services.amazonq.lsp.model.aws.chat.TriggerType
import software.aws.toolkits.jetbrains.services.amazonq.messages.AmazonQMessage
import software.aws.toolkits.jetbrains.services.amazonqCodeTest.controller.TestCommandMessage
import software.aws.toolkits.jetbrains.services.cwc.editor.context.ActiveFileContextExtractor
import software.aws.toolkits.jetbrains.services.cwc.editor.context.ExtractionTriggerType

Expand All @@ -28,25 +25,21 @@ class ActionRegistrar {
val flow = _messages.asSharedFlow()

fun reportMessageClick(command: EditorContextCommand, project: Project) {
if (command == EditorContextCommand.GenerateUnitTests) {
AsyncChatUiListener.notifyPartialMessageUpdate(project, Gson().toJson(TestCommandMessage()))
} else {
// new agentic chat route
ApplicationManager.getApplication().executeOnPooledThread {
runBlocking {
val contextExtractor = ActiveFileContextExtractor.create(fqnWebviewAdapter = null, project = project)
val fileContext = contextExtractor.extractContextForTrigger(ExtractionTriggerType.ContextMenu)
val codeSelection = "\n```\n${fileContext.focusAreaContext?.codeSelection?.trimIndent()?.trim()}\n```\n"
var uiMessage: FlareUiMessage? = null
if (command.verb != SEND_TO_PROMPT) {
val params = GenericCommandParams(selection = codeSelection, triggerType = TriggerType.CONTEXT_MENU, genericCommand = command.name)
uiMessage = FlareUiMessage(command = GENERIC_COMMAND, params = params)
} else {
val params = SendToPromptParams(selection = codeSelection, triggerType = TriggerType.CONTEXT_MENU)
uiMessage = FlareUiMessage(command = SEND_TO_PROMPT, params = params)
}
AsyncChatUiListener.notifyPartialMessageUpdate(project, uiMessage)
// new agentic chat route
ApplicationManager.getApplication().executeOnPooledThread {
runBlocking {
val contextExtractor = ActiveFileContextExtractor.create(fqnWebviewAdapter = null, project = project)
val fileContext = contextExtractor.extractContextForTrigger(ExtractionTriggerType.ContextMenu)
val codeSelection = "\n```\n${fileContext.focusAreaContext?.codeSelection?.trimIndent()?.trim()}\n```\n"
var uiMessage: FlareUiMessage? = null
if (command.verb != SEND_TO_PROMPT) {
val params = GenericCommandParams(selection = codeSelection, triggerType = TriggerType.CONTEXT_MENU, genericCommand = command.name)
uiMessage = FlareUiMessage(command = GENERIC_COMMAND, params = params)
} else {
val params = SendToPromptParams(selection = codeSelection, triggerType = TriggerType.CONTEXT_MENU)
uiMessage = FlareUiMessage(command = SEND_TO_PROMPT, params = params)
}
AsyncChatUiListener.notifyPartialMessageUpdate(project, uiMessage)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class QuickActionGenerator {

const quickActionCommands = [
{
groupName: `Q Developer Agent for <b>Software Development</b>`,
commands: [
...(this.isFeatureDevEnabled
? [
Expand Down Expand Up @@ -78,11 +77,6 @@ export class QuickActionGenerator {
},
]
: []),
],
},
{
groupName: `Q Developer Agent for <b>Code Transformation</b>`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this stay?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK this was removed from the VSC impl

commands:[
...(this.isCodeTransformEnabled
? [
{
Expand All @@ -93,22 +87,7 @@ export class QuickActionGenerator {
]
: []),
],
},
{
groupName: 'Quick Actions',
commands: [
{
command: '/help',
icon: MynahIcons.HELP,
description: 'Learn more about Amazon Q',
},
{
command: '/clear',
icon: MynahIcons.TRASH,
description: 'Clear this session',
},
],
},
}
].filter((section) => section.commands.length > 0)

const commandUnavailability: Record<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,7 @@ private handleDocCommand(chatPrompt: ChatPrompt, tabID: string, taskName: string
this.connector.startTestGen(testTabId, realPromptText)
return
}
/**
* right click -> generate test has no tab id
* we have to manually create one if a testgen tab
* wasn't previously created
*/
if (!tabID) {
tabID = this.mynahUI?.updateStore('', {})
}

const affectedTabId: string | undefined = this.addTab(tabID)

// if there is no test tab, open a new one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class AwsServerCapabilitiesProvider {
),
history = true,
export = true,
mcpServers = true
mcpServers = true,
// Seems like this is the only way to bounce reroute back to the LSP?
reroute = true,
)
}
}
Expand All @@ -48,6 +50,7 @@ data class ChatOptions(
val history: Boolean,
val export: Boolean,
val mcpServers: Boolean,
val reroute: Boolean,
)

data class QuickActions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ data class DeveloperProfiles(
val developerProfiles: Boolean,
val mcp: Boolean,
val pinnedContextEnabled: Boolean,
val reroute: Boolean,
val workspaceFilePath: String?,
)

Expand Down Expand Up @@ -66,6 +67,7 @@ fun createExtendedClientMetadata(project: Project): ExtendedClientMetadata {
developerProfiles = true,
mcp = true,
pinnedContextEnabled = true,
reroute = true,
workspaceFilePath = project.workspaceFile?.path,
),
window = WindowSettings(
Expand Down
Loading