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

Function extractSectionName

src/utils/analyzeContext.ts:262–271  ·  view source on GitHub ↗

Extract a human-readable name from a system prompt section's content

(content: string)

Source from the content-addressed store, hash-verified

260
261/** Extract a human-readable name from a system prompt section's content */
262function extractSectionName(content: string): string {
263 // Try to find first markdown heading
264 const headingMatch = content.match(/^#+\s+(.+)$/m)
265 if (headingMatch) {
266 return headingMatch[1]!.trim()
267 }
268 // Fall back to a truncated preview of the first non-empty line
269 const firstLine = content.split('\n').find(l => l.trim().length > 0) ?? ''
270 return firstLine.length > 40 ? firstLine.slice(0, 40) + '…' : firstLine
271}
272
273async function countSystemTokens(
274 effectiveSystemPrompt: readonly string[],

Callers 1

countSystemTokensFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected