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

Function contextItemKey

packages/app/src/context/prompt.tsx:122–136  ·  view source on GitHub ↗
(item: ContextItem)

Source from the content-addressed store, hash-verified

120}
121
122function contextItemKey(item: ContextItem) {
123 if (item.type !== "file") return item.type
124 const start = item.selection?.startLine
125 const end = item.selection?.endLine
126 const key = `${item.type}:${item.path}:${start}:${end}`
127
128 if (item.commentID) {
129 return `${key}:c=${item.commentID}`
130 }
131
132 const comment = item.comment?.trim()
133 if (!comment) return key
134 const digest = checksum(comment) ?? comment
135 return `${key}:c=${digest.slice(0, 8)}`
136}
137
138function isCommentItem(item: ContextItem | (ContextItem & { key: string })) {
139 return item.type === "file" && !!item.comment?.trim()

Callers 3

addFunction · 0.85
updateCommentFunction · 0.85
replaceCommentsFunction · 0.85

Calls 1

checksumFunction · 0.90

Tested by

no test coverage detected