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

Function countTurns

lib/state/utils.ts:76–93  ·  view source on GitHub ↗
(state: SessionState, messages: WithParts[])

Source from the content-addressed store, hash-verified

74}
75
76export function countTurns(state: SessionState, messages: WithParts[]): number {
77 let turnCount = 0
78 for (const msg of messages) {
79 if (!isMessageWithInfo(msg)) {
80 continue
81 }
82 if (isMessageCompacted(state, msg)) {
83 continue
84 }
85 const parts = Array.isArray(msg.parts) ? msg.parts : []
86 for (const part of parts) {
87 if (part.type === "step-start") {
88 turnCount++
89 }
90 }
91 }
92 return turnCount
93}
94
95export function loadPruneMap(obj?: Record<string, number>): Map<string, number> {
96 if (!obj || typeof obj !== "object") {

Callers 2

checkSessionFunction · 0.90
ensureSessionInitializedFunction · 0.90

Calls 2

isMessageWithInfoFunction · 0.90
isMessageCompactedFunction · 0.85

Tested by

no test coverage detected