Files
affaan-m--everything-claude…/.cursor/hooks/before-shell-execution-block-no-verify.js
T
wehub-resource-sync d48cda4081
CI / Test (ubuntu-latest, Node 18.x, bun) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, npm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, pnpm) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 18.x, yarn) (push) Failing after 15m1s
CI / Test (ubuntu-latest, Node 20.x, bun) (push) Failing after 17m13s
CI / Test (ubuntu-latest, Node 20.x, npm) (push) Failing after 18m42s
CI / Test (ubuntu-latest, Node 20.x, pnpm) (push) Failing after 15m0s
CI / Test (ubuntu-latest, Node 20.x, yarn) (push) Failing after 49m44s
CI / Test (ubuntu-latest, Node 22.x, bun) (push) Failing after 51m55s
CI / Test (ubuntu-latest, Node 22.x, pnpm) (push) Failing after 21m57s
CI / Test (ubuntu-latest, Node 22.x, npm) (push) Failing after 37m39s
CI / Test (ubuntu-latest, Node 22.x, yarn) (push) Failing after 34m7s
CI / Validate Components (push) Failing after 37m15s
CI / Python Tests (push) Failing after 10m1s
CI / Security Scan (push) Failing after 10m1s
CI / Lint (push) Failing after 17m12s
CI / Coverage (push) Failing after 20m19s
CI / Test (macos-latest, Node 18.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 18.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 20.x, yarn) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, bun) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (macos-latest, Node 22.x, yarn) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, npm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, pnpm) (push) Has been cancelled
CI / Test (windows-latest, Node 22.x, yarn) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:55 +08:00

64 lines
2.2 KiB
JavaScript

#!/usr/bin/env node
/**
* Cursor wrapper for block-no-verify.
*
* Cursor hooks previously called `npx block-no-verify@1.1.2`, an external
* package whose matcher over-matches: it blocks legitimate `git commit`
* whenever the literal string `--no-verify` (or `no-verify`) appears
* anywhere in the command string, including inside the commit message
* body. See issue #2107.
*
* The Claude Code surface already routes through the local, in-repo hook
* `scripts/hooks/block-no-verify.js`, which performs flag-position-aware
* tokenisation (skipping the value of `-m`, `-F`, `-am "..."`, etc.) and
* passes 25 regression tests covering every false-positive case.
*
* This wrapper gives Cursor the same matcher: read Cursor stdin, transform
* to the Claude Code `tool_input.command` shape the local hook understands,
* delegate to its exported `run()`, then forward the exit code and stderr.
*/
'use strict';
const { readStdin, hookEnabled } = require('./adapter');
const { run } = require('../../scripts/hooks/block-no-verify');
readStdin()
.then(raw => {
if (!hookEnabled('pre:bash:block-no-verify', ['minimal', 'standard', 'strict'])) {
process.stdout.write(raw);
return;
}
let command = '';
try {
const parsed = JSON.parse(raw || '{}');
command = String(parsed.command || parsed.args?.command || '');
} catch {
command = String(raw || '');
}
// Local hook accepts either the raw command string or a Claude-Code
// shaped `{ tool_input: { command } }` JSON. Pass the Claude shape so
// the JSON branch in extractCommand() is exercised the same way the
// Claude Code surface exercises it — keeps the two surfaces on the
// same code path.
const claudeInput = JSON.stringify({ tool_input: { command } });
const result = run(claudeInput);
if (result && result.exitCode === 2) {
if (result.stderr) {
process.stderr.write(String(result.stderr) + '\n');
}
process.exit(2);
}
process.stdout.write(raw);
})
.catch(() => {
// Per repo rule: hooks must exit 0 on non-critical errors and never
// unexpectedly block tool execution. A parse / transport error here
// is non-critical — fall through.
process.exit(0);
});