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-notice.ts
30 lines · 1005 BRaw
1import type { EventResult } from 'claude-code'
2
3import { heldKind } from './held-kind.js'
4
5/**
6 * What a person reads, once for each plugin and kind in a session, when a
7 * plugin they installed answered more permissively than what holds over it.
8 *
9 * It names the option an administrator sets to let such plugins override.
10 *
11 * @param plugin the plugin's name, or its batch's, as the trace names it
12 * @param tool the tool the call named
13 * @param held the verdict that holds, naming the rule behind it if one is
14 * @returns the line
15 */
16export function heldNotice(
17 plugin: string,
18 tool: string,
19 held: EventResult<'tool.check'>,
20) {
21 const kind = heldKind(held)
22 const isRuled = held.rule !== undefined
23
24 return (
25 `${plugin} tried to lift ${kind.startsWith('a') ? 'an' : 'a'} ${kind}` +
26 `${isRuled ? ' in your settings' : ''} from a ${tool} call` +
27 `${isRuled ? ` (${held.rule})` : ''}; the ${kind} holds over the ` +
28 'plugins you install (allowModsToOverrideDenyRules)'
29 )
30}