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

Function buildSearchContext

lib/compress/search.ts:16–44  ·  view source on GitHub ↗
(state: SessionState, rawMessages: WithParts[])

Source from the content-addressed store, hash-verified

14}
15
16export function buildSearchContext(state: SessionState, rawMessages: WithParts[]): SearchContext {
17 const rawMessagesById = new Map<string, WithParts>()
18 const rawIndexById = new Map<string, number>()
19 for (const msg of rawMessages) {
20 rawMessagesById.set(msg.info.id, msg)
21 }
22 for (let index = 0; index < rawMessages.length; index++) {
23 const message = rawMessages[index]
24 if (!message) {
25 continue
26 }
27 rawIndexById.set(message.info.id, index)
28 }
29
30 const summaryByBlockId = new Map()
31 for (const [blockId, block] of state.prune.messages.blocksById) {
32 if (!block.active) {
33 continue
34 }
35 summaryByBlockId.set(blockId, block)
36 }
37
38 return {
39 rawMessages,
40 rawMessagesById,
41 rawIndexById,
42 summaryByBlockId,
43 }
44}
45
46export function resolveBoundaryIds(
47 context: SearchContext,

Callers 1

prepareSessionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected