|
| 1 | +import type { EventResult } from 'claude-code' |
| 2 | + |
| 3 | +import { heldKind } from './held-kind.js' |
| 4 | + |
1 | 5 | /** |
2 | | - * What a person reads, once for each plugin in a session, when a plugin they |
3 | | - * installed answered allow or ask over a deny rule in their settings. |
| 6 | + * What a person reads, once for each plugin and kind in a session, when a |
| 7 | + * plugin they installed rewrote a verdict that holds over it. |
4 | 8 | * |
5 | 9 | * It names the option an administrator sets to let such plugins override. |
6 | 10 | * |
7 | 11 | * @param plugin the plugin's name, or its batch's, as the trace names it |
8 | 12 | * @param tool the tool the call named |
9 | | - * @param rule the deny rule that decided, as written |
| 13 | + * @param held the verdict that holds, naming the rule behind it if one is |
| 14 | + * @param attempt what the plugin did: answered looser, or the same reworded |
10 | 15 | * @returns the line |
11 | 16 | */ |
12 | | -export const heldNotice = (plugin: string, tool: string, rule: string) => |
13 | | - `${plugin} tried to lift a deny rule in your settings from a ${tool} ` + |
14 | | - `call (${rule}); the deny rule holds over the plugins you install ` + |
15 | | - '(allowModsToOverrideDenyRules)' |
| 17 | +export function heldNotice( |
| 18 | + plugin: string, |
| 19 | + tool: string, |
| 20 | + held: EventResult<'tool.check'>, |
| 21 | + attempt: 'lift' | 'reword', |
| 22 | +): string { |
| 23 | + const kind = heldKind(held) |
| 24 | + const article = kind.startsWith('a') ? 'an' : 'a' |
| 25 | + const changed = |
| 26 | + held.rule === undefined |
| 27 | + ? `${article} ${kind} from a ${tool} call` |
| 28 | + : `${article} ${kind} in your settings from a ${tool} call (${held.rule})` |
| 29 | + |
| 30 | + return ( |
| 31 | + `${plugin} tried to ${attempt} ${changed}; the ${kind} holds over the ` + |
| 32 | + 'plugins you install (allowModsToOverrideDenyRules)' |
| 33 | + ) |
| 34 | +} |
0 commit comments