/** * CLI Shared Utilities * Common formatting functions for CLI tools */ import { VERSION } from '@rcrsr/rill'; declare const CLI_VERSION: string; import type { NativeValue, RillValue } from '@rcrsr/rill'; import { type ScopeInfo } from './cli-error-enrichment.js'; import { type FormatOptions } from './cli-error-formatter.js'; /** * Format error for stderr output * * When source is available, uses enrichment pipeline to add source snippets and suggestions. * Otherwise, falls back to simple formatting for backward compatibility. * * @param err - The error to format * @param source - Optional source code for enrichment * @param options - Optional format options (defaults to human format) * @param scope - Optional scope information for suggestions * @returns Formatted error message */ export declare function formatError(err: Error, source?: string, options?: Partial, scope?: ScopeInfo, filePath?: string): string; /** * Build a FormatOptions object from a partial override, applying defaults. */ export declare function buildFormatOptions(options?: Partial): FormatOptions; /** * Format the status sidecar of an invalid `RillValue` returned by a script. * * Used when a `guard`-recovered invalid threads through to the script * result. There is no `RillError` to enrich, so we render the halt view * directly with no source-snippet block. */ export declare function formatStatus(value: RillValue, options?: Partial, source?: string, filePath?: string): string; /** * Determine exit code from script result * * Implements exit code semantics per language spec: * - true / non-empty string: exit 0 * - false / empty string: exit 1 * - [0, "message"]: exit 0 with message * - [1, "message"]: exit 1 with message * * @param value - The script return value * @returns Exit code and optional message */ export declare function determineExitCode(value: NativeValue): { code: number; message?: string; }; /** * Minimum Node.js version required by rill-cli. * Mirrors `engines.node` in package.json. */ export declare const MIN_NODE_VERSION = "22.16.0"; /** * Throw-style assertion that the running Node version meets MIN_NODE_VERSION. * * Returns null when the runtime is acceptable; returns a user-facing error * message otherwise. The message is suitable for writing directly to stderr. * * Extracted from CLI entry for unit testability. */ export declare function checkNodeVersion(actual?: string): string | null; /** * Detect help or version flags in CLI argument array. * Checks for --help, -h, --version, -v in any position. * * @param argv - Command-line arguments (process.argv.slice(2)) * @returns Object with mode if flag found, null otherwise */ export declare function detectHelpVersionFlag(argv: string[]): { mode: 'help' | 'version'; } | null; /** * Package version string (re-exported from version-data.ts) * * This replaces the previous async readVersion() function with a synchronous constant. * The version is now generated at build time by packages/core/scripts/generate-version.ts. */ export { VERSION, CLI_VERSION };