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

Function walkMarkdown

packages/agent-core/src/plugin/manifest.ts:362–381  ·  view source on GitHub ↗
(
  root: string,
  dir: string,
  out: PluginCommandEntry[],
)

Source from the content-addressed store, hash-verified

360}
361
362async function walkMarkdown(
363 root: string,
364 dir: string,
365 out: PluginCommandEntry[],
366): Promise<void> {
367 let entries;
368 try {
369 entries = await readdir(dir, { withFileTypes: true });
370 } catch {
371 return;
372 }
373 for (const entry of entries) {
374 const full = path.join(dir, entry.name);
375 if (entry.isDirectory()) {
376 await walkMarkdown(root, full, out);
377 } else if (entry.isFile() && entry.name.endsWith('.md')) {
378 out.push({ path: full, name: commandNameFromFile(full, root) });
379 }
380 }
381}
382
383function commandNameFromFile(file: string, root: string): string {
384 const relative = path.relative(root, file).replace(/\.md$/i, '');

Callers 1

Calls 3

commandNameFromFileFunction · 0.85
readdirFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected