fork

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 12 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 fork cuts an agent's transcript at one of the person's messages and writes what comes before it as a new session of the agent, which the agent CLI resumes as its own: the conversation goes on from that point, the old transcript stays as it was.

Neither CLI can be driven there by a flag of an interactive start: Claude Code's --resume-session-at is read only in print mode, and its Esc-Esc picker (like Codex's Esc-Esc backtrack) rewinds inside the same transcript, which then holds both branches one after the other. A new session file holds only the kept one, and `claude --resume <id>` / `codex resume <id>` take it as it is (the session id inside the lines is the file's own, a uuid of the same length, so every kept line stays at its byte offset and the feed's entry ids do not move).

Index

Constants

View Source
const (
	Claude = "claude"
	Codex  = "codex"
)

Providers, as the conversations name them.

Variables

View Source
var (
	// ErrNotFound: the transcript holds no line of that message.
	ErrNotFound = errors.New("fork: the message is not in the transcript")
	// ErrNothingKept: the cut is before the first message, and an agent cannot resume a session without one.
	ErrNothingKept = errors.New("fork: nothing before the message")
)

Functions

func Cut

func Cut(provider, path, entryID string) (int64, error)

Cut is where a rewind to the person's message entryID cuts the transcript: the start of the message's line, moved back over the lines that only open its turn. Claude's entry ids name the line's uuid ("c:<uuid>#k"), Codex's its offset ("x:<offset>#k").

func SessionID

func SessionID(path string) string

SessionID is the session of a transcript, read off its file name (Claude: <id>.jsonl, Codex: rollout-…-<id>.jsonl).

Types

type Session

type Session struct {
	ID   string
	Path string
}

Session is a forked session: its id and transcript.

func Write

func Write(provider, path, oldID string, cut int64, now time.Time) (Session, error)

Write writes the first cut bytes of the transcript at path, whose session is oldID, as a new session of the agent and returns it. The old transcript is not touched.

Jump to

Keyboard shortcuts

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