1
>
/*---------------------------------------------------------------------------------------------
agentHostBangCommand.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
/**
7
>
* The leading character that marks a chat message as a terminal command.
8
>
*/
9
>
export const BANG_COMMAND_PREFIX = '!';
10
>
11
>
/**
12
>
* Parses a leading `!<command>` at the very start of `prompt`.
13
>
*
14
>
* Like {@link parseRenameCommand}, the marker must be at position 0 (no leading
15
>
* whitespace). A lone `!` or `!` followed only by whitespace is not treated as
16
>
* a bang command — the caller should forward such messages normally.
17
>
*
18
>
* Returns the trimmed command string when the prompt is a bang command, or
19
>
* `undefined` when it is not.
20
>
*/
21
>
export function parseBangCommand(prompt: string): string | undefined {
22
if (!prompt.startsWith(BANG_COMMAND_PREFIX)) {
23
return undefined;