Skip to content

Commit 65daa2e

Browse files
authored
Merge pull request #6552 from aws/autoMerge/feature/amazonqLSP
Merge master into feature/amazonqLSP
2 parents ed3707a + 526cf8a commit 65daa2e

File tree

347 files changed

+1866
-1552
lines changed

Some content is hidden

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

347 files changed

+1866
-1552
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ module.exports = {
180180
'aws-toolkits/no-console-log': 'error',
181181
'aws-toolkits/no-json-stringify-in-log': 'error',
182182
'aws-toolkits/no-printf-mismatch': 'error',
183+
'aws-toolkits/no-index-import': 'error',
183184
'no-restricted-imports': [
184185
'error',
185186
{
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Amazon Q /test: Q identify active test file and infer source file for test generation."
4+
}

packages/amazonq/test/unit/amazonqFeatureDev/session/session.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import {
1818
sessionWriteFile,
1919
assertTelemetry,
2020
} from 'aws-core-vscode/test'
21-
import { CurrentWsFolders, CodeGenState, FeatureDevClient, featureDevScheme } from 'aws-core-vscode/amazonqFeatureDev'
22-
import { Messenger } from 'aws-core-vscode/amazonq'
21+
import { FeatureDevClient, featureDevScheme, FeatureDevCodeGenState } from 'aws-core-vscode/amazonqFeatureDev'
22+
import { Messenger, CurrentWsFolders } from 'aws-core-vscode/amazonq'
2323
import path from 'path'
2424
import { fs } from 'aws-core-vscode/shared'
2525

@@ -75,7 +75,7 @@ describe('session', () => {
7575
workspaceFolders,
7676
}
7777

78-
const codeGenState = new CodeGenState(
78+
const codeGenState = new FeatureDevCodeGenState(
7979
testConfig,
8080
[
8181
{
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import { ServiceOptions } from '../../shared/awsClientBuilder'
7+
8+
export abstract class FeatureClient {
9+
public abstract getClient(options?: Partial<ServiceOptions>): Promise<any>
10+
11+
public abstract createConversation(): Promise<string>
12+
13+
public abstract createUploadUrl(
14+
conversationId: string,
15+
contentChecksumSha256: string,
16+
contentLength: number,
17+
uploadId: string
18+
): Promise<any>
19+
20+
public abstract startCodeGeneration(
21+
conversationId: string,
22+
uploadId: string,
23+
message: string,
24+
intent: any,
25+
codeGenerationId: string,
26+
currentCodeGenerationId?: string,
27+
intentContext?: any
28+
): Promise<any>
29+
30+
public abstract getCodeGeneration(conversationId: string, codeGenerationId: string): Promise<any>
31+
32+
public abstract exportResultArchive(conversationId: string): Promise<any>
33+
}

packages/core/src/amazonq/commons/connector/baseMessenger.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import { ChatItemAction, ProgressField } from '@aws/mynah-ui'
77
import { AuthFollowUpType, AuthMessageDataMap } from '../../../amazonq/auth/model'
8-
import { FeatureAuthState } from '../../../codewhisperer'
98
import { i18n } from '../../../shared/i18n-helper'
109
import { CodeReference } from '../../../amazonq/webview/ui/connector'
1110

@@ -25,9 +24,9 @@ import {
2524
UpdatePlaceholderMessage,
2625
UpdatePromptProgressMessage,
2726
} from './connectorMessages'
28-
import { FollowUpTypes } from '../types'
27+
import { DeletedFileInfo, FollowUpTypes, NewFileInfo } from '../types'
2928
import { messageWithConversationId } from '../../../amazonqFeatureDev/userFacingText'
30-
import { DeletedFileInfo, NewFileInfo } from '../../../amazonqFeatureDev/types'
29+
import { FeatureAuthState } from '../../../codewhisperer/util/authUtil'
3130

3231
export class Messenger {
3332
public constructor(

packages/core/src/amazonq/commons/connector/connectorMessages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { MessagePublisher } from '../../messages/messagePublisher'
88
import { CodeReference } from '../../webview/ui/connector'
99
import { ChatItemAction, ProgressField, SourceLink } from '@aws/mynah-ui'
1010
import { ChatItemType } from '../model'
11-
import { DeletedFileInfo, NewFileInfo } from '../../../amazonqFeatureDev/types'
11+
import { DeletedFileInfo, NewFileInfo } from '../types'
1212
import { licenseText } from '../../../amazonqFeatureDev/constants'
1313

1414
class UiMessage {

packages/core/src/amazonq/commons/controllers/contentController.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as vscode from 'vscode'
77
import path from 'path'
88
import { Position, TextEditor, window } from 'vscode'
9-
import { getLogger } from '../../../shared/logger'
9+
import { getLogger } from '../../../shared/logger/logger'
1010
import { amazonQDiffScheme, amazonQTabSuffix } from '../../../shared/constants'
1111
import { disposeOnEditorClose } from '../../../shared/utilities/editorUtilities'
1212
import {
@@ -15,7 +15,9 @@ import {
1515
getIndentedCode,
1616
getSelectionFromRange,
1717
} from '../../../shared/utilities/textDocumentUtilities'
18-
import { extractFileAndCodeSelectionFromMessage, fs, getErrorMsg, ToolkitError } from '../../../shared'
18+
import { ToolkitError, getErrorMsg } from '../../../shared/errors'
19+
import fs from '../../../shared/fs/fs'
20+
import { extractFileAndCodeSelectionFromMessage } from '../../../shared/utilities/textUtilities'
1921
import { UserWrittenCodeTracker } from '../../../codewhisperer/tracker/userWrittenCodeTracker'
2022

2123
export class ContentProvider implements vscode.TextDocumentContentProvider {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import * as vscode from 'vscode'
7-
import { fs } from '../../shared'
7+
import { fs } from '../../shared/fs/fs'
88
import { diffLines } from 'diff'
99

1010
export async function openDiff(leftPath: string, rightPath: string, tabId: string, scheme: string) {

packages/core/src/amazonq/commons/session/sessionConfigFactory.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
import * as vscode from 'vscode'
77
import { WorkspaceFolderNotFoundError } from '../../../amazonqFeatureDev/errors'
8-
import { VirtualFileSystem, VirtualMemoryFile } from '../../../shared'
9-
import { CurrentWsFolders } from '../../../amazonqFeatureDev/types'
8+
import { CurrentWsFolders } from '../types'
9+
import { VirtualFileSystem } from '../../../shared/virtualFilesystem'
10+
import { VirtualMemoryFile } from '../../../shared/virtualMemoryFile'
1011

1112
export interface SessionConfig {
1213
// The paths on disk to where the source code lives

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

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

6+
import * as vscode from 'vscode'
7+
import { VirtualFileSystem } from '../../shared/virtualFilesystem'
8+
import type { CancellationTokenSource } from 'vscode'
9+
import { CodeReference, UploadHistory } from '../webview/ui/connector'
10+
import { DiffTreeFileInfo } from '../webview/ui/diffTree/types'
11+
import { Messenger } from './connector/baseMessenger'
12+
import { FeatureClient } from '../client/client'
13+
import { TelemetryHelper } from '../util/telemetryHelper'
14+
615
export enum FollowUpTypes {
716
// UnitTestGeneration
817
ViewDiff = 'ViewDiff',
@@ -39,3 +48,119 @@ export enum FollowUpTypes {
3948
ProceedFolderSelection = 'ProceedFolderSelection',
4049
CancelFolderSelection = 'CancelFolderSelection',
4150
}
51+
52+
export type Interaction = {
53+
// content to be sent back to the chat UI
54+
content?: string
55+
responseType?: LLMResponseType
56+
}
57+
58+
export interface SessionStateInteraction {
59+
nextState: SessionState | Omit<SessionState, 'uploadId'> | undefined
60+
interaction: Interaction
61+
currentCodeGenerationId?: string
62+
}
63+
64+
export enum Intent {
65+
DEV = 'DEV',
66+
DOC = 'DOC',
67+
}
68+
69+
export enum DevPhase {
70+
INIT = 'Init',
71+
APPROACH = 'Approach',
72+
CODEGEN = 'Codegen',
73+
}
74+
75+
export enum CodeGenerationStatus {
76+
COMPLETE = 'Complete',
77+
PREDICT_READY = 'predict-ready',
78+
IN_PROGRESS = 'InProgress',
79+
PREDICT_FAILED = 'predict-failed',
80+
DEBATE_FAILED = 'debate-failed',
81+
FAILED = 'Failed',
82+
}
83+
84+
export type SessionStatePhase = DevPhase.INIT | DevPhase.CODEGEN
85+
86+
export type CurrentWsFolders = [vscode.WorkspaceFolder, ...vscode.WorkspaceFolder[]]
87+
88+
export interface SessionState {
89+
readonly filePaths?: NewFileInfo[]
90+
readonly deletedFiles?: DeletedFileInfo[]
91+
readonly references?: CodeReference[]
92+
readonly phase?: SessionStatePhase
93+
readonly uploadId: string
94+
readonly currentIteration?: number
95+
currentCodeGenerationId?: string
96+
tokenSource?: CancellationTokenSource
97+
readonly codeGenerationId?: string
98+
readonly tabID: string
99+
interact(action: SessionStateAction): Promise<SessionStateInteraction>
100+
updateWorkspaceRoot?: (workspaceRoot: string) => void
101+
codeGenerationRemainingIterationCount?: number
102+
codeGenerationTotalIterationCount?: number
103+
uploadHistory?: UploadHistory
104+
}
105+
106+
export interface SessionStateConfig {
107+
workspaceRoots: string[]
108+
workspaceFolders: CurrentWsFolders
109+
conversationId: string
110+
proxyClient: FeatureClient
111+
uploadId: string
112+
currentCodeGenerationId?: string
113+
}
114+
115+
export interface SessionStateAction {
116+
task: string
117+
msg: string
118+
messenger: Messenger
119+
fs: VirtualFileSystem
120+
telemetry: TelemetryHelper
121+
uploadHistory?: UploadHistory
122+
tokenSource?: CancellationTokenSource
123+
}
124+
125+
export type NewFileZipContents = { zipFilePath: string; fileContent: string }
126+
export type NewFileInfo = DiffTreeFileInfo &
127+
NewFileZipContents & {
128+
virtualMemoryUri: vscode.Uri
129+
workspaceFolder: vscode.WorkspaceFolder
130+
}
131+
132+
export type DeletedFileInfo = DiffTreeFileInfo & {
133+
workspaceFolder: vscode.WorkspaceFolder
134+
}
135+
136+
export interface SessionInfo {
137+
// TODO, if it had a summarized name that was better for the UI
138+
name?: string
139+
history: string[]
140+
}
141+
142+
export interface SessionStorage {
143+
[key: string]: SessionInfo
144+
}
145+
146+
export type LLMResponseType = 'EMPTY' | 'INVALID_STATE' | 'VALID'
147+
148+
export interface UpdateFilesPathsParams {
149+
tabID: string
150+
filePaths: NewFileInfo[]
151+
deletedFiles: DeletedFileInfo[]
152+
messageId: string
153+
disableFileActions?: boolean
154+
}
155+
156+
export enum MetricDataOperationName {
157+
StartCodeGeneration = 'StartCodeGeneration',
158+
EndCodeGeneration = 'EndCodeGeneration',
159+
}
160+
161+
export enum MetricDataResult {
162+
Success = 'Success',
163+
Fault = 'Fault',
164+
Error = 'Error',
165+
LlmFailure = 'LLMFailure',
166+
}

0 commit comments

Comments
 (0)