Read-only access to project resources — files and directories bundled with a Hot deploy via hot.project.<name>.resources.paths.

Resources use a "classpath" lookup model: the union of files under every configured root is exposed by relative path. Use this module to read prompts, schemas, JSON config, container payloads, or any other static asset that should travel with your code.

Example

::res ::hot::resource

prompt ::res/load-str("prompts/welcome.md")
schema from-json(::res/load-str("schemas/user.json"))
js-files ::res/list-matching("**/*.js")

Functions

exists

fn (rel-path: Str): Bool

Return true when rel-path is present in the registry.

Example

::res ::hot::resource
prompt if(::res/exists("prompts/welcome.md"), ::res/load-str("prompts/welcome.md"), "Hello!")

list

fn (): Vec<ResourceRef>

Return every registered resource as a Vec<ResourceRef>. Order matches the order in which roots were declared, then alphabetical within each root.

Example

::res ::hot::resource
paths map(::res/list(), %.path)
total reduce(::res/list(), (acc, ref) { add(acc, ref.size) }, 0)

list-matching

fn (glob: Str): Vec<ResourceRef>

Return every resource whose relative path matches glob. Uses .gitignore-style globbing (**, *, ?, character classes).

Example

docs ::hot::resource/list-matching("docs/**/*.md")

load

fn (rel-path: Str): Bytes

Read a resource as raw Bytes. Errors when the path is not in the resource registry.

Example

bytes ::hot::resource/load("images/logo.png")

load-str

fn (rel-path: Str): Str

Read a resource as a UTF-8 Str. Errors when the path is missing or the file is not valid UTF-8.

Example

text ::hot::resource/load-str("prompts/welcome.md")

path

fn (rel-path: Str): Str

Return the canonical hot://res/<rel-path> URI for a resource. Useful for handing references to subsystems (Box mounts, file pipelines) that resolve hot:// URIs themselves.

Example

::res ::hot::resource
uri ::res/path("prompts/welcome.md")
tap(uri)

Types

ResourceRef

ResourceRef type {
    path: Str,
    hash: Str,
    size: Int
}

Metadata about a single resource entry.

  • path — relative path used for lookup, e.g. "prompts/welcome.md".
  • hash — Blake3 content hash. Empty in dev mode until first read; populated at hot build/hot deploy time.
  • size — file size in bytes.