MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / appendSkillMenuLines

Function appendSkillMenuLines

packages/node-runtime/src/ai/skill-menu.ts:33–44  ·  view source on GitHub ↗
(baseMenu: string | null | undefined, lines: readonly string[])

Source from the content-addressed store, hash-verified

31}
32
33export function appendSkillMenuLines(baseMenu: string | null | undefined, lines: readonly string[]): string | null {
34 const visibleLines = normalizeSkillMenuLines(lines)
35 if (visibleLines.length === 0) return baseMenu ?? null
36 if (!baseMenu) return buildSkillMenuText(visibleLines)
37
38 const insertion = `\n${visibleLines.join('\n')}`
39 if (!baseMenu.includes(SKILL_MENU_CLOSING_BLOCK)) {
40 return `${baseMenu}${insertion}`
41 }
42
43 return baseMenu.replace(SKILL_MENU_CLOSING_BLOCK, `${insertion}${SKILL_MENU_CLOSING_BLOCK}`)
44}
45
46function normalizeSkillMenuLines(lines: readonly string[]): string[] {
47 return lines.map((line) => line.trim()).filter(Boolean)

Callers 2

skill-menu.test.tsFile · 0.90

Calls 2

normalizeSkillMenuLinesFunction · 0.85
buildSkillMenuTextFunction · 0.85

Tested by

no test coverage detected