diff --git a/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqDoc/session/PrepareDocGenerationState.kt b/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqDoc/session/PrepareDocGenerationState.kt index f9720cd4ce2..497126bb12d 100644 --- a/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqDoc/session/PrepareDocGenerationState.kt +++ b/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqDoc/session/PrepareDocGenerationState.kt @@ -39,7 +39,7 @@ class PrepareDocGenerationState( var zipFileLength: Long? = null val nextState: SessionState try { - val repoZipResult = config.repoContext.getProjectZip() + val repoZipResult = config.repoContext.getProjectZip(false) val zipFileChecksum = repoZipResult.checksum zipFileLength = repoZipResult.contentLength val fileToUpload = repoZipResult.payload diff --git a/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/FeatureDevConstants.kt b/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/FeatureDevConstants.kt index 8c4312fccb4..658cdc2ed58 100644 --- a/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/FeatureDevConstants.kt +++ b/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/FeatureDevConstants.kt @@ -8,7 +8,7 @@ const val FEATURE_EVALUATION_PRODUCT_NAME = "FeatureDev" const val FEATURE_NAME = "Amazon Q Developer Agent for software development" @Suppress("MaxLineLength") -const val GENERATE_DEV_FILE_PROMPT = "generate a devfile in my repository. Note that you should only use devfile version 2.0.0 and the only supported command is test, so you should bundle all install, build and test commands in “test”. also you can use “public.ecr.aws/aws-mde/universal-image:latest” as universal image if you aren’t sure which image to use. here is an example for a node repository (but don't assume it's always a node project. look at the existing repository structure before generating the devfile): schemaVersion: 2.0.0 components: - name: dev container: image: public.ecr.aws/aws-mde/universal-image:latest commands: - id: test exec: component: dev commandLine: \"npm install && npm run build && npm run test\"" +const val GENERATE_DEV_FILE_PROMPT = "generate a devfile in my repository. Note that you should only use devfile version 2.0.0 and the only supported commands are install, build and test (are all optional). so you may have to bundle some commands together using '&&'. also you can use \"public.ecr.aws/aws-mde/universal-image:latest\" as universal image if you aren’t sure which image to use. here is an example for a node repository (but don't assume it's always a node project. look at the existing repository structure before generating the devfile): schemaVersion: 2.0.0 components: - name: dev container: image: public.ecr.aws/aws-mde/universal-image:latest commands: - id: install exec: component: dev commandLine: \"npm install\" - id: build exec: component: dev commandLine: \"npm run build\" - id: test exec: component: dev commandLine: \"npm run test\"" // Max number of times a user can attempt to retry a code generation request if it fails const val CODE_GENERATION_RETRY_LIMIT = 3 diff --git a/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/controller/FeatureDevController.kt b/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/controller/FeatureDevController.kt index 4bc86d89543..d13f03e7fce 100644 --- a/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/controller/FeatureDevController.kt +++ b/plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/controller/FeatureDevController.kt @@ -736,7 +736,7 @@ class FeatureDevController( return } - session.preloader(message, messenger) + session.preloader(messenger) broadcastQEvent(QFeatureEvent.INVOCATION) when (session.sessionState.phase) { diff --git a/plugins/amazonq/chat/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/FeatureDevSessionContextTest.kt b/plugins/amazonq/chat/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/FeatureDevSessionContextTest.kt index 136c4d3e433..dfebd35097c 100644 --- a/plugins/amazonq/chat/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/FeatureDevSessionContextTest.kt +++ b/plugins/amazonq/chat/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/FeatureDevSessionContextTest.kt @@ -55,10 +55,9 @@ class FeatureDevSessionContextTest : FeatureDevTestBase(HeavyJavaCodeInsightTest @Test fun testWithInvalidFile() { - val txtFile = mock() - whenever(txtFile.extension).thenReturn("txt") - whenever(txtFile.path).thenReturn("file.txt") - assertFalse(featureDevSessionContext.isFileExtensionAllowed(txtFile)) + val mediaFile = mock() + whenever(mediaFile.extension).thenReturn("mp4") + assertFalse(featureDevSessionContext.isFileExtensionAllowed(mediaFile)) } @Test @@ -96,10 +95,11 @@ class FeatureDevSessionContextTest : FeatureDevTestBase(HeavyJavaCodeInsightTest "License.md", "node_modules/express", "build/outputs", - "dist/bundle.js" + "dist/bundle.js", + "gradle/wrapper/gradle-wrapper.jar", ) - val zipResult = featureDevSessionContext.getProjectZip() + val zipResult = featureDevSessionContext.getProjectZip(false) val zipPath = zipResult.payload.path val zippedFiles = mutableSetOf() @@ -120,6 +120,8 @@ class FeatureDevSessionContextTest : FeatureDevTestBase(HeavyJavaCodeInsightTest "builder/GetTestBuilder.java", "settings.gradle", "build.gradle", + "gradle/wrapper/gradle-wrapper.jar", + ".gitignore", ) assertTrue(zippedFiles == expectedFiles) diff --git a/plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererProjectCodeScanTest.kt b/plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererProjectCodeScanTest.kt index 47d2c5ff6e9..4bf42a83a77 100644 --- a/plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererProjectCodeScanTest.kt +++ b/plugins/amazonq/codewhisperer/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codewhisperer/codescan/CodeWhispererProjectCodeScanTest.kt @@ -34,6 +34,7 @@ class CodeWhispererProjectCodeScanTest : CodeWhispererCodeScanTestBase(PythonCod private lateinit var testYaml: VirtualFile private lateinit var helperPy: VirtualFile private lateinit var testTf: VirtualFile + private lateinit var gitIgnore: VirtualFile private lateinit var sessionConfigSpy: CodeScanSessionConfig private lateinit var sessionConfigSpy2: CodeScanSessionConfig @@ -63,9 +64,9 @@ class CodeWhispererProjectCodeScanTest : CodeWhispererCodeScanTestBase(PythonCod fun `test createPayload`() { val payload = sessionConfigSpy.createPayload() assertNotNull(payload) - assertThat(payload.context.totalFiles).isEqualTo(10) + assertThat(payload.context.totalFiles).isEqualTo(11) - assertThat(payload.context.scannedFiles.size).isEqualTo(10) + assertThat(payload.context.scannedFiles.size).isEqualTo(11) assertThat(payload.context.scannedFiles).contains(testYaml, testTf, readMeMd, utilsJs, utilsCs, testJson, testCs, helperPy, helperCs, helpGo) assertThat(payload.context.srcPayloadSize).isEqualTo(totalSize) @@ -80,12 +81,12 @@ class CodeWhispererProjectCodeScanTest : CodeWhispererCodeScanTestBase(PythonCod filesInZip += 1 } - assertThat(filesInZip).isEqualTo(10) + assertThat(filesInZip).isEqualTo(11) } @Test fun `getProjectPayloadMetadata()`() { - getProjectPayloadMetadata(sessionConfigSpy, 10, totalSize, this.totalLines, CodewhispererLanguage.Csharp) + getProjectPayloadMetadata(sessionConfigSpy, 11, totalSize, this.totalLines, CodewhispererLanguage.Csharp) } @Test @@ -105,7 +106,7 @@ class CodeWhispererProjectCodeScanTest : CodeWhispererCodeScanTestBase(PythonCod @Test fun `e2e happy path integration test`() = runTest { - assertE2ERunsSuccessfully(sessionConfigSpy, project, totalLines, 10, totalSize, 1) + assertE2ERunsSuccessfully(sessionConfigSpy, project, totalLines, 11, totalSize, 1) } private fun setupCsharpProject() { @@ -371,7 +372,10 @@ class CodeWhispererProjectCodeScanTest : CodeWhispererCodeScanTestBase(PythonCod // Adding gitignore file and gitignore file member for testing. // The tests include the markdown file but not these two files. - projectRule.fixture.addFileToProject("/.gitignore", "node_modules\n.idea\n.vscode\n.DS_Store").virtualFile + gitIgnore = projectRule.fixture.addFileToProject("/.gitignore", "node_modules\n.idea\n.vscode\n.DS_Store").virtualFile + totalSize += gitIgnore.length + totalLines += gitIgnore.toNioPath().toFile().readLines().size + projectRule.fixture.addFileToProject("/.idea/ref", "ref: refs/heads/main") } } diff --git a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/FeatureDevSessionContext.kt b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/FeatureDevSessionContext.kt index 2a7cc5ceece..127c524bee6 100644 --- a/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/FeatureDevSessionContext.kt +++ b/plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/FeatureDevSessionContext.kt @@ -47,11 +47,11 @@ class RepoSizeLimitError(override val message: String) : RuntimeException(), Rep class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Long? = null) { // TODO: Need to correct this class location in the modules going further to support both amazonq and codescan. + private val requiredFilesForExecution = setOf("gradle/wrapper/gradle-wrapper.jar") private val additionalGitIgnoreRules = setOf( ".aws-sam", ".gem", ".git", - ".gitignore", ".gradle", ".hg", ".idea", @@ -136,6 +136,9 @@ class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Lo suspend fun ignoreFile(file: VirtualFile): Boolean = ignoreFile(file.presentableUrl) suspend fun ignoreFile(path: String): Boolean { + if (requiredFilesForExecution.any { path.endsWith(it) }) { + return false + } // this method reads like something a JS dev would write and doesn't do what the author thinks val deferredResults = ignorePatternsWithGitIgnore.map { pattern -> withContext(coroutineContext) {