Skip to content

Commit bf9eadc

Browse files
justinmk3JadenSimonleigaolgmeghraoPrateek Chauhan
committed
feat: CodeWhisperer re:Invent 2022
https://aws.amazon.com/codewhisperer Co-authored-by: JadenSimon <[email protected]> Co-authored-by: Justin M. Keyes <[email protected]> Co-authored-by: Lei Gao <[email protected]> Co-authored-by: Meghana Gunuganti <[email protected]> Co-authored-by: Prateek Chauhan <[email protected]> Co-authored-by: Rachel Cross <[email protected]> Co-authored-by: Stephen Yuan <[email protected]> Co-authored-by: Wade Fang <[email protected]> Co-authored-by: Will Lo <[email protected]> Co-authored-by: Zoe Lin <[email protected]> Co-authored-by: Andrew Yu <[email protected]>
1 parent 5ea6365 commit bf9eadc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2460
-737
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules/**
22
**/*.json
33
src/shared/telemetry/clienttelemetry.d.ts
44
src/codewhisperer/client/codewhispererclient.d.ts
5+
src/codewhisperer/client/codewhispereruserclient.d.ts
56
**/*.gen.ts
67
src/testFixtures/workspaceFolder/ts-plain-sam-app/
78
dist/**

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ src/shared/telemetry/vscodeTelemetry.json
2626
# Auto generated Service Clients
2727
src/shared/telemetry/clienttelemetry.d.ts
2828
src/codewhisperer/client/codewhispererclient.d.ts
29+
src/codewhisperer/client/codewhispereruserclient.d.ts
2930

3031
# Generated by tests
3132
src/testFixtures/**/bin

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,13 @@
262262
"markdownDescription": "%AWS.configuration.description.experiments%",
263263
"default": {
264264
"jsonResourceModification": false,
265-
"CodeWhisperer": true,
266265
"samSyncCode": false
267266
},
268267
"properties": {
269268
"jsonResourceModification": {
270269
"type": "boolean",
271270
"default": false
272271
},
273-
"CodeWhisperer": {
274-
"type": "boolean",
275-
"default": true
276-
},
277272
"samSyncCode": {
278273
"type": "boolean",
279274
"default": false
@@ -797,6 +792,10 @@
797792
"command": "aws.listCommands",
798793
"when": "false"
799794
},
795+
{
796+
"command": "aws.codeWhisperer.removeConnection",
797+
"when": "false"
798+
},
800799
{
801800
"command": "aws.downloadSchemaItemCode",
802801
"when": "false"
@@ -1773,14 +1772,24 @@
17731772
},
17741773
{
17751774
"command": "aws.codeWhisperer.configure",
1776-
"when": "viewItem == awsCodeWhispererNode && !isCloud9",
1775+
"when": "viewItem =~ /^awsCodeWhispererNode/ && !isCloud9",
17771776
"group": "inline@2"
17781777
},
17791778
{
17801779
"command": "aws.codeWhisperer.introduction",
1781-
"when": "viewItem == awsCodeWhispererNode && !isCloud9 && CODEWHISPERER_TERMS_ACCEPTED",
1780+
"when": "viewItem =~ /^awsCodeWhispererNode/ && !isCloud9 && CODEWHISPERER_TERMS_ACCEPTED",
17821781
"group": "inline@1"
17831782
},
1783+
{
1784+
"command": "aws.codeWhisperer.removeConnection",
1785+
"when": "viewItem == awsCodeWhispererNodeSaved",
1786+
"group": "0@1"
1787+
},
1788+
{
1789+
"command": "aws.codeWhisperer.removeConnection",
1790+
"when": "viewItem == awsCodeWhispererNodeSaved",
1791+
"group": "inline@3"
1792+
},
17841793
{
17851794
"command": "aws.cdk.refresh",
17861795
"when": "viewItem == awsCdkRootNode",
@@ -3008,6 +3017,12 @@
30083017
}
30093018
}
30103019
},
3020+
{
3021+
"command": "aws.codeWhisperer.removeConnection",
3022+
"title": "%AWS.command.codewhisperer.removeConnection%",
3023+
"category": "%AWS.title%",
3024+
"icon": "$(debug-disconnect)"
3025+
},
30113026
{
30123027
"command": "aws.dev.openMenu",
30133028
"title": "Open Developer Menu",
@@ -3372,7 +3387,7 @@
33723387
"report": "nyc report --reporter=html --reporter=json"
33733388
},
33743389
"devDependencies": {
3375-
"@aws-toolkits/telemetry": "^1.0.79",
3390+
"@aws-toolkits/telemetry": "^1.0.80",
33763391
"@cspotcode/source-map-support": "^0.8.1",
33773392
"@sinonjs/fake-timers": "^8.1.0",
33783393
"@types/adm-zip": "^0.4.34",

package.nls.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"AWS.configuration.description.suppressPrompts": "Prompts which ask for confirmation. Checking an item suppresses the prompt.",
1919
"AWS.configuration.enableCodeLenses": "Enable SAM hints in source files",
2020
"AWS.configuration.description.resources.enabledResources": "AWS resources to display in the 'Resources' portion of the explorer.",
21-
"AWS.configuration.description.experiments": "Try experimental features and give feedback. Note that experimental features may be removed at any time.\n * `jsonResourceModification` - Enables basic create, update, and delete support for cloud resources via the JSON Resources explorer component \n * `CodeWhisperer` - CodeWhisperer helps improve efficiency by providing real-time code suggestions from AI models. [Learn More](https://aws.amazon.com/codewhisperer). Use a keyboard shortcut to request suggestions from CodeWhisperer while writing code. Default keyboard shortcut is [Alt(Option) + C], can be updated in Keyboard Shortcuts.\n * `samSyncCode` - Adds an additional code-only option when synchronizing SAM applications. Code-only synchronizations are faster but can cause drift in the CloudFormation stack. Does nothing when using the legacy SAM deploy feature.",
21+
"AWS.configuration.description.experiments": "Try experimental features and give feedback. Note that experimental features may be removed at any time.\n * `jsonResourceModification` - Enables basic create, update, and delete support for cloud resources via the JSON Resources explorer component.\n * `samSyncCode` - Adds an additional code-only option when synchronizing SAM applications. Code-only synchronizations are faster but can cause drift in the CloudFormation stack. Does nothing when using the legacy SAM deploy feature.",
2222
"AWS.stepFunctions.asl.format.enable.desc": "Enables the default formatter used with Amazon States Language files",
2323
"AWS.stepFunctions.asl.maxItemsComputed.desc": "The maximum number of outline symbols and folding regions computed (limited for performance reasons).",
2424
"AWS.configuration.description.awssam.debug.api": "API Gateway configuration",
@@ -74,7 +74,7 @@
7474
"AWS.command.apig.copyUrl": "Copy URL",
7575
"AWS.command.apig.invokeRemoteRestApi": "Invoke on AWS",
7676
"AWS.command.apig.invokeRemoteRestApi.cn": "Invoke on Amazon",
77-
"AWS.command.auth.addConnection": "Add new Connection",
77+
"AWS.command.auth.addConnection": "Add New Connection",
7878
"AWS.command.auth.switchConnections": "Switch Connections",
7979
"AWS.command.auth.signout": "Sign out",
8080
"AWS.command.github": "View Source on GitHub",
@@ -175,6 +175,7 @@
175175
"AWS.command.resources.configure": "Show Resources...",
176176
"AWS.command.codewhisperer.introduction": "What is CodeWhisperer?",
177177
"AWS.command.codewhisperer.configure": "CodeWhisperer Settings",
178+
"AWS.command.codewhisperer.removeConnection": "Remove Connection from Tool",
178179
"AWS.lambda.explorerTitle": "Explorer",
179180
"AWS.developerTools.explorerTitle": "Developer Tools",
180181
"AWS.cloudWatchLogs.limit.desc": "Maximum amount of log entries pulled per request from CloudWatch Logs (max 10000)",
Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
1-
## How to Use Amazon CodeWhisperer
1+
## Using Amazon CodeWhisperer
22

3-
Welcome to the Amazon CodeWhisperer preview! CodeWhisperer uses machine learning to generate code suggestions
4-
from the existing code and comments in your IDE. Supported languages include: **Java, Python, and JavaScript**.
3+
CodeWhisperer uses machine learning to generate code suggestions from the existing code and comments in your IDE. Supported languages include **Java, Python, JavaScript, C# and TypeScript**.
54

6-
### TAB. Left Arrow. Right Arrow. That’s all!
5+
---
76

8-
You should automatically see inline code suggestions. Use the **TAB key to accept** a suggestion. CodeWhisperer may
9-
provide multiple suggestions to choose from, use **[left arrow] and [right arrow] to navigate** between suggestions.
7+
**Navigating with the tab and arrow keys**
108

11-
That’s all you need to know. If you don’t like the suggestions you see, simply keep typing (or hit ESC key).
12-
The suggestions will go away and CodeWhisperer will generate new ones at a later point based on the additional context.
9+
As you enter your code, CodeWhisperer will offer inline code suggestions. Use **TAB to accept** a suggestion. CodeWhisperer may provide multiple suggestions to choose from. Use **[left arrow] and [right arrow] to navigate** between suggestions.
1310

14-
### Requesting Suggestions Manually
11+
If you don’t like the suggestions you see, keep typing (or hit ESC). The suggestions will disappear, and CodeWhisperer will generate new ones at a later point based on the additional context.
1512

16-
You can also request a suggestion at any time, use **Option C** on Mac and **ALT C** on Windows. Once you receive
17-
the suggestions use TAB to accept and the Arrow keys to navigate.
13+
<img src="twosum_vsc.gif" style="max-height:400px;" alt="twosum">
1814

19-
### How to get the best recommendations
15+
---
2016

21-
- More context = better recommendations. You will see better recommendations when your current file has more
22-
existing code.
17+
**Requesting suggestions manually**
2318

24-
- Write more comments and be more descriptive. “Function to upload a file to S3” will get better results than
25-
“Upload a file.”
19+
You can request suggestions at any time. Use **Option-C** on Mac or **ALT-C** on Windows. After you receive suggestions, use TAB to accept and arrow keys to navigate.
2620

27-
- Try to specify the libraries you prefer by inserting import statements.
21+
---
2822

29-
- Use descriptive names for variable and functions. A function called “upload_file_to_S3” will get better results
30-
than a function called “file_upload”
23+
**Getting the best recommendations**
3124

32-
- Break down complex tasks into smaller tasks and write descriptive comments.
25+
For best results, follow these practices.
3326

34-
### How to provide feedback
27+
- Give CodeWhisperer something to work with. The more code your file contains, the more context CodeWhisperer has for generating recommendations.
28+
- Write descriptive comments. “Function to upload a file to S3” will get better results than “Upload a file”.
29+
- Specify the libraries you prefer by using import statements.
30+
- Use descriptive names for variable and functions. A function called “upload_file_to_S3” will get better results than a function called “file_upload”.
31+
- Break down complex tasks into simpler tasks.
3532

36-
CodeWhisperer is in preview, let us know what your think by sharing feedback (using the AWS Toolkit
37-
feedback button) or reaching out to [[email protected]](mailto:[email protected]) .
33+
---
34+
35+
**Further reading**
36+
37+
To learn more about working with CodeWhisperer and VS Code, see [CodeWhisperer for VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/codewhisperer.html).
38+
39+
---
40+
41+
**Providing feedback**
42+
43+
CodeWhisperer is in preview. Let us know what you think by sharing feedback (using the AWS Toolkit feedback button) or by reaching out to [[email protected]](mailto:[email protected]).

resources/markdown/twosum_vsc.gif

256 KB
Loading

scripts/build/generateServiceClient.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ ${fileContents}
214214
serviceJsonPath: 'src/codewhisperer/client/service-2.json',
215215
serviceName: 'CodeWhispererClient',
216216
},
217+
{
218+
serviceJsonPath: 'src/codewhisperer/client/user-service-2.json',
219+
serviceName: 'CodeWhispererUserClient',
220+
},
217221
]
218222
await generateServiceClients(serviceClientDefinitions)
219223
})()

