MCPcopy Index your code
hub / github.com/anomalyco/opencode / parseAddFileContent

Function parseAddFileContent

packages/opencode/src/patch/index.ts:157–174  ·  view source on GitHub ↗
(lines: string[], startIdx: number)

Source from the content-addressed store, hash-verified

155}
156
157function parseAddFileContent(lines: string[], startIdx: number): { content: string; nextIdx: number } {
158 let content = ""
159 let i = startIdx
160
161 while (i < lines.length && !lines[i].startsWith("***")) {
162 if (lines[i].startsWith("+")) {
163 content += lines[i].substring(1) + "\n"
164 }
165 i++
166 }
167
168 // Remove trailing newline
169 if (content.endsWith("\n")) {
170 content = content.slice(0, -1)
171 }
172
173 return { content, nextIdx: i }
174}
175
176function stripHeredoc(input: string): string {
177 // Match heredoc patterns like: cat <<'EOF'\n...\nEOF or <<EOF\n...\nEOF

Callers 1

parsePatchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected