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

Function completedCompactions

packages/opencode/src/session/compaction.ts:62–78  ·  view source on GitHub ↗
(messages: SessionV1.WithParts[])

Source from the content-addressed store, hash-verified

60}
61
62function completedCompactions(messages: SessionV1.WithParts[]) {
63 const users = new Map<MessageID, number>()
64 for (let i = 0; i < messages.length; i++) {
65 const msg = messages[i]
66 if (msg.info.role !== "user") continue
67 if (!msg.parts.some((part) => part.type === "compaction")) continue
68 users.set(msg.info.id, i)
69 }
70
71 return messages.flatMap((msg, assistantIndex): CompletedCompaction[] => {
72 if (msg.info.role !== "assistant") return []
73 if (!msg.info.summary || !msg.info.finish || msg.info.error) return []
74 const userIndex = users.get(msg.info.parentID)
75 if (userIndex === undefined) return []
76 return [{ userIndex, assistantIndex, summary: summaryText(msg) }]
77 })
78}
79
80function preserveRecentBudget(input: { cfg: ConfigV1.Info; model: Provider.Model }) {
81 return (

Callers 1

compaction.tsFile · 0.85

Calls 3

summaryTextFunction · 0.85
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected