paths

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntireDir         = ".entire"
	EntireTmpDir      = ".entire/tmp"
	EntireMetadataDir = ".entire/metadata"
)

Directory constants

View Source
const (
	PromptFileName           = "prompt.txt"
	TranscriptFileName       = "full.jsonl"
	TranscriptFileNameLegacy = "full.log"
	// CompactTranscriptFileName is the compact transcript stored alongside
	// full.jsonl. It holds the full compacted session; this checkpoint's slice
	// begins at the session metadata's compact_transcript_start.
	CompactTranscriptFileName = "transcript.jsonl"
	MetadataFileName          = "metadata.json"
	CheckpointFileName        = "checkpoint.json"
	ContentHashFileName       = "content_hash.txt"
	SettingsFileName          = "settings.json"

	// AssetsDir is the per-session subfolder holding externalized transcript
	// assets (e.g. images); AssetsManifestFile indexes them. AssetsDirName is the
	// bare tree-entry name (no trailing slash) used when walking git trees.
	AssetsDirName      = "assets"
	AssetsDir          = "assets/"
	AssetsManifestFile = "assets/manifest.json"
)

Metadata file names

View Source
const MetadataBranchName = "entire/checkpoints/v1"

MetadataBranchName is the orphan branch used by manual-commit strategy to store metadata

View Source
const TrailsBranchName = "entire/trails/v1"

TrailsBranchName is the orphan branch used to store trail metadata. Trails are branch-centric work tracking abstractions that link to checkpoints by branch name.

Variables

This section is empty.

Functions

func AbsPath

func AbsPath(ctx context.Context, relPath string) (string, error)

AbsPath returns the absolute path for a relative path within the repository. If the path is already absolute, it is returned as-is. Uses WorktreeRoot() to resolve paths relative to the worktree root.

func CaseInsensitiveFS added in v0.9.0

func CaseInsensitiveFS() bool

CaseInsensitiveFS reports whether path comparisons should be case-insensitive on the host OS. This is OS-based, not volume-based: Windows and macOS default to case-insensitive filesystems, Linux to case-sensitive. Keying on GOOS keeps the result deterministic. It must only influence EXCLUSION decisions (see IsProtectedSubpath / Equal): on an atypical volume (e.g. a case-sensitive macOS APFS volume) it treats a differently-cased path as matching, which is safe only when the effect is to exclude more, never to widen an allow gate.

func ClearWorktreeRootCache added in v0.4.8

func ClearWorktreeRootCache()

ClearWorktreeRootCache clears the cached worktree root. This is primarily useful for testing when changing directories.

func Equal added in v0.9.0

func Equal(a, b string) bool

Equal reports whether two paths refer to the same location, honoring the host OS's case sensitivity (see CaseInsensitiveFS). Both inputs are cleaned and slash-normalized before comparison. Like IsProtectedSubpath, this is intended for EXCLUSION matching (e.g. protected files), not fail-closed containment.

func ExtractSessionIDFromTranscriptPath

func ExtractSessionIDFromTranscriptPath(transcriptPath string) string

ExtractSessionIDFromTranscriptPath attempts to extract a session ID from a transcript path. Claude transcripts are stored at ~/.claude/projects/<project>/sessions/<id>.jsonl If the path doesn't match expected format, returns empty string.

func GetLastTimestampFromBytes

func GetLastTimestampFromBytes(data []byte) time.Time

GetLastTimestampFromBytes extracts the timestamp from the last non-empty line of JSONL content. Returns zero time if not found.

func GetLastTimestampFromFile

func GetLastTimestampFromFile(path string) time.Time

GetLastTimestampFromFile reads the last non-empty line from a JSONL file and extracts the timestamp field. Returns zero time if file doesn't exist or no valid timestamp is found.

func GetWorktreeID

func GetWorktreeID(worktreePath string) (string, error)

GetWorktreeID returns the internal git worktree identifier for the given path. For the main worktree (where .git is a directory), returns empty string. For linked worktrees (where .git is a file), extracts the name from .git/worktrees/<name>/ path. This name is stable across `git worktree move`.

func IsInfrastructurePath

func IsInfrastructurePath(path string) bool

IsInfrastructurePath returns true if the path is part of CLI infrastructure (i.e., inside the .entire directory). It is used only to EXCLUDE infra paths from checkpoints/tracking, so it matches case-insensitively on case-insensitive filesystems via IsProtectedSubpath. Do not use it as a containment/allow gate.

func IsProtectedSubpath added in v0.9.0

func IsProtectedSubpath(parent, child string) bool

IsProtectedSubpath reports whether child is under parent for the purpose of EXCLUDING protected/infrastructure content from checkpoints and tracking. Unlike IsSubpath it honors OS case-insensitivity (see CaseInsensitiveFS), so a case variant of a protected dir (".Claude" vs ".claude") is still excluded on Windows/macOS.

SECURITY: never use this for allow/containment decisions. Case-folding widens what counts as "inside" parent, which is safe only when the effect is to exclude more. On a case-sensitive volume under a case-insensitive GOOS it over-matches; for a fail-closed gate that would fail open. Use IsSubpath there.

func IsRelativeTraversal added in v0.7.7

func IsRelativeTraversal(rel string) bool

IsRelativeTraversal reports whether rel escapes its base directory. It accepts both OS-native paths and Git-style slash-normalized paths.

func IsSubpath added in v0.5.1

func IsSubpath(parent, child string) bool

IsSubpath reports whether child is lexically under parent (or equal to it). It uses filepath.Rel, which cleans both inputs and is traversal-resistant: a crafted child like "/a/b/../../../etc/passwd" that escapes parent will produce a relative path starting with ".." and be rejected.

Matching is case-SENSITIVE. This is the correct primitive for fail-closed containment/allow checks (e.g. validating an attacker-influenced path stays under an Entire-owned dir): on a case-sensitive volume a differently-cased path names a different directory, so folding it in would fail open. For EXCLUSION decisions that must also catch case variants on Windows/macOS, use IsProtectedSubpath instead.

func ParseTimestampFromJSONL

func ParseTimestampFromJSONL(line string) time.Time

ParseTimestampFromJSONL extracts the timestamp from a JSONL line. Returns zero time if the line is empty or doesn't contain a valid timestamp.

func SessionMetadataDirFromSessionID

func SessionMetadataDirFromSessionID(sessionID string) string

SessionMetadataDirFromSessionID returns the path to a session's metadata directory for the given Entire session ID. The sessionID must be the full, already date-prefixed Entire session identifier as stored on disk, not an agent-specific or raw Claude ID.

func ToRelativePath

func ToRelativePath(absPath, cwd string) string

ToRelativePath converts an absolute path to relative. Returns empty string if the path is outside the working directory.

func WorktreeRoot added in v0.4.8

func WorktreeRoot(ctx context.Context) (string, error)

WorktreeRoot returns the git worktree root directory. Uses 'git rev-parse --show-toplevel' which returns the working tree toplevel. In a worktree this is the worktree root, not the main repository root. The result is cached per working directory. Returns an error if not inside a git repository.

Types

This section is empty.

Jump to

Keyboard shortcuts

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