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>
STATE_ENTRY_TYPE skill-reinject:state matches SPEC §6.1 so state survives
/resume and branch reload without a full rescan.
Co-authored-by: Cursor <cursoragent@cursor.com>
createInitialState and createRuntimeFlags return SPEC §6.1 defaults
before load, detect, and settings merge on session_start.
Co-authored-by: Cursor <cursoragent@cursor.com>
TrackedSkill, ExtensionState (version 1), and RuntimeFlags with union
aliases for skill sources, compaction source, and auto-compact integration.
Co-authored-by: Cursor <cursoragent@cursor.com>
Atomic checklists for phases 0–13 so agents can run the AGENTS.md cycle without re-deriving scope from SPEC.
Co-authored-by: Cursor <cursoragent@cursor.com>
Introduce AGENTS.md, TODO maintenance rules, BACKLOG, and Cursor rules
so agents can run the full cycle: changes, review, fixes, and commits.
Co-authored-by: Cursor <cursoragent@cursor.com>