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 / ask-kind.ts
GitHub Actions (publish-mods)chore: Update mods/ 5a2676e · 2 days ago History
32 lines · 1010 BRaw
1import type { EventResult } from 'claude-code'
2
3import { pluginOf } from './verdicts/plugin-of.js'
4
5/**
6 * Names who asked, where no rule decided a verdict that holds: the classic
7 * hook first, then the setting whose check asked, then the plugin that made
8 * it, then the ceiling an organization set on the tool.
9 *
10 * An ask that names none of them holds by the host that answers it.
11 *
12 * @param held the ask in question
13 * @returns `<event> hook's ask`, `<key> setting's ask`, `<plugin>'s ask`,
14 * `ask cap`, or `host's ask`
15 */
16export function askKind(held: EventResult<'tool.check'>) {
17 const plugin = pluginOf(held)
18 const isHooked = held.hook !== undefined
19 const isSet = held.setting !== undefined
20 const isMade = plugin !== undefined
21 const isCapped = held.ceiling !== undefined
22
23 return isHooked
24 ? `${held.hook} hook's ask`
25 : isSet
26 ? `${held.setting} setting's ask`
27 : isMade
28 ? `${plugin}'s ask`
29 : isCapped
30 ? 'ask cap'
31 : "host's ask"
32}