import type { AgentId } from '../agents/registry'; export type RefEvent = 'PreToolUse' | 'PostToolUse' | 'SessionStart' | 'UserPromptSubmit' | 'Stop' | 'InstructionsLoaded' | 'SessionEnd'; export interface TopicSpec { type: 'command' | 'mcp_tool'; /** Path under templates/hook/scripts/ — POSIX form, no leading slash. */ script?: string; /** Per-topic timeout in seconds (each agent's `timeout` field). */ timeout?: number; /** Claude Code hook entry `async` flag. Other agents do not get this field. */ async?: boolean; /** Optional CLI arguments appended after the script path. */ args?: string[]; /** MCP server name for `mcp_tool` entries. */ server?: string; /** MCP tool name for `mcp_tool` entries. */ tool?: string; /** Optional MCP tool input object. */ input?: Record; /** Optional Claude / Codex matcher (regex). Cursor / Copilot ignore this. */ matcher?: string; } /** Load and normalize templates/hook/hooks.json. Cached after first call. */ export declare function loadEventTopics(): Record; /** Where each agent expects to find its hook scripts (relative to project). */ export declare const HOOK_SCRIPT_DIRS: Partial>; /** Where each agent's hooks config file lives. Claude's settings.json is * now in this map (was previously special-cased as a static template). */ export declare const HOOK_CONFIG_PATHS: Partial>; /** Claude Code — `.claude/settings.json`. Native shape: * `hooks.` is an array of matcher groups; each group has * `matcher` (regex string) and `hooks` (array of {type, command, timeout}). */ export declare function buildClaudeSettingsJson(scriptsDir: string): string; export declare function buildCursorHooksJson(scriptsDir: string): string; export declare function buildCopilotHooksJson(scriptsDir: string): string; /** Codex CLI — `.codex/hooks.json`. Mirrors Claude's nested matcher-group * shape but events are PascalCase (same as Claude). matcher honored. */ export declare function buildCodexHooksJson(scriptsDir: string): string; /** Google Antigravity — `.agents/hooks.json`. Same nested matcher-group shape * as Claude / Codex, PascalCase event names. Differs from Codex by including * SessionEnd (Antigravity supports it). InstructionsLoaded / mcp_tool / async * / `if` are Claude-only — projected out by AGENT_EVENT_SUPPORT and the * portable hook entry filter. matcher input is the Gemini-CLI tool-name * vocabulary (`run_command`, etc.) — see docs/agent-support.ko.md §4.3 for * the file-edit tool-name caveat. */ export declare function buildAntigravityHooksJson(scriptsDir: string): string; /** Public: resolve the expected on-disk JSON for an agent's hooks config. * Returns null for agents without a hooks-config registration. Used by * inspect / status / update for drift comparison against on-disk files. */ export declare function expectedHooksConfig(agent: AgentId): string | null; export type HookAction = 'created' | 'updated' | 'noop' | 'skipped' | 'dry-run'; export interface HookFileResult { agent: AgentId; path: string; action: HookAction; reason?: string; } export interface InstallHooksOptions { cwd: string; agents: AgentId[]; dryRun: boolean; force: boolean; } export interface InstallHooksResult { /** Per-agent per-script copies (full templates/hook/scripts/ tree per agent). */ scripts: HookFileResult[]; /** Per-agent generated config file (1 × N agents). */ configs: HookFileResult[]; /** Orphan topic directories removed during reconcile (script files inside * matched the hash we recorded last time). */ removedTopics: string[]; /** Individual orphan script files removed (subset of removedTopics expanded). */ removedFiles: string[]; /** Files inside an orphan topic that mswai refused to delete because they * no longer match the recorded hash — user took ownership. Preserved. */ keptUserOwnedFiles: string[]; /** Soft warnings (legacy fallback, partial-modified topic preserved, etc.). */ warnings: string[]; } export declare function hookIdentity(node: unknown): string | null; /** Recursively extract every mswai hook identity from a hook config JSON. Used * to compute the set of entries mswai writes for the deep-merge filter, and * by `doctor` to verify wiring subset (desired ⊆ on-disk). */ export declare function extractHookIdentities(node: unknown, out: Set): void; /** * Mirror templates/hook/scripts/ into each requested agent's hooks dir, then * deep-merge the generated hooks config into each agent's on-disk file. * * Authoritative ownership model * ------------------------------ * - Hook scripts live in topic directories (mlua-lsp/, skill-router-reminder/, * ...). Topics shipped in the current templates are owned by mswai and * overwritten on every run. Topics no longer shipped become 'orphans' — * we delete them only when every file inside still matches the hash we * recorded in `lock.fileHashes`. Hash mismatch = user took ownership → * preserve and warn. * - Hook config JSON (`.claude/settings.json`, etc.) gets a deep-merge: * user's top-level keys (permissions, env, custom hook entries) are * preserved; only entries whose `command` matches one of ours get * replaced. JSON-parse failure backs up the broken file to `.bak` and * recreates from scratch with a warning. */ export declare function installHooks(opts: InstallHooksOptions): InstallHooksResult;