10 Commits
Author SHA1 Message Date
Sunil 5beffaeb17 Merge remote-tracking branch 'upstream/main' into fix/simplify-ignore-git-revert
# Conflicts:
#	hooks/simplify-ignore-test.sh
#	hooks/simplify-ignore.sh
2026-10-10 17:11:41 +05:30
Sunil e9e172d909 fix(hooks): simplify-ignore keeps a change reverted with git and re-hides the file 2026-10-06 00:14:30 +05:30
Sunil 807bba68af fix(hooks): simplify-ignore never loses a block whose placeholder was removed 2026-10-05 23:55:43 +05:30
ayobamiseun 7b31a90852 fix(hooks): insert protected block content literally under bash 5.2
The round-trip test added in this PR failed on ubuntu-latest while passing
on macOS: after Read → Stop, a protected block containing a backslash came
back altered (byte 109, line 3 of the fixture).

expand_file rebuilds each line with `${line//$placeholder/$block_content}`.
Bash 5.2 enables patsub_replacement by default, which makes the replacement
side of that expansion special: an unquoted `&` expands to the matched text
and backslashes are consumed. Block content is raw code and routinely
contains `&&` and backslashes, so on any bash 5.2 host every protected block
with either character was corrupted when it was expanded back. Bash 3.2 on
macOS has no such option, which is why local runs never showed it.

Turn the option off at the top of the hook; older bashes reject the shopt,
so the error is ignored there. Extend the byte-fidelity fixture with `&&`
and `&` so the ampersand case is guarded alongside the backslash one.
2026-09-18 09:49:16 +01:00
ayobamiseun 73d1181ce1 test(hooks): add regression coverage for sdd-cache and simplify-ignore round-trip (#295) 2026-09-18 09:45:07 +01:00
mavericksea-aiandClaude Opus 5 510259aca0 fix(hooks): keep the rewrite in the cache when simplify-ignore falls back
When a Stop leaves no BLOCK_ placeholder to expand, the hook has to restore
the backup to recover the protected block — which overwrote whatever had
replaced the file. Copy that content into the cache as <id>.recovered first
and name both paths in the warning, so the rewrite is merged back by hand
rather than lost.

Adds a test that the fallback keeps the rewritten content in the cache, and
a minimal lifecycle test (Read, a direct write with no event, Stop) asserting
the write survives.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 01:59:59 +00:00
mavericksea-aiandClaude Opus 5 b1ac22c7d2 fix(hooks): expand simplify-ignore files at Stop instead of restoring backups
The Stop branch restores every cached file from its backup, but that
backup is written on PreToolUse Read and refreshed only by the
PostToolUse Edit|Write branch. A change made to a filtered file through
any other route between Read and Stop — a Bash command, a formatter, an
external editor — is overwritten at session end. Reproduced in #295:
Bash wrote const editable = 2 and read it back, Stop left const
editable = 1 on disk, with no crash and no failed tool call.

The hook protects the content of an annotated block, not the file: the
header documents the backup as holding the model's changes, and Edit and
Write already preserve them. So Stop now runs the same placeholder
expansion the Edit|Write branch runs, against the file as it is on disk.
Whatever wrote the file wrote its filtered form with the placeholders
intact, so expanding it restores the protected blocks and keeps the
change, whichever route it came from.

The expansion body moves into an expand_file function that both branches
call, so the fuzzy-match and deleted-block warnings apply at Stop too.
When no cached BLOCK_<hash> is left, the file was rewritten wholesale and
the hook cannot place the block; it falls back to the backup as before,
now with a warning instead of in silence. That residual is documented in
SIMPLIFY-IGNORE.md. With no outside write, expansion reproduces the
backup exactly, so Read→Stop and Read→Edit→Stop are byte-identical.

Test 11 drives the real hook through Read, an Edit event, a write with no
event after it, and Stop; it fails at be4e44a on the two assertions for
the lost write. Suite: 28 passed, 0 failed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 01:35:47 +00:00
youjinchoi dbb32a565c fix(hooks): simplify-ignore-test asserts the no-jq guard instead of failing
Test 10 pipes malformed JSON through the real hook, but the hook's jq
guard exits with 'error: missing jq' before parsing on machines without
jq (default Git for Windows, minimal Linux). The suite then reports a
failure unrelated to the contributor's change; tests 1-9 only exercise
the extracted filter_file and keep passing.

Mirror session-start-test.sh, which CONTRIBUTING documents as validating
both the jq and no-jq branches: with jq on PATH keep the existing
bad-JSON warning assertion, without it assert the documented missing-jq
guard message.

Verified on Windows (Git Bash): 21 passed, 0 failed both with jq 1.8.1
on PATH and without jq.
2026-07-18 02:39:16 +09:00
zhoujingtian 22ce244ba9 fix(hooks): make simplify-ignore-test.sh executable
hooks/simplify-ignore-test.sh was committed with mode 100644 while its
sibling test script hooks/session-start-test.sh is 100755. Both share
the same #!/bin/bash shebang and live in the same directory; set the
exec bit for consistency.
2026-06-14 15:23:28 +08:00
Addy Osmani 111eade87e For #7 some additional minor tweaks 2026-03-27 18:38:08 -07:00