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 / tests / fixtures / tool-check / checks-answered-in-turn.ts
GitHub Actions (publish-mods)chore: Update mods/ 3deb873 · 15 days ago History
24 lines · 621 BRaw
1import type { EventResult, On } from 'claude-code'
2
3import { ASKED } from './asked.js'
4
5/**
6 * Answers every `tool.check` beneath the plugins with one verdict of a list,
7 * the first until the answer is called, then the next; past the last, ASKED.
8 *
9 * @param on the test's `on`
10 * @param verdicts what the engine's evaluation decides, call after call
11 * @returns `() => void`: from then on the next verdict answers
12 */
13export function checksAnsweredInTurn(
14 on: On,
15 verdicts: readonly EventResult<'tool.check'>[],
16) {
17 let at = 0
18
19 on('tool.check', () => verdicts[at] ?? ASKED)
20
21 return () => {
22 at += 1
23 }
24}