// internal/session/history.go package session import ( "fmt" "strings" ) // FormatHistory formats prior session entries as a structured block for // injection into a worker task prompt. Entries matching excludePhase are // omitted (pass the current phase to avoid circular injection). func FormatHistory(entries []Entry, excludePhase string) string { var filtered []Entry for _, e := range entries { if e.Phase != excludePhase { filtered = append(filtered, e) } } if len(filtered) == 0 { return "" } var b strings.Builder b.WriteString("## Session history\n\n") for _, e := range filtered { fmt.Fprintf(&b, "### Phase: %s\n", e.Phase) //nolint:errcheck // strings.Builder never errors fmt.Fprintf(&b, "- Skill: %s\n", e.Skill) //nolint:errcheck fmt.Fprintf(&b, "- Status: %s\n", e.FinalStatus) //nolint:errcheck if e.FilePath != "" { fmt.Fprintf(&b, "- File: %s\n", e.FilePath) //nolint:errcheck } if e.Message != "" { fmt.Fprintf(&b, "- Summary: %s\n", e.Message) //nolint:errcheck } b.WriteString("\n") } return b.String() }