Skip to content

Commit 8d0d233

Browse files
committed
feat(amazonq): chat context commands for prompts
1 parent ad2c5d7 commit 8d0d233

File tree

8 files changed

+410
-38
lines changed

8 files changed

+410
-38
lines changed

package-lock.json

+113-33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/aws-lsp-codewhisperer/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"hpagent": "^1.2.0",
4545
"js-md5": "^0.8.3",
4646
"uuid": "^11.0.5",
47-
"vscode-uri": "^3.1.0"
47+
"vscode-uri": "^3.1.0",
48+
"chokidar": "^4.0.3"
4849
},
4950
"devDependencies": {
5051
"@types/adm-zip": "^0.5.5",

server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

+20-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ import {
1313
TextEdit,
1414
chatRequestType,
1515
InlineChatParams,
16+
CreatePromptParams,
17+
FileClickParams,
1618
} from '@aws/language-server-runtimes/protocol'
1719
import {
1820
CancellationToken,
1921
Chat,
2022
ChatParams,
2123
ChatResult,
24+
FileList,
2225
EndChatParams,
2326
LSPErrorCodes,
2427
QuickActionParams,
@@ -52,15 +55,14 @@ import {
5255
} from '../../shared/amazonQServiceManager/errors'
5356
import { AmazonQTokenServiceManager } from '../../shared/amazonQServiceManager/AmazonQTokenServiceManager'
5457
import { AmazonQWorkspaceConfig } from '../../shared/amazonQServiceManager/configurationUtils'
58+
import { ContextCommandsProvider } from './context/contextCommandsProvider'
5559

5660
type ChatHandlers = Omit<
5761
LspHandlers<Chat>,
5862
| 'openTab'
5963
| 'sendChatUpdate'
60-
| 'onFileClicked'
6164
| 'onInlineChatPrompt'
6265
| 'sendContextCommands'
63-
| 'onCreatePrompt'
6466
| 'onListConversations'
6567
| 'onConversationClick'
6668
>
@@ -70,6 +72,7 @@ export class AgenticChatController implements ChatHandlers {
7072
#chatSessionManagementService: ChatSessionManagementService
7173
#telemetryController: ChatTelemetryController
7274
#triggerContext: QChatTriggerContext
75+
#contextCommandsProvider: ContextCommandsProvider
7376
#customizationArn?: string
7477
#telemetryService: TelemetryService
7578
#amazonQServiceManager?: AmazonQTokenServiceManager
@@ -86,11 +89,17 @@ export class AgenticChatController implements ChatHandlers {
8689
this.#telemetryController = new ChatTelemetryController(features, telemetryService)
8790
this.#telemetryService = telemetryService
8891
this.#amazonQServiceManager = amazonQServiceManager
92+
this.#contextCommandsProvider = new ContextCommandsProvider(features)
93+
}
94+
95+
async onCreatePrompt(params: CreatePromptParams): Promise<void> {
96+
await this.#contextCommandsProvider?.handleCreatePrompt(params.promptName)
8997
}
9098

9199
dispose() {
92100
this.#chatSessionManagementService.dispose()
93101
this.#telemetryController.dispose()
102+
this.#contextCommandsProvider?.dispose()
94103
}
95104

96105
async onChatPrompt(params: ChatParams, token: CancellationToken): Promise<ChatResult | ResponseError<ChatResult>> {
@@ -134,6 +143,7 @@ export class AgenticChatController implements ChatHandlers {
134143
this.#customizationArn,
135144
profileArn
136145
)
146+
await this.#contextCommandsProvider.addAdditionalContext(triggerContext)
137147

138148
metric.recordStart()
139149
response = await session.sendMessage(requestInput)
@@ -386,13 +396,20 @@ export class AgenticChatController implements ChatHandlers {
386396
return success
387397
}
388398

399+
async onFileClicked(params: FileClickParams) {
400+
// TODO: also pass in selection and handle on client side
401+
await this.#features.lsp.window.showDocument({ uri: params.filePath })
402+
}
403+
389404
onFollowUpClicked() {}
390405

391406
onInfoLinkClick() {}
392407

393408
onLinkClick() {}
394409

395-
onReady() {}
410+
onReady() {
411+
void this.#contextCommandsProvider?.processContextCommandUpdate()
412+
}
396413

397414
onSendFeedback({ tabId, feedbackPayload }: FeedbackParams) {
398415
this.#features.telemetry.emitMetric({

0 commit comments

Comments
 (0)