extract

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FilePathTools = map[string]string{
	"Read":         "file_path",
	"Write":        "file_path",
	"Edit":         "file_path",
	"LSP":          "filePath",
	"NotebookEdit": "notebook_path",
}

FilePathTools maps tool names to their JSON field containing the file path. Includes all tools that reference specific files (Read, Write, Edit, LSP, NotebookEdit). Used by buildStandardEntry to show file artifacts in conversation preview.

Functions

func CleanURL

func CleanURL(raw string) string

CleanURL strips JSON escape artifacts and trailing punctuation.

func FormatDiff added in v0.3.0

func FormatDiff(toolName, toolInput string, width int, styles DiffStyles) string

FormatDiff renders a colorized diff from a tool name and its JSON input. Returns empty string if not a change tool or unparseable.

func JSONField

func JSONField(jsonStr, field string) string

JSONField extracts a string field value from a JSON string. Handles both "field":"value" and "field": "value" (with optional space).

func OpenInBrowser

func OpenInBrowser(u string) error

OpenInBrowser opens a URL in the default browser.

func ShortenPath

func ShortenPath(path string) string

ShortenPath creates a display label from a file path.

func SummarizeChangeCount added in v0.3.0

func SummarizeChangeCount(summary string, count int) string

Types

type ChangeItem added in v0.3.0

type ChangeItem struct {
	Item        Item
	ToolNames   []string
	ToolInputs  []string
	Summary     string
	ChangeCount int
	Timestamp   time.Time
}

func BlockChanges added in v0.3.0

func BlockChanges(blocks []session.ContentBlock) []ChangeItem

func EntryChanges added in v0.3.0

func EntryChanges(entries []session.Entry) []ChangeItem

EntryChanges extracts change items from entries, preserving timestamps.

func SessionChanges added in v0.3.0

func SessionChanges(filePath string) []ChangeItem

type DiffStyles added in v0.3.0

type DiffStyles struct {
	Add    func(string) string
	Del    func(string) string
	Hunk   func(string) string
	Header func(string) string
}

DiffStyles holds the ANSI color codes for diff rendering.

func DefaultDiffStyles added in v0.3.0

func DefaultDiffStyles() DiffStyles

DefaultDiffStyles returns plain text styling (no color).

type Item

type Item struct {
	URL      string
	Label    string // short display label
	Category string // github, jira, slack, pr, other
}

Item represents a URL or file path extracted from a session.

func BlockFilePaths

func BlockFilePaths(blocks []session.ContentBlock) []Item

BlockFilePaths extracts unique file paths from tool_use blocks. Includes all file-referencing tools (Read, Write, Edit, etc.).

func BlockModifiedFiles added in v0.3.0

func BlockModifiedFiles(blocks []session.ContentBlock) []Item

BlockModifiedFiles extracts unique file paths from write/edit tool_use blocks. Excludes Read (context-only), image files, and search tools (Glob/Grep).

func BlockURLs

func BlockURLs(blocks []session.ContentBlock) []Item

BlockURLs extracts unique URLs from content blocks.

func CategorizeURL

func CategorizeURL(u string) Item

CategorizeURL classifies a URL and generates a short label.

func EntryURLs

func EntryURLs(entries []session.Entry) []Item

EntryURLs extracts unique URLs from a set of entries.

func SessionFilePaths

func SessionFilePaths(filePath string) []Item

SessionFilePaths loads messages and extracts file paths.

func SessionURLs

func SessionURLs(filePath string) []Item

SessionURLs loads all messages from a session file and extracts unique URLs.

Jump to

Keyboard shortcuts

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