magi-code 0.80.1

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

Owns run preparation, prompt/replay projection, provider turns, tools, and continuation.

## Where to look

| Task | Path |
| --- | --- |
| Session and request orchestration | `mod.rs`, `runner.rs` |
| Selection, auth, tools, hooks, title setup | `runner/preparation.rs` |
| Preflight and continuation compaction | `runner/auto_compaction.rs` |
| Stream acceptance and turn state | `provider_stream.rs`, `turn_state.rs` |
| Tool records and continuation | `tool_lifecycle.rs`, `tool_continuation.rs`, `session_persistence.rs` |
| Prompt additions and directory instructions | `prompt.rs`, `prompt_injections.rs`, `subdir_instructions.rs` |
| Opt-in review context | `prompt_injections.rs`, `mod.rs`; backend: `../diff_review.rs`, `../diff_review/` |
| Steering, recovery, response rules | `steering.rs`, `recovery.rs`, `ttsr.rs` |
| Provider-facing tool summaries | `tool_output_compression.rs` |

## Local rules

- Resolve the normal-run provider in preparation; construct it through `../providers/factory.rs`. Keep automatic compaction around the existing request loop.
- Keep stream acceptance in `provider_stream.rs` and terminal partial-text recording in `session_persistence.rs`, not renderers. Accepted assistant text must survive cancellation/failure for replay; a rejected sink delta must not enter accumulated output.
- Deliver steering at continuation boundaries; acknowledge it only after required persistence succeeds.
- Review context requires standalone `#diff-changes` in root user input or consumed steering, never implicit loading or subagent/internal prompts. Include unresolved comments once, without bash, changed code or a file list. Reanchor saved paths without scanning the worktree; report tag failures. Persist expanded prompts; resolving/deleting comments cannot rewrite prior messages.
- Preserve tool call/result identities and order through retries and continuation. Flush assistant completion before the tool phase.
- Persistent service sinks require title-worker cleanup before returning, including cancellation. Wait on the turn worker so its writer lease cannot be released while a title task still writes.
- Tool-output compression changes provider-facing results, not raw local output. Keep command recognition conservative.

## Verification landmarks

`tests/session_replay.rs`, `tests/cancellation.rs`, and `tests/tools_continuation.rs` cover ordering and interruption. Preparation and automatic-compaction tests also live in `runner.rs`.