Skip to content

PromptScript API


Class: FileLoader

Defined in: resolver/src/loader.ts:19

File loader for loading and resolving PromptScript files.

Constructors

Constructor

new FileLoader(options): FileLoader

Defined in: resolver/src/loader.ts:23

Parameters

options

LoaderOptions

Returns

FileLoader

Methods

getLocalPath()

getLocalPath(): string

Defined in: resolver/src/loader.ts:105

Get the local path.

Returns

string


getRegistryPath()

getRegistryPath(): string

Defined in: resolver/src/loader.ts:98

Get the registry path.

Returns

string


load()

load(path): Promise\<string>

Defined in: resolver/src/loader.ts:35

Load file content from disk.

Parameters

path

string

Absolute path to the file

Returns

Promise\<string>

File content as string

Throws

FileNotFoundError if file doesn't exist


resolveRef()

resolveRef(ref, fromFile): string

Defined in: resolver/src/loader.ts:86

Resolve a PathReference to an absolute path.

Parameters

ref

PathReference

PathReference from AST

fromFile

string

File containing the reference (for relative resolution)

Returns

string

Absolute filesystem path


toAbsolutePath()

toAbsolutePath(path): string

Defined in: resolver/src/loader.ts:57

Convert a path string to an absolute path.

Handles: - Already absolute paths (start with /) - Registry paths (namespace/path) - Relative paths (./path, ../path, or bare path)

Parameters

path

string

Path to convert

Returns

string

Absolute filesystem path