Repository navigation
recognize common test-runner wrappers in the agent hook - #18
dxnnystyles wants to merge 3 commits into
Conversation
argahv
left a comment
There was a problem hiding this comment.
Thanks for this. The quote-aware splitting is a real improvement, and the new negatives are good ones. A few things before it can go in:
npx playwright testis no longer detected (Scripts/notchflow.py:319).npxandbunxare now stripped before theTEST_RUNNERSmatch, so the command becomesplaywright test, which isn't in the list (onlynpx playwright testis). It was labelled Tests before this change. Adding"playwright test"toTEST_RUNNERS, with a test case, fixes it.- One unbalanced quote turns off detection for the whole command (
command_segments, line 281). Returning[]for malformed quoting means an apostrophe in a heredoc body or a comment, or the[:4000]cut landing inside a string, hides every test command, including ones before it:The old line split foundcat > t.py <<'EOF' # it's a test EOF pytest t.py
pytest t.py; this returnsFalse. Returning the segments completed before the unterminated quote would keep yourecho 'literal; pytest -qnegative and still catch these. - Dead entries in
TEST_RUNNERS. Because the package manager andnpxare stripped first,"npm test","npm run test","pnpm test","pnpm run test","yarn test","npx jest","npx vitest"and"npx playwright test"can't match any more. Removing them keeps the list honest; it's how the Playwright case slipped through. - Optional, while you're in there:
pnpm -F web test(-Fis--filter),pnpm -C app test(-Cis--dir),bun run testandenv CI=1 time pytestare still missed.
Happy to pair on any of it. Just ask here.
|
thanks for the careful review — restored |
argahv
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround. Playwright is back, the dead entries are gone, and the extra wrappers all work. I ran the branch against main over a batch of commands, and two kinds of multi-line command that main labels Tests aren't labelled any more:
- Line continuations (
Scripts/notchflow.py:262). A\at the end of a line is kept as an escaped character, soshlexturns the backslash-newline into a word of its own and the real command no longer starts the segment. These are Tests onmainand not on this branch:cd app && \ npm test
The same goes forCI=1 \ pytest -q
npm run build && \thennpm test, andmake lint; \thencargo test. Outside single quotes the shell drops a backslash-newline pair entirely, so skipping both characters incommand_segmentsinstead of keeping them fixes it. - Apostrophes in a heredoc body (
command_segments). My earlier example only passes because its apostrophe sits on a#line, which is skipped as a comment. Anywhere else in the body, the apostrophe opens a quote that never closes, and every command after it is dropped:A README heredoc containingcat > src/sum.test.js <<'EOF' // it's the sum test EOF npx jest
What's newfollowed bygo test ./...fails the same way. Skipping heredoc bodies would cover these: after<<WORD,<<'WORD'or<<-WORD, ignore lines up to the one that is justWORD. Please add both shapes to therunslist. - Small:
echo $'it\'s'; pytestregressed too. Inside$'…'a backslash escapes the quote, so it needs its own quote state. - Small:
assertNotIn(command, json.dumps(events))can't fail for the multi-line commands, becausejson.dumpswrites the newline as\n. Also checkingjson.dumps(command)[1:-1]would make it a real check.
|
thanks for the extra cases! I added the line-continuation, heredoc, and ANSI-C quote regressions, restored Playwright after wrapper stripping, and removed unreachable runner entries. the privacy assertion now checks the JSON-escaped command; the focused test and full 24-test bridge suite pass. |
What this changes
recognizes common test-runner wrappers in the agent hook while keeping command text out of published events. closes #5.
Why
the agent heartbeat previously missed package-manager and environment wrappers around test commands, and separators inside quoted shell arguments could produce false positives.
How it was tested
swift testpasses — not run; this change is limited to the Python hookpython3 -I Tests/test_bridge.pypasses — 24 testsbash Scripts/build.shbuilds — not run; no macOS app code changedIf I added, moved or removed a Swift file: I ran
python3 Scripts/generate_project.pyand committedNotchFlow.xcodeproj— not applicable; no Swift files changedChecked on a Mac — not run
Focused hook regression — 1 test passed; covers wrappers, continuations, heredocs, ANSI-C quotes, malformed tails, false positives, and command privacy
Python 3.9 grammar parsing passed for both changed files
git diff --checkpassedAccessibility and motion
Privacy and security