normalizer

package
v0.0.0-...-c266382 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package normalizer ports the trajectory normalizer to Go.

Index

Constants

View Source
const ChunkSize = 1000

Variables

View Source
var (
	ErrEmptyInput     = errors.New("cannot detect format of an empty file")
	ErrNoKnownRecords = errors.New("file contains no recognizable records")
)

Functions

func NormalizeBytes

func NormalizeBytes(data []byte) (*obj, error)

NormalizeBytes detects and normalizes one transcript.

func NormalizeClaude

func NormalizeClaude(records []*obj) *obj

NormalizeClaude is the Claude 2.1 adapter; it returns an insertion-ordered document. Two rules from SPEC.md §3.1 drive the shape of this code:

  • A key declared absent still occupies its slot, even though it never serializes — so every field is Set here, with Undefined for "absent", in declaration order.
  • Assigning to an already-declared key keeps its original slot — so later attachments (result, childSessionId, i) Set on the same object.

func NormalizeCodex

func NormalizeCodex(records []*obj) *obj

func NormalizeFile

func NormalizeFile(path string) (*obj, error)

func NormalizeOpenCode

func NormalizeOpenCode(doc *obj) *obj

func ShardBytes

func ShardBytes(doc *obj) (map[string][]byte, error)

ShardBytes returns the relative sharded files for one trajectory.

func WriteSharded

func WriteSharded(doc *obj, dir string) error

Types

type Source

type Source string
const (
	SourceClaudeCode Source = "claude-code"
	SourceCodex      Source = "codex"
	SourceOpenCode   Source = "opencode"
)

func DetectFormat

func DetectFormat(input []byte) (Source, error)

DetectFormat implements the reference detector: whole OpenCode documents first, then JSONL Codex sentinel records, with Claude as the JSONL fallback.

type TreeResult

type TreeResult struct {
	Documents   []*obj
	Skipped     int
	Diagnostics []string
}

func NormalizeDirectory

func NormalizeDirectory(input, out, linksPath string) (TreeResult, error)

NormalizeDirectory normalizes a set and writes the oracle-compatible tree.

Jump to

Keyboard shortcuts

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