MCPcopy Create free account
hub / github.com/anomalyco/opencode / takePrefix

Function takePrefix

packages/core/src/tool-output-store.ts:50–60  ·  view source on GitHub ↗
(input: string, maximumBytes: number)

Source from the content-addressed store, hash-verified

48export class Service extends Context.Service<Service, Interface>()("@opencode/v2/ToolOutputStore") {}
49
50const takePrefix = (input: string, maximumBytes: number) => {
51 let bytes = 0
52 let content = ""
53 for (const char of input) {
54 const size = Buffer.byteLength(char, "utf-8")
55 if (bytes + size > maximumBytes) break
56 content += char
57 bytes += size
58 }
59 return content
60}
61
62const takeSuffix = (input: string, maximumBytes: number) => {
63 let bytes = 0

Callers 2

previewFunction · 0.85
boundedPreviewFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected