release: v0.2.0 — context-loss recovery (/compact + /clear)#32
Merged
Conversation
Cadence section now lists four triggers (was three): first prompt, every-N counter, time-gap, and the new post-compact override. Quick start mentions install-hook now wires both UserPromptSubmit and PostCompact.
Sibling to the post-compact trigger from #30. `/clear` wipes more than `/compact` (full conversation reset), but the recovery path is identical — re-inject the brief on the next prompt, bypassing cadence. Wired through Claude Code's `SessionStart` hook with `matcher: "clear"`, the documented dedicated signal. Implementation: - New `cmd_mark_clear` writes the same `.claude/revive-compact.signal` as `cmd_mark_compact`. Two commands so settings.json reads naturally and hook.log distinguishes the source. - `cmd_install_hook` now wires three hooks. Refactored the upsert helper to take an optional `matcher`, so SessionStart{clear} stays distinct from any user-added SessionStart{startup} or {resume} entry (idempotency key: event + matcher + command). - `cmd_doctor` adds a third hook check via the existing `_doctor_check_hook` helper (`SessionStart` + `revive mark-clear`). - README cadence section gains trigger #5; install-hook line now lists all three events. 6 new tests cover: signal write, help-text surface, settings.json shape (matcher field present), 3-hook idempotency, doctor warn on missing SessionStart, doctor green path with all three hooks.
Headline: context-loss recovery. Refresh now fires immediately after `/compact` (#30) and `/clear` — the two moments when an agent has just lost most of its working memory and the brief gives the highest ROI. Three hook events wired by `install-hook`: UserPromptSubmit, PostCompact, SessionStart(matcher=clear). Also since v0.1.19: - `revive init` auto-fixes `.gitignore` so static.md is trackable (#31) - README tagline rewrite (#31)
There was a problem hiding this comment.
Pull request overview
Release v0.2.0 focused on context-loss recovery by ensuring a refresh is forced immediately after both /compact and /clear, using a shared signal-file mechanism and updated hook wiring.
Changes:
- Added a new
mark-clearcommand and wired aSessionStart(matcher=clear)hook viainstall-hook. - Extended
doctorto check for the third hook and updated CLI help/version text. - Updated README cadence documentation and added Bats coverage for
/clear+ 3-hook idempotency.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
bin/revive |
Adds mark-clear, updates install-hook to insert a SessionStart(clear) entry, and extends doctor checks; bumps version to 0.2.0. |
tests/revive.bats |
Adds tests for mark-clear, install-hook JSON shape/idempotency across 3 hooks, and doctor behavior with/without SessionStart. |
README.md |
Updates install instructions, cadence triggers list, and status blurb for v0.2.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
`_doctor_check_hook` accepted any SessionStart entry pointing at
`revive mark-clear` regardless of its `matcher` value. A user who
hand-wired SessionStart{startup} → mark-clear (or no matcher at
all) would pass doctor, but `/clear` would never trigger that
hook. Codex flagged the false-positive on the v0.2.0 PR.
Two changes:
1. The helper takes an optional 3rd arg `matcher`. When set, the
jq query also asserts `(.matcher // "") == $m` so only the
intended entry counts. Doctor labels include the matcher in
parens — `SessionStart(clear) hook installed`.
2. The grep fallback used to override a legitimate "no match"
from jq because it ran on any non-zero jq exit. Distinguish
jq's exit codes:
- 0 → match;
- 1 → legitimate no-match (trust it, skip grep);
- ≥2 → jq error or absent → grep fallback (best-effort,
can't tie matcher to command across JSON lines).
Without that, the matcher check would have been silently
defeated whenever jq returned 1 and grep happened to find
the command string anywhere in the file.
Also: `set -e` interaction. The naive `jq ...; rc=$?` pattern
would abort the function on jq's non-zero exit before the
assignment. Wrapping in `if jq ...; then rc=0; else rc=$?; fi`
preserves the code.
Tests:
- "doctor warns when SessionStart entry has wrong matcher" — new
regression test for codex P3, hand-crafts settings.json with
matcher=startup pointing at mark-clear, asserts the warning.
- Existing missing-SessionStart and all-three-hooks tests
updated to expect the `(clear)` label.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
v0.2.0 — context-loss recovery. Refresh now fires immediately after both
/compact(shipped in #30) and/clear(this PR). Sibling triggers, single signal file, three hook events./cleartrigger (this PR)cmd_mark_clearwrites.claude/revive-compact.signal(same filemark-compactuses; semantics: "force the next emit, agent lost context"). Two commands so settings.json reads naturally and hook.log distinguishes source.install-hooknow wires three hooks. Refactored upsert to take an optionalmatcher, soSessionStart{clear}stays distinct from any user-addedSessionStart{startup}/{resume}entry. Idempotency key: event + matcher + command.doctoradds a third hook check via the existing_doctor_check_hookhelper.Release notes since v0.1.19
/compactrefresh trigger (feat: post-compact refresh trigger #30)/clearrefresh trigger (this PR)revive initauto-fixes.gitignore(feat(init): auto-update .gitignore + tighter tagline #31)Test plan
/clear: signal write, help-text surface, settings.json shape (matcher field), 3-hook idempotency, doctor warn on missing SessionStart, doctor green path with all three hooksbats tests/— 138/138shellcheck bin/revive install.shcleaninstall-hookon this repo — third entry added cleanly, doctor reports all three hooks installedMigration
Existing users:
revive install-hookis idempotent — re-running it adds the newSessionStartentry next to the existing two without duplication.🤖 Generated with Claude Code