{"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/policy.ts","../core/types/while.ts","../core/types/control.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","isArraySliceNode","isArrayFilterNode","isTimeDurationNode","ParseErrorCode","MlldAstError","Error","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","isLetAssignment","entry","isAugmentedAssignment","isConditionPair","isWhenSimpleNode","isWhenBlockNode","isWhenMatchNode","isWhenNode","isWhenExpression","isVarDirectiveNode","isVarExecDefinition","isNestedDirective","content","isDataObject","isDataArray","isPrimitiveValue","isDirectiveValue","isVariableReferenceValue","some","isTemplateValue","isDataObjectValue","isDataArrayValue","isEmbedDirectiveValue","isRunDirectiveValue","isNestedEmbedDirective","isNestedRunDirective","isContentNodes","isForeachExpression","isForDirective","isForExpression","isPolicyDirective","isWhileDirective","isDoneLiteral","isContinueLiteral","VariableValueType","VALID_VARIABLE_TYPES","isValidVariableType","includes","createVariableReferenceNode","fields","format","isVariableReference","nodeId","Date","now","Math","random","isCommandExecutable","def","isCommandRefExecutable","isCodeExecutable","isTemplateExecutable","isSectionExecutable","isResolverExecutable","isPipelineExecutable","isDataExecutable","isProseExecutable","isExecSourced","sourceDirective","isTextSourced","astLocationToSourceLocation","astLocation","filePath","line","start","column","offset","isExtendedVariable","variable","createPreciseLocation","createFileLocation","isPreciseLocation"],"mappings":";;;AAyDO,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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AAMF,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,kBAAkBtG,QAAwB,EAAA;AACxD,EAAA,OAAO,OAAOA,QAAS8F,CAAAA,IAAAA,KAAS,QAAY,IAAA,OAAO9F,SAASgG,MAAW,KAAA,QAAA;AACzE;AAFgBM,MAAAA,CAAAA,iBAAAA,EAAAA,mBAAAA,CAAAA","file":"chunk-6PZVQRSR.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  FieldAccessNode,\n  ArraySliceNode,\n  ArrayFilterNode,\n  TimeDurationNode\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';\nimport type { GuardDirectiveNode } from './guard';\nimport type { CapabilityContext, CapabilityKind } from './security';\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\nexport function isGuardDirective(node: DirectiveNode): node is GuardDirectiveNode {\n  return node.kind === 'guard';\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\n/**\n * Array operation type guards\n */\nexport function isArraySliceNode(node: FieldAccessNode): node is ArraySliceNode {\n  return node.type === 'arraySlice';\n}\n\nexport function isArrayFilterNode(node: FieldAccessNode): node is ArrayFilterNode {\n  return node.type === 'arrayFilter';\n}\n\nexport function isTimeDurationNode(node: any): node is TimeDurationNode {\n  return node?.type === 'TimeDuration';\n}\n\n// ---------------------------------------------------------------------------\n// CAPABILITY GUARD TYPES\n// ---------------------------------------------------------------------------\n\nexport type GuardEvent =\n  | { kind: Extract<CapabilityKind, 'import'>; context: CapabilityContext & { directive: DirectiveNode } }\n  | { kind: Extract<CapabilityKind, 'command'>; context: CapabilityContext & { command: string } }\n  | { kind: Extract<CapabilityKind, 'output'>; context: CapabilityContext & { target: string } };\n\nexport type GuardDecision =\n  | { action: 'allow' }\n  | { action: 'deny'; reason: string };\n\nexport type GuardThunk<E = unknown> = (\n  event: GuardEvent,\n  env: E\n) => GuardDecision | Promise<GuardDecision>;\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';\nimport type { DataLabel } from './security';\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  securityLabels?: 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  securityLabels?: DataLabel[];\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  securityLabels?: DataLabel[];\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 * Exe directive type definitions\n */\nimport { DirectiveNode, TypedDirectiveNode } from './base';\nimport { ContentNodeArray, TextNodeArray, VariableNodeArray } from './values';\nimport { WithClause } from './run';\nimport type { BaseMlldNode, ParameterNode } from './primitives';\nimport type { DataLabel } from './security';\n\nexport interface ExeReturnNode extends BaseMlldNode {\n  type: 'ExeReturn';\n  values: BaseMlldNode[];\n  raw?: string;\n  meta?: {\n    hasValue?: boolean;\n  };\n}\n\nexport interface ExeBlockNode extends BaseMlldNode {\n  type: 'ExeBlock';\n  values: {\n    statements: BaseMlldNode[];\n    return?: ExeReturnNode;\n  };\n  raw?: {\n    statements?: string;\n    hasReturn?: boolean;\n  };\n  meta?: {\n    statementCount?: number;\n    hasReturn?: boolean;\n  };\n}\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  securityLabels?: string;\n  statements?: string;\n  hasReturn?: boolean;\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  securityLabels?: DataLabel[];\n  statementCount?: number;\n  hasReturn?: boolean;\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 =\n  | 'exeCommand'\n  | 'exeCode'\n  | 'exeData'\n  | 'exeTemplate'\n  | 'exeTemplateFile'\n  | 'exeSection'\n  | 'exeWhen'\n  | 'exeForeach'\n  | 'exeFor'\n  | 'exeResolver'\n  | 'exeBlock';\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  securityLabels?: DataLabel[];\n  statements?: BaseMlldNode[];\n  return?: ExeReturnNode;\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    securityLabels?: DataLabel[];\n  };\n  raw: {\n    identifier: string;\n    params: string[];\n    metadata?: string;\n    command: string;\n    securityLabels?: 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    securityLabels?: DataLabel[];\n  };\n  raw: {\n    identifier: string;\n    params: string[];\n    metadata?: string;\n    lang: string;\n    code: string;\n    securityLabels?: string;\n  };\n  meta: ExeMeta;\n}\n\nexport interface ExeBlockDirectiveNode extends ExeDirectiveNode {\n  subtype: 'exeBlock';\n  values: {\n    identifier: TextNodeArray;\n    params: ParameterNode[];\n    statements: BaseMlldNode[];\n    return?: ExeReturnNode;\n    securityLabels?: DataLabel[];\n  };\n  raw: {\n    identifier: string;\n    params: string[];\n    statements: string;\n    hasReturn: boolean;\n    securityLabels?: string;\n  };\n  meta: ExeMeta & {\n    statementCount: number;\n    hasReturn: boolean;\n  };\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","/**\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 type { Expression } from './primitives';\nimport { ContentNodeArray, TextNodeArray, VariableNodeArray } from './values';\nimport type { DataLabel } from './security';\nimport type { PathMeta } from './meta';\n\n/**\n * With clause for pipeline and dependency management\n */\nexport interface WhilePipelineStage {\n  type: 'whileStage';\n  cap: number;\n  rateMs: number | null;\n  processor: VariableNodeArray;\n  rawIdentifier?: string;\n  meta?: { hasRate?: boolean; [key: string]: unknown };\n  location?: any;\n}\n\nexport type PipelineStageEntry = PipelineCommand | InlineCommandStage | InlineValueStage | WhilePipelineStage;\nexport type PipelineStage = PipelineStageEntry | PipelineStageEntry[];\n\nexport interface GuardOverrideOptions {\n  only?: string[];\n  except?: string[];\n}\n\nexport interface WithClause {\n  pipeline?: PipelineStage[];\n  trust?: TrustLevel;\n  parallel?: number;\n  delayMs?: number;\n  stdin?: Expression;\n  guards?: GuardOverrideOptions | false;\n  stream?: boolean;\n  streamFormat?: any;\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  meta?: Record<string, unknown>;\n  // Optional inline effects attached to this functional stage.\n  // These are pipeline builtin \"effect\" commands (e.g., @log) that should\n  // execute after this stage succeeds, and do not count as stages themselves.\n  effects?: PipelineCommand[];\n}\n\n/**\n * Inline shell command stage (cmd { ... }) executed directly in the pipeline\n */\nexport interface InlineCommandStage {\n  type: 'inlineCommand';\n  command: ContentNodeArray;\n  commandBases?: VariableNodeArray;\n  workingDir?: ContentNodeArray;\n  workingDirMeta?: PathMeta;\n  rawWorkingDir?: string;\n  rawCommand: string;\n  meta?: Record<string, unknown>;\n  location?: any;\n}\n\n/**\n * Inline data stage ({ ... }) treated as a structured value source\n */\nexport interface InlineValueStage {\n  type: 'inlineValue';\n  value: any;\n  rawIdentifier: string;\n  meta?: Record<string, unknown>;\n  location?: any;\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  securityLabels?: string;\n  workingDir?: string;\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  securityLabels?: DataLabel[];\n  workingDirMeta?: PathMeta;\n  hasWorkingDir?: boolean;\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  securityLabels?: DataLabel[];\n  workingDir?: ContentNodeArray;\n  workingDirMeta?: PathMeta;\n}\n\n/**\n * Run Command directive - @run [command]\n */\nexport interface RunCommandDirectiveNode extends RunDirectiveNode {\n  subtype: 'runCommand';\n  values: {\n    command: ContentNodeArray;\n    securityLabels?: DataLabel[];\n    workingDir?: ContentNodeArray;\n    workingDirMeta?: PathMeta;\n  };\n  raw: {\n    command: string;\n    securityLabels?: string;\n    workingDir?: string;\n  };\n  meta: {\n    isMultiLine: boolean;\n    hasVariables: boolean;\n    securityLabels?: DataLabel[];\n    workingDirMeta?: PathMeta;\n    hasWorkingDir?: 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    securityLabels?: DataLabel[];\n    workingDir?: ContentNodeArray;\n    workingDirMeta?: PathMeta;\n  };\n  raw: {\n    lang: string;\n    args: string[];\n    code: string;\n    securityLabels?: string;\n    workingDir?: string;\n  };\n  meta: {\n    isMultiLine: boolean;\n    language: string;\n    securityLabels?: DataLabel[];\n    workingDirMeta?: PathMeta;\n    hasWorkingDir?: boolean;\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    securityLabels?: DataLabel[];\n  };\n  raw: {\n    identifier: string;\n    args: string[];\n    securityLabels?: string;\n  };\n  meta: {\n    argumentCount: number;\n    securityLabels?: DataLabel[];\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","/**\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';\nimport type { WithClause } from './run';\n\n/**\n * Modifiers for when block form that control evaluation behavior\n */\nexport type WhenModifier = 'first';\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 * Let assignment entry in a when block for local variable declarations\n */\nexport interface LetAssignmentNode extends BaseMlldNode {\n  type: 'LetAssignment';\n  identifier: string;\n  value: BaseMlldNode[];\n  withClause?: WithClause;\n  meta?: Record<string, unknown>;\n}\n\n/**\n * Augmented assignment entry in a when block for local variable mutation\n * Supports: arrays (concat), strings (append), objects (shallow merge)\n */\nexport interface AugmentedAssignmentNode extends BaseMlldNode {\n  type: 'AugmentedAssignment';\n  identifier: string;\n  operator: '+=';  // Extensible for future -=, *=, etc.\n  value: BaseMlldNode[];\n  withClause?: WithClause;\n  meta?: Record<string, unknown>;\n}\n\n/**\n * Union type for when block entries (let assignments, augmented assignments, and condition pairs)\n */\nexport type WhenEntry = WhenConditionPair | LetAssignmentNode | AugmentedAssignmentNode;\n\n/**\n * Type guard for let assignment nodes\n */\nexport function isLetAssignment(entry: WhenEntry | BaseMlldNode): entry is LetAssignmentNode {\n  return (entry as any).type === 'LetAssignment';\n}\n\n/**\n * Type guard for augmented assignment nodes\n */\nexport function isAugmentedAssignment(entry: WhenEntry | BaseMlldNode): entry is AugmentedAssignmentNode {\n  return (entry as any).type === 'AugmentedAssignment';\n}\n\n/**\n * Type guard for condition pairs (not let or augmented assignments)\n */\nexport function isConditionPair(entry: WhenEntry): entry is WhenConditionPair {\n  return !isLetAssignment(entry) && !isAugmentedAssignment(entry);\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: WhenEntry[];  // Mixed let assignments and condition pairs\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: WhenEntry[];     // Mixed let assignments and 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: WhenEntry[];  // Mixed let assignments and condition pairs\n  withClause?: TailModifiers | null;\n  boundValue?: BaseMlldNode;\n  boundIdentifier?: string;\n  meta: {\n    conditionCount: number;\n    isValueReturning: true;\n    evaluationType: 'expression';\n    hasTailModifiers: boolean;\n    modifier?: WhenModifier | null;\n    hasBoundValue?: boolean;\n    boundIdentifier?: string;\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","/**\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, ConditionalArrayElementNode } from './nodes';\nimport type { ExeBlockNode } from './exe';\nimport type { PipelineStage } from './run';\nimport type { DataLabel } from './security';\n\n/**\n * Data object entry - either a key-value pair or a spread\n */\nexport type DataObjectEntry =\n  | { type: 'pair'; key: string; value: DataValue }\n  | { type: 'conditionalPair'; key: string; value: DataValue }\n  | { type: 'spread'; value: VariableNodeArray };\n\n/**\n * Data object value structure for var directive\n */\nexport interface DataObjectValue {\n  type: 'object';\n  entries: DataObjectEntry[];\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-command';\n  value: {\n    type: 'foreach';\n    execInvocation: ExecInvocation;\n    arrays: (ContentNodeArray | DirectiveNode)[];\n    with?: ForeachWithOptions;\n    batchPipeline?: ForeachBatchPipeline | null;\n    [key: string]: unknown;\n  };\n  rawText: string;\n  batchPipeline?: ForeachBatchPipeline | null;\n  [key: string]: unknown;\n}\n\n/**\n * Batch pipeline metadata for foreach expressions\n */\nexport type ForeachBatchPipeline = \n  | PipelineStage[]\n  | {\n      pipeline: PipelineStage[];\n      isBatchPipeline?: boolean;\n      [key: string]: unknown;\n    };\n\n/**\n * Foreach with-clause options\n */\nexport interface ForeachWithOptions {\n  separator?: unknown;\n  template?: unknown;\n  batchPipeline?: ForeachBatchPipeline | null;\n  isBatchPipeline?: boolean;\n  [key: string]: unknown;\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  | ConditionalArrayElementNode\n  | ForeachCommandExpression\n  | ForeachSectionExpression;\n\n/**\n * Var directive raw values\n */\nexport interface VarRaw {\n  identifier: string;\n  value?: string;\n  securityLabels?: 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  securityLabels?: DataLabel[];\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  securityLabels?: DataLabel[];\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  | ExeBlockNode // Block expressions\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    securityLabels?: DataLabel[];\n  };\n  raw: {\n    identifier: string;\n    value?: string;\n    securityLabels?: 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' ||\n      node.type === 'VariableReference' ||\n      node.type === 'ConditionalTemplateSnippet' ||\n      node.type === 'ConditionalStringFragment')\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}\n","import type { DirectiveNode, BaseMlldNode, VariableReferenceNode } from './primitives';\nimport type { PipelineStage } from './run';\n\nexport interface ForBatchPipelineMeta {\n  pipeline: PipelineStage[];\n  isBatchPipeline?: boolean;\n  [key: string]: unknown;\n}\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    /** Optional parallel options for this loop */\n    forOptions?: {\n      parallel?: boolean;\n      cap?: number;\n      rateMs?: number;\n    };\n  };\n  meta: {\n    hasVariables: true;\n    actionType: 'single' | 'block';\n    block?: { statementCount?: number };\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    forOptions?: {\n      parallel?: boolean;\n      cap?: number;\n      rateMs?: number;\n    };\n    batchPipeline?: ForBatchPipelineMeta | null;\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","import type { TypedDirectiveNode } from './base';\nimport type { DirectiveNode, SourceLocation } from './primitives';\nimport type { TextNode } from './values';\n\nexport interface PolicyReferenceNode {\n  type: 'ref';\n  name: string;\n  location?: SourceLocation;\n}\n\nexport interface PolicyUnionExpression {\n  type: 'union';\n  args: PolicyReferenceNode[];\n  location?: SourceLocation;\n}\n\nexport interface PolicyDirectiveValues {\n  name: TextNode[];\n  expr: PolicyUnionExpression;\n}\n\nexport interface PolicyDirectiveRaw {\n  name: string;\n  expr: PolicyUnionExpression;\n}\n\nexport interface PolicyDirectiveMeta {\n  location?: SourceLocation | null;\n}\n\nexport type PolicyDirectiveNode = TypedDirectiveNode<'policy', 'policy'> & {\n  values: PolicyDirectiveValues;\n  raw: PolicyDirectiveRaw & Record<string, unknown>;\n  meta: PolicyDirectiveMeta & Record<string, unknown>;\n};\n\nexport function isPolicyDirective(node: DirectiveNode): node is PolicyDirectiveNode {\n  return node.kind === 'policy';\n}\n","import type { DirectiveNode } from './nodes';\nimport type { VariableReferenceNode } from './primitives';\nimport type { WithClause } from './run';\n\nexport interface WhileDirective extends DirectiveNode {\n  kind: 'while';\n  subtype: 'while';\n  values: {\n    cap: number;\n    processor: VariableReferenceNode[];\n    rateMs?: number | null;\n    tail?: WithClause;\n  };\n  raw: {\n    cap: number;\n    processor: string;\n    rateMs?: number;\n    tail?: WithClause;\n  };\n  meta: {\n    hasCap: true;\n    hasRate: boolean;\n    parallel?: { parallel?: number; delayMs?: number } | null;\n    comment?: unknown;\n  };\n}\n\nexport function isWhileDirective(node: DirectiveNode): node is WhileDirective {\n  return node.kind === 'while';\n}\n","import type { BaseMlldNode, LiteralNode } from './primitives';\n\nexport interface DoneLiteralNode extends LiteralNode {\n  valueType: 'done';\n  value: BaseMlldNode[] | string;\n}\n\nexport interface ContinueLiteralNode extends LiteralNode {\n  valueType: 'continue';\n  value: BaseMlldNode[] | string;\n}\n\nexport function isDoneLiteral(node: BaseMlldNode): node is DoneLiteralNode {\n  return node.type === 'Literal' && (node as any).valueType === 'done';\n}\n\nexport function isContinueLiteral(node: BaseMlldNode): node is ContinueLiteralNode {\n  return node.type === 'Literal' && (node as any).valueType === 'continue';\n}\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  EXPORT = 'export',\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  'export',\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","/**\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 { VariableContext, VariableInternal } from './index';\nimport type { PipelineStage } from './run';\nimport type { DataValue } from './var';\nimport type { PathMeta } from './meta';\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' | 'pipeline' | 'prose';\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  withClause?: any; // Stdin and other with-clause options\n  sourceDirective: 'exec';\n  workingDir?: MlldNode[];\n  workingDirMeta?: PathMeta;\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  withClause?: any; // Pipeline information from the original directive\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  workingDir?: MlldNode[];\n  workingDirMeta?: PathMeta;\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 * Pipeline executable - @exe name() = || @a() || @b()\n */\nexport interface PipelineExecutable extends BaseExecutable {\n  type: 'pipeline';\n  pipeline: PipelineStage[];\n  format?: string;\n  parallelCap?: number;\n  delayMs?: number;\n  sourceDirective: 'exec';\n}\n\n/**\n * Data executable - /exe name(params) = { ... } returning structured data\n */\nexport interface DataExecutable extends BaseExecutable {\n  type: 'data';\n  dataTemplate: DataValue;\n  sourceDirective: 'exec';\n}\n\n/**\n * Prose executable - /exe name(params) = prose:@config { ... }\n * Executes OpenProse content via skill injection to a model\n */\nexport interface ProseExecutable extends BaseExecutable {\n  type: 'prose';\n  /** Reference to the config variable containing model settings */\n  configRef: MlldNode[];\n  /** Content type: 'inline' for {...}, 'file' for \"path.prose\", 'template' for template \"path.prose.att\" */\n  contentType: 'inline' | 'file' | 'template';\n  /** Inline prose content (for contentType='inline') */\n  contentTemplate?: MlldNode[];\n  /** Path to prose file (for contentType='file' or 'template') */\n  pathTemplate?: 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  | PipelineExecutable\n  | DataExecutable\n  | ProseExecutable;\n\n/**\n * Variable that stores an executable definition\n */\nexport interface ExecutableVariable {\n  type: 'executable';\n  name: string;\n  value: ExecutableDefinition;\n  mx: VariableContext;\n  internal?: VariableInternal;\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\nexport function isPipelineExecutable(def: ExecutableDefinition): def is PipelineExecutable {\n  return def.type === 'pipeline';\n}\n\nexport function isDataExecutable(def: ExecutableDefinition): def is DataExecutable {\n  return def.type === 'data';\n}\n\nexport function isProseExecutable(def: ExecutableDefinition): def is ProseExecutable {\n  return def.type === 'prose';\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  options?: { mx?: Partial<VariableContext>; internal?: Partial<VariableInternal> }\n): ExecutableVariable {\n  return {\n    type: 'executable',\n    name,\n    value: definition,\n    mx: {\n      ...options?.mx\n    },\n    internal: {\n      ...options?.internal\n    }\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 './security';\nexport * from './state';\nexport * from './errors';\n\n// Re-export directive types\nexport * from './import';\nexport * from './export';\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 './guard'; // Guard directives\nexport * from './policy'; // Policy directives\nexport * from './load-content'; // Load content types and utilities including URL metadata\nexport * from './while'; // While directives and stages\nexport * from './control'; // Control literals (done/continue)\n\n// Parser modes\nexport * from './mode';\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  TemplateForBlockNode,\n  TemplateInlineShowNode,\n  ConditionalTemplateSnippetNode,\n  ConditionalStringFragmentNode,\n  ConditionalArrayElementNode\n} from './nodes';\n\n// Import WhenExpressionNode\nimport { WhenExpressionNode } from './when';\n\n// Import ForExpression\nimport { ForExpression } from './for';\n\n// Import Exe block nodes (used by when-expression actions)\nimport type { ExeBlockNode, ExeReturnNode } from './exe';\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  | TemplateForBlockNode\n  | TemplateInlineShowNode\n  | ConditionalTemplateSnippetNode\n  | ConditionalStringFragmentNode\n  | ConditionalArrayElementNode\n  | WhenExpressionNode\n  | ForExpression\n  | ExeBlockNode\n  | ExeReturnNode;\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  security?: import('./security').SecurityDescriptor;\n  capability?: import('./security').CapabilityContext;\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';\n"]}