shots

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package shots lists the pictures a Claude Code agent and its subagents looked at: the image files it Read, and the ones a tool such as a browser's screenshot saved. They come from the transcripts only (the main one and the subagents' beside it), read once from the tail and then by what each gained, as internal/sessionmeta does, so a busy agent's every write costs its new lines. The list holds paths the agent really touched and nothing else: a picture is served only by an id of this list, never by a path a caller names.

Index

Constants

View Source
const (
	// Max is how many pictures the list holds.
	Max = 30
	// MaxBytes is the largest picture served.
	MaxBytes = 12 << 20
)
View Source
const NamedMax = 12

NamedMax is how many pictures one text names, at most.

Variables

View Source
var ErrNotServed = errors.New("shots: not served")

ErrNotServed is the answer for a picture that cannot be handed over: gone, not a plain file, too big, not a picture.

Functions

func Allowed

func Allowed(path string, roots []string) (real string, st os.FileInfo, ok bool)

Allowed is the picture file a path names when it may be shown: an absolute path to an image by its name that, its links followed, is a plain non-empty file of at most MaxBytes inside one of the roots (the roots' own links followed too). It gives the real path and the file's stat; ok is false for anything else, a file that is not there included.

func ID

func ID(path string, at int64) string

ID is the id of a picture: its path and the time it was looked at, so a file written over again and read again is a new picture to a page that cached the old one.

func IsImage

func IsImage(path string) bool

IsImage says whether a path names a picture the list takes.

func Named

func Named(text string) []string

Named is the absolute paths of pictures a text names, in order, each once, exactly as the text writes them. A path inside a word or a link (https://host/a.png, ./a.png, ~/a.png) is not one.

func ScratchRoot

func ScratchRoot() string

ScratchRoot is where Claude Code keeps the scratchpads of this user's sessions.

Types

type File

type File struct {
	Body    *os.File
	Mime    string
	ModTime time.Time
}

File is a picture opened to be served.

func Open

func Open(path string) (File, error)

Open opens a listed picture: a plain file of at most MaxBytes whose first bytes are those of a PNG, a JPEG, a GIF or a WebP — the name says what the agent meant, the bytes what it is. Anything else is ErrNotServed.

func OpenIn

func OpenIn(path string, roots []string) (File, error)

OpenIn opens a picture a message named, as Open does, after Allowed has said it may be shown; the file opened must be the one checked, so a link swapped in between is not followed out of the roots.

type Reader

type Reader struct {
	// Index, when set, reads what a transcript gains for the reader and for the transcript's other readers at once:
	// the reader reads a transcript's tail itself and takes the lines after it from the index. nil has it read every
	// transcript itself.
	Index *transcriptindex.Index
	// contains filtered or unexported fields
}

Reader keeps one cursor per transcript. Reads of one conversation take turns.

func (*Reader) Cursors

func (r *Reader) Cursors() int

Cursors is how many files (transcripts and their subagents') the reader keeps a cursor of.

func (*Reader) Forget

func (r *Reader) Forget(transcript string)

Forget drops the cursors of a transcript and of the subagents beside it.

func (*Reader) Read

func (r *Reader) Read(transcript string) []Shot

Read is the pictures of a transcript and of its subagents', newest first, at most Max.

type Shot

type Shot struct {
	ID    string
	Path  string
	At    int64 // epoch milliseconds
	Agent string
}

Shot is one picture: the file the agent looked at, when, and the subagent that did (its description; "" for the agent itself).

func (Shot) Name

func (s Shot) Name() string

Name is the file's name.

Jump to

Keyboard shortcuts

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