Commit Graph

73 Commits

Author SHA1 Message Date
grayhook 84535def76 Phase 15: extend debug diag with compaction source and delivery branch
Log sourceInferred, isIdle, deliveryBranch on session_compact and
mid_turn_deliver after steer for B-003 troubleshooting.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 23:01:47 +07:00
grayhook 223836f41a Phase 15: wire mid-turn steer delivery on session_compact defer path
When agent is not idle after auto compaction, deliver pending reinject
immediately via steer instead of waiting for before_agent_start.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 23:00:25 +07:00
grayhook 24a3d35c06 Phase 15: add mid-turn defer reinject via sendMessage steer
Deliver pending skills on session_compact when agent is not idle, and
skip before_agent_start consume when steer already ran for compaction.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 22:59:59 +07:00
grayhook 11d0659a25 Phase 15: count skill-reinject:inject in kept-window presence check
Treat defer reinject custom_message entries like user skill blocks so
a second compaction does not plan redundant reinject for same skill.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 22:58:26 +07:00
grayhook eba5b5dc99 Phase 15: call ensureCompactionSourceMarked on session_compact
Safety net when session_before_compact does not run so auto compaction
still sets lastCompactionSource and passes the reinject gate.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 22:57:27 +07:00
grayhook 20429a02ab Phase 15: add ensureCompactionSourceMarked for compaction source fallback
Extract shared helper so session_before_compact and session_compact can
both infer auto when compaction was not explicitly manual.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-18 22:57:09 +07:00
grayhook 459b8775f4 Phase 14: reinjectNow loose fallback for --skill paths — B-002 now command
resolveReinjectSkillNames includes tracked skills on disk when requireRegistered is false so /skill-reinject now works without resourceLoader entry.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 17:35:19 +07:00
grayhook ebc169c91f Phase 14: build reinject blocks from tracked paths — loose skill disk fallback
buildReinjectBlocks uses tracked filePath/baseDir when resourceLoader has no entry and requireRegistered is false, completing defer-path B-002 injection.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 17:34:43 +07:00
grayhook e63041bfc5 Phase 14: filter deferred pending on before_agent_start — registry + disk fallback
filterPendingReinjectForConsume applies fresh registered check at consume time; loose skills pass when requireRegistered is false and tracked SKILL.md exists.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 17:34:06 +07:00
grayhook a81337c08e Phase 14: defer reinject plan without registry at compaction — B-002 stage 1
planDeferredReinject locks pending by kept-window only; defer path in index uses it while immediate keeps registered filter at compact time.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 17:31:43 +07:00
grayhook fe25e606b8 Phase 14: split kept-window filter from registry gate — defer planning stage
filterSkillsNeedingReinjectByKept tracks absent skills without registeredNames; immediate path keeps the combined filter.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 17:28:32 +07:00
grayhook aca68e73ee Phase 14: add requireRegistered setting — opt-out for strict registry filter
Default false so CLI --skill paths can be re-injected from disk in later Phase 14 items; explicit true restores registered-only behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 17:27:09 +07:00
grayhook ef9b7a8c30 Phase 14: B-002 pre-fix RPC repro — filter snapshots and readSettings fix
RPC E2E with debug shows registered present at session_compact but planned=[]
because kept still contains the skill block; registered=[] still drops skills
absent from kept. Sync file readSettings avoids RPC hook deadlock on
SettingsManager/isProjectTrusted.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 15:21:53 +07:00
grayhook 8f48040eac Phase 14: add debug reinject diag logging — B-002 filter visibility
Expose settings.debug snapshots on session_compact and before_agent_start
so Phase 14 can see which filter stage drops --skill paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 14:29:56 +07:00
grayhook 09619d9dd8 Phase 12: recalculate pending on each compact — SPEC §16.6.
Every session_compact replans pendingReinject in defer mode; skipped reinject clears the queue unless manual compaction is waiting for the next user prompt.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 13:15:13 +07:00
grayhook 502ca39b3e Phase 12: RPC no-ui command safety — SPEC §11.
Slash commands persist state changes in hasUI=false mode without calling notify; export handler for regression tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 13:13:42 +07:00
grayhook 66d9a39a18 Phase 12: maxSkills soft warn — SPEC §15.
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>
2026-06-17 13:12:21 +07:00
grayhook d92c5f827d Phase 12: skill name collision warn — SPEC §11.
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>
2026-06-17 13:11:32 +07:00
grayhook c071f240d3 Phase 12: manual compaction defer clear — SPEC §16.5, §12.3.
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>
2026-06-17 13:10:56 +07:00
grayhook 5d902349d1 Phase 11: footer status line on·N — SPEC §7.2.
Update skill-reinject status after toggles, clear, skill tracking, and session restore.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:57:38 +07:00
grayhook 00ed5c6253 Phase 11: register /sr and /skills-reinject aliases — SPEC §7.1.
Expose the same handler under optional shorthand command names.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:56:57 +07:00
grayhook 0534093f2c Phase 11: /skill-reinject now delegates to reinjectNow — SPEC §7.1.
Wire debug force re-inject through the existing immediate delivery path with registered skills from the session.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:56:36 +07:00
grayhook 03dcdb22de Phase 11: integration session override — SPEC §7.1, §16.4.
Persist autoCompactIntegration override in state and wire resolveDeliveryMode plus status delivery line.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:56:19 +07:00
grayhook 435c5b3289 Phase 11: list and clear tracked skills — SPEC §7.1.
Show tracked skill names with sources on list; clear skills array without resetting session toggle.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:55:47 +07:00
grayhook 5c0eb4d039 Phase 11: global on/off toggle — SPEC §7.1, §7.3.
Write skillReinject.enabled to ~/.pi/agent/settings.json via merge write without clobbering other keys.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:55:19 +07:00
grayhook e55a14e469 Phase 11: session on/off/reset toggle — SPEC §5.1, §7.1.
Persist sessionOverride via saveState and confirm the effective enabled layer after each toggle.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:55:07 +07:00
grayhook 7d1c4f031f Phase 11: show /skill-reinject status output — SPEC §7.2.
Format enabled layer, delivery mode, tracked skills, pending queue, and last compaction source on bare command.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:54:47 +07:00
grayhook dc07e516af Phase 11: register /skill-reinject command — SPEC §7.
Wire pi.registerCommand with a minimal handler stub so later subcommands can plug into commands.ts.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:52:58 +07:00
grayhook ecddaf5752 Phase 10: flush persisted state on session_shutdown — SPEC §11.
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>
2026-06-17 12:47:05 +07:00
grayhook a5448b4002 Phase 10: restore session state on session_tree for branch switch — SPEC §6.3, §11.
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>
2026-06-17 12:46:44 +07:00
grayhook ee13faf285 Phase 10: rescan branch for tracked skills when state entry missing — SPEC §6.3.
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>
2026-06-17 12:45:51 +07:00
grayhook 1a690f921f Phase 10: load persisted state and settings on session_start — SPEC §5.1, §6.3, §16.4.
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>
2026-06-17 12:40:33 +07:00
grayhook 0e32a498ee Phase 9: wire session_compact to defer and immediate reinject — SPEC §5.2, §8.
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>
2026-06-17 12:35:01 +07:00
grayhook 0d274881dd Phase 9: persist state after tracked skill changes — SPEC §6.1.
Call saveState via appendEntry after slash, skill-block, and read-path tracking so session state survives resume.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:31:36 +07:00
grayhook edc01d1079 Phase 9: track read tool paths to SKILL.md on tool_call — SPEC §6.2 #3.
Match read tool paths against registered skills when trackReadPaths is enabled and upsert with source read.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:30:57 +07:00
grayhook 2021ee1293 Phase 9: track skill blocks on message_end for user messages — SPEC §6.2 #2.
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>
2026-06-17 12:30:17 +07:00
grayhook 86c6837351 Phase 9: track slash /skill:name on input hook — SPEC §6.2 #1.
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>
2026-06-17 12:28:22 +07:00
grayhook 0f06e0e45b Phase 8: add shouldReinject gate and consume on session_compact — SPEC §8.
Evaluates enabled layer and compaction source, records lastCompactionSource, clears pending flag.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:04:47 +07:00
grayhook 18dd600d2d Phase 8: mark auto compaction before_compact — default source unless manual.
session_before_compact sets pendingCompactionSource to auto when input did not mark /compact.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:03:33 +07:00
grayhook 7bbe2370d7 Phase 8: mark manual compaction from /compact input — SPEC §8 input hook.
Sets pendingCompactionSource before expansion when user text starts with /compact.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:02:48 +07:00
grayhook cf2eedb85b Phase 8: add compaction runtime state — pendingCompactionSource container for §8.
Transient CompactionRuntime holds pending source between input, before_compact, and session_compact hooks.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 12:01:36 +07:00
grayhook d637722ea5 Phase 7: add reinjectNow — force immediate re-inject of all tracked skills for debug.
Uses idle vs followUp delivery based on ctx.isIdle(); skips unregistered skills via existing buildReinjectBlocks warnings.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:59:24 +07:00
grayhook 9a197aee10 Phase 7: skip missing skills with ui.notify warning on expand.
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>
2026-06-17 11:59:12 +07:00
grayhook dc73ea9747 Phase 7: add sendImmediateReinjectAllFollowUp — queue all blocks when streaming or willRetry.
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>
2026-06-17 11:58:29 +07:00
grayhook 446a186431 Phase 7: add sendImmediateReinjectIdle — first skill triggers turn, rest as followUp.
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>
2026-06-17 11:58:15 +07:00
grayhook 2059f6033b Phase 7: add defer inject on before_agent_start — combined skill blocks, clear queue.
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>
2026-06-17 11:57:48 +07:00
grayhook e0daa50cce Phase 7: add enqueueDeferredReinjectFromCompact — queue plan on session_compact without sendUserMessage.
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>
2026-06-17 11:55:13 +07:00
grayhook 23d580b6d2 Phase 7: add planReinject — kept-window and registration filter for post-compaction skills.
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>
2026-06-17 11:54:01 +07:00
grayhook bf862656ae Phase 6: add compaction coexistence hint — one-time notify when both compactors run.
Shows ui.notify once when pi-auto-compact is detected while Pi compaction.enabled stays true.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:47:27 +07:00
grayhook 2e6d36a855 Phase 6: add PI_AUTO_COMPACT_FOLLOW_UP_PREFIXES — document pi-auto-compact phrases.
Constants match SPEC §16.9 for tests and docs; runtime v1 does not match follow-up text.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:46:38 +07:00