49
return { message, diff };
50
}
52
>
export class ChatRequestTextPart implements IParsedChatRequestPart {
53
>
static readonly Kind = 'text';
54
>
readonly kind = ChatRequestTextPart.Kind;
55
>
constructor(readonly range: OffsetRange, readonly editorRange: IRange, readonly text: string) { }
56
>
57
>
get promptText(): string {
58
return this.text;
59
}
61
>
62
>
// warning, these also show up in a regex in the parser
63
>
export const chatVariableLeader = '#';
64
>
export const chatAgentLeader = '@';
65
>
export const chatSubcommandLeader = '/';
66
>
67
>
/**
68
>
* An invocation of a static variable that can be resolved by the variable service
69
>
* @deprecated, but kept for backwards compatibility with old persisted chat requests
70
>
*/
71
>
class ChatRequestVariablePart implements IParsedChatRequestPart {
72
>
static readonly Kind = 'var';
73
>
readonly kind = ChatRequestVariablePart.Kind;
74
>
constructor(readonly range: OffsetRange, readonly editorRange: IRange, readonly variableName: string, readonly variableArg: string, readonly variableId: string) { }
75
>
76
>
get text(): string {
77
const argPart = this.variableArg ? `:${this.variableArg}` : '';
78
return `${chatVariableLeader}${this.variableName}${argPart}`;
79
}
81
>
get promptText(): string {
82
return this.text;
83
}
85
>
86
>
/**
87
>
* An invocation of a tool
88
>
*/
89
>
export class ChatRequestToolPart implements IParsedChatRequestPart {
90
>
static readonly Kind = 'tool';
91
>
readonly kind = ChatRequestToolPart.Kind;
92
>
constructor(readonly range: OffsetRange, readonly editorRange: IRange, readonly toolName: string, readonly toolId: string, readonly displayName?: string, readonly icon?: IToolData['icon']) { }
93
>
94
>
get text(): string {
95
return `${chatVariableLeader}${this.toolName}`;
96
}
98
>
get promptText(): string {
99
return this.text;
100
}
102
>
toVariableEntry(): IChatRequestToolEntry {
103
return { kind: 'tool', id: this.toolId, name: this.toolName, range: this.range, value: undefined, icon: ThemeIcon.isThemeIcon(this.icon) ? this.icon : undefined, fullName: this.displayName };
104
}
106
>
107
>
/**
108
>
* An invocation of a tool
109
>
*/
110
>
export class ChatRequestToolSetPart implements IParsedChatRequestPart {
111
>
static readonly Kind = 'toolset';
112
>
readonly kind = ChatRequestToolSetPart.Kind;
113
>
constructor(readonly range: OffsetRange, readonly editorRange: IRange, readonly id: string, readonly name: string, readonly icon: ThemeIcon, readonly tools: IChatRequestToolEntry[]) { }
114
>
115
>
get text(): string {
116
return `${chatVariableLeader}${this.name}`;
117
}
119
>
get promptText(): string {
120
return this.text;
121
}
123
>
toVariableEntry(): IChatRequestToolSetEntry {
124
return { kind: 'toolset', id: this.id, name: this.name, range: this.range, icon: this.icon, value: this.tools };
125
}
127
>
128
>
/**
129
>
* An invocation of an agent that can be resolved by the agent service
130
>
*/
131
>
export class ChatRequestAgentPart implements IParsedChatRequestPart {
132
>
static readonly Kind = 'agent';
133
>
readonly kind = ChatRequestAgentPart.Kind;
134
>
constructor(readonly range: OffsetRange, readonly editorRange: IRange, readonly agent: IChatAgentData) { }
135
>
136
>
get text(): string {
137
138
return `${chatAgentLeader}${this.agent.name}`;
139
}
141
>
get promptText(): string {
142
return '';
143
}
145
>
146
>
/**
147
>
* An invocation of an agent's subcommand
148
>
*/
149
>
export class ChatRequestAgentSubcommandPart implements IParsedChatRequestPart {
150
>
static readonly Kind = 'subcommand';
151
>
readonly kind = ChatRequestAgentSubcommandPart.Kind;
152
>
constructor(readonly range: OffsetRange, readonly editorRange: IRange, readonly command: IChatAgentCommand) { }
153
>
154
>
get text(): string {
155
return `${chatSubcommandLeader}${this.command.name}`;
156
}
158
>
get promptText(): string {
159
return '';
160
}
162
>
163
>
/**
164
>
* An invocation of a standalone slash command
165
>
*/
166
>
export class ChatRequestSlashCommandPart implements IParsedChatRequestPart {
167
>
static readonly Kind = 'slash';
168
>
readonly kind = ChatRequestSlashCommandPart.Kind;
169
>
constructor(readonly range: OffsetRange, readonly editorRange: IRange, readonly slashCommand: IChatSlashData) { }
170
>
171
>
get text(): string {
172
return `${chatSubcommandLeader}${this.slashCommand.command}`;
173
}
175
>
get promptText(): string {
176
return `${chatSubcommandLeader}${this.slashCommand.command}`;
177
}
179
>
180
>
/**
181
>
* An invocation of a standalone slash command
182
>
*/
183
>
export class ChatRequestSlashPromptPart implements IParsedChatRequestPart {
184
>
static readonly Kind = 'prompt';
185
>
readonly kind = ChatRequestSlashPromptPart.Kind;
186
>
readonly displayText?: string;
187
>
constructor(readonly range: OffsetRange, readonly editorRange: IRange, readonly name: string, displayText?: string) {
188
// Only set the own property when provided so the canonical
189
// form (no `displayText` field) stays compatible with snapshots