Skip to main content

File System

All operations work within directories declared in the manifest (fs.dirs). Paths must be absolute.

Read & Write

import { fsRead, fsWrite, fsCreate } from "@luminarys/sdk-as";

// Read file
const data = fsRead("/data/config.json");

// Write / overwrite
fsWrite("/data/output.txt", Uint8Array.wrap(String.UTF8.encode("content")));

// Create (fails if file exists)
fsCreate("/data/new.txt", Uint8Array.wrap(String.UTF8.encode("new file")));

Read lines with pagination

import { fsReadLines } from "@luminarys/sdk-as";

const result = fsReadLines("/data/logfile.log", 100, 50);
// result.lines, result.total_lines, result.offset, result.is_truncated

Parameters:

FieldTypeDescription
pathstringAbsolute file path
offsetintStart line, 0-based (0 = beginning)
limitintMaximum lines to return (0 = all)

Response:

FieldTypeDescription
linesstring[]Array of line contents
total_linesintTotal number of lines in the file
offsetintActual offset used
is_truncatedboolTrue if more lines exist beyond the returned range

Directories

import { fsMkdir, fsLs, fsDelete } from "@luminarys/sdk-as";

// Create directory (recursive, supports brace expansion)
fsMkdir("/data/logs/2026/03");

// List directory
const entries = fsLs("/data");
// entries[i].name, entries[i].size, entries[i].is_dir

// Delete file or directory
fsDelete("/data/temp");

fsLs / FsLs / fs_ls parameters:

FieldTypeDescription
pathstringAbsolute directory path
longboolIf true, populate mod_time, mode, mode_str (slower)

DirEntry fields:

FieldTypeConditionDescription
namestringalwaysFile or directory name
sizeint64alwaysSize in bytes (0 for directories)
is_dirboolalwaysIs a directory
mod_timeint64long=trueUnix timestamp (seconds)
modeuint32long=truePermission bits (e.g. 493 = 0o755)
mode_strstringlong=trueHuman-readable, e.g. "drwxr-xr-x"

Copy & Chmod

import { fsCopy, fsChmod } from "@luminarys/sdk-as";

// Copy file: source → destination
fsCopy("/data/src.txt", "/data/backup/src.txt");
fsChmod("/data/script.sh", 493, false); // 0o755 = 493

Glob

import { fsGlob } from "@luminarys/sdk-as";

// patterns, path, onlyFiles
const matches = fsGlob(["**/*.go"], "/data/project", true);
// matches[i].path, matches[i].is_dir

GlobOptions:

FieldTypeDefaultDescription
patternsstring[]requiredGlob patterns (union). Supports *, ?, [abc], **, {a,b}
pathstringsandbox rootBase directory to search
only_filesboolfalseReturn only regular files
only_dirsboolfalseReturn only directories
match_hiddenboolfalseInclude dot-files and dot-directories
max_depthint0 (unlimited)Max directory recursion depth
ignore_dirsstring[][]Directory names to skip entirely

GlobEntry (result):

FieldTypeDescription
pathstringPath relative to the search directory
is_dirboolIs a directory

Grep

import { fsGrep } from "@luminarys/sdk-as";

// pattern, path, fixed, caseInsensitive, withLines
const matches = fsGrep("func main", "/data/project", false, false, true);
// matches[i].path, matches[i].matches[j].line_num, matches[i].matches[j].line

GrepOptions:

FieldTypeDefaultDescription
patternstringrequiredRE2 regex (or literal when fixed = true)
pathstringsandbox rootDirectory or file to search
fixedboolfalseTreat pattern as literal string
case_insensitiveboolfalseCase-insensitive matching
with_linesboolfalseInclude full line text in results
includestring[][]Glob patterns to restrict files
excludestring[][]Glob patterns to skip files
max_countint0 (unlimited)Max matching lines per file
max_depthint0 (unlimited)Max directory recursion depth
workersint0 (default)Number of parallel search workers
type_filterstring""File type filter (e.g. "go", "ts")
ignore_dirsstring[][]Directory names to skip entirely
filename_onlyboolfalseReturn only file paths, no line details

GrepFileMatch (result):

FieldTypeDescription
pathstringFile path relative to the search directory
matchesGrepLineMatch[]Matching lines in this file

GrepLineMatch:

FieldTypeDescription
line_numintLine number (1-based)
linestringLine content (only when with_lines = true)
rangesGrepRange[]Byte-offset ranges of matches within the line

GrepRange:

FieldTypeDescription
startintStart byte offset (inclusive)
endintEnd byte offset (exclusive)

Allowed directories

Query which directories the skill has access to at runtime:

import { fsAllowedDirs } from "@luminarys/sdk-as";

const dirs = fsAllowedDirs();
for (let i = 0; i < dirs.length; i++) {
// dirs[i].path, dirs[i].mode ("ro" | "rw")
}

AllowedDir:

FieldTypeDescription
pathstringAbsolute directory path
modestringAccess mode: "ro" (read-only) or "rw" (read-write)