Task: Add Intents to a Hudson App
Context
Intents declare structured metadata about app commands for LLM/voice/search integration. Read packages/hudson-sdk/src/types/intent.ts for the full type.
Inputs
- App ID: Which app to add intents to
- Commands: List of existing commands from
useCommands()
Steps
-
Read existing commands: Open
app/apps/{app}/hooks.ts, finduseCommands()return array. Note each command’sid,label, andaction. -
Create intents file (
app/apps/{app}/intents.ts):import type { AppIntent } from '@hudson/sdk'; export const {app}Intents: AppIntent[] = [ { commandId: '{app}:{action}', // Must match a CommandOption.id title: 'Human-Readable Action', description: 'Natural language description for LLM matching', category: 'tool', // tool|edit|file|view|navigation|toggle|workspace|settings keywords: ['synonym1', 'synonym2'], shortcut: 'Cmd+1', // Optional dangerous: false, // Optional, true = requires confirmation }, ]; -
Add to app definition: In
app/apps/{app}/index.ts, import intents and addintents: {app}Intentsto the HudsonApp object. -
Validate: Every
commandIdin intents must match anidin theuseCommands()return array. Mismatches will show dev-mode warnings.
Category Guide
| Category | When to use |
|---|---|
tool | Activating a tool (pen, select, eraser) |
edit | Mutating data (delete, duplicate, transform) |
file | I/O (save, export, import, open) |
view | View changes (zoom, pan, fit, toggle grid) |
navigation | Navigation (go to item, switch view) |
toggle | Boolean toggles (snap, rulers, dark mode) |
workspace | Workspace actions (switch, create) |
settings | Preferences (theme, font size) |