or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

file-operations.mdindex.mdlogic-math.mdmisc-utilities.mdpath-utilities.mdsystem-utilities.mdtext-processing.md
tile.json

system-utilities.mddocs/

System Utilities

System information and environment utilities for inspecting and managing system state within the WebAssembly environment. These utilities provide access to system information, user context, and environment variables.

Capabilities

System Information

Display system and kernel information.

/**
 * Display system information
 * WebAssembly binary: dist/wasm/bin/uname
 * 
 * Usage patterns:
 * - uname [options]
 * - Supports -a (all info), -s (system), -n (node), -r (release)
 * - Shows system name, version, and architecture information
 */

User Information

Display user and group identification information.

/**
 * Display user and group IDs
 * WebAssembly binary: dist/wasm/bin/id
 * 
 * Usage patterns:
 * - id [options] [user]
 * - Supports -u (user ID), -g (group ID), -G (all groups)
 * - Shows effective and real user/group information
 */
/**
 * Display login name
 * WebAssembly binary: dist/wasm/bin/logname
 * 
 * Usage patterns:
 * - logname
 * - Displays the current user's login name
 * - Gets name from login session information
 */

Environment Management

Display and manipulate environment variables.

/**
 * Display or modify environment
 * WebAssembly binary: dist/wasm/bin/env
 * 
 * Usage patterns:
 * - env [options] [variable=value...] [command [args...]]
 * - Supports -i (ignore environment), -u (unset variable)
 * - Can run commands with modified environment
 * - Note: execvp functionality limited in WebAssembly context
 */

Date and Time

Display or set system date and time.

/**
 * Display or set system date
 * WebAssembly binary: dist/wasm/bin/date
 * 
 * Usage patterns:
 * - date [options] [+format]
 * - date [options] [date_string]
 * - Supports custom formatting with strftime format specifiers
 * - Can parse and display dates in various formats
 */

Terminal Information

Display terminal device information.

/**
 * Display terminal device name
 * WebAssembly binary: dist/wasm/bin/tty
 * 
 * Usage patterns:
 * - tty [options]
 * - Supports -s (silent mode)
 * - Shows the file name of the terminal connected to stdin
 */

File System Information

Display directory space usage information.

/**
 * Display directory space usage
 * WebAssembly binary: dist/wasm/bin/du
 * 
 * Usage patterns:
 * - du [options] [directory...]
 * - Supports -h (human readable), -s (summary), -a (all files)
 * - Calculates disk usage for directories and files
 */

Command Location

Locate executable commands in the system PATH.

/**
 * Locate commands in PATH
 * WebAssembly binary: dist/wasm/bin/which
 * 
 * Usage patterns:
 * - which [options] command...
 * - Supports -a (all matches), -s (silent mode)
 * - Shows the full path of executable commands
 */

Usage Examples

System inspection:

const { path } = require("@cowasm/coreutils");
const { join } = require("path");

// Access system utility binaries
const binPath = join(path, "bin");
const unameBinary = join(binPath, "uname");
const idBinary = join(binPath, "id");
const dateBinary = join(binPath, "date");

// These would be executed via your WebAssembly runtime

Common system queries:

# System identification
uname -a                    # Full system information
uname -s                    # System name only

# User context
id                          # Current user and group IDs
logname                     # Login name

# Environment inspection
env                         # All environment variables
env | grep PATH             # PATH variable specifically

# Date and time
date                        # Current date and time
date "+%Y-%m-%d %H:%M:%S"   # Custom format

# Disk usage
du -sh /path/to/directory   # Directory size summary
du -h /path/to/directory    # Human-readable directory usage

# Command location
which ls                    # Find ls command location

Environment manipulation:

# Run command with modified environment
env PATH="/custom/path:$PATH" command

# Run command with clean environment
env -i HOME="$HOME" PATH="/bin:/usr/bin" command

# Unset specific variables
env -u TEMP_VAR command

Date formatting examples:

# Various date formats
date "+%Y-%m-%d"           # 2023-12-25
date "+%H:%M:%S"           # 14:30:45
date "+%A, %B %d, %Y"      # Monday, December 25, 2023
date "+%s"                 # Unix timestamp

WebAssembly Environment Considerations

System Information

  • uname reports WebAssembly/WASI system information
  • Architecture information reflects the WASM runtime environment
  • System version information may be limited compared to native systems

User Context

  • User and group information depends on WASM runtime implementation
  • Some user identification features may be limited or simulated
  • Login name detection works within WASM environment constraints

Environment Variables

  • Environment access works within WASM sandbox limitations
  • Some system environment variables may not be available
  • Custom environment manipulation is fully supported

File System Access

  • du operates on the virtual file system provided by WASM runtime
  • Disk usage calculations are accurate within the virtual environment
  • Directory space reporting reflects WASM filesystem structure

Time and Date

  • Date operations work with system time as provided by WASM runtime
  • Timezone handling depends on runtime implementation
  • Date parsing and formatting fully functional

Notes

  • All utilities operate within WebAssembly sandbox security constraints
  • System information reflects the WASM runtime environment, not host system
  • Some functionality may be limited compared to native Unix implementations
  • Error handling and exit codes follow standard Unix conventions
  • Performance characteristics appropriate for WASM execution model