File Operations
readFile
Read entire file contents as UTF-8 string.string
required
File path (absolute or relative to cwd)
Promise<string>
File contents as UTF-8 string
writeFile
Write string content to a NEW file (fails if file exists).string
required
Destination path (absolute or relative to cwd)
string
required
UTF-8 string to write
fileExists
Check if a path exists (file, directory, or symlink).string
required
Path to check (absolute or relative to cwd)
boolean
true if path exists, false otherwiseDoes not follow symlinks; returns true for broken symlinks. Use
fileStat for more detailed information.fileStat
Get metadata about a file or directory.string
required
Path to stat (absolute or relative to cwd)
FileStat
File metadata object
Follows symlinks. Returns
exists=false for non-existent paths rather than throwing. Size is in bytes; directories may report 0.Directory Operations
readDir
List directory contents.string
required
Directory path (absolute or relative to cwd)
DirEntry[]
Array of directory entries
Returns unsorted entries with type info. Entry names are relative to the directory (use
pathJoin to construct full paths). Throws on permission errors or if path is not a directory.Path Operations
pathJoin
Join path segments using the OS path separator.string[]
required
Path segments to join
string
Joined path string
Handles empty segments and normalizes separators. If a segment is absolute, previous segments are discarded.
pathDirname
Get the parent directory of a path.string
required
File or directory path
string
Parent directory path, or empty string for root paths
Does not resolve symlinks or check existence.
pathBasename
Get the final component of a path.string
required
File or directory path
string
Final path component, or empty string for root paths
Does not strip file extension; use
pathExtname for that.pathExtname
Get the file extension including the dot.string
required
File path
string
File extension with dot, or empty string if no extension
Only returns the last extension for files like “archive.tar.gz” (returns “.gz”).
pathIsAbsolute
Check if a path is absolute.string
required
Path to check
boolean
true if path is absolute, false otherwiseOn Unix: starts with ”/”. On Windows: starts with drive letter or UNC path.
Environment Operations
getCwd
Get the editor’s current working directory.string
Absolute path to the editor’s working directory set at startup
Use as base for resolving relative paths.
getEnv
Get an environment variable.string
required
Name of environment variable
string
Environment variable value, or empty string if not set