feat(session): export PrependHistory for shared use across skills
This commit is contained in:
@@ -36,3 +36,21 @@ func FormatHistory(entries []Entry, excludePhase string) string {
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// PrependHistory reads the session log for sessionID and prepends a formatted
|
||||
// history block to task. Returns task unchanged if sessionID or sessionsDir is
|
||||
// empty, or if no prior entries exist.
|
||||
func PrependHistory(sessionsDir, sessionID, currentPhase, task string) string {
|
||||
if sessionID == "" || sessionsDir == "" {
|
||||
return task
|
||||
}
|
||||
entries, err := Read(sessionsDir, sessionID)
|
||||
if err != nil || len(entries) == 0 {
|
||||
return task
|
||||
}
|
||||
history := FormatHistory(entries, currentPhase)
|
||||
if history == "" {
|
||||
return task
|
||||
}
|
||||
return history + "\n---\n\n" + task
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user