Filesystem access, archives and moving bytes. Each function lists its parameters, defaults and return value.
File system operations.
Scope: System
Function Description file.read()Read file contents file.write()Write content to a file file.exists()Check if a file or directory exists file.remove()Remove a file or directory file.copy()Copy a file file.move()Move or rename a file file.mkdir()Create a directory
Read the contents of a file.
Parameter Type Default Description pathstring — File path to read (required) encodingstring "utf-8"Text encoding
Field Type Description successbool Whether read succeeded contentstring File contents
let result = file . read ( { path: " /config/settings.json " } )
// Read with home directory expansion
let result = file . read ( { path: " ~/.ssh/config " } )
let result = file . read ( { path: " /etc/hostname " } )
log ( " Hostname: " + result . content . trim ())
Write content to a file.
Parameter Type Default Description pathstring — File path to write (required) contentstring — Content to write (required) appendbool falseAppend instead of overwrite createbool trueCreate file if it doesn’t exist modestring "0644"File permissions (octal)
Field Type Description successbool Whether write succeeded
path: " /var/log/app.log " ,
content: " New log entry \n " ,
let data = { name: " app " , version: " 1.0 " }
path: " /tmp/config.json " ,
content: JSON . stringify ( data , null , 2 )
Check if a file or directory exists.
Parameter Type Default Description pathstring — Path to check (required)
Field Type Description successbool Whether the check succeeded existsbool Whether the path exists isDirbool Whether the path is a directory
// Check if a file exists
let result = file . exists ( { path: " /config/settings.json " } )
// Check if a directory exists
let result = file . exists ( { path: " /app/node_modules " } )
if ( result . exists && result . isDir ) {
log ( " Dependencies installed " )
Remove a file or directory.
Parameter Type Default Description pathstring — Path to remove (required) recursivebool falseRemove directories recursively
Field Type Description successbool Whether removal succeeded
file . remove ({ path: " /tmp/output.txt " })
// Remove a directory recursively
file . remove ({ path: " /tmp/build " , recursive: true })
Copy a file from source to destination.
Parameter Type Default Description sourcestring — Source file path (required) destinationstring — Destination file path (required) overwritebool falseOverwrite existing file
Field Type Description successbool Whether copy succeeded
source: " /config/template.yaml " ,
destination: " /config/settings.yaml "
source: " /tmp/new-config.json " ,
destination: " /app/config.json " ,
Move or rename a file.
Parameter Type Default Description sourcestring — Source file path (required) destinationstring — Destination file path (required) overwritebool falseOverwrite existing file
Field Type Description successbool Whether move succeeded
source: " /tmp/output.txt " ,
destination: " /tmp/result.txt "
source: " /tmp/new-config.json " ,
destination: " /app/config.json " ,
Create a directory.
Parameter Type Default Description pathstring — Directory path to create (required) recursivebool trueCreate parent directories as needed modestring "0755"Directory permissions (octal)
Field Type Description successbool Whether directory creation succeeded
file . mkdir ({ path: " /tmp/output " })
// Create nested directories
file . mkdir ({ path: " /app/data/cache/images " })
// Non-recursive (parent must exist)
file . mkdir ({ path: " /app/new-dir " , recursive: false })
File pattern matching functions.
Scope: System
Function Description glob.find()Find files matching a glob pattern
Find files matching a glob pattern.
Parameter Type Default Description patternstring — Glob pattern to match (required, e.g., "**/*.txt", "*.go") pathstring "."Base directory to search in excludearray — Patterns to exclude filesOnlybool falseReturn only files, not directories dirsOnlybool falseReturn only directories, not files
Field Type Description successbool Whether the search succeeded matchesarray Array of matching file paths
let result = glob . find ( { pattern: " **/*.yaml " } )
log ( " Found " + result . matches . length + " YAML files " )
// Find files in a specific directory
exclude: [ " node_modules/** " , " dist/** " ]
// Files only (no directories)
Archive extraction and compression functions.
Scope: System
Function Description archive.extract()Extract an archive file archive.compress()Create an archive from files or directories
Extract an archive file (tar, tar.gz, tar.bz2, zip).
Parameter Type Default Description sourcestring — Path to archive file (required) destinationstring — Extraction destination directory (required) formatstring (auto) Archive format — auto-detected from extension if not specified stripRootbool falseRemove root directory from extracted paths
Field Type Description successbool Whether extraction succeeded pathstring Extraction destination path
// Extract a tar.gz archive
source: " /tmp/app-v1.2.tar.gz " ,
// Extract with root stripping
source: " /tmp/release.zip " ,
// Extract with explicit format
source: " /tmp/data.archive " ,
Create an archive from files or directories.
Parameter Type Default Description sourcestring — Single source path (file or directory) sourcesarray — Array of source paths (alternative to source) destinationstring — Output archive path (required) formatstring (auto) Archive format — auto-detected from extension if not specified
Field Type Description successbool Whether compression succeeded pathstring Output archive path
destination: " /tmp/app-dist.tar.gz "
// Compress multiple sources
sources: [ " /app/dist " , " /app/config " ],
destination: " /tmp/release.zip "
destination: " /tmp/data.archive " ,
Content extraction from structured documents.
Scope: System
Function Description extract.markdown()Extract content from Markdown documents
Extract structured content from Markdown documents — code blocks by language, sections by heading, or specific matches by index.
Parameter Type Default Description contentstring — Inline Markdown content to extract from filestring — File path to read content from globstring — Glob pattern for multiple files selectstring — CSS/path selector to narrow extraction languagestring — Filter code blocks by language headingstring — Filter sections by heading text indexint — Select a specific match by index
At least one of content, file, or glob is required.
Field Type Description successbool Whether extraction succeeded contentstring Extracted content blocksarray Extracted code blocks (when filtering by language)
// Extract code blocks by language
let result = extract . markdown ( {
log ( " Found " + result . blocks . length + " YAML blocks " )
// Extract section by heading
let section = extract . markdown ( {
file: " ./docs/README.md " ,
heading: " Getting Started "
// Extract from file with language filter
let config = extract . markdown ( {
log ( " First JSON block: " + config . content )
// Extract from multiple files
let results = extract . markdown ( {
Rsync file synchronization functions. Shells out to the local rsync binary
(must be on PATH, or set via rsyncPath) and threads SSH transport
parameters through -e ssh ....
Scope: Network
Function Description rsync.push()Sync a local path to a remote host (local → remote) rsync.pull()Sync a remote path to a local path (remote → local) rsync.sync()Push or pull based on a direction parameter
All three functions accept the same parameter map.
Parameter Type Default Description hoststring — Remote host (required) userstring — SSH username portint 22SSH port keyPathstring — Path to private key file jumpHoststring — Jump/bastion host jumpUserstring — Jump host username jumpPortint 22Jump host SSH port jumpKeyPathstring — Jump host private key path sshCommandstring — Custom ssh command — overrides keyPath/port/jumpHost when set rsyncPathstring "rsync"Path to the rsync binary
Parameter Type Default Description localPathstring — Local file or directory (required) remotePathstring — Remote file or directory (required) directionstring "push""push" or "pull" — used by rsync.sync() only
Parameter Type Default Description archivebool falseArchive mode (-a) — recursive + symlinks + perms + times + owner + group + devices compressbool falseCompress during transfer (-z) verbosebool falseVerbose output (-v) progressbool falseShow transfer progress (--progress) deletebool falseDelete extraneous files at the destination (--delete) dryRunbool falseTrial run, no changes (-n) recursivebool falseRecursive (-r). Implied by archive preservePermsbool falsePreserve permissions (-p). Implied by archive preserveTimesbool falsePreserve modification times (-t). Implied by archive preserveOwnerbool falsePreserve owner (-o). Implied by archive preserveGroupbool falsePreserve group (-g). Implied by archive checksumbool falseCompare with checksums instead of mtime+size (-c) partialbool falseKeep partially-transferred files (--partial) partialDirstring — Directory for partial files (--partial-dir) bandwidthLimitint 0Bandwidth cap in KB/s (--bwlimit) timeoutint 0I/O timeout in seconds (--timeout)
Parameter Type Description excludestring[] Patterns passed via --exclude includestring[] Patterns passed via --include excludeFromstring File of exclude patterns (--exclude-from) includeFromstring File of include patterns (--include-from)
Parameter Type Description extraArgsstring[] Additional arguments appended to the rsync command line
Field Type Description successbool Whether the sync succeeded bytesSentint Bytes sent to the remote bytesReceivedint Bytes received from the remote filesTransferredint Number of files transferred totalFilesint Total files considered outputstring Captured stdout errorOutputstring Captured stderr exitCodeint rsync exit code errorstring Error message when success is false
let result = rsync . push ( {
keyPath: " ~/.ssh/id_rsa " ,
remotePath: " /var/www/html/ " ,
log ( " Sent " + result . bytesSent + " bytes " )
keyPath: " ~/.ssh/backup_key " ,
remotePath: " /var/backups/db/ " ,
let preview = rsync . push ( {
host: " prod.example.com " ,
keyPath: " ~/.ssh/prod_key " ,
exclude: [ " *.log " , " node_modules/ " , " .git/ " ] ,
keyPath: " ~/.ssh/internal_key " ,
jumpHost: " bastion.example.com " ,
jumpKeyPath: " ~/.ssh/bastion_key " ,
remotePath: " /opt/release/ " ,
host: " host.example.com " ,
sshCommand: " ssh -o StrictHostKeyChecking=yes -o UserKnownHostsFile=~/.ssh/prod_known_hosts -i ~/.ssh/prod_key " ,
host: " host.example.com " ,
keyPath: " ~/.ssh/id_rsa " ,
remotePath: " /var/tree/ " ,
direction: dir // "push" or "pull"
host: " remote.example.com " ,
keyPath: " ~/.ssh/id_rsa " ,
localPath: " ./large-dataset/ " ,
bandwidthLimit: 1024 , // 1 MB/s cap
partialDir: " .rsync-partial "
SCP file transfer functions. Built on the standalone registry/scp package
which adds jump-host (ProxyJump) chains, strict host key checking, and
explicit authMethod selection on top of the basic SCP transport.
For a connection-less single-call SCP that piggybacks on the SSH namespace’s
client, see ssh.upload / ssh.download. Use the scp
namespace when you need jump hosts, agent auth selection, or known_hosts
verification.
Scope: Network
Function Description scp.upload()Upload a local file or directory to a remote host scp.download()Download a remote file or directory to the local host scp.transfer()Upload or download based on a direction parameter
All three functions accept the same parameter map.
Parameter Type Default Description hoststring — Remote host or host:port (required) userstring — SSH username (required) passwordstring — Password for password auth keyPathstring — Path to private key file keyPassphrasestring — Passphrase for an encrypted private key authMethodstring inferred "key", "password", or "agent". Inferred from credentials when omittedtimeoutint 120Connection timeout in seconds strictHostKeyCheckingbool falseVerify the host key against known_hosts knownHostsPathstring — Path to a known_hosts file jumpHostsarray — Ordered list of jump/bastion hosts; see below
Parameter Type Default Description localPathstring — Local file or directory (required) remotePathstring — Remote file or directory (required) recursivebool falseCopy directories recursively preserveModebool falsePreserve file permissions and timestamps directionstring "upload""upload" or "download" — used by scp.transfer() only
jumpHosts is an array of map entries. Each entry accepts:
Field Type Description hoststring Jump host host or host:port userstring SSH username on the jump host passwordstring Password for password auth keyPathstring Path to private key file keyPassphrasestring Passphrase for the private key authMethodstring "key", "password", or "agent"
Hosts are dialed in order. The final SSH connection to host is tunnelled
through every jump host in sequence.
When strictHostKeyChecking: true, every hop — including every jump host —
is verified against the same known_hosts file. When strictHostKeyChecking
is left off, both the target and the jump hosts skip verification.
Field Type Description successbool Whether the transfer succeeded bytesTransferredint Total bytes transferred filesTransferredint Number of files transferred (multi-file when recursive: true) errorstring Error message when success is false
let result = scp . upload ( {
host: " server.example.com " ,
keyPath: " ~/.ssh/id_rsa " ,
localPath: " ./dist/app.tar.gz " ,
remotePath: " /tmp/app.tar.gz "
log ( " Uploaded " + result . bytesTransferred + " bytes " )
host: " server.example.com " ,
keyPath: " ~/.ssh/id_rsa " ,
remotePath: " /etc/myapp/ " ,
localPath: " ./backup/config/ " ,
host: " 10.0.5.20 " , // private-network target
keyPath: " ~/.ssh/internal_key " ,
host: " bastion.example.com:22 " ,
keyPath: " ~/.ssh/bastion_key "
localPath: " ./release.tar.gz " ,
remotePath: " /opt/releases/release.tar.gz "
host: " prod.example.com " ,
keyPath: " ~/.ssh/prod_key " ,
strictHostKeyChecking: true ,
knownHostsPath: " ~/.ssh/known_hosts " ,
localPath: " ./build/server " ,
remotePath: " /usr/local/bin/server " ,
function syncArtifact ( dir ) {
host: " server.example.com " ,
keyPath: " ~/.ssh/id_rsa " ,
localPath: " ./artifact.bin " ,
remotePath: " /var/cache/artifact.bin " ,
direction: dir // "upload" or "download"
S3-compatible storage functions.
Scope: Network
Function Description s3.upload()Upload files to S3 s3.download()Download files from S3 s3.list()List objects in S3 s3.delete()Delete objects from S3
All functions require these connection parameters:
Parameter Type Default Description endpointstring — S3 endpoint URL (required) accessKeystring — Access key ID (required) secretKeystring — Secret access key (required) bucketstring — Bucket name (required) securebool falseUse HTTPS insecureSkipVerifybool falseSkip TLS certificate verification
Upload files or directories to S3.
Parameter Type Default Description sourcestring — Local file/directory path (required) destinationstring — S3 object key/prefix (required) recursivebool trueUpload directories recursively
Field Type Description successbool Whether upload succeeded uploadedint Number of files uploaded
endpoint: " s3.amazonaws.com " ,
accessKey: " AKIAIOSFODNN7EXAMPLE " ,
secretKey: " wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY " ,
source: " /tmp/backup.tar.gz " ,
destination: " backups/backup.tar.gz "
// Upload a directory (MinIO)
endpoint: " minio.local:9000 " ,
destination: " releases/v1.0/ " ,
Download files from S3.
Parameter Type Default Description objectstring — S3 object key to download (required) pathstring — Local destination path (required)
Field Type Description successbool Whether download succeeded downloadedint Number of files downloaded
endpoint: " s3.amazonaws.com " ,
accessKey: " AKIAIOSFODNN7EXAMPLE " ,
secretKey: " wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY " ,
object: " backups/backup.tar.gz " ,
path: " /tmp/backup.tar.gz "
List objects in an S3 bucket.
Parameter Type Default Description prefixstring — Filter objects by prefix
Field Type Description successbool Whether listing succeeded objectsarray Array of objects with name, size, modTime, isDir
endpoint: " minio.local:9000 " ,
for ( let obj of result . objects ) {
log ( obj . name + " ( " + obj . size + " bytes) " )
// List with prefix filter
endpoint: " minio.local:9000 " ,
Delete objects from S3.
Parameter Type Default Description pathstring — Object key or prefix to delete (required) recursivebool falseDelete all objects with the given prefix
Field Type Description successbool Whether deletion succeeded deletedint Number of objects deleted
// Delete a single object
endpoint: " minio.local:9000 " ,
path: " old-release.tar.gz "
// Delete all objects with prefix
endpoint: " minio.local:9000 " ,
Azure Blob storage functions.
Scope: Network
Function Description azureblob.upload()Upload files to Azure Blob Storage azureblob.download()Download files from Azure Blob Storage azureblob.list()List blobs in a container azureblob.delete()Delete blobs from Azure Blob Storage
Upload files or directories to Azure Blob Storage with parallel processing and incremental sync support.
Parameter Type Default Description connectionStringstring — Azure storage connection string (required) maxRetriesint 3Maximum retry attempts maxWorkersint 4Concurrent upload workers incrementalbool falseOnly upload changed files continueOnErrorbool trueContinue on individual file errors syncModestring — Sync mode: "fast" or "hash" containerstring — Blob container name (required) sourcestring — Local file/directory path (required) destinationstring — Blob prefix/path (required) recursivebool trueUpload directories recursively skipPatternsarray — Patterns to skip
Field Type Description successbool Whether upload succeeded uploadedint Number of files uploaded skippedint Number of files skipped
connectionString: " DefaultEndpointsProtocol=https;AccountName=... " ,
destination: " releases/v1.0/ "
// Incremental upload (only changed files)
connectionString: " DefaultEndpointsProtocol=https;AccountName=... " ,
skipPatterns: [ " *.tmp " , " .DS_Store " ]
Download files from Azure Blob Storage.
Parameter Type Default Description connectionStringstring — Azure storage connection string (required) maxRetriesint 3Maximum retry attempts maxWorkersint 4Concurrent download workers incrementalbool falseOnly download changed files continueOnErrorbool trueContinue on individual file errors containerstring — Blob container name (required) prefixstring — Blob prefix to download destinationstring — Local destination path (required) skipPatternsarray — Patterns to skip
Field Type Description successbool Whether download succeeded downloadedint Number of files downloaded skippedint Number of files skipped
// Download all blobs with prefix
connectionString: " DefaultEndpointsProtocol=https;AccountName=... " ,
destination: " /tmp/restore/ "
connectionString: " DefaultEndpointsProtocol=https;AccountName=... " ,
destination: " /app/public/images/ " ,
List blobs in an Azure Blob Storage container.
Parameter Type Default Description connectionStringstring — Azure storage connection string (required) containerstring — Blob container name (required) prefixstring — Blob prefix to filter
Field Type Description successbool Whether listing succeeded blobsarray Array of blobs with name, size, lastModified, contentType
// List all blobs in container
let result = azureblob . list ( {
connectionString: " DefaultEndpointsProtocol=https;AccountName=... " ,
for ( let blob of result . blobs ) {
log ( blob . name + " ( " + blob . size + " bytes, " + blob . contentType + " ) " )
// List with prefix filter
let result = azureblob . list ( {
connectionString: " DefaultEndpointsProtocol=https;AccountName=... " ,
Delete blobs from Azure Blob Storage.
Parameter Type Default Description connectionStringstring — Azure storage connection string (required) containerstring — Blob container name (required) prefixstring — Blob prefix to delete blobNamestring — Specific blob name to delete
Field Type Description successbool Whether deletion succeeded deletedint Number of blobs deleted
// Delete a specific blob
connectionString: " DefaultEndpointsProtocol=https;AccountName=... " ,
// Delete all blobs with prefix
connectionString: " DefaultEndpointsProtocol=https;AccountName=... " ,