discovery

package
v0.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AgentIDLength is the expected length of agent ID hex strings
	AgentIDLength = 8
	// UUIDLength is the expected length of UUID strings (with hyphens)
	UUIDLength = 36
)
View Source
const MaxLinesForExtraction = 50

MaxLinesForExtraction limits how many lines we read when extracting metadata. Summaries and first user messages typically appear in the first few lines.

View Source
const MaxMetadataFieldSize = 8 * 1024 // 8KB

MaxMetadataFieldSize is the backend-imposed limit for metadata fields like first_user_message. The server rejects metadata fields larger than this value. Messages are truncated to half this (4KB) to leave headroom in chunk uploads. If the backend limit changes, this constant must be updated accordingly.

Variables

This section is empty.

Functions

func ExtractAgentIDsFromMessage

func ExtractAgentIDsFromMessage(message map[string]interface{}) []string

ExtractAgentIDsFromMessage extracts agent IDs from a parsed JSONL message. It checks both root-level toolUseResult.agentId and nested content blocks.

func FindSessionByID

func FindSessionByID(partialID string) (fullID string, transcriptPath string, err error)

FindSessionByID finds a session transcript by full or partial ID Returns the full session ID and transcript path

func GetProjectsDir

func GetProjectsDir() (string, error)

GetProjectsDir returns the path to the Claude projects directory (defaults to ~/.claude/projects, can be overridden with CONFAB_CLAUDE_DIR)

func IsValidAgentID

func IsValidAgentID(s string) bool

IsValidAgentID checks if a string is a valid 8-character hex agent ID

func ReadHookInputFrom

func ReadHookInputFrom(r io.Reader) (*types.HookInput, error)

ReadHookInputFrom reads and parses hook data from the given reader

func SanitizeText

func SanitizeText(input string) string

SanitizeText removes HTML tags, decodes HTML entities, and normalizes whitespace.

Types

type ExtractionResult

type ExtractionResult struct {
	Summary          string        // Local summary for current session (no leafUuid)
	FirstUserMessage string        // First user message content
	SummaryLinks     []SummaryLink // Summaries with leafUuid (for linking to previous sessions)
}

ExtractionResult holds extracted metadata from transcript lines.

func ExtractMetadataFromLines

func ExtractMetadataFromLines(lines []string) ExtractionResult

ExtractMetadataFromLines extracts summary and first user message from transcript lines. Unlike ExtractSessionMetadata, this processes lines already in memory (from a chunk).

For summaries:

  • Summaries with leafUuid are collected in SummaryLinks (for linking to previous sessions)
  • Summaries without leafUuid are local to current session (last one wins)

For user messages:

  • First user message encountered sets FirstUserMessage

func ExtractSessionMetadata

func ExtractSessionMetadata(transcriptPath string) ExtractionResult

ExtractSessionMetadata reads a transcript file and extracts summary and first user message. It reads up to MaxLinesForExtraction lines and delegates to ExtractMetadataFromLines.

type SessionInfo

type SessionInfo struct {
	SessionID        string
	TranscriptPath   string
	ProjectPath      string // Relative path from projects dir
	ModTime          time.Time
	SizeBytes        int64
	Summary          string // First summary after first user message
	FirstUserMessage string // First user message content
}

SessionInfo holds metadata about a discovered session

func ScanAllSessions

func ScanAllSessions() ([]SessionInfo, error)

ScanAllSessions finds all session transcript files in ~/.claude/projects/ Returns sessions sorted by modification time (oldest first)

type SummaryLink struct {
	Summary  string
	LeafUUID string
}

SummaryLink represents a summary that links to a previous session via leafUuid.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL