Documentation
¶
Overview ¶
Package format handles message serialization using JSON frontmatter with Markdown body content. It provides message ID generation, parsing, and timestamp-based sorting utilities.
Index ¶
- Constants
- Variables
- func IsValidKind(k string) bool
- func IsValidPriority(p string) bool
- func NewMessageID(now time.Time) (string, error)
- func SortByTimestamp[T Timestamped](items []T)
- func ValidKinds() []string
- func ValidKindsList() string
- func ValidPriorities() []string
- type Header
- type Message
- type Timestamped
Constants ¶
const ( CurrentSchema = 1 CurrentVersion = 1 )
Schema and version constants.
const ( PriorityUrgent = "urgent" PriorityNormal = "normal" PriorityLow = "low" )
Priority constants for co-op mode message handling.
const ( KindBrainstorm = "brainstorm" KindReviewRequest = "review_request" KindReviewResponse = "review_response" KindQuestion = "question" KindAnswer = "answer" KindDecision = "decision" KindStatus = "status" KindTodo = "todo" )
Kind constants for co-op mode message classification.
const MaxMessageSize = 10 * 1024 * 1024
MaxMessageSize is the maximum allowed message file size (10 MB).
Variables ¶
var ( ErrMissingFrontmatterStart = errors.New("missing frontmatter start") ErrMissingFrontmatterEnd = errors.New("missing frontmatter end") ErrMessageTooLarge = errors.New("message exceeds maximum size") )
Sentinel errors for message parsing.
Functions ¶
func IsValidKind ¶ added in v0.6.0
IsValidKind returns true if the kind is valid or empty.
func IsValidPriority ¶ added in v0.6.0
IsValidPriority returns true if the priority is valid or empty.
func SortByTimestamp ¶
func SortByTimestamp[T Timestamped](items []T)
SortByTimestamp sorts a slice of Timestamped items by time, then by ID for stability.
func ValidKinds ¶ added in v0.6.0
func ValidKinds() []string
ValidKinds returns the list of valid kind values.
func ValidKindsList ¶ added in v0.19.0
func ValidKindsList() string
ValidKindsList returns a comma-joined string of valid kind values for usage messages.
func ValidPriorities ¶ added in v0.6.0
func ValidPriorities() []string
ValidPriorities returns the list of valid priority values.
Types ¶
type Header ¶
type Header struct {
Schema int `json:"schema"`
ID string `json:"id"`
From string `json:"from"`
To []string `json:"to"`
Thread string `json:"thread"`
Subject string `json:"subject,omitempty"`
Created string `json:"created"`
AckRequired bool `json:"ack_required"`
Refs []string `json:"refs,omitempty"`
// Co-op mode fields (optional, for inter-agent communication)
Priority string `json:"priority,omitempty"` // urgent, normal, low
Kind string `json:"kind,omitempty"` // message kind (see ValidKinds())
Labels []string `json:"labels,omitempty"` // free-form tags
Context map[string]any `json:"context,omitempty"` // structured context (paths, symbols, etc.)
// Cross-session reply routing (optional). Set automatically when sending
// via --session. Allows replies to route back to the sender's session.
ReplyTo string `json:"reply_to,omitempty"` // e.g., "claude@auth"
// Cross-project reply routing (optional). Set automatically when sending
// via --project. Contains the sender's project name so replies can route
// back to the correct project via peer lookup.
ReplyProject string `json:"reply_project,omitempty"` // e.g., "amq-core"
// Sender's project name (optional). Set automatically on cross-project
// sends so receivers can distinguish same-handle senders from different
// projects (e.g., "claude" in project A vs "claude" in project B).
FromProject string `json:"from_project,omitempty"` // e.g., "homelab-ai"
}
Header is the JSON frontmatter stored at the top of each message file.
func ParseHeader ¶
func ReadHeaderFile ¶
type Message ¶
Message is the in-memory representation of a message file.