UNPKG

mlld

Version:

mlld: a modular prompt scripting language

928 lines (906 loc) 33.6 kB
import { init_locationFormatter, formatLocationForError } from './chunk-OIIQ3NPY.mjs'; import { isPreciseLocation } from './chunk-6BOVVHHZ.mjs'; import { __name, __publicField } from './chunk-OMKLS24H.mjs'; // core/errors/MlldError.ts init_locationFormatter(); var ErrorSeverity = /* @__PURE__ */ function(ErrorSeverity2) { ErrorSeverity2["Recoverable"] = "recoverable"; ErrorSeverity2["Fatal"] = "fatal"; ErrorSeverity2["Info"] = "info"; ErrorSeverity2["Warning"] = "warning"; return ErrorSeverity2; }({}); var _MlldError = class _MlldError extends Error { constructor(message, options) { super(message, { cause: options.cause }); /** A unique code identifying the type of error */ __publicField(this, "code"); /** The severity level of the error */ __publicField(this, "severity"); /** Additional context-specific details about the error */ __publicField(this, "details"); /** Optional source location where the error occurred */ __publicField(this, "sourceLocation"); /** Optional environment for source access */ __publicField(this, "env"); this.name = this.constructor.name; this.code = options.code; this.severity = options.severity; this.details = options.details; this.sourceLocation = options.sourceLocation; this.env = options.env; if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } } /** * Determines if the error represents a condition that could potentially be * treated as a warning rather than a fatal error, based on its severity. * Recoverable errors and explicit warnings can potentially be warnings. * * @returns {boolean} True if the error severity allows it to be a warning, false otherwise. */ canBeWarning() { return this.severity === "recoverable" || this.severity === "warning"; } /** * Get source context for error display */ getSourceContext() { if (!this.sourceLocation || !this.env) { return void 0; } const filePath = this.sourceLocation.filePath; if (!filePath) { return void 0; } const source = this.env.getSource(filePath); if (!source || !this.sourceLocation.line) { return void 0; } return this.formatSourceContext(source); } /** * Format source context with visual indicators */ formatSourceContext(source) { const lines = source.split("\n"); const lineNum = this.sourceLocation.line - 1; if (lineNum < 0 || lineNum >= lines.length) { return ""; } lines[lineNum]; const column = this.sourceLocation.column || 1; const pointer = " ".repeat(column - 1) + "^"; const contextStart = Math.max(0, lineNum - 2); const contextEnd = Math.min(lines.length - 1, lineNum + 2); let result = ""; for (let i = contextStart; i <= contextEnd; i++) { const lineNumber = String(i + 1).padStart(4, " "); const marker = i === lineNum ? ">" : " "; result += `${marker} ${lineNumber} | ${lines[i]} `; if (i === lineNum && this.sourceLocation.column) { result += ` | ${pointer} `; } } return result; } /** * Provides a string representation including code and severity. */ toString() { let result = `[${this.code}] ${this.message}`; if (this.sourceLocation) { result += ` at ${formatLocationForError(this.sourceLocation)}`; } result += ` (Severity: ${this.severity})`; const sourceContext = this.getSourceContext(); if (sourceContext) { result += "\n\n" + sourceContext; } return result; } /** * Serializes the error to JSON with formatted location string. */ toJSON() { const result = { name: this.name, message: this.message, code: this.code, severity: this.severity }; if (this.details) { result.details = this.details; } if (this.sourceLocation) { result.sourceLocation = formatLocationForError(this.sourceLocation); } return result; } }; __name(_MlldError, "MlldError"); var MlldError = _MlldError; // core/errors/MlldParseError.ts init_locationFormatter(); var _MlldParseError = class _MlldParseError extends MlldError { constructor(message, position, options = {}) { const locationStr = position ? ` at line ${"line" in position ? position.line : position.start.line}, column ${"column" in position ? position.column : position.start.column}` + ("filePath" in position && position.filePath ? ` in ${position.filePath}` : "") : ""; let location; let filePath; if (position) { if ("line" in position) { location = { start: position, end: position, filePath: void 0 }; } else { location = position; } filePath = location?.filePath; } const severity = options.severity || ErrorSeverity.Fatal; super(`Parse error: ${message}${locationStr}`, { // Pass filePath via details, not directly code: "PARSE_ERROR", severity, details: { ...options.context, filePath: options.filePath || filePath }, sourceLocation: location, cause: options.cause }); /** * Location information for where the error occurred */ __publicField(this, "location"); // Explicitly store the cause passed in options __publicField(this, "cause"); this.name = "MlldParseError"; this.location = location; this.cause = options.cause; Object.setPrototypeOf(this, _MlldParseError.prototype); } /** * Custom serialization to avoid circular references and include only essential info */ toJSON() { const cause = this.cause; return { name: this.name, message: this.message, code: this.code, severity: this.severity, location: this.location, sourceLocation: this.sourceLocation ? formatLocationForError(this.sourceLocation) : void 0, filePath: this.details?.filePath, cause: cause instanceof Error ? cause.message : String(cause), details: this.details }; } }; __name(_MlldParseError, "MlldParseError"); var MlldParseError = _MlldParseError; // core/errors/MlldResolutionError.ts var _MlldResolutionError = class _MlldResolutionError extends MlldError { constructor(message, options) { super(message, { code: options.code, severity: options.severity || ErrorSeverity.Fatal, details: options.details, sourceLocation: options.sourceLocation, cause: options.cause }); } /** * Get a formatted error message including details */ formatMessage() { let msg = `Resolution error: ${this.message}`; if (this.details?.value) { msg += ` Value: ${this.details.value}`; } if (this.details?.context) { msg += ` Context: ${this.details.context}`; } if (this.details?.variableName) { msg += ` Variable: ${this.details.variableName}`; if (this.details.variableType) { msg += ` (${this.details.variableType})`; } } if (this.details?.fieldPath) { msg += ` Field path: ${this.details.fieldPath}`; } return msg; } }; __name(_MlldResolutionError, "MlldResolutionError"); var MlldResolutionError = _MlldResolutionError; // core/errors/MlldInterpreterError.ts init_locationFormatter(); var _MlldInterpreterError = class _MlldInterpreterError extends MlldError { constructor(message, nodeType, location, options = {}) { const locationStr = location && isPreciseLocation(location) ? ` at line ${location.line}, column ${location.column}${location.filePath ? ` in ${location.filePath}` : ""}` : location?.filePath ? ` in ${location.filePath}` : ""; const severity = options.severity || ErrorSeverity.Recoverable; const filePath = location?.filePath || options.context?.filePath; super(`Interpreter error (${nodeType}): ${message}${locationStr}`, { code: options.code || "INTERPRETATION_FAILED", cause: options.cause, severity, details: { ...options.context, filePath, nodeType }, sourceLocation: location }); __publicField(this, "nodeType"); __publicField(this, "location"); __publicField(this, "context"); __publicField(this, "cause"); this.name = "MlldInterpreterError"; this.nodeType = nodeType; this.location = location; this.context = options.context; this.cause = options.cause; Object.setPrototypeOf(this, _MlldInterpreterError.prototype); } /** * Custom serialization to avoid circular references and include only essential info */ toJSON() { const cause = this.cause; return { name: this.name, message: this.message, nodeType: this.nodeType, location: this.location, sourceLocation: this.sourceLocation ? formatLocationForError(this.sourceLocation) : void 0, filePath: this.location?.filePath, cause: cause instanceof Error ? cause.message : String(cause), fullCauseMessage: cause instanceof Error ? this.getFullCauseMessage(cause) : void 0, severity: this.severity, code: this.code, context: this.context ? { filePath: this.context.filePath, nodeType: this.context.nodeType, nodeCount: this.context.state?.nodeCount } : void 0 }; } /** * Get the full cause message chain */ getFullCauseMessage(error) { if (!error) return ""; let message = error.message || "Unknown error"; if ("cause" in error) { const cause = error.cause; if (cause instanceof Error) { message += ` -> ${this.getFullCauseMessage(cause)}`; } } return message; } }; __name(_MlldInterpreterError, "MlldInterpreterError"); var MlldInterpreterError = _MlldInterpreterError; // core/errors/MlldImportError.ts var _MlldImportError = class _MlldImportError extends MlldError { constructor(message, options = {}) { const importChainStr = options.details?.importChain ? ` (chain: ${options.details.importChain.join(" \u2192 ")})` : ""; const isCyclic = options.code === "CIRCULAR_IMPORT" || message.includes("circular"); const severity = options.severity || (isCyclic ? ErrorSeverity.Fatal : ErrorSeverity.Recoverable); super(`Import error${options.code ? ` (${options.code})` : ""}: ${message}${importChainStr}`, { code: options.code || "IMPORT_FAILED", cause: options.cause || options.details?.cause, severity, details: { ...options.context, filePath: options.details?.filePath, importChain: options.details?.importChain, variableName: options.details?.variableName } }); __publicField(this, "details"); this.name = "MlldImportError"; this.details = options.details; Object.setPrototypeOf(this, _MlldImportError.prototype); } }; __name(_MlldImportError, "MlldImportError"); var MlldImportError = _MlldImportError; // core/errors/MlldFileSystemError.ts init_locationFormatter(); var _MlldFileSystemError = class _MlldFileSystemError extends MlldError { constructor(message, options = {}) { const severity = options.severity || ErrorSeverity.Fatal; const code = options.code || "FILE_SYSTEM_ERROR"; super(message, { severity, code, details: options.details, sourceLocation: options.sourceLocation, cause: options.cause }); __publicField(this, "command"); __publicField(this, "cwd"); __publicField(this, "cause"); this.name = "MlldFileSystemError"; this.command = options.command; this.cwd = options.cwd; this.cause = options.cause; Object.setPrototypeOf(this, _MlldFileSystemError.prototype); } toJSON() { const cause = this.cause; return { name: this.name, message: this.message, code: this.code, severity: this.severity, command: this.command, cwd: this.cwd, filePath: this.details?.filePath, cause: cause instanceof Error ? cause.message : String(cause), details: this.details, sourceLocation: this.sourceLocation ? formatLocationForError(this.sourceLocation) : void 0 }; } }; __name(_MlldFileSystemError, "MlldFileSystemError"); var MlldFileSystemError = _MlldFileSystemError; // core/errors/MlldFileNotFoundError.ts var _MlldFileNotFoundError = class _MlldFileNotFoundError extends MlldError { constructor(message, options) { super(message, { code: "E_FILE_NOT_FOUND", severity: options.severity || ErrorSeverity.Fatal, details: options.details, sourceLocation: options.sourceLocation, cause: options.cause }); } }; __name(_MlldFileNotFoundError, "MlldFileNotFoundError"); var MlldFileNotFoundError = _MlldFileNotFoundError; // core/errors/MlldOutputError.ts var _MlldOutputError = class _MlldOutputError extends MlldError { constructor(message, format, options = {}) { const severity = options.severity || ErrorSeverity.Recoverable; super(`Output error (${format}): ${message}`, { code: "OUTPUT_GENERATION_FAILED", cause: options.cause, severity, details: { ...options.context, format } }); __publicField(this, "format"); this.name = "MlldOutputError"; this.format = format; Object.setPrototypeOf(this, _MlldOutputError.prototype); } }; __name(_MlldOutputError, "MlldOutputError"); var MlldOutputError = _MlldOutputError; // core/errors/MlldDirectiveError.ts var _MlldDirectiveError = class _MlldDirectiveError extends MlldError { constructor(message, directiveKind, options = {}) { const locationStr = options.location ? ` at line ${options.location.line}, column ${options.location.column}${options.location.filePath ? ` in ${options.location.filePath}` : ""}` : ""; super(`Directive error (${directiveKind}): ${message}${locationStr}`, { code: options.code || "VALIDATION_FAILED", cause: options.cause, severity: options.severity || ErrorSeverity.Recoverable, // Pass context and filePath via details details: { ...options.context, directiveKind, filePath: options.location?.filePath, // Keep location in details as well if needed for context location: options.location }, // Pass location as sourceLocation sourceLocation: options.location, // Pass environment for source access env: options.env }); __publicField(this, "directiveKind"); __publicField(this, "location"); this.name = "MlldDirectiveError"; this.directiveKind = directiveKind; this.location = options.location; Object.setPrototypeOf(this, _MlldDirectiveError.prototype); } }; __name(_MlldDirectiveError, "MlldDirectiveError"); var MlldDirectiveError = _MlldDirectiveError; // core/errors/PathValidationError.ts var PathErrorCode = /* @__PURE__ */ function(PathErrorCode2) { PathErrorCode2["INVALID_PATH"] = "INVALID_PATH"; PathErrorCode2["PATH_NOT_FOUND"] = "PATH_NOT_FOUND"; PathErrorCode2["NOT_A_FILE"] = "NOT_A_FILE"; PathErrorCode2["NOT_A_DIRECTORY"] = "NOT_A_DIRECTORY"; PathErrorCode2["OUTSIDE_BASE_DIR"] = "OUTSIDE_BASE_DIR"; PathErrorCode2["INVALID_VARIABLE"] = "INVALID_VARIABLE"; PathErrorCode2["NULL_BYTE"] = "NULL_BYTE"; PathErrorCode2["INVALID_CHARS"] = "INVALID_CHARS"; return PathErrorCode2; }({}); var _PathValidationError = class _PathValidationError extends MlldError { constructor(message, options) { super(message, { code: options.code, severity: options.severity || ErrorSeverity.Fatal, details: options.details, sourceLocation: options.sourceLocation, cause: options.cause }); } }; __name(_PathValidationError, "PathValidationError"); var PathValidationError = _PathValidationError; // core/errors/DataEvaluationError.ts var _DataEvaluationError = class _DataEvaluationError extends MlldError { constructor(dataPath, originalError) { super(`Failed to evaluate data at ${dataPath}: ${originalError.message}`, "DATA_EVALUATION_ERROR", void 0); __publicField(this, "dataPath"); __publicField(this, "originalError"); this.dataPath = dataPath, this.originalError = originalError; this.name = "DataEvaluationError"; } }; __name(_DataEvaluationError, "DataEvaluationError"); var DataEvaluationError = _DataEvaluationError; // core/errors/VariableRedefinitionError.ts init_locationFormatter(); var _VariableRedefinitionError = class _VariableRedefinitionError extends MlldInterpreterError { constructor(message, options = {}) { const context = options.context; const location = context?.newLocation; let enhancedMessage = message; if (context?.existingLocation) { const locStr = formatLocationForError(context.existingLocation); enhancedMessage += `. Originally defined at ${locStr}`; } if (context?.suggestion) { enhancedMessage += `. ${context.suggestion}`; } super(enhancedMessage, "variable-redefinition", location, { ...options, code: "VARIABLE_REDEFINITION", severity: options.severity || ErrorSeverity.Critical }); __publicField(this, "variableRedefinitionContext"); this.name = "VariableRedefinitionError"; this.variableRedefinitionContext = context; Object.setPrototypeOf(this, _VariableRedefinitionError.prototype); } /** * Create error for same-file redefinition */ static forSameFile(variableName, existingLocation, newLocation) { return new _VariableRedefinitionError(`Variable '${variableName}' is already defined and cannot be redefined`, { context: { variableName, existingLocation, newLocation, filePath: newLocation?.filePath, suggestion: "Variables in mlld are immutable by design. Use a different variable name or remove one of the definitions." } }); } /** * Create error for import conflict */ static forImportConflict(variableName, existingLocation, newLocation, importPath, isExistingImported) { let message; let suggestion; if (isExistingImported) { message = `Variable '${variableName}' is already imported and cannot be redefined locally`; suggestion = importPath ? `Consider using import aliases: @import { ${variableName} as ${variableName}Imported } from "${importPath}"` : "Consider using import aliases or a different variable name"; } else { message = `Variable '${variableName}' is already defined locally and cannot be imported`; suggestion = `Consider using import aliases: @import { ${variableName} as ${variableName}Imported } from the import file`; } return new _VariableRedefinitionError(message, { context: { variableName, existingLocation, newLocation, filePath: newLocation?.filePath, suggestion } }); } }; __name(_VariableRedefinitionError, "VariableRedefinitionError"); var VariableRedefinitionError = _VariableRedefinitionError; // core/errors/MlldCommandExecutionError.ts var _MlldCommandExecutionError = class _MlldCommandExecutionError extends MlldError { constructor(message, sourceLocation, details, env) { super(message, { code: "COMMAND_EXECUTION_FAILED", severity: ErrorSeverity.Recoverable, sourceLocation, details, env }); } /** * Creates a command execution error with enhanced context */ static create(command, exitCode, duration, sourceLocation, additionalContext) { const message = `Command execution failed: ${command}`; return new _MlldCommandExecutionError(message, sourceLocation, { command, exitCode, duration, stdout: additionalContext?.stdout, stderr: additionalContext?.stderr, workingDirectory: additionalContext?.workingDirectory || process.cwd(), directiveType: additionalContext?.directiveType || "run" }, additionalContext?.env); } }; __name(_MlldCommandExecutionError, "MlldCommandExecutionError"); var MlldCommandExecutionError = _MlldCommandExecutionError; // core/errors/MlldDependencyError.ts var _MlldDependencyError = class _MlldDependencyError extends MlldError { constructor(message, missing, mismatched, location) { super(message, location); __publicField(this, "missing"); __publicField(this, "mismatched"); this.missing = missing, this.mismatched = mismatched; this.name = "MlldDependencyError"; } /** * Get a formatted error message with installation instructions */ getFormattedMessage() { const lines = [ this.message ]; if (this.missing.length > 0) { lines.push(""); lines.push("To install missing packages:"); const nodePackages = this.missing.filter((p) => p.includes("@")); const pythonPackages = this.missing.filter((p) => !p.includes("@")); if (nodePackages.length > 0) { lines.push(` npm install ${nodePackages.join(" ")}`); } if (pythonPackages.length > 0) { lines.push(` pip install ${pythonPackages.join(" ")}`); } } if (this.mismatched.length > 0) { lines.push(""); lines.push("Version mismatches detected. Update packages to satisfy constraints."); } return lines.join("\n"); } }; __name(_MlldDependencyError, "MlldDependencyError"); var MlldDependencyError = _MlldDependencyError; // core/errors/MlldConditionError.ts var _MlldConditionError = class _MlldConditionError extends MlldDirectiveError { constructor(message, modifier, location, details = {}) { super(message, "when", { location, code: "CONDITION_ERROR", context: { modifier, ...details } }); __publicField(this, "details"); this.details = { ...details, modifier }; this.name = "MlldConditionError"; Object.setPrototypeOf(this, _MlldConditionError.prototype); } }; __name(_MlldConditionError, "MlldConditionError"); var MlldConditionError = _MlldConditionError; // core/errors/ResolverError.ts var ResolverErrorCode = /* @__PURE__ */ function(ResolverErrorCode2) { ResolverErrorCode2["NOT_FOUND"] = "E_RESOLVER_NOT_FOUND"; ResolverErrorCode2["UNSUPPORTED_CONTEXT"] = "E_RESOLVER_UNSUPPORTED_CONTEXT"; ResolverErrorCode2["UNSUPPORTED_CAPABILITY"] = "E_RESOLVER_UNSUPPORTED_CAPABILITY"; ResolverErrorCode2["READONLY"] = "E_RESOLVER_READONLY"; ResolverErrorCode2["INVALID_FORMAT"] = "E_RESOLVER_INVALID_FORMAT"; ResolverErrorCode2["RESOLUTION_FAILED"] = "E_RESOLVER_RESOLUTION_FAILED"; ResolverErrorCode2["NAME_PROTECTED"] = "E_RESOLVER_NAME_PROTECTED"; ResolverErrorCode2["GENERIC"] = "E_RESOLVER_ERROR"; return ResolverErrorCode2; }({}); var _ResolverError = class _ResolverError extends MlldError { constructor(message, code = "E_RESOLVER_ERROR", details = {}) { super(message, { code, severity: details.originalError ? ErrorSeverity.Fatal : ErrorSeverity.Recoverable, details, cause: details.originalError }); __publicField(this, "details"); this.details = details; this.name = "ResolverError"; } /** * Create error for missing resolver */ static notFound(reference, context) { const contextMsg = context ? ` in ${context} context` : ""; return new _ResolverError(`No resolver found for reference '${reference}'${contextMsg}`, { reference, context, operation: "resolve" }); } /** * Create error for unsupported capability */ static unsupportedCapability(resolverName, capability, context) { return new _ResolverError(`Resolver '${resolverName}' does not support ${capability}`, { resolverName, context, missingCapability: capability, operation: "validate" }); } /** * Create error for invalid format */ static invalidFormat(resolverName, format, supportedFormats) { const suggestedFormat = supportedFormats[0] || "default"; return new _ResolverError(`Resolver '${resolverName}' does not support format '${format}'. Supported formats: ${supportedFormats.join(", ")}`, { resolverName, operation: "resolve", suggestedFormat }); } /** * Create error for resolution failure */ static resolutionFailed(resolverName, reference, originalError) { return new _ResolverError(`${resolverName} failed to resolve '${reference}': ${originalError.message}`, { resolverName, reference, operation: "resolve", originalError }); } /** * Create error for name protection violation */ static nameProtected(name, isVariable = true) { const type = isVariable ? "variable" : "import alias"; return new _ResolverError(`Cannot use '${name}' as ${type} name - it is a reserved resolver name`, { reference: name, operation: "validate" }); } /** * Get formatted error message with attribution */ getFormattedMessage() { const parts = [ this.message ]; if (this.details.resolverName) { parts.push(`Resolver: ${this.details.resolverName}`); } if (this.details.context) { parts.push(`Context: ${this.details.context}`); } if (this.details.missingCapability) { parts.push(`Missing capability: ${this.details.missingCapability}`); } if (this.details.availableResolvers && this.details.availableResolvers.length > 0) { parts.push(`Available resolvers: ${this.details.availableResolvers.join(", ")}`); } if (this.details.suggestedFormat) { parts.push(`\u{1F4A1} Try using format: ${this.details.suggestedFormat}`); } return parts.join("\n "); } /** * Get helpful suggestions based on error type */ getSuggestions() { const suggestions = []; if (this.details.operation === "resolve" && !this.details.resolverName) { suggestions.push("Check that the module or resolver is installed"); suggestions.push("Verify the reference syntax is correct"); if (this.details.reference?.startsWith("@")) { suggestions.push("For modules, use: @author/module"); suggestions.push("For built-in resolvers, use: @TIME, @DEBUG, @INPUT, or @PROJECTPATH"); } } if (this.details.missingCapability === "supportsImports") { suggestions.push(`This resolver can only be used in path contexts, not imports`); suggestions.push(`Try using it with @path directive instead`); } if (this.details.missingCapability === "supportsPaths") { suggestions.push(`This resolver can only be used in import contexts, not paths`); suggestions.push(`Try using it with @import directive instead`); } if (this.details.operation === "validate" && this.message.includes("reserved resolver name")) { suggestions.push("Choose a different name that doesn't conflict with built-in resolvers"); suggestions.push("Built-in resolver names: TIME, DEBUG, INPUT, PROJECTPATH"); } return suggestions; } }; __name(_ResolverError, "ResolverError"); var ResolverError = _ResolverError; // core/errors/MlldWhenExpressionError.ts var _MlldWhenExpressionError = class _MlldWhenExpressionError extends MlldError { constructor(message, location, details) { super(message, "E_WHEN_EXPRESSION", location); __publicField(this, "details"); this.details = details; this.name = "MlldWhenExpressionError"; } }; __name(_MlldWhenExpressionError, "MlldWhenExpressionError"); var MlldWhenExpressionError = _MlldWhenExpressionError; // core/errors/messages/paths.ts var PathErrorMessages = { // Basic validation errors EMPTY_PATH: "Path cannot be empty", NULL_BYTE: "Path contains null bytes which is a security risk", INVALID_PATH: "Invalid path format", FILE_NOT_FOUND: "File not found: {path}", PATH_NOT_FOUND: "Path not found: {path}", // File type validation errors NOT_A_FILE: "Path is not a file: {path}", NOT_A_DIRECTORY: "Path is not a directory: {path}", // Mlld-specific path rule errors CONTAINS_DOT_SEGMENTS: "Path cannot contain . or .. segments", INVALID_PATH_FORMAT: "Invalid path format - paths with slashes must use $. or $~", RAW_ABSOLUTE_PATH: "Raw absolute paths are not allowed - use $. or $~ instead", OUTSIDE_BASE_DIR: "Path is outside of the base directory", /** * Error for path validation issues */ validation: { /** * Guidance message for raw absolute paths */ rawAbsolutePath: { message: "For better cross-platform portability, consider using path variables like $. or $PROJECTPATH for project-relative paths and $~ or $HOMEPATH for home-relative paths. Raw absolute paths are allowed but may not work across different environments.", code: "PATH_GUIDANCE", severity: "info" }, /** * Guidance message for paths with slashes but no path variable */ slashesWithoutPathVariable: { message: "For better cross-platform portability, consider using path variables like $. or $PROJECTPATH for project-relative paths and $~ or $HOMEPATH for home-relative paths. Standard paths are allowed but may not work across different environments.", code: "PATH_GUIDANCE", severity: "info" }, /** * Guidance message for paths with dot segments */ dotSegments: { message: "For better cross-platform portability, consider using path variables like $. or $PROJECTPATH for project-relative paths and $~ or $HOMEPATH for home-relative paths. Relative paths with dot segments are allowed but may not work across different environments.", code: "PATH_GUIDANCE", severity: "info" } }, /** * Error messages for file access issues */ fileAccess: { /** * Error message for file not found */ fileNotFound: { message: "File not found: {filePath}", code: "FILE_NOT_FOUND", severity: "recoverable" }, /** * Error message for directory not found */ directoryNotFound: { message: "Directory not found: {dirPath}", code: "DIRECTORY_NOT_FOUND", severity: "recoverable" }, /** * Error message for permission issues */ permissionDenied: { message: "Permission denied when accessing file: {filePath}", code: "PERMISSION_DENIED", severity: "recoverable" } }, /** * Error messages for circular dependency issues */ circular: { /** * Error message for circular imports */ circularImport: { message: "Circular import detected in file: {filePath}", code: "CIRCULAR_IMPORT", severity: "recoverable" } } }; // core/errors/FieldAccessError.ts var _FieldAccessError = class _FieldAccessError extends MlldError { constructor(message, details, cause) { super(message, { code: ResolutionErrorCode.FIELD_ACCESS_ERROR, severity: ErrorSeverity.Recoverable, details, cause }); __publicField(this, "details"); this.name = "FieldAccessError"; this.details = details; } }; __name(_FieldAccessError, "FieldAccessError"); var FieldAccessError = _FieldAccessError; // core/errors/VariableResolutionError.ts var _VariableResolutionError = class _VariableResolutionError extends MlldError { constructor(message, options) { super(message, { code: options.code, severity: options.severity || ErrorSeverity.Recoverable, details: options.details, sourceLocation: options.sourceLocation, cause: options.cause }); } }; __name(_VariableResolutionError, "VariableResolutionError"); var VariableResolutionError = _VariableResolutionError; // core/errors/index.ts var ResolutionErrorCode = /* @__PURE__ */ function(ResolutionErrorCode2) { ResolutionErrorCode2["FIELD_ACCESS_ERROR"] = "FIELD_ACCESS_ERROR"; ResolutionErrorCode2["VARIABLE_NOT_FOUND"] = "VARIABLE_NOT_FOUND"; ResolutionErrorCode2["INVALID_VARIABLE_TYPE"] = "INVALID_VARIABLE_TYPE"; ResolutionErrorCode2["CIRCULAR_REFERENCE"] = "CIRCULAR_REFERENCE"; ResolutionErrorCode2["MAX_DEPTH_EXCEEDED"] = "MAX_DEPTH_EXCEEDED"; ResolutionErrorCode2["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE"; ResolutionErrorCode2["STRINGIFY_FAILED"] = "STRINGIFY_FAILED"; ResolutionErrorCode2["E_PARSE_FAILED"] = "E_PARSE_FAILED"; ResolutionErrorCode2["E_RESOLVE_CONTENT_FAILED"] = "E_RESOLVE_CONTENT_FAILED"; ResolutionErrorCode2["E_RESOLVE_TEXT_FAILED"] = "E_RESOLVE_TEXT_FAILED"; ResolutionErrorCode2["E_RESOLVE_DATA_FAILED"] = "E_RESOLVE_DATA_FAILED"; ResolutionErrorCode2["E_RESOLVE_INVALID_PATH_TYPE"] = "E_RESOLVE_INVALID_PATH_TYPE"; ResolutionErrorCode2["E_UNSUPPORTED_TYPE"] = "E_UNSUPPORTED_TYPE"; ResolutionErrorCode2["E_COMMAND_FAILED"] = "E_COMMAND_FAILED"; ResolutionErrorCode2["E_COMMAND_TYPE_UNSUPPORTED"] = "E_COMMAND_TYPE_UNSUPPORTED"; ResolutionErrorCode2["E_SECTION_NOT_FOUND"] = "E_SECTION_NOT_FOUND"; ResolutionErrorCode2["E_SECTION_EXTRACTION_FAILED"] = "E_SECTION_EXTRACTION_FAILED"; ResolutionErrorCode2["E_VAR_NOT_FOUND"] = "E_VAR_NOT_FOUND"; ResolutionErrorCode2["E_UNEXPECTED_TYPE"] = "E_UNEXPECTED_TYPE"; ResolutionErrorCode2["E_PATH_VALIDATION_FAILED"] = "E_PATH_VALIDATION_FAILED"; return ResolutionErrorCode2; }({}); export { DataEvaluationError, ErrorSeverity, FieldAccessError, MlldCommandExecutionError, MlldConditionError, MlldDependencyError, MlldDirectiveError, MlldError, MlldFileNotFoundError, MlldFileSystemError, MlldImportError, MlldInterpreterError, MlldOutputError, MlldParseError, MlldResolutionError, MlldWhenExpressionError, PathErrorCode, PathErrorMessages, PathValidationError, ResolutionErrorCode, ResolverError, ResolverErrorCode, VariableRedefinitionError, VariableResolutionError }; //# sourceMappingURL=chunk-YMCO2JI3.mjs.map //# sourceMappingURL=chunk-YMCO2JI3.mjs.map