Skip to content

Commit e82f0f3

Browse files
author
David Hasani
committed
feat(amazonq): enable agentic workflow
1 parent ebece9d commit e82f0f3

File tree

7 files changed

+19
-9
lines changed

7 files changed

+19
-9
lines changed

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/CodeModernizerSession.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import javax.net.ssl.SSLHandshakeException
7373

7474
const val MAX_ZIP_SIZE = 2000000000 // 2GB
7575
const val EXPLAINABILITY_V1 = "EXPLAINABILITY_V1"
76+
const val SELECTIVE_TRANSFORMATION_V2 = "SELECTIVE_TRANSFORMATION_V2"
7677

7778
// constants for handling SDKClientException
7879
const val CONNECTION_REFUSED_ERROR: String = "Connection refused"

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ fun buildTransformResumingChatContent() = CodeTransformChatMessageContent(
554554
type = CodeTransformChatMessageType.PendingAnswer,
555555
)
556556

557-
fun buildTransformResultChatContent(result: CodeModernizerJobCompletedResult): CodeTransformChatMessageContent {
557+
fun buildTransformResultChatContent(result: CodeModernizerJobCompletedResult, targetJdkVersion: String = ""): CodeTransformChatMessageContent {
558558
val resultMessage = when (result) {
559559
is CodeModernizerJobCompletedResult.JobAbortedZipTooLarge -> {
560560
"${message(
@@ -568,7 +568,7 @@ fun buildTransformResultChatContent(result: CodeModernizerJobCompletedResult): C
568568
buildZipUploadFailedChatMessage(result.failureReason)
569569
}
570570
is CodeModernizerJobCompletedResult.JobCompletedSuccessfully -> {
571-
message("codemodernizer.chat.message.result.success")
571+
message("codemodernizer.chat.message.result.success", targetJdkVersion)
572572
}
573573
is CodeModernizerJobCompletedResult.JobPartiallySucceeded -> {
574574
message("codemodernizer.chat.message.result.partially_success")

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/controller/CodeTransformChatController.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.CodeTransformTele
3131
import software.aws.toolkits.jetbrains.services.codemodernizer.EXPLAINABILITY_V1
3232
import software.aws.toolkits.jetbrains.services.codemodernizer.HilTelemetryMetaData
3333
import software.aws.toolkits.jetbrains.services.codemodernizer.InboundAppMessagesHandler
34+
import software.aws.toolkits.jetbrains.services.codemodernizer.SELECTIVE_TRANSFORMATION_V2
3435
import software.aws.toolkits.jetbrains.services.codemodernizer.client.GumbyClient
3536
import software.aws.toolkits.jetbrains.services.codemodernizer.commands.CodeTransformActionMessage
3637
import software.aws.toolkits.jetbrains.services.codemodernizer.commands.CodeTransformCommand
@@ -119,6 +120,7 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.utils.validateSct
119120
import software.aws.toolkits.jetbrains.services.codewhisperer.telemetry.QFeatureEvent
120121
import software.aws.toolkits.jetbrains.services.codewhisperer.telemetry.broadcastQEvent
121122
import software.aws.toolkits.jetbrains.services.cwc.messages.ChatMessageType
123+
import software.aws.toolkits.jetbrains.utils.notifyStickyInfo
122124
import software.aws.toolkits.resources.message
123125
import software.aws.toolkits.telemetry.CodeTransformPreValidationError
124126

@@ -415,7 +417,7 @@ class CodeTransformChatController(
415417
it.sessionContext.customBuildCommand = customBuildCommand
416418
}
417419
// TODO: add CLIENT_SIDE_BUILD below when releasing CSB
418-
val transformCapabilities = listOf(EXPLAINABILITY_V1)
420+
val transformCapabilities = listOf(EXPLAINABILITY_V1, SELECTIVE_TRANSFORMATION_V2)
419421
codeModernizerManager.codeTransformationSession?.let {
420422
it.sessionContext.transformCapabilities = transformCapabilities
421423
codeModernizerManager.runLocalMavenBuild(context.project, it)
@@ -476,7 +478,7 @@ dependencyManagement:
476478
- identifier: "com.example:library1"
477479
targetVersion: "2.1.0"
478480
versionProperty: "library1.version" # Optional
479-
originType: "FIRST_PARTY" # or "THIRD_PARTY" # Optional
481+
originType: "FIRST_PARTY" # or "THIRD_PARTY"
480482
- identifier: "com.example:library2"
481483
targetVersion: "3.0.0"
482484
originType: "THIRD_PARTY"
@@ -797,8 +799,12 @@ dependencyManagement:
797799
is DownloadArtifactResult.Success -> {
798800
if (downloadResult.artifact !is CodeModernizerArtifact) return artifactHandler.notifyUnableToApplyPatch("")
799801
codeTransformChatHelper.updateLastPendingMessage(
800-
buildTransformResultChatContent(result)
802+
buildTransformResultChatContent(
803+
result,
804+
codeModernizerManager.codeTransformationSession?.sessionContext?.targetJavaVersion.toString()
805+
)
801806
)
807+
notifyStickyInfo("jdkVersion", codeModernizerManager.codeTransformationSession?.sessionContext?.targetJavaVersion.toString())
802808
}
803809
is DownloadArtifactResult.DownloadFailure -> artifactHandler.notifyUnableToDownload(downloadResult.failureReason)
804810
is DownloadArtifactResult.ParseZipFailure -> artifactHandler.notifyUnableToApplyPatch(downloadResult.failureReason.errorMessage)

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/model/CodeModernizerSessionContext.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const val CUSTOM_DEPENDENCY_VERSIONS_FILE_PATH = "custom-upgrades.yaml"
4949
const val UPLOAD_ZIP_MANIFEST_VERSION = "1.0"
5050
const val HIL_1P_UPGRADE_CAPABILITY = "HIL_1pDependency_VersionUpgrade"
5151
const val EXPLAINABILITY_V1 = "EXPLAINABILITY_V1"
52+
const val SELECTIVE_TRANSFORMATION_V2 = "SELECTIVE_TRANSFORMATION_V2"
5253
const val CLIENT_SIDE_BUILD = "CLIENT_SIDE_BUILD"
5354
const val MAVEN_CONFIGURATION_FILE_NAME = "pom.xml"
5455
const val MAVEN_BUILD_RUN_UNIT_TESTS = "clean test"

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/model/ZipManifest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ data class ZipManifest(
1111
val version: String = UPLOAD_ZIP_MANIFEST_VERSION,
1212
val hilCapabilities: List<String> = listOf(HIL_1P_UPGRADE_CAPABILITY),
1313
// TODO: add CLIENT_SIDE_BUILD to transformCapabilities when releasing CSB
14-
// TODO: add AGENTIC_PLAN_V1 or something here AND in processCodeTransformSkipTests when backend allowlists everyone
15-
val transformCapabilities: List<String> = listOf(EXPLAINABILITY_V1),
14+
val transformCapabilities: List<String> = listOf(EXPLAINABILITY_V1, SELECTIVE_TRANSFORMATION_V2),
15+
val noInteractiveMode: Boolean = true,
1616
val customBuildCommand: String = MAVEN_BUILD_RUN_UNIT_TESTS,
1717
val requestedConversions: RequestedConversions? = null, // only used for SQL conversions for now
1818
)

plugins/amazonq/codetransform/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codemodernizer/CodeWhispererCodeModernizerSessionTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class CodeWhispererCodeModernizerSessionTest : CodeWhispererCodeModernizerTestBa
146146
root.children[0],
147147
JavaSdkVersion.JDK_1_8,
148148
JavaSdkVersion.JDK_11,
149-
listOf(EXPLAINABILITY_V1),
149+
listOf(EXPLAINABILITY_V1, SELECTIVE_TRANSFORMATION_V2),
150150
MAVEN_BUILD_SKIP_UNIT_TESTS
151151
)
152152
val mockFile = mock(File::class.java)
@@ -164,6 +164,8 @@ class CodeWhispererCodeModernizerSessionTest : CodeWhispererCodeModernizerTestBa
164164
Path("manifest.json") -> {
165165
assertThat(fileContent).isNotNull()
166166
assertThat(fileContent).contains(MAVEN_BUILD_SKIP_UNIT_TESTS)
167+
assertThat(fileContent).contains(SELECTIVE_TRANSFORMATION_V2)
168+
assertThat(fileContent).contains("\"noInteractiveMode\":true")
167169
}
168170
Path("sources/src/tmp.txt") -> assertThat(fileContent).isEqualTo(fileText)
169171
Path("build-logs.txt") -> assertThat(fileContent).isNotNull()

plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ codemodernizer.chat.message.result.fail_initial_build=I am having trouble buildi
677677
codemodernizer.chat.message.result.fail_initial_build_no_build_log=I am having trouble building your project in the secure build environment: {0}.
678678
codemodernizer.chat.message.result.fail_with_known_reason=Sorry, I couldn''t complete the transformation. {0}
679679
codemodernizer.chat.message.result.partially_success=I transformed part of your code. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the files I updated and the errors that prevented a complete transformation.
680-
codemodernizer.chat.message.result.success=I successfully completed your transformation. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the changes I'm proposing.
680+
codemodernizer.chat.message.result.success=I successfully completed your transformation. You can review the diff to see my proposed changes and accept or reject them. The transformation summary has details about the changes I'm proposing. If you want to upgrade additional libraries and other dependencies, run /transform with the transformed code and specify {0} as the source and target version.
681681
codemodernizer.chat.message.result.zip_too_large=Sorry, your project size exceeds the Amazon Q Code Transformation upload limit of 2GB.
682682
codemodernizer.chat.message.resume_ongoing=I'm still transforming your code. It can take 10 to 30 minutes to upgrade your code, depending on the size of your module. To monitor progress, go to the Transformation Hub.
683683
codemodernizer.chat.message.skip_tests=I will build your project using `mvn clean test` by default. If you would like me to build your project without running unit tests, I will use `mvn clean test-compile`.

0 commit comments

Comments
 (0)