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

Function tokenizeArgs

packages/agent-core/src/skill/parser.ts:253–288  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

251}
252
253function tokenizeArgs(raw: string): string[] {
254 const out: string[] = [];
255 let current = '';
256 let quote: '"' | "'" | undefined;
257 let hasContent = false;
258
259 for (const char of raw) {
260 if (quote !== undefined) {
261 if (char === quote) {
262 quote = undefined;
263 } else {
264 current += char;
265 hasContent = true;
266 }
267 continue;
268 }
269 if (char === '"' || char === "'") {
270 quote = char;
271 hasContent = true;
272 continue;
273 }
274 if (/\s/.test(char)) {
275 if (hasContent) {
276 out.push(current);
277 current = '';
278 hasContent = false;
279 }
280 continue;
281 }
282 current += char;
283 hasContent = true;
284 }
285
286 if (hasContent) out.push(current);
287 return out;
288}
289
290function nonEmptyString(value: unknown): string | undefined {
291 return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined;

Callers 1

expandSkillParametersFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected