Assets and .ferret packages
Skill ferret-packages · download all skills · SKILL.md
When to use#
Packing a game's levels, loading content from a URL or a file, signing or encrypting it, caching downloads, or reasoning about the security of loaded content.
What exists#
FerretPackage,packPackage,PackageManifest,validatePackageManifest,validatePackage: the format and its own checks.- Signing and keys:
generateSigningKey,signManifest,verifyManifestSignature,generateEncryptionKey,createEncryption. - Sources:
urlSource,httpFolderSource,folderSource,bytesSource,blobSource. - Catalogs and streaming:
buildCatalog,signCatalog,loadCatalog,CatalogClient(inlevels), travel with a transition. - Cache:
PersistentCachewith backends (IndexedDB, storage, memory), LRU by package, pins, quota, partials,downloadedContentItemfor a menu entry. CodePolicy: a package that carries code runs under it.- The asset library (
docs/concepts/asset-library.md): textures, PBR materials, characters and clip sets as.ferretpackages of kindassets, found by id in a catalog (/lib/ferret-assets/, orFERRET_ASSETS). Take from it instead of copying files out of another project:AssetLibrary(inlevels) withlist,material(id, { variant }),texture(id),character(id, { tier }),preload; the viewer's?libraryshows every item. Items are built from UE exports bytools/asset-lib/make.mjs, never by hand. - Running code:
code.entryinferret.json(one bundled ES module undercode/exportinginstall(ctx)),installCode/CodeLoader.require(id)(dependencies first, policy, sha256 of the module,installonce; the engine comes asctx.ferret, the sharedglobalThis.Ferret), commandspkg.requireandpkg.loaded.
Steps to publish#
- Pack the level folder with
packPackage(see API reference for options). - Sign with a developer key; the owner of the keys signs and encrypts, an agent only prepares unsigned drafts.
- Build and sign a catalog if levels are fetched remotely.
- Load with
installPackages; the loader checks signatures, hashes and paths before anything is used.
Check afterwards#
validatePackage is clean; a tampered file is refused; a second load is served from the cache; quota errors are handled (QuotaError).
What usually goes wrong#
- Putting private keys in the repo or in a draft; keys are the developer's.
- Paths with
..or absolute paths in the manifest: refused by the loader by design. - A package with code and no
CodePolicydecision. - Assuming the cache is unlimited: it evicts by package and has a quota.
Files#
reference/levels.md— The level manifest, the level registry and travel, environment, and the .ferret package format.reference/api-assets.md— every export of@ferret/assetswith signature and doc commentreference/api-assets-2.md— every export of@ferret/assetswith signature and doc commentreference/api-levels.md— every export of@ferret/levelswith signature and doc commentreference/api-levels-2.md— every export of@ferret/levelswith signature and doc commentreference/commands.md— 39 commands of these packages with their arguments