// tests/hooks/storm-matcher.test.mjs // The STORM cap (pre-agent-cap.mjs) must see subagent spawns. The tool was // renamed Task -> Agent in Claude Code 2.1.63; the docs state the old name // still works as an alias «in settings and agent definitions» // (code.claude.com/docs/en/sub-agents, the rename note) and say nothing about // hook matchers, which compare against the tool name the hook input carries. // So the matcher must name `Agent` itself. Resolved with Claude Code's matcher // rules (hooks § Matcher patterns), as write-guard-coverage.test.mjs does. import { test } from 'node:test'; import { strict as assert } from 'node:assert'; import { scriptsFor } from './guard-helpers.mjs'; const fires = (tool) => scriptsFor('PreToolUse', tool).some((p) => p.endsWith('pre-agent-cap.mjs')); test('STORM cap fires on Agent (the tool name since 2.1.63)', () => { assert.ok(fires('Agent'), 'pre-agent-cap.mjs must fire for tool_name "Agent"'); }); test('STORM cap still fires on WebSearch, WebFetch and the old Task name', () => { for (const t of ['WebSearch', 'WebFetch', 'Task']) assert.ok(fires(t), t); }); test('STORM cap does not fire on unrelated tools', () => { for (const t of ['Bash', 'Edit', 'Write', 'Read', 'AgentOutput', 'ExitPlanMode']) assert.ok(!fires(t), t); });