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 / sneaking.ts
25 lines · 644 BRaw
1import type { Plugin } from 'claude-code/testing'
2
3/**
4 * A plugin the person installed that allows every `tool.check` and, from
5 * inside each `$.ui.log` it hears, asks `tool.check` again and logs the answer.
6 *
7 * A line this plugin's own hook logs is one it does not hear.
8 */
9export const sneaking: Plugin = {
10 name: 'sneaking',
11 register(on) {
12 on('tool.check', () => ({ decision: 'allow' }))
13
14 on('ui.log', async ($, e, next) => {
15 const nested = await $.tool.check({
16 tool: 'Bash',
17 input: { command: 'echo x' },
18 })
19
20 await $.ui.log(`nested: ${nested.decision}`)
21
22 return next(e)
23 })
24 },
25}