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

Function hook_cursor_session_start

src/hooks/cursor.rs:260–288  ·  view source on GitHub ↗

Cursor `sessionStart` hook handler (fire-and-forget). Emits Cursor's `sessionStart` output shape (`additional_context` + `env`) steering the agent toward tracedecay MCP tools and reporting index freshness for the resolved workspace. Never blocks session creation.

()

Source from the content-addressed store, hash-verified

258/// steering the agent toward tracedecay MCP tools and reporting index freshness
259/// for the resolved workspace. Never blocks session creation.
260pub async fn hook_cursor_session_start() -> i32 {
261 let event = read_hook_event!();
262 let root = cursor_project_root_from_event(&event);
263 record_hook_invoked(root.as_deref(), HintAgent::Cursor, "sessionStart", &event);
264 ingest_cursor_transcript_for_event(
265 &event,
266 Some(CURSOR_CATCH_UP_INGEST_MAX_BYTES),
267 CURSOR_SESSION_INGEST_BUDGET,
268 )
269 .await;
270 let mut context = cursor_session_context_for_root(root.as_deref()).await;
271 if let Some(root) = root.as_deref() {
272 let session_id = serde_json::from_str::<Value>(&event)
273 .ok()
274 .as_ref()
275 .and_then(event_session_id);
276 if let Some(digest) =
277 memory_inject::session_memory_digest(root, session_id.as_deref()).await
278 {
279 append_context_block(&mut context, &digest);
280 }
281 memory_inject::regenerate_cursor_memory_rule(root).await;
282 }
283 if session_start_from_compaction(&event) {
284 append_context_recovery_hint(&mut context);
285 }
286 println!("{}", cursor_session_start_json(root.as_deref(), &context));
287 0
288}
289
290/// Builds the lean Cursor `sessionStart` context for a resolved project root.
291///

Callers 1

handle_hook_commandFunction · 0.85

Tested by

no test coverage detected