feat(hooks): add if field to markitdown and deny-vendor-write hooks#124
feat(hooks): add if field to markitdown and deny-vendor-write hooks#124
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Code Review
This pull request introduces the if field to several hooks to improve performance by filtering tool-call invocations before spawning processes. It also includes a new track for this feature with a plan and specification. Several critical issues were identified in the implementation: the added if fields in .claude/settings.json and plugins/markitdown/hooks/hooks.json contain syntax errors (missing commas) that break JSON parsing. Additionally, the glob patterns used for vendor/sources filtering are too broad and should be refined to target specific directories. There is also a consistency issue in the specification regarding PDF support that does not match the actual implementation.
There was a problem hiding this comment.
1 issue found across 6 files
Confidence score: 4/5
- This PR is likely safe to merge with minimal risk: the reported issue is moderate-low severity (4/10) and appears limited to hook filtering behavior rather than core runtime functionality.
- In
.claude/settings.json, the*vendor*/*sources*patterns are substring matches, so the hook may still trigger on unrelated files and reduce the expected performance improvement. - Pay close attention to
.claude/settings.json- tighten the filter patterns to target actualvendor/sourcesdirectories and avoid unintended hook executions.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".claude/settings.json">
<violation number="1" location=".claude/settings.json:10">
P2: The new hook filter is too broad: `*vendor*`/`*sources*` match substrings rather than vendor/sources directories, so the hook can still spawn on unrelated edits and miss the intended performance reduction.
(Based on your team's feedback about narrowing hook `if` filters to avoid unnecessary process overhead.) [FEEDBACK_USED]</violation>
</file>
Architecture diagram
sequenceDiagram
participant Claude as Claude Code Engine
participant Engine as Hook Evaluator
participant Script as External Hook Script
participant FS as File System / Tool
Note over Claude,FS: Tool Invocation Flow (e.g., Read, Edit, Write)
Claude->>Engine: Trigger PreToolUse Hook
Note over Engine: NEW: Evaluate "if" field<br/>(Permission Rule Syntax)
alt Pattern Matches (e.g., Read(*.docx) or Edit(*vendor*))
Engine->>Script: CHANGED: Spawn process and execute script
Script-->>Engine: Return exit code/validation
alt Hook Allowed
Engine-->>Claude: Continue tool execution
Claude->>FS: Perform File Operation
FS-->>Claude: Operation Result
else Hook Denied
Engine-->>Claude: Block tool execution (Error)
end
else Pattern Does NOT Match (e.g., Read(*.ts) or Edit(src/))
Note over Engine,Script: NEW: Skip process spawn (Performance Gain)
Engine-->>Claude: Continue tool execution
Claude->>FS: Perform File Operation
FS-->>Claude: Operation Result
end
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
All review feedback addressed:
|
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".please/docs/tracks/active/hooks-if-field-20260328/plan.md">
<violation number="1" location=".please/docs/tracks/active/hooks-if-field-20260328/plan.md:47">
P3: The T-2 descoping update is not propagated through the rest of the plan, leaving contradictory guidance in the same document.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Add permission rule syntax filters to reduce unnecessary hook process spawns. Markitdown hook now only fires on binary doc extensions (pptx/docx/xlsx/xls/ppt/doc). Deny-vendor-write hook now only fires on edits targeting vendor/ or sources/ paths.
Permission rule syntax (gitignore spec) does not support | alternation. Split markitdown hook into 6 separate entries, one per extension. Remove if field from deny-vendor-write hook — would require 8 entries (4 tool types × 2 paths), too verbose for the benefit.
72eaae6 to
5250912
Compare
Summary
iffield (permission rule syntax filter) to markitdown PreToolUse hook — only fires on binary doc extensions (*.pptx,*.docx,*.xlsx,*.xls,*.ppt,*.doc) instead of everyReadcalliffield to deny-vendor-write PreToolUse hook — only fires on edits targetingvendor/orsources/paths instead of everyEdit/WritecallTest plan
.docx/.pptx/.xlsxfiles.ts/.md/.jsonreadsvendor/andsources/pathsclaude plugin validate plugins/markitdownpassesSummary by cubic
Added an
iffilter to themarkitdownPreToolUse hook so it only runs on binary document reads, reducing unnecessary hook spawns. Dropped the planneddeny-vendor-writefilter due to permission rule limits (no alternation).New Features
markitdownPreToolUse now runs only forReadon: .pptx, .docx, .xlsx, .xls, .ppt, .docRefactors
markitdowninto six single-pattern entries since permission rules don’t support alternation.Written for commit 5250912. Summary will update on new commits.