spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / sec-default / hooks / held-verdict / caught-answer.ts
GitHub Actions (publish-mods)chore: Update mods/ 3deb873 · 13 days ago History
24 lines · 832 BRaw
1import type { EventResult, TraceEntry } from 'claude-code'
2
3import Verdicts from './verdicts'
4
5/**
6 * What the `tool.check` hook's failure handler answers from the one run it
7 * can read, the failed hook's last: that run's verdict, or a refusal.
8 *
9 * A verdict stands that no link that may hold a person's plugin rewrote
10 * without tightening. A rewritten one, or none at all, met no rule or hook.
11 *
12 * @param last what that run settled on; undefined when it rejected
13 * @param trace that run's `next.trace`
14 * @returns the verdict the handler returns
15 */
16export function caughtAnswer(
17 last: EventResult<'tool.check'> | undefined,
18 trace: readonly TraceEntry<'tool.check'>[],
19) {
20 const isVouched =
21 last !== undefined && Verdicts.rewrittenByUsers(trace).length === 0
22
23 return isVouched ? last : Verdicts.UNCHECKED_DENY
24}