fix(hooks): pass deno.jsonc explicitly so the TS hook runs from node_modules - #73
Merged
Merged
Conversation
…modules
A plugin install lands hooks under node_modules, where Deno's config
discovery stops: the co-located deno.jsonc import map is never loaded,
so the hook cannot resolve @std/* or arktype and dies before reading the
payload ("Could not find package '@std/fs'").
Invoke the hook as `deno run --config <plugin>/hooks/deno.jsonc …`
instead of executing the file directly. The explicit config marks the
module as first-class Deno (not node-compat material), which both loads
the import map and re-enables type-stripping — so the hook ships as the
original TypeScript (run.ts) again, restoring arktype + @std/* and
dropping the compiled run.js from 0.3.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
PostToolUsehook ships as an npm/marketplace plugin whosehooks/directory lands undernode_moduleswhen installed. Deno's config discovery stops insidenode_modules, so the co-locateddeno.jsoncimport map is never loaded and the hook dies before reading the payload:Every npm consumer of 0.3.1 hits this: the hook never flags anything.
Change
deno run --config "${CLAUDE_PLUGIN_ROOT}/hooks/deno.jsonc" --allow-read --allow-run=comment-checker,direnv --allow-env=CLAUDE_PROJECT_DIR,PATH,HOME "${CLAUDE_PLUGIN_ROOT}/hooks/run.ts"The explicit
--configmarks the module as first-class Deno rather than node-compat material, which both loads the import map (with the lockfile) and re-enables type-stripping undernode_modules— one flag fixes both failures.arktype,@std/fs,@std/io,@std/path), verbatim from before fix(hooks): ship run.js so the PostToolUse hook runs on Deno >= 2.9 #71. The compiled.js+checkJsworkaround is gone.compilerOptions.checkJs(a fix(hooks): ship run.js so the PostToolUse hook runs on Deno >= 2.9 #71-era crutch for the compiled.js; typecheck now comes fromdeno checkon the restored.ts).Verification
deno check --config hooks/deno.jsonc hooks/run.tsexits 0.node_modules(/tmp/cc-verify/node_modules/claude-code-comment-checker/hooks/), run with the exact new command fromhooks.json, strips a flagged comment: exit 2,<file>rewritten, report on stderr.run.jsfrom the installed 0.3.1 package errors with the exact@std/fsfailure above.Notes
run.jsis superseded by this approach (TS restored, same minimal flag surface).ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING);--configis the escape hatch, not a Deno version upgrade.