Skip to content

Commit f90644c

Browse files
dhasani23David Hasani
andauthored
feat(amazonq): enable agentic workflow (#5808)
* feat(amazonq): enable agentic workflow * fix apostrophe * fix test --------- Co-authored-by: David Hasani <[email protected]>
1 parent 9df2368 commit f90644c

File tree

8 files changed

+18
-10
lines changed

8 files changed

+18
-10
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: 7 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
@@ -412,7 +413,7 @@ class CodeTransformChatController(
412413
it.sessionContext.customBuildCommand = customBuildCommand
413414
}
414415
// TODO: add CLIENT_SIDE_BUILD below when releasing CSB
415-
val transformCapabilities = listOf(EXPLAINABILITY_V1)
416+
val transformCapabilities = listOf(EXPLAINABILITY_V1, SELECTIVE_TRANSFORMATION_V2)
416417
codeModernizerManager.codeTransformationSession?.let {
417418
it.sessionContext.transformCapabilities = transformCapabilities
418419
codeModernizerManager.runLocalMavenBuild(context.project, it)
@@ -473,7 +474,7 @@ dependencyManagement:
473474
- identifier: "com.example:library1"
474475
targetVersion: "2.1.0"
475476
versionProperty: "library1.version" # Optional
476-
originType: "FIRST_PARTY" # or "THIRD_PARTY" # Optional
477+
originType: "FIRST_PARTY" # or "THIRD_PARTY"
477478
- identifier: "com.example:library2"
478479
targetVersion: "3.0.0"
479480
originType: "THIRD_PARTY"
@@ -794,7 +795,10 @@ dependencyManagement:
794795
is DownloadArtifactResult.Success -> {
795796
if (downloadResult.artifact !is CodeModernizerArtifact) return artifactHandler.notifyUnableToApplyPatch("")
796797
codeTransformChatHelper.updateLastPendingMessage(
797-
buildTransformResultChatContent(result)
798+
buildTransformResultChatContent(
799+
result,
800+
codeModernizerManager.codeTransformationSession?.sessionContext?.targetJavaVersion.toString()
801+
)
798802
)
799803
}
800804
is DownloadArtifactResult.DownloadFailure -> artifactHandler.notifyUnableToDownload(downloadResult.failureReason)

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/CodeTransformChatTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class CodeTransformChatTest {
3030
fun `test that transform result chat item includes view summary button and view diff button with correct label when job fully succeeded`() {
3131
val result = CodeModernizerJobCompletedResult.JobCompletedSuccessfully(JobId("dummy-job-id-123"))
3232
val chatItem = buildTransformResultChatContent(result)
33-
assertThat(chatItem.message).isEqualTo(message("codemodernizer.chat.message.result.success"))
33+
assertThat(chatItem.message).contains("I successfully completed your transformation")
3434
assertThat(chatItem.buttons)
3535
.hasSize(2)
3636
.satisfiesKt { buttons ->

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
@@ -681,7 +681,7 @@ codemodernizer.chat.message.result.fail_initial_build=I am having trouble buildi
681681
codemodernizer.chat.message.result.fail_initial_build_no_build_log=I am having trouble building your project in the secure build environment: {0}.
682682
codemodernizer.chat.message.result.fail_with_known_reason=Sorry, I couldn''t complete the transformation. {0}
683683
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.
684-
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.
684+
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 am 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.
685685
codemodernizer.chat.message.result.zip_too_large=Sorry, your project size exceeds the Amazon Q Code Transformation upload limit of 2GB.
686686
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.
687687
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)