Documentation
¶
Overview ¶
Package format transforms session data into formatted journal Markdown with frontmatter and turn headers.
Index ¶
- func Duration(d interface{ ... }) string
- func ExtractSystemReminders(content string) (string, []string)
- func FenceForContent(content string) string
- func JournalEntryPart(s *entity.Session, messages []entity.Message, ...) string
- func JournalFilename(s *entity.Session, slugOverride string) string
- func NormalizeCodeFences(content string) string
- func PartNavigation(part, totalParts int, baseName string) string
- func SessionMatchLines(matches []*entity.Session) []string
- func StripLineNumbers(content string) string
- func Tokens(tokens int) string
- func ToolUse(t entity.ToolUse) string
- func Truncate(s string, max int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Duration ¶
Duration formats a duration in a human-readable way.
Parameters:
- d: Duration with Minutes() method
Returns:
- string: Human-readable duration (e.g., "<1m", "5m", "1h30m")
func ExtractSystemReminders ¶
ExtractSystemReminders separates system-reminder content from tool output.
Claude Code injects <system-reminder> tags into tool results. This function extracts them so they can be rendered as Markdown outside code fences.
Parameters:
- content: Tool result content potentially containing system-reminder tags
Returns:
- string: Content with system-reminder tags removed
- []string: Extracted reminder texts (may be empty)
func FenceForContent ¶
FenceForContent returns the appropriate code fence for content.
Uses longer fences when content contains backticks to avoid nested Markdown rendering issues. Starts with ``` and adds more backticks as needed.
Parameters:
- content: The content to be fenced
Returns:
- string: A fence string (e.g., "```", "````", "```"")
func JournalEntryPart ¶
func JournalEntryPart( s *entity.Session, messages []entity.Message, startMsgIdx, part, totalParts int, baseName, title string, ) string
JournalEntryPart generates Markdown content for a part of a journal entry.
Includes metadata, tool usage summary (on part 1 only), navigation links, and the conversation subset for this part.
Parameters:
- s: Session to format
- messages: Subset of messages for this part
- startMsgIdx: Starting message index (for numbering)
- part: Current part number (1-indexed)
- totalParts: Total number of parts
- baseName: Base filename without extension (for navigation links)
- title: Human-readable title for frontmatter and H1 heading (may be empty)
Returns:
- string: Markdown content for this part
func JournalFilename ¶
JournalFilename generates the filename for a journal entry.
Format: YYYY-MM-DD-slug-shortid.md Uses local time for the date.
When slugOverride is non-empty it replaces s.Slug in the filename, allowing title-derived slugs to be used instead of Claude Code's random slug.
Parameters:
- s: Session to generate filename for
- slugOverride: If non-empty, used instead of s.Slug
Returns:
- string: Filename like "2026-01-15-fix-auth-bug-abc12345.md"
func NormalizeCodeFences ¶
NormalizeCodeFences ensures code fences are on their own lines with proper spacing.
Users often type "text: ```code" without proper line breaks. Markdown requires code fences to be on their own lines with blank lines separating them from surrounding content.
Parameters:
- content: Text that may contain inline code fences
Returns:
- string: Content with code fences properly separated by blank lines
func PartNavigation ¶
PartNavigation generates previous/next navigation links for multipart sessions.
Parameters:
- part: Current part number (1-indexed)
- totalParts: Total number of parts
- baseName: Base filename without extension
Returns:
- string: Formatted navigation line (e.g., "**Part 2 of 3** | [← Previous](...) | [Next →](...)")
func SessionMatchLines ¶
SessionMatchLines formats session matches for ambiguous query output.
Parameters:
- matches: sessions that matched the query.
Returns:
- []string: pre-formatted lines, one per match.
func StripLineNumbers ¶
StripLineNumbers removes Claude Code's line number prefixes from content.
Parameters:
- content: Text potentially containing " 1→" style prefixes
Returns:
- string: Content with line number prefixes removed
func Tokens ¶
Tokens formats token counts in a human-readable way.
Parameters:
- tokens: Token count to format
Returns:
- string: Human-readable count (e.g., "500", "1.5K", "2.3M")
Types ¶
This section is empty.