Native host hooks: planr prime injection and session guards#17
Merged
Conversation
…tion, identity-scoped guard
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
Wires Planr into the native hook systems of Cursor, Claude Code, and Codex CLI — installed by default, never mandatory (
--no-hooksopts out, everything fails open). The problem this solves: "state survives sessions" was discipline (a skill had to remember to read map state); now it is mechanism — every new session, including post-compaction session starts, gets the map state injected automatically.Reviewed by an independent GPT-5.5 subagent across three rounds (1 blocker, 2 majors, 4 minors found and fixed); final verdict complete.
planr prime(new command)--hook-json(Claude SessionStarthookSpecificOutput.additionalContext),--cursor-json(Cursoradditional_context), plain stdout for Codex..planrdirectories.Default hook installation (
planr install codex|claude|cursor).cursor/hooks.json:sessionStart→ prime--cursor-json;subagentStop→ evidence guard..claude/settings.json:SessionStart(matcherstartup|resume|compact) → prime--hook-json..codex/hooks.json:SessionStart→ prime, with the one-time/hookstrust note in the install output.compactsource covers the compaction case.|| truewith a 10s timeout.--no-hooksskips hook installation entirely.Evidence guard (Cursor
subagentStop)PLANR_WORKER_ID/PLANR_SESSION_ID); silent without an explicit identity so no agent is steered toward foreign items. JSON built byjq -nc --arg(never string interpolation), always exit 0, shellcheck-clean, refreshed on re-install when the shipped script changed.Docs
Dogfood
.cursor/hooks.json+ the guard.Testing
cargo test: 42 unit + 66 e2e green — prime content/envelopes/no-db silence/unicode contract, default hook writes, foreign-entry preservation, idempotent re-install, stale-hook upgrade path (old broken entry upgraded in place, retired event cleaned, old guard refreshed), Claude settings preservation, Codex trust note,--no-hooksskip, broken-file protection, and direct guard execution (anonymous/foreign-worker silence, valid followup JSON for own unlogged pick, silence after evidence, exit 0 always).cargo clippy --all-targetsclean; guard passes shellcheck.