Skip to main content
Glama

面向 Apple 平台的 AI 智能体压缩层

AI 编码智能体按 Token 付费。Apple 的 API 接口(如 App Intents、SwiftUI、WidgetKit)非常冗长。在编写任何业务逻辑之前,单个小组件就需要 TimelineEntry、TimelineProvider、EntryView 和 Widget 结构体。

Axint 压缩了所有这些内容。一个 TypeScript 定义即可编译为符合惯用语法的生产级 Swift 代码,且零样板代码。Intent 可压缩约 4 倍,视图可压缩约 4 倍,小组件可压缩 13 倍

┌───────────────────────────────────────────┐
│  defineIntent()  defineView()             │  TypeScript / Python / JSON
│  defineWidget()  defineApp()              │
└───────────────────┬───────────────────────┘
                    │  axint compile
          ┌─────────┼─────────┐─────────┐
          ▼         ▼         ▼         ▼
     ┌────────┐ ┌───────┐ ┌────────┐ ┌──────┐
     │ .swift │ │ .swift│ │ .swift │ │.swift│
     │ .plist │ │       │ │        │ │      │
     │ .entl. │ │       │ │        │ │      │
     └────────┘ └───────┘ └────────┘ └──────┘
     App Intent  SwiftUI   WidgetKit   App
     for Siri    View      Widget      Scaffold

Related MCP server: xcode-mcp

为什么选择 Axint

  • 四个 Apple 界面,一个编译器。 App Intents、SwiftUI 视图、WidgetKit 小组件和完整应用脚手架均可从同一流水线编译。

  • 真正的 TypeScript AST 解析器。 使用 TypeScript 编译器 API(与 tsc 相同),而非正则表达式。提供完整的类型保真度和带有行/列跨度的诊断信息。

  • 原生支持 MCP 及 JSON 模式。 向任何 MCP 客户端公开 13 种工具。axint.schema.compile 工具接受极简 JSON(约 20 个 Token)并返回编译后的 Swift 代码 —— AI 智能体完全跳过 TypeScript,节省更多 Token。

  • 原生类型保真度。 int → Intdouble → Doubledate → Dateurl → URLduration → Measurement<UnitDuration>。默认值和可选性在端到端过程中均得到保留。

  • 150 个诊断代码 (AX000AX999),提供修复建议和彩色输出。Intent、实体、视图、小组件、应用、Swift 并发和实时活动(Live Activities)验证器均有专门的错误范围。

  • 亚毫秒级编译。 axint.ai 演练场在浏览器中运行完整编译器,无需服务器往返。

  • 500 个测试。 解析器、验证器、生成器、发射路径、视图、小组件、应用、监视模式、沙盒、MCP、Swift 并发和实时活动 —— 全部覆盖。

  • 跨语言 IR。 中间表示(IR)是语言无关的 JSON。TypeScript、Python 和原始 JSON 均可输入同一生成器。新的语言前端无需触及 Swift 发射器即可接入。

  • Apache 2.0 协议,无需 CLA。 随意分叉、扩展和发布。


快速入门

npm install -g @axint/compiler

# Or run without installing
npx @axint/compiler compile my-intent.ts --stdout

Intent

import { defineIntent, param } from "@axint/compiler";

export default defineIntent({
  name: "CreateEvent",
  title: "Create Calendar Event",
  description: "Creates a new event in the user's calendar.",
  domain: "productivity",
  params: {
    title: param.string("Event title"),
    date: param.date("Event date"),
    duration: param.duration("Event duration", { default: "1h" }),
    location: param.string("Location", { required: false }),
  },
});

View

import { defineView, prop, state, view } from "@axint/compiler";

export default defineView({
  name: "EventCard",
  props: {
    title: prop.string(),
    date: prop.date(),
  },
  state: {
    isExpanded: state.boolean(false),
  },
  body: [
    view.vstack({ alignment: "leading", spacing: 8 }, [
      view.text("entry.title"),
      view.conditional("isExpanded", [view.text("entry.date")]),
    ]),
  ],
});

Widget

import { defineWidget, entry, view } from "@axint/compiler";

export default defineWidget({
  name: "EventCountdown",
  displayName: "Event Countdown",
  description: "Shows time until the next event.",
  families: ["systemSmall", "systemMedium"],
  entry: {
    eventName: entry.string("Untitled"),
    minutesUntil: entry.int(0),
  },
  body: [
    view.vstack({ alignment: "center", spacing: 4 }, [
      view.text("entry.eventName"),
      view.text("entry.minutesUntil"),
    ]),
  ],
});

App

import { defineApp, scene, storage } from "@axint/compiler";

export default defineApp({
  name: "WeatherApp",
  scenes: [
    scene.windowGroup("WeatherDashboard"),
    scene.settings("SettingsView", { platform: "macOS" }),
  ],
  appStorage: {
    useCelsius: storage.boolean("use_celsius", true),
    lastCity: storage.string("last_city", "Cupertino"),
  },
});

编译其中任何一个:

axint compile my-intent.ts --out ios/Intents/
axint compile my-view.ts --out ios/Views/
axint compile my-widget.ts --out ios/Widgets/
axint compile my-app.ts --out ios/App/

