feat(pst): PostCompact hook to recover ledger state after auto compact#65
Merged
Conversation
…paction Adds pst-post-compact.rb wired to the PostCompact auto event. After an auto compact, the hook re-inits the ledger JSON if the file was lost and emits a user-visible summary of in-flight tasks. Claude picks up ledger state on the next turn via the rule-22 nudge in pst-prompt-reminder.rb (PostCompact stdout is shown to the user only, not injected into context). Also fixes stale hook binaries: pst-mode.rb's install step now includes pst-post-compact.rb so re-arming keeps all hooks current. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019BCr5Qxi8jXnG2Rr7zdkw1
…ocess pst-ledger.rb resolve_sid checks ENV['CLAUDE_SESSION_ID'] first; without it, stdin is /dev/null so resolve_sid returns '' and init exits 1 silently. Pass the session id as an env var so the subprocess can resolve it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019BCr5Qxi8jXnG2Rr7zdkw1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pst-post-compact.rbwired to the Claude CodePostCompact(matcher:auto) hook eventpst-prompt-reminder.rbhandles Claude's per-turn ledger awareness viaUserPromptSubmitpst-mode.rbinstall step now includespst-post-compact.rbso re-arming always updates all hook binariesWhy PostCompact can't inject into Claude's context
Per the Claude Code hooks docs,
PostCompactis a "context only / no blocking" event -- its output is shown to the user terminal but not to Claude. Claude regains ledger awareness on the nextUserPromptSubmitvia the rule-22 nudge (already implemented in the previous PR).Test plan
/pst, register a task withpst-ledger.rb register, trigger a/compact, confirm the user sees in-flight summary in terminalpst-prompt-reminder.rbrule-22 nudge fires on the next user message post-compact🤖 Generated with Claude Code
https://claude.ai/code/session_019BCr5Qxi8jXnG2Rr7zdkw1