MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / formatData

Method formatData

lib/logger.ts:22–45  ·  view source on GitHub ↗
(data?: any)

Source from the content-addressed store, hash-verified

20 }
21
22 private formatData(data?: any): string {
23 if (!data) return ""
24
25 const parts: string[] = []
26 for (const [key, value] of Object.entries(data)) {
27 if (value === undefined || value === null) continue
28
29 // Format arrays compactly
30 if (Array.isArray(value)) {
31 if (value.length === 0) continue
32 parts.push(
33 `${key}=[${value.slice(0, 3).join(",")}${value.length > 3 ? `...+${value.length - 3}` : ""}]`,
34 )
35 } else if (typeof value === "object") {
36 const str = JSON.stringify(value)
37 if (str.length < 50) {
38 parts.push(`${key}=${str}`)
39 }
40 } else {
41 parts.push(`${key}=${value}`)
42 }
43 }
44 return parts.join(" ")
45 }
46
47 private getCallerFile(skipFrames: number = 3): string {
48 const originalPrepareStackTrace = Error.prepareStackTrace

Callers 1

writeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected