Cursor `preCompact` hook handler. Cursor's compaction event exposes pressure metadata but not Cursor's own generated summary text. At the boundary, `TraceDecay` ingests the current transcript tail, asks LCM for the compactable raw-message backlog, generates a summary through `cursor-agent -p`, and stores that summary as a normal LCM summary node. The hook is fail-open and emits Cursor's empty obj
()
| 221 | /// a summary through `cursor-agent -p`, and stores that summary as a normal LCM |
| 222 | /// summary node. The hook is fail-open and emits Cursor's empty object shape. |
| 223 | pub async fn hook_cursor_pre_compact() -> i32 { |
| 224 | let event = read_hook_event!(); |
| 225 | let root = cursor_project_root_from_event(&event); |
| 226 | record_hook_invoked(root.as_deref(), HintAgent::Cursor, "preCompact", &event); |
| 227 | if std::env::var(crate::sessions::cursor_agent::CURSOR_SUMMARY_CHILD_ENV).is_err() { |
| 228 | let mut config = crate::sessions::cursor_agent::CursorAgentSummaryConfig::from_env(); |
| 229 | config.timeout = config.timeout.min(CURSOR_PRE_COMPACT_SUMMARY_BUDGET); |
| 230 | let outcome = cursor_pre_compact_for_event_with_config(&event, &config).await; |
| 231 | if outcome.status == "error" { |
| 232 | eprintln!( |
| 233 | "tracedecay Cursor preCompact summary failed: {}", |
| 234 | outcome.reason |
| 235 | ); |
| 236 | } |
| 237 | } |
| 238 | println!("{}", serde_json::json!({})); |
| 239 | 0 |
| 240 | } |
| 241 | |
| 242 | /// Cursor `afterFileEdit` hook handler. |
| 243 | /// |
no test coverage detected