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

Function prependPathRefs

src/bridge/inboundAttachments.ts:142–161  ·  view source on GitHub ↗
(
  content: string | Array<ContentBlockParam>,
  prefix: string,
)

Source from the content-addressed store, hash-verified

140 * block[0] means they're silently ignored for [text, image] content.
141 */
142export function prependPathRefs(
143 content: string | Array<ContentBlockParam>,
144 prefix: string,
145): string | Array<ContentBlockParam> {
146 if (!prefix) return content
147 if (typeof content === 'string') return prefix + content
148 const i = content.findLastIndex(b => b.type === 'text')
149 if (i !== -1) {
150 const b = content[i]!
151 if (b.type === 'text') {
152 return [
153 ...content.slice(0, i),
154 { ...b, text: prefix + b.text },
155 ...content.slice(i + 1),
156 ]
157 }
158 }
159 // No text block — append one at the end so it's last.
160 return [...content, { type: 'text', text: prefix.trimEnd() }]
161}
162
163/**
164 * Convenience: extract + resolve + prepend. No-op when the message has no

Callers 1

resolveAndPrependFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected