Skip to content

release: v0.2.0 — context-loss recovery (/compact + /clear)#32

Merged
justi merged 4 commits intomainfrom
release/v0.2.0
Apr 27, 2026
Merged

release: v0.2.0 — context-loss recovery (/compact + /clear)#32
justi merged 4 commits intomainfrom
release/v0.2.0

Conversation

@justi
Copy link
Copy Markdown
Owner

@justi justi commented Apr 27, 2026

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.

/clear trigger (this PR)

  • New cmd_mark_clear writes .claude/revive-compact.signal (same file mark-compact uses; semantics: "force the next emit, agent lost context"). Two commands so settings.json reads naturally and hook.log distinguishes source.
  • install-hook now wires three hooks. Refactored upsert to take an optional matcher, so SessionStart{clear} stays distinct from any user-added SessionStart{startup} / {resume} entry. Idempotency key: event + matcher + command.
  • doctor adds a third hook check via the existing _doctor_check_hook helper.
  • README cadence section gains trigger fix(suggest): route meta-comments to stderr for clean pbcopy #5.

Release notes since v0.1.19

Test plan

  • 6 new tests for /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 hooks
  • bats tests/ — 138/138
  • shellcheck bin/revive install.sh clean
  • Smoke: re-ran install-hook on this repo — third entry added cleanly, doctor reports all three hooks installed
  • Tag + GH release after merge

Migration

Existing users: revive install-hook is idempotent — re-running it adds the new SessionStart entry next to the existing two without duplication.

🤖 Generated with Claude Code

justi added 3 commits April 27, 2026 22:27
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)
Copilot AI review requested due to automatic review settings April 27, 2026 13:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-clear command and wired a SessionStart(matcher=clear) hook via install-hook.
  • Extended doctor to 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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@justi justi merged commit 0379a3e into main Apr 27, 2026
7 checks passed
@justi justi deleted the release/v0.2.0 branch April 27, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants