MCPcopy Index your code
hub / github.com/codeaashu/claude-code / coerceDescriptionToString

Function coerceDescriptionToString

src/utils/frontmatterParser.ts:304–326  ·  view source on GitHub ↗
(
  value: unknown,
  componentName?: string,
  pluginName?: string,
)

Source from the content-addressed store, hash-verified

302 * @param pluginName - The plugin name, if this came from a plugin
303 */
304export function coerceDescriptionToString(
305 value: unknown,
306 componentName?: string,
307 pluginName?: string,
308): string | null {
309 if (value == null) {
310 return null
311 }
312 if (typeof value === 'string') {
313 return value.trim() || null
314 }
315 if (typeof value === 'number' || typeof value === 'boolean') {
316 return String(value)
317 }
318 // Non-scalar descriptions (arrays, objects) are invalid — log and omit
319 const source = pluginName
320 ? `${pluginName}:${componentName}`
321 : (componentName ?? 'unknown')
322 logForDebugging(`Description invalid for ${source} - omitting`, {
323 level: 'warn',
324 })
325 return null
326}
327
328/**
329 * Parse a boolean frontmatter value.

Callers 5

createPluginCommandFunction · 0.85
loadAgentFromFileFunction · 0.85
loadOutputStyleFromFileFunction · 0.85

Calls 1

logForDebuggingFunction · 0.85

Tested by

no test coverage detected