# OpenUI v0.1.1 - API Reference

## Modules

- [OpenUI](OpenUI.md): An Elixir implementation of OpenUI Lang 1.0, the language a model writes to
describe a user interface, with an optional Phoenix LiveView renderer.
- [OpenUI.Parser.Expression](OpenUI.Parser.Expression.md): Parses tokens into an expression tree (language.md, sections 1.5 and 1.6)
by precedence climbing, and classifies statements (section 2.1).
- [OpenUI.Parser.Lexer](OpenUI.Parser.Lexer.md): Turns OpenUI Lang source into tokens (language.md, section 1.3).
- [OpenUI.Parser.Source](OpenUI.Parser.Source.md): Prepares response text for parsing (language.md, section 1.2): fence
extraction, comment stripping and trimming, in that order.

- [OpenUI.Parser.Statements](OpenUI.Parser.Statements.md): Statement boundaries (language.md, section 1.4) and implicit closing
(section 4, rule 2).

- Catalog
  - [OpenUI.Library](OpenUI.Library.md): A component library: the components, custom functions, custom actions and
groups a program may use (prompt.md, section 2).
  - [OpenUI.Library.Callable](OpenUI.Library.Callable.md): A custom function or action of a library.
  - [OpenUI.Library.Compat](OpenUI.Library.Compat.md): Checks that a new version of a LibrarySpec keeps stored programs readable
(prompt.md, section 3.2): props of components, functions and actions are
only added at the end, never moved or removed, and a new required prop
carries a default.

  - [OpenUI.Library.Component](OpenUI.Library.Component.md): A component of a library: its prompt signature, description and positional props.
  - [OpenUI.Library.DSL](OpenUI.Library.DSL.md): The macros of `use OpenUI.Library`: `component/2`, `function/2`,
`action/2` and `group/3`. See `OpenUI.Library` for an example.
  - [OpenUI.Library.Group](OpenUI.Library.Group.md): A titled group of components in the prompt's component list.
  - [OpenUI.Library.Prop](OpenUI.Library.Prop.md): One positional argument of a component, function or action.
  - [OpenUI.Library.Rules](OpenUI.Library.Rules.md): The definition-time rules of a library (prompt.md, section 3.1).

- Language
  - [OpenUI.Canonical](OpenUI.Canonical.md): The canonical form of a program at stream end, as the OpenUI conformance
