@womp/flowir
v0.5.0
Published
A line-oriented language for typed node graphs: the dialect registry, parser, checker, printer, and the rendering of a dialect and the language rules for an LLM prompt.
Keywords
Readme
@womp/flowir
A line-oriented language for typed node graphs: the dialect registry, parser, checker, printer, and the rendering of a dialect and the language rules for an LLM prompt.
Install
npm install @womp/flowirQuick start
import { Registry, compileFromProgram, formatDiagnostics, parseIRText } from "@womp/flowir"
const registry = Registry.fromJsonObject(dialectJson)
const parsed = parseIRText(source)
if (!parsed.ok) throw new Error(formatDiagnostics(source, parsed.diagnostics))
const result = compileFromProgram(parsed.program, registry)
if (!result.ok) console.error(formatDiagnostics(source, result.diagnostics))API
| Export | Description |
|--------|-------------|
| Registry | Load a dialect with Registry.fromJsonObject; query its nodes, ports, enums and casts |
| parseIRText | Parse FlowIR text into an AstProgram |
| compileFromProgram | Check a parsed program against a registry |
| programToIRText | Print an AstProgram as FlowIR text |
| formatDiagnostics | Render diagnostics with their source line, a caret and a fix hint, quoting each source line and hint once; an optional limit shows the first diagnostics and counts the rest |
| renderPrompt | Render the <flowir> document a model reads before writing a program for a dialect |
The AST (AstProgram, AstStatement, AstValue, …), dialect (DialectSchema,
DialectNode, DialectPort) and diagnostic (Diagnostic, DiagnosticCode,
CompilationResult, SourcePos) types are exported as well.
Development
npm install
npm run build
npm test