Skip to content

Commit 03394e2

Browse files
authored
Merge pull request microsoft#253040 from microsoft/copilot/fix-253029
Add Fig completion spec for `code chat` CLI subcommand
2 parents 26325e8 + 6a9fe87 commit 03394e2

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

extensions/terminal-suggest/src/completions/code.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ export const extTunnelSubcommand = {
549549
};
550550

551551

552-
export const codeTunnelSubcommands = [
552+
export const codeTunnelSubcommands: Fig.Subcommand[] = [
553553
{
554554
name: 'tunnel',
555555
description: 'Create a tunnel that\'s accessible on vscode.dev from anywhere. Run`code tunnel --help` for more usage info',
@@ -797,6 +797,39 @@ export const codeTunnelSubcommands = [
797797
},
798798
],
799799
},
800+
{
801+
name: 'chat',
802+
description: 'Pass in a prompt to run in a chat session in the current working directory.',
803+
args: {
804+
name: 'prompt',
805+
description: 'The prompt to use as chat',
806+
isVariadic: true,
807+
isOptional: true,
808+
},
809+
options: [
810+
{
811+
name: ['-m', '--mode'],
812+
description: 'The mode to use for the chat session. Defaults to \'agent\'',
813+
args: {
814+
name: 'mode',
815+
suggestions: ['agent', 'ask', 'edit'],
816+
},
817+
},
818+
{
819+
name: ['-a', '--add-file'],
820+
description: 'Add files as context to the chat session',
821+
isRepeatable: true,
822+
args: {
823+
name: 'file',
824+
template: 'filepaths',
825+
},
826+
},
827+
{
828+
name: ['-h', '--help'],
829+
description: 'Print usage',
830+
},
831+
],
832+
},
800833
{
801834
name: 'status',
802835
description: 'Print process usage and diagnostics information',
@@ -953,6 +986,10 @@ export const codeTunnelSubcommands = [
953986
}
954987
],
955988
},
989+
{
990+
name: 'chat',
991+
description: 'Pass in a prompt to run in a chat session in the current working directory.',
992+
},
956993
extTunnelSubcommand,
957994
{
958995
name: 'status',

extensions/terminal-suggest/src/test/completions/code.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const codeSpecOptionsAndSubcommands = [
6060
'--version',
6161
'--wait',
6262
'tunnel',
63+
'chat [<prompt>]',
6364
'serve-web',
6465
'help',
6566
'status',
@@ -71,6 +72,7 @@ export function createCodeTestSpecs(executable: string): ITestSpec[] {
7172
const categoryOptions = ['azure', 'data science', 'debuggers', 'extension packs', 'education', 'formatters', 'keymaps', 'language packs', 'linters', 'machine learning', 'notebooks', 'programming languages', 'scm providers', 'snippets', 'testing', 'themes', 'visualization', 'other'];
7273
const logOptions = ['critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'];
7374
const syncOptions = ['on', 'off'];
75+
const chatOptions = ['--add-file <file>', '--help', '--mode <mode>', '-a <file>', '-h', '-m <mode>'];
7476

7577
const typingTests: ITestSpec[] = [];
7678
for (let i = 1; i < executable.length; i++) {
@@ -119,6 +121,11 @@ export function createCodeTestSpecs(executable: string): ITestSpec[] {
119121
{ input: `${executable} --category |`, expectedCompletions: categoryOptions },
120122
{ input: `${executable} --category a|`, expectedCompletions: categoryOptions },
121123

124+
// Chat subcommand tests
125+
{ input: `${executable} chat |`, expectedCompletions: chatOptions },
126+
{ input: `${executable} chat --mode |`, expectedCompletions: ['agent', 'ask', 'edit'] },
127+
{ input: `${executable} chat --add-file |`, expectedResourceRequests: { type: 'files', cwd: testPaths.cwd } },
128+
122129
// Middle of command
123130
{ input: `${executable} | --locale`, expectedCompletions: codeSpecOptionsAndSubcommands, expectedResourceRequests: { type: 'both', cwd: testPaths.cwd } },
124131
];
@@ -177,6 +184,7 @@ export function createCodeTunnelTestSpecs(executable: string): ITestSpec[] {
177184
'-s',
178185
'-v',
179186
'-w',
187+
'chat [<prompt>]',
180188
'ext',
181189
'help',
182190
'serve-web',
@@ -273,6 +281,9 @@ export function createCodeTunnelTestSpecs(executable: string): ITestSpec[] {
273281
{ input: `${executable} tunnel unregister |`, expectedCompletions: [...commonFlags] },
274282
{ input: `${executable} tunnel service |`, expectedCompletions: [...commonFlags, 'help', 'install', 'log', 'uninstall'] },
275283
{ input: `${executable} tunnel help |`, expectedCompletions: helpSubcommands },
284+
{ input: `${executable} chat |`, expectedCompletions: ['--mode <mode>', '--add-file <file>', '--help', '-m <mode>', '-a <file>', '-h'] },
285+
{ input: `${executable} chat --mode |`, expectedCompletions: ['agent', 'ask', 'edit'] },
286+
{ input: `${executable} chat --add-file |`, expectedResourceRequests: { type: 'files', cwd: testPaths.cwd } },
276287
{ input: `${executable} serve-web |`, expectedCompletions: serveWebSubcommandsAndFlags },
277288
{ input: `${executable} ext |`, expectedCompletions: extSubcommands },
278289
{ input: `${executable} ext list |`, expectedCompletions: [...commonFlags, '--category [<category>]', '--show-versions'] },

0 commit comments

Comments
 (0)