Documentation
¶
Overview ¶
Package rewrite adapts a copied session to the target machine.
It applies a single-pass prefix map (repo root, worktree, home, config dir) to every JSON string in the transcript, keys included, on path boundaries. It handles JSON-escaped Windows paths and paths that follow JSON escapes, converts separators below mapped folders between Windows and macOS/Linux, and never edits ids or signed thinking blocks (dropping them whole only for cross-account moves). It strips the source's Remote Control link record, optionally redacts secrets, and appends a `relocated` record the way Claude Code's own /cd does.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
Mappings []Mapping
// Policy is the agent module's: protected keys, dropped records and elements, renames.
Policy agent.RewritePolicy
// Redact, if set, is applied to every rewritable string token (raw JSON bytes) after path
// mapping; it returns the new bytes and how many secrets it replaced.
Redact func(raw []byte) ([]byte, int)
}
Options controls a rewrite.
type Stats ¶
type Stats struct {
Lines int `json:"lines"`
LinesChanged int `json:"linesChanged"`
Replacements map[string]int `json:"replacements"` // by Mapping.From
DroppedRecords int `json:"droppedRecords,omitempty"`
DroppedElems int `json:"droppedElements,omitempty"`
RenamedIDs int `json:"renamedIds,omitempty"`
Redactions int `json:"redactions"`
}
Stats reports what a rewrite changed.