src/awsexplorer/activation.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { checkExplorerForDefaultRegion } from './defaultRegion'
2525
import { createLocalExplorerView } from './localExplorer'
2626
import { telemetry } from '../shared/telemetry/telemetry'
2727
import { cdkNode, CdkRootNode } from '../cdk/explorer/rootNode'
28-
import { codewhispererNode } from '../codewhisperer/explorer/codewhispererNode'
28+
import { CodeWhispererNode, codewhispererNode } from '../codewhisperer/explorer/codewhispererNode'
2929
import { once } from '../shared/utilities/functionUtils'
3030
import { Auth, AuthNode } from '../credentials/auth'
3131
import { isCloud9 } from '../shared/extensionUtilities'
@@ -76,9 +76,12 @@ export async function activate(args: {
7676

7777
// Legacy CDK metric, remove this when we add something generic
7878
const recordExpandCdkOnce = once(() => telemetry.cdk_appExpanded.emit())
79+
const onDidExpandCodeWhisperer = once(() => telemetry.ui_click.emit({ elementId: 'cw_parentNode' }))
7980
developerTools.onDidExpandElement(e => {
8081
if (e.element.resource instanceof CdkRootNode) {
8182
recordExpandCdkOnce()
83+
} else if (e.element.resource instanceof CodeWhispererNode) {
84+
onDidExpandCodeWhisperer()
8285
}
8386
})
8487
}

0 commit comments

Comments
 (0)