Skip to content

smelt.path

Tier: Host - Available in every runtime, including headless mode.

Visibility: Public - Stable Lua API intended for user config and plugins.

Pure path arithmetic: normalize, join, relative, expand, display, etc.

smelt.path.basename

fun(p: string): string?

Return the final component (file name) of p, or nil if p ends in ...

smelt.path.canonical

fun(p: string): string?, string?

Resolve p to its canonical absolute form (following symlinks). Returns (path, nil) on success or (nil, err_string) on failure.

smelt.path.commands_dir

fun(): string

Return the absolute path to the slash-commands directory under the user config root.

smelt.path.config_dir

fun(): string

Return the absolute path to smelt's user config directory.

smelt.path.display

fun(p: string): string

Return a user-friendly rendering of p for UI display (e.g. with the home dir abbreviated to ~).

smelt.path.display_streaming

fun(p: string): string

Return a user-friendly rendering of a possibly partial path for streaming tool summaries. Absolute paths that may still collapse to the current working directory or home directory return an empty string until enough path has arrived.

smelt.path.expand

fun(p: string): string

Expand config-path syntax in p: leading ~, $VAR, and ${VAR}. Does not invoke a shell, expand globs, or canonicalize symlinks.

smelt.path.extension

fun(p: string): string?

Return the file extension of p (without the leading dot), or nil if there is none.

smelt.path.is_absolute

fun(p: string): boolean

Return true if p is an absolute path on the current platform.

smelt.path.join

fun(...: string): string

Join the variadic parts into a single path using the platform separator.

smelt.path.normalize

fun(p: string): string

Normalize p by collapsing redundant ., .., and separator components without touching the filesystem.

smelt.path.parent

fun(p: string): string?

Return the parent directory of p, or nil if p has no parent component.

smelt.path.relative

fun(base: string, target: string): string

Return the path of target expressed relative to base.