Skip to content

Commit

Permalink
Merge branch 'aws:master' into output-terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
mbfreder authored Nov 26, 2024
2 parents 84c0e18 + 61d67f8 commit 2de568d
Show file tree
Hide file tree
Showing 14 changed files with 88 additions and 27 deletions.
18 changes: 18 additions & 0 deletions buildspec/release/35opengate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 0.2

phases:
install:
runtime-versions:
nodejs: 16

pre_build:
commands:
- STAGE_NAME=SourceWithGit
- PIPELINE=$(echo $CODEBUILD_INITIATOR | sed -e 's/codepipeline\///')
build:
commands:
- |
aws codepipeline enable-stage-transition \
--pipeline-name "$PIPELINE" \
--stage-name "$STAGE_NAME" \
--transition-type "Inbound"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "Amazon Q /dev: support `Dockerfile` files"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "Introduce @workspace command to enhance context fetching for Chat"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "Feature(Amazon Q Code Transformation): allow users to view results in 5 smaller diffs"
}
2 changes: 1 addition & 1 deletion packages/core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"AWS.configuration.description.amazonq": "Amazon Q creates a code reference when you insert a code suggestion from Amazon Q that is similar to training data. When unchecked, Amazon Q will not show code suggestions that have code references. If you authenticate through IAM Identity Center, this setting is controlled by your Amazon Q administrator. [Learn More](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/code-reference.html)",
"AWS.configuration.description.amazonq.shareContentWithAWS": "When checked, your content processed by Amazon Q may be used for service improvement (except for content processed for users with the Amazon Q Developer Pro Tier). Unchecking this box will cause AWS to delete any of your content used for that purpose. The information used to provide the Amazon Q service to you will not be affected. See the [Service Terms](https://aws.amazon.com/service-terms) for more details.",
"AWS.configuration.description.amazonq.importRecommendation": "Amazon Q will add import statements with inline code suggestions when necessary.",
"AWS.configuration.description.amazonq.workspaceIndex": "This feature is in BETA. When you add @workspace to your question in Amazon Q chat, Amazon Q will index your open workspace files locally to use as context for its response. Extra CPU usage is expected while indexing a workspace. This will not impact Amazon Q features or your IDE, but you may manage CPU usage by setting the number of local threads in 'Local Workspace Index Threads'.",
"AWS.configuration.description.amazonq.workspaceIndex": "When you add @workspace to your question in Amazon Q chat, Amazon Q will index your open workspace files locally to use as context for its response. Extra CPU usage is expected while indexing a workspace. This will not impact Amazon Q features or your IDE, but you may manage CPU usage by setting the number of local threads in 'Local Workspace Index Threads'.",
"AWS.configuration.description.amazonq.workspaceIndexWorkerThreads": "Number of worker threads of Amazon Q local index process. '0' will use the system default worker threads for balance performance. You may increase this number to more quickly index your workspace, but only up to your hardware's number of CPU cores. Please restart VS Code or reload the VS Code window after changing worker threads.",
"AWS.configuration.description.amazonq.workspaceIndexUseGPU": "Enable GPU to help index your local workspace files. Only applies to Linux and Windows.",
"AWS.configuration.description.amazonq.workspaceIndexMaxSize": "The maximum size of local workspace files to be indexed in MB",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/amazonq/webview/ui/tabs/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const workspaceCommand: QuickActionCommandGroup = {
commands: [
{
command: '@workspace',
description: '(BETA) Reference all code in workspace.',
description: 'Reference all code in workspace.',
},
],
}
Expand Down
10 changes: 3 additions & 7 deletions packages/core/src/amazonqGumby/chat/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ import { getStringHash } from '../../../shared/utilities/textUtilities'
import { getVersionData } from '../../../codewhisperer/service/transformByQ/transformMavenHandler'
import AdmZip from 'adm-zip'
import { AuthError } from '../../../auth/sso/server'
import { isSelectiveTransformationReady } from '../../../dev/config'

