magi-code 0.80.0

Repository-aware CLI coding agent for terminal work
Documentation
# Context guide

Projects session history into provider conversations and estimates request budgets.

## Where to look

| Task | Path |
| --- | --- |
| Context types and event visibility | `mod.rs` |
| Turn reconstruction and compaction cutoff | `replay.rs` |
| Session replay reuse | `replay_cache.rs` |
| Test-only replay material | `cache.rs` |
| Token projection | `tokens.rs` |
| Behavioral coverage | `tests/replay.rs`, `tests/replay_cache.rs`, `tests/cache.rs`, `tests/tokens.rs` |

## Local rules

- Keep replay filtering separate from tolerant JSONL parsing in `../sessions/read.rs`. Local-only events and reasoning summaries are not ordinary provider messages.
- Reconstruct ordered turns and matched tool calls/results, not a flat event-payload list. Preserve cancelled/failed assistant text from terminal status records.
- User-input `reasoning_selection` replays immediately before its user message. Preserve it through partial-turn replay, omit it from frontend messages, and let compaction cutoffs reset its baseline with the retained prefix.
- `ConversationReplayCache` checks session identity, replay generation, file stamps and a content digest; file size alone is insufficient.
- `cache.rs` is test-only. Normal runs do not read/write disk conversation snapshots; existing snapshots stay untouched.
- Budget estimates are not observed provider usage. Check projection changes against agent request construction as well as local token tests.