Skip to content

Convert Claude Code or Codex into the most intelligent Deep Research Agent. Collect, search, and synthesize web research into a persistent, searchable wiki that builds on itself. Hosted API + MCP: hyperresearch.ai

fix: quote the hook script path so the shell keeps it intact (#98)

Wu Shuwenb2c6bf7d5063
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1202669..e40caaa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## [Unreleased]
+- **The registered PreToolUse hook command quotes the script path.** `install` wrote `node <path>` into `.claude/settings.json` unquoted, and a hook command runs through a shell — so a project directory containing a space split the path there and node was handed a truncated script, making the hook exit 1 on every `Glob`, `Grep`, `WebSearch` and `WebFetch` call. Paths with spaces are ordinary (a Windows user directory, anything under `My Documents`). Installs written before this change keep the old entry, because the installer treats any existing hyperresearch hook as already installed; removing that entry and re-running `install` picks up the fix.
+
## [0.10.0] - 2026-08-01
### Open-access full-text recovery (Unpaywall + Europe PMC)
diff --git a/src/hyperresearch/core/hooks.py b/src/hyperresearch/core/hooks.py
index b5842f3..59ba264 100644
--- a/src/hyperresearch/core/hooks.py
+++ b/src/hyperresearch/core/hooks.py
@@ -3727,7 +3727,7 @@ def _install_claude_hook(vault_root: Path, hpr_path: str) -> str | None:
"matcher": "Glob|Grep|WebSearch|WebFetch",
"hooks": [{
"type": "command",
- "command": f"node {hook_path.as_posix()}",
+ "command": f'node "{hook_path.as_posix()}"',
}],
})
diff --git a/tests/test_core/test_hooks.py b/tests/test_core/test_hooks.py
index bd00491..fca5134 100644
--- a/tests/test_core/test_hooks.py
+++ b/tests/test_core/test_hooks.py
@@ -2,9 +2,13 @@
from __future__ import annotations
+import json
+import shlex
+
from hyperresearch.core.hooks import (
_RETIRED_AGENT_FILES,
_RETIRED_SKILL_DIRS,
+ _install_claude_hook,
_install_depth_critic_agent,
_install_depth_investigator_agent,
_install_dialectic_critic_agent,
@@ -435,3 +439,25 @@ def test_install_hooks_second_run_is_noop(tmp_vault):
# Hook installer may still report the hook is already installed → no
# actions or a trivial subset. Must not crash, must not reinstall files.
assert not second or all("pruned" not in a.lower() for a in second)
+
+
+# ---------------------------------------------------------------------------
+# The registered command must survive the shell that runs it
+# ---------------------------------------------------------------------------
+
+
+def test_installed_hook_command_keeps_the_script_path_in_one_argument(tmp_path):
+ """Claude Code runs a hook command through a shell, so an unquoted path is
+ split at its first space and node receives a truncated script path. Project
+ directories with spaces are ordinary — a Windows user directory, or anything
+ under "My Documents" — and the hook then fails on every matching tool call
+ without the reminder ever appearing."""
+ project = tmp_path / "my project"
+ project.mkdir()
+
+ _install_claude_hook(project, "hyperresearch")
+
+ settings = json.loads((project / ".claude" / "settings.json").read_text(encoding="utf-8"))
+ command = settings["hooks"]["PreToolUse"][0]["hooks"][0]["command"]
+
+ assert shlex.split(command) == ["node", (project / ".hyperresearch" / "hook.js").as_posix()]