Skip to content

Commit c7f917c

Browse files
committed
Merge branch 'master' into pTests/downloadAndExtract
2 parents eb74057 + 1205101 commit c7f917c

File tree

47 files changed

+960
-608
lines changed

Some content is hidden

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

47 files changed

+960
-608
lines changed

package-lock.json

Lines changed: 1 addition & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Amazon Q Developer: Updated legal disclaimer text"
4+
}

packages/core/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,6 @@
502502
"mime-types": "^2.1.32",
503503
"node-fetch": "^2.7.0",
504504
"portfinder": "^1.0.32",
505-
"proper-lockfile": "^4.1.2",
506-
"ps-list": "^8.1.1",
507505
"semver": "^7.5.4",
508506
"stream-buffers": "^3.0.2",
509507
"strip-ansi": "^5.2.0",

packages/core/src/amazonq/commons/diff.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { existsSync } from 'fs'
76
import * as vscode from 'vscode'
87
import { featureDevScheme } from '../../amazonqFeatureDev/constants'
8+
import { fs } from '../../shared'
99

1010
export async function openDiff(leftPath: string, rightPath: string, tabId: string) {
11-
const { left, right } = getFileDiffUris(leftPath, rightPath, tabId)
11+
const { left, right } = await getFileDiffUris(leftPath, rightPath, tabId)
1212
await vscode.commands.executeCommand('vscode.diff', left, right)
1313
}
1414

1515
export async function openDeletedDiff(filePath: string, name: string, tabId: string) {
16-
const fileUri = getOriginalFileUri(filePath, tabId)
16+
const fileUri = await getOriginalFileUri(filePath, tabId)
1717
await vscode.commands.executeCommand('vscode.open', fileUri, {}, `${name} (Deleted)`)
1818
}
1919

