legacy

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: CC0-1.0 Imports: 11 Imported by: 0

Documentation

Overview

Package legacy reads the prosa v1 ".prosa" data bundle (a SQLite catalog + content-addressed zstd-compressed raw source files) so the v3 importers can re-ingest historical sessions whose original source files have since disappeared from the filesystem (e.g., Claude Code retention deleted ~/.claude/projects/.../*.jsonl past a few weeks).

See docs/sources/legacy-bundle.md for the on-disk layout, and internal/cli/sync.go for the `prosa sync --legacy-bundle` wiring that drives this package end-to-end.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bundle

type Bundle struct {
	Path string
	// contains filtered or unexported fields
}

Bundle wraps a read-only handle to a v1 prosa bundle directory. The caller MUST Close it when done.

func Open

func Open(path string) (*Bundle, error)

Open validates that path looks like a v1 bundle (has prosa.sqlite alongside raw/sources/) and opens the SQLite catalog read-only.

func (*Bundle) Close

func (b *Bundle) Close() error

func (*Bundle) Decompress

func (b *Bundle) Decompress(ctx context.Context, sf SourceFile, tmpDir string) (string, error)

Decompress reads <bundle>/raw/sources/<ObjectIDHex>.zst, falling back to an uncompressed <ObjectIDHex>.bin object when present. It writes the source bytes to <tmpDir>/<basename(OriginalPath)> and returns the temp path. Preserving the source basename matters for codex (the importer falls back to the filename UUID when session_meta is absent) and for cursor (where the temp file is opened as a SQLite db).

Respects ctx.Done() before opening the source file. The decompress itself is not cancellable mid-stream — zstd reads can take seconds on large files — but that's bounded by per-file size in practice.

func (*Bundle) SourceFiles

func (b *Bundle) SourceFiles(ctx context.Context) ([]SourceFile, error)

SourceFiles returns the catalog rows the v3 pipeline can re-ingest. Only the tools v3 has importers for are returned; v1 also stored `hermes`, which had zero rows in practice and stays excluded.

type SourceFile

type SourceFile struct {
	// Tool is the v1 source_tool string: "claude" | "codex" | "cursor" |
	// "gemini". sync.go maps this to a v3 importer instance.
	Tool string

	// OriginalPath is where the source file used to live on disk (e.g.
	// /Users/u/.claude/projects/.../<uuid>.jsonl). Used as the basename
	// for the decompressed temp file so downstream parsers' filename
	// fallback works.
	OriginalPath string

	// ObjectIDHex is the content hash without the "blake3:" prefix —
	// matches the filename in <bundle>/raw/sources/<hex>.zst or .bin.
	ObjectIDHex string

	// SizeBytes is the uncompressed source file size at v1 import time.
	SizeBytes int64
}

SourceFile is one row from the v1 `source_files` table, scoped to the fields the v3 re-ingestion pipeline actually consumes.

Jump to

Keyboard shortcuts

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