pi

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package pi provides the Pi coding agent source for agentwatch.

Pi (github.com/earendil-works/pi) stores sessions as JSONL files at:

<sessions_dir>/--<path>--/<timestamp>_<uuid>.jsonl

where <path> is the working directory with "/" replaced by "-". The sessions directory defaults to ~/.pi/agent/sessions but can be overridden by passing it via WithRoot. Consumers that want environment fallback can implement it themselves:

sessDir := os.Getenv("PI_CODING_AGENT_SESSION_DIR")
if sessDir == "" {
    base := os.Getenv("PI_CODING_AGENT_DIR")
    if base == "" {
        home, _ := os.UserHomeDir()
        base = filepath.Join(home, ".pi", "agent")
    }
    sessDir = filepath.Join(base, "sessions")
}
src := pi.New(pi.WithRoot(sessDir))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(r *source.Registry, opts ...Option) error

Register registers this source with a source.Registry using a factory that calls New(opts...).

Types

type Option

type Option func(*Source)

Option configures a Source.

func WithDiscoverWindow

func WithDiscoverWindow(d time.Duration) Option

WithDiscoverWindow limits discovery to session files whose modification time is within d of the current time. Zero disables age filtering.

func WithRoot

func WithRoot(path string) Option

WithRoot sets the Pi sessions directory (the directory containing encoded-path subdirectories such as --home-user-project--). Without this option the source discovers no sessions.

type Source

type Source struct {
	// contains filtered or unexported fields
}

Source implements source.Source for Pi coding agent sessions.

Pi stores sessions under a root sessions directory in per-project subdirectories named --<encoded-path>--. Each session is a JSONL file named <timestamp>_<uuid>.jsonl.

func New

func New(opts ...Option) *Source

New creates a new Pi source with the given options.

func (*Source) Discover

func (s *Source) Discover(ctx context.Context) ([]source.SessionHandle, error)

Discover implements source.Source. It walks the configured root for Pi session JSONL files and returns a handle for each one found.

func (*Source) Name

func (s *Source) Name() string

Name implements source.Source.

func (*Source) Parse

Parse implements source.Source. The cursor is the byte offset into the session file as a decimal string. An empty cursor means start from zero.

Jump to

Keyboard shortcuts

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