Skip to content

defineIntent()

defineIntent() is the single entry point for authoring an App Intent in TypeScript. Every field below flows through the IR into the generated Swift.

Signature

import { defineIntent, param } from "@axint/compiler/sdk";
defineIntent({
name: string; // Swift type name (must end in "Intent")
title: string; // Human-facing title in Shortcuts
description: string; // Human-facing description
domain: IntentDomain; // "messaging" | "productivity" | ...
params?: Record<string, ParamSpec>;
entitlements?: string[];
infoPlistKeys?: string[];
isDiscoverable?: boolean; // default: true
perform?: () => unknown; // optional; used for return-type inference
});

Required fields

name

The Swift struct name. Must be a valid Swift identifier ending in Intent.

name: "SendMessageIntent" // ✅
name: "SendMessage" // ❌ AX100: must end in "Intent"
name: "send-message" // ❌ AX100: not a valid Swift identifier

title

Human-facing title shown in Shortcuts and the Siri prompt sheet.

description

Longer description shown in Shortcuts. Keep it under ~140 characters.

domain

One of Apple’s standard App Intent domains: messaging, productivity, transportation, navigation, music, finance, health, smartHome, commerce, utility.

Optional fields

params

Object literal mapping parameter names to param.* calls.

params: {
recipient: param.string("Who to send the message to"),
body: param.string("What to say"),
}

entitlements

Array of reverse-DNS entitlement identifiers.

entitlements: ["com.apple.developer.healthkit"]

infoPlistKeys

Array of Info.plist usage description keys.

infoPlistKeys: ["NSHealthUpdateUsageDescription"]

isDiscoverable

Whether the intent shows up in Shortcuts’ action library. Defaults to true. Set to false for background-only intents.

perform

An optional stub function. If present, Axint walks its body to infer the Swift return type. If absent, the generated perform() returns .result() with no value.

perform: () => ({
orderId: "42",
total: 19.99,
})
// → generates `-> some IntentResult & ReturnsValue<OrderConfirmation>`

See also