Skip to content

Sync .claude/hooks with agents-master c80f825 - #4

Open
emscape wants to merge 1 commit into
mainfrom
chore/sync-agents-master-config
Open

emscape wants to merge 1 commit into
mainfrom
chore/sync-agents-master-config

Conversation

@emscape

@emscape emscape commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Brings .claude/hooks/ up to date with agents-master c80f825, which the session-start sync reported as out of date.

Changed: 18 hook files, including the shared command parser lib/git-command.cjs (wrappers, subshells, git -C targets) used by the merge, branch-delete, push-audit and CI-status guards.

Added: check-agent-routing.js and its tests (opt-in, left unregistered as upstream does), plus new tests for the env guard, merge guard lifecycle, script-exists guard and git-command wrappers.

Left as is:

  • hooks.config.json project overrides
  • release-readiness.md, qa-reviewer.md, content-integrity-auditor.md, failure-mode-analyzer.md: these are tailored to HelloEmily.dev, and upstream differs only by generic template text
  • integration-architect.md, performance-sanity-checker.md: differ only in line endings

Testing: node --test *.test.js *.test.cjs lib/*.test.cjs in .claude/hooks: 569 pass, 0 fail. No site files change.

WHY:
- The session-start sync reported this repo's hooks out of date with
  agents-master: 18 hook files changed upstream and 6 were missing
- Shared command parsing (lib/git-command.cjs) now covers wrappers,
  subshells and git -C targets, which the guards rely on

EXPECTED:
- .claude/hooks matches agents-master c80f825, including the new
  opt-in check-agent-routing.js (left unregistered, as upstream does)
  and its tests
- hooks.config.json project overrides are unchanged
- Project-tailored skills/agents (release-readiness, qa-reviewer,
  content-integrity-auditor, failure-mode-analyzer) keep their
  HelloEmily.dev text instead of the generic template
- node --test *.test.js *.test.cjs lib/*.test.cjs: 569 pass, 0 fail
Copilot AI lite review requested due to automatic review settings November 10, 2026 21:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Multiple critical guard flaws still allow valid push/delete commands to bypass protection, including failed-directory handling, SSH remote parsing, quoted shell syntax, and spaced xargs paths.

5 open issues
What changed in this PR

This pull request synchronizes .claude/hooks/ with agents-master c80f825, expanding shared command parsing and updating Git-related guards, configuration, documentation, and test coverage.

Changes:

  • Enhanced command parsing for wrappers, quoting, refspecs, chained pushes, redirections, and repository paths.
  • Updated merge, branch-delete, push-audit, CI-status, environment, script-existence, search, and commit-message guard behavior.
  • Added lifecycle and regression tests plus the opt-in agent-routing reminder hook.
File Description
.claude/​hooks/​README.md Documents the updated parser behavior, guard defaults, limitations, optional routing hook, and test commands.
.claude/​hooks/​lib/​git-command.test.cjs Updates shared parser tests for directory tracking and multiple push segments.
.claude/​hooks/​lib/​git-command.cjs Adds shell parsing, wrapper handling, quote removal, refspec extraction, redirection filtering, directory tracking, and multi-push support.
.claude/​hooks/​lib/​git-command-wrappers.test.cjs Adds regression coverage for eval, xargs, quoting, nested wrappers, and command-path variations.
.claude/​hooks/​hook-config-integration.test.cjs Verifies the default commit-guard configuration.
.claude/​hooks/​config.json Enables blocking commit-message enforcement by default and updates exit-code documentation.
.claude/​hooks/​check-search-command.test.js Adds lifecycle coverage for quoted and Windows-style search executable paths.
.claude/​hooks/​check-search-command.js Improves detection of watched search commands with quoted or path-qualified executables.
.claude/​hooks/​check-script-exists.test.js Tests project-directory resolution and blocking behavior from an external working directory.
.claude/​hooks/​check-script-exists.mjs Resolves configured package paths from the project directory and uses the blocking exit code.
.claude/​hooks/​check-merge-guard.test.js Adds coverage for protected refspecs, checkout tracking, tags, redirections, and multiple repositories.
.claude/​hooks/​check-merge-guard.js Uses shared push parsing and per-repository checkout state to identify protected-branch operations.
.claude/​hooks/​check-merge-guard.hook.test.js Tests runtime blocking for wrapped merge and push commands.
.claude/​hooks/​check-git-push-audit.test.js Adds coverage for chained pushes, delete-only operations, matching refspecs, and unknown repositories.
.claude/​hooks/​check-git-push-audit.js Audits pushes across multiple repositories while excluding delete-only operations.
.claude/​hooks/​check-env-guard.test.js Adds lifecycle coverage for case-insensitive environment-file matching and allowed filenames.
.claude/​hooks/​check-env-guard.js Makes environment-file matching case-insensitive.
.claude/​hooks/​check-commit-message.test.js Updates the documented test invocation.
.claude/​hooks/​check-ci-status-after-push.test.js Adds lifecycle coverage for chained pushes and deletion handling.
.claude/​hooks/​check-ci-status-after-push.js Verifies CI status independently for each detected push.
.claude/​hooks/​check-branch-delete-guard.test.js Adds coverage for remote forms, refspecs, wrappers, paths, and multi-repository deletions.
.claude/​hooks/​check-branch-delete-guard.js Parses deletion refspecs through shared helpers and evaluates targets per repository.
.claude/​hooks/​check-agent-routing.test.js Tests matching and unmatched prompt-routing behavior.
.claude/​hooks/​check-agent-routing.js Adds an opt-in prompt-routing reminder hook.

Review effort: Lite

Comment on lines +123 to +124
for (const { normalized: segment, cwd } of commandSegments(fullCmd)) {
const dir = cwd !== null && fs.existsSync(cwd) ? cwd : null;
if (nonFlags.length >= 2 && PROTECTED_BRANCHES.includes(branch)) {
return { src: branch, dest: branch };
const { remote, refspecs } = pushArgs(segment);
const candidates = remote && remote.includes(':') ? [remote, ...refspecs] : refspecs;
Comment on lines +175 to 178
function effectiveBranch(i, dir) {
const target = checkedOutTo(i, dir);
if (target) return target;
if (!branchByDir.has(dir)) branchByDir.set(dir, getCurrentBranch(dir));
// line continuation is removed. `$(...)` and backtick substitutions are
// copied through unchanged, to be parsed later. Null if a quote is
// unterminated.
function unquotedWords(str) {
// from GNU/BSD) takes the rest of the token, or the next token if none
// remains; i/e/l take only an attached rest. Only the common options are
// handled.
const XARGS_COMMAND = /^(?:\S*[\\/])?xargs(?:\.exe)?(?=\s|$)\s*/;

This branch has not been deployed

No deployments
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