Skip to content

feat(hooks): close hook coverage gaps and add scan switches - #36

Merged
yannelli merged 2 commits into
mainfrom
feat/hook-coverage-gaps
Oct 8, 2026
Merged

yannelli merged 2 commits into
mainfrom
feat/hook-coverage-gaps

Conversation

@yannelli

@yannelli yannelli commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Closes the scan gaps from the hook coverage review and adds a switch for each new surface.

New surfaces

  • code scope: whole code files and unknown extensions, string literals included. hidden-characters uses it.
  • check-edit: cat/tee heredoc writes and NotebookEdit cells.
  • check-shell-writes (new, PostToolUse on Bash and PowerShell): the lines a command added to files in a git work tree (sed -i, echo >, scripts). Each finding is reported once, next to the command output.
  • check-bash:
    • git commit|tag|merge|notes with -F, --trailer, and git -C.
    • jj and hg messages.
    • gh pr review|merge and gh release.
    • Titles and merge subjects.
    • Body files.
    • gh api fields (body, message, description, title, @file, --input).
    • PowerShell commands.
  • check-tool-text (replaces check-mcp): MCP posts, MCP file writes and their commit messages, the ExitPlanMode plan (its file sits under .claude/, which styleIgnoreGlobs skip), TaskCreate/TaskUpdate text, and AskUserQuestion questions. Codex runs it on MCP tools too.

Switches

scan.codeFiles, notebooks, heredocWrites, shellWrites, mcp, plans, tasks, questions: all true by default. Each is also a BEC_FEATURE_* id and a toggle on the console's Scanned text panel.

Other changes

  • check-edit and check-bash claim the call's tool_use_id when two of their if rules can match one command. This keeps an overlapping second run from breaking the confirm flow.
  • The console scanner now uses the hooks' own extraction.

Not covered

  • Text between tool calls: MessageDisplay is display-only.
  • Page text in HTML files.
  • Shell writes outside a git work tree.
  • Codex shell writes other than heredocs.
  • omp MCP calls.

Checks

  • node scripts/check.mjs
  • node --test test/*.test.mjs: 199 passed.
  • The plugin suite: 2111 passed.
  • Line coverage: 100%.
  • render-patterns --check and validate-packs: both pass.

…P posts

A new code scope reads whole code files, string literals included, so hidden-characters catches a zero-width space in a string. check-bash reads git commit, tag, merge, and notes messages from -F and --trailer, with git -C in front, and gh release notes, gh pr review bodies, and body files. check-edit reads files that cat or tee writes from a heredoc, and NotebookEdit cells. The new check-mcp hook reads the body or message an MCP tool posts. PowerShell commands go through check-bash.
Each surface past Write and Edit now has a switch under `scan` (codeFiles, notebooks, heredocWrites, shellWrites, mcp, plans, tasks, questions), all on by default, with matching BEC_FEATURE ids and console toggles.

New checks:
- check-shell-writes (PostToolUse on Bash and PowerShell) scans the lines a command added to files in a git work tree and reports each finding once.
- check-tool-text replaces check-mcp. It reads MCP posts, MCP file writes and their commit messages, the ExitPlanMode plan, TaskCreate and TaskUpdate text, and AskUserQuestion questions.
- check-bash reads gh api request fields, gh titles and merge subjects, and jj and hg messages.
- Codex runs check-tool-text on MCP tools.

check-edit and check-bash claim the call's tool_use_id when two of their if rules can match one command, so an overlapping second run exits without output.
@yannelli yannelli changed the title feat(hooks): scan code, body files, heredoc writes, notebooks, and MCP posts feat(hooks): close hook coverage gaps and add scan switches Oct 8, 2026
@yannelli
yannelli merged commit 82b2ec8 into main Oct 8, 2026
2 of 4 checks passed
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.

1 participant