MCPcopy Create free account
hub / github.com/SethGammon/Citadel / preToolUse

Function preToolUse

scripts/integration-test.js:108–123  ·  view source on GitHub ↗

* Dispatch all PreToolUse hooks for a tool. * Returns { blocked, blockMessage, script } — first exit-2 stops dispatch.

(sandbox, toolName, toolInput)

Source from the content-addressed store, hash-verified

106 * Dispatch all PreToolUse hooks for a tool.
107 * Returns { blocked, blockMessage, script } — first exit-2 stops dispatch.
108 */
109function preToolUse(sandbox, toolName, toolInput) {
110 const scripts = getHooksForEvent(sandbox, 'PreToolUse', toolName);
111 for (const scriptPath of scripts) {
112 const r = spawnSync('node', [scriptPath], {
113 input: JSON.stringify({ tool_name: toolName, tool_input: toolInput }),
114 cwd: sandbox,
115 env: { ...process.env, CLAUDE_PROJECT_DIR: sandbox, CLAUDE_PLUGIN_DATA: path.join(sandbox, '.claude') },
116 encoding: 'utf8',
117 timeout: 10000,
118 });
119 if ((r.status ?? -1) === 2) {
120 return { blocked: true, blockMessage: r.stdout || '', script: path.basename(scriptPath) };
121 }
122 }
123 return { blocked: false };
124}
125
126/**

Callers 1

Calls 1

getHooksForEventFunction · 0.85

Tested by

no test coverage detected