From 9a0e935b0c08127501314e434acfda424e36a14e Mon Sep 17 00:00:00 2001 From: Ryan Lee Date: Fri, 28 Aug 2026 15:16:34 +0000 Subject: [PATCH] fix(hooks): pass deno.jsonc explicitly so the TS hook runs from node_modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 /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. --- .changeset/explicit-config-hook.md | 5 +++++ hooks/deno.jsonc | 3 --- hooks/hooks.json | 4 ++-- hooks/{run.js => run.ts} | 6 +----- 4 files changed, 8 insertions(+), 10 deletions(-) create mode 100644 .changeset/explicit-config-hook.md rename hooks/{run.js => run.ts} (93%) mode change 100755 => 100644 diff --git a/.changeset/explicit-config-hook.md b/.changeset/explicit-config-hook.md new file mode 100644 index 0000000..c6f02ef --- /dev/null +++ b/.changeset/explicit-config-hook.md @@ -0,0 +1,5 @@ +--- +"@systemfsoftware/claude-code-comment-checker": patch +--- + +The `PostToolUse` hook command now invokes `deno run --config /hooks/deno.jsonc … /hooks/run.ts` explicitly. The config file is what makes Deno treat the hook as a first-class module instead of node-compat material: without it, a hook living under `node_modules` (as an installed plugin does) cannot resolve `@std/*` or `arktype` and never reaches the checker. Passing the config restores the TypeScript source (`run.ts`) with its real imports, replacing the compiled `run.js` shipped in 0.3.1. \ No newline at end of file diff --git a/hooks/deno.jsonc b/hooks/deno.jsonc index 27661b1..a8eaf7c 100644 --- a/hooks/deno.jsonc +++ b/hooks/deno.jsonc @@ -1,8 +1,5 @@ { "lock": "./deno.lock", - "compilerOptions": { - "checkJs": true - }, "imports": { "@std/fs": "jsr:@std/fs@1.0.19", "@std/io": "jsr:@std/io@0.225.2", diff --git a/hooks/hooks.json b/hooks/hooks.json index 87cb7ee..5dc3949 100644 --- a/hooks/hooks.json +++ b/hooks/hooks.json @@ -5,10 +5,10 @@ "hooks": [ { "type": "command", - "command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run.js\"", + "command": "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\"", "timeout": 30 } ] } ] -} +} \ No newline at end of file diff --git a/hooks/run.js b/hooks/run.ts old mode 100755 new mode 100644 similarity index 93% rename from hooks/run.js rename to hooks/run.ts index 32cbb97..58f40c3 --- a/hooks/run.js +++ b/hooks/run.ts @@ -21,11 +21,7 @@ if (env instanceof type.errors) { Deno.exit(1) } -/** @param {string} cmd - * @param {string[]} args - * @returns {Promise} - */ -async function run(cmd, args) { +async function run(cmd: string, args: string[]): Promise { try { const { code } = await new Deno.Command(cmd, { args,