MCPcopy Create free account
hub / github.com/codehamr/codehamr / countHistoryLines

Function countHistoryLines

internal/tui/history_store.go:115–128  ·  view source on GitHub ↗

countHistoryLines tallies lines without parsing them: fast path for the trim decision in appendPromptHistory.

(path string)

Source from the content-addressed store, hash-verified

113// countHistoryLines tallies lines without parsing them: fast path for the
114// trim decision in appendPromptHistory.
115func countHistoryLines(path string) (int, error) {
116 f, err := os.Open(path)
117 if err != nil {
118 return 0, err
119 }
120 defer f.Close()
121 sc := bufio.NewScanner(f)
122 sc.Buffer(make([]byte, 64*1024), historyScannerMax)
123 n := 0
124 for sc.Scan() {
125 n++
126 }
127 return n, sc.Err()
128}
129
130// clearPromptHistory removes the on-disk file so /clear also wipes recall.
131// A missing file is not an error: the empty-history intent already holds.

Callers 1

appendPromptHistoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected