MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / handleAddDirCommand

Function handleAddDirCommand

apps/kimi-code/src/tui/commands/add-dir.ts:7–53  ·  view source on GitHub ↗
(host: SlashCommandHost, args: string)

Source from the content-addressed store, hash-verified

5type AddDirChoice = 'session' | 'remember' | 'cancel';
6
7export async function handleAddDirCommand(host: SlashCommandHost, args: string): Promise<void> {
8 const input = args.trim();
9 const session = host.session;
10
11 if (input.length === 0 || input.toLowerCase() === 'list') {
12 const additionalDirs = session?.summary?.additionalDirs ?? [];
13 if (additionalDirs.length === 0) {
14 host.showStatus('No additional directories configured.');
15 return;
16 }
17 host.showStatus(formatAdditionalDirsStatus(additionalDirs));
18 return;
19 }
20
21 if (session === undefined) {
22 host.showError(NO_ACTIVE_SESSION_MESSAGE);
23 return;
24 }
25
26 host.mountEditorReplacement(
27 new ChoicePickerComponent({
28 title: `Add directory to workspace: ${input}`,
29 hint: '↑↓ navigate · Enter confirm · Esc cancel',
30 options: [
31 {
32 value: 'session',
33 label: 'Yes, for this session',
34 },
35 {
36 value: 'remember',
37 label: 'Yes, and remember this directory',
38 },
39 {
40 value: 'cancel',
41 label: 'No',
42 },
43 ],
44 onSelect: (value) => {
45 void handleAddDirChoice(host, session.id, input, value as AddDirChoice);
46 },
47 onCancel: () => {
48 host.restoreEditor();
49 host.showStatus(`Did not add ${input} as a working directory.`);
50 },
51 }),
52 );
53}
54
55function formatAdditionalDirsStatus(additionalDirs: readonly string[]): string {
56 return ['Additional directories:', ...additionalDirs.map((dir) => ` ${dir}`)].join('\n');

Callers 2

add-dir.test.tsFile · 0.90

Calls 6

handleAddDirChoiceFunction · 0.85
showStatusMethod · 0.65
showErrorMethod · 0.65
restoreEditorMethod · 0.65

Tested by

no test coverage detected