fixtures summarize it (`spec/fixtures/1.0/README.md`, "How the tree is
summarized").
  - [OpenUI.Edit](OpenUI.Edit.md): Incremental editing (language.md, section 7): merges a patch, the changed
statements a model answers with in edit mode, into the current program.
  - [OpenUI.Parser](OpenUI.Parser.md): Parses OpenUI Lang into an `OpenUI.Program` (language.md, sections 1, 2
and 8).
  - [OpenUI.Serializer](OpenUI.Serializer.md): Writes a rendered tree back to OpenUI Lang (language.md, section 9.2).
  - [OpenUI.Stream](OpenUI.Stream.md): Parses a response a chunk at a time (language.md, section 4).

- Runtime
  - [OpenUI.Runtime](OpenUI.Runtime.md): A rendered program as a pure value: its state store, form fields, query
results and mutations, with the interactions of language.md, sections 5
and 6.
  - [OpenUI.Runtime.Builtins](OpenUI.Runtime.Builtins.md): The built-in functions that evaluate their arguments up front
(language.md, section 3.4). `@Each` is lazy and lives in the evaluator.

  - [OpenUI.Runtime.Collation](OpenUI.Runtime.Collation.md): String order for `@Sort`, close to the ICU root collation that ECMAScript's
`localeCompare` uses (language.md, section 3.4).
  - [OpenUI.Runtime.Context](OpenUI.Runtime.Context.md): What evaluation reads: the library, the state store, the current result of
each query and the status of each mutation.
  - [OpenUI.Runtime.Evaluator](OpenUI.Runtime.Evaluator.md): Evaluates a parsed program into a tree of plain values (language.md,
sections 3 and 6.3).
  - [OpenUI.Runtime.HostValue](OpenUI.Runtime.HostValue.md): Turns Elixir data from the host, such as tool results, into the JSON-like
values programs work with.
  - [OpenUI.Runtime.Validation](OpenUI.Runtime.Validation.md): Field validation rules (language.md, section 5.4): `required`, `email`,
`url`, `numeric`, `minLength`, `maxLength`, `min`, `max` and `pattern`.
  - [OpenUI.Runtime.Value](OpenUI.Runtime.Value.md): The value semantics of OpenUI Lang (language.md, sections 3.1 and 3.2).

- LiveView
  - [OpenUI.LiveView](OpenUI.LiveView.md): Renders OpenUI programs in Phoenix LiveView.
  - [OpenUI.LiveView.Components](OpenUI.LiveView.Components.md): Maps a library's components to the host's function components.

- Prompt
  - [OpenUI.Message](OpenUI.Message.md): The protocol a host stores responses with (prompt.md, section 7): the
program wrapped in `]]>openui:content`, `]]>openui:context` and
`]]>openui:end` marker lines. The model never writes or sees these lines.
  - [OpenUI.Prompt](OpenUI.Prompt.md): Generates the system prompt that teaches a model a library (prompt.md,
section 4). For the same library and options the prompt is byte-identical
to the official `generateSystemPrompt`.

- Data
  - [OpenUI.ActionPlan](OpenUI.ActionPlan.md): The actions a component triggers, in order (language.md, section 6.3).
  - [OpenUI.Binding](OpenUI.Binding.md): A two-way binding of a bindable prop to a state variable (language.md, section 5.2).
  - [OpenUI.Builtins](OpenUI.Builtins.md): The names the language reserves for built-in functions and action steps
(language.md, sections 1.3, 3.4 and 6.3).

  - [OpenUI.Element](OpenUI.Element.md): A component in a program tree. `props` maps prop names to values; before
evaluation a value may still be an expression.
  - [OpenUI.Error](OpenUI.Error.md): An error in the shape of language.md, section 8.3, ready to send back to the
model. `to_map/1` gives the wire form.

  - [OpenUI.Event](OpenUI.Event.md): An action that reaches the host (language.md, section 6.3):
`continue_conversation` from `@ToAssistant`, `open_url` from `@OpenUrl`, or
the name of a library action.
  - [OpenUI.JSON](OpenUI.JSON.md): JSON on top of Elixir's `JSON` that keeps the key order of objects.
  - [OpenUI.JSON.Object](OpenUI.JSON.Object.md): A JSON object that keeps the order of its keys.
  - [OpenUI.Program](OpenUI.Program.md): A parsed program: its statements, the materialized entry, state defaults,
queries, mutations and the parse metadata of language.md, section 2.
  - [OpenUI.Program.Mutation](OpenUI.Program.Mutation.md): A `Mutation(tool, args)` statement (language.md, section 6.2).
  - [OpenUI.Program.Query](OpenUI.Program.Query.md): A `Query(tool, args, defaults, refresh)` statement (language.md, section 6.1).
`deps` are the state variables written literally in `args`: a change in one
of them fetches again.

  - [OpenUI.Statement](OpenUI.Statement.md): One `name = expression` statement of a program (language.md, section 2.1).
  - [OpenUI.Unknown](OpenUI.Unknown.md): Marks where a component the library does not know sat in a list of
components. It renders nothing, or the host's diagnostic for unknown
components (language.md, section 10). It is not part of the canonical tree.

## Mix Tasks

- [mix openui.gen.spec](Mix.Tasks.Openui.Gen.Spec.md): Writes the LibrarySpec of a library module, the `library.json` other
clients (a React app, a mobile app) build their library from.