// These events can be interactions within the chat,
// or elsewhere in the IDE
Expand Down Expand Up @@ -424,18 +423,15 @@ export class GumbyController {
result: MetadataResult.Pass,
})
this.messenger.sendSkipTestsSelectionMessage(skipTestsSelection, message.tabID)
if (!isSelectiveTransformationReady) {
// perform local build
await this.validateBuildWithPromptOnError(message)
} else {
await this.messenger.sendOneOrMultipleDiffsPrompt(message.tabID)
}
await this.messenger.sendOneOrMultipleDiffsPrompt(message.tabID)
}

private async handleOneOrMultipleDiffs(message: any) {
const oneOrMultipleDiffsSelection = message.formSelectedValues['GumbyTransformOneOrMultipleDiffsForm']
if (oneOrMultipleDiffsSelection === CodeWhispererConstants.multipleDiffsMessage) {
transformByQState.setMultipleDiffs(true)
} else {
transformByQState.setMultipleDiffs(false)
}
this.messenger.sendOneOrMultipleDiffsMessage(oneOrMultipleDiffsSelection, message.tabID)
// perform local build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ export class Messenger {
}

public sendOneOrMultipleDiffsMessage(selectiveTransformationSelection: string, tabID: string) {
const message = `Okay, I will create ${selectiveTransformationSelection.toLowerCase()} when providing the proposed changes.`
const message = `Okay, I will create ${selectiveTransformationSelection.toLowerCase()} with my proposed changes.`
this.dispatcher.sendChatMessage(new ChatMessage({ message, messageType: 'ai-prompt' }, tabID))
}

Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/codewhisperer/models/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const patchDescriptions: { [key: string]: string } = {
'Popular Enterprise Specifications and Application Frameworks upgrade':
'This diff patch covers the set of upgrades for Jakarta EE 10, Hibernate 6.2, and Micronaut 3.',
'HTTP Client Utilities, Apache Commons Utilities, and Web Frameworks':
'This diff patch covers the set of upgrades for Apache HTTP Client 5, Apache Commons utilities (Collections, IO, Lang, Math), Struts 6.0.',
'This diff patch covers the set of upgrades for Apache HTTP Client 5, Apache Commons utilities (Collections, IO, Lang, Math), and Struts 6.0.',
'Testing Tools and Frameworks upgrade':
'This diff patch covers the set of upgrades for ArchUnit, Mockito, TestContainers, Cucumber, and additionally, Jenkins plugins and the Maven Wrapper.',
'This diff patch covers the set of upgrades for ArchUnit, Mockito, TestContainers, and Cucumber, in addition to the Jenkins plugins and the Maven Wrapper.',
'Miscellaneous Processing Documentation upgrade':
'This diff patch covers a diverse set of upgrades spanning ORMs, XML processing, API documentation, and more.',
'Deprecated API replacement, dependency upgrades, and formatting':
Expand Down Expand Up @@ -470,7 +470,7 @@ export const chooseTransformationObjective = `I can help you with the following
export const chooseTransformationObjectivePlaceholder = 'Enter "language upgrade" or "sql conversion"'

export const userPatchDescriptionChatMessage = `
I can now divide the transformation results into diff patches (if applicable to the app) if you would like to review and accept each diff with fewer changes:
If you'd like to update and test your code with fewer changes at a time, I can divide the transformation results into separate diff patches. If applicable to your application, I can split up the diffs up into the following groups of upgrades. Here are the upgrades included in each diff:
• Minimal Compatible Library Upgrade to Java 17: Dependencies to the minimum compatible versions in Java 17, including Springboot, JUnit, and PowerMockito.
Expand Down Expand Up @@ -616,16 +616,16 @@ export const jobCancelledNotification = 'You cancelled the transformation.'

export const diffMessage = (multipleDiffs: boolean) => {
return multipleDiffs
? 'You can review the diff to see my proposed changes and accept or reject them. If you reject the diff, you will not be able to see the diffs later.'
? 'You can review the diffs to see my proposed changes and accept or reject them. You will be able to accept changes from one diff at a time. If you reject changes in one diff, you will not be able to view or accept changes in the other diffs.'
: 'You can review the diff to see my proposed changes and accept or reject them.'
}

export const jobCompletedChatMessage = (multipleDiffsString: string) => {
return `I transformed your code. ${multipleDiffsString} The transformation summary has details about the files I updated.`
return `I completed your transformation. ${multipleDiffsString} The transformation summary has details about the changes I'm proposing.`
}

export const jobCompletedNotification = (multipleDiffsString: string) => {
return `Amazon Q transformed your code. ${multipleDiffsString} The transformation summary has details about the files I updated.`
return `Amazon Q transformed your code. ${multipleDiffsString} The transformation summary has details about the changes.`
}

export const jobPartiallyCompletedChatMessage = (multipleDiffsString: string) => {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/codewhisperer/models/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ export class TransformByQState {
this.errorLog = ''
this.customBuildCommand = ''
this.intervalId = undefined
this.produceMultipleDiffs = false
}
}

Expand Down
33 changes: 33 additions & 0 deletions packages/core/src/codewhisperer/util/telemetryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,39 @@ export class TelemetryHelper {
credentialStartUrl: AuthUtil.instance.startUrl,
traceId: this.traceId,
})

