Skip to content

State Manager

Per-step file write detection and changelog generation using the shadow git index.

state

File state tracking via shadow git.

Uses the shadow git index as the "cache" for detecting per-step writes. After each write check, changes are staged so the next check only sees new modifications.

Two levels of granularity: 1. Session diffs: full unified diff via shadow git (replaces snapshots) 2. Per-step write log: fine-grained attribution of changes to step_ids

WriteEvent(timestamp, session_index, step_id, file_path, diff, content_before, content_after, diff_stats) dataclass

A single file write detected between steps.

StateManager(work_dir, shadow_git)

Manages file state tracking via shadow git.

seed_memory(memory_file, memory_seed)

Write seed content to the memory file if it doesn't exist.

check_for_writes(session_index, step_id)

Detect file changes since last check using shadow git.

Uses the git index as the reference point. After detecting changes, stages them so the next call only sees new modifications.

save_changelog(dest)

Write all write events to a JSONL file.