MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / hook_cursor_pre_compact

Function hook_cursor_pre_compact

src/hooks/cursor.rs:223–240  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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.
223pub 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///

Callers 1

handle_hook_commandFunction · 0.85

Tested by

no test coverage detected