client
.sendTelemetryEvent({
telemetryEvent: {
userTriggerDecisionEvent: {
sessionId: sessionId,
requestId: requestIdList[0],
customizationArn: selectedCustomization.arn === '' ? undefined : selectedCustomization.arn,
programmingLanguage: {
languageName: runtimeLanguageContext.toRuntimeLanguage(language),
},
completionType: 'LINE',
suggestionState: 'EMPTY',
recommendationLatencyMilliseconds: 0,
triggerToResponseLatencyMilliseconds: session.timeToFirstRecommendation,
perceivedLatencyMilliseconds: session.perceivedLatency,
timestamp: new Date(Date.now()),
suggestionReferenceCount: 0,
generatedLine: 0,
numberOfRecommendations: 0,
acceptedCharacterCount: 0,
},
},
})
.then()
.catch((error) => {
let requestId: string | undefined
if (isAwsError(error)) {
requestId = error.requestId
}

getLogger().error(`Failed to invoke sendTelemetryEvent, requestId: ${requestId ?? ''}`)
})
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import { getHttpStatusCode, AwsClientResponseError } from '../../../shared/error
import { uiEventRecorder } from '../../../amazonq/util/eventRecorder'
import { globals, waitUntil } from '../../../shared'
import { telemetry } from '../../../shared/telemetry'
import { Auth } from '../../../auth'
import { isSsoConnection } from '../../../auth/connection'
import { inspect } from '../../../shared/utilities/collectionUtils'

Expand Down Expand Up @@ -633,11 +632,7 @@ export class ChatController {
this.messenger.sendOpenSettingsMessage(triggerID, tabID)
return
}
}
// if user does not have @workspace in the prompt, but user is Amazon internal
// add project context by default
else if (
Auth.instance.isInternalAmazonUser() &&
} else if (
!LspController.instance.isIndexingInProgress() &&
CodeWhispererSettings.instance.isLocalIndexEnabled()
) {
Expand Down
3 changes: 0 additions & 3 deletions packages/core/src/dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ export const betaUrl = {
amazonq: '',
toolkit: '',
}

//feature flag for Selective Transformation
export const isSelectiveTransformationReady = false
13 changes: 11 additions & 2 deletions packages/core/src/shared/filetypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export const codefileExtensions = new Set([
'.d',
'.dart',
'.dfm',
'.dockerfile',
'.dpr',
'.e',
'.el',
Expand Down Expand Up @@ -347,8 +348,16 @@ export const codefileExtensions = new Set([
'.zig',
])

// Some well-known code files without an extension
export const wellKnownCodeFiles = new Set(['Dockerfile', 'Dockerfile.build'])

/** Returns true if `filename` is a code file. */
export function isCodeFile(filename: string): boolean {
const ext = path.extname(filename).toLowerCase()
return codefileExtensions.has(ext)
if (codefileExtensions.has(path.extname(filename).toLowerCase())) {
return true
} else if (wellKnownCodeFiles.has(filename)) {
return true
} else {
return false
}
}

0 comments on commit 2de568d

Please sign in to comment.