agentimport

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package agentimport imports a coding agent's pre-existing local transcripts into Entire as read-only, commit-less checkpoints on the v1 metadata branch.

The orchestration (discovery loop, idempotent per-turn IDs, redaction, and the checkpoint write) is agent-agnostic and lives here. Each agent plugs in an Importer that knows where its transcripts live and how to split one into per-user-prompt turns. Claude Code is the only implementation today (see claude.go); others register themselves the same way.

Index

Constants

View Source
const LookbackDays = 30

LookbackDays bounds how far back import reaches. Fixed this pass (no flag).

Variables

This section is empty.

Functions

func DeriveCheckpointID

func DeriveCheckpointID(sessionID, turnUUID string) id.CheckpointID

DeriveCheckpointID produces a stable 12-hex checkpoint ID for an imported turn. Re-importing the same (sessionID, turnUUID) yields the same ID, which is how import stays idempotent.

Types

type Importer

type Importer interface {
	// Name is the registry key and the provenance source (e.g. "claude-code").
	Name() string
	// AgentType is the display name stored in checkpoint metadata (e.g. "Claude Code").
	AgentType() types.AgentType
	// Discover returns the agent's transcript files for the repo within the
	// lookback window. overridePath replaces the default transcript dir;
	// sessionFilter, when non-empty, keeps only matching session IDs.
	Discover(repoRoot, overridePath string, now time.Time, sessionFilter []string) ([]SessionFile, error)
	// SplitTurns splits one session's raw transcript bytes into per-turn units.
	SplitTurns(sf SessionFile, full []byte) ([]Turn, error)
}

Importer is the per-agent seam: it locates an agent's transcripts for a repo and splits one into per-turn units. Everything else (idempotency, redaction, writing) is handled generically by Run.

func All

func All() []Importer

All returns every supported importer, sorted by name.

type Options

type Options struct {
	RepoRoot      string
	OverridePath  string
	SessionFilter []string
	Now           time.Time
	DryRun        bool
}

Options configures an import run.

type Result

type Result struct {
	SessionsScanned int
	TurnsImported   int
	TurnsSkipped    int
}

Result summarizes an import run.

func Run

func Run(ctx context.Context, repo *git.Repository, imp Importer, opts Options) (Result, error)

Run imports the given agent's transcripts (within the lookback window) as read-only checkpoints on the v1 metadata branch (Kind "imported"). It is idempotent: turns whose deterministic ID already exists are skipped.

type SessionFile

type SessionFile struct {
	Path      string // absolute path to the transcript file
	SessionID string // agent session id (used in checkpoint metadata)
}

SessionFile is one discovered agent transcript for a repo.

type Turn

type Turn struct {
	LineStart, LineEnd int
	UUID               string
	Prompt, Model      string
	CreatedAt          time.Time
	Tokens             *types.TokenUsage
}

Turn is one user-prompt turn extracted from a session transcript. Line offsets are in raw-line space (newline-counted), matching transcript slicing and the agent token-usage helpers.

Jump to

Keyboard shortcuts

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