Work on the core package (types, validation, normalization, diff). Use when modifying DSL processing logic or data flow.
The core package (packages/core/) is dependency-free and handles all DSL processing.
DSL (YAML input) ā validate() ā normalize() ā IR ā diff() ā Patch
| File | Purpose | Exports |
|---|---|---|
types.ts |
Type definitions | DSL*, IR*, Patch, WebSocket protocol |
validate.ts |
YAML validation | validate(dsl): ValidationResult |
normalize.ts |
DSL ā IR conversion | normalize(dsl): IRDocument |
diff.ts |
IR diff calculation | diff(prev, next): Patch |
DSL Types (user input) IR Types (normalized)
āāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāāā
DSLDocument IRDocument
āā version: number āā version: number
āā docId: string āā docId: string
āā title?: string āā title: string
āā nodes: DSLNode[] āā nodes: Record<string, IRNode>
āā edges?: DSLEdge[] āā edges: Record<string, IREdge>
DSLNode IRNode
āā id: string āā id: string
āā provider: string āā provider: string
āā kind: string āā kind: string
āā label?: string āā label: string (default: id)
āā parent?: string āā parent: string | null
āā layout: DSLLayout āā layout: { x, y, w, h }
DSLEdge IREdge
āā id: string āā id: string
āā from: string āā from: string
āā to: string āā to: string
āā label?: string āā label: string (default: "")
type PatchOp =
| { op: "upsertNode"; node: IRNode }
| { op: "removeNode"; id: string }
| { op: "upsertEdge"; edge: IREdge }
| { op: "removeEdge"; id: string };
interface Patch {
baseRev: number;
nextRev: number;
ops: PatchOp[];
}
// Plugin ā CLI
interface HelloMessage {
type: "hello";
docId: string;
secret?: string;
}
interface RequestFullMessage {
type: "requestFull";
docId: string;
}
// CLI ā Plugin
interface FullMessage {
type: "full";
rev: number;
ir: IRDocument;
}
interface PatchMessage {
type: "patch";
baseRev: number;
nextRev: number;
ops: PatchOp[];
}
interface ErrorMessage {
type: "error";
message: string;
}
types.tsvalidate.ts catches invalid inputnormalize.tsdiff.ts*.test.ts filesbun test packages/core/# All core tests
bun test packages/core/
# Specific test file
bun test packages/core/src/diff.test.ts
bun test packages/core/src/validate.test.ts
bun test packages/core/src/normalize.test.ts
# Watch mode
bun test --watch packages/core/
DSLNode and IRNode in types.tsvalidate.tsnormalize.tsDSLEdge and IREdge in types.tsvalidate.tsnormalize.ts