Problem
Backslash-newline line continuations aren't parsed properly. The hook's whitespace collapse (main() in scripts/annotate-pre.sh) replaces the newline with a space but leaves the preceding continuation backslash in place, so the annotation shows a stray \:
command sent: echo hello \
world && ls
annotation: 💬 echo hello \ world ✅ && 📋 ls
expected: 💬 echo hello world ✅ && 📋 ls
Repro
printf '{"tool_name":"Bash","tool_input":{"command":"echo hello \\\nworld && ls"}}' \
| bash scripts/annotate-pre.sh
# systemMessage contains "echo hello \ world" — stray backslash
Cause
main() collapses \n\r\t to spaces after unescaping, turning \ + newline into \ + space. Downstream, _render_segment's walk then treats that \ as a backslash-escape pair, which also swallows the word boundary for chunking purposes.
Suggested fix
Strip continuation sequences before the general whitespace collapse:
command="${command//\$'\n'/ }" # backslash-newline → single space
plus a segmentation test (parser: section) asserting echo hello \<newline>world renders with no \ in the plain text. The pre-consolidation parser had exactly this behavior ("backslash continuation joins lines" in the old test suite).
Found during review of #13; deferred from that PR.
🤖 Generated with Claude Code
Problem
Backslash-newline line continuations aren't parsed properly. The hook's whitespace collapse (
main()inscripts/annotate-pre.sh) replaces the newline with a space but leaves the preceding continuation backslash in place, so the annotation shows a stray\:Repro
Cause
main()collapses\n\r\tto spaces after unescaping, turning\+ newline into\+ space. Downstream,_render_segment's walk then treats that\as a backslash-escape pair, which also swallows the word boundary for chunking purposes.Suggested fix
Strip continuation sequences before the general whitespace collapse:
plus a segmentation test (
parser:section) assertingecho hello \<newline>worldrenders with no\in the plain text. The pre-consolidation parser had exactly this behavior ("backslash continuation joins lines" in the old test suite).Found during review of #13; deferred from that PR.
🤖 Generated with Claude Code