Skip to content

Share One Registration Helper Between the Agent-Safety Installer's PreToolUse Hooks #3517

Closed

Description

@ptr727

host-setup/agent-safety/claude/install.py now registers two PreToolUse hooks, gh-write-guard.py under the Bash matcher and model-tier-guard.py under Agent|Workflow. Each has its own copy of the same two blocks:

  • In registration_problems, a loop counts named entries, checks the command with runs_hook, checks the matcher with matcher_sees_tool, and reports "not registered" and "registered N times". The two loops differ only in hook name, deployed path, tool list, and message wording.
  • In main, a strip-then-register block removes every entry naming the hook, then appends one entry to the group with that hook's matcher. The SessionEnd sweep has a third copy.

A later fix to registration logic has to be made in each copy. Fold each pair into one helper, one taking the hook name, deployed path, and tools to check, and one taking the event list, hook name, group selector, and entry.

Raised by the local strict review on #3516 and deferred by the maintainer to its own change, so that fix landed without the refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions