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

Function parseSlashInput

apps/kimi-code/src/tui/commands/parse.ts:3–14  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

1import type { ParsedSlashInput } from './types';
2
3export function parseSlashInput(input: string): ParsedSlashInput | null {
4 if (!input.startsWith('/')) return null;
5 const trimmed = input.slice(1).trim();
6 if (trimmed.length === 0) return null;
7 const spaceIdx = trimmed.indexOf(' ');
8 const name = spaceIdx === -1 ? trimmed : trimmed.slice(0, spaceIdx);
9 const args = spaceIdx === -1 ? '' : trimmed.slice(spaceIdx + 1).trim();
10 // Reject file paths (e.g. `/usr/local/bin`), but allow namespaced plugin
11 // commands whose name itself contains `/` (e.g. `plugin:frontend/component`).
12 if (name.includes('/') && !name.includes(':')) return null;
13 return { name, args };
14}

Callers 4

dispatchInputFunction · 0.90
executeSlashCommandFunction · 0.90
resolveSlashCommandInputFunction · 0.90
registry.test.tsFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected