@manifesto-ai/compiler 3.9.0 → 5.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 CHANGED
@@ -21,7 +21,7 @@ MEL source -> Compiler -> DomainSchema -> Core
21
21
  | Parse MEL | Tokenize and parse MEL into an AST |
22
22
  | Validate | Scope, typing, and semantic checks aligned to the current compiler contract |
23
23
  | Generate IR | Produce DomainSchema for Core |
24
- | Lower system values | Optional lowering of $system.* into explicit effects |
24
+ | Lower runtime/context expressions | Lower ADR-027 `$runtime.*` and `$context.*` references into Core expressions |
25
25
 
26
26
  ---
27
27
 
@@ -216,7 +216,7 @@ type CompileOptions = {
216
216
  | [MEL Syntax](../../docs/mel/SYNTAX.md) | Grammar and syntax |
217
217
  | [MEL Examples](../../docs/mel/EXAMPLES.md) | Example library |
218
218
  | [MEL Error Guide](../../docs/mel/ERROR-GUIDE.md) | Error codes and fixes |
219
- | [Compiler Spec](docs/SPEC-v1.1.0.md) | Current full compiler and MEL spec |
219
+ | [Compiler Spec](docs/SPEC-v1.2.0.md) | Current full compiler and MEL spec |
220
220
  | [Compiler FDR](docs/FDR-v0.5.0.md) | Design rationale |
221
221
  | [Compiler Compliance Suite](docs/compiler-SPEC-compilance-test-suite.md) | CCTS structure, rule modes, and execution guide |
222
222
 
@@ -6,6 +6,7 @@ export type TypeEnv = Map<string, TypeExprNode>;
6
6
  export type ComparableSurfaceClass = "primitive" | "nonprimitive" | "unknown";
7
7
  export interface DomainTypeSymbols {
8
8
  stateTypes: Map<string, TypeExprNode>;
9
+ contextTypes: Map<string, TypeExprNode>;
9
10
  computedDecls: Map<string, ComputedNode>;
10
11
  typeDefs: Map<string, TypeDeclNode>;
11
12
  computedTypeCache: Map<string, TypeExprNode | null>;
@@ -31,6 +31,7 @@ export declare class SemanticValidator {
31
31
  * v0.3.3: Validate state field - check for anonymous object types (W012)
32
32
  */
33
33
  private validateStateField;
34
+ private validateContext;
34
35
  private validateStateInitializer;
35
36
  /**
36
37
  * v0.3.3: Check if a type expression contains anonymous object types
@@ -39,13 +40,13 @@ export declare class SemanticValidator {
39
40
  private checkAnonymousObjectType;
40
41
  private validateAction;
41
42
  /**
42
- * v0.3.3: Validate available expression is pure (E005)
43
- * No $system.*, no effects, no $input.*
43
+ * v0.3.3: Validate available expression is pure (E005).
44
+ * No dollar namespace reads or action parameters.
44
45
  */
45
46
  private validateAvailableExpr;
46
47
  /**
47
- * v0.9.0: Validate dispatchable expression is pure (E047)
48
- * Allows state/computed/action params, but forbids direct $input.*, $meta.*, and $system.*.
48
+ * v0.9.0: Validate dispatchable expression is pure (E047).
49
+ * Allows state/computed/action params, but forbids direct dollar namespace reads.
49
50
  */
50
51
  private validateDispatchableExpr;
51
52
  private validateGuardedStmt;
@@ -58,6 +59,8 @@ export declare class SemanticValidator {
58
59
  private validateStop;
59
60
  private validateCondition;
60
61
  private validateExpr;
62
+ private validateDollarIdent;
63
+ private validateContextPath;
61
64
  private validateFunctionCall;
62
65
  private validatePrimitiveEquality;
63
66
  private inferType;
@@ -4,11 +4,9 @@ import type { MelIRPatchPath } from "../lowering/lower-runtime-patch.js";
4
4
  import type { GuardedStmtNode, InnerStmtNode, PatchStmtNode } from "../parser/ast.js";
5
5
  import { toMelExpr } from "./compile-mel-patch-expr.js";
6
6
  export interface PatchCollectContext {
7
- actionName: string;
8
- onceCounter: number;
9
- onceIntentCounter: number;
10
- whenCounter: number;
7
+ readonly actionName: string;
11
8
  }
9
+ type AllowedSysPrefix = "input" | "runtime" | "context";
12
10
  export type ConditionedPatchStatement = {
13
11
  patch: PatchStmtNode;
14
12
  condition?: MelExprNode;
@@ -19,11 +17,11 @@ export interface PatchCollectorDeps {
19
17
  }
20
18
  export declare class PatchStatementCollector {
21
19
  private readonly deps;
22
- private readonly conditionComposer;
23
20
  private readonly exprValidator;
24
- constructor(deps: PatchCollectorDeps);
21
+ constructor(deps: PatchCollectorDeps, allowSysPrefixes?: readonly AllowedSysPrefix[]);
25
22
  collect(stmts: GuardedStmtNode[] | InnerStmtNode[], errors: Diagnostic[], context: PatchCollectContext, parentCondition: MelExprNode | undefined): ConditionedPatchStatement[];
26
23
  private collectPatchStatements;
24
+ private pushUnsupportedControlError;
27
25
  }
28
26
  export declare function compilePatchStmtToMelRuntime(patchStatement: ConditionedPatchStatement): {
29
27
  op: "set" | "unset" | "merge";
@@ -31,3 +29,4 @@ export declare function compilePatchStmtToMelRuntime(patchStatement: Conditioned
31
29
  value?: MelExprNode;
32
30
  condition?: MelExprNode;
33
31
  };
32
+ export {};
@@ -81,11 +81,11 @@ export interface CompileMelPatchOptions {
81
81
  */
82
82
  actionName: string;
83
83
  /**
84
- * Allowed system path prefixes.
85
- * Default: ["meta", "input"] (system is forbidden per §20.3).
84
+ * Allowed dollar namespace prefixes.
85
+ * Default: ["input", "runtime", "context"].
86
86
  */
87
87
  allowSysPaths?: {
88
- prefixes: ("meta" | "input")[];
88
+ prefixes: ("input" | "runtime" | "context")[];
89
89
  };
90
90
  /**
91
91
  * Function table version.
@@ -140,7 +140,7 @@ export declare function compileMelModule(melText: string, options?: CompileMelMo
140
140
  * by evaluateRuntimePatches() to get concrete values.
141
141
  *
142
142
  * Constraints:
143
- * - §20.3: $system.* is forbidden in Translator path
143
+ * - ADR-027: `$system.*` and `$meta.*` are retired in current v5 MEL.
144
144
  *
145
145
  * @param melText - MEL patch source text
146
146
  * @param options - Compilation options
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @see SPEC v0.4.0 §19
7
7
  */
8
- export type { Annotation, AnnotationIndex, CompileTrace, CompileMelDomainOptions, CompileMelDomainResult, CompileMelModuleOptions, CompileMelModuleResult, CompileMelPatchOptions, CompileMelPatchResult, DomainModule, JsonLiteral, LocalTargetKey, SourceMapEmissionContext, SourceMapEntry, SourceMapIndex, SourceMapPath, SourcePoint, SourceSpan, } from "./compile-mel.js";
8
+ export type { Annotation, AnnotationIndex, CompileTrace, CompileMelDomainOptions, CompileMelDomainResult, CompileMelModuleOptions, CompileMelModuleResult, DomainModule, JsonLiteral, LocalTargetKey, SourceMapEmissionContext, SourceMapEntry, SourceMapIndex, SourceMapPath, SourcePoint, SourceSpan, } from "./compile-mel.js";
9
9
  export type { CompileFragmentInContextOptions, MelEditAddActionOp, MelEditAddAvailableOp, MelEditAddComputedOp, MelEditAddDispatchableOp, MelEditAddStateFieldOp, MelEditAddTypeOp, MelEditOp, MelEditRemoveDeclarationOp, MelEditRenameDeclarationOp, MelEditReplaceActionBodyOp, MelEditReplaceAvailableOp, MelEditReplaceComputedExprOp, MelEditReplaceDispatchableOp, MelEditReplaceStateDefaultOp, MelEditReplaceTypeFieldOp, MelEditResult, MelParamSource, MelTextEdit, SchemaDiff, SchemaModifiedTarget, } from "./compile-fragment-in-context.js";
10
- export { compileMelDomain, compileMelModule, compileMelPatch } from "./compile-mel.js";
10
+ export { compileMelDomain, compileMelModule } from "./compile-mel.js";
11
11
  export { compileFragmentInContext } from "./compile-fragment-in-context.js";
@@ -1,3 +1,3 @@
1
- import{a as f,b as g}from"./chunk-5MK25QWV.js";import{da as d}from"./chunk-53553ZHJ.js";import{createHash as p}from"crypto";import*as i from"path";import{createUnplugin as h}from"unplugin";var M=new Set(["transform","build","both"]);function l(e){return e.split("?",1)[0]}function b(e,t){return e.lastIndex=0,e.test(t)}function y(e){let t=l(e).replace(/\\/g,"/");if(!t)return"domain.mel";if(!i.isAbsolute(e))return t.replace(/^\.\//,"");let n=i.relative(process.cwd(),e);return!n||n.startsWith("..")||i.isAbsolute(n)?w(t):n.split(i.sep).join("/")}function w(e){let t=i.posix.basename(e)||"domain.mel",n=i.posix.extname(t),o=t.slice(0,t.length-n.length)||"domain",r=p("sha256").update(e).digest("hex").slice(0,12);return`external/${x(o)}--${r}${n}`}function x(e){return e.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"domain"}function E(e){if(!e)return null;if(typeof e=="function")return{emit:e,timing:"transform"};if(typeof e=="object"&&typeof e.emit=="function"){let t=e.timing??"transform";if(!M.has(t))throw new TypeError(`manifesto:mel codegen timing must be one of "transform", "build", or "both" (received ${JSON.stringify(t)})`);return{emit:e.emit,timing:t}}throw new TypeError("manifesto:mel codegen must be a function or an object with a callable emit field")}var O=h((e={})=>{let t=e.include??/\.mel$/,n=new Map,o=E(e.codegen);return{name:"manifesto:mel",enforce:"pre",transformInclude(r){return b(t,l(r))},async transform(r,s){let m=l(s),a=d(r,{mode:"domain"});if(a.errors.length>0){let u=a.errors.map(f).join(`
1
+ import{a as f,b as g}from"./chunk-HOS3TLHW.js";import{aa as d}from"./chunk-JYNK3VUK.js";import{createHash as p}from"crypto";import*as i from"path";import{createUnplugin as h}from"unplugin";var M=new Set(["transform","build","both"]);function l(e){return e.split("?",1)[0]}function b(e,t){return e.lastIndex=0,e.test(t)}function y(e){let t=l(e).replace(/\\/g,"/");if(!t)return"domain.mel";if(!i.isAbsolute(e))return t.replace(/^\.\//,"");let n=i.relative(process.cwd(),e);return!n||n.startsWith("..")||i.isAbsolute(n)?w(t):n.split(i.sep).join("/")}function w(e){let t=i.posix.basename(e)||"domain.mel",n=i.posix.extname(t),o=t.slice(0,t.length-n.length)||"domain",r=p("sha256").update(e).digest("hex").slice(0,12);return`external/${x(o)}--${r}${n}`}function x(e){return e.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"domain"}function E(e){if(!e)return null;if(typeof e=="function")return{emit:e,timing:"transform"};if(typeof e=="object"&&typeof e.emit=="function"){let t=e.timing??"transform";if(!M.has(t))throw new TypeError(`manifesto:mel codegen timing must be one of "transform", "build", or "both" (received ${JSON.stringify(t)})`);return{emit:e.emit,timing:t}}throw new TypeError("manifesto:mel codegen must be a function or an object with a callable emit field")}var O=h((e={})=>{let t=e.include??/\.mel$/,n=new Map,o=E(e.codegen);return{name:"manifesto:mel",enforce:"pre",transformInclude(r){return b(t,l(r))},async transform(r,s){let m=l(s),a=d(r,{mode:"domain"});if(a.errors.length>0){let u=a.errors.map(f).join(`
2
2
  `);throw new Error(`MEL compilation failed for ${m}
3
3
  ${u}`)}if(!a.schema)throw new Error(`MEL compilation produced no schema for ${m}`);let c=y(m);return o&&((o.timing==="transform"||o.timing==="both")&&await o.emit({schema:a.schema,sourceId:c}),(o.timing==="build"||o.timing==="both")&&n.set(c,a.schema)),g(a.schema)},async buildEnd(){if(!(!o||n.size===0))for(let[r,s]of n)await o.emit({schema:s,sourceId:r})}}});export{O as a};
@@ -1,4 +1,4 @@
1
- import{da as t}from"./chunk-53553ZHJ.js";function i(o){let e=o.location;if(!e)return`[${o.code}] ${o.message}`;let{line:r,column:n}=e.start;return`[${o.code}] ${o.message} (${r}:${n})`}function s(o){return`export default ${JSON.stringify(o,null,2)};
1
+ import{aa as t}from"./chunk-JYNK3VUK.js";function i(o){let e=o.location;if(!e)return`[${o.code}] ${o.message}`;let{line:r,column:n}=e.start;return`[${o.code}] ${o.message} (${r}:${n})`}function s(o){return`export default ${JSON.stringify(o,null,2)};
2
2
  `}function a(o,e){let r=t(o,{mode:"domain"});if(r.errors.length>0){let n=r.errors.map(i).join(`
3
3
  `);throw new Error(`MEL compilation failed for ${e}
4
4
  ${n}`)}if(!r.schema)throw new Error(`MEL compilation produced no schema for ${e}`);return s(r.schema)}export{i as a,s as b,a as c};