@axintai/compiler 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +154 -153
- package/dist/cli/index.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +133 -8
- package/dist/core/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/compiler.ts","../../src/core/parser.ts","../../src/core/types.ts","../../src/core/generator.ts","../../src/core/validator.ts","../../src/core/eject.ts","../../src/sdk/index.ts"],"sourcesContent":["/**\n * Axint Compiler\n *\n * Orchestrates the full compilation pipeline:\n * 1. Parse TypeScript intent definition → IR\n * 2. Validate IR against App Intents constraints\n * 3. Generate Swift source code\n * 4. Validate generated Swift\n * 5. Optionally emit Info.plist and entitlements fragments\n *\n * This is the main entry point for the compilation process.\n */\n\nimport { readFileSync } from \"node:fs\";\nimport { parseIntentSource, ParserError } from \"./parser.js\";\nimport {\n generateSwift,\n generateInfoPlistFragment,\n generateEntitlementsFragment,\n} from \"./generator.js\";\nimport { validateIntent, validateSwiftSource } from \"./validator.js\";\nimport type {\n CompilerOutput,\n CompilerOptions,\n Diagnostic,\n IRIntent,\n IRType,\n IRParameter,\n IRPrimitiveType,\n} from \"./types.js\";\n\nexport interface CompileResult {\n success: boolean;\n output?: CompilerOutput;\n diagnostics: Diagnostic[];\n}\n\n/**\n * Compile a TypeScript intent definition file into Swift.\n */\nexport function compileFile(\n filePath: string,\n options: Partial<CompilerOptions> = {}\n): CompileResult {\n // 1. Read source\n let source: string;\n try {\n source = readFileSync(filePath, \"utf-8\");\n } catch (_err) {\n return {\n success: false,\n diagnostics: [\n {\n code: \"AX000\",\n severity: \"error\",\n message: `Cannot read file: ${filePath}`,\n file: filePath,\n },\n ],\n };\n }\n\n return compileSource(source, filePath, options);\n}\n\n/**\n * Compile a TypeScript source string directly (no file I/O).\n * Useful for MCP server and testing.\n */\nexport function compileSource(\n source: string,\n fileName: string = \"<stdin>\",\n options: Partial<CompilerOptions> = {}\n): CompileResult {\n // 1. Parse → IR (catch ParserError as a diagnostic so the caller\n // sees a clean error list instead of an uncaught exception)\n let ir;\n try {\n ir = parseIntentSource(source, fileName);\n } catch (err) {\n if (err instanceof ParserError) {\n return {\n success: false,\n diagnostics: [\n {\n code: err.code,\n severity: \"error\",\n message: err.message,\n file: err.file,\n line: err.line,\n suggestion: err.suggestion,\n },\n ],\n };\n }\n throw err;\n }\n\n return compileFromIR(ir, options);\n}\n\n/**\n * Compile from a pre-built IR (skips parsing). This is the bridge\n * that allows any frontend language (Python, Rust, Go) to emit an\n * IRIntent JSON and feed it directly into the Swift generator.\n *\n * Used by:\n * - `compileSource()` after its own parse step\n * - `axint compile --from-ir <file.json>` for cross-language pipelines\n * - The Python SDK's `axintai compile` command\n */\nexport function compileFromIR(\n ir: IRIntent,\n options: Partial<CompilerOptions> = {}\n): CompileResult {\n const diagnostics: Diagnostic[] = [];\n\n // 1. Validate IR\n const irDiagnostics = validateIntent(ir);\n diagnostics.push(...irDiagnostics);\n\n if (irDiagnostics.some((d) => d.severity === \"error\")) {\n return { success: false, diagnostics };\n }\n\n // 2. Generate Swift\n const swiftCode = generateSwift(ir);\n\n // 3. Validate generated Swift\n if (options.validate !== false) {\n const swiftDiagnostics = validateSwiftSource(swiftCode);\n diagnostics.push(...swiftDiagnostics);\n\n if (swiftDiagnostics.some((d) => d.severity === \"error\")) {\n return { success: false, diagnostics };\n }\n }\n\n // 4. Optional fragments\n const infoPlistFragment = options.emitInfoPlist\n ? generateInfoPlistFragment(ir)\n : undefined;\n const entitlementsFragment = options.emitEntitlements\n ? generateEntitlementsFragment(ir)\n : undefined;\n\n // 5. Build output\n const intentFileName = `${ir.name}Intent.swift`;\n const outputPath = options.outDir\n ? `${options.outDir}/${intentFileName}`\n : intentFileName;\n\n return {\n success: true,\n output: {\n outputPath,\n swiftCode,\n infoPlistFragment,\n entitlementsFragment,\n ir,\n diagnostics,\n },\n diagnostics,\n };\n}\n\n// ─── Cross-Language IR Bridge ───────────────────────────────────────\n\n/** Valid primitive type strings from any SDK */\nconst VALID_PRIMITIVES = new Set<string>([\n \"string\",\n \"int\",\n \"double\",\n \"float\",\n \"boolean\",\n \"date\",\n \"duration\",\n \"url\",\n]);\n\n/**\n * Parse a raw JSON object into a typed IRIntent. Accepts the flat\n * format that the Python SDK's `IntentIR.to_dict()` produces, where\n * parameter types are plain strings rather than `{ kind, value }` objects.\n *\n * This is the key function that bridges the Python → TypeScript gap.\n */\nexport function irFromJSON(data: Record<string, unknown>): IRIntent {\n const parameters: IRParameter[] = ((data.parameters as unknown[]) ?? []).map(\n (p: unknown) => {\n const param = p as Record<string, unknown>;\n return {\n name: param.name as string,\n type: normalizeIRType(param.type),\n title: (param.title as string) ?? (param.description as string) ?? \"\",\n description: (param.description as string) ?? \"\",\n isOptional: (param.optional as boolean) ?? (param.isOptional as boolean) ?? false,\n defaultValue: param.default ?? param.defaultValue,\n };\n }\n );\n\n return {\n name: data.name as string,\n title: data.title as string,\n description: data.description as string,\n domain: data.domain as string | undefined,\n parameters,\n returnType: data.returnType\n ? normalizeIRType(data.returnType)\n : { kind: \"primitive\", value: \"string\" },\n sourceFile: (data.sourceFile as string) ?? undefined,\n entitlements: (data.entitlements as string[]) ?? undefined,\n infoPlistKeys: (data.infoPlistKeys as Record<string, string>) ?? undefined,\n isDiscoverable: (data.isDiscoverable as boolean) ?? true,\n };\n}\n\n/**\n * Normalize a type value from JSON. The Python SDK sends types as\n * plain strings (\"string\", \"int\", etc.) while the TS IR uses\n * `{ kind: \"primitive\", value: \"string\" }`. This function handles both.\n */\nfunction normalizeIRType(type: unknown): IRType {\n if (typeof type === \"string\") {\n const normalized = type === \"number\" ? \"int\" : type;\n if (VALID_PRIMITIVES.has(normalized)) {\n return { kind: \"primitive\", value: normalized as IRPrimitiveType };\n }\n return { kind: \"primitive\", value: \"string\" };\n }\n if (type && typeof type === \"object\") {\n const t = type as Record<string, unknown>;\n if (t.kind === \"primitive\") return type as IRType;\n if (t.kind === \"array\")\n return { kind: \"array\", elementType: normalizeIRType(t.elementType) };\n if (t.kind === \"optional\")\n return { kind: \"optional\", innerType: normalizeIRType(t.innerType) };\n if (t.kind === \"entity\") return type as IRType;\n if (t.kind === \"enum\") return type as IRType;\n }\n // Default fallback\n return { kind: \"primitive\", value: \"string\" };\n}\n","/**\n * Axint Parser\n *\n * Parses TypeScript intent definitions (using the defineIntent() API)\n * into the Axint Intermediate Representation (IR).\n *\n * Approach: Real TypeScript compiler API AST walker. We create a\n * SourceFile, find defineIntent() CallExpressions, and extract the\n * ObjectLiteralExpression properties using the actual TS AST.\n *\n * The previous v0.1.x parser used regex matching. That approach was\n * replaced in v0.2.0 to support enums, arrays, entities, and accurate\n * return-type inference.\n */\n\nimport ts from \"typescript\";\nimport type {\n IRIntent,\n IRParameter,\n IRType,\n IRPrimitiveType,\n IREntity,\n DisplayRepresentation,\n} from \"./types.js\";\nimport { PARAM_TYPES, LEGACY_PARAM_ALIASES } from \"./types.js\";\n\n/**\n * Parse a TypeScript source file containing defineIntent() and/or\n * defineEntity() calls and return the IR representation.\n */\nexport function parseIntentSource(\n source: string,\n filePath: string = \"<stdin>\"\n): IRIntent {\n const sourceFile = ts.createSourceFile(\n filePath,\n source,\n ts.ScriptTarget.Latest,\n true, // setParentNodes\n ts.ScriptKind.TS\n );\n\n // Parse all entity definitions first, so they can be referenced by intents\n const entities = findDefineEntityCalls(sourceFile).map((call) =>\n parseEntityDefinition(call, filePath, sourceFile)\n );\n\n const defineIntentCall = findDefineIntentCall(sourceFile);\n if (!defineIntentCall) {\n throw new ParserError(\n \"AX001\",\n `No defineIntent() call found in ${filePath}`,\n filePath,\n undefined,\n \"Ensure your file contains a `defineIntent({ ... })` call.\"\n );\n }\n\n const arg = defineIntentCall.arguments[0];\n if (!arg || !ts.isObjectLiteralExpression(arg)) {\n throw new ParserError(\n \"AX001\",\n \"defineIntent() must be called with an object literal\",\n filePath,\n posOf(sourceFile, defineIntentCall),\n \"Pass an object: defineIntent({ name, title, description, params, perform })\"\n );\n }\n\n const props = propertyMap(arg);\n\n const name = readStringLiteral(props.get(\"name\"));\n const title = readStringLiteral(props.get(\"title\"));\n const description = readStringLiteral(props.get(\"description\"));\n const domain = readStringLiteral(props.get(\"domain\"));\n const category = readStringLiteral(props.get(\"category\"));\n const isDiscoverable = readBooleanLiteral(props.get(\"isDiscoverable\"));\n\n if (!name) {\n throw new ParserError(\n \"AX002\",\n \"Missing required field: name\",\n filePath,\n posOf(sourceFile, arg),\n 'Add a name field: name: \"MyIntent\"'\n );\n }\n if (!title) {\n throw new ParserError(\n \"AX003\",\n \"Missing required field: title\",\n filePath,\n posOf(sourceFile, arg),\n 'Add a title field: title: \"My Intent Title\"'\n );\n }\n if (!description) {\n throw new ParserError(\n \"AX004\",\n \"Missing required field: description\",\n filePath,\n posOf(sourceFile, arg),\n 'Add a description field: description: \"What this intent does\"'\n );\n }\n\n const paramsNode = props.get(\"params\");\n const parameters: IRParameter[] = paramsNode\n ? extractParameters(paramsNode, filePath, sourceFile)\n : [];\n\n // Return-type inference from the perform() function signature.\n const performNode = props.get(\"perform\");\n const returnType = inferReturnType(performNode);\n\n // Entitlements (optional array of strings)\n const entitlementsNode = props.get(\"entitlements\");\n const entitlements = readStringArray(entitlementsNode);\n\n // Info.plist keys (optional object literal of { key: \"description\" })\n const infoPlistNode = props.get(\"infoPlistKeys\");\n const infoPlistKeys = readStringRecord(infoPlistNode);\n\n // Intent donation (optional boolean)\n const donateOnPerformNode = props.get(\"donateOnPerform\");\n const donateOnPerform = readBooleanLiteral(donateOnPerformNode);\n\n // Custom result type (optional string)\n const customResultTypeNode = props.get(\"customResultType\");\n const customResultType = readStringLiteral(customResultTypeNode);\n\n return {\n name,\n title,\n description,\n domain: domain || undefined,\n category: category || undefined,\n parameters,\n returnType,\n sourceFile: filePath,\n entitlements: entitlements.length > 0 ? entitlements : undefined,\n infoPlistKeys:\n Object.keys(infoPlistKeys).length > 0 ? infoPlistKeys : undefined,\n isDiscoverable: isDiscoverable ?? undefined,\n entities: entities.length > 0 ? entities : undefined,\n donateOnPerform: donateOnPerform ?? undefined,\n customResultType: customResultType ?? undefined,\n };\n}\n\n// ─── AST Walkers ─────────────────────────────────────────────────────\n\n/**\n * Find the first defineIntent() call in the AST.\n */\nfunction findDefineIntentCall(\n node: ts.Node\n): ts.CallExpression | undefined {\n let found: ts.CallExpression | undefined;\n const visit = (n: ts.Node): void => {\n if (found) return;\n if (\n ts.isCallExpression(n) &&\n ts.isIdentifier(n.expression) &&\n n.expression.text === \"defineIntent\"\n ) {\n found = n;\n return;\n }\n ts.forEachChild(n, visit);\n };\n visit(node);\n return found;\n}\n\n/**\n * Find all defineEntity() calls in the AST.\n */\nfunction findDefineEntityCalls(node: ts.Node): ts.CallExpression[] {\n const found: ts.CallExpression[] = [];\n const visit = (n: ts.Node): void => {\n if (\n ts.isCallExpression(n) &&\n ts.isIdentifier(n.expression) &&\n n.expression.text === \"defineEntity\"\n ) {\n found.push(n);\n return;\n }\n ts.forEachChild(n, visit);\n };\n visit(node);\n return found;\n}\n\nfunction propertyMap(\n obj: ts.ObjectLiteralExpression\n): Map<string, ts.Expression> {\n const map = new Map<string, ts.Expression>();\n for (const prop of obj.properties) {\n if (ts.isPropertyAssignment(prop)) {\n const key = propertyKeyName(prop.name);\n if (key) map.set(key, prop.initializer);\n } else if (ts.isShorthandPropertyAssignment(prop)) {\n map.set(prop.name.text, prop.name);\n } else if (ts.isMethodDeclaration(prop)) {\n const key = propertyKeyName(prop.name);\n if (key) map.set(key, prop as unknown as ts.Expression);\n }\n }\n return map;\n}\n\nfunction propertyKeyName(name: ts.PropertyName): string | undefined {\n if (ts.isIdentifier(name)) return name.text;\n if (ts.isStringLiteral(name)) return name.text;\n if (ts.isNumericLiteral(name)) return name.text;\n return undefined;\n}\n\nfunction readStringLiteral(node: ts.Expression | undefined): string | null {\n if (!node) return null;\n if (ts.isStringLiteral(node)) return node.text;\n if (ts.isNoSubstitutionTemplateLiteral(node)) return node.text;\n return null;\n}\n\nfunction readBooleanLiteral(\n node: ts.Expression | undefined\n): boolean | undefined {\n if (!node) return undefined;\n if (node.kind === ts.SyntaxKind.TrueKeyword) return true;\n if (node.kind === ts.SyntaxKind.FalseKeyword) return false;\n return undefined;\n}\n\nfunction readStringArray(node: ts.Expression | undefined): string[] {\n if (!node || !ts.isArrayLiteralExpression(node)) return [];\n const out: string[] = [];\n for (const el of node.elements) {\n const s = readStringLiteral(el);\n if (s !== null) out.push(s);\n }\n return out;\n}\n\nfunction readStringRecord(\n node: ts.Expression | undefined\n): Record<string, string> {\n if (!node || !ts.isObjectLiteralExpression(node)) return {};\n const rec: Record<string, string> = {};\n for (const prop of node.properties) {\n if (!ts.isPropertyAssignment(prop)) continue;\n const key = propertyKeyName(prop.name);\n const val = readStringLiteral(prop.initializer);\n if (key && val !== null) rec[key] = val;\n }\n return rec;\n}\n\n// ─── Entity Definition Parsing ───────────────────────────────────────\n\n/**\n * Parse a defineEntity() call into an IREntity.\n */\nfunction parseEntityDefinition(\n call: ts.CallExpression,\n filePath: string,\n sourceFile: ts.SourceFile\n): IREntity {\n const arg = call.arguments[0];\n if (!arg || !ts.isObjectLiteralExpression(arg)) {\n throw new ParserError(\n \"AX015\",\n \"defineEntity() must be called with an object literal\",\n filePath,\n posOf(sourceFile, call),\n \"Pass an object: defineEntity({ name, display, properties, query })\"\n );\n }\n\n const props = propertyMap(arg);\n\n const name = readStringLiteral(props.get(\"name\"));\n if (!name) {\n throw new ParserError(\n \"AX016\",\n \"Entity definition missing required field: name\",\n filePath,\n posOf(sourceFile, arg),\n 'Add a name field: name: \"Task\"'\n );\n }\n\n const displayNode = props.get(\"display\");\n if (!displayNode || !ts.isObjectLiteralExpression(displayNode)) {\n throw new ParserError(\n \"AX017\",\n \"Entity definition missing required field: display\",\n filePath,\n posOf(sourceFile, arg),\n 'Add display field: display: { title: \"name\", subtitle: \"status\" }'\n );\n }\n\n const displayProps = propertyMap(displayNode);\n const displayRepresentation: DisplayRepresentation = {\n title: readStringLiteral(displayProps.get(\"title\")) || \"name\",\n subtitle: readStringLiteral(displayProps.get(\"subtitle\")) || undefined,\n image: readStringLiteral(displayProps.get(\"image\")) || undefined,\n };\n\n const propertiesNode = props.get(\"properties\");\n const properties = propertiesNode\n ? extractParameters(propertiesNode, filePath, sourceFile)\n : [];\n\n const queryTypeNode = props.get(\"query\");\n const queryTypeStr = readStringLiteral(queryTypeNode);\n const queryType = validateQueryType(queryTypeStr, filePath, sourceFile, queryTypeNode);\n\n return {\n name,\n displayRepresentation,\n properties,\n queryType,\n };\n}\n\n/**\n * Validate and normalize query type string.\n */\nfunction validateQueryType(\n value: string | null,\n filePath: string,\n sourceFile: ts.SourceFile,\n node: ts.Expression | undefined\n): \"all\" | \"id\" | \"string\" | \"property\" {\n if (!value) {\n throw new ParserError(\n \"AX018\",\n \"Entity definition missing required field: query\",\n filePath,\n node ? posOf(sourceFile, node) : undefined,\n 'Add query field: query: \"string\" (or \"all\", \"id\", \"property\")'\n );\n }\n const valid = [\"all\", \"id\", \"string\", \"property\"] as const;\n if (!valid.includes(value as any)) {\n throw new ParserError(\n \"AX019\",\n `Invalid query type: \"${value}\". Must be one of: all, id, string, property`,\n filePath,\n node ? posOf(sourceFile, node) : undefined\n );\n }\n return value as \"all\" | \"id\" | \"string\" | \"property\";\n}\n\n// ─── Parameter Extraction ────────────────────────────────────────────\n\nfunction extractParameters(\n node: ts.Expression,\n filePath: string,\n sourceFile: ts.SourceFile\n): IRParameter[] {\n if (!ts.isObjectLiteralExpression(node)) {\n throw new ParserError(\n \"AX006\",\n \"`params` must be an object literal\",\n filePath,\n posOf(sourceFile, node),\n \"Use params: { name: param.string(...), ... }\"\n );\n }\n\n const params: IRParameter[] = [];\n for (const prop of node.properties) {\n if (!ts.isPropertyAssignment(prop)) continue;\n const paramName = propertyKeyName(prop.name);\n if (!paramName) continue;\n\n const { typeName, description, configObject, callExpr } = extractParamCall(\n prop.initializer,\n filePath,\n sourceFile\n );\n\n const resolvedType = resolveParamType(typeName, filePath, sourceFile, prop, callExpr);\n\n const isOptional = configObject\n ? readBooleanLiteral(configObject.get(\"required\")) === false\n : false;\n\n const defaultExpr = configObject?.get(\"default\");\n const defaultValue = defaultExpr ? evaluateLiteral(defaultExpr) : undefined;\n\n const titleFromConfig = configObject\n ? readStringLiteral(configObject.get(\"title\"))\n : null;\n\n const irType: IRType = isOptional\n ? {\n kind: \"optional\",\n innerType: resolvedType,\n }\n : resolvedType;\n\n params.push({\n name: paramName,\n type: irType,\n title: titleFromConfig || prettyTitle(paramName),\n description,\n isOptional,\n defaultValue,\n });\n }\n\n return params;\n}\n\ninterface ParamCallInfo {\n typeName: string;\n description: string;\n configObject: Map<string, ts.Expression> | null;\n callExpr: ts.CallExpression;\n}\n\n/**\n * Extract param type, description, and config from a param.* call.\n * For param.entity() and param.dynamicOptions(), the structure is different.\n */\nfunction extractParamCall(\n expr: ts.Expression,\n filePath: string,\n sourceFile: ts.SourceFile\n): ParamCallInfo {\n if (!ts.isCallExpression(expr)) {\n throw new ParserError(\n \"AX007\",\n \"Parameter value must be a call to a param.* helper\",\n filePath,\n posOf(sourceFile, expr),\n \"Use param.string(...), param.int(...), param.date(...), etc.\"\n );\n }\n\n // Expect: param.<type>(description?, config?)\n if (\n !ts.isPropertyAccessExpression(expr.expression) ||\n !ts.isIdentifier(expr.expression.expression) ||\n expr.expression.expression.text !== \"param\"\n ) {\n throw new ParserError(\n \"AX007\",\n \"Parameter value must be a call to a param.* helper\",\n filePath,\n posOf(sourceFile, expr),\n \"Use param.string(...), param.int(...), param.date(...), etc.\"\n );\n }\n\n const typeName = expr.expression.name.text;\n\n // For entity and dynamicOptions, the structure differs:\n // - param.entity(\"EntityName\", \"description\", config?)\n // - param.dynamicOptions(\"Provider\", param.string(...), \"description\", config?)\n let descriptionArg: ts.Expression | undefined;\n let configArg: ts.Expression | undefined;\n\n if (typeName === \"entity\" && expr.arguments.length >= 2) {\n descriptionArg = expr.arguments[1];\n configArg = expr.arguments[2];\n } else if (typeName === \"dynamicOptions\" && expr.arguments.length >= 3) {\n descriptionArg = expr.arguments[2];\n configArg = expr.arguments[3];\n } else {\n descriptionArg = expr.arguments[0];\n configArg = expr.arguments[1];\n }\n\n const description = descriptionArg ? readStringLiteral(descriptionArg) : null;\n if (description === null) {\n throw new ParserError(\n \"AX008\",\n `param.${typeName}() requires a string description`,\n filePath,\n posOf(sourceFile, expr),\n `Example: param.${typeName}(\"Human-readable description\")`\n );\n }\n\n const configObject =\n configArg && ts.isObjectLiteralExpression(configArg)\n ? propertyMap(configArg)\n : null;\n\n return { typeName, description, configObject, callExpr: expr };\n}\n\n/**\n * Resolve a param type name into an IRType.\n * Supports primitives, entity references, and dynamic options.\n */\nfunction resolveParamType(\n typeName: string,\n filePath: string,\n sourceFile: ts.SourceFile,\n node: ts.Node,\n callExpr?: ts.CallExpression\n): IRType {\n // Primitive types\n if (PARAM_TYPES.has(typeName as IRPrimitiveType)) {\n return { kind: \"primitive\", value: typeName as IRPrimitiveType };\n }\n\n // Legacy aliases\n if (typeName in LEGACY_PARAM_ALIASES) {\n return {\n kind: \"primitive\",\n value: LEGACY_PARAM_ALIASES[typeName],\n };\n }\n\n // Entity types: param.entity(\"EntityName\")\n if (typeName === \"entity\") {\n if (!callExpr || callExpr.arguments.length === 0) {\n throw new ParserError(\n \"AX020\",\n \"param.entity() requires the entity name as the first argument\",\n filePath,\n posOf(sourceFile, node),\n 'Example: param.entity(\"Task\", \"Reference an entity\")'\n );\n }\n const entityName = readStringLiteral(callExpr.arguments[0]);\n if (!entityName) {\n throw new ParserError(\n \"AX021\",\n \"param.entity() requires a string entity name\",\n filePath,\n posOf(sourceFile, node)\n );\n }\n return {\n kind: \"entity\",\n entityName,\n properties: [],\n };\n }\n\n // Dynamic options: param.dynamicOptions(\"ProviderName\", innerType)\n if (typeName === \"dynamicOptions\") {\n if (!callExpr || callExpr.arguments.length < 2) {\n throw new ParserError(\n \"AX022\",\n \"param.dynamicOptions() requires (providerName, paramType)\",\n filePath,\n posOf(sourceFile, node),\n 'Example: param.dynamicOptions(\"PlaylistProvider\", param.string(...))'\n );\n }\n const providerName = readStringLiteral(callExpr.arguments[0]);\n if (!providerName) {\n throw new ParserError(\n \"AX023\",\n \"param.dynamicOptions() provider name must be a string\",\n filePath,\n posOf(sourceFile, node)\n );\n }\n // TODO: Extract inner param type from the second argument\n const valueType: IRType = { kind: \"primitive\", value: \"string\" };\n return {\n kind: \"dynamicOptions\",\n valueType,\n providerName,\n };\n }\n\n throw new ParserError(\n \"AX005\",\n `Unknown param type: param.${typeName}`,\n filePath,\n posOf(sourceFile, node),\n `Supported types: ${[...PARAM_TYPES].join(\", \")}, entity, dynamicOptions`\n );\n}\n\n// ─── Literal Evaluation ──────────────────────────────────────────────\n\nfunction evaluateLiteral(node: ts.Expression): unknown {\n if (ts.isStringLiteral(node)) return node.text;\n if (ts.isNoSubstitutionTemplateLiteral(node)) return node.text;\n if (ts.isNumericLiteral(node)) return Number(node.text);\n if (node.kind === ts.SyntaxKind.TrueKeyword) return true;\n if (node.kind === ts.SyntaxKind.FalseKeyword) return false;\n if (node.kind === ts.SyntaxKind.NullKeyword) return null;\n if (\n ts.isPrefixUnaryExpression(node) &&\n node.operator === ts.SyntaxKind.MinusToken &&\n ts.isNumericLiteral(node.operand)\n ) {\n return -Number(node.operand.text);\n }\n return undefined;\n}\n\n// ─── Return-Type Inference ───────────────────────────────────────────\n\nfunction inferReturnType(performNode: ts.Expression | undefined): IRType {\n // Default when we can't infer anything.\n const defaultType: IRType = { kind: \"primitive\", value: \"string\" };\n if (!performNode) return defaultType;\n\n // Handle method shorthand: perform() { ... }\n if (ts.isMethodDeclaration(performNode)) {\n return inferFromReturnStatements(performNode.body);\n }\n\n // Handle arrow function: perform: async () => { ... }\n if (ts.isArrowFunction(performNode)) {\n if (performNode.body && ts.isBlock(performNode.body)) {\n return inferFromReturnStatements(performNode.body);\n }\n // Single-expression arrow: perform: async (p) => \"literal\"\n return inferFromExpression(performNode.body as ts.Expression);\n }\n\n // Handle function expression: perform: async function() { ... }\n if (ts.isFunctionExpression(performNode)) {\n return inferFromReturnStatements(performNode.body);\n }\n\n return defaultType;\n}\n\nfunction inferFromReturnStatements(block: ts.Block | undefined): IRType {\n const defaultType: IRType = { kind: \"primitive\", value: \"string\" };\n if (!block) return defaultType;\n\n let inferred: IRType | undefined;\n const visit = (n: ts.Node): void => {\n if (inferred) return;\n if (ts.isReturnStatement(n) && n.expression) {\n inferred = inferFromExpression(n.expression);\n return;\n }\n // Don't walk into nested functions — only the top-level perform() body.\n if (\n ts.isFunctionDeclaration(n) ||\n ts.isFunctionExpression(n) ||\n ts.isArrowFunction(n)\n ) {\n return;\n }\n ts.forEachChild(n, visit);\n };\n visit(block);\n return inferred ?? defaultType;\n}\n\nfunction inferFromExpression(expr: ts.Expression): IRType {\n if (ts.isStringLiteral(expr) || ts.isNoSubstitutionTemplateLiteral(expr)) {\n return { kind: \"primitive\", value: \"string\" };\n }\n if (ts.isNumericLiteral(expr)) {\n return expr.text.includes(\".\")\n ? { kind: \"primitive\", value: \"double\" }\n : { kind: \"primitive\", value: \"int\" };\n }\n if (\n expr.kind === ts.SyntaxKind.TrueKeyword ||\n expr.kind === ts.SyntaxKind.FalseKeyword\n ) {\n return { kind: \"primitive\", value: \"boolean\" };\n }\n // Default fallback\n return { kind: \"primitive\", value: \"string\" };\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────\n\nfunction prettyTitle(name: string): string {\n const spaced = name.replace(/([A-Z])/g, \" $1\").trim();\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\nfunction posOf(\n sourceFile: ts.SourceFile,\n node: ts.Node\n): number | undefined {\n try {\n const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n return line + 1;\n } catch {\n return undefined;\n }\n}\n\n// ─── Error Class ─────────────────────────────────────────────────────\n\nexport class ParserError extends Error {\n constructor(\n public code: string,\n message: string,\n public file: string,\n public line?: number,\n public suggestion?: string\n ) {\n super(message);\n this.name = \"ParserError\";\n }\n\n format(): string {\n let output = `\\n error[${this.code}]: ${this.message}\\n`;\n if (this.file) output += ` --> ${this.file}`;\n if (this.line) output += `:${this.line}`;\n output += \"\\n\";\n if (this.suggestion) {\n output += ` = help: ${this.suggestion}\\n`;\n }\n return output;\n }\n}\n","/**\n * Axint Core Types\n *\n * Intermediate Representation (IR) and compiler types for the\n * TypeScript → Swift App Intent compilation pipeline.\n */\n\n// ─── IR Types ────────────────────────────────────────────────────────\n\n/** Primitive types supported by App Intents */\nexport type IRPrimitiveType =\n | \"string\"\n | \"int\"\n | \"double\"\n | \"float\"\n | \"boolean\"\n | \"date\"\n | \"duration\"\n | \"url\";\n\n/** Type node in the IR */\nexport type IRType =\n | { kind: \"primitive\"; value: IRPrimitiveType }\n | { kind: \"array\"; elementType: IRType }\n | { kind: \"optional\"; innerType: IRType }\n | { kind: \"entity\"; entityName: string; properties: IRParameter[] }\n | { kind: \"entityQuery\"; entityName: string; queryType: \"all\" | \"id\" | \"string\" | \"property\" }\n | { kind: \"dynamicOptions\"; valueType: IRType; providerName: string }\n | { kind: \"enum\"; name: string; cases: string[] };\n\n/** A single parameter in an intent definition */\nexport interface IRParameter {\n name: string;\n type: IRType;\n title: string;\n description: string;\n isOptional: boolean;\n defaultValue?: unknown;\n}\n\n/**\n * Display representation configuration for an entity.\n * Maps which properties to show in Siri and Shortcuts UI.\n */\nexport interface DisplayRepresentation {\n title: string;\n subtitle?: string;\n image?: string;\n}\n\n/**\n * An App Entity definition for complex, domain-specific data types.\n * Entities can be queried and used as parameter types in intents.\n */\nexport interface IREntity {\n name: string;\n displayRepresentation: DisplayRepresentation;\n properties: IRParameter[];\n queryType: \"all\" | \"id\" | \"string\" | \"property\";\n}\n\n/** The main IR node representing a compiled intent */\nexport interface IRIntent {\n name: string;\n title: string;\n description: string;\n domain?: string;\n category?: string;\n parameters: IRParameter[];\n returnType: IRType;\n sourceFile: string;\n /** Entitlements required by this intent (e.g., \"com.apple.developer.siri\") */\n entitlements?: string[];\n /** Info.plist keys required by this intent (e.g., \"NSCalendarsUsageDescription\") */\n infoPlistKeys?: Record<string, string>;\n /** Whether the intent should be exposed to Spotlight indexing */\n isDiscoverable?: boolean;\n /** App Entities used by this intent */\n entities?: IREntity[];\n /** Whether to donate this intent to Spotlight/Siri when performed */\n donateOnPerform?: boolean;\n /** Custom result type (SwiftUI view or custom struct) to return */\n customResultType?: string;\n}\n\n// ─── Compiler Types ──────────────────────────────────────────────────\n\nexport interface CompilerOptions {\n /** Output directory for generated Swift files */\n outDir: string;\n /** Whether to run validation after generation */\n validate?: boolean;\n /** Target iOS/macOS version */\n target?: \"ios16\" | \"ios17\" | \"ios18\" | \"ios26\" | \"macos13\" | \"macos14\" | \"macos15\" | \"macos26\";\n /** Whether to emit an Info.plist fragment alongside the Swift file */\n emitInfoPlist?: boolean;\n /** Whether to emit an entitlements fragment alongside the Swift file */\n emitEntitlements?: boolean;\n /** Whether to run swift-format on the output (requires swift-format on PATH) */\n format?: boolean;\n}\n\nexport interface CompilerOutput {\n /** Path to the generated Swift file */\n outputPath: string;\n /** The generated Swift source code */\n swiftCode: string;\n /** Info.plist fragment (if emitInfoPlist is true) */\n infoPlistFragment?: string;\n /** Entitlements fragment (if emitEntitlements is true) */\n entitlementsFragment?: string;\n /** The intermediate representation */\n ir: IRIntent;\n /** Validation diagnostics */\n diagnostics: Diagnostic[];\n}\n\n// ─── Diagnostics ─────────────────────────────────────────────────────\n\nexport type DiagnosticSeverity = \"error\" | \"warning\" | \"info\";\n\nexport interface Diagnostic {\n code: string;\n severity: DiagnosticSeverity;\n message: string;\n file?: string;\n line?: number;\n column?: number;\n suggestion?: string;\n}\n\n// ─── Param Type Registry ─────────────────────────────────────────────\n\n/**\n * Canonical set of supported param types.\n * Single source of truth — parser, SDK, and docs all derive from this.\n * To add a new type: add it to IRPrimitiveType, PARAM_TYPES, and SWIFT_TYPE_MAP.\n */\nexport const PARAM_TYPES: ReadonlySet<IRPrimitiveType> = new Set<IRPrimitiveType>([\n \"string\",\n \"int\",\n \"double\",\n \"float\",\n \"boolean\",\n \"date\",\n \"duration\",\n \"url\",\n]);\n\n/**\n * Legacy alias: \"number\" → \"int\" for backwards compatibility with v0.1.x files.\n * Parser will accept \"number\" and rewrite it to \"int\" with a deprecation warning.\n */\nexport const LEGACY_PARAM_ALIASES: Record<string, IRPrimitiveType> = {\n number: \"int\",\n};\n\n// ─── Swift Type Mapping ──────────────────────────────────────────────\n\nexport const SWIFT_TYPE_MAP: Record<IRPrimitiveType, string> = {\n string: \"String\",\n int: \"Int\",\n double: \"Double\",\n float: \"Float\",\n boolean: \"Bool\",\n date: \"Date\",\n duration: \"Measurement<UnitDuration>\",\n url: \"URL\",\n};\n\n/**\n * Convert an IRType to its Swift type string.\n */\nexport function irTypeToSwift(type: IRType): string {\n switch (type.kind) {\n case \"primitive\":\n return SWIFT_TYPE_MAP[type.value];\n case \"array\":\n return `[${irTypeToSwift(type.elementType)}]`;\n case \"optional\":\n return `${irTypeToSwift(type.innerType)}?`;\n case \"entity\":\n return type.entityName;\n case \"entityQuery\":\n return `${type.entityName}Query`;\n case \"dynamicOptions\":\n return `[DynamicOptionsResult<${irTypeToSwift(type.valueType)}>]`;\n case \"enum\":\n return type.name;\n }\n}\n","/**\n * Axint Swift Code Generator\n *\n * Transforms the IR into clean, idiomatic Swift App Intent source code.\n * Uses string templates for readability and maintainability.\n *\n * In addition to the primary Swift file, this module can emit two\n * companion fragments:\n * - an Info.plist XML fragment, listing the keys the intent requires\n * - an .entitlements XML fragment, listing the entitlements the\n * intent requires\n *\n * Both fragments are designed to be merged into the host Xcode project\n * by the user (or a future axint-link command).\n */\n\nimport type { IRIntent, IRParameter, IRType, IREntity } from \"./types.js\";\nimport { irTypeToSwift } from \"./types.js\";\n\n// ─── String Escaping ─────────────────────────────────────────────────\n\n/**\n * Escape a string for safe interpolation into Swift string literals.\n * Prevents code injection via user-controlled titles/descriptions.\n */\nexport function escapeSwiftString(s: string): string {\n return s\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, \"\\\\n\")\n .replace(/\\r/g, \"\\\\r\")\n .replace(/\\t/g, \"\\\\t\");\n}\n\n/**\n * Escape a string for safe interpolation into XML (Info.plist or\n * .entitlements). Plist XML uses the same rules as general XML.\n */\nexport function escapeXml(s: string): string {\n return s\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\n// ─── Primary Swift Generator ─────────────────────────────────────────\n\n/**\n * Generate a Swift App Intent source file from an IR intent.\n * If entities are present, they are generated first, followed by the intent.\n */\nexport function generateSwift(intent: IRIntent): string {\n const lines: string[] = [];\n\n // File header\n lines.push(`// ${intent.name}Intent.swift`);\n lines.push(`// Generated by Axint — https://github.com/agenticempire/axint`);\n lines.push(`// Do not edit manually. Re-run \\`axint compile\\` to regenerate.`);\n lines.push(``);\n lines.push(`import AppIntents`);\n lines.push(`import Foundation`);\n lines.push(``);\n\n // Generate entities before the intent\n if (intent.entities && intent.entities.length > 0) {\n for (const entity of intent.entities) {\n lines.push(generateEntity(entity));\n lines.push(``);\n lines.push(generateEntityQuery(entity));\n lines.push(``);\n }\n }\n\n // Struct declaration\n lines.push(`struct ${intent.name}Intent: AppIntent {`);\n\n // Static metadata\n lines.push(\n ` static let title: LocalizedStringResource = \"${escapeSwiftString(intent.title)}\"`\n );\n lines.push(\n ` static let description: IntentDescription = IntentDescription(\"${escapeSwiftString(intent.description)}\")`\n );\n if (intent.isDiscoverable !== undefined) {\n lines.push(` static let isDiscoverable: Bool = ${intent.isDiscoverable}`);\n }\n lines.push(``);\n\n // Parameters\n for (const param of intent.parameters) {\n lines.push(generateParameter(param));\n }\n\n if (intent.parameters.length > 0) {\n lines.push(``);\n }\n\n // Perform function with return-type aware signature\n const returnTypeSignature = generateReturnSignature(\n intent.returnType,\n intent.customResultType\n );\n lines.push(` func perform() async throws -> ${returnTypeSignature} {`);\n lines.push(` // TODO: Implement your intent logic here.`);\n\n if (intent.parameters.length > 0) {\n const paramList = intent.parameters.map((p) => `\\\\(${p.name})`).join(\", \");\n lines.push(` // Parameters available: ${paramList}`);\n }\n\n // Add intent donation if enabled\n if (intent.donateOnPerform) {\n lines.push(` `);\n lines.push(` // Donate this intent to Siri and Spotlight`);\n lines.push(` try? await IntentDonationManager.shared.donate(intent: self)`);\n }\n\n lines.push(generatePerformReturn(intent.returnType, intent.customResultType));\n lines.push(` }`);\n lines.push(`}`);\n lines.push(``);\n\n return lines.join(\"\\n\");\n}\n\n// ─── Entity Generation ───────────────────────────────────────────────\n\n/**\n * Generate an AppEntity struct from an IREntity definition.\n */\nexport function generateEntity(entity: IREntity): string {\n const lines: string[] = [];\n const propertyNames = new Set(entity.properties.map((p) => p.name));\n\n lines.push(`struct ${entity.name}: AppEntity {`);\n lines.push(` static var defaultQuery = ${entity.name}Query()`);\n lines.push(``);\n\n // Apple requires AppEntity to have an id property\n const hasId = propertyNames.has(\"id\");\n if (!hasId) {\n lines.push(` var id: String`);\n }\n\n // Properties\n for (const prop of entity.properties) {\n const swiftType = irTypeToSwift(prop.type);\n lines.push(` var ${prop.name}: ${swiftType}`);\n }\n\n lines.push(``);\n\n // Type display representation\n lines.push(\n ` static let typeDisplayRepresentation: TypeDisplayRepresentation = TypeDisplayRepresentation(`\n );\n lines.push(\n ` name: LocalizedStringResource(\"${escapeSwiftString(entity.name)}\")`\n );\n lines.push(` )`);\n lines.push(``);\n\n // Display representation computed property — title/subtitle are property\n // name references, so we emit Swift string interpolation \\(propName)\n lines.push(` var displayRepresentation: DisplayRepresentation {`);\n lines.push(` DisplayRepresentation(`);\n lines.push(\n ` title: \"\\\\(${entity.displayRepresentation.title})\"${entity.displayRepresentation.subtitle || entity.displayRepresentation.image ? \",\" : \"\"}`\n );\n if (entity.displayRepresentation.subtitle) {\n const hasImage = !!entity.displayRepresentation.image;\n lines.push(\n ` subtitle: \"\\\\(${entity.displayRepresentation.subtitle})\"${hasImage ? \",\" : \"\"}`\n );\n }\n if (entity.displayRepresentation.image) {\n lines.push(\n ` image: .init(systemName: \"${escapeSwiftString(entity.displayRepresentation.image)}\")`\n );\n }\n lines.push(` )`);\n lines.push(` }`);\n\n lines.push(`}`);\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Generate an EntityQuery conformance struct based on the entity's query type.\n */\nexport function generateEntityQuery(entity: IREntity): string {\n const lines: string[] = [];\n const queryType = entity.queryType;\n\n lines.push(`struct ${entity.name}Query: EntityQuery {`);\n lines.push(\n ` func entities(for identifiers: [${entity.name}.ID]) async throws -> [${entity.name}] {`\n );\n lines.push(` // TODO: Fetch entities by IDs`);\n lines.push(` return []`);\n lines.push(` }`);\n lines.push(``);\n\n // Generate appropriate query method based on queryType\n if (queryType === \"all\") {\n lines.push(` func allEntities() async throws -> [${entity.name}] {`);\n lines.push(` // TODO: Return all entities`);\n lines.push(` return []`);\n lines.push(` }`);\n } else if (queryType === \"id\") {\n // ID-based query is handled by entities(for:) above\n lines.push(` // ID-based query is provided by the entities(for:) method above`);\n } else if (queryType === \"string\") {\n lines.push(\n ` func entities(matching string: String) async throws -> [${entity.name}] {`\n );\n lines.push(` // TODO: Search entities by string`);\n lines.push(` return []`);\n lines.push(` }`);\n } else if (queryType === \"property\") {\n // Property-based query requires additional configuration\n lines.push(` // Property-based query: implement using EntityPropertyQuery`);\n lines.push(` // Example: property.where { \\\\$0.status == \"active\" }`);\n }\n\n lines.push(`}`);\n\n return lines.join(\"\\n\");\n}\n\n// ─── Info.plist Fragment Generator ───────────────────────────────────\n\n/**\n * Generate an Info.plist XML fragment from the intent's declared keys.\n * Returns `undefined` if the intent declares no Info.plist keys.\n *\n * The fragment is a bare `<dict>`-less sequence of `<key>…</key>` /\n * `<string>…</string>` pairs, ready to be merged into an existing\n * Info.plist. A commented header identifies the source intent so users\n * can audit provenance.\n */\nexport function generateInfoPlistFragment(intent: IRIntent): string | undefined {\n const keys = intent.infoPlistKeys;\n if (!keys || Object.keys(keys).length === 0) return undefined;\n\n const lines: string[] = [];\n lines.push(`<?xml version=\"1.0\" encoding=\"UTF-8\"?>`);\n lines.push(`<!-- Info.plist fragment generated by Axint for ${intent.name}Intent -->`);\n lines.push(`<!-- Merge these keys into your app's Info.plist. -->`);\n lines.push(`<plist version=\"1.0\">`);\n lines.push(`<dict>`);\n for (const [key, desc] of Object.entries(keys)) {\n lines.push(` <key>${escapeXml(key)}</key>`);\n lines.push(` <string>${escapeXml(desc)}</string>`);\n }\n lines.push(`</dict>`);\n lines.push(`</plist>`);\n lines.push(``);\n\n return lines.join(\"\\n\");\n}\n\n// ─── Entitlements Fragment Generator ─────────────────────────────────\n\n/**\n * Generate a `.entitlements` XML fragment from the intent's declared\n * entitlements. Returns `undefined` if the intent declares none.\n *\n * Axint only knows the entitlement identifiers, so all entries are\n * emitted as `<true/>` boolean entitlements. If an entitlement requires\n * a typed value (string, array), users must edit the fragment after\n * generation — a TODO comment is emitted to flag this.\n */\nexport function generateEntitlementsFragment(intent: IRIntent): string | undefined {\n const ents = intent.entitlements;\n if (!ents || ents.length === 0) return undefined;\n\n const lines: string[] = [];\n lines.push(`<?xml version=\"1.0\" encoding=\"UTF-8\"?>`);\n lines.push(\n `<!-- Entitlements fragment generated by Axint for ${intent.name}Intent -->`\n );\n lines.push(`<!-- Merge these into your target's .entitlements file. -->`);\n lines.push(`<!-- Note: entitlements requiring typed values (string/array) -->`);\n lines.push(`<!-- need manual adjustment — defaults below are boolean true. -->`);\n lines.push(\n `<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">`\n );\n lines.push(`<plist version=\"1.0\">`);\n lines.push(`<dict>`);\n for (const ent of ents) {\n lines.push(` <key>${escapeXml(ent)}</key>`);\n lines.push(` <true/>`);\n }\n lines.push(`</dict>`);\n lines.push(`</plist>`);\n lines.push(``);\n\n return lines.join(\"\\n\");\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────\n\nfunction generateParameter(param: IRParameter): string {\n const swiftType = irTypeToSwift(param.type);\n const lines: string[] = [];\n\n // Build @Parameter decorator\n const attrs: string[] = [];\n attrs.push(`title: \"${escapeSwiftString(param.title)}\"`);\n if (param.description) {\n attrs.push(`description: \"${escapeSwiftString(param.description)}\"`);\n }\n\n const decorator = ` @Parameter(${attrs.join(\", \")})`;\n lines.push(decorator);\n\n // Property declaration\n if (param.defaultValue !== undefined) {\n const defaultStr = formatSwiftDefault(param.defaultValue, param.type);\n lines.push(` var ${param.name}: ${swiftType} = ${defaultStr}`);\n } else {\n lines.push(` var ${param.name}: ${swiftType}`);\n }\n\n lines.push(``);\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Choose the Swift return-type signature for the generated perform().\n * We map the inferred IR return type to an App Intents `IntentResult`\n * shape. For primitive return types we use `some ReturnsValue<T>`;\n * for custom result types we use the custom type; otherwise we fall\n * back to `some IntentResult`.\n */\nfunction generateReturnSignature(type: IRType, customResultType?: string): string {\n if (customResultType) {\n return customResultType;\n }\n if (type.kind === \"primitive\") {\n const swift = irTypeToSwift(type);\n return `some IntentResult & ReturnsValue<${swift}>`;\n }\n if (type.kind === \"optional\" && type.innerType.kind === \"primitive\") {\n const swift = irTypeToSwift(type.innerType);\n return `some IntentResult & ReturnsValue<${swift}>`;\n }\n return `some IntentResult`;\n}\n\n/**\n * Emit the `return .result(...)` line that matches the return signature\n * produced by `generateReturnSignature`. When the return type is a\n * primitive we return a well-typed default placeholder the user can\n * replace; otherwise we emit a plain `.result()`.\n */\nfunction generatePerformReturn(type: IRType, customResultType?: string): string {\n const indent = \" \";\n if (customResultType) {\n // For custom result types, the user must provide the implementation\n return `${indent}// TODO: Return a ${customResultType} instance`;\n }\n if (type.kind === \"primitive\") {\n return `${indent}return .result(value: ${defaultLiteralFor(type.value)})`;\n }\n if (type.kind === \"optional\" && type.innerType.kind === \"primitive\") {\n return `${indent}return .result(value: ${defaultLiteralFor(type.innerType.value)})`;\n }\n return `${indent}return .result()`;\n}\n\nfunction defaultLiteralFor(primitive: string): string {\n switch (primitive) {\n case \"string\":\n return `\"\"`;\n case \"int\":\n return `0`;\n case \"double\":\n return `0.0`;\n case \"float\":\n return `Float(0)`;\n case \"boolean\":\n return `false`;\n case \"date\":\n return `Date()`;\n case \"duration\":\n return `Measurement<UnitDuration>(value: 0, unit: .seconds)`;\n case \"url\":\n return `URL(string: \"about:blank\")!`;\n default:\n return `\"\"`;\n }\n}\n\nfunction formatSwiftDefault(value: unknown, _type: IRType): string {\n if (typeof value === \"string\") return `\"${escapeSwiftString(value)}\"`;\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) return `0`; // Guard against NaN/Infinity\n return `${value}`;\n }\n if (typeof value === \"boolean\") return value ? \"true\" : \"false\";\n return `\"${escapeSwiftString(String(value))}\"`; // Safe fallback\n}\n","/**\n * Axint Validator\n *\n * Validates generated Swift App Intent code against Apple's API surface.\n * Returns diagnostics with error codes, locations, and fix suggestions.\n */\n\nimport type { Diagnostic, IRIntent, IREntity } from \"./types.js\";\n\n/** Apple-recommended maximum parameters per intent for usability */\nconst MAX_PARAMETERS = 10;\n\n/** Maximum title length before Siri may truncate display */\nconst MAX_TITLE_LENGTH = 60;\n\n/**\n * Validate an IR intent for App Intents framework compliance.\n */\nexport function validateIntent(intent: IRIntent): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n // Rule: Intent name must be PascalCase and non-empty\n if (!intent.name || !/^[A-Z][a-zA-Z0-9]*$/.test(intent.name)) {\n diagnostics.push({\n code: \"AX100\",\n severity: \"error\",\n message: `Intent name \"${intent.name}\" must be PascalCase (e.g., \"CreateEvent\")`,\n file: intent.sourceFile,\n suggestion: `Rename to \"${toPascalCase(intent.name)}\"`,\n });\n }\n\n // Rule: Title must not be empty\n if (!intent.title || intent.title.trim().length === 0) {\n diagnostics.push({\n code: \"AX101\",\n severity: \"error\",\n message: \"Intent title must not be empty\",\n file: intent.sourceFile,\n suggestion: \"Add a human-readable title for Siri and Shortcuts display\",\n });\n }\n\n // Rule: Description must not be empty\n if (!intent.description || intent.description.trim().length === 0) {\n diagnostics.push({\n code: \"AX102\",\n severity: \"error\",\n message: \"Intent description must not be empty\",\n file: intent.sourceFile,\n suggestion: \"Add a description explaining what this intent does\",\n });\n }\n\n // Rule: Parameter names must be valid Swift identifiers\n for (const param of intent.parameters) {\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(param.name)) {\n diagnostics.push({\n code: \"AX103\",\n severity: \"error\",\n message: `Parameter name \"${param.name}\" is not a valid Swift identifier`,\n file: intent.sourceFile,\n suggestion: `Rename to \"${param.name.replace(/[^a-zA-Z0-9_]/g, \"_\")}\"`,\n });\n }\n\n // Rule: Parameter description should not be empty\n if (!param.description || param.description.trim().length === 0) {\n diagnostics.push({\n code: \"AX104\",\n severity: \"warning\",\n message: `Parameter \"${param.name}\" has no description — Siri will display it without context`,\n file: intent.sourceFile,\n suggestion: \"Add a description for better Siri/Shortcuts display\",\n });\n }\n }\n\n // Rule: Max 10 parameters per intent (App Intents recommendation)\n if (intent.parameters.length > MAX_PARAMETERS) {\n diagnostics.push({\n code: \"AX105\",\n severity: \"warning\",\n message: `Intent has ${intent.parameters.length} parameters. Apple recommends ${MAX_PARAMETERS} or fewer for usability.`,\n file: intent.sourceFile,\n suggestion:\n \"Consider splitting into multiple intents or grouping parameters into an entity\",\n });\n }\n\n // Rule: Title should not exceed 60 characters (Siri display constraint)\n if (intent.title && intent.title.length > MAX_TITLE_LENGTH) {\n diagnostics.push({\n code: \"AX106\",\n severity: \"warning\",\n message: `Intent title is ${intent.title.length} characters. Siri display may truncate titles over ${MAX_TITLE_LENGTH} characters.`,\n file: intent.sourceFile,\n });\n }\n\n // Rule: Parameter names must be unique within an intent\n const seen = new Set<string>();\n for (const param of intent.parameters) {\n if (seen.has(param.name)) {\n diagnostics.push({\n code: \"AX107\",\n severity: \"error\",\n message: `Duplicate parameter name \"${param.name}\"`,\n file: intent.sourceFile,\n suggestion: \"Each parameter in a single intent must have a unique name\",\n });\n }\n seen.add(param.name);\n }\n\n // Rule: Entitlement strings must look like reverse-DNS identifiers\n for (const ent of intent.entitlements ?? []) {\n if (!/^[a-zA-Z0-9._-]+$/.test(ent) || !ent.includes(\".\")) {\n diagnostics.push({\n code: \"AX108\",\n severity: \"warning\",\n message: `Entitlement \"${ent}\" does not look like a valid reverse-DNS identifier`,\n file: intent.sourceFile,\n suggestion:\n 'Use reverse-DNS, e.g., \"com.apple.developer.siri\" or \"com.apple.security.app-sandbox\"',\n });\n }\n }\n\n // Rule: Info.plist keys must start with \"NS\" or other known prefixes\n for (const key of Object.keys(intent.infoPlistKeys ?? {})) {\n if (!/^(NS|UI|LS|CF|CA|CK)[A-Za-z0-9]+$/.test(key)) {\n diagnostics.push({\n code: \"AX109\",\n severity: \"warning\",\n message: `Info.plist key \"${key}\" does not match Apple's usual naming conventions`,\n file: intent.sourceFile,\n suggestion:\n 'Apple keys generally start with \"NS\" (e.g., \"NSCalendarsUsageDescription\")',\n });\n }\n }\n\n // Validate all entities\n if (intent.entities) {\n for (const entity of intent.entities) {\n diagnostics.push(...validateEntity(entity, intent.sourceFile));\n }\n }\n\n return diagnostics;\n}\n\n/**\n * Validate an IREntity for App Intents framework compliance.\n */\nexport function validateEntity(entity: IREntity, sourceFile: string): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n // Rule AX110: Entity name must be PascalCase\n if (!entity.name || !/^[A-Z][a-zA-Z0-9]*$/.test(entity.name)) {\n diagnostics.push({\n code: \"AX110\",\n severity: \"error\",\n message: `Entity name \"${entity.name}\" must be PascalCase (e.g., \"Task\", \"Playlist\")`,\n file: sourceFile,\n suggestion: `Rename to \"${toPascalCase(entity.name)}\"`,\n });\n }\n\n // Rule AX111: Entity must have at least one property\n if (entity.properties.length === 0) {\n diagnostics.push({\n code: \"AX111\",\n severity: \"error\",\n message: `Entity \"${entity.name}\" must have at least one property`,\n file: sourceFile,\n suggestion: \"Add properties to define the entity's structure\",\n });\n }\n\n // Rule AX112: Display title must reference an existing property\n const titleProp = entity.displayRepresentation.title;\n const propertyNames = new Set(entity.properties.map((p) => p.name));\n if (titleProp && !propertyNames.has(titleProp)) {\n diagnostics.push({\n code: \"AX112\",\n severity: \"warning\",\n message: `Display title \"${titleProp}\" does not reference an existing property`,\n file: sourceFile,\n suggestion: `Available properties: ${[...propertyNames].join(\", \")}`,\n });\n }\n\n // Rule AX113: Query type must be valid\n const validQueryTypes = [\"all\", \"id\", \"string\", \"property\"];\n if (!validQueryTypes.includes(entity.queryType)) {\n diagnostics.push({\n code: \"AX113\",\n severity: \"error\",\n message: `Entity query type \"${entity.queryType}\" is not valid`,\n file: sourceFile,\n suggestion: `Use one of: ${validQueryTypes.join(\", \")}`,\n });\n }\n\n return diagnostics;\n}\n\n/**\n * Validate generated Swift source code for basic correctness.\n */\nexport function validateSwiftSource(swift: string): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n // Check for required import\n if (!swift.includes(\"import AppIntents\")) {\n diagnostics.push({\n code: \"AX200\",\n severity: \"error\",\n message: 'Generated Swift is missing \"import AppIntents\"',\n });\n }\n\n // Check for AppIntent conformance\n if (!swift.includes(\": AppIntent\")) {\n diagnostics.push({\n code: \"AX201\",\n severity: \"error\",\n message: \"Generated struct does not conform to AppIntent protocol\",\n });\n }\n\n // Check for perform function\n if (!swift.includes(\"func perform()\")) {\n diagnostics.push({\n code: \"AX202\",\n severity: \"error\",\n message: \"Generated struct is missing the perform() function\",\n });\n }\n\n return diagnostics;\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────\n\nfunction toPascalCase(s: string): string {\n if (!s) return \"UnnamedIntent\";\n return s\n .replace(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : \"\"))\n .replace(/^(.)/, (c) => c.toUpperCase());\n}\n","/**\n * Axint Eject Module\n *\n * Generates standalone Swift code that has no dependency on Axint.\n * This is useful for teams that want to verify there's no vendor lock-in\n * or for distributing intents without the compilation layer.\n *\n * The eject process:\n * 1. Compiles the TypeScript intent using the standard pipeline\n * 2. Transforms the output to remove Axint markers\n * 3. Optionally generates XCTest stubs\n * 4. Emits all files (Swift, plist, entitlements, test)\n */\n\nimport { compileSource } from \"./compiler.js\";\nimport type { IRIntent } from \"./types.js\";\n\n// ─── Public Interface ────────────────────────────────────────────────\n\nexport interface EjectOptions {\n /** Output directory for ejected files (defaults to \".\") */\n outDir?: string;\n /** Generate a basic XCTest file for the intent */\n includeTests?: boolean;\n /** Format output with swift-format (requires swift-format on PATH) */\n format?: boolean;\n}\n\nexport interface EjectResult {\n /** The primary Swift file */\n swiftFile: {\n path: string;\n content: string;\n };\n /** Optional Info.plist fragment */\n infoPlist?: {\n path: string;\n content: string;\n };\n /** Optional entitlements fragment */\n entitlements?: {\n path: string;\n content: string;\n };\n /** Optional XCTest file */\n testFile?: {\n path: string;\n content: string;\n };\n}\n\n// ─── Main Eject Function ────────────────────────────────────────────\n\n/**\n * Eject an intent from Axint, producing standalone Swift code with no\n * vendor lock-in. The resulting Swift code is production-ready and can\n * be committed directly to version control.\n *\n * @param source The TypeScript intent source\n * @param fileName Display name for diagnostics (e.g., \"intent.ts\")\n * @param options Eject options (outDir, includeTests, format)\n * @returns Ejected files\n */\nexport function ejectIntent(\n source: string,\n fileName: string,\n options: EjectOptions = {}\n): EjectResult {\n // 1. Compile using the standard pipeline\n const compileResult = compileSource(source, fileName, {\n validate: true,\n emitInfoPlist: true,\n emitEntitlements: true,\n });\n\n if (!compileResult.success || !compileResult.output) {\n throw new Error(\n `Compilation failed: ${compileResult.diagnostics\n .filter((d) => d.severity === \"error\")\n .map((d) => d.message)\n .join(\"; \")}`\n );\n }\n\n const { ir, swiftCode, infoPlistFragment, entitlementsFragment } =\n compileResult.output;\n const outDir = options.outDir ?? \".\";\n\n // 2. Transform Swift to remove Axint markers\n const ejectedSwift = transformSwiftForEject(swiftCode, ir);\n\n // 3. Construct file paths\n const intentFileName = `${ir.name}Intent.swift`;\n const swiftPath = `${outDir}/${intentFileName}`;\n const plistPath = infoPlistFragment\n ? `${outDir}/${ir.name}Intent.plist.fragment.xml`\n : null;\n const entitlementsPath = entitlementsFragment\n ? `${outDir}/${ir.name}Intent.entitlements.fragment.xml`\n : null;\n const testPath = options.includeTests\n ? `${outDir}/${ir.name}IntentTests.swift`\n : null;\n\n // 4. Build result object\n const result: EjectResult = {\n swiftFile: {\n path: swiftPath,\n content: ejectedSwift,\n },\n };\n\n if (infoPlistFragment && plistPath) {\n result.infoPlist = {\n path: plistPath,\n content: infoPlistFragment,\n };\n }\n\n if (entitlementsFragment && entitlementsPath) {\n result.entitlements = {\n path: entitlementsPath,\n content: entitlementsFragment,\n };\n }\n\n if (options.includeTests && testPath) {\n result.testFile = {\n path: testPath,\n content: generateTestFile(ir),\n };\n }\n\n return result;\n}\n\n// ─── Swift Transformation ───────────────────────────────────────────\n\n/**\n * Transform generated Swift code to be \"ejected\" — remove Axint markers,\n * update the header comment, and enhance the TODO placeholder.\n */\nfunction transformSwiftForEject(swiftCode: string, ir: IRIntent): string {\n const lines = swiftCode.split(\"\\n\");\n const result: string[] = [];\n\n let inHeader = true;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n\n // Replace header comment\n if (inHeader && line.startsWith(\"// \")) {\n if (i === 0) {\n // First line: replace with intent name\n result.push(`// ${ir.name}Intent.swift`);\n } else if (line.includes(\"Generated by Axint\")) {\n // Skip the Axint header\n result.push(\n `// Originally generated by Axint (https://github.com/agenticempire/axint)`\n );\n } else if (line.includes(\"Do not edit manually\")) {\n // Skip the regeneration instruction\n } else {\n result.push(line);\n }\n } else if (line === \"\") {\n inHeader = false;\n result.push(line);\n } else {\n inHeader = false;\n\n // Replace the TODO comment with a more helpful one\n if (line.includes(\"// TODO: Implement your intent logic here.\")) {\n result.push(` // TODO: Implement your intent logic here.`);\n result.push(` //`);\n result.push(\n ` // For more information about App Intents, see:`\n );\n result.push(\n ` // https://developer.apple.com/documentation/appintents`\n );\n } else {\n result.push(line);\n }\n }\n }\n\n return result.join(\"\\n\");\n}\n\n// ─── Test File Generation ───────────────────────────────────────────\n\n/**\n * Generate a basic XCTest file for the intent.\n * This provides a scaffold that users can fill in with their own tests.\n */\nfunction generateTestFile(ir: IRIntent): string {\n const lines: string[] = [];\n\n lines.push(`// ${ir.name}IntentTests.swift`);\n lines.push(`// Ejected from Axint`);\n lines.push(``);\n lines.push(`import XCTest`);\n lines.push(`import AppIntents`);\n lines.push(``);\n lines.push(`final class ${ir.name}IntentTests: XCTestCase {`);\n lines.push(``);\n lines.push(` func testIntentInitialization() throws {`);\n lines.push(` let intent = ${ir.name}Intent()`);\n lines.push(` XCTAssertEqual(${ir.name}Intent.title.stringValue, \"${ir.title}\")`);\n lines.push(` }`);\n lines.push(``);\n lines.push(` func testIntentPerform() async throws {`);\n lines.push(` let intent = ${ir.name}Intent()`);\n lines.push(` // TODO: Set up intent parameters and test perform()`);\n lines.push(` // let result = try await intent.perform()`);\n lines.push(` // XCTAssertNotNil(result)`);\n lines.push(` }`);\n lines.push(``);\n lines.push(`}`);\n lines.push(``);\n\n return lines.join(\"\\n\");\n}\n","/**\n * axint — Decorators and types for defining Apple App Intents\n *\n * The canonical way to define an App Intent in TypeScript. The axint\n * compiler parses files written against this SDK and emits a native\n * Swift `AppIntent` struct (plus optional Info.plist and entitlements\n * fragments) suitable for dropping into an Xcode project.\n *\n * @example\n * ```typescript\n * import { defineIntent, param } from \"@axintai/compiler\";\n *\n * export default defineIntent({\n * name: \"CreateEvent\",\n * title: \"Create Calendar Event\",\n * description: \"Creates a new event in the user's calendar\",\n * domain: \"productivity\",\n * entitlements: [\"com.apple.developer.siri\"],\n * infoPlistKeys: {\n * NSCalendarsUsageDescription: \"Axint needs calendar access to create events.\",\n * },\n * params: {\n * title: param.string(\"Event title\"),\n * date: param.date(\"Event date\"),\n * durationMinutes: param.int(\"Duration in minutes\", { default: 30 }),\n * allDay: param.boolean(\"Is all-day event\", { required: false }),\n * },\n * perform: async ({ title, date }) => {\n * return { success: true, id: \"evt_123\" };\n * },\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// ─── Shared Config ───────────────────────────────────────────────────\n\n/** Configuration for a single parameter. */\nexport interface ParamConfig {\n /** Display name for this parameter (auto-generated from field name if omitted). */\n title?: string;\n /** Human-readable description shown in Siri/Shortcuts. */\n description: string;\n /** Default value if the user doesn't provide one. */\n default?: unknown;\n /**\n * Whether this parameter is required. Defaults to `true`.\n * Set to `false` to make the Swift property optional (`Type?`).\n */\n required?: boolean;\n}\n\ntype ParamFactory<T extends string> = (\n description: string,\n config?: Partial<ParamConfig>\n) => { type: T; description: string } & Partial<ParamConfig>;\n\nfunction make<T extends string>(type: T): ParamFactory<T> {\n return (description, config) => ({\n type,\n description,\n ...config,\n });\n}\n\n// ─── Parameter Type Helpers ──────────────────────────────────────────\n\n/**\n * Parameter type helpers for defining intent parameters.\n *\n * Each helper maps directly to a Swift App Intents type:\n *\n * | Helper | Swift type |\n * |-------------------|-------------------------------|\n * | `param.string` | `String` |\n * | `param.int` | `Int` |\n * | `param.double` | `Double` |\n * | `param.float` | `Float` |\n * | `param.boolean` | `Bool` |\n * | `param.date` | `Date` |\n * | `param.duration` | `Measurement<UnitDuration>` |\n * | `param.url` | `URL` |\n * | `param.number` * | `Int` *(deprecated alias)* |\n *\n * @example\n * ```typescript\n * params: {\n * name: param.string(\"User's name\"),\n * age: param.int(\"Age in years\"),\n * height: param.double(\"Height in meters\"),\n * notify: param.boolean(\"Send notification\", { required: false }),\n * when: param.date(\"Scheduled date\"),\n * length: param.duration(\"How long\"),\n * link: param.url(\"Resource URL\"),\n * }\n * ```\n */\nexport const param = {\n /** String parameter → Swift `String` */\n string: make(\"string\"),\n /** 64-bit signed integer → Swift `Int` */\n int: make(\"int\"),\n /** Double-precision float → Swift `Double` */\n double: make(\"double\"),\n /** Single-precision float → Swift `Float` */\n float: make(\"float\"),\n /** Boolean parameter → Swift `Bool` */\n boolean: make(\"boolean\"),\n /** Date parameter → Swift `Date` */\n date: make(\"date\"),\n /** Duration parameter → Swift `Measurement<UnitDuration>` */\n duration: make(\"duration\"),\n /** URL parameter → Swift `URL` */\n url: make(\"url\"),\n /**\n * @deprecated Use `param.int` (or `param.double` / `param.float`) for\n * explicit Swift numeric fidelity. `param.number` is kept as an alias\n * for `param.int` to preserve v0.1.x compatibility and will be removed\n * in v1.0.0.\n */\n number: make(\"number\"),\n\n /**\n * Entity reference parameter. The entity name must match a\n * `defineEntity()` call in the same file or project.\n */\n entity: (entityName: string, description: string, config?: Partial<ParamConfig>) => ({\n type: \"entity\" as const,\n entityName,\n description,\n ...config,\n }),\n\n /**\n * Parameter with dynamic option suggestions provided at runtime\n * by a DynamicOptionsProvider. The `providerName` maps to a\n * generated Swift `DynamicOptionsProvider` struct.\n */\n dynamicOptions: (\n providerName: string,\n innerParam: ReturnType<ParamFactory<string>>\n ) => {\n const { type: innerType, description, ...rest } = innerParam;\n return {\n type: \"dynamicOptions\" as const,\n providerName,\n innerType,\n description,\n ...rest,\n };\n },\n};\n\n// ─── Intent Definition ───────────────────────────────────────────────\n\n/** The full intent definition including name, metadata, params, and perform function. */\nexport interface IntentDefinition<\n TParams extends Record<string, ReturnType<(typeof param)[keyof typeof param]>>,\n> {\n /** PascalCase name for the generated Swift struct (e.g., \"CreateEvent\"). */\n name: string;\n /** Display name shown in Siri and Shortcuts. */\n title: string;\n /** Human-readable description of what this intent does. */\n description: string;\n /**\n * Apple App Intent Domain for categorization.\n * Common values: \"messaging\", \"productivity\", \"finance\", \"health\",\n * \"commerce\", \"media\", \"navigation\", \"smart-home\"\n */\n domain?: string;\n /** Siri/Shortcuts category for discoverability. */\n category?: string;\n /**\n * Entitlements required by this intent.\n * Example: `[\"com.apple.developer.siri\", \"com.apple.developer.healthkit\"]`\n * The compiler can emit a matching `.entitlements` fragment.\n */\n entitlements?: string[];\n /**\n * Info.plist keys required by this intent, mapped to their usage\n * description strings.\n * Example: `{ NSCalendarsUsageDescription: \"We need calendar access\" }`\n */\n infoPlistKeys?: Record<string, string>;\n /** Whether the intent should be exposed to Spotlight indexing. */\n isDiscoverable?: boolean;\n /** Parameter definitions using `param.*` helpers. */\n params: TParams;\n /**\n * The perform function (used for local testing/type-checking).\n * Note: The compiler generates a placeholder `perform()` in Swift —\n * you'll implement the actual logic in your Xcode project.\n */\n perform: (params: {\n [K in keyof TParams]: unknown;\n }) => Promise<unknown>;\n}\n\n/**\n * Define an Apple App Intent for compilation to Swift.\n *\n * This is the main entry point for the Axint SDK. The returned definition\n * is parsed by the Axint compiler and transformed into a native Swift\n * `AppIntent` struct.\n *\n * @param config - The intent definition\n * @returns The same config (identity function for type inference)\n *\n * @example\n * ```typescript\n * export default defineIntent({\n * name: \"SendMessage\",\n * title: \"Send Message\",\n * description: \"Sends a message to a contact\",\n * domain: \"messaging\",\n * params: {\n * recipient: param.string(\"Who to send the message to\"),\n * body: param.string(\"The message content\"),\n * },\n * perform: async ({ recipient, body }) => {\n * return { sent: true };\n * },\n * });\n * ```\n */\nexport function defineIntent<\n TParams extends Record<string, ReturnType<(typeof param)[keyof typeof param]>>,\n>(config: IntentDefinition<TParams>): IntentDefinition<TParams> {\n return config;\n}\n\n// ─── Entity Definition ──────────────────────────────────────────────\n\n/** Display representation mapping for an entity. */\nexport interface EntityDisplay {\n title: string;\n subtitle?: string;\n image?: string;\n}\n\n/** The full entity definition for generating an AppEntity struct. */\nexport interface EntityDefinition {\n /** PascalCase name for the generated Swift struct. */\n name: string;\n /** How the entity is displayed in Siri/Shortcuts. */\n display: EntityDisplay;\n /** Entity properties using `param.*` helpers. */\n properties: Record<string, ReturnType<(typeof param)[keyof typeof param]>>;\n /** Query type: \"string\" for StringQuery, \"property\" for PropertyQuery. */\n query?: \"string\" | \"property\";\n}\n\n/**\n * Define an Apple AppEntity for compilation to Swift.\n *\n * Generates a Swift `AppEntity` struct with `EntityQuery` conformance,\n * display representation, and typed properties.\n *\n * @param config - The entity definition\n * @returns The same config (identity function for type inference)\n */\nexport function defineEntity(config: EntityDefinition): EntityDefinition {\n return config;\n}\n"],"mappings":";AAaA,SAAS,oBAAoB;;;ACE7B,OAAO,QAAQ;;;AC2HR,IAAM,cAA4C,oBAAI,IAAqB;AAAA,EAChF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,uBAAwD;AAAA,EACnE,QAAQ;AACV;AAIO,IAAM,iBAAkD;AAAA,EAC7D,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,UAAU;AAAA,EACV,KAAK;AACP;AAKO,SAAS,cAAc,MAAsB;AAClD,UAAQ,KAAK,MAAM;AAAA,IACjB,KAAK;AACH,aAAO,eAAe,KAAK,KAAK;AAAA,IAClC,KAAK;AACH,aAAO,IAAI,cAAc,KAAK,WAAW,CAAC;AAAA,IAC5C,KAAK;AACH,aAAO,GAAG,cAAc,KAAK,SAAS,CAAC;AAAA,IACzC,KAAK;AACH,aAAO,KAAK;AAAA,IACd,KAAK;AACH,aAAO,GAAG,KAAK,UAAU;AAAA,IAC3B,KAAK;AACH,aAAO,yBAAyB,cAAc,KAAK,SAAS,CAAC;AAAA,IAC/D,KAAK;AACH,aAAO,KAAK;AAAA,EAChB;AACF;;;ADhKO,SAAS,kBACd,QACA,WAAmB,WACT;AACV,QAAM,aAAa,GAAG;AAAA,IACpB;AAAA,IACA;AAAA,IACA,GAAG,aAAa;AAAA,IAChB;AAAA;AAAA,IACA,GAAG,WAAW;AAAA,EAChB;AAGA,QAAM,WAAW,sBAAsB,UAAU,EAAE;AAAA,IAAI,CAAC,SACtD,sBAAsB,MAAM,UAAU,UAAU;AAAA,EAClD;AAEA,QAAM,mBAAmB,qBAAqB,UAAU;AACxD,MAAI,CAAC,kBAAkB;AACrB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C,QAAM,KAAK,OAAO;AAClB,QAAM,KAAK,EAAE;AACb,QAAM,KAAK,GAAG;AACd,QAAM,KAAK,EAAE;AAEb,SAAO,MAAM,KAAK,IAAI;AACxB;;;ACtKA,SAAS,KAAuB,MAA0B;AACxD,SAAO,CAAC,aAAa,YAAY;AAAA,IAC/B;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AACF;AAkCO,IAAM,QAAQ;AAAA;AAAA,EAEnB,QAAQ,KAAK,QAAQ;AAAA;AAAA,EAErB,KAAK,KAAK,KAAK;AAAA;AAAA,EAEf,QAAQ,KAAK,QAAQ;AAAA;AAAA,EAErB,OAAO,KAAK,OAAO;AAAA;AAAA,EAEnB,SAAS,KAAK,SAAS;AAAA;AAAA,EAEvB,MAAM,KAAK,MAAM;AAAA;AAAA,EAEjB,UAAU,KAAK,UAAU;AAAA;AAAA,EAEzB,KAAK,KAAK,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOf,QAAQ,KAAK,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMrB,QAAQ,CAAC,YAAoB,aAAqB,YAAmC;AAAA,IACnF,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,gBAAgB,CACd,cACA,eACG;AACH,UAAM,EAAE,MAAM,WAAW,aAAa,GAAG,KAAK,IAAI;AAClD,WAAO;AAAA,MACL,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EACF;AACF;AA2EO,SAAS,aAEd,QAA8D;AAC9D,SAAO;AACT;AAgCO,SAAS,aAAa,QAA4C;AACvE,SAAO;AACT;","names":["param","param","param"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/compiler.ts","../../src/core/parser.ts","../../src/core/types.ts","../../src/core/generator.ts","../../src/core/validator.ts","../../src/core/format.ts","../../src/core/eject.ts","../../src/sdk/index.ts"],"sourcesContent":["/**\n * Axint Compiler\n *\n * Orchestrates the full compilation pipeline:\n * 1. Parse TypeScript intent definition → IR\n * 2. Validate IR against App Intents constraints\n * 3. Generate Swift source code\n * 4. Validate generated Swift\n * 5. Optionally emit Info.plist and entitlements fragments\n *\n * This is the main entry point for the compilation process.\n */\n\nimport { readFileSync } from \"node:fs\";\nimport { parseIntentSource, ParserError } from \"./parser.js\";\nimport {\n generateSwift,\n generateInfoPlistFragment,\n generateEntitlementsFragment,\n} from \"./generator.js\";\nimport { validateIntent, validateSwiftSource } from \"./validator.js\";\nimport type {\n CompilerOutput,\n CompilerOptions,\n Diagnostic,\n IRIntent,\n IRType,\n IRParameter,\n IRPrimitiveType,\n} from \"./types.js\";\n\nexport interface CompileResult {\n success: boolean;\n output?: CompilerOutput;\n diagnostics: Diagnostic[];\n}\n\n/**\n * Compile a TypeScript intent definition file into Swift.\n */\nexport function compileFile(\n filePath: string,\n options: Partial<CompilerOptions> = {}\n): CompileResult {\n // 1. Read source\n let source: string;\n try {\n source = readFileSync(filePath, \"utf-8\");\n } catch (_err) {\n return {\n success: false,\n diagnostics: [\n {\n code: \"AX000\",\n severity: \"error\",\n message: `Cannot read file: ${filePath}`,\n file: filePath,\n },\n ],\n };\n }\n\n return compileSource(source, filePath, options);\n}\n\n/**\n * Compile a TypeScript source string directly (no file I/O).\n * Useful for MCP server and testing.\n */\nexport function compileSource(\n source: string,\n fileName: string = \"<stdin>\",\n options: Partial<CompilerOptions> = {}\n): CompileResult {\n // 1. Parse → IR (catch ParserError as a diagnostic so the caller\n // sees a clean error list instead of an uncaught exception)\n let ir;\n try {\n ir = parseIntentSource(source, fileName);\n } catch (err) {\n if (err instanceof ParserError) {\n return {\n success: false,\n diagnostics: [\n {\n code: err.code,\n severity: \"error\",\n message: err.message,\n file: err.file,\n line: err.line,\n suggestion: err.suggestion,\n },\n ],\n };\n }\n throw err;\n }\n\n return compileFromIR(ir, options);\n}\n\n/**\n * Compile from a pre-built IR (skips parsing). This is the bridge\n * that allows any frontend language (Python, Rust, Go) to emit an\n * IRIntent JSON and feed it directly into the Swift generator.\n *\n * Used by:\n * - `compileSource()` after its own parse step\n * - `axint compile --from-ir <file.json>` for cross-language pipelines\n * - The Python SDK's `axintai compile` command\n */\nexport function compileFromIR(\n ir: IRIntent,\n options: Partial<CompilerOptions> = {}\n): CompileResult {\n const diagnostics: Diagnostic[] = [];\n\n // 1. Validate IR\n const irDiagnostics = validateIntent(ir);\n diagnostics.push(...irDiagnostics);\n\n if (irDiagnostics.some((d) => d.severity === \"error\")) {\n return { success: false, diagnostics };\n }\n\n // 2. Generate Swift\n const swiftCode = generateSwift(ir);\n\n // 3. Validate generated Swift\n if (options.validate !== false) {\n const swiftDiagnostics = validateSwiftSource(swiftCode);\n diagnostics.push(...swiftDiagnostics);\n\n if (swiftDiagnostics.some((d) => d.severity === \"error\")) {\n return { success: false, diagnostics };\n }\n }\n\n // 4. Optional fragments\n const infoPlistFragment = options.emitInfoPlist\n ? generateInfoPlistFragment(ir)\n : undefined;\n const entitlementsFragment = options.emitEntitlements\n ? generateEntitlementsFragment(ir)\n : undefined;\n\n // 5. Build output\n const intentFileName = `${ir.name}Intent.swift`;\n const outputPath = options.outDir\n ? `${options.outDir}/${intentFileName}`\n : intentFileName;\n\n return {\n success: true,\n output: {\n outputPath,\n swiftCode,\n infoPlistFragment,\n entitlementsFragment,\n ir,\n diagnostics,\n },\n diagnostics,\n };\n}\n\n// ─── Cross-Language IR Bridge ───────────────────────────────────────\n\n/** Valid primitive type strings from any SDK */\nconst VALID_PRIMITIVES = new Set<string>([\n \"string\",\n \"int\",\n \"double\",\n \"float\",\n \"boolean\",\n \"date\",\n \"duration\",\n \"url\",\n]);\n\n/**\n * Parse a raw JSON object into a typed IRIntent. Accepts the flat\n * format that the Python SDK's `IntentIR.to_dict()` produces, where\n * parameter types are plain strings rather than `{ kind, value }` objects.\n *\n * This is the key function that bridges the Python → TypeScript gap.\n */\nexport function irFromJSON(data: Record<string, unknown>): IRIntent {\n const parameters: IRParameter[] = ((data.parameters as unknown[]) ?? []).map(\n (p: unknown) => {\n const param = p as Record<string, unknown>;\n return {\n name: param.name as string,\n type: normalizeIRType(param.type),\n title: (param.title as string) ?? (param.description as string) ?? \"\",\n description: (param.description as string) ?? \"\",\n isOptional: (param.optional as boolean) ?? (param.isOptional as boolean) ?? false,\n defaultValue: param.default ?? param.defaultValue,\n };\n }\n );\n\n return {\n name: data.name as string,\n title: data.title as string,\n description: data.description as string,\n domain: data.domain as string | undefined,\n parameters,\n returnType: data.returnType\n ? normalizeIRType(data.returnType)\n : { kind: \"primitive\", value: \"string\" },\n sourceFile: (data.sourceFile as string) ?? undefined,\n entitlements: (data.entitlements as string[]) ?? undefined,\n infoPlistKeys: (data.infoPlistKeys as Record<string, string>) ?? undefined,\n isDiscoverable: (data.isDiscoverable as boolean) ?? true,\n };\n}\n\n/**\n * Normalize a type value from JSON. The Python SDK sends types as\n * plain strings (\"string\", \"int\", etc.) while the TS IR uses\n * `{ kind: \"primitive\", value: \"string\" }`. This function handles both.\n */\nfunction normalizeIRType(type: unknown): IRType {\n if (typeof type === \"string\") {\n const normalized = type === \"number\" ? \"int\" : type;\n if (VALID_PRIMITIVES.has(normalized)) {\n return { kind: \"primitive\", value: normalized as IRPrimitiveType };\n }\n return { kind: \"primitive\", value: \"string\" };\n }\n if (type && typeof type === \"object\") {\n const t = type as Record<string, unknown>;\n if (t.kind === \"primitive\") return type as IRType;\n if (t.kind === \"array\")\n return { kind: \"array\", elementType: normalizeIRType(t.elementType) };\n if (t.kind === \"optional\")\n return { kind: \"optional\", innerType: normalizeIRType(t.innerType) };\n if (t.kind === \"entity\") return type as IRType;\n if (t.kind === \"enum\") return type as IRType;\n }\n // Default fallback\n return { kind: \"primitive\", value: \"string\" };\n}\n","/**\n * Axint Parser\n *\n * Parses TypeScript intent definitions (using the defineIntent() API)\n * into the Axint Intermediate Representation (IR).\n *\n * Approach: Real TypeScript compiler API AST walker. We create a\n * SourceFile, find defineIntent() CallExpressions, and extract the\n * ObjectLiteralExpression properties using the actual TS AST.\n *\n * The previous v0.1.x parser used regex matching. That approach was\n * replaced in v0.2.0 to support enums, arrays, entities, and accurate\n * return-type inference.\n */\n\nimport ts from \"typescript\";\nimport type {\n IRIntent,\n IRParameter,\n IRType,\n IRPrimitiveType,\n IREntity,\n DisplayRepresentation,\n} from \"./types.js\";\nimport { PARAM_TYPES, LEGACY_PARAM_ALIASES } from \"./types.js\";\n\n/**\n * Parse a TypeScript source file containing defineIntent() and/or\n * defineEntity() calls and return the IR representation.\n */\nexport function parseIntentSource(\n source: string,\n filePath: string = \"<stdin>\"\n): IRIntent {\n const sourceFile = ts.createSourceFile(\n filePath,\n source,\n ts.ScriptTarget.Latest,\n true, // setParentNodes\n ts.ScriptKind.TS\n );\n\n // Parse all entity definitions first, so they can be referenced by intents\n const entities = findDefineEntityCalls(sourceFile).map((call) =>\n parseEntityDefinition(call, filePath, sourceFile)\n );\n\n const defineIntentCall = findDefineIntentCall(sourceFile);\n if (!defineIntentCall) {\n throw new ParserError(\n \"AX001\",\n `No defineIntent() call found in ${filePath}`,\n filePath,\n undefined,\n \"Ensure your file contains a `defineIntent({ ... })` call.\"\n );\n }\n\n const arg = defineIntentCall.arguments[0];\n if (!arg || !ts.isObjectLiteralExpression(arg)) {\n throw new ParserError(\n \"AX001\",\n \"defineIntent() must be called with an object literal\",\n filePath,\n posOf(sourceFile, defineIntentCall),\n \"Pass an object: defineIntent({ name, title, description, params, perform })\"\n );\n }\n\n const props = propertyMap(arg);\n\n const name = readStringLiteral(props.get(\"name\"));\n const title = readStringLiteral(props.get(\"title\"));\n const description = readStringLiteral(props.get(\"description\"));\n const domain = readStringLiteral(props.get(\"domain\"));\n const category = readStringLiteral(props.get(\"category\"));\n const isDiscoverable = readBooleanLiteral(props.get(\"isDiscoverable\"));\n\n if (!name) {\n throw new ParserError(\n \"AX002\",\n \"Missing required field: name\",\n filePath,\n posOf(sourceFile, arg),\n 'Add a name field: name: \"MyIntent\"'\n );\n }\n if (!title) {\n throw new ParserError(\n \"AX003\",\n \"Missing required field: title\",\n filePath,\n posOf(sourceFile, arg),\n 'Add a title field: title: \"My Intent Title\"'\n );\n }\n if (!description) {\n throw new ParserError(\n \"AX004\",\n \"Missing required field: description\",\n filePath,\n posOf(sourceFile, arg),\n 'Add a description field: description: \"What this intent does\"'\n );\n }\n\n const paramsNode = props.get(\"params\");\n const parameters: IRParameter[] = paramsNode\n ? extractParameters(paramsNode, filePath, sourceFile)\n : [];\n\n // Return-type inference from the perform() function signature.\n const performNode = props.get(\"perform\");\n const returnType = inferReturnType(performNode);\n\n // Entitlements (optional array of strings)\n const entitlementsNode = props.get(\"entitlements\");\n const entitlements = readStringArray(entitlementsNode);\n\n // Info.plist keys (optional object literal of { key: \"description\" })\n const infoPlistNode = props.get(\"infoPlistKeys\");\n const infoPlistKeys = readStringRecord(infoPlistNode);\n\n // Intent donation (optional boolean)\n const donateOnPerformNode = props.get(\"donateOnPerform\");\n const donateOnPerform = readBooleanLiteral(donateOnPerformNode);\n\n // Custom result type (optional string)\n const customResultTypeNode = props.get(\"customResultType\");\n const customResultType = readStringLiteral(customResultTypeNode);\n\n return {\n name,\n title,\n description,\n domain: domain || undefined,\n category: category || undefined,\n parameters,\n returnType,\n sourceFile: filePath,\n entitlements: entitlements.length > 0 ? entitlements : undefined,\n infoPlistKeys:\n Object.keys(infoPlistKeys).length > 0 ? infoPlistKeys : undefined,\n isDiscoverable: isDiscoverable ?? undefined,\n entities: entities.length > 0 ? entities : undefined,\n donateOnPerform: donateOnPerform ?? undefined,\n customResultType: customResultType ?? undefined,\n };\n}\n\n// ─── AST Walkers ─────────────────────────────────────────────────────\n\n/**\n * Find the first defineIntent() call in the AST.\n */\nfunction findDefineIntentCall(\n node: ts.Node\n): ts.CallExpression | undefined {\n let found: ts.CallExpression | undefined;\n const visit = (n: ts.Node): void => {\n if (found) return;\n if (\n ts.isCallExpression(n) &&\n ts.isIdentifier(n.expression) &&\n n.expression.text === \"defineIntent\"\n ) {\n found = n;\n return;\n }\n ts.forEachChild(n, visit);\n };\n visit(node);\n return found;\n}\n\n/**\n * Find all defineEntity() calls in the AST.\n */\nfunction findDefineEntityCalls(node: ts.Node): ts.CallExpression[] {\n const found: ts.CallExpression[] = [];\n const visit = (n: ts.Node): void => {\n if (\n ts.isCallExpression(n) &&\n ts.isIdentifier(n.expression) &&\n n.expression.text === \"defineEntity\"\n ) {\n found.push(n);\n return;\n }\n ts.forEachChild(n, visit);\n };\n visit(node);\n return found;\n}\n\nfunction propertyMap(\n obj: ts.ObjectLiteralExpression\n): Map<string, ts.Expression> {\n const map = new Map<string, ts.Expression>();\n for (const prop of obj.properties) {\n if (ts.isPropertyAssignment(prop)) {\n const key = propertyKeyName(prop.name);\n if (key) map.set(key, prop.initializer);\n } else if (ts.isShorthandPropertyAssignment(prop)) {\n map.set(prop.name.text, prop.name);\n } else if (ts.isMethodDeclaration(prop)) {\n const key = propertyKeyName(prop.name);\n if (key) map.set(key, prop as unknown as ts.Expression);\n }\n }\n return map;\n}\n\nfunction propertyKeyName(name: ts.PropertyName): string | undefined {\n if (ts.isIdentifier(name)) return name.text;\n if (ts.isStringLiteral(name)) return name.text;\n if (ts.isNumericLiteral(name)) return name.text;\n return undefined;\n}\n\nfunction readStringLiteral(node: ts.Expression | undefined): string | null {\n if (!node) return null;\n if (ts.isStringLiteral(node)) return node.text;\n if (ts.isNoSubstitutionTemplateLiteral(node)) return node.text;\n return null;\n}\n\nfunction readBooleanLiteral(\n node: ts.Expression | undefined\n): boolean | undefined {\n if (!node) return undefined;\n if (node.kind === ts.SyntaxKind.TrueKeyword) return true;\n if (node.kind === ts.SyntaxKind.FalseKeyword) return false;\n return undefined;\n}\n\nfunction readStringArray(node: ts.Expression | undefined): string[] {\n if (!node || !ts.isArrayLiteralExpression(node)) return [];\n const out: string[] = [];\n for (const el of node.elements) {\n const s = readStringLiteral(el);\n if (s !== null) out.push(s);\n }\n return out;\n}\n\nfunction readStringRecord(\n node: ts.Expression | undefined\n): Record<string, string> {\n if (!node || !ts.isObjectLiteralExpression(node)) return {};\n const rec: Record<string, string> = {};\n for (const prop of node.properties) {\n if (!ts.isPropertyAssignment(prop)) continue;\n const key = propertyKeyName(prop.name);\n const val = readStringLiteral(prop.initializer);\n if (key && val !== null) rec[key] = val;\n }\n return rec;\n}\n\n// ─── Entity Definition Parsing ───────────────────────────────────────\n\n/**\n * Parse a defineEntity() call into an IREntity.\n */\nfunction parseEntityDefinition(\n call: ts.CallExpression,\n filePath: string,\n sourceFile: ts.SourceFile\n): IREntity {\n const arg = call.arguments[0];\n if (!arg || !ts.isObjectLiteralExpression(arg)) {\n throw new ParserError(\n \"AX015\",\n \"defineEntity() must be called with an object literal\",\n filePath,\n posOf(sourceFile, call),\n \"Pass an object: defineEntity({ name, display, properties, query })\"\n );\n }\n\n const props = propertyMap(arg);\n\n const name = readStringLiteral(props.get(\"name\"));\n if (!name) {\n throw new ParserError(\n \"AX016\",\n \"Entity definition missing required field: name\",\n filePath,\n posOf(sourceFile, arg),\n 'Add a name field: name: \"Task\"'\n );\n }\n\n const displayNode = props.get(\"display\");\n if (!displayNode || !ts.isObjectLiteralExpression(displayNode)) {\n throw new ParserError(\n \"AX017\",\n \"Entity definition missing required field: display\",\n filePath,\n posOf(sourceFile, arg),\n 'Add display field: display: { title: \"name\", subtitle: \"status\" }'\n );\n }\n\n const displayProps = propertyMap(displayNode);\n const displayRepresentation: DisplayRepresentation = {\n title: readStringLiteral(displayProps.get(\"title\")) || \"name\",\n subtitle: readStringLiteral(displayProps.get(\"subtitle\")) || undefined,\n image: readStringLiteral(displayProps.get(\"image\")) || undefined,\n };\n\n const propertiesNode = props.get(\"properties\");\n const properties = propertiesNode\n ? extractParameters(propertiesNode, filePath, sourceFile)\n : [];\n\n const queryTypeNode = props.get(\"query\");\n const queryTypeStr = readStringLiteral(queryTypeNode);\n const queryType = validateQueryType(queryTypeStr, filePath, sourceFile, queryTypeNode);\n\n return {\n name,\n displayRepresentation,\n properties,\n queryType,\n };\n}\n\n/**\n * Validate and normalize query type string.\n */\nfunction validateQueryType(\n value: string | null,\n filePath: string,\n sourceFile: ts.SourceFile,\n node: ts.Expression | undefined\n): \"all\" | \"id\" | \"string\" | \"property\" {\n if (!value) {\n throw new ParserError(\n \"AX018\",\n \"Entity definition missing required field: query\",\n filePath,\n node ? posOf(sourceFile, node) : undefined,\n 'Add query field: query: \"string\" (or \"all\", \"id\", \"property\")'\n );\n }\n const valid = [\"all\", \"id\", \"string\", \"property\"] as const;\n if (!valid.includes(value as any)) {\n throw new ParserError(\n \"AX019\",\n `Invalid query type: \"${value}\". Must be one of: all, id, string, property`,\n filePath,\n node ? posOf(sourceFile, node) : undefined\n );\n }\n return value as \"all\" | \"id\" | \"string\" | \"property\";\n}\n\n// ─── Parameter Extraction ────────────────────────────────────────────\n\nfunction extractParameters(\n node: ts.Expression,\n filePath: string,\n sourceFile: ts.SourceFile\n): IRParameter[] {\n if (!ts.isObjectLiteralExpression(node)) {\n throw new ParserError(\n \"AX006\",\n \"`params` must be an object literal\",\n filePath,\n posOf(sourceFile, node),\n \"Use params: { name: param.string(...), ... }\"\n );\n }\n\n const params: IRParameter[] = [];\n for (const prop of node.properties) {\n if (!ts.isPropertyAssignment(prop)) continue;\n const paramName = propertyKeyName(prop.name);\n if (!paramName) continue;\n\n const { typeName, description, configObject, callExpr } = extractParamCall(\n prop.initializer,\n filePath,\n sourceFile\n );\n\n const resolvedType = resolveParamType(typeName, filePath, sourceFile, prop, callExpr);\n\n const isOptional = configObject\n ? readBooleanLiteral(configObject.get(\"required\")) === false\n : false;\n\n const defaultExpr = configObject?.get(\"default\");\n const defaultValue = defaultExpr ? evaluateLiteral(defaultExpr) : undefined;\n\n const titleFromConfig = configObject\n ? readStringLiteral(configObject.get(\"title\"))\n : null;\n\n const irType: IRType = isOptional\n ? {\n kind: \"optional\",\n innerType: resolvedType,\n }\n : resolvedType;\n\n params.push({\n name: paramName,\n type: irType,\n title: titleFromConfig || prettyTitle(paramName),\n description,\n isOptional,\n defaultValue,\n });\n }\n\n return params;\n}\n\ninterface ParamCallInfo {\n typeName: string;\n description: string;\n configObject: Map<string, ts.Expression> | null;\n callExpr: ts.CallExpression;\n}\n\n/**\n * Extract param type, description, and config from a param.* call.\n * For param.entity() and param.dynamicOptions(), the structure is different.\n */\nfunction extractParamCall(\n expr: ts.Expression,\n filePath: string,\n sourceFile: ts.SourceFile\n): ParamCallInfo {\n if (!ts.isCallExpression(expr)) {\n throw new ParserError(\n \"AX007\",\n \"Parameter value must be a call to a param.* helper\",\n filePath,\n posOf(sourceFile, expr),\n \"Use param.string(...), param.int(...), param.date(...), etc.\"\n );\n }\n\n // Expect: param.<type>(description?, config?)\n if (\n !ts.isPropertyAccessExpression(expr.expression) ||\n !ts.isIdentifier(expr.expression.expression) ||\n expr.expression.expression.text !== \"param\"\n ) {\n throw new ParserError(\n \"AX007\",\n \"Parameter value must be a call to a param.* helper\",\n filePath,\n posOf(sourceFile, expr),\n \"Use param.string(...), param.int(...), param.date(...), etc.\"\n );\n }\n\n const typeName = expr.expression.name.text;\n\n // For entity and dynamicOptions, the structure differs:\n // - param.entity(\"EntityName\", \"description\", config?)\n // - param.dynamicOptions(\"Provider\", param.string(...), \"description\", config?)\n let descriptionArg: ts.Expression | undefined;\n let configArg: ts.Expression | undefined;\n\n if (typeName === \"entity\" && expr.arguments.length >= 2) {\n descriptionArg = expr.arguments[1];\n configArg = expr.arguments[2];\n } else if (typeName === \"dynamicOptions\" && expr.arguments.length >= 3) {\n descriptionArg = expr.arguments[2];\n configArg = expr.arguments[3];\n } else {\n descriptionArg = expr.arguments[0];\n configArg = expr.arguments[1];\n }\n\n const description = descriptionArg ? readStringLiteral(descriptionArg) : null;\n if (description === null) {\n throw new ParserError(\n \"AX008\",\n `param.${typeName}() requires a string description`,\n filePath,\n posOf(sourceFile, expr),\n `Example: param.${typeName}(\"Human-readable description\")`\n );\n }\n\n const configObject =\n configArg && ts.isObjectLiteralExpression(configArg)\n ? propertyMap(configArg)\n : null;\n\n return { typeName, description, configObject, callExpr: expr };\n}\n\n/**\n * Resolve a param type name into an IRType.\n * Supports primitives, entity references, and dynamic options.\n */\nfunction resolveParamType(\n typeName: string,\n filePath: string,\n sourceFile: ts.SourceFile,\n node: ts.Node,\n callExpr?: ts.CallExpression\n): IRType {\n // Primitive types\n if (PARAM_TYPES.has(typeName as IRPrimitiveType)) {\n return { kind: \"primitive\", value: typeName as IRPrimitiveType };\n }\n\n // Legacy aliases\n if (typeName in LEGACY_PARAM_ALIASES) {\n return {\n kind: \"primitive\",\n value: LEGACY_PARAM_ALIASES[typeName],\n };\n }\n\n // Entity types: param.entity(\"EntityName\")\n if (typeName === \"entity\") {\n if (!callExpr || callExpr.arguments.length === 0) {\n throw new ParserError(\n \"AX020\",\n \"param.entity() requires the entity name as the first argument\",\n filePath,\n posOf(sourceFile, node),\n 'Example: param.entity(\"Task\", \"Reference an entity\")'\n );\n }\n const entityName = readStringLiteral(callExpr.arguments[0]);\n if (!entityName) {\n throw new ParserError(\n \"AX021\",\n \"param.entity() requires a string entity name\",\n filePath,\n posOf(sourceFile, node)\n );\n }\n return {\n kind: \"entity\",\n entityName,\n properties: [],\n };\n }\n\n // Dynamic options: param.dynamicOptions(\"ProviderName\", innerType)\n if (typeName === \"dynamicOptions\") {\n if (!callExpr || callExpr.arguments.length < 2) {\n throw new ParserError(\n \"AX022\",\n \"param.dynamicOptions() requires (providerName, paramType)\",\n filePath,\n posOf(sourceFile, node),\n 'Example: param.dynamicOptions(\"PlaylistProvider\", param.string(...))'\n );\n }\n const providerName = readStringLiteral(callExpr.arguments[0]);\n if (!providerName) {\n throw new ParserError(\n \"AX023\",\n \"param.dynamicOptions() provider name must be a string\",\n filePath,\n posOf(sourceFile, node)\n );\n }\n // TODO: Extract inner param type from the second argument\n const valueType: IRType = { kind: \"primitive\", value: \"string\" };\n return {\n kind: \"dynamicOptions\",\n valueType,\n providerName,\n };\n }\n\n throw new ParserError(\n \"AX005\",\n `Unknown param type: param.${typeName}`,\n filePath,\n posOf(sourceFile, node),\n `Supported types: ${[...PARAM_TYPES].join(\", \")}, entity, dynamicOptions`\n );\n}\n\n// ─── Literal Evaluation ──────────────────────────────────────────────\n\nfunction evaluateLiteral(node: ts.Expression): unknown {\n if (ts.isStringLiteral(node)) return node.text;\n if (ts.isNoSubstitutionTemplateLiteral(node)) return node.text;\n if (ts.isNumericLiteral(node)) return Number(node.text);\n if (node.kind === ts.SyntaxKind.TrueKeyword) return true;\n if (node.kind === ts.SyntaxKind.FalseKeyword) return false;\n if (node.kind === ts.SyntaxKind.NullKeyword) return null;\n if (\n ts.isPrefixUnaryExpression(node) &&\n node.operator === ts.SyntaxKind.MinusToken &&\n ts.isNumericLiteral(node.operand)\n ) {\n return -Number(node.operand.text);\n }\n return undefined;\n}\n\n// ─── Return-Type Inference ───────────────────────────────────────────\n\nfunction inferReturnType(performNode: ts.Expression | undefined): IRType {\n // Default when we can't infer anything.\n const defaultType: IRType = { kind: \"primitive\", value: \"string\" };\n if (!performNode) return defaultType;\n\n // Handle method shorthand: perform() { ... }\n if (ts.isMethodDeclaration(performNode)) {\n return inferFromReturnStatements(performNode.body);\n }\n\n // Handle arrow function: perform: async () => { ... }\n if (ts.isArrowFunction(performNode)) {\n if (performNode.body && ts.isBlock(performNode.body)) {\n return inferFromReturnStatements(performNode.body);\n }\n // Single-expression arrow: perform: async (p) => \"literal\"\n return inferFromExpression(performNode.body as ts.Expression);\n }\n\n // Handle function expression: perform: async function() { ... }\n if (ts.isFunctionExpression(performNode)) {\n return inferFromReturnStatements(performNode.body);\n }\n\n return defaultType;\n}\n\nfunction inferFromReturnStatements(block: ts.Block | undefined): IRType {\n const defaultType: IRType = { kind: \"primitive\", value: \"string\" };\n if (!block) return defaultType;\n\n let inferred: IRType | undefined;\n const visit = (n: ts.Node): void => {\n if (inferred) return;\n if (ts.isReturnStatement(n) && n.expression) {\n inferred = inferFromExpression(n.expression);\n return;\n }\n // Don't walk into nested functions — only the top-level perform() body.\n if (\n ts.isFunctionDeclaration(n) ||\n ts.isFunctionExpression(n) ||\n ts.isArrowFunction(n)\n ) {\n return;\n }\n ts.forEachChild(n, visit);\n };\n visit(block);\n return inferred ?? defaultType;\n}\n\nfunction inferFromExpression(expr: ts.Expression): IRType {\n if (ts.isStringLiteral(expr) || ts.isNoSubstitutionTemplateLiteral(expr)) {\n return { kind: \"primitive\", value: \"string\" };\n }\n if (ts.isNumericLiteral(expr)) {\n return expr.text.includes(\".\")\n ? { kind: \"primitive\", value: \"double\" }\n : { kind: \"primitive\", value: \"int\" };\n }\n if (\n expr.kind === ts.SyntaxKind.TrueKeyword ||\n expr.kind === ts.SyntaxKind.FalseKeyword\n ) {\n return { kind: \"primitive\", value: \"boolean\" };\n }\n // Default fallback\n return { kind: \"primitive\", value: \"string\" };\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────\n\nfunction prettyTitle(name: string): string {\n const spaced = name.replace(/([A-Z])/g, \" $1\").trim();\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\nfunction posOf(\n sourceFile: ts.SourceFile,\n node: ts.Node\n): number | undefined {\n try {\n const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n return line + 1;\n } catch {\n return undefined;\n }\n}\n\n// ─── Error Class ─────────────────────────────────────────────────────\n\nexport class ParserError extends Error {\n constructor(\n public code: string,\n message: string,\n public file: string,\n public line?: number,\n public suggestion?: string\n ) {\n super(message);\n this.name = \"ParserError\";\n }\n\n format(): string {\n let output = `\\n error[${this.code}]: ${this.message}\\n`;\n if (this.file) output += ` --> ${this.file}`;\n if (this.line) output += `:${this.line}`;\n output += \"\\n\";\n if (this.suggestion) {\n output += ` = help: ${this.suggestion}\\n`;\n }\n return output;\n }\n}\n","/**\n * Axint Core Types\n *\n * Intermediate Representation (IR) and compiler types for the\n * TypeScript → Swift App Intent compilation pipeline.\n */\n\n// ─── IR Types ────────────────────────────────────────────────────────\n\n/** Primitive types supported by App Intents */\nexport type IRPrimitiveType =\n | \"string\"\n | \"int\"\n | \"double\"\n | \"float\"\n | \"boolean\"\n | \"date\"\n | \"duration\"\n | \"url\";\n\n/** Type node in the IR */\nexport type IRType =\n | { kind: \"primitive\"; value: IRPrimitiveType }\n | { kind: \"array\"; elementType: IRType }\n | { kind: \"optional\"; innerType: IRType }\n | { kind: \"entity\"; entityName: string; properties: IRParameter[] }\n | { kind: \"entityQuery\"; entityName: string; queryType: \"all\" | \"id\" | \"string\" | \"property\" }\n | { kind: \"dynamicOptions\"; valueType: IRType; providerName: string }\n | { kind: \"enum\"; name: string; cases: string[] };\n\n/** A single parameter in an intent definition */\nexport interface IRParameter {\n name: string;\n type: IRType;\n title: string;\n description: string;\n isOptional: boolean;\n defaultValue?: unknown;\n}\n\n/**\n * Display representation configuration for an entity.\n * Maps which properties to show in Siri and Shortcuts UI.\n */\nexport interface DisplayRepresentation {\n title: string;\n subtitle?: string;\n image?: string;\n}\n\n/**\n * An App Entity definition for complex, domain-specific data types.\n * Entities can be queried and used as parameter types in intents.\n */\nexport interface IREntity {\n name: string;\n displayRepresentation: DisplayRepresentation;\n properties: IRParameter[];\n queryType: \"all\" | \"id\" | \"string\" | \"property\";\n}\n\n/** The main IR node representing a compiled intent */\nexport interface IRIntent {\n name: string;\n title: string;\n description: string;\n domain?: string;\n category?: string;\n parameters: IRParameter[];\n returnType: IRType;\n sourceFile: string;\n /** Entitlements required by this intent (e.g., \"com.apple.developer.siri\") */\n entitlements?: string[];\n /** Info.plist keys required by this intent (e.g., \"NSCalendarsUsageDescription\") */\n infoPlistKeys?: Record<string, string>;\n /** Whether the intent should be exposed to Spotlight indexing */\n isDiscoverable?: boolean;\n /** App Entities used by this intent */\n entities?: IREntity[];\n /** Whether to donate this intent to Spotlight/Siri when performed */\n donateOnPerform?: boolean;\n /** Custom result type (SwiftUI view or custom struct) to return */\n customResultType?: string;\n}\n\n// ─── Compiler Types ──────────────────────────────────────────────────\n\nexport interface CompilerOptions {\n /** Output directory for generated Swift files */\n outDir: string;\n /** Whether to run validation after generation */\n validate?: boolean;\n /** Target iOS/macOS version */\n target?: \"ios16\" | \"ios17\" | \"ios18\" | \"ios26\" | \"macos13\" | \"macos14\" | \"macos15\" | \"macos26\";\n /** Whether to emit an Info.plist fragment alongside the Swift file */\n emitInfoPlist?: boolean;\n /** Whether to emit an entitlements fragment alongside the Swift file */\n emitEntitlements?: boolean;\n /** Whether to run swift-format on the output (requires swift-format on PATH) */\n format?: boolean;\n}\n\nexport interface CompilerOutput {\n /** Path to the generated Swift file */\n outputPath: string;\n /** The generated Swift source code */\n swiftCode: string;\n /** Info.plist fragment (if emitInfoPlist is true) */\n infoPlistFragment?: string;\n /** Entitlements fragment (if emitEntitlements is true) */\n entitlementsFragment?: string;\n /** The intermediate representation */\n ir: IRIntent;\n /** Validation diagnostics */\n diagnostics: Diagnostic[];\n}\n\n// ─── Diagnostics ─────────────────────────────────────────────────────\n\nexport type DiagnosticSeverity = \"error\" | \"warning\" | \"info\";\n\nexport interface Diagnostic {\n code: string;\n severity: DiagnosticSeverity;\n message: string;\n file?: string;\n line?: number;\n column?: number;\n suggestion?: string;\n}\n\n// ─── Param Type Registry ─────────────────────────────────────────────\n\n/**\n * Canonical set of supported param types.\n * Single source of truth — parser, SDK, and docs all derive from this.\n * To add a new type: add it to IRPrimitiveType, PARAM_TYPES, and SWIFT_TYPE_MAP.\n */\nexport const PARAM_TYPES: ReadonlySet<IRPrimitiveType> = new Set<IRPrimitiveType>([\n \"string\",\n \"int\",\n \"double\",\n \"float\",\n \"boolean\",\n \"date\",\n \"duration\",\n \"url\",\n]);\n\n/**\n * Legacy alias: \"number\" → \"int\" for backwards compatibility with v0.1.x files.\n * Parser will accept \"number\" and rewrite it to \"int\" with a deprecation warning.\n */\nexport const LEGACY_PARAM_ALIASES: Record<string, IRPrimitiveType> = {\n number: \"int\",\n};\n\n// ─── Swift Type Mapping ──────────────────────────────────────────────\n\nexport const SWIFT_TYPE_MAP: Record<IRPrimitiveType, string> = {\n string: \"String\",\n int: \"Int\",\n double: \"Double\",\n float: \"Float\",\n boolean: \"Bool\",\n date: \"Date\",\n duration: \"Measurement<UnitDuration>\",\n url: \"URL\",\n};\n\n/**\n * Convert an IRType to its Swift type string.\n */\nexport function irTypeToSwift(type: IRType): string {\n switch (type.kind) {\n case \"primitive\":\n return SWIFT_TYPE_MAP[type.value];\n case \"array\":\n return `[${irTypeToSwift(type.elementType)}]`;\n case \"optional\":\n return `${irTypeToSwift(type.innerType)}?`;\n case \"entity\":\n return type.entityName;\n case \"entityQuery\":\n return `${type.entityName}Query`;\n case \"dynamicOptions\":\n return `[DynamicOptionsResult<${irTypeToSwift(type.valueType)}>]`;\n case \"enum\":\n return type.name;\n }\n}\n","/**\n * Axint Swift Code Generator\n *\n * Transforms the IR into clean, idiomatic Swift App Intent source code.\n * Uses string templates for readability and maintainability.\n *\n * In addition to the primary Swift file, this module can emit two\n * companion fragments:\n * - an Info.plist XML fragment, listing the keys the intent requires\n * - an .entitlements XML fragment, listing the entitlements the\n * intent requires\n *\n * Both fragments are designed to be merged into the host Xcode project\n * by the user (or a future axint-link command).\n */\n\nimport type { IRIntent, IRParameter, IRType, IREntity } from \"./types.js\";\nimport { irTypeToSwift } from \"./types.js\";\n\n// ─── String Escaping ─────────────────────────────────────────────────\n\n/**\n * Escape a string for safe interpolation into Swift string literals.\n * Prevents code injection via user-controlled titles/descriptions.\n */\nexport function escapeSwiftString(s: string): string {\n return s\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, \"\\\\n\")\n .replace(/\\r/g, \"\\\\r\")\n .replace(/\\t/g, \"\\\\t\");\n}\n\n/**\n * Escape a string for safe interpolation into XML (Info.plist or\n * .entitlements). Plist XML uses the same rules as general XML.\n */\nexport function escapeXml(s: string): string {\n return s\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\n// ─── Primary Swift Generator ─────────────────────────────────────────\n\n/**\n * Generate a Swift App Intent source file from an IR intent.\n * If entities are present, they are generated first, followed by the intent.\n */\nexport function generateSwift(intent: IRIntent): string {\n const lines: string[] = [];\n\n // File header\n lines.push(`// ${intent.name}Intent.swift`);\n lines.push(`// Generated by Axint — https://github.com/agenticempire/axint`);\n lines.push(`// Do not edit manually. Re-run \\`axint compile\\` to regenerate.`);\n lines.push(``);\n lines.push(`import AppIntents`);\n lines.push(`import Foundation`);\n lines.push(``);\n\n // Generate entities before the intent\n if (intent.entities && intent.entities.length > 0) {\n for (const entity of intent.entities) {\n lines.push(generateEntity(entity));\n lines.push(``);\n lines.push(generateEntityQuery(entity));\n lines.push(``);\n }\n }\n\n // Struct declaration\n lines.push(`struct ${intent.name}Intent: AppIntent {`);\n\n // Static metadata\n lines.push(\n ` static let title: LocalizedStringResource = \"${escapeSwiftString(intent.title)}\"`\n );\n lines.push(\n ` static let description: IntentDescription = IntentDescription(\"${escapeSwiftString(intent.description)}\")`\n );\n if (intent.isDiscoverable !== undefined) {\n lines.push(` static let isDiscoverable: Bool = ${intent.isDiscoverable}`);\n }\n lines.push(``);\n\n // Parameters\n for (const param of intent.parameters) {\n lines.push(generateParameter(param));\n }\n\n if (intent.parameters.length > 0) {\n lines.push(``);\n }\n\n // Perform function with return-type aware signature\n const returnTypeSignature = generateReturnSignature(\n intent.returnType,\n intent.customResultType\n );\n lines.push(` func perform() async throws -> ${returnTypeSignature} {`);\n lines.push(` // TODO: Implement your intent logic here.`);\n\n if (intent.parameters.length > 0) {\n const paramList = intent.parameters.map((p) => `\\\\(${p.name})`).join(\", \");\n lines.push(` // Parameters available: ${paramList}`);\n }\n\n // Add intent donation if enabled\n if (intent.donateOnPerform) {\n lines.push(` `);\n lines.push(` // Donate this intent to Siri and Spotlight`);\n lines.push(` try? await IntentDonationManager.shared.donate(intent: self)`);\n }\n\n lines.push(generatePerformReturn(intent.returnType, intent.customResultType));\n lines.push(` }`);\n lines.push(`}`);\n lines.push(``);\n\n return lines.join(\"\\n\");\n}\n\n// ─── Entity Generation ───────────────────────────────────────────────\n\n/**\n * Generate an AppEntity struct from an IREntity definition.\n */\nexport function generateEntity(entity: IREntity): string {\n const lines: string[] = [];\n const propertyNames = new Set(entity.properties.map((p) => p.name));\n\n lines.push(`struct ${entity.name}: AppEntity {`);\n lines.push(` static var defaultQuery = ${entity.name}Query()`);\n lines.push(``);\n\n // Apple requires AppEntity to have an id property\n const hasId = propertyNames.has(\"id\");\n if (!hasId) {\n lines.push(` var id: String`);\n }\n\n // Properties\n for (const prop of entity.properties) {\n const swiftType = irTypeToSwift(prop.type);\n lines.push(` var ${prop.name}: ${swiftType}`);\n }\n\n lines.push(``);\n\n // Type display representation\n lines.push(\n ` static let typeDisplayRepresentation: TypeDisplayRepresentation = TypeDisplayRepresentation(`\n );\n lines.push(\n ` name: LocalizedStringResource(\"${escapeSwiftString(entity.name)}\")`\n );\n lines.push(` )`);\n lines.push(``);\n\n // Display representation computed property — title/subtitle are property\n // name references, so we emit Swift string interpolation \\(propName)\n lines.push(` var displayRepresentation: DisplayRepresentation {`);\n lines.push(` DisplayRepresentation(`);\n lines.push(\n ` title: \"\\\\(${entity.displayRepresentation.title})\"${entity.displayRepresentation.subtitle || entity.displayRepresentation.image ? \",\" : \"\"}`\n );\n if (entity.displayRepresentation.subtitle) {\n const hasImage = !!entity.displayRepresentation.image;\n lines.push(\n ` subtitle: \"\\\\(${entity.displayRepresentation.subtitle})\"${hasImage ? \",\" : \"\"}`\n );\n }\n if (entity.displayRepresentation.image) {\n lines.push(\n ` image: .init(systemName: \"${escapeSwiftString(entity.displayRepresentation.image)}\")`\n );\n }\n lines.push(` )`);\n lines.push(` }`);\n\n lines.push(`}`);\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Generate an EntityQuery conformance struct based on the entity's query type.\n */\nexport function generateEntityQuery(entity: IREntity): string {\n const lines: string[] = [];\n const queryType = entity.queryType;\n\n lines.push(`struct ${entity.name}Query: EntityQuery {`);\n lines.push(\n ` func entities(for identifiers: [${entity.name}.ID]) async throws -> [${entity.name}] {`\n );\n lines.push(` // TODO: Fetch entities by IDs`);\n lines.push(` return []`);\n lines.push(` }`);\n lines.push(``);\n\n // Generate appropriate query method based on queryType\n if (queryType === \"all\") {\n lines.push(` func allEntities() async throws -> [${entity.name}] {`);\n lines.push(` // TODO: Return all entities`);\n lines.push(` return []`);\n lines.push(` }`);\n } else if (queryType === \"id\") {\n // ID-based query is handled by entities(for:) above\n lines.push(` // ID-based query is provided by the entities(for:) method above`);\n } else if (queryType === \"string\") {\n lines.push(\n ` func entities(matching string: String) async throws -> [${entity.name}] {`\n );\n lines.push(` // TODO: Search entities by string`);\n lines.push(` return []`);\n lines.push(` }`);\n } else if (queryType === \"property\") {\n // Property-based query requires additional configuration\n lines.push(` // Property-based query: implement using EntityPropertyQuery`);\n lines.push(` // Example: property.where { \\\\$0.status == \"active\" }`);\n }\n\n lines.push(`}`);\n\n return lines.join(\"\\n\");\n}\n\n// ─── Info.plist Fragment Generator ───────────────────────────────────\n\n/**\n * Generate an Info.plist XML fragment from the intent's declared keys.\n * Returns `undefined` if the intent declares no Info.plist keys.\n *\n * The fragment is a bare `<dict>`-less sequence of `<key>…</key>` /\n * `<string>…</string>` pairs, ready to be merged into an existing\n * Info.plist. A commented header identifies the source intent so users\n * can audit provenance.\n */\nexport function generateInfoPlistFragment(intent: IRIntent): string | undefined {\n const keys = intent.infoPlistKeys;\n if (!keys || Object.keys(keys).length === 0) return undefined;\n\n const lines: string[] = [];\n lines.push(`<?xml version=\"1.0\" encoding=\"UTF-8\"?>`);\n lines.push(`<!-- Info.plist fragment generated by Axint for ${intent.name}Intent -->`);\n lines.push(`<!-- Merge these keys into your app's Info.plist. -->`);\n lines.push(`<plist version=\"1.0\">`);\n lines.push(`<dict>`);\n for (const [key, desc] of Object.entries(keys)) {\n lines.push(` <key>${escapeXml(key)}</key>`);\n lines.push(` <string>${escapeXml(desc)}</string>`);\n }\n lines.push(`</dict>`);\n lines.push(`</plist>`);\n lines.push(``);\n\n return lines.join(\"\\n\");\n}\n\n// ─── Entitlements Fragment Generator ─────────────────────────────────\n\n/**\n * Generate a `.entitlements` XML fragment from the intent's declared\n * entitlements. Returns `undefined` if the intent declares none.\n *\n * Axint only knows the entitlement identifiers, so all entries are\n * emitted as `<true/>` boolean entitlements. If an entitlement requires\n * a typed value (string, array), users must edit the fragment after\n * generation — a TODO comment is emitted to flag this.\n */\nexport function generateEntitlementsFragment(intent: IRIntent): string | undefined {\n const ents = intent.entitlements;\n if (!ents || ents.length === 0) return undefined;\n\n const lines: string[] = [];\n lines.push(`<?xml version=\"1.0\" encoding=\"UTF-8\"?>`);\n lines.push(\n `<!-- Entitlements fragment generated by Axint for ${intent.name}Intent -->`\n );\n lines.push(`<!-- Merge these into your target's .entitlements file. -->`);\n lines.push(`<!-- Note: entitlements requiring typed values (string/array) -->`);\n lines.push(`<!-- need manual adjustment — defaults below are boolean true. -->`);\n lines.push(\n `<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">`\n );\n lines.push(`<plist version=\"1.0\">`);\n lines.push(`<dict>`);\n for (const ent of ents) {\n lines.push(` <key>${escapeXml(ent)}</key>`);\n lines.push(` <true/>`);\n }\n lines.push(`</dict>`);\n lines.push(`</plist>`);\n lines.push(``);\n\n return lines.join(\"\\n\");\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────\n\nfunction generateParameter(param: IRParameter): string {\n const swiftType = irTypeToSwift(param.type);\n const lines: string[] = [];\n\n // Build @Parameter decorator\n const attrs: string[] = [];\n attrs.push(`title: \"${escapeSwiftString(param.title)}\"`);\n if (param.description) {\n attrs.push(`description: \"${escapeSwiftString(param.description)}\"`);\n }\n\n const decorator = ` @Parameter(${attrs.join(\", \")})`;\n lines.push(decorator);\n\n // Property declaration\n if (param.defaultValue !== undefined) {\n const defaultStr = formatSwiftDefault(param.defaultValue, param.type);\n lines.push(` var ${param.name}: ${swiftType} = ${defaultStr}`);\n } else {\n lines.push(` var ${param.name}: ${swiftType}`);\n }\n\n lines.push(``);\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Choose the Swift return-type signature for the generated perform().\n * We map the inferred IR return type to an App Intents `IntentResult`\n * shape. For primitive return types we use `some ReturnsValue<T>`;\n * for custom result types we use the custom type; otherwise we fall\n * back to `some IntentResult`.\n */\nfunction generateReturnSignature(type: IRType, customResultType?: string): string {\n if (customResultType) {\n return customResultType;\n }\n if (type.kind === \"primitive\") {\n const swift = irTypeToSwift(type);\n return `some IntentResult & ReturnsValue<${swift}>`;\n }\n if (type.kind === \"optional\" && type.innerType.kind === \"primitive\") {\n const swift = irTypeToSwift(type.innerType);\n return `some IntentResult & ReturnsValue<${swift}>`;\n }\n return `some IntentResult`;\n}\n\n/**\n * Emit the `return .result(...)` line that matches the return signature\n * produced by `generateReturnSignature`. When the return type is a\n * primitive we return a well-typed default placeholder the user can\n * replace; otherwise we emit a plain `.result()`.\n */\nfunction generatePerformReturn(type: IRType, customResultType?: string): string {\n const indent = \" \";\n if (customResultType) {\n // For custom result types, the user must provide the implementation\n return `${indent}// TODO: Return a ${customResultType} instance`;\n }\n if (type.kind === \"primitive\") {\n return `${indent}return .result(value: ${defaultLiteralFor(type.value)})`;\n }\n if (type.kind === \"optional\" && type.innerType.kind === \"primitive\") {\n return `${indent}return .result(value: ${defaultLiteralFor(type.innerType.value)})`;\n }\n return `${indent}return .result()`;\n}\n\nfunction defaultLiteralFor(primitive: string): string {\n switch (primitive) {\n case \"string\":\n return `\"\"`;\n case \"int\":\n return `0`;\n case \"double\":\n return `0.0`;\n case \"float\":\n return `Float(0)`;\n case \"boolean\":\n return `false`;\n case \"date\":\n return `Date()`;\n case \"duration\":\n return `Measurement<UnitDuration>(value: 0, unit: .seconds)`;\n case \"url\":\n return `URL(string: \"about:blank\")!`;\n default:\n return `\"\"`;\n }\n}\n\nfunction formatSwiftDefault(value: unknown, _type: IRType): string {\n if (typeof value === \"string\") return `\"${escapeSwiftString(value)}\"`;\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) return `0`; // Guard against NaN/Infinity\n return `${value}`;\n }\n if (typeof value === \"boolean\") return value ? \"true\" : \"false\";\n return `\"${escapeSwiftString(String(value))}\"`; // Safe fallback\n}\n","/**\n * Axint Validator\n *\n * Validates generated Swift App Intent code against Apple's API surface.\n * Returns diagnostics with error codes, locations, and fix suggestions.\n */\n\nimport type { Diagnostic, IRIntent, IREntity } from \"./types.js\";\n\n/** Apple-recommended maximum parameters per intent for usability */\nconst MAX_PARAMETERS = 10;\n\n/** Maximum title length before Siri may truncate display */\nconst MAX_TITLE_LENGTH = 60;\n\n/**\n * Validate an IR intent for App Intents framework compliance.\n */\nexport function validateIntent(intent: IRIntent): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n // Rule: Intent name must be PascalCase and non-empty\n if (!intent.name || !/^[A-Z][a-zA-Z0-9]*$/.test(intent.name)) {\n diagnostics.push({\n code: \"AX100\",\n severity: \"error\",\n message: `Intent name \"${intent.name}\" must be PascalCase (e.g., \"CreateEvent\")`,\n file: intent.sourceFile,\n suggestion: `Rename to \"${toPascalCase(intent.name)}\"`,\n });\n }\n\n // Rule: Title must not be empty\n if (!intent.title || intent.title.trim().length === 0) {\n diagnostics.push({\n code: \"AX101\",\n severity: \"error\",\n message: \"Intent title must not be empty\",\n file: intent.sourceFile,\n suggestion: \"Add a human-readable title for Siri and Shortcuts display\",\n });\n }\n\n // Rule: Description must not be empty\n if (!intent.description || intent.description.trim().length === 0) {\n diagnostics.push({\n code: \"AX102\",\n severity: \"error\",\n message: \"Intent description must not be empty\",\n file: intent.sourceFile,\n suggestion: \"Add a description explaining what this intent does\",\n });\n }\n\n // Rule: Parameter names must be valid Swift identifiers\n for (const param of intent.parameters) {\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(param.name)) {\n diagnostics.push({\n code: \"AX103\",\n severity: \"error\",\n message: `Parameter name \"${param.name}\" is not a valid Swift identifier`,\n file: intent.sourceFile,\n suggestion: `Rename to \"${param.name.replace(/[^a-zA-Z0-9_]/g, \"_\")}\"`,\n });\n }\n\n // Rule: Parameter description should not be empty\n if (!param.description || param.description.trim().length === 0) {\n diagnostics.push({\n code: \"AX104\",\n severity: \"warning\",\n message: `Parameter \"${param.name}\" has no description — Siri will display it without context`,\n file: intent.sourceFile,\n suggestion: \"Add a description for better Siri/Shortcuts display\",\n });\n }\n }\n\n // Rule: Max 10 parameters per intent (App Intents recommendation)\n if (intent.parameters.length > MAX_PARAMETERS) {\n diagnostics.push({\n code: \"AX105\",\n severity: \"warning\",\n message: `Intent has ${intent.parameters.length} parameters. Apple recommends ${MAX_PARAMETERS} or fewer for usability.`,\n file: intent.sourceFile,\n suggestion:\n \"Consider splitting into multiple intents or grouping parameters into an entity\",\n });\n }\n\n // Rule: Title should not exceed 60 characters (Siri display constraint)\n if (intent.title && intent.title.length > MAX_TITLE_LENGTH) {\n diagnostics.push({\n code: \"AX106\",\n severity: \"warning\",\n message: `Intent title is ${intent.title.length} characters. Siri display may truncate titles over ${MAX_TITLE_LENGTH} characters.`,\n file: intent.sourceFile,\n });\n }\n\n // Rule: Parameter names must be unique within an intent\n const seen = new Set<string>();\n for (const param of intent.parameters) {\n if (seen.has(param.name)) {\n diagnostics.push({\n code: \"AX107\",\n severity: \"error\",\n message: `Duplicate parameter name \"${param.name}\"`,\n file: intent.sourceFile,\n suggestion: \"Each parameter in a single intent must have a unique name\",\n });\n }\n seen.add(param.name);\n }\n\n // Rule: Entitlement strings must look like reverse-DNS identifiers\n for (const ent of intent.entitlements ?? []) {\n if (!/^[a-zA-Z0-9._-]+$/.test(ent) || !ent.includes(\".\")) {\n diagnostics.push({\n code: \"AX108\",\n severity: \"warning\",\n message: `Entitlement \"${ent}\" does not look like a valid reverse-DNS identifier`,\n file: intent.sourceFile,\n suggestion:\n 'Use reverse-DNS, e.g., \"com.apple.developer.siri\" or \"com.apple.security.app-sandbox\"',\n });\n }\n }\n\n // Rule: Info.plist keys must start with \"NS\" or other known prefixes\n for (const key of Object.keys(intent.infoPlistKeys ?? {})) {\n if (!/^(NS|UI|LS|CF|CA|CK)[A-Za-z0-9]+$/.test(key)) {\n diagnostics.push({\n code: \"AX109\",\n severity: \"warning\",\n message: `Info.plist key \"${key}\" does not match Apple's usual naming conventions`,\n file: intent.sourceFile,\n suggestion:\n 'Apple keys generally start with \"NS\" (e.g., \"NSCalendarsUsageDescription\")',\n });\n }\n }\n\n // Validate all entities\n if (intent.entities) {\n for (const entity of intent.entities) {\n diagnostics.push(...validateEntity(entity, intent.sourceFile));\n }\n }\n\n return diagnostics;\n}\n\n/**\n * Validate an IREntity for App Intents framework compliance.\n */\nexport function validateEntity(entity: IREntity, sourceFile: string): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n // Rule AX110: Entity name must be PascalCase\n if (!entity.name || !/^[A-Z][a-zA-Z0-9]*$/.test(entity.name)) {\n diagnostics.push({\n code: \"AX110\",\n severity: \"error\",\n message: `Entity name \"${entity.name}\" must be PascalCase (e.g., \"Task\", \"Playlist\")`,\n file: sourceFile,\n suggestion: `Rename to \"${toPascalCase(entity.name)}\"`,\n });\n }\n\n // Rule AX111: Entity must have at least one property\n if (entity.properties.length === 0) {\n diagnostics.push({\n code: \"AX111\",\n severity: \"error\",\n message: `Entity \"${entity.name}\" must have at least one property`,\n file: sourceFile,\n suggestion: \"Add properties to define the entity's structure\",\n });\n }\n\n // Rule AX112: Display title must reference an existing property\n const titleProp = entity.displayRepresentation.title;\n const propertyNames = new Set(entity.properties.map((p) => p.name));\n if (titleProp && !propertyNames.has(titleProp)) {\n diagnostics.push({\n code: \"AX112\",\n severity: \"warning\",\n message: `Display title \"${titleProp}\" does not reference an existing property`,\n file: sourceFile,\n suggestion: `Available properties: ${[...propertyNames].join(\", \")}`,\n });\n }\n\n // Rule AX113: Query type must be valid\n const validQueryTypes = [\"all\", \"id\", \"string\", \"property\"];\n if (!validQueryTypes.includes(entity.queryType)) {\n diagnostics.push({\n code: \"AX113\",\n severity: \"error\",\n message: `Entity query type \"${entity.queryType}\" is not valid`,\n file: sourceFile,\n suggestion: `Use one of: ${validQueryTypes.join(\", \")}`,\n });\n }\n\n return diagnostics;\n}\n\n/**\n * Validate generated Swift source code for basic correctness.\n */\nexport function validateSwiftSource(swift: string): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n\n // Check for required import\n if (!swift.includes(\"import AppIntents\")) {\n diagnostics.push({\n code: \"AX200\",\n severity: \"error\",\n message: 'Generated Swift is missing \"import AppIntents\"',\n });\n }\n\n // Check for AppIntent conformance\n if (!swift.includes(\": AppIntent\")) {\n diagnostics.push({\n code: \"AX201\",\n severity: \"error\",\n message: \"Generated struct does not conform to AppIntent protocol\",\n });\n }\n\n // Check for perform function\n if (!swift.includes(\"func perform()\")) {\n diagnostics.push({\n code: \"AX202\",\n severity: \"error\",\n message: \"Generated struct is missing the perform() function\",\n });\n }\n\n return diagnostics;\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────\n\nfunction toPascalCase(s: string): string {\n if (!s) return \"UnnamedIntent\";\n return s\n .replace(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : \"\"))\n .replace(/^(.)/, (c) => c.toUpperCase());\n}\n","/**\n * swift-format integration (optional post-processor)\n *\n * After codegen, optionally pipe the emitted Swift through Apple's\n * `swift-format` tool with a house style file that mirrors Apple's own\n * codebase. This is the last stage of the pipeline that runs before\n * writing to disk.\n *\n * `swift-format` ships with the Swift toolchain on macOS. If the binary\n * isn't on $PATH (Linux CI, Windows, containers) we log a warning and\n * return the source unchanged rather than failing the build — the\n * generator already emits valid, well-indented Swift without it.\n */\n\nimport { spawn } from \"node:child_process\";\nimport { writeFile, unlink } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { tmpdir } from \"node:os\";\n\nexport interface FormatOptions {\n /** Hard timeout in ms for the swift-format call (default 8s) */\n timeoutMs?: number;\n /** Throw on failure instead of returning the original source */\n strict?: boolean;\n}\n\nexport interface FormatResult {\n formatted: string;\n ran: boolean;\n reason?: string;\n}\n\n/** The house style file — tracks Apple's swift-format defaults + Axint tweaks. */\nexport const SWIFT_FORMAT_CONFIG = {\n version: 1,\n lineLength: 100,\n indentation: { spaces: 4 },\n tabWidth: 4,\n maximumBlankLines: 1,\n respectsExistingLineBreaks: true,\n lineBreakBeforeControlFlowKeywords: false,\n lineBreakBeforeEachArgument: false,\n lineBreakBeforeEachGenericRequirement: false,\n prioritizeKeepingFunctionOutputTogether: false,\n indentConditionalCompilationBlocks: true,\n lineBreakAroundMultilineExpressionChainComponents: false,\n fileScopedDeclarationPrivacy: { accessLevel: \"private\" },\n rules: {\n AllPublicDeclarationsHaveDocumentation: false,\n AlwaysUseLowerCamelCase: true,\n AmbiguousTrailingClosureOverload: true,\n BeginDocumentationCommentWithOneLineSummary: false,\n DoNotUseSemicolons: true,\n DontRepeatTypeInStaticProperties: true,\n FileScopedDeclarationPrivacy: true,\n FullyIndirectEnum: true,\n GroupNumericLiterals: true,\n IdentifiersMustBeASCII: true,\n NeverForceUnwrap: false,\n NeverUseForceTry: false,\n NeverUseImplicitlyUnwrappedOptionals: false,\n NoBlockComments: false,\n NoCasesWithOnlyFallthrough: true,\n NoEmptyTrailingClosureParentheses: true,\n NoLabelsInCasePatterns: true,\n NoLeadingUnderscores: false,\n NoParensAroundConditions: true,\n NoVoidReturnOnFunctionSignature: true,\n OneCasePerLine: true,\n OneVariableDeclarationPerLine: true,\n OnlyOneTrailingClosureArgument: true,\n OrderedImports: true,\n ReturnVoidInsteadOfEmptyTuple: true,\n UseEarlyExits: false,\n UseLetInEveryBoundCaseVariable: true,\n UseShorthandTypeNames: true,\n UseSingleLinePropertyGetter: true,\n UseSynthesizedInitializer: true,\n UseTripleSlashForDocumentationComments: true,\n UseWhereClausesInForLoops: false,\n ValidateDocumentationComments: false,\n },\n} as const;\n\n/**\n * Run swift-format against a Swift source string and return the formatted\n * output. Falls back to the original source if swift-format is unavailable.\n */\nexport async function formatSwift(\n source: string,\n options: FormatOptions = {}\n): Promise<FormatResult> {\n const available = await hasSwiftFormat();\n if (!available) {\n if (options.strict) {\n throw new Error(\n \"swift-format not found on $PATH. Install Xcode + Command Line Tools, or drop --format.\"\n );\n }\n return {\n formatted: source,\n ran: false,\n reason: \"swift-format not found on $PATH\",\n };\n }\n\n const configPath = join(\n tmpdir(),\n `axint-swift-format-${Date.now()}-${Math.random().toString(36).slice(2)}.json`\n );\n await writeFile(configPath, JSON.stringify(SWIFT_FORMAT_CONFIG, null, 2));\n\n try {\n const result = await runSwiftFormat(source, configPath, options.timeoutMs ?? 8_000);\n if (result.code === 0) {\n return { formatted: result.stdout, ran: true };\n }\n if (options.strict) {\n throw new Error(`swift-format failed: ${result.stderr}`);\n }\n return {\n formatted: source,\n ran: false,\n reason: `swift-format exited ${result.code}: ${result.stderr}`,\n };\n } finally {\n await unlink(configPath).catch(() => undefined);\n }\n}\n\nfunction hasSwiftFormat(): Promise<boolean> {\n return new Promise((resolve) => {\n const child = spawn(\"swift-format\", [\"--version\"], { stdio: \"pipe\" });\n child.on(\"error\", () => resolve(false));\n child.on(\"exit\", (code) => resolve(code === 0));\n });\n}\n\nfunction runSwiftFormat(\n source: string,\n configPath: string,\n timeoutMs: number\n): Promise<{ stdout: string; stderr: string; code: number }> {\n return new Promise((resolve) => {\n const child = spawn(\"swift-format\", [\"format\", \"--configuration\", configPath], {\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n });\n let stdout = \"\";\n let stderr = \"\";\n child.stdout?.on(\"data\", (d) => (stdout += d.toString()));\n child.stderr?.on(\"data\", (d) => (stderr += d.toString()));\n const timer = setTimeout(() => {\n child.kill(\"SIGKILL\");\n resolve({\n stdout,\n stderr: stderr + `\\n[format] killed after ${timeoutMs}ms`,\n code: 124,\n });\n }, timeoutMs);\n child.on(\"exit\", (code) => {\n clearTimeout(timer);\n resolve({ stdout, stderr, code: code ?? 1 });\n });\n child.stdin?.write(source);\n child.stdin?.end();\n });\n}\n","/**\n * Axint Eject Module\n *\n * Generates standalone Swift code that has no dependency on Axint.\n * This is useful for teams that want to verify there's no vendor lock-in\n * or for distributing intents without the compilation layer.\n *\n * The eject process:\n * 1. Compiles the TypeScript intent using the standard pipeline\n * 2. Transforms the output to remove Axint markers\n * 3. Optionally generates XCTest stubs\n * 4. Emits all files (Swift, plist, entitlements, test)\n */\n\nimport { compileSource } from \"./compiler.js\";\nimport { formatSwift } from \"./format.js\";\nimport type { IRIntent } from \"./types.js\";\n\n// ─── Public Interface ────────────────────────────────────────────────\n\nexport interface EjectOptions {\n /** Output directory for ejected files (defaults to \".\") */\n outDir?: string;\n /** Generate a basic XCTest file for the intent */\n includeTests?: boolean;\n /** Format output with swift-format (requires swift-format on PATH) */\n format?: boolean;\n}\n\nexport interface EjectResult {\n /** The primary Swift file */\n swiftFile: {\n path: string;\n content: string;\n };\n /** Optional Info.plist fragment */\n infoPlist?: {\n path: string;\n content: string;\n };\n /** Optional entitlements fragment */\n entitlements?: {\n path: string;\n content: string;\n };\n /** Optional XCTest file */\n testFile?: {\n path: string;\n content: string;\n };\n}\n\n// ─── Main Eject Function ────────────────────────────────────────────\n\n/**\n * Eject an intent from Axint, producing standalone Swift code with no\n * vendor lock-in. The resulting Swift code is production-ready and can\n * be committed directly to version control.\n *\n * @param source The TypeScript intent source\n * @param fileName Display name for diagnostics (e.g., \"intent.ts\")\n * @param options Eject options (outDir, includeTests, format)\n * @returns Ejected files\n */\nexport async function ejectIntent(\n source: string,\n fileName: string,\n options: EjectOptions = {}\n): Promise<EjectResult> {\n // 1. Compile using the standard pipeline\n const compileResult = compileSource(source, fileName, {\n validate: true,\n emitInfoPlist: true,\n emitEntitlements: true,\n });\n\n if (!compileResult.success || !compileResult.output) {\n throw new Error(\n `Compilation failed: ${compileResult.diagnostics\n .filter((d) => d.severity === \"error\")\n .map((d) => d.message)\n .join(\"; \")}`\n );\n }\n\n const { ir, swiftCode, infoPlistFragment, entitlementsFragment } = compileResult.output;\n const outDir = options.outDir ?? \".\";\n\n // 2. Transform Swift to remove Axint markers\n let ejectedSwift = transformSwiftForEject(swiftCode, ir);\n\n // 2b. Optionally run swift-format\n if (options.format) {\n const { formatted, ran } = await formatSwift(ejectedSwift);\n if (ran) ejectedSwift = formatted;\n }\n\n // 3. Construct file paths\n const intentFileName = `${ir.name}Intent.swift`;\n const swiftPath = `${outDir}/${intentFileName}`;\n const plistPath = infoPlistFragment\n ? `${outDir}/${ir.name}Intent.plist.fragment.xml`\n : null;\n const entitlementsPath = entitlementsFragment\n ? `${outDir}/${ir.name}Intent.entitlements.fragment.xml`\n : null;\n const testPath = options.includeTests ? `${outDir}/${ir.name}IntentTests.swift` : null;\n\n // 4. Build result object\n const result: EjectResult = {\n swiftFile: {\n path: swiftPath,\n content: ejectedSwift,\n },\n };\n\n if (infoPlistFragment && plistPath) {\n result.infoPlist = {\n path: plistPath,\n content: infoPlistFragment,\n };\n }\n\n if (entitlementsFragment && entitlementsPath) {\n result.entitlements = {\n path: entitlementsPath,\n content: entitlementsFragment,\n };\n }\n\n if (options.includeTests && testPath) {\n result.testFile = {\n path: testPath,\n content: generateTestFile(ir),\n };\n }\n\n return result;\n}\n\n// ─── Swift Transformation ───────────────────────────────────────────\n\n/**\n * Transform generated Swift code to be \"ejected\" — remove Axint markers,\n * update the header comment, and enhance the TODO placeholder.\n */\nfunction transformSwiftForEject(swiftCode: string, ir: IRIntent): string {\n const lines = swiftCode.split(\"\\n\");\n const result: string[] = [];\n\n let inHeader = true;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n\n // Replace header comment\n if (inHeader && line.startsWith(\"// \")) {\n if (i === 0) {\n // First line: replace with intent name\n result.push(`// ${ir.name}Intent.swift`);\n } else if (line.includes(\"Generated by Axint\")) {\n // Skip the Axint header\n result.push(\n `// Originally generated by Axint (https://github.com/agenticempire/axint)`\n );\n } else if (line.includes(\"Do not edit manually\")) {\n // Skip the regeneration instruction\n } else {\n result.push(line);\n }\n } else if (line === \"\") {\n inHeader = false;\n result.push(line);\n } else {\n inHeader = false;\n\n // Replace the TODO comment with a more helpful one\n if (line.includes(\"// TODO: Implement your intent logic here.\")) {\n result.push(` // TODO: Implement your intent logic here.`);\n result.push(` //`);\n result.push(` // For more information about App Intents, see:`);\n result.push(` // https://developer.apple.com/documentation/appintents`);\n } else {\n result.push(line);\n }\n }\n }\n\n return result.join(\"\\n\");\n}\n\n// ─── Test File Generation ───────────────────────────────────────────\n\n/**\n * Generate a basic XCTest file for the intent.\n * This provides a scaffold that users can fill in with their own tests.\n */\nfunction generateTestFile(ir: IRIntent): string {\n const lines: string[] = [];\n\n lines.push(`// ${ir.name}IntentTests.swift`);\n lines.push(`// Ejected from Axint`);\n lines.push(``);\n lines.push(`import XCTest`);\n lines.push(`import AppIntents`);\n lines.push(``);\n lines.push(`final class ${ir.name}IntentTests: XCTestCase {`);\n lines.push(``);\n lines.push(` func testIntentInitialization() throws {`);\n lines.push(` let intent = ${ir.name}Intent()`);\n lines.push(` XCTAssertEqual(${ir.name}Intent.title.stringValue, \"${ir.title}\")`);\n lines.push(` }`);\n lines.push(``);\n lines.push(` func testIntentPerform() async throws {`);\n lines.push(` let intent = ${ir.name}Intent()`);\n lines.push(` // TODO: Set up intent parameters and test perform()`);\n lines.push(` // let result = try await intent.perform()`);\n lines.push(` // XCTAssertNotNil(result)`);\n lines.push(` }`);\n lines.push(``);\n lines.push(`}`);\n lines.push(``);\n\n return lines.join(\"\\n\");\n}\n","/**\n * axint — Decorators and types for defining Apple App Intents\n *\n * The canonical way to define an App Intent in TypeScript. The axint\n * compiler parses files written against this SDK and emits a native\n * Swift `AppIntent` struct (plus optional Info.plist and entitlements\n * fragments) suitable for dropping into an Xcode project.\n *\n * @example\n * ```typescript\n * import { defineIntent, param } from \"@axintai/compiler\";\n *\n * export default defineIntent({\n * name: \"CreateEvent\",\n * title: \"Create Calendar Event\",\n * description: \"Creates a new event in the user's calendar\",\n * domain: \"productivity\",\n * entitlements: [\"com.apple.developer.siri\"],\n * infoPlistKeys: {\n * NSCalendarsUsageDescription: \"Axint needs calendar access to create events.\",\n * },\n * params: {\n * title: param.string(\"Event title\"),\n * date: param.date(\"Event date\"),\n * durationMinutes: param.int(\"Duration in minutes\", { default: 30 }),\n * allDay: param.boolean(\"Is all-day event\", { required: false }),\n * },\n * perform: async ({ title, date }) => {\n * return { success: true, id: \"evt_123\" };\n * },\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// ─── Shared Config ───────────────────────────────────────────────────\n\n/** Configuration for a single parameter. */\nexport interface ParamConfig {\n /** Display name for this parameter (auto-generated from field name if omitted). */\n title?: string;\n /** Human-readable description shown in Siri/Shortcuts. */\n description: string;\n /** Default value if the user doesn't provide one. */\n default?: unknown;\n /**\n * Whether this parameter is required. Defaults to `true`.\n * Set to `false` to make the Swift property optional (`Type?`).\n */\n required?: boolean;\n}\n\ntype ParamFactory<T extends string> = (\n description: string,\n config?: Partial<ParamConfig>\n) => { type: T; description: string } & Partial<ParamConfig>;\n\nfunction make<T extends string>(type: T): ParamFactory<T> {\n return (description, config) => ({\n type,\n description,\n ...config,\n });\n}\n\n// ─── Parameter Type Helpers ──────────────────────────────────────────\n\n/**\n * Parameter type helpers for defining intent parameters.\n *\n * Each helper maps directly to a Swift App Intents type:\n *\n * | Helper | Swift type |\n * |-------------------|-------------------------------|\n * | `param.string` | `String` |\n * | `param.int` | `Int` |\n * | `param.double` | `Double` |\n * | `param.float` | `Float` |\n * | `param.boolean` | `Bool` |\n * | `param.date` | `Date` |\n * | `param.duration` | `Measurement<UnitDuration>` |\n * | `param.url` | `URL` |\n * | `param.number` * | `Int` *(deprecated alias)* |\n *\n * @example\n * ```typescript\n * params: {\n * name: param.string(\"User's name\"),\n * age: param.int(\"Age in years\"),\n * height: param.double(\"Height in meters\"),\n * notify: param.boolean(\"Send notification\", { required: false }),\n * when: param.date(\"Scheduled date\"),\n * length: param.duration(\"How long\"),\n * link: param.url(\"Resource URL\"),\n * }\n * ```\n */\nexport const param = {\n /** String parameter → Swift `String` */\n string: make(\"string\"),\n /** 64-bit signed integer → Swift `Int` */\n int: make(\"int\"),\n /** Double-precision float → Swift `Double` */\n double: make(\"double\"),\n /** Single-precision float → Swift `Float` */\n float: make(\"float\"),\n /** Boolean parameter → Swift `Bool` */\n boolean: make(\"boolean\"),\n /** Date parameter → Swift `Date` */\n date: make(\"date\"),\n /** Duration parameter → Swift `Measurement<UnitDuration>` */\n duration: make(\"duration\"),\n /** URL parameter → Swift `URL` */\n url: make(\"url\"),\n /**\n * @deprecated Use `param.int` (or `param.double` / `param.float`) for\n * explicit Swift numeric fidelity. `param.number` is kept as an alias\n * for `param.int` to preserve v0.1.x compatibility and will be removed\n * in v1.0.0.\n */\n number: make(\"number\"),\n\n /**\n * Entity reference parameter. The entity name must match a\n * `defineEntity()` call in the same file or project.\n */\n entity: (entityName: string, description: string, config?: Partial<ParamConfig>) => ({\n type: \"entity\" as const,\n entityName,\n description,\n ...config,\n }),\n\n /**\n * Parameter with dynamic option suggestions provided at runtime\n * by a DynamicOptionsProvider. The `providerName` maps to a\n * generated Swift `DynamicOptionsProvider` struct.\n */\n dynamicOptions: (\n providerName: string,\n innerParam: ReturnType<ParamFactory<string>>\n ) => {\n const { type: innerType, description, ...rest } = innerParam;\n return {\n type: \"dynamicOptions\" as const,\n providerName,\n innerType,\n description,\n ...rest,\n };\n },\n};\n\n// ─── Intent Definition ───────────────────────────────────────────────\n\n/** The full intent definition including name, metadata, params, and perform function. */\nexport interface IntentDefinition<\n TParams extends Record<string, ReturnType<(typeof param)[keyof typeof param]>>,\n> {\n /** PascalCase name for the generated Swift struct (e.g., \"CreateEvent\"). */\n name: string;\n /** Display name shown in Siri and Shortcuts. */\n title: string;\n /** Human-readable description of what this intent does. */\n description: string;\n /**\n * Apple App Intent Domain for categorization.\n * Common values: \"messaging\", \"productivity\", \"finance\", \"health\",\n * \"commerce\", \"media\", \"navigation\", \"smart-home\"\n */\n domain?: string;\n /** Siri/Shortcuts category for discoverability. */\n category?: string;\n /**\n * Entitlements required by this intent.\n * Example: `[\"com.apple.developer.siri\", \"com.apple.developer.healthkit\"]`\n * The compiler can emit a matching `.entitlements` fragment.\n */\n entitlements?: string[];\n /**\n * Info.plist keys required by this intent, mapped to their usage\n * description strings.\n * Example: `{ NSCalendarsUsageDescription: \"We need calendar access\" }`\n */\n infoPlistKeys?: Record<string, string>;\n /** Whether the intent should be exposed to Spotlight indexing. */\n isDiscoverable?: boolean;\n /** Parameter definitions using `param.*` helpers. */\n params: TParams;\n /**\n * The perform function (used for local testing/type-checking).\n * Note: The compiler generates a placeholder `perform()` in Swift —\n * you'll implement the actual logic in your Xcode project.\n */\n perform: (params: {\n [K in keyof TParams]: unknown;\n }) => Promise<unknown>;\n}\n\n/**\n * Define an Apple App Intent for compilation to Swift.\n *\n * This is the main entry point for the Axint SDK. The returned definition\n * is parsed by the Axint compiler and transformed into a native Swift\n * `AppIntent` struct.\n *\n * @param config - The intent definition\n * @returns The same config (identity function for type inference)\n *\n * @example\n * ```typescript\n * export default defineIntent({\n * name: \"SendMessage\",\n * title: \"Send Message\",\n * description: \"Sends a message to a contact\",\n * domain: \"messaging\",\n * params: {\n * recipient: param.string(\"Who to send the message to\"),\n * body: param.string(\"The message content\"),\n * },\n * perform: async ({ recipient, body }) => {\n * return { sent: true };\n * },\n * });\n * ```\n */\nexport function defineIntent<\n TParams extends Record<string, ReturnType<(typeof param)[keyof typeof param]>>,\n>(config: IntentDefinition<TParams>): IntentDefinition<TParams> {\n return config;\n}\n\n// ─── Entity Definition ──────────────────────────────────────────────\n\n/** Display representation mapping for an entity. */\nexport interface EntityDisplay {\n title: string;\n subtitle?: string;\n image?: string;\n}\n\n/** The full entity definition for generating an AppEntity struct. */\nexport interface EntityDefinition {\n /** PascalCase name for the generated Swift struct. */\n name: string;\n /** How the entity is displayed in Siri/Shortcuts. */\n display: EntityDisplay;\n /** Entity properties using `param.*` helpers. */\n properties: Record<string, ReturnType<(typeof param)[keyof typeof param]>>;\n /** Query type: \"string\" for StringQuery, \"property\" for PropertyQuery. */\n query?: \"string\" | \"property\";\n}\n\n/**\n * Define an Apple AppEntity for compilation to Swift.\n *\n * Generates a Swift `AppEntity` struct with `EntityQuery` conformance,\n * display representation, and typed properties.\n *\n * @param config - The entity definition\n * @returns The same config (identity function for type inference)\n */\nexport function defineEntity(config: EntityDefinition): EntityDefinition {\n return config;\n}\n"],"mappings":";AAaA,SAAS,oBAAoB;;;ACE7B,OAAO,QAAQ;;;AC2HR,IAAM,cAA4C,oBAAI,IAAqB;AAAA,EAChF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,uBAAwD;AAAA,EACnE,QAAQ;AACV;AAIO,IAAM,iBAAkD;AAAA,EAC7D,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,UAAU;AAAA,EACV,KAAK;AACP;AAKO,SAAS,cAAc,MAAsB;AAClD,UAAQ,KAAK,MAAM;AAAA,IACjB,KAAK;AACH,aAAO,eAAe,KAAK,KAAK;AAAA,IAClC,KAAK;AACH,aAAO,IAAI,cAAc,KAAK,WAAW,CAAC;AAAA,IAC5C,KAAK;AACH,aAAO,GAAG,cAAc,KAAK,SAAS,CAAC;AAAA,IACzC,KAAK;AACH,aAAO,KAAK;AAAA,IACd,KAAK;AACH,aAAO,GAAG,KAAK,UAAU;AAAA,IAC3B,KAAK;AACH,aAAO,yBAAyB,cAAc,KAAK,SAAS,CAAC;AAAA,IAC/D,KAAK;AACH,aAAO,KAAK;AAAA,EAChB;AACF;;;ADhKO,SAAS,kBACd,QACA,WAAmB,WACT;AACV,QAAM,aAAa,GAAG;AAAA,IACpB;AAAA,IACA;AAAA,IACA,GAAG,aAAa;AAAA,IAChB;AAAA;AAAA,IACA,GAAG,WAAW;AAAA,EAChB;AAGA,QAA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