feat(hooks): remind agents to use semantic search before open searches
CI / CI configuration security checks (push) Successful in 2s
CI / Capabilities and shell quality (push) Successful in 16s
CI / Python tests and compilation (push) Successful in 29s
CI / QMD unit tests (push) Successful in 5s
CI / Build and inspect generated packages (push) Successful in 17s
CI / PowerShell tests on Ubuntu (push) Successful in 1m10s
CI / Installed client configuration smoke tests (push) Successful in 34s
CI / Bash integration and installation guards (push) Successful in 1m9s

Add a PreToolUse hook (Show-SearchReminder/show-search-reminder.sh via
agent-guards.py) that, once per session, reminds the agent to run
semantic-search before the first open search. It fires on Grep/Glob and
on shell search commands, never blocks, stays silent once the session
ran qmd-search.mjs, and does nothing unless QMD is installed. Per-session
markers are hashed and pruned after seven days.

Claude matches Grep|Glob|Bash|PowerShell; Codex matches Bash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian LechnerandClaude Opus 5.5 committed 2026-11-16 12:56:49 +01:00
1 parent cb22d56539
commit 305bcdeb54
13 files changed
+146 -11

No files matched your search

+3
View File
@@ -7,6 +7,7 @@ The adapters register these events:
| Client | Event | Action |
| --- | --- | --- |
| Codex and Claude | `PreToolUse` | Block clearly destructive shell commands (`Validate-CommandSafety`/`validate-command-safety.sh`); Claude matches the `Bash` and `PowerShell` tools. |
| Codex and Claude | `PreToolUse` | Once per session, remind the agent to run `semantic-search` before the first open search (`Show-SearchReminder`/`show-search-reminder.sh`); a no-op unless QMD's `qmd-search.mjs` is installed. Claude matches `Grep`, `Glob`, `Bash`, and `PowerShell`; Codex matches `Bash`. |
| Codex and Claude | `Stop` | Run the finish notification (`flashbang`). |
| Codex and Claude | `Stop` | Push back once on an unbacked completion claim (`Check-CompletionEvidence`/`check-completion-evidence.sh`). |
| Codex and Claude | `UserPromptSubmit` | Ask the agent to propose a durable rule when a prompt looks like a correction (`Show-CorrectionPrompt`/`show-correction-prompt.sh`). |
@@ -16,6 +17,8 @@ The adapters register these events:
The main agent alone maintains canonical task state. Hooks never write or summarize it, print its contents, or infer completed verification. The task-state hooks use the hook event's `cwd`, falling back to the process working directory when no workspace is supplied. Malformed event data does not fall back to another project. An absent state file is a successful no-op. Legacy state under the installed configuration root is not automatically adopted; confirm its task before migrating it. The scripts do not grant permissions, bypass approvals, or replace client permission systems.
The search reminder never blocks a tool call. It fires on `Grep`/`Glob` or on shell commands that look like searches (`rg`, `grep`, `find`, `fd`, `git grep`, `Select-String`, recursive `Get-ChildItem`). It stays silent for the rest of the session once it has fired or once the session ran `qmd-search.mjs`. It matches command text, so wrapped or aliased searches can slip through. Per-session markers are hashed session IDs under `~/.my-ai-configuration/state/search-reminder/`; markers older than seven days are pruned.
The QMD warm-up hook uses the process working directory and starts only inside a Git repository when Node.js and the installed wrapper are available. It runs detached; wrapper errors are recorded in `~/.my-ai-configuration/qmd/warm.log`. Disabling local search removes its hook registration. See [Local QMD search](configuration.md#local-qmd-search) for daemon behavior and storage.
When enabled during installation or update, Flashbang runs on `Stop`, after the main agent finishes responding. The default flash lasts about 500 milliseconds. The PowerShell command omits `-WindowStyle Hidden`, which can hide or minimize the shared terminal. The PowerShell hook creates a low-opacity click-through overlay without activating another window when its native GUI APIs are available; unsupported runtimes exit safely. Its native DLL cache is optional: a missing `LOCALAPPDATA` environment variable or an unusable cache falls back to in-process compilation instead of suppressing the notification. The Bash hook uses Python's `tkinter`, uses `xrandr` for multi-monitor bounds when available, and falls back to `notify-send` when the overlay is unavailable. Registered hooks are best effort: errors do not fail a Claude session.
+1 -1
View File
@@ -79,7 +79,7 @@ On Windows, an unavailable profile-folder lookup falls back to PowerShell's home
| `tests/test-qmd-lib.mjs`, `test-qmd-daemon.mjs`, `test-qmd-search.mjs`, `test-qmd-warm.mjs`, `test-qmd-benchmark.mjs` | Model-free QMD unit tests; require the YAML dependency. |
| `tests/test-qmd-integration.mjs` | Manual integration test using real QMD and downloaded models; excluded from CI. |
| `tests/test-qmd-setup.py` | Validate QMD installation, migration, and removal. |
| `tests/test-agent-guards.py` | Validate the completion-evidence and correction-prompt hooks. |
| `tests/test-agent-guards.py` | Validate the completion-evidence, correction-prompt, and search-reminder hooks. |
| `tests/test-session-state.py` | Validate session-state helpers. |
| `tests/test-shell-packages.ps1`, `tests/test-shell-packages.sh` | Validate generated package contents and client settings. |
| `tests/test-runtime-status.ps1`, `tests/test-runtime-status.sh` | Validate build summaries and status-line output. |