Help us shape the future of Go! Take the 2026 Go Developer Survey

capture

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const NoSpawnEnv = "XIS_NO_ASYNC_INGEST"
View Source
const SpoolVersion = 1

Variables

This section is empty.

Functions

func AppendLine

func AppendLine(spoolDir, sessionID string, l Line) error

func DropSpool

func DropSpool(spoolDir, sessionID string, n int64) error

DropSpool removes the first n bytes that TakeSpool returned. Hooks only append, so the lines written after TakeSpool stay for the next ingest.

func HookCommand

func HookCommand(xisCmd, agent, event string) string

func Install

func Install(path, xisCmd, agent string) ([]string, error)

Install merges the xis hooks into the hook file of the agent. Claude Code and Codex use the same format. It keeps all other settings and hooks, and it does not add an entry twice.

func Installed

func Installed(path string) (map[string]bool, error)

Installed reports which events have an xis hook in the settings file.

func IsHome

func IsHome(dir string) bool

IsHome reports whether dir is the home directory. A git repository there holds all files of the user, so xis neither installs project hooks for it nor takes snapshots of it.

func LockIngest

func LockIngest(spoolDir, sessionID string, timeout time.Duration) (*lockfile.Lock, error)

LockIngest lets one ingest of a session run at a time. Hooks never take it.

func LockSession

func LockSession(spoolDir, sessionID string, timeout time.Duration) (*lockfile.Lock, error)

LockSession serializes ingest with the hooks of the same session.

func RemoveSpool

func RemoveSpool(spoolDir, sessionID string) error

RemoveSpool deletes the spool file. It keeps the lock files: another process can hold them, and a new file would give a second lock holder.

func SettingsPath

func SettingsPath(agent, scope, repoDir, home string) (string, error)

SettingsPath is the file that holds the hooks of the agent: the settings of Claude Code, or the hooks.json of Codex.

func SpawnIngest

func SpawnIngest(sessionID string) error

func SpoolPath

func SpoolPath(spoolDir, sessionID string) string

func Uninstall

func Uninstall(path string) ([]string, error)

Types

type Handler

type Handler struct {
	Agent string
	Paths config.Paths
	Cfg   config.Config
	Now   func() time.Time
	Spawn func(sessionID string) error
}

func NewHandler

func NewHandler(p config.Paths, c config.Config) *Handler

func (*Handler) Handle

func (h *Handler) Handle(event string, stdin io.Reader)

Handle must never fail the agent: it returns nothing, writes nothing to stdout and recovers from panics.

type Line

type Line struct {
	V             int             `json:"xis_v"`
	Agent         string          `json:"agent,omitempty"`
	Ts            time.Time       `json:"ts"`
	Event         string          `json:"event"`
	Payload       json.RawMessage `json:"payload"`
	Snapshot      *string         `json:"snapshot"`
	Repo          *RepoInfo       `json:"repo,omitempty"`
	NoGit         bool            `json:"no_git,omitempty"`
	SnapshotError string          `json:"snapshot_error,omitempty"`
}

func TakeSpool

func TakeSpool(spoolDir, sessionID string) ([]Line, int64, error)

TakeSpool reads the spool of a session under the session lock and returns its lines and its size. The lock is held only for the read, so the hooks of a running session never wait for an ingest.

func (Line) SnapshotID

func (l Line) SnapshotID() string

type RepoInfo

type RepoInfo struct {
	ID        string `json:"id"`
	Top       string `json:"top"`
	CommonDir string `json:"common_dir,omitempty"`
	Head      string `json:"head,omitempty"`
	Remote    string `json:"remote,omitempty"`
}

type SpoolFile

type SpoolFile struct {
	SessionID string
	Path      string
	ModTime   time.Time
	Size      int64
}

func ListSpool

func ListSpool(spoolDir string) ([]SpoolFile, error)

Jump to

Keyboard shortcuts

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