Skip to content

refactor(git-hooks): simplify the shared check lib and installer - #14594

Merged
kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14344-42612635829-1
Nov 9, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
work-resolve-issue/issue-14344-42612635829-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #14344

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Simplified lib/git-hooks/check-lib.sh and lib/git-hooks/install.mjs without changing behavior. check-lib.sh: checks_regular_file now has one regular-file test instead of two, checks_skip_listed drops an empty-list guard the loop already covered, and checks_require_tool inlines a variable it used once. install.mjs: managerDecisions reuses lefthookHook instead of repeating its read, plainDecisions computes layout() once outside the event loop, wiring builds the husky run line only when it needs it, copy builds its support list in one expression, and entryVerdict loops over the modified/stale precedence. I ran scripts/sync-shared-copies.sh to regenerate the 10 vendored plugin copies and added a patch fragment for each of those plugins. Since a copy's stamp hashes check-lib.sh, a git-hook copy a consumer already installed now shows as stale until setup refreshes it. That is the normal effect of any library release, and the fragments say so.

Not verified

  • lib/git-hooks tests (check-lib.test.sh, install.test.mjs, install.test.sh, sh-entries.test.sh) not run here: this lane cannot run test runners. Left to the PR's CI.
  • ci-status green: left to the PR's CI
  • tidy skipped: the change touches lib/, a listed shared path, and has 32 changed files, over the 10-file cutoff
  • verify step (build and tests) skipped: no build for these files, and this lane cannot run test runners. check-affected covered the lint and class checks.

Fix

  • lib/git-hooks/check-lib.sh: merged the two regular-file branches in checks_regular_file, removed the redundant empty-list guard in checks_skip_listed, inlined the verb variable in checks_require_tool
  • lib/git-hooks/install.mjs: managerDecisions reuses lefthookHook; plainDecisions hoists layout() and iterates the event Set directly; wiring calls runLine only on the husky path; copy builds support with a spread; entryVerdict loops over [modified, stale]
  • plugins/{actionlint,bash-format,biome-format,go-format,guardrails,instruction-placement,markdown-format,powershell-format,ruff-format,typos-format}/lib/git-hooks/check-lib.sh: copies regenerated by scripts/sync-shared-copies.sh
  • plugins/{actionlint,bash-format,biome-format,go-format,guardrails,instruction-placement,markdown-format,powershell-format,ruff-format,typos-format}/lib/git-hooks/install.mjs: copies regenerated by scripts/sync-shared-copies.sh
  • .changes/{actionlint,bash-format,biome-format,go-format,guardrails,instruction-placement,markdown-format,powershell-format,ruff-format,typos-format}/work-resolve-issue-issue-14344-*.md: patch fragments for the vendored copy change

Verification

The runner ran each check from the base copy against 1273d95:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • sync-shared-copies: regenerated all 20 vendored copies, exit status 0
  • check-changelog-fragments: all 16 fragments under .changes/ valid
  • check-changed-skills: no changed skills, nothing to gate
  • check-affected: 13 passed, 6 skipped (ruff: no .py; typos not installed; three validate-plugins steps that run code from the checked tree; changed-skills), over 32 changed files
  • fresh-context review subagent: rated every hunk behavior-equivalent, including edge cases (empty tip in pre-push mode, worktree mode, an empty or comma-only checks.skipmissing value, set -e, const temporal dead zone at call time, Set iteration order), and found no test assertion on the changed…
  • git-read diff --numstat: check-lib.sh +10/-18, install.mjs +11/-13; 2 hand-edited files, well under the 400-line / 15-file limit
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42612635829

Left out: the items under Not verified.

Related

