Optional maxSkills setting sets the warn threshold; when unset, re-injecting more than three tracked skills emits a one-time UI warning without blocking delivery.
Co-authored-by: Cursor <cursoragent@cursor.com>
Duplicate names in resourceLoader resolve to the first skill with a one-time UI warning during re-inject expansion.
Co-authored-by: Cursor <cursoragent@cursor.com>
Stale pendingReinject from auto compaction is blocked until the next user prompt after manual /compact with default settings; a later auto compaction resets the clear flag.
Co-authored-by: Cursor <cursoragent@cursor.com>
Wire debug force re-inject through the existing immediate delivery path with registered skills from the session.
Co-authored-by: Cursor <cursoragent@cursor.com>
Persist autoCompactIntegration override in state and wire resolveDeliveryMode plus status delivery line.
Co-authored-by: Cursor <cursoragent@cursor.com>
Write skillReinject.enabled to ~/.pi/agent/settings.json via merge write without clobbering other keys.
Co-authored-by: Cursor <cursoragent@cursor.com>
Format enabled layer, delivery mode, tracked skills, pending queue, and last compaction source on bare command.
Co-authored-by: Cursor <cursoragent@cursor.com>
Append skill-reinject:state before extension teardown so the latest tracked
skills and session override survive quit, reload, and session replacement.
Co-authored-by: Cursor <cursoragent@cursor.com>
Extract restoreSessionState for reload/resume/startup and reuse on session_tree
so /tree branch navigation reloads persisted state or rescans like session_start.
Co-authored-by: Cursor <cursoragent@cursor.com>
Walk user messages and read tool calls on session_start to rebuild tracked
skills from history when no skill-reinject:state entry exists on the branch.
Co-authored-by: Cursor <cursoragent@cursor.com>
Restore skill-reinject:state from branch on startup/resume, read merged settings,
and detect pi-auto-compact; reset to initial state when no entry exists.
Co-authored-by: Cursor <cursoragent@cursor.com>
Connect compaction source gate with plan/enqueue/send paths and consume deferred queue on before_agent_start for end-to-end auto compaction trigger.
Co-authored-by: Cursor <cursoragent@cursor.com>
Call saveState via appendEntry after slash, skill-block, and read-path tracking so session state survives resume.
Co-authored-by: Cursor <cursoragent@cursor.com>
Match read tool paths against registered skills when trackReadPaths is enabled and upsert with source read.
Co-authored-by: Cursor <cursoragent@cursor.com>
Scan finalized user message text for expanded skill XML blocks and upsert tracked skills using registered metadata when available.
Co-authored-by: Cursor <cursoragent@cursor.com>
Wire input handler to detect slash skills and upsert into session state using registered skill metadata from before_agent_start cache or loadSkills fallback.
Co-authored-by: Cursor <cursoragent@cursor.com>
Uses idle vs followUp delivery based on ctx.isIdle(); skips unregistered skills via existing buildReinjectBlocks warnings.
Co-authored-by: Cursor <cursoragent@cursor.com>
buildReinjectBlocks checks registration and file presence before expandSkill; warns via ctx.ui when hasUI, no-op in RPC/print mode.
Co-authored-by: Cursor <cursoragent@cursor.com>
Uses deliverAs followUp for every skill block so re-inject does not interrupt an active agent turn or overflow recovery.
Co-authored-by: Cursor <cursoragent@cursor.com>
Extracts buildReinjectBlocks for shared expand logic; immediate delivery when the agent is idle uses sendUserMessage without deliverAs for the first block only.
Co-authored-by: Cursor <cursoragent@cursor.com>
Builds one injected custom message from pendingReinject via expandSkill, clears the queue only after content is built successfully.
Co-authored-by: Cursor <cursoragent@cursor.com>
Defer delivery stores planned skill names in pendingReinject for injection on the next before_agent_start, avoiding races with pi-auto-compact follow-ups.
Co-authored-by: Cursor <cursoragent@cursor.com>
Computes which tracked skills need re-inject after compaction by slicing the kept branch and excluding skills still present in kept user messages or unregistered on disk.
Co-authored-by: Cursor <cursoragent@cursor.com>
Wraps effectiveIntegration with RuntimeFlags.autoCompactDetected so reinject wiring reads delivery mode from one place.
Co-authored-by: Cursor <cursoragent@cursor.com>
Uses the public ExtensionAPI command list and caches the result in RuntimeFlags for session_start wiring.
Co-authored-by: Cursor <cursoragent@cursor.com>