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 / verdicts / is-same-verdict.ts
GitHub Actions (publish-mods)chore: Update mods/ bf2323b · 13 days ago History
24 lines · 749 BRaw
1import type { EventResult } from 'claude-code'
2
3/**
4 * Whether two `tool.check` verdicts say the same in every field: decision,
5 * reason, and whatever either names (a rule, a hook, a setting, a host).
6 *
7 * @param one a verdict
8 * @param other another, or undefined when nothing settled
9 * @returns true when no field differs
10 */
11export const isSameVerdict = (
12 one: EventResult<'tool.check'>,
13 other: EventResult<'tool.check'> | undefined,
14) =>
15 other !== undefined &&
16 [one, other]
17 .map(verdict =>
18 JSON.stringify(
19 Object.entries(verdict)
20 .filter(([, value]) => value !== undefined)
21 .toSorted(([left], [right]) => (left < right ? -1 : 1)),
22 ),
23 )
24 .every((line, _, lines) => line === lines[0])