mlld
Version:
mlld: a modular prompt scripting language
1 lines • 67.8 kB
Source Map (JSON)
{"version":3,"sources":["../core/types/guards.ts","../core/types/errors.ts","../core/types/show.ts","../core/types/exe.ts","../core/types/path.ts","../core/types/run.ts","../core/types/output.ts","../core/types/when.ts","../core/types/var.ts","../core/types/for.ts","../core/types/variables.ts","../core/types/executable.ts","../core/types/index.ts"],"names":["isInterpolatableValueArray","value","Array","isArray","length","type","isTextNode","node","isDirectiveNode","isCodeFenceNode","isCommentNode","isVariableReferenceNode","isLiteralNode","isDotSeparatorNode","isPathSeparatorNode","isFileReferenceNode","isImportDirective","kind","isImportAllDirective","subtype","isImportSelectedDirective","isWildcardImport","valueType","identifier","isExecInvocation","hasWithClause","directive","values","withClause","undefined","isNegationNode","isBinaryExpression","isTernaryExpression","isUnaryExpression","ParseErrorCode","MlldAstError","Error","constructor","message","code","location","name","isShowDirectiveNode","isShowPathDirectiveNode","isShowTemplateDirectiveNode","isShowVariableDirectiveNode","isShowPathSectionDirectiveNode","isExeDirectiveNode","isExeCommandDirective","isExeCodeDirective","isPathDirective","isPathAssignmentDirective","hasSpecialVariablePath","path","firstComponent","startsWith","components","isRunCommandDirective","isRunCodeDirective","isRunExecDirective","isOutputDirective","isOutputDocumentDirective","isOutputFileDirective","isOutputStreamDirective","isOutputEnvDirective","isOutputResolverDirective","isFileTarget","target","isStreamTarget","isEnvTarget","isResolverTarget","isWhenSimpleNode","isWhenBlockNode","isWhenMatchNode","isWhenNode","isVarDirectiveNode","isVarExecDefinition","isNestedDirective","content","isDataObject","isDataArray","isPrimitiveValue","isDirectiveValue","isVariableReferenceValue","some","isTemplateValue","isDataObjectValue","isDataArrayValue","isEmbedDirectiveValue","isRunDirectiveValue","isNestedEmbedDirective","isNestedRunDirective","isContentNodes","isForeachExpression","isForDirective","isForExpression","VariableValueType","VALID_VARIABLE_TYPES","isValidVariableType","includes","createVariableReferenceNode","fields","format","isVariableReference","nodeId","Date","now","Math","random","isCommandExecutable","def","isCommandRefExecutable","isCodeExecutable","isTemplateExecutable","isSectionExecutable","isResolverExecutable","isExecSourced","sourceDirective","isTextSourced","astLocationToSourceLocation","astLocation","filePath","line","start","column","offset","isExtendedVariable","variable","createPreciseLocation","createFileLocation","isPreciseLocation"],"mappings":";;;AAmDO,SAASA,2BAA2BC,KAAc,EAAA;AACvD,EAAOC,OAAAA,KAAAA,CAAMC,OAAQF,CAAAA,KAAAA,CACbA,KAAAA,KAAAA,CAAMG,MAAW,KAAA,CAAA,IAChBH,KAAM,CAAA,CAAA,CAAM,IAAA,OAAOA,KAAM,CAAA,CAAA,CAAO,KAAA,QAAA,IAAa,MAAUA,IAAAA,KAAAA,CAAM,CAAA,CAAA,KAC5DA,KAAM,CAAA,CAAA,CAAGI,CAAAA,IAAAA,KAAS,MAAUJ,IAAAA,KAAAA,CAAM,CAAA,CAAA,CAAGI,IAAS,KAAA,mBAAA,CAAA,CAAA;AAC1D;AALgBL,MAAAA,CAAAA,0BAAAA,EAAAA,4BAAAA,CAAAA;AAWT,SAASM,WAAWC,IAAc,EAAA;AACvC,EAAA,OAAOA,KAAKF,IAAS,KAAA,MAAA;AACvB;AAFgBC,MAAAA,CAAAA,UAAAA,EAAAA,YAAAA,CAAAA;AAIT,SAASE,gBAAgBD,IAAc,EAAA;AAC5C,EAAA,OAAOA,KAAKF,IAAS,KAAA,WAAA;AACvB;AAFgBG,MAAAA,CAAAA,eAAAA,EAAAA,iBAAAA,CAAAA;AAIT,SAASC,gBAAgBF,IAAc,EAAA;AAC5C,EAAA,OAAOA,KAAKF,IAAS,KAAA,WAAA;AACvB;AAFgBI,MAAAA,CAAAA,eAAAA,EAAAA,iBAAAA,CAAAA;AAIT,SAASC,cAAcH,IAAc,EAAA;AAC1C,EAAA,OAAOA,KAAKF,IAAS,KAAA,SAAA;AACvB;AAFgBK,MAAAA,CAAAA,aAAAA,EAAAA,eAAAA,CAAAA;AAIT,SAASC,wBAAwBJ,IAAc,EAAA;AACpD,EAAA,OAAOA,KAAKF,IAA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,QAAiB,EAAA;AAEjB,EAAI,IAAA,CAACD,aAAoB3F,OAAAA,MAAAA;AAEzB,EAAO,OAAA;AACL6F,IAAAA,IAAAA,EAAMF,YAAYG,KAAMD,CAAAA,IAAAA;AACxBE,IAAAA,MAAAA,EAAQJ,YAAYG,KAAMC,CAAAA,MAAAA;AAC1BC,IAAAA,MAAAA,EAAQL,YAAYG,KAAME,CAAAA,MAAAA;AAC1BJ,IAAAA;AACF,GAAA;AACF;AAZgBF,MAAAA,CAAAA,2BAAAA,EAAAA,6BAAAA,CAAAA;AAsBT,SAASO,mBAAmBC,QAAiB,EAAA;AAClD,EAAA,OAAOA,QAAa,KAAA,IAAA,IAAQ,OAAOA,QAAAA,KAAa,YAAY,MAAUA,IAAAA,QAAAA;AACxE;AAFgBD,MAAAA,CAAAA,kBAAAA,EAAAA,oBAAAA,CAAAA;AA0CT,SAASE,qBACdN,CAAAA,IAAAA,EACAE,MACAH,EAAAA,QAAAA,EACAI,MAAe,EAAA;AAEf,EAAO,OAAA;AAAEJ,IAAAA,QAAAA;AAAUC,IAAAA,IAAAA;AAAME,IAAAA,MAAAA;AAAQC,IAAAA;AAAO,GAAA;AAC1C;AAPgBG,MAAAA,CAAAA,qBAAAA,EAAAA,uBAAAA,CAAAA;AAYT,SAASC,mBAAmBR,QAAgB,EAAA;AACjD,EAAO,OAAA;AAAEA,IAAAA;AAAS,GAAA;AACpB;AAFgBQ,MAAAA,CAAAA,kBAAAA,EAAAA,oBAAAA,CAAAA;AAOT,SAASC,kBAAkB1F,QAAwB,EAAA;AACxD,EAAA,OAAO,OAAOA,QAASkF,CAAAA,IAAAA,KAAS,QAAY,IAAA,OAAOlF,SAASoF,MAAW,KAAA,QAAA;AACzE;AAFgBM,MAAAA,CAAAA,iBAAAA,EAAAA,mBAAAA,CAAAA","file":"chunk-6BOVVHHZ.mjs","sourcesContent":["/**\n * Type guards for Mlld AST nodes using discriminated unions\n */\n\n// Import node types for type guards\nimport type {\n TextNode,\n DirectiveNode,\n CodeFenceNode,\n CommentNode,\n VariableReferenceNode,\n LiteralNode,\n DotSeparatorNode,\n PathSeparatorNode,\n ExecInvocation,\n NegationNode,\n FileReferenceNode,\n BinaryExpression,\n TernaryExpression,\n UnaryExpression\n} from './primitives';\n\n// Import the union type\nimport type { MlldNode } from './index';\n\n// Import existing directive types\nimport { ImportDirectiveNode, ImportAllDirectiveNode, ImportSelectedDirectiveNode } from './import';\nimport {\n DataValue,\n DataObjectValue,\n DataArrayValue,\n isDirectiveValue,\n isTemplateValue as isContentNodeArray,\n isDataObjectValue,\n isDataArrayValue,\n isEmbedDirectiveValue,\n isRunDirectiveValue,\n isNestedDirective,\n isNestedEmbedDirective,\n isNestedRunDirective\n} from './var';\nimport { ImportWildcardNode } from './values';\nimport { WithClause } from './run';\n\n// Define InterpolatableValue for the guard function\nexport type InterpolatableValue = Array<TextNode | VariableReferenceNode>;\n\n/**\n * Type guard to check if a value is an InterpolatableValue array.\n * Checks if it's an array and if the first element (if any) looks like a TextNode or VariableReferenceNode.\n */\nexport function isInterpolatableValueArray(value: unknown): value is InterpolatableValue {\n return Array.isArray(value) && \n (value.length === 0 || \n (value[0] && typeof value[0] === 'object' && ('type' in value[0]) && \n (value[0].type === 'Text' || value[0].type === 'VariableReference')));\n}\n\n/**\n * Base node type guards using discriminated unions\n */\n\nexport function isTextNode(node: MlldNode): node is TextNode {\n return node.type === 'Text';\n}\n\nexport function isDirectiveNode(node: MlldNode): node is DirectiveNode {\n return node.type === 'Directive';\n}\n\nexport function isCodeFenceNode(node: MlldNode): node is CodeFenceNode {\n return node.type === 'CodeFence';\n}\n\nexport function isCommentNode(node: MlldNode): node is CommentNode {\n return node.type === 'Comment';\n}\n\nexport function isVariableReferenceNode(node: MlldNode): node is VariableReferenceNode {\n return node.type === 'VariableReference';\n}\n\nexport function isLiteralNode(node: MlldNode): node is LiteralNode {\n return node.type === 'Literal';\n}\n\nexport function isDotSeparatorNode(node: MlldNode): node is DotSeparatorNode {\n return node.type === 'DotSeparator';\n}\n\nexport function isPathSeparatorNode(node: MlldNode): node is PathSeparatorNode {\n return node.type === 'PathSeparator';\n}\n\nexport function isFileReferenceNode(node: MlldNode): node is FileReferenceNode {\n return node.type === 'FileReference';\n}\n\n/**\n * Import directive type guards\n */\n\nexport function isImportDirective(node: DirectiveNode): node is ImportDirectiveNode {\n return node.kind === 'import';\n}\n\nexport function isImportAllDirective(node: DirectiveNode): node is ImportAllDirectiveNode {\n return node.kind === 'import' && node.subtype === 'importAll';\n}\n\nexport function isImportSelectedDirective(node: DirectiveNode): node is ImportSelectedDirectiveNode {\n return node.kind === 'import' && node.subtype === 'importSelected';\n}\n\nexport function isWildcardImport(node: VariableReferenceNode): node is ImportWildcardNode {\n return node.valueType === 'import' && node.identifier === '*';\n}\n\n\n\n\n\n/**\n * ExecInvocation type guards\n */\n\nexport function isExecInvocation(node: any): node is ExecInvocation {\n return node?.type === 'ExecInvocation';\n}\n\nexport function hasWithClause(directive: any): directive is { values: { withClause: WithClause } } {\n return directive?.values?.withClause !== undefined;\n}\n\n/**\n * Negation type guard\n */\nexport function isNegationNode(node: any): node is NegationNode {\n return node?.type === 'Negation';\n}\n\n/**\n * Expression type guards for logical operators\n */\nexport function isBinaryExpression(node: any): node is BinaryExpression {\n return node?.type === 'BinaryExpression';\n}\n\nexport function isTernaryExpression(node: any): node is TernaryExpression {\n return node?.type === 'TernaryExpression';\n}\n\nexport function isUnaryExpression(node: any): node is UnaryExpression {\n return node?.type === 'UnaryExpression';\n}","/**\n * Error types for AST parsing\n */\n\nimport type { MlldNode } from './nodes';\n\n/**\n * Error codes for parsing failures\n */\nexport enum ParseErrorCode {\n INVALID_SYNTAX = 'INVALID_SYNTAX',\n INVALID_NODE = 'INVALID_NODE',\n UNEXPECTED_TOKEN = 'UNEXPECTED_TOKEN',\n MISSING_REQUIRED_FIELD = 'MISSING_REQUIRED_FIELD',\n INVALID_DIRECTIVE = 'INVALID_DIRECTIVE'\n}\n\n/**\n * AST parsing error\n */\nexport class MlldAstError extends Error {\n constructor(\n message: string,\n public code: ParseErrorCode,\n public location?: { start: { line: number; column: number }; end: { line: number; column: number } }\n ) {\n super(message);\n this.name = 'MlldAstError';\n }\n}\n\n/**\n * Peggy parser error interface\n */\nexport interface PeggyError {\n message: string;\n location?: {\n start: { line: number; column: number; offset: number };\n end: { line: number; column: number; offset: number };\n };\n expected?: Array<{ type: string; description?: string }>;\n found?: string;\n}\n\n/**\n * Parser options\n */\nexport interface ParserOptions {\n failFast?: boolean;\n trackLocations?: boolean;\n validateNodes?: boolean;\n preserveCodeFences?: boolean;\n onError?: (error: Error) => void;\n}\n\n/**\n * Parse result\n */\nexport interface ParseResult {\n success: boolean;\n nodes?: MlldNode[];\n errors?: Error[];\n}","import { \n DirectiveNode, \n NodeType, \n PathNode, \n PathNodeArray, \n TextNode, \n TextNodeArray, \n TypedDirectiveNode, \n VariableNode, \n VariableNodeArray \n} from './base';\n\n// ====================\n// Raw Value Interfaces\n// ====================\n\nexport interface ShowRaw {\n path?: string;\n section?: string;\n headerLevel?: string;\n underHeader?: string;\n content?: string;\n variable?: string;\n names?: string[];\n sectionTitle?: string;\n newTitle?: string;\n}\n\nexport interface ShowPathRaw extends ShowRaw {\n path: string;\n section?: string;\n headerLevel?: string;\n underHeader?: string;\n}\n\nexport interface ShowTemplateRaw extends ShowRaw {\n content: string;\n headerLevel?: string;\n underHeader?: string;\n}\n\nexport interface ShowVariableRaw extends ShowRaw {\n variable: string;\n headerLevel?: string;\n underHeader?: string;\n}\n\nexport interface ShowPathSectionRaw extends ShowRaw {\n sectionTitle: string;\n path: string;\n newTitle?: string;\n}\n\n\n// ====================\n// Value Interfaces\n// ====================\n\nexport interface ShowValues {\n path?: PathNodeArray;\n section?: TextNodeArray;\n headerLevel?: number;\n underHeader?: TextNodeArray;\n content?: TextNodeArray;\n variable?: VariableNodeArray;\n names?: VariableNodeArray;\n sectionTitle?: TextNodeArray;\n newTitle?: TextNodeArray;\n}\n\nexport interface ShowPathValues extends ShowValues {\n path: PathNodeArray;\n section?: TextNodeArray;\n headerLevel?: number;\n underHeader?: TextNodeArray;\n}\n\nexport interface ShowTemplateValues extends ShowValues {\n content: TextNodeArray;\n headerLevel?: number;\n underHeader?: TextNodeArray;\n}\n\nexport interface ShowVariableValues extends ShowValues {\n variable: VariableNodeArray;\n headerLevel?: number;\n underHeader?: TextNodeArray;\n}\n\nexport interface ShowPathSectionValues extends ShowValues {\n sectionTitle: TextNodeArray;\n path: PathNodeArray;\n newTitle?: TextNodeArray;\n}\n\n\n// ====================\n// Metadata Interfaces\n// ====================\n\nexport interface ShowMeta {\n path?: {\n hasVariables: boolean;\n };\n isTemplateContent?: boolean;\n}\n\nexport interface ShowPathMeta extends ShowMeta {\n path: {\n hasVariables: boolean;\n };\n}\n\nexport interface ShowTemplateMeta extends ShowMeta {\n isTemplateContent: boolean;\n hasVariables: boolean;\n wrapperType: string;\n}\n\nexport interface ShowPathSectionMeta extends ShowMeta {\n path: {\n hasVariables: boolean;\n };\n}\n\n// ====================\n// Node Interfaces\n// ====================\n\nexport interface ShowDirectiveNode extends TypedDirectiveNode<'show', \n 'showPath' | 'showTemplate' | 'showVariable' | 'showPathSection'> {\n values: ShowValues;\n raw: ShowRaw;\n meta: ShowMeta;\n}\n\nexport interface ShowPathDirectiveNode extends ShowDirectiveNode {\n subtype: 'showPath';\n values: ShowPathValues;\n raw: ShowPathRaw;\n meta: ShowPathMeta;\n}\n\nexport interface ShowTemplateDirectiveNode extends ShowDirectiveNode {\n subtype: 'showTemplate';\n values: ShowTemplateValues;\n raw: ShowTemplateRaw;\n meta: ShowTemplateMeta;\n}\n\nexport interface ShowVariableDirectiveNode extends ShowDirectiveNode {\n subtype: 'showVariable';\n values: ShowVariableValues;\n raw: ShowVariableRaw;\n meta: ShowMeta;\n}\n\nexport interface ShowPathSectionDirectiveNode extends ShowDirectiveNode {\n subtype: 'showPathSection';\n values: ShowPathSectionValues;\n raw: ShowPathSectionRaw;\n meta: ShowPathSectionMeta;\n}\n\n\n// ====================\n// Type Guards\n// ====================\n\nexport function isShowDirectiveNode(node: DirectiveNode): node is ShowDirectiveNode {\n return node.kind === 'show';\n}\n\nexport function isShowPathDirectiveNode(node: DirectiveNode): node is ShowPathDirectiveNode {\n return isShowDirectiveNode(node) && node.subtype === 'showPath';\n}\n\nexport function isShowTemplateDirectiveNode(node: DirectiveNode): node is ShowTemplateDirectiveNode {\n return isShowDirectiveNode(node) && node.subtype === 'showTemplate';\n}\n\nexport function isShowVariableDirectiveNode(node: DirectiveNode): node is ShowVariableDirectiveNode {\n return isShowDirectiveNode(node) && node.subtype === 'showVariable';\n}\n\nexport function isShowPathSectionDirectiveNode(node: DirectiveNode): node is ShowPathSectionDirectiveNode {\n return isShowDirectiveNode(node) && node.subtype === 'showPathSection';\n}\n\n","/**\n * Exe directive type definitions\n */\nimport { DirectiveNode, TypedDirectiveNode } from './base';\nimport { ContentNodeArray, TextNodeArray, VariableNodeArray } from './values';\nimport { WithClause } from './run';\nimport { ParameterNode } from './primitives';\n\n/**\n * Exe directive raw values\n */\nexport interface ExeRaw {\n identifier: string;\n params: string[];\n metadata?: string;\n command?: string;\n lang?: string;\n code?: string;\n withClause?: WithClause;\n}\n\n/**\n * Exe directive metadata\n */\nexport interface ExeMeta {\n parameterCount: number;\n argumentCount?: number;\n hasVariables?: boolean;\n language?: string;\n isMultiLine?: boolean;\n metadata?: {\n type?: string;\n [key: string]: unknown;\n };\n withClause?: WithClause;\n}\n\n/**\n * Base Exe directive node\n */\nexport interface ExeDirectiveNode extends TypedDirectiveNode<'exe', ExeSubtype> {\n values: ExeValues;\n raw: ExeRaw;\n meta: ExeMeta;\n}\n\n/**\n * Exe subtypes\n */\nexport type ExeSubtype = 'exeCommand' | 'exeCode';\n\n/**\n * Exe directive values - different structures based on subtype\n */\nexport interface ExeValues {\n identifier: TextNodeArray;\n params: ParameterNode[];\n metadata?: TextNodeArray;\n command?: ContentNodeArray;\n lang?: TextNodeArray;\n code?: ContentNodeArray;\n withClause?: WithClause;\n}\n\n/**\n * Exe Command directive - /exe commandName (params) = /run [command]\n */\nexport interface ExeCommandDirectiveNode extends ExeDirectiveNode {\n subtype: 'exeCommand';\n values: {\n identifier: TextNodeArray;\n params: ParameterNode[];\n metadata?: TextNodeArray;\n command: ContentNodeArray;\n };\n raw: {\n identifier: string;\n params: string[];\n metadata?: string;\n command: string;\n };\n meta: ExeMeta;\n}\n\n/**\n * Exe Code directive - /exe commandName (params) = /run language [code]\n */\nexport interface ExeCodeDirectiveNode extends ExeDirectiveNode {\n subtype: 'exeCode';\n values: {\n identifier: TextNodeArray;\n params: ParameterNode[];\n metadata?: TextNodeArray;\n lang: TextNodeArray;\n code: ContentNodeArray;\n };\n raw: {\n identifier: string;\n params: string[];\n metadata?: string;\n lang: string;\n code: string;\n };\n meta: ExeMeta;\n}\n\n/**\n * Type guards to check the type of an exe directive\n */\nexport function isExeDirectiveNode(node: DirectiveNode): node is ExeDirectiveNode {\n return node.kind === 'exe';\n}\n\nexport function isExeCommandDirective(node: ExeDirectiveNode): node is ExeCommandDirectiveNode {\n return node.subtype === 'exeCommand';\n}\n\nexport function isExeCodeDirective(node: ExeDirectiveNode): node is ExeCodeDirectiveNode {\n return node.subtype === 'exeCode';\n}","/**\n * Path directive type definitions\n */\nimport { DirectiveNode, TypedDirectiveNode } from './base';\nimport { VariableNodeArray, PathNodeArray } from './values';\nimport { PathRaw } from './raw';\nimport { PathDirectiveMeta } from './meta';\nimport { TTLValue } from './primitives';\nimport { WithClause } from './run';\n\n/**\n * Path directive values structure\n */\nexport interface PathValues {\n // Common to all path directive subtypes\n identifier: VariableNodeArray;\n path: PathNodeArray;\n ttl?: TTLValue;\n withClause?: WithClause;\n}\n\n/**\n * Base Path directive node\n */\nexport interface PathDirectiveNode extends TypedDirectiveNode<'path', 'pathAssignment'> {\n values: PathValues;\n raw: PathRaw;\n meta: PathDirectiveMeta;\n}\n\n/**\n * Path Assignment directive - @path var = \"$PROJECTPATH/value\"\n */\nexport interface PathAssignmentDirectiveNode extends PathDirectiveNode {\n subtype: 'pathAssignment';\n values: {\n identifier: VariableNodeArray;\n path: PathNodeArray;\n ttl?: TTLValue;\n withClause?: WithClause;\n };\n raw: {\n identifier: string;\n path: string;\n };\n}\n\n/**\n * Type guard to check if node is a path directive\n */\nexport function isPathDirective(node: DirectiveNode): node is PathDirectiveNode {\n return node.kind === 'path';\n}\n\n/**\n * Type guard to check if node is a path assignment directive\n */\nexport function isPathAssignmentDirective(node: DirectiveNode): node is PathAssignmentDirectiveNode {\n return isPathDirective(node) && node.subtype === 'pathAssignment';\n}\n\n/**\n * Type guard to check if node has a special variable path\n */\nexport function hasSpecialVariablePath(node: PathAssignmentDirectiveNode): boolean {\n // Check if the path contains a special variable reference (HOMEPATH, PROJECTPATH, etc.)\n if (node.values.path.length > 0) {\n const firstComponent = node.values.path[0];\n if (firstComponent.type === 'string' && \n (firstComponent.value.startsWith('$HOMEPATH') || \n firstComponent.value.startsWith('$~') ||\n firstComponent.value.startsWith('$PROJECTPATH') ||\n firstComponent.value.startsWith('$.'))) {\n return true;\n }\n \n // For interpolated strings, check components\n if (firstComponent.type === 'interpolated' && \n firstComponent.components && \n firstComponent.components.length > 0 &&\n firstComponent.components[0].type === 'specialVariable') {\n return true;\n }\n }\n \n return false;\n}","/**\n * Run directive type definitions\n */\nimport { DirectiveNode, TypedDirectiveNode } from './base';\nimport { ContentNodeArray, TextNodeArray, VariableNodeArray } from './values';\nimport { TrustLevel } from './primitives';\n\n/**\n * With clause for pipeline and dependency management\n */\nexport interface WithClause {\n pipeline?: PipelineCommand[];\n needs?: DependencyMap;\n trust?: TrustLevel;\n [key: string]: any; // For other with clause properties\n}\n\n/**\n * A pipeline command reference\n */\nexport interface PipelineCommand {\n identifier: VariableNodeArray;\n args: VariableNodeArray[];\n fields?: any[]; // Field access array\n rawIdentifier: string;\n rawArgs: string[];\n}\n\n/**\n * Dependency map by language\n */\nexport interface DependencyMap {\n [language: string]: {\n [packageName: string]: string; // version constraint\n };\n}\n\n/**\n * Run directive raw values\n */\nexport interface RunRaw {\n command?: string;\n lang?: string;\n args?: string[];\n code?: string;\n identifier?: string;\n withClause?: WithClause;\n}\n\n/**\n * Run directive metadata\n */\nexport interface RunMeta {\n isMultiLine?: boolean;\n argumentCount?: number;\n language?: string;\n hasVariables?: boolean;\n withClause?: WithClause;\n}\n\n/**\n * Base Run directive node\n */\nexport interface RunDirectiveNode extends TypedDirectiveNode<'run', RunSubtype> {\n values: RunValues;\n raw: RunRaw;\n meta: RunMeta;\n}\n\n/**\n * Run subtypes\n */\nexport type RunSubtype = 'runCommand' | 'runCode' | 'runExec';\n\n/**\n * Run directive values - different structures based on subtype\n */\nexport interface RunValues {\n command?: ContentNodeArray;\n lang?: TextNodeArray;\n args?: VariableNodeArray;\n code?: ContentNodeArray;\n identifier?: VariableNodeArray;\n withClause?: WithClause;\n}\n\n/**\n * Run Command directive - @run [command]\n */\nexport interface RunCommandDirectiveNode extends RunDirectiveNode {\n subtype: 'runCommand';\n values: {\n command: ContentNodeArray;\n };\n raw: {\n command: string;\n };\n meta: {\n isMultiLine: boolean;\n hasVariables: boolean;\n };\n}\n\n/**\n * Run Code directive - @run language [code]\n */\nexport interface RunCodeDirectiveNode extends RunDirectiveNode {\n subtype: 'runCode';\n values: {\n lang: TextNodeArray;\n args: VariableNodeArray;\n code: ContentNodeArray;\n };\n raw: {\n lang: string;\n args: string[];\n code: string;\n };\n meta: {\n isMultiLine: boolean;\n language: string;\n };\n}\n\n/**\n * Run Exec directive - @run $commandName (arg1, arg2)\n */\nexport interface RunExecDirectiveNode extends RunDirectiveNode {\n subtype: 'runExec';\n values: {\n identifier: VariableNodeArray;\n args: VariableNodeArray;\n };\n raw: {\n identifier: string;\n args: string[];\n };\n meta: {\n argumentCount: number;\n };\n}\n\n/**\n * Type guards to check the type of a run directive\n */\nexport function isRunCommandDirective(node: RunDirectiveNode): node is RunCommandDirectiveNode {\n return node.subtype === 'runCommand';\n}\n\nexport function isRunCodeDirective(node: RunDirectiveNode): node is RunCodeDirectiveNode {\n return node.subtype === 'runCode';\n}\n\nexport function isRunExecDirective(node: RunDirectiveNode): node is RunExecDirectiveNode {\n return node.subtype === 'runExec';\n}","/**\n * Type definitions for the output directive\n */\nimport { \n TypedDirectiveNode,\n BaseMlldNode,\n TextNode,\n VariableReferenceNode\n} from './base';\nimport type { FieldAccessNode } from './primitives';\n\n// Output directive subtypes\nexport type OutputSubtype = \n | 'outputDocument'\n | 'outputFile'\n | 'outputStream'\n | 'outputEnv'\n | 'outputResolver'\n | 'outputVariable'\n | 'outputInvocation'\n | 'outputExecInvocation'\n | 'outputCommand'\n | 'outputLiteral';\n\n// Output target types\nexport interface OutputTargetFile {\n type: 'file';\n path: BaseMlldNode[];\n raw: string;\n meta: {\n quoted?: boolean;\n bracketed?: boolean;\n unquoted?: boolean;\n };\n}\n\nexport interface OutputTargetStream {\n type: 'stream';\n stream: 'stdout' | 'stderr';\n raw: string;\n}\n\nexport interface OutputTargetEnv {\n type: 'env';\n varname: string | null; // null means use default MLLD_VARIABLE pattern\n raw: string;\n}\n\nexport interface OutputTargetResolver {\n type: 'resolver';\n resolver: string;\n path: TextNode[];\n raw: string;\n}\n\nexport type OutputTarget = \n | OutputTargetFile\n | OutputTargetStream\n | OutputTargetEnv\n | OutputTargetResolver;\n\n// Output source types\nexport interface OutputSourceVariable {\n type: 'variable';\n subtype: 'outputVariable' | 'outputInvocation';\n values: {\n identifier: VariableReferenceNode[];\n fields?: FieldAccessNode[]; // Field access\n args?: BaseMlldNode[]; // For invocations\n };\n raw: {\n identifier: string;\n fields?: string[];\n args?: string[];\n };\n}\n\nexport interface OutputSourceExec {\n type: 'exec';\n subtype: 'outputExecInvocation';\n values: BaseMlldNode[]; // Exec invocation with tail modifiers\n raw: {\n commandName: string;\n };\n}\n\nexport interface OutputSourceCommand {\n type: 'command';\n subtype: 'outputCommand';\n values: {\n identifier: VariableReferenceNode[];\n args: BaseMlldNode[];\n };\n raw: {\n identifier: string;\n args: string[];\n };\n}\n\nexport interface OutputSourceLiteral {\n type: 'literal';\n subtype: 'outputLiteral';\n values: TextNode[];\n raw: string;\n}\n\nexport type OutputSource = \n | OutputSourceVariable\n | OutputSourceExec\n | OutputSourceCommand\n | OutputSourceLiteral;\n\n// Base output directive interface\nexport interface OutputDirectiveBase extends TypedDirectiveNode<'output', OutputSubtype> {\n kind: 'output';\n values: {\n source?: OutputSource['values'];\n target: OutputTarget;\n };\n raw: {\n source?: OutputSource['raw'];\n target: string;\n };\n meta: {\n sourceType?: OutputSource['type'];\n targetType: OutputTarget['type'];\n hasSource: boolean;\n format?: string;\n explicitFormat?: boolean;\n legacy?: boolean; // For backward compatibility with [path] syntax\n };\n}\n\n// Specific output directive types\nexport interface OutputDocumentDirective extends OutputDirectiveBase {\n subtype: 'outputDocument';\n meta: OutputDirectiveBase['meta'] & { hasSource: false };\n}\n\nexport interface OutputFileDirective extends OutputDirectiveBase {\n subtype: 'outputFile';\n}\n\nexport interface OutputStreamDirective extends OutputDirectiveBase {\n subtype: 'outputStream';\n}\n\nexport interface OutputEnvDirective extends OutputDirectiveBase {\n subtype: 'outputEnv';\n}\n\nexport interface OutputResolverDirective extends OutputDirectiveBase {\n subtype: 'outputResolver';\n}\n\n// Union of all output directive types\nexport type OutputDirective = \n | OutputDocumentDirective\n | OutputFileDirective\n | OutputStreamDirective\n | OutputEnvDirective\n | OutputResolverDirective;\n\n// Type guards\nexport function isOutputDirective(node: BaseMlldNode): node is OutputDirective {\n return node.type === 'Directive' && (node as any).kind === 'output';\n}\n\nexport function isOutputDocumentDirective(node: BaseMlldNode): node is OutputDocumentDirective {\n return isOutputDirective(node) && node.subtype === 'outputDocument';\n}\n\nexport function isOutputFileDirective(node: BaseMlldNode): node is OutputFileDirective {\n return isOutputDirective(node) && node.subtype === 'outputFile';\n}\n\nexport function isOutputStreamDirective(node: BaseMlldNode): node is OutputStreamDirective {\n return isOutputDirective(node) && node.subtype === 'outputStream';\n}\n\nexport function isOutputEnvDirective(node: BaseMlldNode): node is OutputEnvDirective {\n return isOutputDirective(node) && node.subtype === 'outputEnv';\n}\n\nexport function isOutputResolverDirective(node: BaseMlldNode): node is OutputResolverDirective {\n return isOutputDirective(node) && node.subtype === 'outputResolver';\n}\n\n// Utility function to check if target is a file\nexport function isFileTarget(target: OutputTarget): target is OutputTargetFile {\n return target.type === 'file';\n}\n\n// Utility function to check if target is a stream\nexport function isStreamTarget(target: OutputTarget): target is OutputTargetStream {\n return target.type === 'stream';\n}\n\n// Utility function to check if target is env\nexport function isEnvTarget(target: OutputTarget): target is OutputTargetEnv {\n return target.type === 'env';\n}\n\n// Utility function to check if target is resolver\nexport function isResolverTarget(target: OutputTarget): target is OutputTargetResolver {\n return target.type === 'resolver';\n}","/**\n * Type definitions for the @when conditional directive\n */\n\nimport type { DirectiveNode, BaseMlldNode } from './nodes';\n\n/**\n * Modifiers for when block form that control evaluation behavior\n */\nexport type WhenModifier = 'first' | 'all' | 'any';\n\n/**\n * Represents a condition-action pair in when block form\n */\nexport interface WhenConditionPair {\n condition: BaseMlldNode[];\n action?: BaseMlldNode[];\n}\n\n/**\n * Simple form of @when directive: @when <condition> => <action>\n */\nexport interface WhenSimpleNode extends DirectiveNode {\n kind: 'when';\n subtype: 'whenSimple';\n values: {\n condition: BaseMlldNode[];\n action: BaseMlldNode[];\n };\n}\n\n/**\n * Block form of @when directive: @when <var> <modifier>: [...]\n */\nexport interface WhenBlockNode extends DirectiveNode {\n kind: 'when';\n subtype: 'whenBlock';\n values: {\n variable?: BaseMlldNode[];\n modifier: BaseMlldNode[]; // Text node containing modifier value\n conditions: WhenConditionPair[];\n action?: BaseMlldNode[]; // Optional block-level action\n };\n meta: {\n modifier: WhenModifier;\n conditionCount: number;\n hasVariable?: boolean;\n };\n}\n\n/**\n * Match form of @when directive: @when <expression>: [value => action, ...]\n * Evaluates expression and executes actions for all matching conditions\n */\nexport interface WhenMatchNode extends DirectiveNode {\n kind: 'when';\n subtype: 'whenMatch';\n values: {\n expression: BaseMlldNode[]; // Expression to evaluate\n conditions: WhenConditionPair[]; // value => action pairs\n };\n meta: {\n conditionCount: number;\n };\n}\n\n/**\n * Union type for all when directive nodes\n */\nexport type WhenNode = WhenSimpleNode | WhenBlockNode | WhenMatchNode;\n\n/**\n * Type guard for when simple form\n */\nexport function isWhenSimpleNode(node: DirectiveNode): node is WhenSimpleNode {\n return node.kind === 'when' && node.subtype === 'whenSimple';\n}\n\n/**\n * Type guard for when block form\n */\nexport function isWhenBlockNode(node: DirectiveNode): node is WhenBlockNode {\n return node.kind === 'when' && node.subtype === 'whenBlock';\n}\n\n/**\n * Type guard for when match form\n */\nexport function isWhenMatchNode(node: DirectiveNode): node is WhenMatchNode {\n return node.kind === 'when' && node.subtype === 'whenMatch';\n}\n\n/**\n * Type guard for any when directive\n */\nexport function isWhenNode(node: DirectiveNode): node is WhenNode {\n return node.kind === 'when';\n}\n\n/**\n * Tail modifiers that can be applied to when expression results\n */\nexport interface TailModifiers {\n pipes?: BaseMlldNode[];\n}\n\n/**\n * When expression for value-returning contexts\n * Used in /var and /exe RHS: when: [condition => value, ...]\n */\nexport interface WhenExpressionNode extends BaseMlldNode {\n type: 'WhenExpression';\n conditions: WhenConditionPair[];\n withClause?: TailModifiers;\n meta: {\n conditionCount: number;\n isValueReturning: true;\n evaluationType: 'expression';\n hasTailModifiers: boolean;\n };\n}\n\n/**\n * Type guard for when expressions\n */\nexport function isWhenExpression(node: BaseMlldNode): node is WhenExpressionNode {\n return node.type === 'WhenExpression';\n}","/**\n * Var directive AST node type definitions\n * \n * This file defines the AST node types for the new @var directive.\n * These types represent the parsed structure from the grammar.\n */\n\nimport { TypedDirectiveNode } from './base';\nimport { ContentNodeArray, VariableNodeArray } from './values';\nimport { DirectiveNode, ExecInvocation } from './nodes';\n\n/**\n * Data object value structure for var directive\n */\nexport interface DataObjectValue {\n type: 'object';\n properties: Record<string, DataValue>;\n}\n\n/**\n * Data array value structure for var directive\n */\nexport interface DataArrayValue {\n type: 'array';\n items: DataValue[];\n}\n\n/**\n * Foreach command expression structure\n */\nexport interface ForeachCommandExpression {\n type: 'foreach';\n command: ExecInvocation;\n arrays: (ContentNodeArray | DirectiveNode)[];\n}\n\n/**\n * Foreach section expression structure\n */\nexport interface ForeachSectionExpression {\n type: 'foreachSection';\n template: ContentNodeArray;\n arrays: (ContentNodeArray | DirectiveNode)[];\n}\n\n/**\n * Recursive type for data values\n */\nexport type DataValue = \n | ContentNodeArray // String literals, numbers, booleans\n | DataObjectValue\n | DataArrayValue\n | DirectiveNode // Nested directive\n | ExecInvocation // Exec invocation\n | ForeachCommandExpression\n | ForeachSectionExpression;\n\n/**\n * Var directive raw values\n */\nexport interface VarRaw {\n identifier: string;\n value?: string;\n [key: string]: string | undefined; // Allow additional properties for compatibility\n}\n\n/**\n * Var directive metadata\n */\nexport interface VarMeta {\n inferredType?: 'text' | 'data' | 'path' | 'exec';\n [key: string]: unknown;\n}\n\n/**\n * Var directive values - the parsed AST structure\n */\nexport interface VarValues {\n identifier: VariableNodeArray;\n value?: VarValue; // Optional for declarations without initial value\n [key: string]: any; // Allow additional properties for compatibility\n}\n\n/**\n * AST value type for @var directive - represents parsed values\n */\nexport type VarValue = \n | ContentNodeArray // String literals, numbers, booleans, paths\n | DataObjectValue // Objects\n | DataArrayValue // Arrays\n | DirectiveNode // Nested directives (@run, @add, etc.)\n | ExecInvocation // Exec invocations\n | ForeachCommandExpression // Foreach command expressions\n | ForeachSectionExpression // Foreach section expressions\n | VarExecDefinition; // Exec definitions (parameterized commands)\n\n/**\n * Exec definition AST structure\n */\nexport interface VarExecDefinition {\n type: 'varExec';\n params?: VariableNodeArray[]; // Parameter names as variable nodes\n body: VarExecBody;\n}\n\n/**\n * Exec body AST structure\n */\nexport type VarExecBody = \n | { type: 'command'; nodes: ContentNodeArray }\n | { type: 'code'; language: string; nodes: ContentNodeArray };\n\n/**\n * Base Var directive AST node\n */\nexport interface VarDirectiveNode extends TypedDirectiveNode<'var', 'varAssignment'> {\n values: VarValues;\n raw: VarRaw;\n meta: VarMeta;\n}\n\n/**\n * Var Assignment directive AST node - @var name = value\n */\nexport interface VarAssignmentDirectiveNode extends VarDirectiveNode {\n subtype: 'varAssignment';\n values: {\n identifier: VariableNodeArray;\n value?: VarValue;\n };\n raw: {\n identifier: string;\n value?: string;\n };\n}\n\n/**\n * Type guard to check if a node is a var directive\n */\nexport function isVarDirectiveNode(node: unknown): node is VarDirectiveNode {\n return node && \n typeof node === 'object' && \n node.type === 'Directive' && \n node.kind === 'var';\n}\n\n/**\n * Type guard to check if a value is a var exec definition\n */\nexport function isVarExecDefinition(value: VarValue): value is VarExecDefinition {\n return typeof value === 'object' && \n value !== null && \n !Array.isArray(value) && \n 'type' in value && \n value.type === 'varExec';\n}\n\n/**\n * Type guard to check if content is a nested directive\n */\nexport function isNestedDirective(content: VarValue): content is DirectiveNode {\n return typeof content === 'object' &&\n content !== null &&\n !Array.isArray(content) && \n 'kind' in content;\n}\n\n/**\n * Type guard to check if content is a data object\n */\nexport function isDataObject(value: VarValue): value is DataObjectValue {\n return typeof value === 'object' && \n value !== null &&\n !Array.isArray(value) && \n 'type' in value && \n value.type === 'object';\n}\n\n/**\n * Type guard to check if content is a data array\n */\nexport function isDataArray(value: VarValue): value is DataArrayValue {\n return typeof value === 'object' && \n value !== null &&\n !Array.isArray(value) && \n 'type' in value && \n value.type === 'array';\n}\n\n/**\n * Type guard to check if value is a primitive (string, number, boolean, null)\n */\nexport function isPrimitiveValue(value: unknown): value is string | number | boolean | null {\n return value === null || \n typeof value === 'string' || \n typeof value === 'number' || \n typeof value === 'boolean';\n}\n\n/**\n * Type guard to check if value is a directive node\n */\nexport function isDirectiveValue(value: unknown): value is DirectiveNode {\n return typeof value === 'object' &&\n value !== null &&\n 'type' in value &&\n value.type === 'Directive' &&\n 'kind' in value;\n}\n\n/**\n * Type guard to check if value is a variable reference node\n */\nexport function isVariableReferenceValue(value: unknown): value is ContentNodeArray {\n if (!Array.isArray(value)) return false;\n return value.some(node => \n typeof node === 'object' &&\n node !== null &&\n 'type' in node &&\n node.type === 'VariableReference'\n );\n}\n\n/**\n * Type guard to check if value is a template (array with Text/VariableReference nodes)\n */\nexport function isTemplateValue(value: unknown): value is ContentNodeArray {\n if (!Array.isArray(value)) return false;\n return value.some(node => \n typeof node === 'object' &&\n node !== null &&\n 'type' in node &&\n (node.type === 'Text' || node.type === 'VariableReference')\n );\n}\n\n/**\n * Type guard to check if value is a data object value\n */\nexport function isDataObjectValue(value: unknown): value is DataObjectValue {\n return typeof value === 'object' && \n value !== null &&\n !Array.isArray(value) && \n 'type' in value && \n value.type === 'object';\n}\n\n/**\n * Type guard to check if value is a data array value\n */\nexport function isDataArrayValue(value: unknown): value is DataArrayValue {\n return typeof value === 'object' && \n value !== null &&\n !Array.isArray(value) && \n 'type' in value && \n value.type === 'array';\n}\n\n/**\n * Type guard to check if value is an embed directive\n */\nexport function isEmbedDirectiveValue(value: unknown): boolean {\n return isDirectiveValue(value) && value.kind === 'embed';\n}\n\n/**\n * Type guard to check if value is a run directive\n */\nexport function isRunDirectiveValue(value: unknown): boolean {\n return isDirectiveValue(value) && value.kind === 'run';\n}\n\n/**\n * Type guard to check if content is a nested embed directive\n */\nexport function isNestedEmbedDirective(content: unknown): boolean {\n return isDirectiveValue(content) && content.kind === 'embed';\n}\n\n/**\n * Type guard to check if content is a nested run directive\n */\nexport function isNestedRunDirective(content: unknown): boolean {\n return isDirectiveValue(content) && content.kind === 'run';\n}\n\n/**\n * Type guard to check if content is a content node array (primitive value)\n */\nexport function isContentNodes(value: VarValue): value is ContentNodeArray {\n return Array.isArray(value);\n}\n\n/**\n * Type guard to check if var contains a foreach expression\n */\nexport function isForeachExpression(value: VarValue): value is ForeachCommandExpression | ForeachSectionExpression {\n return typeof value === 'object' && \n value !== null &&\n !Array.isArray(value) && \n 'type' in value && \n (value.type === 'foreach-command' || value.type === 'foreach-section');\n}","import type { DirectiveNode, BaseMlldNode, VariableReferenceNode } from './primitives';\n\n/**\n * Directive node for /for loops\n * Represents: /for @var in @collection => action\n */\nexport interface ForDirective extends DirectiveNode {\n kind: 'for';\n subtype: 'for';\n values: {\n /** Iteration variable (e.g., @item) */\n variable: VariableReferenceNode[];\n /** Collection to iterate over */\n source: BaseMlldNode[];\n /** Action to execute for each item */\n action: BaseMlldNode[];\n };\n meta: {\n hasVariables: true;\n actionType: 'single';\n };\n}\n\n/**\n * Expression node for for...in expressions\n * Represents: for @var in @collection => expression\n * Used in /var and /exe assignments to collect results\n */\nexport interface ForExpression extends BaseMlldNode {\n type: 'ForExpression';\n /** Iteration variable */\n variable: VariableReferenceNode;\n /** Collection to iterate over */\n source: BaseMlldNode[];\n /** Expression to evaluate for each item */\n expression: BaseMlldNode[];\n meta: {\n isForExpression: true;\n };\n}\n\n/**\n * Type guard for ForDirective\n */\nexport function isForDirective(node: DirectiveNode): node is ForDirective {\n return node.kind === 'for' && node.subtype === 'for';\n}\n\n/**\n * Type guard for ForExpression\n */\nexport function isForExpression(node: BaseMlldNode): node is ForExpression {\n return node.type === 'ForExpression';\n}","/**\n * Types for variables in Mlld grammar\n */\n\n/**\n * Enumeration of variable types used in the new grammar\n */\nexport enum VariableValueType {\n // Core variable types\n TEXT = 'text',\n DATA = 'data',\n PATH = 'path',\n EXEC = 'exec',\n IMPORT = 'import',\n \n // New universal variable syntax types\n VAR_INTERPOLATION = 'varInterpolation',\n VAR_IDENTIFIER = 'varIdentifier'\n}\n\n/**\n * List of all valid variable types that should pass validation\n * This is centralized here to avoid hard-coding in validation logic\n */\nexport const VALID_VARIABLE_TYPES = [\n // Core types\n 'text',\n 'data',\n 'path',\n 'exec',\n 'import',\n \n // New universal types\n 'varInterpolation',\n 'varIdentifier'\n];\n\n/**\n * Function to validate if a given string is a valid variable type\n */\nexport function isValidVariableType(type: string): boolean {\n return VALID_VARIABLE_TYPES.includes(type);\n}\n\n/**\n * Interface for fields in a variable reference\n */\nexport interface Field {\n type: 'field' | 'index';\n value: string | number;\n}\n\n/**\n * Create a variable reference node with proper type checking\n */\nexport function createVariableReferenceNode(\n identifier: string,\n valueType: string,\n fields?: Field[],\n format?: string,\n location?: { start: { line: number; column: number }; end: { line: number; column: number } }\n): any { // Return any for now since we need VariableReferenceNode\n return {\n type: 'VariableReference',\n identifier,\n valueType,\n fields,\n isVariableReference: true,\n nodeId: 'generated-' + Date.now() + '-' + Math.random(), // Simple ID generation\n ...(format && { format }),\n ...(location && { location })\n };\n}","/**\n * Unified executable type definitions for mlld\n * \n * This module defines a unified Executable interface that encompasses\n * both @exec commands and @text templates with parameters.\n */\n\nimport { MlldNode } from './nodes';\nimport { VariableMetadata } from './index';\n\n/**\n * Base executable definition that can be invoked with parameters\n */\nexport interface BaseExecutable {\n /** The type of executable */\n type: 'command' | 'commandRef' | 'code' | 'template' | 'section' | 'resolver';\n /** Parameter names expected by this executable */\n paramNames: string[];\n /** Original directive type this came from (exec or text) */\n sourceDirective: 'exec' | 'text';\n}\n\n/**\n * Command executable - @exec name(params) = @run [command]\n */\nexport interface CommandExecutable extends BaseExecutable {\n type: 'command';\n commandTemplate: MlldNode[];\n sourceDirective: 'exec';\n}\n\n/**\n * Command reference executable - @exec name(params) = @otherCommand(args)\n */\nexport interface CommandRefExecutable extends BaseExecutable {\n type: 'commandRef';\n commandRef: string;\n commandArgs?: MlldNode[];\n sourceDirective: 'exec';\n}\n\n/**\n * Code executable - @exec name(params) = @run language [code]\n */\nexport interface CodeExecutable extends BaseExecutable {\n type: 'code';\n codeTemplate: MlldNode[];\n language: string;\n sourceDirective: 'exec';\n}\n\n/**\n * Template executable - @text name(params) = [[template]]\n */\nexport interface TemplateExecutable extends BaseExecutable {\n type: 'template';\n template: MlldNode[];\n sourceDirective: 'text' | 'exec';\n}\n\n/**\n * Section executable - @exec name(file, section) = [@file # @section]\n */\nexport interface SectionExecutable extends BaseExecutable {\n type: 'section';\n pathTemplate: MlldNode[];\n sectionTemplate: MlldNode[];\n renameTemplate?: MlldNode[];\n sourceDirective: 'exec';\n}\n\n/**\n * Resolver executable - @exec name(params) = @resolver/path { @payload }\n */\nexport interface ResolverExecutable extends BaseExecutable {\n type: 'resolver';\n resolverPath: string;\n payloadTemplate?: MlldNode[];\n sourceDirective: 'exec';\n}\n\n/**\n * Unified executable type\n */\nexport type ExecutableDefinition = \n | CommandExecutable \n | CommandRefExecutable \n | CodeExecutable \n | TemplateExecutable\n | SectionExecutable\n | ResolverExecutable;\n\n/**\n * Variable that stores an executable definition\n */\nexport interface ExecutableVariable {\n type: 'executable';\n name: string;\n value: ExecutableDefinition;\n metadata?: VariableMetadata;\n}\n\n/**\n * Type guards for executable types\n */\nexport function isCommandExecutable(def: ExecutableDefinition): def is CommandExecutable {\n return def.type === 'command';\n}\n\nexport function isCommandRefExecutable(def: ExecutableDefinition): def is CommandRefExecutable {\n return def.type === 'commandRef';\n}\n\nexport function isCodeExecutable(def: ExecutableDefinition): def is CodeExecutable {\n return def.type === 'code';\n}\n\nexport function isTemplateExecutable(def: ExecutableDefinition): def is TemplateExecutable {\n return def.type === 'template';\n}\n\nexport function isSectionExecutable(def: ExecutableDefinition): def is SectionExecutable {\n return def.type === 'section';\n}\n\nexport function isResolverExecutable(def: ExecutableDefinition): def is ResolverExecutable {\n return def.type === 'resolver';\n}\n\n/**\n * Check if an executable came from an exec directive\n */\nexport function isExecSourced(def: ExecutableDefinition): boolean {\n return def.sourceDirective === 'exec';\n}\n\n/**\n * Check if an executable came from a text directive\n */\nexport function isTextSourced(def: ExecutableDefinition): boolean {\n return def.sourceDirective === 'text';\n}\n\n/**\n * Create an executable variable\n */\nexport function createExecutableVariable(\n name: string,\n definition: ExecutableDefinition,\n metadata?: Partial<VariableMetadata>\n): ExecutableVariable {\n return {\n type: 'executable',\n name,\n value: definition,\n metadata: {\n createdAt: Date.now(),\n modifiedAt: Date.now(),\n ...metadata\n }\n };\n}","/**\n * Mlld Core Types\n * \n * Clean export of all types used by the interpreter and API.\n * This is the single source of truth for type definitions.\n */\n\n// =========================================================================\n// AST NODE TYPES\n// =========================================================================\n\n// Re-export all AST node types and utilities\nexport * from './base';\nexport * from './nodes';\nexport * from './meta';\nexport * from './values';\nexport * from './raw';\nexport * from './guards';\nexport * from './errors';\n\n// Re-export directive types\nexport * from './import';\nexport * from './show';\nexport * from './exe';\nexport * from './path';\nexport * from './run';\nexport * from './output';\nexport * from './when';\nexport * from './var'; // New unified var directive\nexport * from './for'; // For loop directive and expression\nexport * from './load-content'; // Load content types and utilities including URL metadata\n\n// Import node types for the MlldNode union\nimport {\n TextNode,\n DirectiveNode,\n CodeFenceNode,\n MlldRunBlockNode,\n CommentNode,\n VariableReferenceNode,\n LiteralNode,\n DotSeparatorNode,\n PathSeparatorNode,\n ErrorNode,\n FrontmatterNode,\n NewlineNode,\n SectionMarkerNode,\n SourceLocation,\n ExecInvocation,\n NegationNode,\n FileReferenceNode,\n BinaryExpression,\n TernaryExpression,\n UnaryExpression\n} from './nodes';\n\n// Import WhenExpressionNode\nimport { WhenExpressionNode } from './when';\n\n// Import ForExpression\nimport { ForExpression } from './for';\n\n/**\n * Unified AST node type - MlldNode\n * \n * This discriminated union encompasses all possible nodes\n * in the Mlld AST. Each node type has a unique 'type' field\n * that allows TypeScript to narrow types during processing.\n */\nexport type MlldNode =\n | TextNode \n | DirectiveNode \n | CodeFenceNode\n | MlldRunBlockNode\n | CommentNode\n | VariableReferenceNode\n | LiteralNode\n | DotSeparatorNode\n | PathSeparatorNode\n | ErrorNode\n | FrontmatterNode\n | NewlineNode\n | SectionMarkerNode\n | ExecInvocation\n | NegationNode\n | FileReferenceNode\n | BinaryExpression\n | TernaryExpression\n | UnaryExpression\n | WhenExpressionNode\n | ForExpression;\n\n// =========================================================================\n// VARIABLE TYPES\n// =========================================================================\n\n// Export variable types and enums\nexport * from './variables';\nexport * from './executable';\n// Variable-legacy removed during Phase 6 cleanup\nexport * from './variable'; // New discriminated union variable system\n\n\n// Base variable metadata interface\nexport interface VariableMetadata {\n createdAt?: number;\n modifiedAt?: number;\n definedAt?: SourceLocation;\n isImported?: boolean;\n importPath?: string;\n isComplex?: boolean;\n}\n\n// Import ExecutableVariable for the union\nimport { ExecutableVariable } from './executable';\n// Import ExtendedMlldVariable for the extended type guard\nimport { ExtendedMlldVariable } from './variable';\n\n\n// Command definition structure\nexport interface BaseCommandDefinition {\n type: 'command' | 'commandRef' | 'code';\n paramNames?: string[];\n}\n\nexport interface CommandTemplateDefinition extends BaseCommandDefinition {\n type: 'command';\n commandTemplate: MlldNode[];\n}\n\nexport interface CommandRefDefinition extends BaseCommandDefinition {\n type: 'commandRef';\n commandRef: string;\n commandArgs?: MlldNode[];\n}\n\nexport interface CodeDefinition extends BaseCommandDefinition {\n type: 'code';\n codeTemplate: MlldNode[];\n language?: string;\n}\n\nexport type CommandDefinition = CommandTemplateDefinition | CommandRefDefinition | CodeDefinition;\n\n\n// =========================================================================\n// VARIABLE FACTORY FUNCTIONS\n// =========================================================================\n\n/**\n * Convert AST SourceLocation (with start/end) to unified SourceLocation format\n */\nexport function astLocationToSourceLocation(\n astLocation?: { start: Position; end: Position },\n filePath?: string\n): SourceLocation | undefined {\n if (!astLocation) return undefined;\n \n return {\n line: astLocation.start.line,\n column: astLocation.start.column,\n offset: astLocation.start.offset,\n filePath\n };\n}\n\n\n// =========================================================================\n// TYPE GUARD FUNCTIONS\n// =========================================================================\n\n/**\n * Type guard to check if a variable is using the extended type system\n */\nexport function isExtendedVariable(variable: unknown): variable is ExtendedMlldVariable {\n return variable !== null && typeof variable === 'object' && 'type' in variable;\n}\n\n// =========================================================================\n// COMMON TYPES\n// =========================================================================\n\n/**\n * Source location in a file\n */\nexport interface Position {\n line: number;\n column: number;\n offset?: number;\n}\n\nexport interface Location {\n start: Position;\n end: Position;\n}\n\n/**\n * Unified source location type that replaces both InterpreterLocation and ErrorSourceLocation.\n * This type serves as the single source of truth for representing source locations\n * throughout the codebase, supporting both precise locations (with line/column) and\n * partial locations (file-only references).\n */\nexport interface SourceLocation {\n /** The file path where this location occurs */\n filePath?: string;\n /** Line number (1-based) - required for precise locations */\n line?: number;\n /** Column number (1-based) - required for precise locations */\n column?: number;\n /** Byte offset in the file (0-based) - optional for enhanced tooling support */\n offset?: number;\n}\n\n/**\n * Creates a precise SourceLocation with line and column information\n */\nexport function createPreciseLocation(\n line: number,\n column: number,\n filePath?: string,\n offset?: number\n): SourceLocation {\n return { filePath, line, column, offset };\n}\n\n/**\n * Creates a file-only SourceLocation for references without precise position\n */\nexport function createFileLocation(filePath: string): SourceLocation {\n return { filePath };\n}\n\n/**\n * Type guard to check if a SourceLocation has precise position information\n */\nexport function isPreciseLocation(location: SourceLocation): location is Required<Pick<SourceLocation, 'line' | 'column'>> & SourceLocation {\n return typeof location.line === 'number' && typeof location.column === 'number';\n}\n\n// =========================================================================\n// TYPE UTILITIES\n// =========================================================================\n\n// Export any additional utilities from sub-modules\nexport { \n isDirectiveNode as isDirective,\n isTextNode as isText, \n isCommentNode as isComment, \n isCodeFenceNode as isCodeFence,\n isTextNode,\n isDirectiveNode,\n isCommentNode,\n isCodeFenceNode,\n isVariableReferenceNode,\n isLiteralNode,\n isNegationNode,\n isFileReferenceNode,\n isBinaryExpression,\n isTernaryExpression,\n isUnaryExpression\n} from './guards';"]}