@younndai/yon-parser
v2.0.2
Published
Reference parser, validator, and formatter for YON™ — the stream-first data format for AI agent workflows.
Maintainers
Readme
What is this?
@younndai/yon-parser is the reference implementation of the YON v2.0 block format — a parser, validator, and deterministic formatter. Reference implementations define correctness: other YON parsers should match this behavior. It parses YON text into a structured AST, validates records and blocks against the spec and domain schemas, and formats documents in canonical, minimal, and ultra-compact modes.
Install
npm install @younndai/yon-parserQuick Start
import { parse, validate, format } from "@younndai/yon-parser";
// Parse YON string → AST
const doc = parse('@DOC ver=2.0 | id=test | title="Hello"\n@NOTE text="World"');
// Validate (strict mode)
const result = validate(doc, { strict: true });
if (!result.valid) {
console.error(result.errors);
}
// Format (deterministic output)
const formatted = format(doc, { mode: "canon" });Key Features
- Full YON v2.0 compliance — conformance vectors + comprehensive deterministic test suite.
- Streaming parser — line-by-line event-driven parsing for transport.
- Granular validation API — per-record and per-block validation, field constraints (range, enum, pattern, type), and domain lifecycle checking.
- Domain resolution — 34 bundled offline domains (full list:
listDomains('official')), remote resolution with caching, and runtime registration of custom schemas. - Deterministic formatting — canon, min, and ultra output modes, plus SHA-256 block integrity helpers.
- Detailed diagnostics — line numbers and error codes on every failure.
CLI
yon validate document.yon --profile exec # Validate a file
yon validate document.yon --lenient # Validate in lenient mode
yon format document.yon --mode CANON # Format a file
yon format document.yon --check # Format with diff check
yon parse document.yon --json # Parse and output JSON ASTDocumentation
| Document | Description |
| -------------------------------- | --------------------------------------------------------- |
| Overview | Architecture, processing pipeline, spec mapping |
| Parsing | parse(), Lexer, token types, AST shape |
| Validation | validate(), granular API, field constraints, lifecycle |
| Formatting | format(), canon/min/ultra modes, granular formatting |
| Streaming | StreamingYonParser, line-by-line transport parsing |
| Domains | Two-tier resolution, registration, lifecycle, constraints |
| Integrity | SHA-256 verification helpers |
| Reference | Types, constants, error codes, profiles, features |
| How to Use | Comprehensive usage guide with examples |
| Changelog | Version history and release notes |
The YON Project
YON is an open block format and toolchain.
- Specification —
@younndai/yon-spec— the normative YON v2.0 standard. - Toolchain —
YounndAI/yon— parser, generator, runner, converter, examples, benchmarks, domains, ai-relay. - Editor support —
yon-vscode(VS Code Marketplace) ·@younndai/yon-textmate(TextMate grammar).
Testing
# Run all tests (see TESTING.md for current count)
npx vitest run
# Generate a timestamped report
npx tsx test/generate-report.tsSee TESTING.md for test architecture, conformance vectors, and the report generator.
About YounndAI
YounndAI™ — You and AI, unified. (pronounced "yoon-dye")
A philosophy of intelligence: building with intention, so humans and machines think together without losing what makes either whole.
License & Attribution
Apache-2.0. © 2026 MARLINK TRADING SRL (YounndAI). See LICENSE and NOTICE.
"YON" and "YounndAI" are trademarks of MARLINK TRADING SRL — see TRADEMARK.md.
Created by Alexandru Mareș.
Website: yon.younndai.com
| | | | ------------- | ------------------------------------------------------- | | Spec | YON v2.0 | | Author | Alexandru Mareș | | Company | MARLINK TRADING SRL · YounndAI™ | | License | Apache 2.0 — © 2026 MARLINK TRADING SRL | | Trademark | YounndAI™ Trademark Guidelines |
