Skip to content

Commit

Permalink
Merge branch 'master' into sdkv3/startMigration
Browse files Browse the repository at this point in the history
  • Loading branch information
Hweinstock committed Nov 29, 2024
2 parents 89ef745 + b52666e commit 4dbd3b4
Show file tree
Hide file tree
Showing 40 changed files with 624 additions and 211 deletions.
148 changes: 74 additions & 74 deletions .github/workflows/copyPasteDetection.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,86 @@
# github actions: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-nodejs
# setup-node: https://github.com/actions/setup-node
# # github actions: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-nodejs
# # setup-node: https://github.com/actions/setup-node

name: Copy-Paste Detection
# name: Copy-Paste Detection

on:
pull_request:
branches: [master, feature/*, staging]
# on:
# pull_request:
# branches: [master, feature/*, staging]

jobs:
jscpd:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
env:
NODE_OPTIONS: '--max-old-space-size=8192'
# jobs:
# jscpd:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# node-version: [18.x]
# env:
# NODE_OPTIONS: '--max-old-space-size=8192'

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v4
# with:
# node-version: ${{ matrix.node-version }}

- name: Fetch fork upstream
run: |
git remote add forkUpstream https://github.com/${{ github.event.pull_request.head.repo.full_name }} # URL of the fork
git fetch forkUpstream # Fetch fork
# - name: Fetch fork upstream
# run: |
# git remote add forkUpstream https://github.com/${{ github.event.pull_request.head.repo.full_name }} # URL of the fork
# git fetch forkUpstream # Fetch fork

- name: Determine base and target branches for comparison.
run: |
echo "CURRENT_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
echo "TARGET_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
- run: git diff --name-only origin/$TARGET_BRANCH forkUpstream/$CURRENT_BRANCH > diff_output.txt
- run: |
npm install -g jscpd
# - name: Determine base and target branches for comparison.
# run: |
# echo "CURRENT_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
# echo "TARGET_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
# - run: git diff --name-only origin/$TARGET_BRANCH forkUpstream/$CURRENT_BRANCH > diff_output.txt
# - run: |
# npm install -g jscpd

- run: jscpd --config "$GITHUB_WORKSPACE/.github/workflows/jscpd.json"
# - run: jscpd --config "$GITHUB_WORKSPACE/.github/workflows/jscpd.json"

- if: always()
uses: actions/upload-artifact@v4
with:
name: unfiltered-jscpd-report
path: ./jscpd-report.json
# - if: always()
# uses: actions/upload-artifact@v4
# with:
# name: unfiltered-jscpd-report
# path: ./jscpd-report.json

- name: Filter jscpd report for changed files
run: |
if [ ! -f ./jscpd-report.json ]; then
echo "jscpd-report.json not found"
exit 1
fi
echo "Filtering jscpd report for changed files..."
CHANGED_FILES=$(jq -R -s -c 'split("\n")[:-1]' diff_output.txt)
echo "Changed files: $CHANGED_FILES"
jq --argjson changed_files "$CHANGED_FILES" '
.duplicates | map(select(
(.firstFile?.name as $fname | $changed_files | any(. == $fname)) or
(.secondFile?.name as $sname | $changed_files | any(. == $sname))
))
' ./jscpd-report.json > filtered-jscpd-report.json
cat filtered-jscpd-report.json
# - name: Filter jscpd report for changed files
# run: |
# if [ ! -f ./jscpd-report.json ]; then
# echo "jscpd-report.json not found"
# exit 1
# fi
# echo "Filtering jscpd report for changed files..."
# CHANGED_FILES=$(jq -R -s -c 'split("\n")[:-1]' diff_output.txt)
# echo "Changed files: $CHANGED_FILES"
# jq --argjson changed_files "$CHANGED_FILES" '
# .duplicates | map(select(
# (.firstFile?.name as $fname | $changed_files | any(. == $fname)) or
# (.secondFile?.name as $sname | $changed_files | any(. == $sname))
# ))
# ' ./jscpd-report.json > filtered-jscpd-report.json
# cat filtered-jscpd-report.json

- name: Check for duplicates
run: |
if [ $(wc -l < ./filtered-jscpd-report.json) -gt 1 ]; then
echo "filtered_report_exists=true" >> $GITHUB_ENV
else
echo "filtered_report_exists=false" >> $GITHUB_ENV
fi
- name: upload filtered report (if applicable)
if: env.filtered_report_exists == 'true'
uses: actions/upload-artifact@v4
with:
name: filtered-jscpd-report
path: ./filtered-jscpd-report.json
# - name: Check for duplicates
# run: |
# if [ $(wc -l < ./filtered-jscpd-report.json) -gt 1 ]; then
# echo "filtered_report_exists=true" >> $GITHUB_ENV
# else
# echo "filtered_report_exists=false" >> $GITHUB_ENV
# fi
# - name: upload filtered report (if applicable)
# if: env.filtered_report_exists == 'true'
# uses: actions/upload-artifact@v4
# with:
# name: filtered-jscpd-report
# path: ./filtered-jscpd-report.json

- name: Fail and log found duplicates.
if: env.filtered_report_exists == 'true'
run: |
cat ./filtered-jscpd-report.json
echo "Duplications found, failing the check."
exit 1
# - name: Fail and log found duplicates.
# if: env.filtered_report_exists == 'true'
# run: |
# cat ./filtered-jscpd-report.json
# echo "Duplications found, failing the check."
# exit 1
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"
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions packages/amazonq/.changes/1.38.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"date": "2024-11-27",
"version": "1.38.0",
"entries": [
{
"type": "Feature",
"description": "Amazon Q /dev: support `Dockerfile` files"
},
{
"type": "Feature",
"description": "Introduce @workspace command to enhance context fetching for Chat"
},
{
"type": "Feature",
"description": "Feature(Amazon Q Code Transformation): allow users to view results in 5 smaller diffs"
}
]
}
6 changes: 6 additions & 0 deletions packages/amazonq/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.38.0 2024-11-27

- **Feature** Amazon Q /dev: support `Dockerfile` files
- **Feature** Introduce @workspace command to enhance context fetching for Chat
- **Feature** Feature(Amazon Q Code Transformation): allow users to view results in 5 smaller diffs

## 1.37.0 2024-11-22

- **Bug Fix** Amazon Q Feature Dev: display limit reached error message
Expand Down
2 changes: 1 addition & 1 deletion packages/amazonq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "amazon-q-vscode",
"displayName": "Amazon Q",
"description": "Amazon Q is your generative AI-powered assistant across the software development lifecycle.",
"version": "1.38.0-SNAPSHOT",
"version": "1.39.0-SNAPSHOT",
"extensionKind": [
"workspace"
],
Expand Down
12 changes: 7 additions & 5 deletions packages/amazonq/src/extensionNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Auth, AuthUtils, getTelemetryMetadataForConn, isAnySsoConnection } from
import api from './api'
import { activate as activateCWChat } from './app/chat/activation'
import { beta } from 'aws-core-vscode/dev'
import { activate as activateNotifications } from 'aws-core-vscode/notifications'
import { activate as activateNotifications, NotificationsController } from 'aws-core-vscode/notifications'
import { AuthState, AuthUtil } from 'aws-core-vscode/codewhisperer'
import { telemetry, AuthUserState } from 'aws-core-vscode/telemetry'

Expand Down Expand Up @@ -67,15 +67,14 @@ async function activateAmazonQNode(context: vscode.ExtensionContext) {

// TODO: Should probably emit for web as well.
// Will the web metric look the same?
const authState = await getAuthState()
telemetry.auth_userState.emit({
passive: true,
result: 'Succeeded',
source: AuthUtils.ExtensionUse.instance.sourceForTelemetry(),
...authState,
...(await getAuthState()),
})

void activateNotifications(context, authState, getAuthState)
void activateNotifications(context, getAuthState)
}

async function getAuthState(): Promise<Omit<AuthUserState, 'source'>> {
Expand Down Expand Up @@ -122,13 +121,16 @@ async function setupDevMode(context: vscode.ExtensionContext) {

const devOptions: DevOptions = {
context,
auth: Auth.instance,
auth: () => Auth.instance,
notificationsController: () => NotificationsController.instance,
menuOptions: [
'editStorage',
'resetState',
'showEnvVars',
'deleteSsoConnections',
'expireSsoConnections',
'editAuthConnections',
'notificationsSend',
'forceIdeCrash',
],
}
Expand Down
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
Loading

0 comments on commit 4dbd3b4

Please sign in to comment.