magi-code 0.80.0

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

Runs lifecycle hooks and separates provider context from local diagnostics.

## Where to look

| Task | Path |
| --- | --- |
| Runtime facade | `mod.rs` |
| Execution, policy, cancellation, injection | `runtime.rs` |
| Payloads, affected paths, stdout parsing | `payload.rs` |
| Phases and durable record shapes | `records.rs` |
| Optional activity bridge | `activity.rs` |
| Safety and phase coverage | `tests.rs` |

## Local rules

- Phases are `before_tool`, `after_tool`, `after_assistant`, `after_reasoning`. Tool filtering applies to tool phases; context injection to after phases.
- Failure policies distinguish ignore, warn, block and fail. Block applies only before tools; preserve `target_ran` for post-target failures.
- Inject stdout only as parsed `context_items` with user-role content. Reject other roles and enforce byte limits, never inject arbitrary stdout.
- Execute through tool cwd preflight and shared platform-shell spawning; hook runtime owns bounded pipes and cleanup.
- Payload-ref files stay under the canonical session root with protected permissions. Oversized payloads may be omitted, not allowed to escape limits.
- Affected paths have separate count/length limits and tool path checks; preserve write-symlink rejection.
- Redact lifecycle/context-injection records before persistence. Optional activity and hook diagnostics are not provider conversation items.