@axintai/compiler 0.2.1 → 0.3.0
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/README.md +10 -9
- package/dist/cli/index.js +2332 -178
- package/dist/cli/index.js.map +1 -1
- package/dist/core/index.d.ts +125 -3
- package/dist/core/index.js +592 -42
- package/dist/core/index.js.map +1 -1
- package/dist/mcp/index.js +410 -33
- package/dist/mcp/index.js.map +1 -1
- package/dist/sdk/index.d.ts +55 -2
- package/dist/sdk/index.js +30 -1
- package/dist/sdk/index.js.map +1 -1
- package/package.json +1 -1
package/dist/mcp/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/server.ts","../../src/core/compiler.ts","../../src/core/parser.ts","../../src/core/types.ts","../../src/core/generator.ts","../../src/core/validator.ts","../../src/mcp/scaffold.ts","../../src/templates/index.ts","../../src/mcp/index.ts"],"sourcesContent":["/**\n * Axint MCP Server\n *\n * Exposes Axint capabilities as MCP tools that AI coding assistants\n * (Claude Code, Cursor, Windsurf, Zed, any MCP client) can call\n * automatically.\n *\n * Tools:\n * - axint_scaffold: Generate a starter TypeScript intent file\n * - axint_compile: Compile TypeScript intent → Swift App Intent\n * (optionally with Info.plist and entitlements)\n * - axint_validate: Validate an intent definition without codegen\n * - axint_list_templates: List bundled reference templates\n * - axint_template: Return the source of a specific template\n */\n\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { readFileSync } from \"node:fs\";\nimport { resolve, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { compileSource } from \"../core/compiler.js\";\nimport { scaffoldIntent } from \"./scaffold.js\";\nimport { TEMPLATES, getTemplate } from \"../templates/index.js\";\n\n// Read version from package.json so it stays in sync\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst pkg = JSON.parse(\n readFileSync(resolve(__dirname, \"../../package.json\"), \"utf-8\")\n);\n\ntype CompileArgs = {\n source: string;\n fileName?: string;\n emitInfoPlist?: boolean;\n emitEntitlements?: boolean;\n};\n\ntype ScaffoldArgs = {\n name: string;\n description: string;\n domain?: string;\n params?: Array<{ name: string; type: string; description: string }>;\n};\n\ntype TemplateArgs = { id: string };\n\nexport async function startMCPServer(): Promise<void> {\n const server = new Server(\n { name: \"axint\", version: pkg.version },\n { capabilities: { tools: {} } }\n );\n\n // List available tools\n server.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: [\n {\n name: \"axint_scaffold\",\n description:\n \"Generate a starter TypeScript intent file using the axint SDK. \" +\n \"Pass a PascalCase name, a description, and optionally a domain \" +\n \"(messaging, productivity, health, finance, commerce, media, \" +\n \"navigation, smart-home) and a list of parameters. Returns ready-\" +\n \"to-save source code that compiles with `axint compile`.\",\n inputSchema: {\n type: \"object\" as const,\n properties: {\n name: {\n type: \"string\",\n description: \"PascalCase name for the intent, e.g., 'CreateEvent'\",\n },\n description: {\n type: \"string\",\n description: \"Human-readable description of what the intent does\",\n },\n domain: {\n type: \"string\",\n description:\n \"Optional Apple App Intent domain (messaging, productivity, \" +\n \"health, finance, commerce, media, navigation, smart-home)\",\n },\n params: {\n type: \"array\",\n description:\n \"Optional initial parameters. Each item: { name, type, description }. \" +\n \"Supported types: string, int, double, float, boolean, date, duration, url.\",\n items: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n type: { type: \"string\" },\n description: { type: \"string\" },\n },\n required: [\"name\", \"type\", \"description\"],\n },\n },\n },\n required: [\"name\", \"description\"],\n },\n },\n {\n name: \"axint_compile\",\n description:\n \"Compile a TypeScript intent definition into a native Swift App \" +\n \"Intent. Optionally emits Info.plist and entitlements fragments \" +\n \"alongside the Swift file. Pass the full TypeScript source code \" +\n \"using the defineIntent() API.\",\n inputSchema: {\n type: \"object\" as const,\n properties: {\n source: {\n type: \"string\",\n description: \"TypeScript source code containing a defineIntent() call\",\n },\n fileName: {\n type: \"string\",\n description: \"Optional file name for error messages\",\n },\n emitInfoPlist: {\n type: \"boolean\",\n description:\n \"When true, also returns an Info.plist XML fragment for the \" +\n \"intent's declared infoPlistKeys\",\n },\n emitEntitlements: {\n type: \"boolean\",\n description:\n \"When true, also returns an .entitlements XML fragment for \" +\n \"the intent's declared entitlements\",\n },\n },\n required: [\"source\"],\n },\n },\n {\n name: \"axint_validate\",\n description:\n \"Validate a TypeScript intent definition without generating Swift \" +\n \"output. Returns diagnostics with error codes and fix suggestions.\",\n inputSchema: {\n type: \"object\" as const,\n properties: {\n source: {\n type: \"string\",\n description: \"TypeScript source code containing a defineIntent() call\",\n },\n },\n required: [\"source\"],\n },\n },\n {\n name: \"axint_list_templates\",\n description:\n \"List the bundled reference templates. Use `axint_template` to \" +\n \"fetch the full source of a specific template by id.\",\n inputSchema: {\n type: \"object\" as const,\n properties: {},\n },\n },\n {\n name: \"axint_template\",\n description:\n \"Return the full TypeScript source code of a bundled reference \" +\n \"template by id. Use `axint_list_templates` to discover valid ids.\",\n inputSchema: {\n type: \"object\" as const,\n properties: {\n id: {\n type: \"string\",\n description: \"Template id (e.g., 'send-message', 'create-event')\",\n },\n },\n required: [\"id\"],\n },\n },\n ],\n }));\n\n // Handle tool calls\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n try {\n if (name === \"axint_scaffold\") {\n const a = args as unknown as ScaffoldArgs;\n const source = scaffoldIntent({\n name: a.name,\n description: a.description,\n domain: a.domain,\n params: a.params,\n });\n return { content: [{ type: \"text\" as const, text: source }] };\n }\n\n if (name === \"axint_compile\") {\n const a = args as unknown as CompileArgs;\n const result = compileSource(a.source, a.fileName || \"<mcp>\", {\n emitInfoPlist: a.emitInfoPlist,\n emitEntitlements: a.emitEntitlements,\n });\n\n if (result.success && result.output) {\n const parts: string[] = [\n \"// ─── Swift ──────────────────────────\",\n result.output.swiftCode,\n ];\n if (result.output.infoPlistFragment) {\n parts.push(\"// ─── Info.plist fragment ────────────\");\n parts.push(result.output.infoPlistFragment);\n }\n if (result.output.entitlementsFragment) {\n parts.push(\"// ─── .entitlements fragment ─────────\");\n parts.push(result.output.entitlementsFragment);\n }\n return {\n content: [{ type: \"text\" as const, text: parts.join(\"\\n\") }],\n };\n }\n\n const errorText = result.diagnostics\n .map((d) => `[${d.code}] ${d.severity}: ${d.message}`)\n .join(\"\\n\");\n return {\n content: [{ type: \"text\" as const, text: errorText }],\n isError: true,\n };\n }\n\n if (name === \"axint_validate\") {\n const a = args as unknown as { source: string };\n const result = compileSource(a.source, \"<validate>\");\n const text =\n result.diagnostics.length > 0\n ? result.diagnostics\n .map((d) => `[${d.code}] ${d.severity}: ${d.message}`)\n .join(\"\\n\")\n : \"Valid intent definition. No issues found.\";\n return { content: [{ type: \"text\" as const, text }] };\n }\n\n if (name === \"axint_list_templates\") {\n const list = TEMPLATES.map(\n (t) => `${t.id} — ${t.title}${t.domain ? ` [${t.domain}]` : \"\"}`\n ).join(\"\\n\");\n return {\n content: [\n {\n type: \"text\" as const,\n text: list || \"No templates registered.\",\n },\n ],\n };\n }\n\n if (name === \"axint_template\") {\n const a = args as unknown as TemplateArgs;\n const tpl = getTemplate(a.id);\n if (!tpl) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Unknown template id: ${a.id}. Use axint_list_templates to see available ids.`,\n },\n ],\n isError: true,\n };\n }\n return { content: [{ type: \"text\" as const, text: tpl.source }] };\n }\n\n return {\n content: [{ type: \"text\" as const, text: `Unknown tool: ${name}` }],\n isError: true,\n };\n } catch (err: unknown) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Tool error: ${err instanceof Error ? err.message : String(err)}`,\n },\n ],\n isError: true,\n };\n }\n });\n\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","/**\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 { CompilerOutput, CompilerOptions, Diagnostic } 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 const diagnostics: Diagnostic[] = [];\n\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 // 2. 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 // 3. Generate Swift\n const swiftCode = generateSwift(ir);\n\n // 4. 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 // 5. Optional fragments\n const infoPlistFragment = options.emitInfoPlist\n ? generateInfoPlistFragment(ir)\n : undefined;\n const entitlementsFragment = options.emitEntitlements\n ? generateEntitlementsFragment(ir)\n : undefined;\n\n // 6. 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 * 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} from \"./types.js\";\nimport { PARAM_TYPES, LEGACY_PARAM_ALIASES } from \"./types.js\";\n\n/**\n * Parse a TypeScript source file containing a defineIntent() call\n * 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 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 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 };\n}\n\n// ─── AST Walkers ─────────────────────────────────────────────────────\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\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// ─── 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 } = extractParamCall(\n prop.initializer,\n filePath,\n sourceFile\n );\n\n const resolvedType = resolveParamType(typeName, filePath, sourceFile, prop);\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: { kind: \"primitive\", value: resolvedType },\n }\n : { kind: \"primitive\", value: 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}\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 const descriptionArg = expr.arguments[0];\n const configArg = expr.arguments[1];\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 as the first argument`,\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 };\n}\n\nfunction resolveParamType(\n typeName: string,\n filePath: string,\n sourceFile: ts.SourceFile,\n node: ts.Node\n): IRPrimitiveType {\n if (PARAM_TYPES.has(typeName as IRPrimitiveType)) {\n return typeName as IRPrimitiveType;\n }\n if (typeName in LEGACY_PARAM_ALIASES) {\n return LEGACY_PARAM_ALIASES[typeName];\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(\", \")}`\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: \"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/** 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}\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 \"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 } 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 */\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 // 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(intent.returnType);\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 lines.push(generatePerformReturn(intent.returnType));\n lines.push(` }`);\n lines.push(`}`);\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(\n `<!-- Info.plist fragment generated by Axint for ${intent.name}Intent -->`\n );\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(\n intent: IRIntent\n): 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 * otherwise we fall back to `some IntentResult`.\n */\nfunction generateReturnSignature(type: IRType): string {\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): string {\n const indent = \" \";\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 } 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 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 * Scaffold generator for the axint MCP server.\n *\n * Produces a ready-to-save TypeScript intent file from a small set of\n * inputs. This is the \"blank canvas\" AI assistants hit when a user says\n * \"create a new App Intent for X\" — instead of guessing, the assistant\n * calls axint_scaffold and writes the result straight to disk.\n */\n\nimport { PARAM_TYPES, LEGACY_PARAM_ALIASES, type IRPrimitiveType } from \"../core/types.js\";\n\nexport interface ScaffoldInput {\n name: string;\n description: string;\n domain?: string;\n params?: Array<{ name: string; type: string; description: string }>;\n}\n\n/**\n * Generate a starter TypeScript intent file from the given inputs.\n * The result is valid input to `axint compile` — it uses the public\n * defineIntent() / param.* API and includes a TODO in the perform body.\n */\nexport function scaffoldIntent(input: ScaffoldInput): string {\n const name = toPascalCase(input.name);\n const title = humanize(name);\n const desc = sanitize(input.description);\n const domain = input.domain ? sanitize(input.domain) : undefined;\n\n const paramLines: string[] = [];\n const destructureNames: string[] = [];\n for (const p of input.params ?? []) {\n const type = resolveType(p.type);\n const safeName = toCamelCase(p.name);\n destructureNames.push(safeName);\n paramLines.push(\n ` ${safeName}: param.${type}(${JSON.stringify(sanitize(p.description))}),`\n );\n }\n\n const paramsBlock =\n paramLines.length > 0 ? `\\n${paramLines.join(\"\\n\")}\\n ` : \"\";\n const destructure =\n destructureNames.length > 0 ? `{ ${destructureNames.join(\", \")} }` : \"_\";\n\n const lines: string[] = [];\n lines.push(`/**`);\n lines.push(` * ${name}Intent`);\n lines.push(` *`);\n lines.push(` * ${desc}`);\n lines.push(` *`);\n lines.push(` * Generated by axint_scaffold. Edit freely, then run:`);\n lines.push(` * npx axint compile src/intents/${kebab(name)}.ts`);\n lines.push(` */`);\n lines.push(`import { defineIntent, param } from \"axint\";`);\n lines.push(``);\n lines.push(`export default defineIntent({`);\n lines.push(` name: ${JSON.stringify(name)},`);\n lines.push(` title: ${JSON.stringify(title)},`);\n lines.push(` description: ${JSON.stringify(desc)},`);\n if (domain) lines.push(` domain: ${JSON.stringify(domain)},`);\n lines.push(` params: {${paramsBlock}},`);\n lines.push(` perform: async (${destructure}) => {`);\n lines.push(` // TODO: Implement ${name}`);\n lines.push(` return { success: true };`);\n lines.push(` },`);\n lines.push(`});`);\n lines.push(``);\n\n return lines.join(\"\\n\");\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────\n\nfunction resolveType(raw: string): IRPrimitiveType {\n const lc = raw.toLowerCase();\n if (PARAM_TYPES.has(lc as IRPrimitiveType)) return lc as IRPrimitiveType;\n if (lc in LEGACY_PARAM_ALIASES) return LEGACY_PARAM_ALIASES[lc];\n // Fall back to string — keeps scaffolding from throwing on unknown\n // types. Users can edit the file if they wanted something more exotic.\n return \"string\";\n}\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\nfunction toCamelCase(s: string): string {\n const pascal = toPascalCase(s);\n return pascal.charAt(0).toLowerCase() + pascal.slice(1);\n}\n\nfunction humanize(pascal: string): string {\n return pascal.replace(/([A-Z])/g, \" $1\").trim();\n}\n\nfunction kebab(pascal: string): string {\n return pascal\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/\\s+/g, \"-\")\n .toLowerCase();\n}\n\n/**\n * Keep user-provided strings safe for interpolation. We strip control\n * chars and collapse runs of whitespace — this prevents scaffold output\n * from getting garbled by rogue newlines or tabs in a description.\n */\nfunction sanitize(s: string): string {\n // eslint-disable-next-line no-control-regex\n return s.replace(/[\\x00-\\x1f\\x7f]+/g, \" \").replace(/\\s+/g, \" \").trim();\n}\n","/**\n * Intent Template Registry\n *\n * Pre-built reference templates for common App Intent patterns across\n * every major Apple domain. Each template is a complete, runnable\n * TypeScript file that compiles cleanly with `axint compile`.\n *\n * Templates are exposed through the MCP server (`axint_list_templates`,\n * `axint_template`) and the CLI (`axint new --template <id>`).\n */\n\nexport interface IntentTemplate {\n /** Unique template identifier, kebab-case */\n id: string;\n /** Short kebab/camel name (kept for backwards compat) */\n name: string;\n /** Human-readable display title */\n title: string;\n /** Apple App Intent domain */\n domain: string;\n /** Category for filtering — usually mirrors domain */\n category: string;\n /** Description of what this template generates */\n description: string;\n /** The TypeScript source template (uses defineIntent API) */\n source: string;\n}\n\n// ─── Template definitions ────────────────────────────────────────────\n\nconst sendMessage: IntentTemplate = {\n id: \"send-message\",\n name: \"send-message\",\n title: \"Send Message\",\n domain: \"messaging\",\n category: \"messaging\",\n description: \"Send a text message to a contact.\",\n source: `import { defineIntent, param } from \"axint\";\n\nexport default defineIntent({\n name: \"SendMessage\",\n title: \"Send Message\",\n description: \"Sends a message to a specified 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 // TODO: Integrate with your messaging backend\n return { sent: true };\n },\n});\n`,\n};\n\nconst createEvent: IntentTemplate = {\n id: \"create-event\",\n name: \"create-event\",\n title: \"Create Calendar Event\",\n domain: \"productivity\",\n category: \"productivity\",\n description: \"Create a calendar event with a title, date, and duration.\",\n source: `import { defineIntent, param } from \"axint\";\n\nexport 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: \"Access to your calendar 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(\"All-day event\", { required: false }),\n },\n perform: async ({ title, date }) => {\n return { eventId: \"evt_placeholder\" };\n },\n});\n`,\n};\n\nconst bookRide: IntentTemplate = {\n id: \"book-ride\",\n name: \"book-ride\",\n title: \"Book a Ride\",\n domain: \"navigation\",\n category: \"navigation\",\n description: \"Request a ride from a pickup location to a destination.\",\n source: `import { defineIntent, param } from \"axint\";\n\nexport default defineIntent({\n name: \"BookRide\",\n title: \"Book a Ride\",\n description: \"Requests a ride from a pickup location to a destination.\",\n domain: \"navigation\",\n params: {\n pickup: param.string(\"Pickup location\"),\n destination: param.string(\"Destination address\"),\n passengers: param.int(\"Number of passengers\", { default: 1 }),\n },\n perform: async ({ pickup, destination }) => {\n return { rideId: \"ride_placeholder\", eta: 300 };\n },\n});\n`,\n};\n\nconst getDirections: IntentTemplate = {\n id: \"get-directions\",\n name: \"get-directions\",\n title: \"Get Directions\",\n domain: \"navigation\",\n category: \"navigation\",\n description: \"Get turn-by-turn directions to a destination.\",\n source: `import { defineIntent, param } from \"axint\";\n\nexport default defineIntent({\n name: \"GetDirections\",\n title: \"Get Directions\",\n description: \"Returns turn-by-turn directions to a destination.\",\n domain: \"navigation\",\n params: {\n destination: param.string(\"Where to navigate to\"),\n mode: param.string(\"Travel mode (driving, walking, transit)\", {\n default: \"driving\",\n }),\n },\n perform: async ({ destination }) => {\n return { routeId: \"route_placeholder\" };\n },\n});\n`,\n};\n\nconst playTrack: IntentTemplate = {\n id: \"play-track\",\n name: \"play-track\",\n title: \"Play Track\",\n domain: \"media\",\n category: \"media\",\n description: \"Play a specific track or song.\",\n source: `import { defineIntent, param } from \"axint\";\n\nexport default defineIntent({\n name: \"PlayTrack\",\n title: \"Play Track\",\n description: \"Plays a specific track by title and artist.\",\n domain: \"media\",\n params: {\n track: param.string(\"Track title\"),\n artist: param.string(\"Artist name\", { required: false }),\n shuffle: param.boolean(\"Shuffle mode\", { required: false }),\n },\n perform: async ({ track }) => {\n return { playing: true };\n },\n});\n`,\n};\n\nconst createNote: IntentTemplate = {\n id: \"create-note\",\n name: \"create-note\",\n title: \"Create Note\",\n domain: \"productivity\",\n category: \"productivity\",\n description: \"Create a new note with a title and body.\",\n source: `import { defineIntent, param } from \"axint\";\n\nexport default defineIntent({\n name: \"CreateNote\",\n title: \"Create Note\",\n description: \"Creates a new note with a title and body.\",\n domain: \"productivity\",\n params: {\n title: param.string(\"Note title\"),\n body: param.string(\"Note body\"),\n pinned: param.boolean(\"Pin the note\", { required: false }),\n },\n perform: async ({ title, body }) => {\n return { noteId: \"note_placeholder\" };\n },\n});\n`,\n};\n\nconst logExpense: IntentTemplate = {\n id: \"log-expense\",\n name: \"log-expense\",\n title: \"Log Expense\",\n domain: \"finance\",\n category: \"finance\",\n description: \"Log a financial expense with amount, category, and note.\",\n source: `import { defineIntent, param } from \"axint\";\n\nexport default defineIntent({\n name: \"LogExpense\",\n title: \"Log Expense\",\n description: \"Logs a financial expense with amount, category, and note.\",\n domain: \"finance\",\n params: {\n amount: param.double(\"Expense amount\"),\n currency: param.string(\"ISO currency code (e.g., USD)\", {\n default: \"USD\",\n }),\n category: param.string(\"Expense category\"),\n note: param.string(\"Optional note\", { required: false }),\n },\n perform: async ({ amount, category }) => {\n return { expenseId: \"exp_placeholder\" };\n },\n});\n`,\n};\n\nconst logWorkout: IntentTemplate = {\n id: \"log-workout\",\n name: \"log-workout\",\n title: \"Log Workout\",\n domain: \"health\",\n category: \"health\",\n description: \"Log a workout with duration, type, and calories burned.\",\n source: `import { defineIntent, param } from \"axint\";\n\nexport default defineIntent({\n name: \"LogWorkout\",\n title: \"Log Workout\",\n description: \"Logs a workout with duration, type, and calories burned.\",\n domain: \"health\",\n entitlements: [\"com.apple.developer.healthkit\"],\n infoPlistKeys: {\n NSHealthShareUsageDescription: \"Read workout history to track progress.\",\n NSHealthUpdateUsageDescription: \"Save new workouts you log.\",\n },\n params: {\n type: param.string(\"Workout type (e.g., running, cycling)\"),\n duration: param.duration(\"Workout duration\"),\n calories: param.int(\"Calories burned\", { required: false }),\n },\n perform: async ({ type, duration }) => {\n return { workoutId: \"wo_placeholder\" };\n },\n});\n`,\n};\n\nconst setThermostat: IntentTemplate = {\n id: \"set-thermostat\",\n name: \"set-thermostat\",\n title: \"Set Thermostat\",\n domain: \"smart-home\",\n category: \"smart-home\",\n description: \"Set a smart-home thermostat to a target temperature.\",\n source: `import { defineIntent, param } from \"axint\";\n\nexport default defineIntent({\n name: \"SetThermostat\",\n title: \"Set Thermostat\",\n description: \"Sets a smart-home thermostat to a target temperature.\",\n domain: \"smart-home\",\n params: {\n room: param.string(\"Which room\"),\n temperature: param.double(\"Target temperature\"),\n unit: param.string(\"Temperature unit (F or C)\", { default: \"F\" }),\n },\n perform: async ({ room, temperature }) => {\n return { set: true };\n },\n});\n`,\n};\n\nconst placeOrder: IntentTemplate = {\n id: \"place-order\",\n name: \"place-order\",\n title: \"Place Order\",\n domain: \"commerce\",\n category: \"commerce\",\n description: \"Place a commerce order for a product.\",\n source: `import { defineIntent, param } from \"axint\";\n\nexport default defineIntent({\n name: \"PlaceOrder\",\n title: \"Place Order\",\n description: \"Places an order for a product.\",\n domain: \"commerce\",\n params: {\n productId: param.string(\"Product identifier\"),\n quantity: param.int(\"Quantity\", { default: 1 }),\n shippingAddress: param.string(\"Shipping address\", { required: false }),\n },\n perform: async ({ productId, quantity }) => {\n return { orderId: \"ord_placeholder\", total: 0 };\n },\n});\n`,\n};\n\n// ─── Registry ────────────────────────────────────────────────────────\n\nexport const TEMPLATES: IntentTemplate[] = [\n sendMessage,\n createEvent,\n bookRide,\n getDirections,\n playTrack,\n createNote,\n logExpense,\n logWorkout,\n setThermostat,\n placeOrder,\n];\n\n/** @deprecated Use TEMPLATES. Kept for v0.1.x import compatibility. */\nexport const templates = TEMPLATES;\n\nexport function getTemplate(id: string): IntentTemplate | undefined {\n return TEMPLATES.find((t) => t.id === id);\n}\n\nexport function listTemplates(category?: string): IntentTemplate[] {\n if (category) {\n return TEMPLATES.filter((t) => t.category === category);\n }\n return TEMPLATES;\n}\n","import { startMCPServer } from \"./server.js\";\n\nexport { startMCPServer };\n\n// When invoked directly as a binary (axint-mcp), start the server\nstartMCPServer().catch((err: Error) => {\n console.error(\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YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAChC;;;AQlSA,eAAe,EAAE,MAAM,CAAC,QAAe;AACrC,UAAQ,MAAM,+BAA+B,GAAG;AAChD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["readFileSync","toPascalCase","readFileSync"]}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/server.ts","../../src/core/compiler.ts","../../src/core/parser.ts","../../src/core/types.ts","../../src/core/generator.ts","../../src/core/validator.ts","../../src/mcp/scaffold.ts","../../src/templates/index.ts","../../src/mcp/index.ts"],"sourcesContent":["/**\n * Axint MCP Server\n *\n * Exposes Axint capabilities as MCP tools that AI coding assistants\n * (Claude Code, Cursor, Windsurf, Zed, any MCP client) can call\n * automatically.\n *\n * Tools:\n * - axint_scaffold: Generate a starter TypeScript intent file\n * - axint_compile: Compile TypeScript intent → Swift App Intent\n * (optionally with Info.plist and entitlements)\n * - axint_validate: Validate an intent definition without codegen\n * - axint_list_templates: List bundled reference templates\n * - axint_template: Return the source of a specific template\n */\n\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { readFileSync } from \"node:fs\";\nimport { resolve, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { compileSource } from \"../core/compiler.js\";\nimport { scaffoldIntent } from \"./scaffold.js\";\nimport { TEMPLATES, getTemplate } from \"../templates/index.js\";\n\n// Read version from package.json so it stays in sync\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst pkg = JSON.parse(\n readFileSync(resolve(__dirname, \"../../package.json\"), \"utf-8\")\n);\n\ntype CompileArgs = {\n source: string;\n fileName?: string;\n emitInfoPlist?: boolean;\n emitEntitlements?: boolean;\n};\n\ntype ScaffoldArgs = {\n name: string;\n description: string;\n domain?: string;\n params?: Array<{ name: string; type: string; description: string }>;\n};\n\ntype TemplateArgs = { id: string };\n\nexport async function startMCPServer(): Promise<void> {\n const server = new Server(\n { name: \"axint\", version: pkg.version },\n { capabilities: { tools: {} } }\n );\n\n // List available tools\n server.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: [\n {\n name: \"axint_scaffold\",\n description:\n \"Generate a starter TypeScript intent file using the axint SDK. \" +\n \"Pass a PascalCase name, a description, and optionally a domain \" +\n \"(messaging, productivity, health, finance, commerce, media, \" +\n \"navigation, smart-home) and a list of parameters. Returns ready-\" +\n \"to-save source code that compiles with `axint compile`.\",\n inputSchema: {\n type: \"object\" as const,\n properties: {\n name: {\n type: \"string\",\n description: \"PascalCase name for the intent, e.g., 'CreateEvent'\",\n },\n description: {\n type: \"string\",\n description: \"Human-readable description of what the intent does\",\n },\n domain: {\n type: \"string\",\n description:\n \"Optional Apple App Intent domain (messaging, productivity, \" +\n \"health, finance, commerce, media, navigation, smart-home)\",\n },\n params: {\n type: \"array\",\n description:\n \"Optional initial parameters. Each item: { name, type, description }. \" +\n \"Supported types: string, int, double, float, boolean, date, duration, url.\",\n items: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n type: { type: \"string\" },\n description: { type: \"string\" },\n },\n required: [\"name\", \"type\", \"description\"],\n },\n },\n },\n required: [\"name\", \"description\"],\n },\n },\n {\n name: \"axint_compile\",\n description:\n \"Compile a TypeScript intent definition into a native Swift App \" +\n \"Intent. Optionally emits Info.plist and entitlements fragments \" +\n \"alongside the Swift file. Pass the full TypeScript source code \" +\n \"using the defineIntent() API.\",\n inputSchema: {\n type: \"object\" as const,\n properties: {\n source: {\n type: \"string\",\n description: \"TypeScript source code containing a defineIntent() call\",\n },\n fileName: {\n type: \"string\",\n description: \"Optional file name for error messages\",\n },\n emitInfoPlist: {\n type: \"boolean\",\n description:\n \"When true, also returns an Info.plist XML fragment for the \" +\n \"intent's declared infoPlistKeys\",\n },\n emitEntitlements: {\n type: \"boolean\",\n description:\n \"When true, also returns an .entitlements XML fragment for \" +\n \"the intent's declared entitlements\",\n },\n },\n required: [\"source\"],\n },\n },\n {\n name: \"axint_validate\",\n description:\n \"Validate a TypeScript intent definition without generating Swift \" +\n \"output. Returns diagnostics with error codes and fix suggestions.\",\n inputSchema: {\n type: \"object\" as const,\n properties: {\n source: {\n type: \"string\",\n description: \"TypeScript source code containing a defineIntent() call\",\n },\n },\n required: [\"source\"],\n },\n },\n {\n name: \"axint_list_templates\",\n description:\n \"List the bundled reference templates. Use `axint_template` to \" +\n \"fetch the full source of a specific template by id.\",\n inputSchema: {\n type: \"object\" as const,\n properties: {},\n },\n },\n {\n name: \"axint_template\",\n description:\n \"Return the full TypeScript source code of a bundled reference \" +\n \"template by id. Use `axint_list_templates` to discover valid ids.\",\n inputSchema: {\n type: \"object\" as const,\n properties: {\n id: {\n type: \"string\",\n description: \"Template id (e.g., 'send-message', 'create-event')\",\n },\n },\n required: [\"id\"],\n },\n },\n ],\n }));\n\n // Handle tool calls\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params;\n\n try {\n if (name === \"axint_scaffold\") {\n const a = args as unknown as ScaffoldArgs;\n const source = scaffoldIntent({\n name: a.name,\n description: a.description,\n domain: a.domain,\n params: a.params,\n });\n return { content: [{ type: \"text\" as const, text: source }] };\n }\n\n if (name === \"axint_compile\") {\n const a = args as unknown as CompileArgs;\n const result = compileSource(a.source, a.fileName || \"<mcp>\", {\n emitInfoPlist: a.emitInfoPlist,\n emitEntitlements: a.emitEntitlements,\n });\n\n if (result.success && result.output) {\n const parts: string[] = [\n \"// ─── Swift ──────────────────────────\",\n result.output.swiftCode,\n ];\n if (result.output.infoPlistFragment) {\n parts.push(\"// ─── Info.plist fragment ────────────\");\n parts.push(result.output.infoPlistFragment);\n }\n if (result.output.entitlementsFragment) {\n parts.push(\"// ─── .entitlements fragment ─────────\");\n parts.push(result.output.entitlementsFragment);\n }\n return {\n content: [{ type: \"text\" as const, text: parts.join(\"\\n\") }],\n };\n }\n\n const errorText = result.diagnostics\n .map((d) => `[${d.code}] ${d.severity}: ${d.message}`)\n .join(\"\\n\");\n return {\n content: [{ type: \"text\" as const, text: errorText }],\n isError: true,\n };\n }\n\n if (name === \"axint_validate\") {\n const a = args as unknown as { source: string };\n const result = compileSource(a.source, \"<validate>\");\n const text =\n result.diagnostics.length > 0\n ? result.diagnostics\n .map((d) => `[${d.code}] ${d.severity}: ${d.message}`)\n .join(\"\\n\")\n : \"Valid intent definition. No issues found.\";\n return { content: [{ type: \"text\" as const, text }] };\n }\n\n if (name === \"axint_list_templates\") {\n const list = TEMPLATES.map(\n (t) => `${t.id} — ${t.title}${t.domain ? ` [${t.domain}]` : \"\"}`\n ).join(\"\\n\");\n return {\n content: [\n {\n type: \"text\" as const,\n text: list || \"No templates registered.\",\n },\n ],\n };\n }\n\n if (name === \"axint_template\") {\n const a = args as unknown as TemplateArgs;\n const tpl = getTemplate(a.id);\n if (!tpl) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Unknown template id: ${a.id}. Use axint_list_templates to see available ids.`,\n },\n ],\n isError: true,\n };\n }\n return { content: [{ type: \"text\" as const, text: tpl.source }] };\n }\n\n return {\n content: [{ type: \"text\" as const, text: `Unknown tool: ${name}` }],\n isError: true,\n };\n } catch (err: unknown) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Tool error: ${err instanceof Error ? err.message : String(err)}`,\n },\n ],\n isError: true,\n };\n }\n });\n\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","/**\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 * Scaffold generator for the axint MCP server.\n *\n * Produces a ready-to-save TypeScript intent file from a small set of\n * inputs. This is the \"blank canvas\" AI assistants hit when a user says\n * \"create a new App Intent for X\" — instead of guessing, the assistant\n * calls axint_scaffold and writes the result straight to disk.\n */\n\nimport {\n PARAM_TYPES,\n LEGACY_PARAM_ALIASES,\n type IRPrimitiveType,\n} from \"../core/types.js\";\n\nexport interface ScaffoldInput {\n name: string;\n description: string;\n domain?: string;\n params?: Array<{ name: string; type: string; description: string }>;\n}\n\n/**\n * Generate a starter TypeScript intent file from the given inputs.\n * The result is valid input to `axint compile` — it uses the public\n * defineIntent() / param.* API and includes a TODO in the perform body.\n */\nexport function scaffoldIntent(input: ScaffoldInput): string {\n const name = toPascalCase(input.name);\n const title = humanize(name);\n const desc = sanitize(input.description);\n const domain = input.domain ? sanitize(input.domain) : undefined;\n\n const paramLines: string[] = [];\n const destructureNames: string[] = [];\n for (const p of input.params ?? []) {\n const type = resolveType(p.type);\n const safeName = toCamelCase(p.name);\n destructureNames.push(safeName);\n paramLines.push(\n ` ${safeName}: param.${type}(${JSON.stringify(sanitize(p.description))}),`\n );\n }\n\n const paramsBlock = paramLines.length > 0 ? `\\n${paramLines.join(\"\\n\")}\\n ` : \"\";\n const destructure =\n destructureNames.length > 0 ? `{ ${destructureNames.join(\", \")} }` : \"_\";\n\n const lines: string[] = [];\n lines.push(`/**`);\n lines.push(` * ${name}Intent`);\n lines.push(` *`);\n lines.push(` * ${desc}`);\n lines.push(` *`);\n lines.push(` * Generated by axint_scaffold. Edit freely, then run:`);\n lines.push(` * npx axint compile src/intents/${kebab(name)}.ts`);\n lines.push(` */`);\n lines.push(`import { defineIntent, param } from \"@axintai/compiler\";`);\n lines.push(``);\n lines.push(`export default defineIntent({`);\n lines.push(` name: ${JSON.stringify(name)},`);\n lines.push(` title: ${JSON.stringify(title)},`);\n lines.push(` description: ${JSON.stringify(desc)},`);\n if (domain) lines.push(` domain: ${JSON.stringify(domain)},`);\n lines.push(` params: {${paramsBlock}},`);\n lines.push(` perform: async (${destructure}) => {`);\n lines.push(` // TODO: Implement ${name}`);\n lines.push(` return { success: true };`);\n lines.push(` },`);\n lines.push(`});`);\n lines.push(``);\n\n return lines.join(\"\\n\");\n}\n\n// ─── Helpers ─────────────────────────────────────────────────────────\n\nfunction resolveType(raw: string): IRPrimitiveType {\n const lc = raw.toLowerCase();\n if (PARAM_TYPES.has(lc as IRPrimitiveType)) return lc as IRPrimitiveType;\n if (lc in LEGACY_PARAM_ALIASES) return LEGACY_PARAM_ALIASES[lc];\n // Fall back to string — keeps scaffolding from throwing on unknown\n // types. Users can edit the file if they wanted something more exotic.\n return \"string\";\n}\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\nfunction toCamelCase(s: string): string {\n const pascal = toPascalCase(s);\n return pascal.charAt(0).toLowerCase() + pascal.slice(1);\n}\n\nfunction humanize(pascal: string): string {\n return pascal.replace(/([A-Z])/g, \" $1\").trim();\n}\n\nfunction kebab(pascal: string): string {\n return pascal\n .replace(/([a-z])([A-Z])/g, \"$1-$2\")\n .replace(/\\s+/g, \"-\")\n .toLowerCase();\n}\n\n/**\n * Keep user-provided strings safe for interpolation. We strip control\n * chars and collapse runs of whitespace — this prevents scaffold output\n * from getting garbled by rogue newlines or tabs in a description.\n */\nfunction sanitize(s: string): string {\n return s\n .replace(/[\\x00-\\x1f\\x7f]+/g, \" \") // eslint-disable-line no-control-regex\n .replace(/\\s+/g, \" \")\n .trim();\n}\n","/**\n * Intent Template Registry\n *\n * Pre-built reference templates for common App Intent patterns across\n * every major Apple domain. Each template is a complete, runnable\n * TypeScript file that compiles cleanly with `axint compile`.\n *\n * Templates are exposed through the MCP server (`axint_list_templates`,\n * `axint_template`) and the CLI (`axint new --template <id>`).\n */\n\nexport interface IntentTemplate {\n /** Unique template identifier, kebab-case */\n id: string;\n /** Short kebab/camel name (kept for backwards compat) */\n name: string;\n /** Human-readable display title */\n title: string;\n /** Apple App Intent domain */\n domain: string;\n /** Category for filtering — usually mirrors domain */\n category: string;\n /** Description of what this template generates */\n description: string;\n /** The TypeScript source template (uses defineIntent API) */\n source: string;\n}\n\n// ─── Template definitions ────────────────────────────────────────────\n\nconst sendMessage: IntentTemplate = {\n id: \"send-message\",\n name: \"send-message\",\n title: \"Send Message\",\n domain: \"messaging\",\n category: \"messaging\",\n description: \"Send a text message to a contact.\",\n source: `import { defineIntent, param } from \"@axintai/compiler\";\n\nexport default defineIntent({\n name: \"SendMessage\",\n title: \"Send Message\",\n description: \"Sends a message to a specified 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 // TODO: Integrate with your messaging backend\n return { sent: true };\n },\n});\n`,\n};\n\nconst createEvent: IntentTemplate = {\n id: \"create-event\",\n name: \"create-event\",\n title: \"Create Calendar Event\",\n domain: \"productivity\",\n category: \"productivity\",\n description: \"Create a calendar event with a title, date, and duration.\",\n source: `import { defineIntent, param } from \"@axintai/compiler\";\n\nexport 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: \"Access to your calendar 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(\"All-day event\", { required: false }),\n },\n perform: async ({ title, date }) => {\n return { eventId: \"evt_placeholder\" };\n },\n});\n`,\n};\n\nconst bookRide: IntentTemplate = {\n id: \"book-ride\",\n name: \"book-ride\",\n title: \"Book a Ride\",\n domain: \"navigation\",\n category: \"navigation\",\n description: \"Request a ride from a pickup location to a destination.\",\n source: `import { defineIntent, param } from \"@axintai/compiler\";\n\nexport default defineIntent({\n name: \"BookRide\",\n title: \"Book a Ride\",\n description: \"Requests a ride from a pickup location to a destination.\",\n domain: \"navigation\",\n params: {\n pickup: param.string(\"Pickup location\"),\n destination: param.string(\"Destination address\"),\n passengers: param.int(\"Number of passengers\", { default: 1 }),\n },\n perform: async ({ pickup, destination }) => {\n return { rideId: \"ride_placeholder\", eta: 300 };\n },\n});\n`,\n};\n\nconst getDirections: IntentTemplate = {\n id: \"get-directions\",\n name: \"get-directions\",\n title: \"Get Directions\",\n domain: \"navigation\",\n category: \"navigation\",\n description: \"Get turn-by-turn directions to a destination.\",\n source: `import { defineIntent, param } from \"@axintai/compiler\";\n\nexport default defineIntent({\n name: \"GetDirections\",\n title: \"Get Directions\",\n description: \"Returns turn-by-turn directions to a destination.\",\n domain: \"navigation\",\n params: {\n destination: param.string(\"Where to navigate to\"),\n mode: param.string(\"Travel mode (driving, walking, transit)\", {\n default: \"driving\",\n }),\n },\n perform: async ({ destination }) => {\n return { routeId: \"route_placeholder\" };\n },\n});\n`,\n};\n\nconst playTrack: IntentTemplate = {\n id: \"play-track\",\n name: \"play-track\",\n title: \"Play Track\",\n domain: \"media\",\n category: \"media\",\n description: \"Play a specific track or song.\",\n source: `import { defineIntent, param } from \"@axintai/compiler\";\n\nexport default defineIntent({\n name: \"PlayTrack\",\n title: \"Play Track\",\n description: \"Plays a specific track by title and artist.\",\n domain: \"media\",\n params: {\n track: param.string(\"Track title\"),\n artist: param.string(\"Artist name\", { required: false }),\n shuffle: param.boolean(\"Shuffle mode\", { required: false }),\n },\n perform: async ({ track }) => {\n return { playing: true };\n },\n});\n`,\n};\n\nconst createNote: IntentTemplate = {\n id: \"create-note\",\n name: \"create-note\",\n title: \"Create Note\",\n domain: \"productivity\",\n category: \"productivity\",\n description: \"Create a new note with a title and body.\",\n source: `import { defineIntent, param } from \"@axintai/compiler\";\n\nexport default defineIntent({\n name: \"CreateNote\",\n title: \"Create Note\",\n description: \"Creates a new note with a title and body.\",\n domain: \"productivity\",\n params: {\n title: param.string(\"Note title\"),\n body: param.string(\"Note body\"),\n pinned: param.boolean(\"Pin the note\", { required: false }),\n },\n perform: async ({ title, body }) => {\n return { noteId: \"note_placeholder\" };\n },\n});\n`,\n};\n\nconst logExpense: IntentTemplate = {\n id: \"log-expense\",\n name: \"log-expense\",\n title: \"Log Expense\",\n domain: \"finance\",\n category: \"finance\",\n description: \"Log a financial expense with amount, category, and note.\",\n source: `import { defineIntent, param } from \"@axintai/compiler\";\n\nexport default defineIntent({\n name: \"LogExpense\",\n title: \"Log Expense\",\n description: \"Logs a financial expense with amount, category, and note.\",\n domain: \"finance\",\n params: {\n amount: param.double(\"Expense amount\"),\n currency: param.string(\"ISO currency code (e.g., USD)\", {\n default: \"USD\",\n }),\n category: param.string(\"Expense category\"),\n note: param.string(\"Optional note\", { required: false }),\n },\n perform: async ({ amount, category }) => {\n return { expenseId: \"exp_placeholder\" };\n },\n});\n`,\n};\n\nconst logWorkout: IntentTemplate = {\n id: \"log-workout\",\n name: \"log-workout\",\n title: \"Log Workout\",\n domain: \"health\",\n category: \"health\",\n description: \"Log a workout with duration, type, and calories burned.\",\n source: `import { defineIntent, param } from \"@axintai/compiler\";\n\nexport default defineIntent({\n name: \"LogWorkout\",\n title: \"Log Workout\",\n description: \"Logs a workout with duration, type, and calories burned.\",\n domain: \"health\",\n entitlements: [\"com.apple.developer.healthkit\"],\n infoPlistKeys: {\n NSHealthShareUsageDescription: \"Read workout history to track progress.\",\n NSHealthUpdateUsageDescription: \"Save new workouts you log.\",\n },\n params: {\n type: param.string(\"Workout type (e.g., running, cycling)\"),\n duration: param.duration(\"Workout duration\"),\n calories: param.int(\"Calories burned\", { required: false }),\n },\n perform: async ({ type, duration }) => {\n return { workoutId: \"wo_placeholder\" };\n },\n});\n`,\n};\n\nconst setThermostat: IntentTemplate = {\n id: \"set-thermostat\",\n name: \"set-thermostat\",\n title: \"Set Thermostat\",\n domain: \"smart-home\",\n category: \"smart-home\",\n description: \"Set a smart-home thermostat to a target temperature.\",\n source: `import { defineIntent, param } from \"@axintai/compiler\";\n\nexport default defineIntent({\n name: \"SetThermostat\",\n title: \"Set Thermostat\",\n description: \"Sets a smart-home thermostat to a target temperature.\",\n domain: \"smart-home\",\n params: {\n room: param.string(\"Which room\"),\n temperature: param.double(\"Target temperature\"),\n unit: param.string(\"Temperature unit (F or C)\", { default: \"F\" }),\n },\n perform: async ({ room, temperature }) => {\n return { set: true };\n },\n});\n`,\n};\n\nconst placeOrder: IntentTemplate = {\n id: \"place-order\",\n name: \"place-order\",\n title: \"Place Order\",\n domain: \"commerce\",\n category: \"commerce\",\n description: \"Place a commerce order for a product.\",\n source: `import { defineIntent, param } from \"@axintai/compiler\";\n\nexport default defineIntent({\n name: \"PlaceOrder\",\n title: \"Place Order\",\n description: \"Places an order for a product.\",\n domain: \"commerce\",\n params: {\n productId: param.string(\"Product identifier\"),\n quantity: param.int(\"Quantity\", { default: 1 }),\n shippingAddress: param.string(\"Shipping address\", { required: false }),\n },\n perform: async ({ productId, quantity }) => {\n return { orderId: \"ord_placeholder\", total: 0 };\n },\n});\n`,\n};\n\nconst searchTasks: IntentTemplate = {\n id: \"search-tasks\",\n name: \"search-tasks\",\n title: \"Search Tasks\",\n domain: \"productivity\",\n category: \"productivity\",\n description: \"Search for tasks using EntityQuery with string-based search.\",\n source: `import { defineIntent, defineEntity, param } from \"@axintai/compiler\";\n\ndefineEntity({\n name: \"Task\",\n display: {\n title: \"name\",\n subtitle: \"status\",\n },\n properties: {\n id: param.string(\"Unique task identifier\"),\n name: param.string(\"Task name\"),\n status: param.string(\"Task status (todo, in-progress, done)\"),\n dueDate: param.date(\"Due date\"),\n },\n query: \"string\",\n});\n\nexport default defineIntent({\n name: \"SearchTasks\",\n title: \"Search Tasks\",\n description: \"Search for tasks by name or status.\",\n domain: \"productivity\",\n params: {\n query: param.string(\"Search query\"),\n status: param.string(\"Filter by status (optional)\", { required: false }),\n },\n donateOnPerform: true,\n perform: async ({ query, status }) => {\n // TODO: Search your task database with the query\n // Use status filter if provided\n return { found: true, results: 0 };\n },\n});\n`,\n};\n\nconst dynamicPlaylist: IntentTemplate = {\n id: \"dynamic-playlist\",\n name: \"dynamic-playlist\",\n title: \"Dynamic Playlist\",\n domain: \"media\",\n category: \"media\",\n description: \"Create a playlist by name, mood, and track count.\",\n source: `import { defineIntent, param } from \"@axintai/compiler\";\n\nexport default defineIntent({\n name: \"DynamicPlaylist\",\n title: \"Create Dynamic Playlist\",\n description: \"Create a playlist with a given mood or genre.\",\n domain: \"media\",\n params: {\n name: param.string(\"Playlist name\"),\n mood: param.string(\"Mood or genre (e.g., chill, workout, focus)\"),\n trackCount: param.int(\"Number of tracks\", { default: 20 }),\n },\n perform: async ({ name, mood }) => {\n return { playlistId: \"playlist_placeholder\" };\n },\n});\n`,\n};\n\n// ─── Registry ────────────────────────────────────────────────────────\n\nexport const TEMPLATES: IntentTemplate[] = [\n sendMessage,\n createEvent,\n bookRide,\n getDirections,\n playTrack,\n createNote,\n logExpense,\n logWorkout,\n setThermostat,\n placeOrder,\n searchTasks,\n dynamicPlaylist,\n];\n\n/** @deprecated Use TEMPLATES. Kept for v0.1.x import compatibility. */\nexport const templates = TEMPLATES;\n\nexport function getTemplate(id: string): IntentTemplate | undefined {\n return TEMPLATES.find((t) => t.id === id);\n}\n\nexport function listTemplates(category?: string): IntentTemplate[] {\n if (category) {\n return TEMPLATES.filter((t) => t.category === category);\n }\n return TEMPLATES;\n}\n","import { startMCPServer } from \"./server.js\";\n\nexport { startMCPServer };\n\n// When invoked directly as a binary (axint-mcp), start the server\nstartMCPServer().catch((err: Error) => {\n console.error(\"Failed to start MCP server:\", err);\n process.exit(1);\n});\n"],"mappings":";;;AAgBA,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAAA,qBAAoB;AAC7B,SAAS,SAAS,eAAe;AACjC,SAAS,qBAAqB;;;ACX9B,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,C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+B,GAAG;AAChD,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["readFileSync","toPascalCase","readFileSync"]}
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
|
-
* import { defineIntent, param } from "
|
|
11
|
+
* import { defineIntent, param } from "@axintai/compiler";
|
|
12
12
|
*
|
|
13
13
|
* export default defineIntent({
|
|
14
14
|
* name: "CreateEvent",
|
|
@@ -105,6 +105,32 @@ declare const param: {
|
|
|
105
105
|
* in v1.0.0.
|
|
106
106
|
*/
|
|
107
107
|
number: ParamFactory<"number">;
|
|
108
|
+
/**
|
|
109
|
+
* Entity reference parameter. The entity name must match a
|
|
110
|
+
* `defineEntity()` call in the same file or project.
|
|
111
|
+
*/
|
|
112
|
+
entity: (entityName: string, description: string, config?: Partial<ParamConfig>) => {
|
|
113
|
+
title?: string;
|
|
114
|
+
description: string;
|
|
115
|
+
default?: unknown;
|
|
116
|
+
required?: boolean;
|
|
117
|
+
type: "entity";
|
|
118
|
+
entityName: string;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Parameter with dynamic option suggestions provided at runtime
|
|
122
|
+
* by a DynamicOptionsProvider. The `providerName` maps to a
|
|
123
|
+
* generated Swift `DynamicOptionsProvider` struct.
|
|
124
|
+
*/
|
|
125
|
+
dynamicOptions: (providerName: string, innerParam: ReturnType<ParamFactory<string>>) => {
|
|
126
|
+
title?: string | undefined;
|
|
127
|
+
default?: unknown;
|
|
128
|
+
required?: boolean | undefined;
|
|
129
|
+
type: "dynamicOptions";
|
|
130
|
+
providerName: string;
|
|
131
|
+
innerType: string;
|
|
132
|
+
description: string;
|
|
133
|
+
};
|
|
108
134
|
};
|
|
109
135
|
/** The full intent definition including name, metadata, params, and perform function. */
|
|
110
136
|
interface IntentDefinition<TParams extends Record<string, ReturnType<(typeof param)[keyof typeof param]>>> {
|
|
@@ -175,5 +201,32 @@ interface IntentDefinition<TParams extends Record<string, ReturnType<(typeof par
|
|
|
175
201
|
* ```
|
|
176
202
|
*/
|
|
177
203
|
declare function defineIntent<TParams extends Record<string, ReturnType<(typeof param)[keyof typeof param]>>>(config: IntentDefinition<TParams>): IntentDefinition<TParams>;
|
|
204
|
+
/** Display representation mapping for an entity. */
|
|
205
|
+
interface EntityDisplay {
|
|
206
|
+
title: string;
|
|
207
|
+
subtitle?: string;
|
|
208
|
+
image?: string;
|
|
209
|
+
}
|
|
210
|
+
/** The full entity definition for generating an AppEntity struct. */
|
|
211
|
+
interface EntityDefinition {
|
|
212
|
+
/** PascalCase name for the generated Swift struct. */
|
|
213
|
+
name: string;
|
|
214
|
+
/** How the entity is displayed in Siri/Shortcuts. */
|
|
215
|
+
display: EntityDisplay;
|
|
216
|
+
/** Entity properties using `param.*` helpers. */
|
|
217
|
+
properties: Record<string, ReturnType<(typeof param)[keyof typeof param]>>;
|
|
218
|
+
/** Query type: "string" for StringQuery, "property" for PropertyQuery. */
|
|
219
|
+
query?: "string" | "property";
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Define an Apple AppEntity for compilation to Swift.
|
|
223
|
+
*
|
|
224
|
+
* Generates a Swift `AppEntity` struct with `EntityQuery` conformance,
|
|
225
|
+
* display representation, and typed properties.
|
|
226
|
+
*
|
|
227
|
+
* @param config - The entity definition
|
|
228
|
+
* @returns The same config (identity function for type inference)
|
|
229
|
+
*/
|
|
230
|
+
declare function defineEntity(config: EntityDefinition): EntityDefinition;
|
|
178
231
|
|
|
179
|
-
export { type IntentDefinition, type ParamConfig, defineIntent, param };
|
|
232
|
+
export { type EntityDefinition, type EntityDisplay, type IntentDefinition, type ParamConfig, defineEntity, defineIntent, param };
|