Skip to content

fix(hooks): pass deno.jsonc explicitly so the TS hook runs from node_modules - #73

Merged
ryanleecode merged 1 commit into
masterfrom
fix/hook-explicit-config
Aug 28, 2026
Merged

fix(hooks): pass deno.jsonc explicitly so the TS hook runs from node_modules#73
ryanleecode merged 1 commit into
masterfrom
fix/hook-explicit-config

Conversation

@systemfsoftware-maker

Copy link
Copy Markdown
Collaborator

Problem

The PostToolUse hook ships as an npm/marketplace plugin whose hooks/ directory lands under node_modules when installed. Deno's config discovery stops inside node_modules, so the co-located deno.jsonc import map is never loaded and the hook dies before reading the payload:

error: Could not find package '@std/fs' from referrer '.../node_modules/claude-code-comment-checker/hooks/run.js'

Every npm consumer of 0.3.1 hits this: the hook never flags anything.

Change

  1. hooks/hooks.json — invoke the hook explicitly instead of executing the file directly:
    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 --config marks 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 under node_modules — one flag fixes both failures.
  2. hooks/run.js -> hooks/run.ts — restore the original TypeScript with its real packages (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 + checkJs workaround is gone.
  3. hooks/deno.jsonc — drop 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 from deno check on the restored .ts).

Verification

  • deno check --config hooks/deno.jsonc hooks/run.ts exits 0.
  • Fixture install at a path containing node_modules (/tmp/cc-verify/node_modules/claude-code-comment-checker/hooks/), run with the exact new command from hooks.json, strips a flagged comment: exit 2, <file> rewritten, report on stderr.
  • Pre-change control: the same run.js from the installed 0.3.1 package errors with the exact @std/fs failure above.

Notes

…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.
@ryanleecode
ryanleecode merged commit 93df8fc into master Aug 28, 2026
11 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.

2 participants