Repository navigation
fix(hooks): match real file extension in Read|Glob hook (.astro miss, .json false-fire) - #1464
marketechniks wants to merge 1 commit into
Conversation
…s#1463) The Read|Glob PreToolUse hook tested extensions with a substring scan (any(e in s for e in exts)) over the joined file_path/pattern/path. That had two opposite failures: - false negative: .astro/.vue/.svelte were absent from exts, so Read/Glob on framework components never nudged toward the graph. - false positive: '.json' contains the substring '.js', so reading package.json, tsconfig.json, etc. spuriously fired the nudge. Compare each value's real trailing extension (segment after the last '/' then after the last '.') against exts instead, and add .astro/.vue/.svelte. Preserves the graphify-out/ suppression and fail-open behaviour. Adds regression tests: framework-source nudges, **/*.astro glob nudge, and .json/.geojson config silence. Full hook + install-string + codebuddy suites pass (42). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The Read|Glob PreToolUse hook (the "run graphify first" nudge, shared by the Claude Code and CodeBuddy installers via _READ_SETTINGS_HOOK) decided whether to nudge by substring-scanning the joined file_path/pattern/path for known extensions. That had two opposite failures: '.js' is a substring of '.json' so package.json / tsconfig.json spuriously fired, and .astro/.vue/.svelte weren't in the set so Astro/Vue/Svelte projects never nudged on their primary source type. The hook now compares each value's real trailing extension (segment after the last '/', then after the last '.') against the set, and adds .astro/.vue/.svelte. package.json -> tail .json (silent); **/*.astro -> tail .astro (fires); an extension on a directory component (my.ts/file) correctly stays silent. The graphify-out/ suppression and fail-open behavior are unchanged. Ported from PR #1464 by @marketechniks onto current v8. Added three regression tests on top of the PR's (multi-dot a.test.tsx / foo.min.js, a Windows backslash path, and the directory-extension trap) to pin the trickiest parts of the new segment-split logic. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Thanks @marketechniks — clean diagnosis and the right fix. Substring-matching the path was the root of both failures (the Landed on Verified end-to-end by running the actual hook command the way Claude Code invokes it ( |
…hify-Labs#1463) The Read|Glob PreToolUse hook (the "run graphify first" nudge, shared by the Claude Code and CodeBuddy installers via _READ_SETTINGS_HOOK) decided whether to nudge by substring-scanning the joined file_path/pattern/path for known extensions. That had two opposite failures: '.js' is a substring of '.json' so package.json / tsconfig.json spuriously fired, and .astro/.vue/.svelte weren't in the set so Astro/Vue/Svelte projects never nudged on their primary source type. The hook now compares each value's real trailing extension (segment after the last '/', then after the last '.') against the set, and adds .astro/.vue/.svelte. package.json -> tail .json (silent); **/*.astro -> tail .astro (fires); an extension on a directory component (my.ts/file) correctly stays silent. The graphify-out/ suppression and fail-open behavior are unchanged. Ported from PR Graphify-Labs#1464 by @marketechniks onto current v8. Added three regression tests on top of the PR's (multi-dot a.test.tsx / foo.min.js, a Windows backslash path, and the directory-extension trap) to pin the trickiest parts of the new segment-split logic. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Fixes #1463.
Problem
The
Read|GlobPreToolUsehook (_READ_SETTINGS_HOOKingraphify/__main__.py, used by both the Claude and CodeBuddy installers) decided whether to nudge by substring-scanning the joinedfile_path+pattern+pathfor known extensions:Two opposite failures fall out of that:
.astro/.vue/.sveltenever nudge. They weren't inexts, so on Astro/Vue/Svelte projects (where they're the primary source type) reading or globbing a component never surfaced the graph. Only the Bash/grep hook covered those repos..jsonmatches.js.'.js'is a substring of'.json', so readingpackage.json,tsconfig.json, etc. spuriously fired the "run graphify first" nudge. Any path containing a listed ext as a substring over-fires.Fix
Compare each value's real trailing extension (segment after the last
/, then after the last.) againstexts, and add the framework extensions:package.json→ tail.json(not inexts, silent);**/*.astro→ tail.astro(matched, fires). Thegraphify-out/suppression and the fail-open behaviour are unchanged.Tests
Added regression tests in
tests/test_read_hook.py:test_nudges_on_framework_source—.astro/.vue/.sveltereads nudgetest_astro_glob_nudges—**/*.astroglob nudgestest_silent_on_json_config—package.json/tsconfig.json/data.geojsonstay silentAll existing cases still pass: