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
| 1 | import type { EventResult } from 'claude-code' |
| 2 | |
| 3 | import { isPersonTightening } from './is-person-tightening.js' |
| 4 | import { isSameVerdict } from './is-same-verdict.js' |
| 5 | import Ranking from './ranking' |
| 6 | |
| 7 | /** |
| 8 | * Whether the verdict reached past the user tier holds whole over the |
| 9 | * chain's answer: a deny, or an ask that names what stands behind it. |
| 10 | * |
| 11 | * It holds over a more permissive answer and over the same decision reworded |
| 12 | * or stripped of what it names; a stricter answer stands, and so does a host's |
| 13 | * ask that only changed who answers it to a person. A rule, a hook, a |
| 14 | * setting, a host, a person or a ceiling counts; the mode's own ask at a |
| 15 | * dialog never. |
| 16 | * |
| 17 | * @param held what the run past the user tier settled on |
| 18 | * @param answer what the whole chain settled on |
| 19 | * @returns true when the held verdict is the one to return, as it is |
| 20 | */ |
| 21 | export const holdsOver = ( |
| 22 | held: EventResult<'tool.check'>, |
| 23 | answer: EventResult<'tool.check'>, |
| 24 | ) => |
| 25 | !Ranking.isLooser(held, answer) && |
| 26 | !isSameVerdict(held, answer) && |
| 27 | !isPersonTightening(held, answer) && |
| 28 | (held.decision === 'deny' || |
| 29 | held.rule !== undefined || |
| 30 | held.hook !== undefined || |
| 31 | held.setting !== undefined || |
| 32 | held.decider !== undefined || |
| 33 | held.ceiling !== undefined) |