Skip to content

Commit f6bc027

Browse files
committed
fix: address Copilot review on dogfood PR
Three real issues flagged: 1. PURPOSE claimed "single bash file with `git` + `jq`" — implies jq is required at runtime. Actually optional (only `install-hook` and `doctor` use it; `doctor` warns when missing). Rephrased: "git required, jq optional". 2. PURPOSE/INVARIANTS hard-coded "<2200 chars" as a constraint, but the codebase doesn't enforce it — BRIEF_CHAR_BUDGET=2200 is just a number printed by `revive show`, no truncation, no exit code. CLAUDE.md says <1800 (stale, drifted from the 2200 bump). Now honest: describes 2200 as a diagnostics target, not a hard cap. 3. GOTCHAS claimed `cmd_doctor` falls back to grep when "the jq query fails", but the implementation only fell back when `command -v jq` failed (jq absent). A broken jq or malformed JSON would hit `|| continue` and never grep — exactly the false-negative Codex flagged on the original PR. Now actually does what the comment said: try jq path, then grep, then skip.
1 parent fd28622 commit f6bc027

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

.revive/static.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
PURPOSE: Bash CLI that injects a deterministic <2200-char project brief into Claude Code on a cadence via UserPromptSubmit. Solves context rot. Constraint: zero LLM calls, <100ms hot path, single bash file with `git` + `jq`.
1+
PURPOSE: Bash CLI that injects a deterministic project brief into Claude Code on a cadence via UserPromptSubmit. Solves context rot. Constraint: zero LLM calls, <100 ms hot path, single bash file `git` required, `jq` optional.
22
DIFFERENTIATORS:
33
- Two-layer brief: STATIC `.revive/static.md` (curated) + DYNAMIC (regenerated from git per refresh).
44
- Hot path is shell + git. No LLM, no python/node, no daemon. <100 ms.
55
- Cadence-gated (every 5th prompt or >10 min gap).
66
- Auto-generated tree/dep-graph rejected — 2026 research shows it reduces agent success.
77
INVARIANTS:
8-
- Brief <2200 chars, <100 ms, zero LLM calls on hot path. Exceeding these blocks release.
8+
- <100 ms, zero LLM calls on hot path. `BRIEF_CHAR_BUDGET` (2200) is a printed diagnostics target, not enforced — `show` reports overage but doesn't truncate.
99
- STATIC vs DYNAMIC strictly separated. Never inject auto-generated content into static.md.
1010
- `cmd_refresh` always exits 0. Hook failures silent — never break a Claude Code session.
11-
- Bash + git only. `jq` is the sole optional dep. Push back on anything new.
11+
- Bash + git only on hot path. `jq` is the sole optional dep. Push back on anything new.
1212
GOTCHAS:
1313
- bats `run` merges stderr into `$output`. For stdout-only assertions use `--separate-stderr`. Each `[[ ]]` / `[ ]` needs `|| return 1` — bats fails only on the LAST status.
1414
- `set -euo pipefail`: `cmd | head | ... || true` needed in HOT_FILES, else pipefail trips when no commits match filters.
15-
- `command -v jq` finds broken jq. `cmd_doctor` falls back to grep on settings.json when jq query fails.
15+
- `cmd_doctor` falls back to grep on settings.json when the jq path fails (jq absent OR `jq -e` errors out OR malformed JSON) — manually-installed hooks still get detected.
1616
- `purpose_from_*` chain: first hit wins (gh description → manifest → CLAUDE.md → README). `init --force` re-detects.

bin/revive

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,11 +1154,17 @@ cmd_doctor() {
11541154
local hook_found=0 f
11551155
for f in ".claude/settings.json" "$HOME/.claude/settings.json"; do
11561156
[[ -f "$f" ]] || continue
1157-
if command -v jq >/dev/null 2>&1; then
1158-
jq -e '[.hooks.UserPromptSubmit[]?.hooks[]? | select(.command | test("revive[[:space:]]+refresh"))] | length > 0' \
1159-
"$f" >/dev/null 2>&1 || continue
1157+
# Try jq first (structural). If jq is absent OR the structural query
1158+
# errors out (e.g., broken jq, malformed JSON), fall back to grep so a
1159+
# manually-installed hook still gets detected.
1160+
if command -v jq >/dev/null 2>&1 && \
1161+
jq -e '[.hooks.UserPromptSubmit[]?.hooks[]? | select(.command | test("revive[[:space:]]+refresh"))] | length > 0' \
1162+
"$f" >/dev/null 2>&1; then
1163+
:
1164+
elif grep -qE '"command"[[:space:]]*:[[:space:]]*"[^"]*revive[[:space:]]+refresh' "$f"; then
1165+
:
11601166
else
1161-
grep -qE '"command"[[:space:]]*:[[:space:]]*"[^"]*revive[[:space:]]+refresh' "$f" || continue
1167+
continue
11621168
fi
11631169
_doctor_ok "UserPromptSubmit hook installed in $f"
11641170
hook_found=1

0 commit comments

Comments
 (0)