#14344

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-review reviewed 1273d956cf4a84bb94e2a345f0af8be190c12bb1: read 32 of 32 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read every hunk of lib/git-hooks/check-lib.sh, lib/git-hooks/install.mjs, the actionlint copy of each file, and the first changelog fragment. The other copies are byte-identical (per identical.txt) and sit at the same role path (plugins/*/lib/git-hooks/) in each plugin, so moving them changes nothing about what they do.

Behavior check, change by change. Every rewrite gives the same result as the code it replaces.

  • checks_skip_listed: when the skip list is empty, for item in $list runs zero times and falls through to the existing return 1. This is the same result the dropped guard gave. A list of only spaces or commas went down the loop path before the change too.
  • checks_require_tool: checks_git_verb is a pure case/printf. Before the change, verb was read only in the agent branch, so calling it inline there prints the same text.
  • checks_regular_file: all four cases match the old code:
    • a tip is given: ls-tree, as before
    • pre-push with no tip: checks_range_tip || return 1, then ls-tree. In a || b || return 1 the return runs only when b fails.
    • worktree with no tip: the file test, then return
    • any other mode: ls-files
      The final regular-file test is unchanged.
  • install.mjs wiring: runLine is pure (L427). It calls configPath, which the wired line already calls first, so calling runLine later can neither throw nor change the output.
  • plainDecisions: layout is pure (L395), and its arguments don't change inside the loop. Iterating the Set keeps insertion order.
  • managerDecisions: lefthookHook (L732) is exactly Boolean(readText(path.join(info.hooksDir, event))?.includes("lefthook")). The temporal-dead-zone risk is ruled out: the only top-level entry point is at L1289, after the const is defined.
  • copy / entryVerdict: the order of the support list and the modified-before-stale precedence are both unchanged.

Closing issue #14344 criteria

  • Behavior unchanged: met, by my reading of the code above. I could not run tests in this lane. The existing lib/git-hooks tests cover these functions; the author says they were not run and leaves them to CI.
  • Diff edits only the listed files, the regenerated copies and changelog fragments: met.
  • Within 400 lines / 15 hand-edited files: met (2 hand-edited files).
  • ci-status green: left to CI. This lane cannot see it.
  • scripts/sync-shared-copies.sh run and copies committed: the 10 plugin copies match the lib/ hunks (offset by two lines). Whether the script itself was run is the author's claim and unverified.

Other

  • Changelog fragments: bump: patch fits a behavior-preserving change. The note that already-installed copies will show as stale is accurate, because sourceHash includes plugin.libText.
  • No .claude-plugin manifests changed. No .claude/rules path glob matches a changed file. No paved-path or standards criteria were applied.
  • No embedded directives found in the PR context.
  • Spend: none beyond the normal CI run.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 1273d956cf4a84bb94e2a345f0af8be190c12bb1: read 32 of 32 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #14594 (refactor(git-hooks): simplify the shared check lib and installer)

No security issues found.

critical-findings: 0

Scope

This was a full review. I read every hunk of lib/git-hooks/check-lib.sh and lib/git-hooks/install.mjs, the plugins/actionlint/lib/git-hooks/ copies of both files, and the .changes/actionlint/ fragment. The other nine plugins' copies of each file, and the other nine fragments, are listed in identical.txt as exact copies, so I did not read them separately. Each copy sits at the same relative path (plugins/<name>/lib/git-hooks/… or .changes/<name>/…), so none of them behaves differently because of where it lives. None of the changed files matches a TRUSTED PATHS glob. No plugin manifest, workflow, trust control or merge-hold file is touched.

What I checked

  • checks_skip_listed (check-lib.sh#L207-L217): the PR removes the [[ -n "$list" ]] || return 1 guard. With an empty list the for loop never runs and the function falls through to return 1, so an unset or empty checks.skipmissing still skips nothing. The bypass for a missing tool does not get wider.

  • checks_regular_file: I compared all four cases between base and head:

    • a tip is given: ls-tree
    • pre-push with no tip: compute the tip with checks_range_tip, fail closed if that fails, then ls-tree
    • worktree with no tip: -f && ! -L
    • every other mode with no tip: ls-files -s with the :(literal) pathspec

    Each case does the same thing before and after, and the final 100* mode check plus the exact path comparison is still there. Symlinks and non-regular entries are still rejected.

  • checks_require_tool: the PR only moves checks_git_verb inline into the message. The exit codes on the agent path (fail) and the human path (notice) are unchanged.

  • install.mjs:

    • managerDecisions now calls lefthookHook (install.mjs#L732). That helper does exactly the same readText(...).includes("lefthook") read as the line it replaces.
    • layout() moves out of the loop. It is a pure function with no side effects (install.mjs#L395-L402).
    • In wiring, runLine is now called only on the husky path, and its quoting is unchanged.
    • The copy support list holds the same entries in the same order. The modified/refused check before it is unchanged.
    • entryVerdict keeps the same order of precedence: modified, then stale, then wired.
  • Changelog fragments: patch-bump prose only, with no instructions in them.

Notes

  • The PR context has no embedded instructions aimed at this lane.
  • No instruction-surface text is deleted (no CLAUDE.md, AGENTS.md, skill, agent or hook list), so I did not need to consult the instruction exception register.
  • Spend: none. The change does not touch lane runs, schedules or billing.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 9ab5934 Nov 9, 2026
60 checks passed
@kyle-sexton
kyle-sexton deleted the work-resolve-issue/issue-14344-42612635829-1 branch November 9, 2026 13:24
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.

Simplify the git-hooks shared lib source

1 participant