Repository navigation
Description
Summary
The Read|Glob PreToolUse hook installed by graphify claude install (and codebuddy install) matches file extensions by substring search over the concatenated file_path + pattern + path string. This produces two opposite failures:
- False negative —
.astro/.vue/.sveltenever nudge. These extensions aren't in theextstuple, so on Astro/Vue/Svelte projects (where they're the primary source type) aReadorGlobof a component never triggers the graphify hint. Only the Bash/grep hook ends up covering those projects. - False positive —
.jsonmatches.js. The check isany(e in s for e in exts), and the substring.jsis contained in.json, so readingpackage.json,tsconfig.json, etc. fires the "run graphify first" nudge spuriously. More generally, any path containing a listed ext as a substring over-fires.
Location
graphify/__main__.py → _READ_SETTINGS_HOOK (the inline python3 -c payload). Referenced by _install_claude_hook and the codebuddy installer, so both platforms inherit the bug. Reproduced on graphifyy==0.8.49.
The current payload reduces to:
s = (file_path + ' ' + pattern + ' ' + path).lower().replace('\\','/')
hit = 'graphify-out/' not in s and any(e in s for e in exts) # substring matchRepro
# fires, but should be silent (.json contains .js)
echo '{"tool_input":{"file_path":"package.json"}}' | bash -c '<the installed Read|Glob hook command>'
# silent, but should fire (.astro not in exts)
echo '{"tool_input":{"pattern":"**/*.astro"}}' | bash -c '<the installed Read|Glob hook command>'Proposed fix
Extract the real trailing extension per value (segment after the last /, then after the last .) instead of substring-searching, and add the framework extensions:
import json,sys
d=json.load(sys.stdin); t=d.get('tool_input',d)
exts=('.py','.js','.ts','.tsx','.jsx','.astro','.vue','.svelte','.go','.rs','.java','.rb','.c','.h','.cpp','.hpp','.cc','.cs','.kt','.swift','.php','.scala','.lua','.sh','.md','.rst','.txt','.mdx')
vals=[str(t.get('file_path') or ''),str(t.get('pattern') or ''),str(t.get('path') or '')]
j=' '.join(vals).lower().replace(chr(92),'/')
tails=[('.'+x.rsplit('.',1)[-1]) for v in vals if v for x in [v.lower().replace(chr(92),'/').rsplit('/',1)[-1]] if '.' in x]
sys.stdout.write('1' if 'graphify-out/' not in j and any(tl in exts for tl in tails) else '')package.json → tail .json (not in exts, silent); **/*.astro → tail .astro (matched, fires); the graphify-out/ suppression is preserved and every branch still fails open.
Verification (8/8 after fix)
| input | before | after | expected |
|---|---|---|---|
Bash grep -r … |
fire | fire | fire |
Bash npm run build |
silent | silent | silent |
Read src/x.ts |
fire | fire | fire |
Glob **/*.astro |
silent (bug) | fire | fire |
Read Hero.astro |
silent (bug) | fire | fire |
Read package.json |
fire (bug) | silent | silent |
Read graphify-out/GRAPH_REPORT.md |
silent | silent | silent |
Read netlify.toml (no code ext) |
silent | silent | silent |
Environment
graphifyy0.8.49, Python 3.13, Windows 11.
Happy to open a PR with the above change if useful.
Activity
fix(hooks): match the real file extension in the Read|Glob hook (#1463)
safishamsi commentedon Jun 25, 2026
Fixed on
v8in 9b583a0 (via #1464, thanks @marketechniks). The hook now matches the real trailing extension instead of substring-scanning, so.jsonconfigs no longer false-fire (.jswas matching as a substring) and.astro/.vue/.sveltenow nudge correctly. Verified by running the actual hook command against both cases. Ships in the next release.release: 0.8.50
fix(hooks): match the real file extension in the Read|Glob hook (Grap…
release: 0.8.50