MCPcopy Create free account
hub / github.com/Noumena-Network/code / extractDescriptionFromMarkdown

Function extractDescriptionFromMarkdown

src/utils/markdownConfigLoader.ts:95–112  ·  view source on GitHub ↗
(
  content: string,
  defaultDescription: string = 'Custom item',
)

Source from the content-addressed store, hash-verified

93 * Uses the first non-empty line as the description, or falls back to a default
94 */
95export function extractDescriptionFromMarkdown(
96 content: string,
97 defaultDescription: string = 'Custom item',
98): string {
99 const lines = content.split('\n')
100 for (const line of lines) {
101 const trimmed = line.trim()
102 if (trimmed) {
103 // If it's a header, strip the header prefix
104 const headerMatch = trimmed.match(/^#+\s+(.+)$/)
105 const text = headerMatch?.[1] ?? trimmed
106
107 // Return the text, limited to reasonable length
108 return text.length > 100 ? text.substring(0, 97) + '...' : text
109 }
110 }
111 return defaultDescription
112}
113
114/**
115 * Parses tools from frontmatter, supporting both string and array formats

Callers 5

getWorkflowDefinitionsFunction · 0.85
createPluginCommandFunction · 0.85
loadOutputStyleFromFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected