Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

handoff: keep scanHead's signature and give fx its own line bound

Claude58650fe5129d
diff --git a/cli/beacon/internal/handoff/claude.go b/cli/beacon/internal/handoff/claude.go
index d20153a2..018b4493 100644
--- a/cli/beacon/internal/handoff/claude.go
+++ b/cli/beacon/internal/handoff/claude.go
@@ -29,7 +29,7 @@ type claudeHead struct {
// index entry needs the cwd its transcript records.
func readClaudeHead(path string) claudeHead {
var head claudeHead
- scanHead(path, claudeHeadMaxLineSize, func(line []byte) bool {
+ scanHead(path, func(line []byte) bool {
head.consume(line)
return head.CWD != "" && head.GitBranch != "" && head.FirstPrompt != ""
})
@@ -38,10 +38,14 @@ func readClaudeHead(path string) claudeHead {
// scanHead passes the first lines of a JSONL transcript to consume until it returns true, within
// the listing bounds above. A listing opens every transcript, so it reads only its head.
-// maxLineSize controls the largest single line the scanner will keep; lines longer than it are
-// silently skipped so one huge tool result cannot stall a listing. maxBytes caps the total bytes
-// read from the file.
-func scanHead(path string, maxLineSize int, consume func(line []byte) (done bool)) {
+func scanHead(path string, consume func(line []byte) (done bool)) {
+ scanHeadLines(path, claudeHeadMaxLineSize, consume)
+}
+
+// scanHeadLines is scanHead for a transcript whose lines can run longer than a listing's usual
+// bound: a line up to maxLineSize is kept, and one past it is skipped. The byte budget grows with
+// the line bound, so the first long line can still be read whole.
+func scanHeadLines(path string, maxLineSize int, consume func(line []byte) (done bool)) {
maxBytes := int64(claudeHeadMaxBytes)
if int64(maxLineSize) > maxBytes {
maxBytes = int64(maxLineSize) + int64(claudeHeadMaxBytes)
diff --git a/cli/beacon/internal/handoff/fx.go b/cli/beacon/internal/handoff/fx.go
index eba0f277..5473bd31 100644
--- a/cli/beacon/internal/handoff/fx.go
+++ b/cli/beacon/internal/handoff/fx.go
@@ -89,7 +89,7 @@ type fxHead struct {
// log. fx commits a whole turn, prompt included, as one line, so the first prompt is near the top.
func readFxHead(path string) fxHead {
var head fxHead
- scanHead(path, fxsession.MaxFrameBytes, func(line []byte) bool {
+ scanHeadLines(path, fxsession.MaxFrameBytes, func(line []byte) bool {
event, err := fxsession.DecodeEnvelope(line)
if err != nil {
return false
diff --git a/cli/beacon/internal/handoff/pi.go b/cli/beacon/internal/handoff/pi.go
index c9a81e2a..4c05b4f5 100644
--- a/cli/beacon/internal/handoff/pi.go
+++ b/cli/beacon/internal/handoff/pi.go
@@ -165,7 +165,7 @@ func piHeaderBranch(header map[string]interface{}) string {
// readPiFirstPrompt returns the first thing a person typed in a Pi-format transcript.
func readPiFirstPrompt(path string) string {
var prompt string
- scanHead(path, claudeHeadMaxLineSize, func(line []byte) bool {
+ scanHead(path, func(line []byte) bool {
var entry struct {
Type string `json:"type"`
Message struct {