mati_core/hooks/subagent_stop.rs
1/// subagent-stop.sh — harvest a finished subagent's summary (F5).
2///
3/// SubagentStop fires when a Task subagent finishes. Its `last_assistant_message`
4/// is the subagent's own prose summary of its work; capture it into
5/// `session:summary:latest` so `mem_bootstrap` can surface it as `recent_session`.
6/// Unlike stop/subagent-start, this pipes the payload INTO mati — the summary
7/// lives in stdin. Fail-open; must not delay turn-end.
8pub const SCRIPT: &str = r#"#!/usr/bin/env bash
9# mati subagent-stop hook — harvest subagent summary (fail-open)
10HOOKS_DIR="$(cd "$(dirname "$0")" && pwd)" && export PATH="$HOOKS_DIR:$PATH"
11command -v mati >/dev/null 2>&1 || exit 0
12mati subagent-harvest 2>/dev/null || true
13"#;