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>
Mirror agent-session _expandSkillCommand body extraction via public stripFrontmatter API (SPEC §5.3, §10).
Co-authored-by: Cursor <cursoragent@cursor.com>
Preserves unrelated keys in ~/.pi/agent/settings.json when persisting
/skill-reinject global on|off and other skillReinject fields.
Co-authored-by: Cursor <cursoragent@cursor.com>
Parses skillReinject from Pi settings layers with defaults and project-trust
aware loading so extension code shares one merged settings view.
Co-authored-by: Cursor <cursoragent@cursor.com>
Defines SkillReinjectSettings and default values so read/merge/effective
helpers share one source of truth.
Co-authored-by: Cursor <cursoragent@cursor.com>
Upsert merges sources without reordering the skills list per SPEC §6.1
dedupe and insertion-order rules.
Co-authored-by: Cursor <cursoragent@cursor.com>
Walk branch backwards for skill-reinject:state custom entries per SPEC §6.3;
return structuredClone of valid v1 snapshot or null for full rescan.
Co-authored-by: Cursor <cursoragent@cursor.com>