MCPcopy Create free account
hub / github.com/cursor/cookbook / formatArgValue

Function formatArgValue

sdk/coding-agent-cli/src/agent.ts:576–594  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

574}
575
576function formatArgValue(value: unknown): string | undefined {
577 if (typeof value === "string") {
578 return shortenValue(value.replace(/\s+/g, " ").trim())
579 }
580
581 if (typeof value === "number" || typeof value === "boolean") {
582 return String(value)
583 }
584
585 if (Array.isArray(value)) {
586 const items: string[] = value
587 .slice(0, 3)
588 .map(formatArgValue)
589 .filter((item): item is string => Boolean(item))
590 return items.length > 0 ? `[${items.join(",")}]` : undefined
591 }
592
593 return undefined
594}
595
596function shortenValue(value: string, maxLength = 80) {
597 if (value.length <= maxLength) {

Callers 1

summarizeFirstValueFunction · 0.85

Calls 1

shortenValueFunction · 0.85

Tested by

no test coverage detected