Intent

Intent language · 1.0

Specify the system. Discard the code.

A language for what should exist. The compiler writes APIs, stores, and clients. Parsing stays deterministic.

npm install -g @intent-lang/cli

examples/notifications/app.intent

INT 0.1

intent version "0.1"
application Notifications {    actor User    actor Operator    enum Channel { Email Sms Push }
    resource Message {        fields { id UUID channel Channel }        permissions {            User -> read            Operator -> create        }        behavior {            send {                action { create Message }                emit { MessageSent }            }        }    }}

generated/notifications

8 files

  • openapi.yamlcontract
  • sql/schema.sqlstore
  • src/server.tsapi
  • backends/python/app.pyapi
  • backends/go/main.goapi
  • web/react/App.tsxclient
  • mobile/flutter/lib/screen.dartclient
  • docker-compose.ymlrun
  1. 01

    Write

    Actors, resources, constraints, and permissions in a .intent file.

  2. 02

    Validate

    Parser and validator are deterministic. They never call a model.

  3. 03

    Generate

    OpenAPI, SQL, TypeScript, Python, Go, and frontend shells.

  4. 04

    Replace

    Throw the generated tree away when the spec changes. Keep the spec.

Language

A first program

Notifications is the public teaching domain. The same constructs describe a shop, a ledger, or a helpdesk.

examples/notifications/app.intent
intent version "0.1"
application Notifications {
    actor User    actor Operator    actor System
    enum Channel {        Email        Sms        Push    }
    resource Message {
        fields {            id UUID            userId UUID            channel Channel            sentAt DateTime        }
        permissions {            User -> read            Operator -> create            Operator -> read            System -> create        }
        behavior {
            send {
                input {                    user User                    channel Channel                }
                validate {                    user must exist                    channel must be enabled                }
                action {                    create Message                }
                emit {                    MessageSent                }            }        }    }}
Language reference

Generate

One spec. Many artifacts.

What generate writes

openapi.yaml

Contract

paths:
  /messages:
    get:
      operationId: listMessages
    post:
      operationId: sendMessage
      x-intent-actors:
        - Operator
        - System

sql/schema.sql

Store

CREATE TABLE messages (
  id UUID PRIMARY KEY,
  user_id UUID NOT NULL,
  channel TEXT NOT NULL,
  sent_at TIMESTAMPTZ
);

src/server.ts

API

app.get("/messages",
  requireActor("User", "Operator"))
app.post("/messages",
  requireActor("Operator", "System"))
app.get("/health", ok)
app.get("/ready", ready)

clients

Frontends

web/react/App.tsx
web/angular/app.component.ts
mobile/flutter/lib/screen.dart
backends/python/app.py
backends/go/main.go