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 / held-kind.ts
GitHub Actions (publish-mods)chore: Update mods/ bf2323b · 10 days ago History
25 lines · 786 BRaw
1import type { EventResult } from 'claude-code'
2
3import { askKind } from './ask-kind.js'
4
5/**
6 * What kind of thing held over a person's plugin, as the notice calls it:
7 * `deny rule`, `ask rule`, `refusal`, or whose ask it was, else `ask cap`.
8 *
9 * A deny that names no rule is a refusal even when it names a hook: the hook
10 * may only have asked, and something else refused. An ask that names nobody
11 * holds by the ceiling an organization set on the tool.
12 *
13 * @param held the verdict that holds
14 * @returns the kind
15 */
16export function heldKind(held: EventResult<'tool.check'>): string {
17 const isRuled = held.rule !== undefined
18 const isRefused = held.decision === 'deny'
19
20 return isRuled
21 ? `${held.decision} rule`
22 : isRefused
23 ? 'refusal'
24 : askKind(held)
25}