getHookEventMetadata function
Get metadata for all hook events.
Implementation
Map<HookEvent, HookEventMetadata> getHookEventMetadata(List<String> toolNames) {
return {
'PreToolUse': HookEventMetadata(
summary: 'Before tool execution',
description:
'Input to command is JSON of tool call arguments.\n'
'Exit code 0 - stdout/stderr not shown\n'
'Exit code 2 - show stderr to model and block tool call\n'
'Other exit codes - show stderr to user only but continue with tool call',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'tool_name',
values: toolNames,
),
),
'PostToolUse': HookEventMetadata(
summary: 'After tool execution',
description:
'Input to command is JSON with fields "inputs" and "response".\n'
'Exit code 0 - stdout shown in transcript mode\n'
'Exit code 2 - show stderr to model immediately\n'
'Other exit codes - show stderr to user only',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'tool_name',
values: toolNames,
),
),
'PostToolUseFailure': HookEventMetadata(
summary: 'After tool execution fails',
description:
'Input to command is JSON with tool_name, tool_input, etc.\n'
'Exit code 0 - stdout shown in transcript mode\n'
'Exit code 2 - show stderr to model immediately',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'tool_name',
values: toolNames,
),
),
'PermissionDenied': HookEventMetadata(
summary: 'After auto mode classifier denies a tool call',
description:
'Input to command is JSON with tool_name, tool_input, tool_use_id, and reason.',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'tool_name',
values: toolNames,
),
),
'Notification': HookEventMetadata(
summary: 'When notifications are sent',
description:
'Input to command is JSON with notification message and type.',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'notification_type',
values: [
'permission_prompt',
'idle_prompt',
'auth_success',
'elicitation_dialog',
'elicitation_complete',
'elicitation_response',
],
),
),
'UserPromptSubmit': const HookEventMetadata(
summary: 'When the user submits a prompt',
description: 'Input to command is JSON with original user prompt text.',
),
'SessionStart': HookEventMetadata(
summary: 'When a new session is started',
description: 'Input to command is JSON with session start source.',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'source',
values: ['startup', 'resume', 'clear', 'compact'],
),
),
'Stop': const HookEventMetadata(
summary: 'Right before Neomage concludes its response',
description:
'Exit code 0 - stdout/stderr not shown\n'
'Exit code 2 - show stderr to model and continue conversation',
),
'StopFailure': HookEventMetadata(
summary: 'When the turn ends due to an API error',
description: 'Fires instead of Stop when an API error ended the turn.',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'error',
values: [
'rate_limit',
'authentication_failed',
'billing_error',
'invalid_request',
'server_error',
'max_output_tokens',
'unknown',
],
),
),
'SubagentStart': const HookEventMetadata(
summary: 'When a subagent is started',
description: 'Input to command is JSON with agent_id and agent_type.',
matcherMetadata: MatcherMetadata(fieldToMatch: 'agent_type', values: []),
),
'SubagentStop': const HookEventMetadata(
summary: 'Right before a subagent concludes its response',
description: 'Input includes agent_id, agent_type, and transcript_path.',
matcherMetadata: MatcherMetadata(fieldToMatch: 'agent_type', values: []),
),
'PreCompact': HookEventMetadata(
summary: 'Before conversation compaction',
description: 'Input to command is JSON with compaction details.',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'trigger',
values: ['manual', 'auto'],
),
),
'PostCompact': HookEventMetadata(
summary: 'After conversation compaction',
description: 'Input includes compaction details and the summary.',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'trigger',
values: ['manual', 'auto'],
),
),
'SessionEnd': HookEventMetadata(
summary: 'When a session is ending',
description: 'Input to command is JSON with session end reason.',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'reason',
values: ['clear', 'logout', 'prompt_input_exit', 'other'],
),
),
'PermissionRequest': HookEventMetadata(
summary: 'When a permission dialog is displayed',
description: 'Input includes tool_name, tool_input, and tool_use_id.',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'tool_name',
values: toolNames,
),
),
'Setup': HookEventMetadata(
summary: 'Repo setup hooks for init and maintenance',
description:
'Input to command is JSON with trigger (init or maintenance).',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'trigger',
values: ['init', 'maintenance'],
),
),
'TeammateIdle': const HookEventMetadata(
summary: 'When a teammate is about to go idle',
description: 'Input includes teammate_name and team_name.',
),
'TaskCreated': const HookEventMetadata(
summary: 'When a task is being created',
description: 'Input includes task_id, task_subject, task_description.',
),
'TaskCompleted': const HookEventMetadata(
summary: 'When a task is being marked as completed',
description: 'Input includes task_id, task_subject, task_description.',
),
'Elicitation': const HookEventMetadata(
summary: 'When an MCP server requests user input',
description:
'Input includes mcp_server_name, message, and requested_schema.',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'mcp_server_name',
values: [],
),
),
'ElicitationResult': const HookEventMetadata(
summary: 'After a user responds to an MCP elicitation',
description: 'Input includes mcp_server_name, action, content.',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'mcp_server_name',
values: [],
),
),
'ConfigChange': HookEventMetadata(
summary: 'When configuration files change during a session',
description: 'Input includes source and file_path.',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'source',
values: [
'user_settings',
'project_settings',
'local_settings',
'policy_settings',
'skills',
],
),
),
'InstructionsLoaded': HookEventMetadata(
summary: 'When an instruction file is loaded',
description: 'Input includes file_path, memory_type, load_reason.',
matcherMetadata: MatcherMetadata(
fieldToMatch: 'load_reason',
values: [
'session_start',
'nested_traversal',
'path_glob_match',
'include',
'compact',
],
),
),
'WorktreeCreate': const HookEventMetadata(
summary: 'Create an isolated worktree',
description: 'Input is JSON with name (suggested worktree slug).',
),
'WorktreeRemove': const HookEventMetadata(
summary: 'Remove a previously created worktree',
description: 'Input is JSON with worktree_path.',
),
'CwdChanged': const HookEventMetadata(
summary: 'After the working directory changes',
description: 'Input is JSON with old_cwd and new_cwd.',
),
'FileChanged': const HookEventMetadata(
summary: 'When a watched file changes',
description: 'Input is JSON with file_path and event.',
),
};
}