监视模式

对于迭代开发,axint watch 会在每次保存时重新编译:

axint watch ./intents/ --out ios/Intents/ --emit-info-plist --emit-entitlements
axint watch my-intent.ts --out ios/Intents/ --format --swift-build

150ms 去抖动,内联错误显示,并在每次成功编译后可选执行 swift build


MCP 服务器

Axint 附带 axint-mcp,这是一个用于 Claude Desktop、Claude Code、Cursor、Windsurf 及任何 MCP 客户端的模型上下文协议服务器。

{
  "mcpServers": {
    "axint": {
      "command": "axint-mcp",
      "args": []
    }
  }
}

13 种工具(点号命名 —— 旧的下划线别名仍然有效):

工具

功能描述

axint.feature

根据描述生成完整的功能包

axint.suggest

为给定领域建议 Apple 原生功能

axint.scaffold

根据描述生成初始 TypeScript Intent

axint.compile

完整流水线:TypeScript → Swift + plist + 权限配置

axint.validate

带有诊断信息的预运行验证

axint.schema.compile

极简 JSON → Swift(AI 智能体的 Token 节省模式)

axint.swift.validate

根据 Axint 的构建时规则验证现有 Swift 代码

axint.swift.fix

自动修复机械性的 Swift 错误(并发、实时活动)

axint.templates.list

列出捆绑的参考模板

axint.templates.get

返回特定模板的源代码

axint.quick-start

获取 Axint 快速入门指南

axint.create-intent

根据参数创建新 Intent

axint.create-widget

根据参数创建新 Widget

Schema 模式是智能体的关键优化 —— 智能体无需生成 TypeScript 再编译,而是直接发送约 20 个 Token 的 JSON,即可直接获得编译后的 Swift 代码。


诊断信息

跨越八个验证器的 150 个诊断代码:

范围

领域

AX000AX023

编译器 / 解析器

AX100AX113

Intent

AX200AX202

Swift 输出

AX300AX322

视图

AX400AX422

小组件

AX500AX522

应用

AX700AX749

Swift 构建规则

AX720AX735

Swift 6 并发

AX740AX749

实时活动

error[AX100]: Intent name "sendMessage" must be PascalCase
  --> src/intents/messaging.ts:5:9
   = help: rename to "SendMessage"

请参阅 docs/ERRORS.md 获取完整参考。


支持的类型映射

TypeScript

Swift

默认值支持

string

String

int

Int

double

Double

float

Float

boolean

Bool

date

Date

duration

Measurement<UnitDuration>

✓ (例如 "1h")

url

URL

optional<T>

T?


在浏览器中尝试

无需安装:axint.ai/#playground 在浏览器中运行整个编译器,无需服务器往返。


要求

  • Node.js 22+

  • 任何操作系统:macOS, Linux, Windows

  • Xcode 15+(仅用于将生成的 Swift 代码发布到 Apple 平台)


项目结构

axint/
├── src/
│   ├── core/        # Parser, validator, generator, compiler, types, IR
│   ├── sdk/         # defineIntent(), defineView(), defineWidget(), param/prop/state/entry helpers
│   ├── mcp/         # MCP server (13 tools including JSON schema mode)
│   ├── cli/         # axint CLI (compile, watch, validate, eject, init, xcode)
│   └── templates/   # Intent template registry (25 templates)
├── python/          # Python SDK with native Swift codegen
├── extensions/      # Claude Code, Codex, Cursor, Windsurf, Zed, JetBrains, Xcode
├── spm-plugin/      # Xcode SPM build plugin
├── tools/           # swift-syntax helper binary (POC)
├── tests/           # 500 vitest tests
├── examples/        # Example definitions
└── docs/            # Error reference, research, assets

贡献

我们会在 48 小时内审核 PR。良好的入门方式:

  • 浏览 good first issue 问题

  • 为常见用例添加模板

  • 通过更好的修复建议改进诊断信息

请参阅 CONTRIBUTING.md。Apache 2.0 协议,无需 CLA。


路线图

请参阅 ROADMAP.md。亮点:

  • [x] 四个编译目标:intents, views, widgets, apps

  • [x] 带有 JSON schema 模式的 MCP 服务器(6 种工具)

  • [x] 91 个带有修复建议的诊断代码

  • [x] 带有 --swift-build--watch 模式

  • [x] VS Code / Cursor 扩展

  • [x] 带有原生 Swift 代码生成的 Python SDK

  • [x] 用于 Xcode 的 SPM 构建插件 + Xcode 项目插件

  • [x] 用于零依赖 Swift 输出的 axint eject

  • [x] 跨语言 IR 桥接 (TS, Python, JSON)

  • [x] defineApp() — 完整应用脚手架编译

  • [ ] defineExtension() — 应用扩展编译

  • [ ] Axint Cloud(托管编译)


许可证

Apache 2.0 — 随意分叉、扩展和发布。无需 CLA。


Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/agenticempire/axint'

If you have feedback or need assistance with the MCP directory API, please join our Discord server