20-
export function getOriginalFileUri(fullPath: string, tabId: string) {
21-
return existsSync(fullPath) ? vscode.Uri.file(fullPath) : createAmazonQUri('empty', tabId)
20+
export async function getOriginalFileUri(fullPath: string, tabId: string) {
21+
return (await fs.exists(fullPath)) ? vscode.Uri.file(fullPath) : createAmazonQUri('empty', tabId)
2222
}
2323

24-
export function getFileDiffUris(leftPath: string, rightPath: string, tabId: string) {
25-
const left = getOriginalFileUri(leftPath, tabId)
24+
export async function getFileDiffUris(leftPath: string, rightPath: string, tabId: string) {
25+
const left = await getOriginalFileUri(leftPath, tabId)
2626
const right = createAmazonQUri(rightPath, tabId)
2727

2828
return { left, right }

packages/core/src/amazonq/lsp/lspController.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as vscode from 'vscode'
77
import * as path from 'path'
8-
import * as fs from 'fs-extra'
8+
import { createWriteStream } from 'fs'
99
import * as crypto from 'crypto'
1010
import { getLogger } from '../../shared/logger/logger'
1111
import { CurrentWsFolders, collectFilesForIndex } from '../../shared/utilities/workspaceUtils'
@@ -19,12 +19,11 @@ import { CodeWhispererSettings } from '../../codewhisperer/util/codewhispererSet
1919
import { activate as activateLsp } from './lspClient'
2020
import { telemetry } from '../../shared/telemetry'
2121
import { isCloud9 } from '../../shared/extensionUtilities'
22-
import { globals, ToolkitError } from '../../shared'
22+
import { fs, globals, ToolkitError } from '../../shared'
2323
import { AuthUtil } from '../../codewhisperer'
2424
import { isWeb } from '../../shared/extensionGlobals'
2525
import { getUserAgent } from '../../shared/telemetry/util'
2626
import { isAmazonInternalOs } from '../../shared/vscode/env'
27-
import { fs as fs2 } from '../../shared/fs/fs'
2827

2928
function getProjectPaths() {
3029
const workspaceFolders = vscode.workspace.workspaceFolders
@@ -106,7 +105,7 @@ export class LspController {
106105
throw new ToolkitError(`Failed to download. Error: ${JSON.stringify(res)}`)
107106
}
108107
return new Promise((resolve, reject) => {
109-
const file = fs.createWriteStream(localFile)
108+
const file = createWriteStream(localFile)
110109
res.body.pipe(file)
111110
res.body.on('error', (err) => {
112111
reject(err)
@@ -134,16 +133,16 @@ export class LspController {
134133
}
135134

136135
async getFileSha384(filePath: string): Promise<string> {
137-
const fileBuffer = await fs.promises.readFile(filePath)
136+
const fileBuffer = await fs.readFile(filePath)
138137
const hash = crypto.createHash('sha384')
139138
hash.update(fileBuffer)
140139
return hash.digest('hex')
141140
}
142141

143-
isLspInstalled(context: vscode.ExtensionContext) {
142+
async isLspInstalled(context: vscode.ExtensionContext) {
144143
const localQServer = context.asAbsolutePath(path.join('resources', 'qserver'))
145144
const localNodeRuntime = context.asAbsolutePath(path.join('resources', nodeBinName))
146-
return fs.existsSync(localQServer) && fs.existsSync(localNodeRuntime)
145+
return (await fs.exists(localQServer)) && (await fs.exists(localNodeRuntime))
147146
}
148147

149148
getQserverFromManifest(manifest: Manifest): Content | undefined {
@@ -208,7 +207,7 @@ export class LspController {
208207
getLogger().error(
209208
`LspController: Downloaded file sha ${sha384} does not match manifest ${content.hashes[0]}.`
210209
)
211-
fs.removeSync(filePath)
210+
await fs.delete(filePath)
212211
return false
213212
}
214213
return true
@@ -226,19 +225,19 @@ export class LspController {
226225
async tryInstallLsp(context: vscode.ExtensionContext): Promise<boolean> {
227226
let tempFolder = undefined
228227
try {
229-
if (this.isLspInstalled(context)) {
228+
if (await this.isLspInstalled(context)) {
230229
getLogger().info(`LspController: LSP already installed`)
231230
return true
232231
}
233232
// clean up previous downloaded LSP
234233
const qserverPath = context.asAbsolutePath(path.join('resources', 'qserver'))
235-
if (fs.existsSync(qserverPath)) {
234+
if (await fs.exists(qserverPath)) {
236235
await tryRemoveFolder(qserverPath)
237236
}
238237
// clean up previous downloaded node runtime
239238
const nodeRuntimePath = context.asAbsolutePath(path.join('resources', nodeBinName))
240-
if (fs.existsSync(nodeRuntimePath)) {
241-
fs.rmSync(nodeRuntimePath)
239+
if (await fs.exists(nodeRuntimePath)) {
240+
await fs.delete(nodeRuntimePath)
242241
}
243242
// fetch download url for qserver and node runtime
244243
const manifest: Manifest = (await this.fetchManifest()) as Manifest
@@ -259,16 +258,16 @@ export class LspController {
259258
}
260259
const zip = new AdmZip(qserverZipTempPath)
261260
zip.extractAllTo(tempFolder)
262-
fs.moveSync(path.join(tempFolder, 'qserver'), qserverPath)
261+
await fs.rename(path.join(tempFolder, 'qserver'), qserverPath)
263262

264263
// download node runtime to temp folder
265264
const nodeRuntimeTempPath = path.join(tempFolder, nodeBinName)
266265
const downloadNodeOk = await this.downloadAndCheckHash(nodeRuntimeTempPath, nodeRuntimeContent)
267266
if (!downloadNodeOk) {
268267
return false
269268
}
270-
await fs2.chmod(nodeRuntimeTempPath, 0o755)
271-
fs.moveSync(nodeRuntimeTempPath, nodeRuntimePath)
269+
await fs.chmod(nodeRuntimeTempPath, 0o755)
270+
await fs.rename(nodeRuntimeTempPath, nodeRuntimePath)
272271
return true
273272
} catch (e) {
274273
getLogger().error(`LspController: Failed to setup LSP server ${e}`)

packages/core/src/amazonq/webview/ui/tabs/generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class TabDataGenerator {
3030
const tabData: MynahUIDataModel = {
3131
tabTitle: taskName ?? TabTypeDataMap[tabType].title,
3232
promptInputInfo:
33-
'Use of Amazon Q is subject to the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/).',
33+
'Amazon Q Developer uses generative AI. You may need to verify responses. See the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/).',
3434
quickActionCommands: this.quickActionsGenerator.generateForTab(tabType),
3535
promptInputPlaceholder: TabTypeDataMap[tabType].placeholder,
3636
contextCommands: [

packages/core/src/amazonqFeatureDev/client/featureDev.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,17 @@ import { createCodeWhispererChatStreamingClient } from '../../shared/clients/cod
2626
import { getClientId, getOptOutPreference, getOperatingSystem } from '../../shared/telemetry/util'
2727
import { extensionVersion } from '../../shared/vscode/env'
2828

29+
// Re-enable once BE is able to handle retries.
30+
const writeAPIRetryOptions = {
31+
maxRetries: 0,
32+
retryDelayOptions: {
33+
// The default number of milliseconds to use in the exponential backoff
34+
base: 500,
35+
},
36+
}
37+
2938
// Create a client for featureDev proxy client based off of aws sdk v2
30-
export async function createFeatureDevProxyClient(): Promise<FeatureDevProxyClient> {
39+
export async function createFeatureDevProxyClient(options?: Partial<ServiceOptions>): Promise<FeatureDevProxyClient> {
3140
const bearerToken = await AuthUtil.instance.getBearerToken()
3241
const cwsprConfig = getCodewhispererConfig()
3342
return (await globals.sdkClientBuilder.createAwsService(
@@ -37,27 +46,22 @@ export async function createFeatureDevProxyClient(): Promise<FeatureDevProxyClie
3746
region: cwsprConfig.region,
3847
endpoint: cwsprConfig.endpoint,
3948
token: new Token({ token: bearerToken }),
40-
// SETTING TO 0 FOR BETA. RE-ENABLE FOR RE-INVENT
41-
maxRetries: 0,
42-
retryDelayOptions: {
43-
// The default number of milliseconds to use in the exponential backoff
44-
base: 500,
45-
},
49+
...options,
4650
} as ServiceOptions,
4751
undefined
4852
)) as FeatureDevProxyClient
4953
}
5054

5155
export class FeatureDevClient {
52-
public async getClient() {
56+
public async getClient(options?: Partial<ServiceOptions>) {
5357
// Should not be stored for the whole session.
5458
// Client has to be reinitialized for each request so we always have a fresh bearerToken
55-
return await createFeatureDevProxyClient()
59+
return await createFeatureDevProxyClient(options)
5660
}
5761

5862
public async createConversation() {
5963
try {
60-
const client = await this.getClient()
64+
const client = await this.getClient(writeAPIRetryOptions)
6165
getLogger().debug(`Executing createTaskAssistConversation with {}`)
6266
const { conversationId, $response } = await client.createTaskAssistConversation().promise()
6367
getLogger().debug(`${featureName}: Created conversation: %O`, {
@@ -82,7 +86,7 @@ export class FeatureDevClient {
8286

8387
public async createUploadUrl(conversationId: string, contentChecksumSha256: string, contentLength: number) {
8488
try {
85-
const client = await this.getClient()
89+
const client = await this.getClient(writeAPIRetryOptions)
8690
const params = {
8791
uploadContext: {
8892
taskAssistPlanningUploadContext: {
@@ -119,7 +123,7 @@ export class FeatureDevClient {
119123

120124
public async startCodeGeneration(conversationId: string, uploadId: string, message: string) {
121125
try {
122-
const client = await this.getClient()
126+
const client = await this.getClient(writeAPIRetryOptions)
123127
const params = {
124128
conversationState: {
125129
conversationId,

0 commit comments

Comments
 (0)