@manifesto-ai/compiler 1.9.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -5
- package/dist/analyzer/entity-primitives.d.ts +3 -0
- package/dist/analyzer/expr-type-surface.d.ts +21 -0
- package/dist/analyzer/flow-composition.d.ts +7 -0
- package/dist/analyzer/index.d.ts +5 -0
- package/dist/analyzer/scope.d.ts +76 -0
- package/dist/analyzer/validator.d.ts +69 -0
- package/dist/api/compile-mel-patch-collector.d.ts +33 -0
- package/dist/api/compile-mel-patch-expr.d.ts +8 -0
- package/dist/api/compile-mel-patch-location.d.ts +9 -0
- package/dist/api/compile-mel-patch.d.ts +5 -0
- package/dist/api/compile-mel.d.ts +125 -0
- package/dist/api/index.d.ts +9 -0
- package/dist/{chunk-4JJQCFJH.js → chunk-7TT6Y5ZC.js} +6 -2
- package/dist/chunk-7TT6Y5ZC.js.map +1 -0
- package/dist/{chunk-AYZTDA3J.js → chunk-LI5HNMZV.js} +2 -2
- package/dist/chunk-VAFXIS7J.js +101 -0
- package/dist/chunk-VAFXIS7J.js.map +1 -0
- package/dist/diagnostics/codes.d.ts +24 -0
- package/dist/diagnostics/format.d.ts +25 -0
- package/dist/diagnostics/index.d.ts +6 -0
- package/dist/diagnostics/types.d.ts +66 -0
- package/dist/esbuild.d.ts +6 -8
- package/dist/esbuild.js +3 -3
- package/dist/esbuild.js.map +1 -1
- package/dist/evaluation/context.d.ts +90 -0
- package/dist/evaluation/evaluate-expr.d.ts +23 -0
- package/dist/evaluation/evaluate-patch.d.ts +122 -0
- package/dist/evaluation/evaluate-runtime-patch.d.ts +59 -0
- package/dist/evaluation/index.d.ts +14 -0
- package/dist/generator/index.d.ts +6 -0
- package/dist/generator/ir.d.ts +185 -0
- package/dist/generator/lowering.d.ts +10 -0
- package/dist/generator/normalizer.d.ts +15 -0
- package/dist/generator/runtime-lowering.d.ts +2 -0
- package/dist/index.d.ts +19 -2785
- package/dist/index.js +1 -1
- package/dist/lexer/index.d.ts +6 -0
- package/dist/lexer/lexer.d.ts +58 -0
- package/dist/lexer/source-location.d.ts +40 -0
- package/dist/lexer/tokens.d.ts +46 -0
- package/dist/lowering/context.d.ts +95 -0
- package/dist/lowering/errors.d.ts +83 -0
- package/dist/lowering/index.d.ts +19 -0
- package/dist/lowering/lower-expr.d.ts +79 -0
- package/dist/lowering/lower-patch.d.ts +230 -0
- package/dist/lowering/lower-runtime-patch.d.ts +126 -0
- package/dist/lowering/to-mel-expr.d.ts +12 -0
- package/dist/mel-module.d.ts +14 -0
- package/dist/node-loader.d.ts +3 -7
- package/dist/node-loader.js +2 -2
- package/dist/parser/ast.d.ts +367 -0
- package/dist/parser/index.d.ts +6 -0
- package/dist/parser/parser.d.ts +101 -0
- package/dist/parser/precedence.d.ts +43 -0
- package/dist/renderer/expr-node.d.ts +171 -0
- package/dist/renderer/fragment.d.ts +83 -0
- package/dist/renderer/index.d.ts +22 -0
- package/dist/renderer/patch-op.d.ts +81 -0
- package/dist/renderer/type-expr.d.ts +60 -0
- package/dist/rollup.d.ts +6 -8
- package/dist/rollup.js +3 -3
- package/dist/rollup.js.map +1 -1
- package/dist/rspack.d.ts +6 -7
- package/dist/rspack.js +3 -3
- package/dist/rspack.js.map +1 -1
- package/dist/unplugin.d.ts +19 -0
- package/dist/utils/unicode-order.d.ts +5 -0
- package/dist/vite.d.ts +6 -8
- package/dist/vite.js +3 -3
- package/dist/vite.js.map +1 -1
- package/dist/webpack.d.ts +6 -8
- package/dist/webpack.js +3 -3
- package/dist/webpack.js.map +1 -1
- package/package.json +12 -17
- package/dist/chunk-4JJQCFJH.js.map +0 -1
- package/dist/chunk-K4IKHGOP.js +0 -74
- package/dist/chunk-K4IKHGOP.js.map +0 -1
- package/dist/unplugin-6wnvFiEo.d.ts +0 -17
- /package/dist/{chunk-AYZTDA3J.js.map → chunk-LI5HNMZV.js.map} +0 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IR Generator - Transforms MEL AST to Core DomainSchema
|
|
3
|
+
* Based on MEL SPEC v0.3.3 Section 5
|
|
4
|
+
*/
|
|
5
|
+
import type { Diagnostic } from "../diagnostics/types.js";
|
|
6
|
+
import type { ProgramNode } from "../parser/ast.js";
|
|
7
|
+
import type { MelExprNode } from "../lowering/lower-expr.js";
|
|
8
|
+
import { type ExprNode as RuntimeExprNode, type FlowNode as RuntimeFlowNode, type PatchPath } from "@manifesto-ai/core";
|
|
9
|
+
/**
|
|
10
|
+
* Core ExprNode types (simplified, matching core/schema/expr.ts)
|
|
11
|
+
*/
|
|
12
|
+
export type CoreExprNode = RuntimeExprNode;
|
|
13
|
+
export type CompilerExprNode = MelExprNode;
|
|
14
|
+
/**
|
|
15
|
+
* Core FlowNode types (matching core/schema/flow.ts)
|
|
16
|
+
*/
|
|
17
|
+
export type CoreFlowNode = RuntimeFlowNode;
|
|
18
|
+
export type CompilerFlowNode = {
|
|
19
|
+
kind: "seq";
|
|
20
|
+
steps: CompilerFlowNode[];
|
|
21
|
+
} | {
|
|
22
|
+
kind: "if";
|
|
23
|
+
cond: CompilerExprNode;
|
|
24
|
+
then: CompilerFlowNode;
|
|
25
|
+
else?: CompilerFlowNode;
|
|
26
|
+
} | {
|
|
27
|
+
kind: "patch";
|
|
28
|
+
op: "set" | "unset" | "merge";
|
|
29
|
+
path: PatchPath;
|
|
30
|
+
value?: CompilerExprNode;
|
|
31
|
+
} | {
|
|
32
|
+
kind: "effect";
|
|
33
|
+
type: string;
|
|
34
|
+
params: Record<string, CompilerExprNode>;
|
|
35
|
+
} | {
|
|
36
|
+
kind: "call";
|
|
37
|
+
flow: string;
|
|
38
|
+
} | {
|
|
39
|
+
kind: "halt";
|
|
40
|
+
reason?: string;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "fail";
|
|
43
|
+
code: string;
|
|
44
|
+
message?: CompilerExprNode;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Field type definition
|
|
48
|
+
*/
|
|
49
|
+
export type FieldType = "string" | "number" | "boolean" | "null" | "object" | "array" | {
|
|
50
|
+
enum: readonly unknown[];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Field specification
|
|
54
|
+
*/
|
|
55
|
+
export interface FieldSpec {
|
|
56
|
+
type: FieldType;
|
|
57
|
+
required: boolean;
|
|
58
|
+
default?: unknown;
|
|
59
|
+
description?: string;
|
|
60
|
+
fields?: Record<string, FieldSpec>;
|
|
61
|
+
items?: FieldSpec;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* State specification
|
|
65
|
+
*/
|
|
66
|
+
export interface StateSpec {
|
|
67
|
+
fields: Record<string, FieldSpec>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Computed field specification
|
|
71
|
+
*/
|
|
72
|
+
export interface ComputedFieldSpec {
|
|
73
|
+
deps: string[];
|
|
74
|
+
expr: CoreExprNode;
|
|
75
|
+
description?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface CompilerComputedFieldSpec {
|
|
78
|
+
deps: string[];
|
|
79
|
+
expr: CompilerExprNode;
|
|
80
|
+
description?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Computed specification
|
|
84
|
+
*/
|
|
85
|
+
export interface ComputedSpec {
|
|
86
|
+
fields: Record<string, ComputedFieldSpec>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Action specification
|
|
90
|
+
*/
|
|
91
|
+
export interface ActionSpec {
|
|
92
|
+
flow: CoreFlowNode;
|
|
93
|
+
input?: FieldSpec;
|
|
94
|
+
available?: CoreExprNode;
|
|
95
|
+
description?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface CompilerActionSpec {
|
|
98
|
+
flow: CompilerFlowNode;
|
|
99
|
+
input?: FieldSpec;
|
|
100
|
+
available?: CompilerExprNode;
|
|
101
|
+
description?: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Domain schema (output IR)
|
|
105
|
+
*/
|
|
106
|
+
/**
|
|
107
|
+
* v0.3.3: Type specification (named type declaration)
|
|
108
|
+
*/
|
|
109
|
+
export interface TypeSpec {
|
|
110
|
+
name: string;
|
|
111
|
+
definition: TypeDefinition;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* v0.3.3: Type definition structure
|
|
115
|
+
*/
|
|
116
|
+
export type TypeDefinition = {
|
|
117
|
+
kind: "primitive";
|
|
118
|
+
type: string;
|
|
119
|
+
} | {
|
|
120
|
+
kind: "array";
|
|
121
|
+
element: TypeDefinition;
|
|
122
|
+
} | {
|
|
123
|
+
kind: "record";
|
|
124
|
+
key: TypeDefinition;
|
|
125
|
+
value: TypeDefinition;
|
|
126
|
+
} | {
|
|
127
|
+
kind: "object";
|
|
128
|
+
fields: Record<string, {
|
|
129
|
+
type: TypeDefinition;
|
|
130
|
+
optional: boolean;
|
|
131
|
+
}>;
|
|
132
|
+
} | {
|
|
133
|
+
kind: "union";
|
|
134
|
+
types: TypeDefinition[];
|
|
135
|
+
} | {
|
|
136
|
+
kind: "literal";
|
|
137
|
+
value: string | number | boolean | null;
|
|
138
|
+
} | {
|
|
139
|
+
kind: "ref";
|
|
140
|
+
name: string;
|
|
141
|
+
};
|
|
142
|
+
export interface DomainSchema {
|
|
143
|
+
id: string;
|
|
144
|
+
version: string;
|
|
145
|
+
hash: string;
|
|
146
|
+
/** v0.3.3: Named type declarations */
|
|
147
|
+
types: Record<string, TypeSpec>;
|
|
148
|
+
state: StateSpec;
|
|
149
|
+
computed: ComputedSpec;
|
|
150
|
+
actions: Record<string, ActionSpec>;
|
|
151
|
+
meta?: {
|
|
152
|
+
name?: string;
|
|
153
|
+
description?: string;
|
|
154
|
+
authors?: string[];
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
export interface CanonicalDomainSchema {
|
|
158
|
+
id: string;
|
|
159
|
+
version: string;
|
|
160
|
+
hash: string;
|
|
161
|
+
types: Record<string, TypeSpec>;
|
|
162
|
+
state: StateSpec;
|
|
163
|
+
computed: {
|
|
164
|
+
fields: Record<string, CompilerComputedFieldSpec>;
|
|
165
|
+
};
|
|
166
|
+
actions: Record<string, CompilerActionSpec>;
|
|
167
|
+
meta?: {
|
|
168
|
+
name?: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
authors?: string[];
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
export interface GenerateResult {
|
|
174
|
+
schema: DomainSchema | null;
|
|
175
|
+
diagnostics: Diagnostic[];
|
|
176
|
+
}
|
|
177
|
+
export interface GenerateCanonicalResult {
|
|
178
|
+
schema: CanonicalDomainSchema | null;
|
|
179
|
+
diagnostics: Diagnostic[];
|
|
180
|
+
}
|
|
181
|
+
export declare function generateCanonical(program: ProgramNode): GenerateCanonicalResult;
|
|
182
|
+
/**
|
|
183
|
+
* Generate runtime-ready DomainSchema from MEL AST.
|
|
184
|
+
*/
|
|
185
|
+
export declare function generate(program: ProgramNode): GenerateResult;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System Value Lowering
|
|
3
|
+
* Transforms $system.* references into effect-based acquisition
|
|
4
|
+
* Based on MEL SPEC v0.3.1 Section 5.4
|
|
5
|
+
*/
|
|
6
|
+
import type { DomainSchema } from "./ir.js";
|
|
7
|
+
/**
|
|
8
|
+
* Apply system value lowering to a domain schema
|
|
9
|
+
*/
|
|
10
|
+
export declare function lowerSystemValues(schema: DomainSchema): DomainSchema;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expression Normalizer
|
|
3
|
+
* Converts MEL operators and function calls to Core ExprNode format
|
|
4
|
+
* Based on MEL SPEC v0.3.1 Section 4 and FDR-MEL-038
|
|
5
|
+
*/
|
|
6
|
+
import type { CoreExprNode } from "./ir.js";
|
|
7
|
+
import type { BinaryOperator } from "../parser/ast.js";
|
|
8
|
+
/**
|
|
9
|
+
* Normalize a binary operator to Core ExprNode
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeExpr(op: BinaryOperator, left: CoreExprNode, right: CoreExprNode): CoreExprNode;
|
|
12
|
+
/**
|
|
13
|
+
* Function name to Core ExprNode mapping
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeFunctionCall(name: string, args: CoreExprNode[]): CoreExprNode;
|