hooks-authoring

Solid

Rules for authoring, registering, and testing hooks in Rosetta. Use when creating a new hook, adding a SemanticKind, troubleshooting a hook that doesn't fire, or reviewing a hooks PR.

AI & Automation 295 stars 57 forks Updated today Apache-2.0

Install

View on GitHub

Quality Score: 92/100

Stars 20%
82
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

<hooks_authoring> ### Hook entry rule Only files that export `defineHook(…)` AND call `runAsCli(hook, module)` belong directly in `hooks/src/hooks/`. Every `.ts` at the top level of that directory becomes a standalone CJS bundle distributed to all 5 IDEs (claude, codex, copilot, cursor, windsurf). Helper/data files without `runAsCli` belong in a named subdirectory: `hooks/src/hooks/<feature>/`. ### Helper placement - Feature-local helpers → `hooks/src/hooks/<feature>/` (e.g. `hooks/src/hooks/dangerous-actions/patterns.ts`). - Cross-hook runtime helpers → `hooks/src/runtime/`. ### Build is non-recursive `hooks/scripts/build-bundles.mjs:24` uses `readdirSync(hooksDir).filter(f => f.endsWith('.ts'))`. There is **no `{ recursive: true }`**. Subdirectories are invisible to the bundler. Adding a top-level `.ts` without `runAsCli` produces a dead bundle for all 5 IDEs. ### Adding a SemanticKind When a hook needs a new tool category (e.g. `mcp-call`): 1. **`hooks/src/runtime/ide-registry.ts`** — add a row to `TOOL_KINDS` with all 5 IDE columns (`null` where the event doesn't exist). `SemanticKind = keyof typeof TOOL_KINDS` so TypeScript enforces coverage. 2. **`hooks/src/runtime/ide-rows/<ide>.ts`** — if the kind requires special logic (e.g. prefix-match for `mcp__.*`), add a conditional branch at the top of `lookupToolKind` in the IDE-row file before the table loop. Table-driven lookup alone cannot handle open-ended tool name patterns. 3. **Hook entry** — add the new kind t...

Details

Author
griddynamics
Repository
griddynamics/rosetta
Created
4 months ago
Last Updated
today
Language
TypeScript
License
Apache-2.0

Similar Skills

Semantically similar based on skill content — not just same category