Repository Public
1<!--2ORIX Sonata3File: Documentation/manual/packages.md4Author: Simon-Pierre Boucher5Contact: contact@spboucher.ai6-->7# Packages89A package is a folder of Sonata modules that several projects can share: patterns, functions,10instrument definitions. Packages are plain files. Nothing in a package is ever executed: there11is no install script, and a package can only contain Sonata sources and documentation.1213## Layout1415```16riffs/17 package.json name, version, license, dependencies18 src/blues.sonata modules: `import riffs.blues`19 examples/*.sonata optional20 tests/*.sonata optional21 docs/*.md README* LICENSE* CHANGELOG.md optional22```2324```json25{26 "name": "riffs",27 "version": "1.0.0",28 "license": "MIT",29 "description": "Two blues riffs",30 "dependencies": { "scales": "^1.2.0" }31}32```3334Names are lower-case letters, digits and `_`, starting with a letter (they are the first word of35an `import`). Versions are `MAJOR.MINOR.PATCH`, optionally with a pre-release tag (`1.0.0-rc.1`).36A dependency requirement is an exact version, `^1.2.0` (compatible), `~1.2.0` (patches only),37`>=1.2.0` or `*`. A license is required.3839## Commands4041```bash42sonata pkg pack riffs # writes riffs-1.0.0.sonatapkg after compiling every module43sonata pkg verify riffs-1.0.0.sonatapkg # structure, manifest, every file against its hash44sonata pkg install riffs-1.0.0.sonatapkg --project MySong.sonataproject45sonata pkg list --project MySong.sonataproject46sonata pkg check --project MySong.sonataproject # tampering, missing files, unmet dependencies47sonata pkg remove riffs --project MySong.sonataproject48sonata pkg resolve riffs@^1.0.0 --from ~/Packages --project MySong.sonataproject49```5051`--project` is the folder that receives `packages/` and `sonata.lock`; without it, the current52folder. A source compiled from that folder (or a project package) can then write:5354```text55import riffs.blues56```5758The project's own modules are looked up first, then installed packages.5960## What is guaranteed6162- **Reproducible archives.** Packing the same folder twice gives the same bytes: files are63 sorted, timestamps and owners are fixed.64- **Verified content.** Every file is listed with its SHA-256 in `MANIFEST.sha256`; `verify`,65 `install` and `check` compare each file to it. `sonata.lock` records the SHA-256 of each66 installed archive.67- **Safe extraction.** An archive is refused as a whole if it contains a link, a device, an68 absolute path, `..`, a hidden file, a file outside the allowed folders, a duplicate, a file69 over 4 MiB, more than 2000 entries or more than 64 MiB in total. Nothing is written before the70 whole archive has passed.71- **Atomic installation.** Files are written beside the destination and moved into place in one72 step; an installed package is replaced only with `--force`.73- **Deterministic resolution.** `resolve` picks, for each package, the highest version that74 satisfies every requirement, whatever the order of the files in the folder; one version per75 package; a conflict is an error that names who requires what.7677## What does not exist7879There is no remote registry and no download: packages come from files you have. Pre-release80versions are chosen only when a requirement names one. Packages cannot carry audio samples in81this version.82