artifacts

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFromToolResult

func ExtractFromToolResult(text string) (prURLs, commitSHAs, externalURLs []string)

ExtractFromToolResult extracts artifacts from the text content of a single tool_result block. Callers must pass only tool_result content — never raw assistant text — to avoid false positives from doc links in explanations.

Types

type ArtifactExtractor

type ArtifactExtractor struct {

	// OnScanComplete is called after a successful scan with new artifacts.
	// Inject event-bus publish logic here; defaults to no-op.
	// This keeps ArtifactExtractor testable without a live event bus.
	OnScanComplete func(title string, blob *SessionArtifactsBlob)
	// contains filtered or unexported fields
}

ArtifactExtractor reads Claude Code JSONL files and extracts structured artifacts (PR URLs, commit SHAs, external URLs) using an incremental byte-offset scan. Mirrors the TokenStore worker pool pattern.

func NewArtifactExtractor

func NewArtifactExtractor(
	storeFn func(title, blob string) error,
	readFn func(title string) (string, error),
	lookupTitle func(filePath string) (string, bool),
) *ArtifactExtractor

NewArtifactExtractor creates an ArtifactExtractor. storeFn: persists the JSON blob (wraps storage.UpdateInstanceArtifacts). readFn: loads the existing blob (wraps storage.GetInstanceArtifacts). lookupTitle: resolves a JSONL path to its session title.

func (*ArtifactExtractor) OnHistoryFileChanged

func (ae *ArtifactExtractor) OnHistoryFileChanged(filePath string)

OnHistoryFileChanged is the HistoryLinker callback — filters and enqueues.

func (*ArtifactExtractor) SeedOffsets

func (ae *ArtifactExtractor) SeedOffsets(instances []InstanceInfo)

SeedOffsets loads each session's existing blob at startup to restore the byte offset — so the first scan after restart reads only new bytes. Call before Start(). Build InstanceInfo slices in dependencies.go from historyLinker.Instances() to avoid a circular import.

func (*ArtifactExtractor) Start

func (ae *ArtifactExtractor) Start(ctx context.Context, historyDir string)

Start launches worker goroutines and the startup backfill walk.

func (*ArtifactExtractor) Stop

func (ae *ArtifactExtractor) Stop()

Stop cancels background goroutines.

type CommandArtifact

type CommandArtifact struct {
	Type    string `json:"type"`    // "gh_pr_create", "gh_pr_merge", "git_commit", "package_install"
	Command string `json:"command"` // first 200 chars of the raw command for display
	Detail  string `json:"detail"`  // extracted value: PR title, commit message, pkg name, PR number
}

CommandArtifact records a structured signal extracted from a tool_use bash command.

func ExtractFromBashCommand

func ExtractFromBashCommand(command string) *CommandArtifact

ExtractFromBashCommand extracts a structured CommandArtifact from a Bash tool_use input command. Returns nil if no known pattern matches. Only call this on tool_use inputs (not tool_result outputs) to avoid double-counting.

type InstanceInfo

type InstanceInfo struct {
	Title           string
	HistoryFilePath string
}

InstanceInfo provides the minimal session data ArtifactExtractor needs. Defined here to avoid a circular import with the session package.

type SessionArtifactsBlob

type SessionArtifactsBlob struct {
	PRURLs          []string          `json:"pr_urls"`
	CommitSHAs      []string          `json:"commit_shas"`
	ExternalURLs    []string          `json:"external_urls"`
	Commands        []CommandArtifact `json:"commands,omitempty"` // from tool_use bash invocations
	ScanOffsetBytes int64             `json:"scan_offset_bytes"`
	LastScannedAt   time.Time         `json:"last_scanned_at"`
}

SessionArtifactsBlob is the JSON-serialized payload stored in the session_artifacts TEXT column.

Jump to

Keyboard shortcuts

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