@axintai/compiler 0.2.1
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/LICENSE +190 -0
- package/README.md +319 -0
- package/dist/cli/index.js +868 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/index.d.ts +233 -0
- package/dist/core/index.js +776 -0
- package/dist/core/index.js.map +1 -0
- package/dist/mcp/index.d.ts +18 -0
- package/dist/mcp/index.js +1320 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/sdk/index.d.ts +179 -0
- package/dist/sdk/index.js +41 -0
- package/dist/sdk/index.js.map +1 -0
- package/package.json +101 -0
|
@@ -0,0 +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(\"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;;;AC8FR,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,KAAK;AAAA,EAChB;AACF;;;ADjIO,SAAS,kBACd,QACA,WAAmB,WACT;AACV,QAAM,aAAa,GAAG;AAAA,IACpB;AAAA,IACA;AAAA,IACA,GAAG,aAAa;AAAA,IAChB;AAAA;AAAA,IACA,GAAG,WAAW;AAAA,EAChB;AAEA,QAAM,mBAAmB,qBAAqB,UAAU;AACxD,MAAI,CAAC,kBAAkB;AACrB,UAAM,IAAI;AAAA,MACR;AAAA,MACA,mCAAmC,QAAQ;AAAA,MAC3C;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,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AAED,QAAM,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"]}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* axint — Decorators and types for defining Apple App Intents
|
|
3
|
+
*
|
|
4
|
+
* The canonical way to define an App Intent in TypeScript. The axint
|
|
5
|
+
* compiler parses files written against this SDK and emits a native
|
|
6
|
+
* Swift `AppIntent` struct (plus optional Info.plist and entitlements
|
|
7
|
+
* fragments) suitable for dropping into an Xcode project.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { defineIntent, param } from "axint";
|
|
12
|
+
*
|
|
13
|
+
* export default defineIntent({
|
|
14
|
+
* name: "CreateEvent",
|
|
15
|
+
* title: "Create Calendar Event",
|
|
16
|
+
* description: "Creates a new event in the user's calendar",
|
|
17
|
+
* domain: "productivity",
|
|
18
|
+
* entitlements: ["com.apple.developer.siri"],
|
|
19
|
+
* infoPlistKeys: {
|
|
20
|
+
* NSCalendarsUsageDescription: "Axint needs calendar access to create events.",
|
|
21
|
+
* },
|
|
22
|
+
* params: {
|
|
23
|
+
* title: param.string("Event title"),
|
|
24
|
+
* date: param.date("Event date"),
|
|
25
|
+
* durationMinutes: param.int("Duration in minutes", { default: 30 }),
|
|
26
|
+
* allDay: param.boolean("Is all-day event", { required: false }),
|
|
27
|
+
* },
|
|
28
|
+
* perform: async ({ title, date }) => {
|
|
29
|
+
* return { success: true, id: "evt_123" };
|
|
30
|
+
* },
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @packageDocumentation
|
|
35
|
+
*/
|
|
36
|
+
/** Configuration for a single parameter. */
|
|
37
|
+
interface ParamConfig {
|
|
38
|
+
/** Display name for this parameter (auto-generated from field name if omitted). */
|
|
39
|
+
title?: string;
|
|
40
|
+
/** Human-readable description shown in Siri/Shortcuts. */
|
|
41
|
+
description: string;
|
|
42
|
+
/** Default value if the user doesn't provide one. */
|
|
43
|
+
default?: unknown;
|
|
44
|
+
/**
|
|
45
|
+
* Whether this parameter is required. Defaults to `true`.
|
|
46
|
+
* Set to `false` to make the Swift property optional (`Type?`).
|
|
47
|
+
*/
|
|
48
|
+
required?: boolean;
|
|
49
|
+
}
|
|
50
|
+
type ParamFactory<T extends string> = (description: string, config?: Partial<ParamConfig>) => {
|
|
51
|
+
type: T;
|
|
52
|
+
description: string;
|
|
53
|
+
} & Partial<ParamConfig>;
|
|
54
|
+
/**
|
|
55
|
+
* Parameter type helpers for defining intent parameters.
|
|
56
|
+
*
|
|
57
|
+
* Each helper maps directly to a Swift App Intents type:
|
|
58
|
+
*
|
|
59
|
+
* | Helper | Swift type |
|
|
60
|
+
* |-------------------|-------------------------------|
|
|
61
|
+
* | `param.string` | `String` |
|
|
62
|
+
* | `param.int` | `Int` |
|
|
63
|
+
* | `param.double` | `Double` |
|
|
64
|
+
* | `param.float` | `Float` |
|
|
65
|
+
* | `param.boolean` | `Bool` |
|
|
66
|
+
* | `param.date` | `Date` |
|
|
67
|
+
* | `param.duration` | `Measurement<UnitDuration>` |
|
|
68
|
+
* | `param.url` | `URL` |
|
|
69
|
+
* | `param.number` * | `Int` *(deprecated alias)* |
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* params: {
|
|
74
|
+
* name: param.string("User's name"),
|
|
75
|
+
* age: param.int("Age in years"),
|
|
76
|
+
* height: param.double("Height in meters"),
|
|
77
|
+
* notify: param.boolean("Send notification", { required: false }),
|
|
78
|
+
* when: param.date("Scheduled date"),
|
|
79
|
+
* length: param.duration("How long"),
|
|
80
|
+
* link: param.url("Resource URL"),
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
declare const param: {
|
|
85
|
+
/** String parameter → Swift `String` */
|
|
86
|
+
string: ParamFactory<"string">;
|
|
87
|
+
/** 64-bit signed integer → Swift `Int` */
|
|
88
|
+
int: ParamFactory<"int">;
|
|
89
|
+
/** Double-precision float → Swift `Double` */
|
|
90
|
+
double: ParamFactory<"double">;
|
|
91
|
+
/** Single-precision float → Swift `Float` */
|
|
92
|
+
float: ParamFactory<"float">;
|
|
93
|
+
/** Boolean parameter → Swift `Bool` */
|
|
94
|
+
boolean: ParamFactory<"boolean">;
|
|
95
|
+
/** Date parameter → Swift `Date` */
|
|
96
|
+
date: ParamFactory<"date">;
|
|
97
|
+
/** Duration parameter → Swift `Measurement<UnitDuration>` */
|
|
98
|
+
duration: ParamFactory<"duration">;
|
|
99
|
+
/** URL parameter → Swift `URL` */
|
|
100
|
+
url: ParamFactory<"url">;
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated Use `param.int` (or `param.double` / `param.float`) for
|
|
103
|
+
* explicit Swift numeric fidelity. `param.number` is kept as an alias
|
|
104
|
+
* for `param.int` to preserve v0.1.x compatibility and will be removed
|
|
105
|
+
* in v1.0.0.
|
|
106
|
+
*/
|
|
107
|
+
number: ParamFactory<"number">;
|
|
108
|
+
};
|
|
109
|
+
/** The full intent definition including name, metadata, params, and perform function. */
|
|
110
|
+
interface IntentDefinition<TParams extends Record<string, ReturnType<(typeof param)[keyof typeof param]>>> {
|
|
111
|
+
/** PascalCase name for the generated Swift struct (e.g., "CreateEvent"). */
|
|
112
|
+
name: string;
|
|
113
|
+
/** Display name shown in Siri and Shortcuts. */
|
|
114
|
+
title: string;
|
|
115
|
+
/** Human-readable description of what this intent does. */
|
|
116
|
+
description: string;
|
|
117
|
+
/**
|
|
118
|
+
* Apple App Intent Domain for categorization.
|
|
119
|
+
* Common values: "messaging", "productivity", "finance", "health",
|
|
120
|
+
* "commerce", "media", "navigation", "smart-home"
|
|
121
|
+
*/
|
|
122
|
+
domain?: string;
|
|
123
|
+
/** Siri/Shortcuts category for discoverability. */
|
|
124
|
+
category?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Entitlements required by this intent.
|
|
127
|
+
* Example: `["com.apple.developer.siri", "com.apple.developer.healthkit"]`
|
|
128
|
+
* The compiler can emit a matching `.entitlements` fragment.
|
|
129
|
+
*/
|
|
130
|
+
entitlements?: string[];
|
|
131
|
+
/**
|
|
132
|
+
* Info.plist keys required by this intent, mapped to their usage
|
|
133
|
+
* description strings.
|
|
134
|
+
* Example: `{ NSCalendarsUsageDescription: "We need calendar access" }`
|
|
135
|
+
*/
|
|
136
|
+
infoPlistKeys?: Record<string, string>;
|
|
137
|
+
/** Whether the intent should be exposed to Spotlight indexing. */
|
|
138
|
+
isDiscoverable?: boolean;
|
|
139
|
+
/** Parameter definitions using `param.*` helpers. */
|
|
140
|
+
params: TParams;
|
|
141
|
+
/**
|
|
142
|
+
* The perform function (used for local testing/type-checking).
|
|
143
|
+
* Note: The compiler generates a placeholder `perform()` in Swift —
|
|
144
|
+
* you'll implement the actual logic in your Xcode project.
|
|
145
|
+
*/
|
|
146
|
+
perform: (params: {
|
|
147
|
+
[K in keyof TParams]: unknown;
|
|
148
|
+
}) => Promise<unknown>;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Define an Apple App Intent for compilation to Swift.
|
|
152
|
+
*
|
|
153
|
+
* This is the main entry point for the Axint SDK. The returned definition
|
|
154
|
+
* is parsed by the Axint compiler and transformed into a native Swift
|
|
155
|
+
* `AppIntent` struct.
|
|
156
|
+
*
|
|
157
|
+
* @param config - The intent definition
|
|
158
|
+
* @returns The same config (identity function for type inference)
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* export default defineIntent({
|
|
163
|
+
* name: "SendMessage",
|
|
164
|
+
* title: "Send Message",
|
|
165
|
+
* description: "Sends a message to a contact",
|
|
166
|
+
* domain: "messaging",
|
|
167
|
+
* params: {
|
|
168
|
+
* recipient: param.string("Who to send the message to"),
|
|
169
|
+
* body: param.string("The message content"),
|
|
170
|
+
* },
|
|
171
|
+
* perform: async ({ recipient, body }) => {
|
|
172
|
+
* return { sent: true };
|
|
173
|
+
* },
|
|
174
|
+
* });
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
declare function defineIntent<TParams extends Record<string, ReturnType<(typeof param)[keyof typeof param]>>>(config: IntentDefinition<TParams>): IntentDefinition<TParams>;
|
|
178
|
+
|
|
179
|
+
export { type IntentDefinition, type ParamConfig, defineIntent, param };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/sdk/index.ts
|
|
2
|
+
function make(type) {
|
|
3
|
+
return (description, config) => ({
|
|
4
|
+
type,
|
|
5
|
+
description,
|
|
6
|
+
...config
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
var param = {
|
|
10
|
+
/** String parameter → Swift `String` */
|
|
11
|
+
string: make("string"),
|
|
12
|
+
/** 64-bit signed integer → Swift `Int` */
|
|
13
|
+
int: make("int"),
|
|
14
|
+
/** Double-precision float → Swift `Double` */
|
|
15
|
+
double: make("double"),
|
|
16
|
+
/** Single-precision float → Swift `Float` */
|
|
17
|
+
float: make("float"),
|
|
18
|
+
/** Boolean parameter → Swift `Bool` */
|
|
19
|
+
boolean: make("boolean"),
|
|
20
|
+
/** Date parameter → Swift `Date` */
|
|
21
|
+
date: make("date"),
|
|
22
|
+
/** Duration parameter → Swift `Measurement<UnitDuration>` */
|
|
23
|
+
duration: make("duration"),
|
|
24
|
+
/** URL parameter → Swift `URL` */
|
|
25
|
+
url: make("url"),
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use `param.int` (or `param.double` / `param.float`) for
|
|
28
|
+
* explicit Swift numeric fidelity. `param.number` is kept as an alias
|
|
29
|
+
* for `param.int` to preserve v0.1.x compatibility and will be removed
|
|
30
|
+
* in v1.0.0.
|
|
31
|
+
*/
|
|
32
|
+
number: make("number")
|
|
33
|
+
};
|
|
34
|
+
function defineIntent(config) {
|
|
35
|
+
return config;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
defineIntent,
|
|
39
|
+
param
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/sdk/index.ts"],"sourcesContent":["/**\n * axint — Decorators and types for defining Apple App Intents\n *\n * The canonical way to define an App Intent in TypeScript. The axint\n * compiler parses files written against this SDK and emits a native\n * Swift `AppIntent` struct (plus optional Info.plist and entitlements\n * fragments) suitable for dropping into an Xcode project.\n *\n * @example\n * ```typescript\n * import { defineIntent, param } from \"axint\";\n *\n * export default defineIntent({\n * name: \"CreateEvent\",\n * title: \"Create Calendar Event\",\n * description: \"Creates a new event in the user's calendar\",\n * domain: \"productivity\",\n * entitlements: [\"com.apple.developer.siri\"],\n * infoPlistKeys: {\n * NSCalendarsUsageDescription: \"Axint needs calendar access to create events.\",\n * },\n * params: {\n * title: param.string(\"Event title\"),\n * date: param.date(\"Event date\"),\n * durationMinutes: param.int(\"Duration in minutes\", { default: 30 }),\n * allDay: param.boolean(\"Is all-day event\", { required: false }),\n * },\n * perform: async ({ title, date }) => {\n * return { success: true, id: \"evt_123\" };\n * },\n * });\n * ```\n *\n * @packageDocumentation\n */\n\n// ─── Shared Config ───────────────────────────────────────────────────\n\n/** Configuration for a single parameter. */\nexport interface ParamConfig {\n /** Display name for this parameter (auto-generated from field name if omitted). */\n title?: string;\n /** Human-readable description shown in Siri/Shortcuts. */\n description: string;\n /** Default value if the user doesn't provide one. */\n default?: unknown;\n /**\n * Whether this parameter is required. Defaults to `true`.\n * Set to `false` to make the Swift property optional (`Type?`).\n */\n required?: boolean;\n}\n\ntype ParamFactory<T extends string> = (\n description: string,\n config?: Partial<ParamConfig>\n) => { type: T; description: string } & Partial<ParamConfig>;\n\nfunction make<T extends string>(type: T): ParamFactory<T> {\n return (description, config) => ({\n type,\n description,\n ...config,\n });\n}\n\n// ─── Parameter Type Helpers ──────────────────────────────────────────\n\n/**\n * Parameter type helpers for defining intent parameters.\n *\n * Each helper maps directly to a Swift App Intents type:\n *\n * | Helper | Swift type |\n * |-------------------|-------------------------------|\n * | `param.string` | `String` |\n * | `param.int` | `Int` |\n * | `param.double` | `Double` |\n * | `param.float` | `Float` |\n * | `param.boolean` | `Bool` |\n * | `param.date` | `Date` |\n * | `param.duration` | `Measurement<UnitDuration>` |\n * | `param.url` | `URL` |\n * | `param.number` * | `Int` *(deprecated alias)* |\n *\n * @example\n * ```typescript\n * params: {\n * name: param.string(\"User's name\"),\n * age: param.int(\"Age in years\"),\n * height: param.double(\"Height in meters\"),\n * notify: param.boolean(\"Send notification\", { required: false }),\n * when: param.date(\"Scheduled date\"),\n * length: param.duration(\"How long\"),\n * link: param.url(\"Resource URL\"),\n * }\n * ```\n */\nexport const param = {\n /** String parameter → Swift `String` */\n string: make(\"string\"),\n /** 64-bit signed integer → Swift `Int` */\n int: make(\"int\"),\n /** Double-precision float → Swift `Double` */\n double: make(\"double\"),\n /** Single-precision float → Swift `Float` */\n float: make(\"float\"),\n /** Boolean parameter → Swift `Bool` */\n boolean: make(\"boolean\"),\n /** Date parameter → Swift `Date` */\n date: make(\"date\"),\n /** Duration parameter → Swift `Measurement<UnitDuration>` */\n duration: make(\"duration\"),\n /** URL parameter → Swift `URL` */\n url: make(\"url\"),\n /**\n * @deprecated Use `param.int` (or `param.double` / `param.float`) for\n * explicit Swift numeric fidelity. `param.number` is kept as an alias\n * for `param.int` to preserve v0.1.x compatibility and will be removed\n * in v1.0.0.\n */\n number: make(\"number\"),\n};\n\n// ─── Intent Definition ───────────────────────────────────────────────\n\n/** The full intent definition including name, metadata, params, and perform function. */\nexport interface IntentDefinition<\n TParams extends Record<string, ReturnType<(typeof param)[keyof typeof param]>>,\n> {\n /** PascalCase name for the generated Swift struct (e.g., \"CreateEvent\"). */\n name: string;\n /** Display name shown in Siri and Shortcuts. */\n title: string;\n /** Human-readable description of what this intent does. */\n description: string;\n /**\n * Apple App Intent Domain for categorization.\n * Common values: \"messaging\", \"productivity\", \"finance\", \"health\",\n * \"commerce\", \"media\", \"navigation\", \"smart-home\"\n */\n domain?: string;\n /** Siri/Shortcuts category for discoverability. */\n category?: string;\n /**\n * Entitlements required by this intent.\n * Example: `[\"com.apple.developer.siri\", \"com.apple.developer.healthkit\"]`\n * The compiler can emit a matching `.entitlements` fragment.\n */\n entitlements?: string[];\n /**\n * Info.plist keys required by this intent, mapped to their usage\n * description strings.\n * Example: `{ NSCalendarsUsageDescription: \"We need calendar access\" }`\n */\n infoPlistKeys?: Record<string, string>;\n /** Whether the intent should be exposed to Spotlight indexing. */\n isDiscoverable?: boolean;\n /** Parameter definitions using `param.*` helpers. */\n params: TParams;\n /**\n * The perform function (used for local testing/type-checking).\n * Note: The compiler generates a placeholder `perform()` in Swift —\n * you'll implement the actual logic in your Xcode project.\n */\n perform: (params: {\n [K in keyof TParams]: unknown;\n }) => Promise<unknown>;\n}\n\n/**\n * Define an Apple App Intent for compilation to Swift.\n *\n * This is the main entry point for the Axint SDK. The returned definition\n * is parsed by the Axint compiler and transformed into a native Swift\n * `AppIntent` struct.\n *\n * @param config - The intent definition\n * @returns The same config (identity function for type inference)\n *\n * @example\n * ```typescript\n * export default defineIntent({\n * name: \"SendMessage\",\n * title: \"Send Message\",\n * description: \"Sends a message to a contact\",\n * domain: \"messaging\",\n * params: {\n * recipient: param.string(\"Who to send the message to\"),\n * body: param.string(\"The message content\"),\n * },\n * perform: async ({ recipient, body }) => {\n * return { sent: true };\n * },\n * });\n * ```\n */\nexport function defineIntent<\n TParams extends Record<string, ReturnType<(typeof param)[keyof typeof param]>>,\n>(config: IntentDefinition<TParams>): IntentDefinition<TParams> {\n return config;\n}\n"],"mappings":";AA0DA,SAAS,KAAuB,MAA0B;AACxD,SAAO,CAAC,aAAa,YAAY;AAAA,IAC/B;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL;AACF;AAkCO,IAAM,QAAQ;AAAA;AAAA,EAEnB,QAAQ,KAAK,QAAQ;AAAA;AAAA,EAErB,KAAK,KAAK,KAAK;AAAA;AAAA,EAEf,QAAQ,KAAK,QAAQ;AAAA;AAAA,EAErB,OAAO,KAAK,OAAO;AAAA;AAAA,EAEnB,SAAS,KAAK,SAAS;AAAA;AAAA,EAEvB,MAAM,KAAK,MAAM;AAAA;AAAA,EAEjB,UAAU,KAAK,UAAU;AAAA;AAAA,EAEzB,KAAK,KAAK,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOf,QAAQ,KAAK,QAAQ;AACvB;AA2EO,SAAS,aAEd,QAA8D;AAC9D,SAAO;AACT;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@axintai/compiler",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"type": "module",
|
|
8
|
+
"description": "The open-source compiler that transforms AI agent definitions into native Apple App Intents. TypeScript in, Swift out.",
|
|
9
|
+
"author": "Agentic Empire <hello@axint.ai>",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"homepage": "https://axint.ai",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/agenticempire/axint.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/agenticempire/axint/issues"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"compiler",
|
|
21
|
+
"apple-intents",
|
|
22
|
+
"app-intents",
|
|
23
|
+
"swift",
|
|
24
|
+
"siri",
|
|
25
|
+
"shortcuts",
|
|
26
|
+
"ai-agents",
|
|
27
|
+
"mcp",
|
|
28
|
+
"code-generation",
|
|
29
|
+
"typescript",
|
|
30
|
+
"developer-tools"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=22"
|
|
34
|
+
},
|
|
35
|
+
"bin": {
|
|
36
|
+
"axint": "./dist/cli/index.js",
|
|
37
|
+
"axint-mcp": "./dist/mcp/index.js"
|
|
38
|
+
},
|
|
39
|
+
"main": "./dist/core/index.js",
|
|
40
|
+
"types": "./dist/core/index.d.ts",
|
|
41
|
+
"exports": {
|
|
42
|
+
".": {
|
|
43
|
+
"import": "./dist/core/index.js",
|
|
44
|
+
"types": "./dist/core/index.d.ts"
|
|
45
|
+
},
|
|
46
|
+
"./sdk": {
|
|
47
|
+
"import": "./dist/sdk/index.js",
|
|
48
|
+
"types": "./dist/sdk/index.d.ts"
|
|
49
|
+
},
|
|
50
|
+
"./mcp": {
|
|
51
|
+
"import": "./dist/mcp/index.js",
|
|
52
|
+
"types": "./dist/mcp/index.d.ts"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"dist",
|
|
57
|
+
"README.md",
|
|
58
|
+
"LICENSE"
|
|
59
|
+
],
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "tsup",
|
|
62
|
+
"dev": "tsx src/cli/index.ts",
|
|
63
|
+
"test": "vitest run",
|
|
64
|
+
"test:watch": "vitest",
|
|
65
|
+
"test:coverage": "vitest run --coverage",
|
|
66
|
+
"lint": "eslint src/ tests/",
|
|
67
|
+
"format": "prettier --write .",
|
|
68
|
+
"typecheck": "tsc --noEmit",
|
|
69
|
+
"clean": "rm -rf dist",
|
|
70
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
71
|
+
"prepare": "husky"
|
|
72
|
+
},
|
|
73
|
+
"lint-staged": {
|
|
74
|
+
"src/**/*.ts": [
|
|
75
|
+
"eslint --fix",
|
|
76
|
+
"prettier --write"
|
|
77
|
+
],
|
|
78
|
+
"tests/**/*.ts": [
|
|
79
|
+
"eslint --fix",
|
|
80
|
+
"prettier --write"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@types/node": "^22.0.0",
|
|
85
|
+
"@eslint/js": "^9.0.0",
|
|
86
|
+
"eslint": "^9.0.0",
|
|
87
|
+
"typescript-eslint": "^8.0.0",
|
|
88
|
+
"prettier": "^3.5.0",
|
|
89
|
+
"tsup": "^8.5.0",
|
|
90
|
+
"tsx": "^4.19.0",
|
|
91
|
+
"@vitest/coverage-v8": "^3.1.0",
|
|
92
|
+
"husky": "^9.0.0",
|
|
93
|
+
"lint-staged": "^15.0.0",
|
|
94
|
+
"vitest": "^3.1.0"
|
|
95
|
+
},
|
|
96
|
+
"dependencies": {
|
|
97
|
+
"@modelcontextprotocol/sdk": "^1.9.0",
|
|
98
|
+
"commander": "^13.1.0",
|
|
99
|
+
"typescript": "^5.7.0"
|
|
100
|
+
}
|
|
101
|
+
}
|